141 lines
645 KiB
JavaScript
141 lines
645 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-basics-profile-detail~pages-index-monitor"],{1424:function(e,t,r){var i=r("99b7");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var s=r("4f06").default;s("5710a488",i,!0,{sourceMap:!1,shadowMode:!1})},"1d2a":function(e,t,r){"use strict";var i;r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return n})),r.d(t,"a",(function(){return i}));var s=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("v-uni-view",{staticClass:"h-full w-full"},[e.address?r("LiveVideo",{key:e.address,attrs:{url:e.address,type:e.type}}):e._e()],1)},n=[]},2222:function(e,t,r){"use strict";r.r(t);var i=r("e2e5"),s=r.n(i);for(var n in i)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return i[e]}))}(n);t["default"]=s.a},2931:function(e,t,r){"use strict";r.r(t);var i=r("1d2a"),s=r("e52e");for(var n in s)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return s[e]}))}(n);var a,o=r("f0c5"),l=Object(o["a"])(s["default"],i["b"],i["c"],!1,null,null,null,!1,i["a"],a);t["default"]=l.exports},"2cb3":function(e,t,r){"use strict";r.r(t);var i=r("d4f6"),s=r("2222");for(var n in s)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return s[e]}))}(n);r("75f3");var a,o=r("f0c5"),l=Object(o["a"])(s["default"],i["b"],i["c"],!1,null,"4c4d4f71",null,!1,i["a"],a);t["default"]=l.exports},3315:function(e,t,r){var i=r("758e");i.__esModule&&(i=i.default),"string"===typeof i&&(i=[[e.i,i,""]]),i.locals&&(e.exports=i.locals);var s=r("4f06").default;s("782d27be",i,!0,{sourceMap:!1,shadowMode:!1})},"3c35":function(e,t){(function(t){e.exports=t}).call(this,{})},4362:function(e,t,r){t.nextTick=function(e){var t=Array.prototype.slice.call(arguments);t.shift(),setTimeout((function(){e.apply(null,t)}),0)},t.platform=t.arch=t.execPath=t.title="browser",t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(e){throw new Error("No such module. (Possibly not yet loaded)")},function(){var e,i="/";t.cwd=function(){return i},t.chdir=function(t){e||(e=r("df7c")),i=e.resolve(t,i)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},"758e":function(e,t,r){var i=r("4bad");t=i(!1),t.push([e.i,'/*!\n* Mui Player Css Library v1.8.1 @Professional edition\n* Date:2023-01-28\n* Released under GPL-3.0 license\n* https://muiplayer.js.org/\n*/.m-player{width:auto;height:225px;position:relative;overflow:hidden;background:#000;outline:none;-webkit-font-smoothing:antialiased;font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.m-player .mplayer-footer{color:#fff;position:absolute;bottom:0;right:0;left:0;background:linear-gradient(180deg,hsla(0,0%,100%,0),rgba(0,0,0,.65));-webkit-transform:translateY(50px);transform:translateY(50px);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;z-index:7;height:48px;padding:0 10px}.m-player .mplayer-footer.show{-webkit-transform:translateY(0)!important;transform:translateY(0)!important}.m-player .mplayer-footer .progress{display:flex;align-items:center;justify-content:space-between;height:inherit}.m-player .mplayer-footer .progress .progress-container{display:flex;align-items:center;flex:1;height:25px}.m-player .mplayer-footer .progress .progress-container.upper-position{position:absolute;left:20px;right:20px;bottom:100%;margin-bottom:-10.5px}.m-player .mplayer-footer .progress .progress-container .touch-effective{position:relative;height:100%;display:flex;flex:1;align-items:center;margin-left:8px;margin-right:8px;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-default-scale{border-radius:0!important;-webkit-transform:translateY(-50%) translateZ(0) scaleY(2)!important;transform:translateY(-50%) translateZ(0) scaleY(2)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-hover-scale{-webkit-transform:translateY(-50%) translateZ(0) scaleY(3)!important;transform:translateY(-50%) translateZ(0) scaleY(3)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-total{width:100%;background-color:hsla(0,0%,100%,.2);overflow:hidden}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-play,.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-total{position:absolute;height:2px;border-radius:5px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-buffered{background-color:hsla(0,0%,71%,.7);position:absolute;height:2px;border-top-left-radius:5px;border-bottom-left-radius:5px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:width .15s,-webkit-transform;transition:transform,width .15s;transition:transform,width .15s,-webkit-transform}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-prompt{position:absolute;height:2px;width:9px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;z-index:6}.m-player .mplayer-footer .progress .progress-container .touch-effective .progress-seekline{position:absolute;background-color:#ddd;height:2px;width:3px;top:50%;-webkit-transform:scaleY(.9) translateY(-50%);transform:scaleY(.9) translateY(-50%);transition:left 0s linear;z-index:5;visibility:hidden}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container{position:absolute;height:100%;width:100%}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag{height:30px;width:30px;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);transition:-webkit-transform .15s;transition:transform .15s;transition:transform .15s,-webkit-transform .15s;z-index:7}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag.hover-scale,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag.hover-scale{-webkit-transform:translate(-50%,-50%) scale(1)!important;transform:translate(-50%,-50%) scale(1)!important}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag.default-scale,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag.default-scale{-webkit-transform:translate(-50%,-50%) scale(0);transform:translate(-50%,-50%) scale(0)}.m-player .mplayer-footer .progress .progress-container .touch-effective .ball-container .progress-drag .progress-ball,.m-player .mplayer-footer .progress .progress-container .touch-effective .prompts-container .progress-drag .progress-ball{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);height:17px;width:17px;border-radius:50%;display:inline-block;background:#fff}.m-player .mplayer-footer .progress .progress-begin{font-size:13px;min-width:40px;text-align:left}.m-player .mplayer-footer .progress .progress-long{font-size:13px;min-width:40px;text-align:right}.m-player .mplayer-footer .progress .left-part,.m-player .mplayer-footer .progress .right-part{display:flex;height:inherit}.m-player .mplayer-footer .progress .left-part .footer-control,.m-player .mplayer-footer .progress .right-part .footer-control{position:relative}.m-player .mplayer-footer .progress .left-part .footer-control:not(.no-active):active,.m-player .mplayer-footer .progress .right-part .footer-control:not(.no-active):active{opacity:.75}.m-player .mplayer-footer .progress .left-part .footer-control svg,.m-player .mplayer-footer .progress .right-part .footer-control svg{vertical-align:middle}.m-player .mplayer-footer .progress .panel-controls{position:absolute;min-height:50px;bottom:50px;padding:12px;background-color:rgba(0,0,0,.6);border-radius:3px}.m-player .mplayer-footer .progress .live-mode{color:#fff;position:relative;font-size:14px;width:auto;white-space:nowrap}.m-player .mplayer-footer .progress .live-mode .spot{width:6px;height:6px;border-radius:50%;background:#1e98d4;margin-right:5px;display:inline-block;vertical-align:middle}.m-player .mplayer-footer .progress .live-mode .mode-text{display:inline-block;vertical-align:middle}.m-player .mplayer-header{background:linear-gradient(180deg,rgba(0,0,0,.5),hsla(0,0%,100%,0));padding:0 10px;height:60px;position:absolute;top:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;-webkit-transform:translateY(-50px);transform:translateY(-50px);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;z-index:7}.m-player .mplayer-header.show{-webkit-transform:translateY(0)!important;transform:translateY(0)!important}.m-player .mplayer-header .title-groupt{height:100%}.m-player .mplayer-header .title-groupt .back-button{white-space:nowrap;width:auto}.m-player .mplayer-header .title-groupt .back-button div,.m-player .mplayer-header .title-groupt .back-button svg{vertical-align:middle}.m-player .mplayer-header .title-groupt .back-button .title-name{position:relative;color:#fff;margin-left:5px;display:inline-block}.m-player .mplayer-header .buttom-group{display:flex;height:100%}.m-player .mplayer-header .buttom-group .battery-info{display:flex;flex-direction:column;align-items:center;justify-content:center;-webkit-transform:scale(.75);transform:scale(.75);-webkit-transform-origin:right;transform-origin:right}.m-player .mplayer-header .buttom-group .battery-info .time{color:#fff;font-size:14px;position:relative;top:4px;right:0}.m-player .mplayer-header .buttom-group .battery-info .capacity{border:1px solid #fff;height:11px;width:24px;border-radius:2px;position:relative}.m-player .mplayer-header .buttom-group .battery-info .capacity:after{content:"";height:7px;width:2px;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);border-right:none;border-top-left-radius:3px;border-bottom-left-radius:3px;left:-3px;background:#fff}.m-player .mplayer-header .buttom-group .battery-info .capacity .level{position:absolute;top:1px;bottom:1px;left:1px;right:1px}.m-player .mplayer-header .buttom-group .battery-info .capacity .level .count{background:#fff;height:100%;width:0;float:right;border-top-right-radius:1px;border-bottom-right-radius:1px}.m-player .mplayer-sidebar{display:block;position:absolute;top:0;bottom:0;right:0;background-color:rgba(0,0,0,.75);z-index:8;-webkit-transform:translateX(100%);transform:translateX(100%);transition:-webkit-transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease;overflow:auto}.m-player .mplayer-sidebar.open{-webkit-transform:none!important;transform:none!important}.m-player .mplayer-sidebar::-webkit-scrollbar{width:4px;background:transparent}.m-player .mplayer-sidebar::-webkit-scrollbar-thumb{background:rgba(230,230,250,.24);border-radius:3px;height:100px}.m-player .mplayer-sidebar .title{color:#9a9e98;font-size:15px;line-height:40px;position:relative;margin-left:20px;margin-right:50px;text-align:left}.m-player .mplayer-sidebar .title:before{content:"";border-bottom:1px solid hsla(0,0%,87%,.3);position:absolute;left:0;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.m-player .mplayer-sidebar .setting-box{font-size:15px;color:#fff;display:flex;flex-wrap:wrap;align-items:center;margin:15px 50px 20px 20px}.m-player .mplayer-sidebar .setting-box .box-name{margin-left:12px;flex:1;text-align:left}.m-player .mplayer-sidebar .setting-box .toogle-switch{margin-left:12px;cursor:pointer;border-radius:50px;width:45px;height:22px;position:relative;transition:background-color .2s ease-in}.m-player .mplayer-sidebar .setting-box .toogle-switch.open .ball{right:3px}.m-player .mplayer-sidebar .setting-box .toogle-switch.close{background-color:hsla(0,0%,100%,.3)!important}.m-player .mplayer-sidebar .setting-box .toogle-switch.close .ball{right:24px}.m-player .mplayer-sidebar .setting-box .toogle-switch .ball{border-radius:50px;height:18px;width:18px;border-radius:50%;background:#fff;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:right .2s ease-in}.m-player .mplayer-sidebar .setting-box .toogle-switch .disable{position:absolute;top:0;bottom:0;right:0;left:0;border-radius:50px;background:rgba(0,0,0,.6)}.m-player .mplayer-sidebar .setting-box .play-speed{cursor:pointer;font-size:16px;height:35px;width:48px;display:flex;justify-content:center;align-items:center;border-radius:5px;margin-right:4px;flex-shrink:0}.m-player .mplayer-sidebar .setting-box .share-box{cursor:pointer;height:45px;width:45px;display:flex;justify-content:center;align-items:center;margin-right:22px;margin-bottom:12px;flex-shrink:0}.m-player .mp-tooltip{position:absolute;font-size:12px;white-space:nowrap;background-color:rgba(0,0,0,.73);padding:3px 10px;display:block;color:#fff;z-index:9;border-radius:3px;pointer-events:none}.m-player .player-btn{position:relative;cursor:pointer;border:none;background-color:initial;padding:0;padding:0 11px;outline:0;width:45px;min-width:45px;height:inherit;font-size:14px}.m-player .player-btn:focus{outline:none}.m-player .player-btn::-moz-focus-inner{border:0;outline:0}.m-player .mplayer-poster{position:absolute;top:0;bottom:0;left:0;right:0;background:#000}.m-player .mplayer-poster:before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background:rgba(0,0,0,.4)}.m-player .mplayer-cover{position:absolute;top:0;bottom:0;left:0;right:0;background:#000;z-index:8;opacity:0;transition:opacity .2s;pointer-events:none}.m-player .mplayer-time{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:8;opacity:0}.m-player .mplayer-time .time{color:#fff;font-size:26px;text-align:center;white-space:nowrap}.m-player .mplayer-time .time-progress{margin:auto;height:3px;background:hsla(0,0%,100%,.6);width:180px;border-radius:50px;margin-top:9px;overflow:hidden}.m-player .mplayer-time .time-progress .time-total{background:#fff;height:100%;width:50%;border-top-left-radius:50px;border-bottom-left-radius:50px}.m-player .small-control{height:32px;position:absolute;width:143px;top:15%;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);border-radius:50px;background-color:rgba(0,0,0,.55);display:flex;align-items:center;justify-content:center;opacity:0;z-index:7}.m-player .small-control .progress{border-radius:50px;overflow:hidden;height:3px;width:96px;background:hsla(0,0%,87%,.85);margin-left:6px}.m-player .small-control .progress .total{width:50%;height:100%;background:#fff}.m-player .mplayer-loading{color:#1e98d4;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);max-width:100%;max-height:100%;display:none;z-index:8}@-webkit-keyframes mp-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes mp-rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@-webkit-keyframes mp-circular{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-40}to{stroke-dasharray:90,150;stroke-dashoffset:-120}}@keyframes mp-circular{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-40}to{stroke-dasharray:90,150;stroke-dashoffset:-120}}.m-player .mplayer-loading .mplayer-loading__circular{width:40px;height:40px;-webkit-animation:mp-rotate 1.8s linear infinite;animation:mp-rotate 1.8s linear infinite}.m-player .mplayer-loading .mplayer-loading__circular circle{-webkit-animation:mp-circular 1.5s ease-in-out infinite;animation:mp-circular 1.5s ease-in-out infinite;stroke:currentColor;stroke-width:3;stroke-linecap:round}.m-player .mplayer-toast{padding:7px 12px;background-color:rgba(80,80,77,.9);position:absolute;bottom:18%;color:#fff;border-radius:50px;font-size:14px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);-webkit-animation:mplayerToast .25s;animation:mplayerToast .25s;z-index:10}@-webkit-keyframes mplayerToast{0%{bottom:-18%}to{bottom:18%}}@keyframes mplayerToast{0%{bottom:-18%}to{bottom:18%}}.m-player .mplayer-left{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:left .3s;opacity:0;z-index:7}.m-player .mplayer-left ._unlock,.m-player .mplayer-left .control-icon ._lock{height:38px;width:38px;border-radius:50%;background-color:rgba(0,0,0,.3);display:flex;justify-content:center;align-items:center;cursor:pointer}.m-player .mplayer-error{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);color:#fff;z-index:10;font-size:13px;text-align:center;display:none;opacity:1;-webkit-animation:mplayerError .7s;animation:mplayerError .7s}@-webkit-keyframes mplayerError{0%{opacity:0}to{opacity:1}}@keyframes mplayerError{0%{opacity:0}to{opacity:1}}.m-player .mplayer-error .errop-tip{height:25px}.m-player .mplayer-error:active{opacity:.75}.m-player .mini-progress{height:2px;position:absolute;bottom:0;left:0;right:0;-webkit-transform:translateY(.3px);transform:translateY(.3px);opacity:0;z-index:7}.m-player .mini-progress .mini-total{position:absolute;background-color:hsla(0,0%,100%,.2);width:100%;height:100%}.m-player .mini-progress .mini-buffered{position:absolute;background-color:hsla(0,0%,71%,.5);height:100%}.m-player .mini-progress .mini-play{position:absolute;height:100%}@-webkit-keyframes mp-bezel-fadeout{0%{opacity:1}to{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}}@keyframes mp-bezel-fadeout{0%{opacity:1}to{opacity:0;-webkit-transform:scale(1.5);transform:scale(1.5)}}.m-player .mp-bezel-text-hide .mp-bezel{z-index:10;position:absolute;left:50%;top:50%;width:52px;height:52px;margin-left:-26px;margin-top:-26px;background:rgba(0,0,0,.6);border-radius:26px;-webkit-animation:mp-bezel-fadeout .4s linear 1 normal forwards;animation:mp-bezel-fadeout .4s linear 1 normal forwards;pointer-events:none}.m-player .mp-bezel-text-hide .mp-bezel .mp-bezel-icon{width:24px;height:24px;margin:14px}.m-player .mp-bezel-text-hide .mp-bezel .mp-bezel-icon .mp-svg-shadow{stroke:#000;stroke-opacity:.15;stroke-width:2px;fill:none}.m-player .ctxmenu-wrapper{position:absolute;top:0;bottom:0;left:0;right:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:none}.m-player .ctxmenu-wrapper .ctxmenulist{text-align:left;position:absolute;list-style:none;font-size:14px;background:rgba(28,28,28,.9);text-shadow:0 0 2px rgba(0,0,0,.5);color:#eee;border-radius:2px;margin:0;padding:0;min-width:170px;transition:opacity .1s;opacity:0;outline:0;z-index:9}.m-player .ctxmenu-wrapper .ctxmenulist li{padding:9px 30px;cursor:pointer}.m-player .ctxmenu-wrapper .ctxmenulist li:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.m-player .ctxmenu-wrapper .ctxmenulist li:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.m-player .ctxmenu-wrapper .ctxmenulist li:hover{background-color:hsla(0,0%,100%,.1)}.m-player .mplayer-shortcut{text-align:left;font-size:16px;background:rgba(28,28,28,.9);text-shadow:0 0 2px rgba(0,0,0,.5);color:#eee;border-radius:3px;padding:15px 0 15px 20px;position:absolute;top:10px;left:10px;z-index:8;display:none;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;width:430px;max-width:calc(100% - 40px)}.m-player .mplayer-shortcut .title{margin:0;padding-bottom:10px}.m-player .mplayer-shortcut .close-shortcut-panel{position:absolute;top:15px;right:15px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:24px;height:24px}.m-player .mplayer-shortcut .close-shortcut-panel:active{opacity:.8}.m-player .mplayer-shortcut ul{list-style:none;margin:0 0 2px;padding:0;font-size:14px}.m-player .mplayer-shortcut ul li{display:inline-block;height:28px;line-height:28px;width:50%}.m-player .mplayer-shortcut ul li span{color:#999}.m-player .mp-popup-animation{transition:all .25s cubic-bezier(0,0,.2,1)}.m-player .popup-toggle{transition:opacity .1s cubic-bezier(0,0,.2,1)!important}.m-player .mp-popup{border-radius:2px;overflow:hidden;position:absolute;font-size:13px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;will-change:width,height;background:rgba(28,28,28,.9);opacity:0;min-width:42px}.m-player .mp-popup .mp-panel{min-width:260px}.m-player .mp-popup .mp-panel.mp-panel-child .mp-menuitem{padding-left:14.5%}.m-player .mp-popup .mp-panel.mp-panel-item{position:absolute;bottom:0;right:0;overflow-y:auto;overflow-x:hidden}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar{width:8px;background-color:#424242}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar-thumb{background-color:#8e8e8e;border:1px solid #424242;border-radius:3px}.m-player .mp-popup .mp-panel.mp-panel-item::-webkit-scrollbar-track{background-color:#424242}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-selected{background-size:8%;background-repeat:no-repeat;background-position:4%;vertical-align:middle;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTkgMTYuMkw0LjggMTJsLTEuNCAxLjRMOSAxOSAyMSA3bC0xLjQtMS40TDkgMTYuMnoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=)}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-header{height:50px;padding-left:0;line-height:50px}.m-player .mp-popup .mp-panel.mp-panel-item .mp-panel-header:before{content:"";position:absolute;border-bottom:1px solid #fff;left:0;right:0;bottom:0;-webkit-transform:scaleY(.5);transform:scaleY(.5);opacity:.2;z-index:100}.m-player .mp-popup .mp-panel .mp-menuitem{position:relative;list-style:none;color:#eee;margin:0;padding:0;display:flex;justify-content:space-between;align-items:center;padding-left:10%;height:40px;line-height:40px;white-space:nowrap;outline:none}.m-player .mp-popup .mp-panel .mp-menuitem:not(.mp-panel-header){cursor:pointer}.m-player .mp-popup .mp-panel .mp-menuitem:not(.mp-panel-header):hover{background-color:hsla(0,0%,100%,.1)}.m-player .mp-popup .mp-panel .mp-menuitem li{height:inherit;width:50%}.m-player .mp-popup .mp-panel .mp-menuitem li:first-child{padding-right:40px;white-space:pre;overflow:hidden;text-overflow:ellipsis;text-align:left}.m-player .mp-popup .mp-panel .mp-menuitem li:last-child{text-align:right}.m-player .mp-popup .mp-panel .mp-menuitem li .mp-menuitem-content{height:inherit}.m-player .mp-popup .mp-panel .mp-menuitem li .arrow-icon{background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHBhdGggZD0iTTEyLjU5IDIwLjM0bDQuNTgtNC41OS00LjU4LTQuNTlMMTQgOS43NWw2IDYtNiA2eiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==);background-size:35%;background-repeat:no-repeat;background-position:100%;vertical-align:middle;padding-right:35%}.m-player .mp-popup .mp-panel .mp-menuitem li .left-arrow-icon{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PHBhdGggZD0iTTE5LjQxIDIwLjA5bC00LjU4LTQuNTkgNC41OC00LjU5TDE4IDkuNWwtNiA2IDYgNnoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=);background-repeat:no-repeat;background-position:0;background-size:30%;padding-left:30%;text-align:left;cursor:pointer}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch{cursor:pointer;border-radius:50px;width:41px;height:20px;position:relative;display:inline-block;transition:background-color .2s ease-in;vertical-align:middle;right:13%}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch.close{background-color:hsla(0,0%,100%,.3)!important}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch.open .ball{right:4.83%}.m-player .mp-popup .mp-panel .mp-menuitem li .toogle-switch .ball{border-radius:50px;height:16px;width:16px;border-radius:50%;background:#fff;position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);transition:right .15s ease-in;right:56.46%}.m-player .volume-container{width:100%;height:100%;border-radius:2px;color:#fff;text-align:center;outline:0;font-size:12px;padding-top:8px;padding-bottom:8px}.m-player .volume-container .volume-size{color:#fff}.m-player .volume-container .volume-capacity{cursor:pointer;height:100px;width:4px;background-color:#373838;border-radius:7px;margin:25% auto 0;position:relative}.m-player .volume-container .volume-capacity .volume-drag-ball{background-color:#fff;width:14px;height:14px;border-radius:50%;position:absolute;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);bottom:0;z-index:7}.m-player .volume-container .volume-capacity .progress-bar{border-radius:7px;position:absolute;bottom:0;left:0;right:0;height:0}.m-player .danmaku-controls{display:flex;flex-direction:row;align-items:center;font-size:12px;flex:0.65;margin:auto .82%}.m-player .danmaku-controls .dms-button:active{cursor:pointer;opacity:.85}.m-player .danmaku-controls .danmaku-input-wrap{position:relative;width:auto;height:34px;background-color:#111226;flex:1;flex-shrink:0;border-radius:50px;background:hsla(0,0%,100%,.25);color:#fff;margin-left:1.2%;display:flex}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text{height:100%;border:0;left:0;border-radius:50px 0 0 50px;flex:1;padding:0;margin:0;outline:0;background-color:initial;padding:0 12px;color:#fff;font-size:14px;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-webkit-input-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-moz-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::-ms-input-placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-input-text::placeholder{color:#ddd;text-shadow:0 0 4px rgba(0,0,0,.75)}.m-player .danmaku-controls .danmaku-input-wrap .dms-btn-submit{top:0;right:0;width:66px;height:100%;border:none;border-radius:0 50px 50px 0;outline:0;background-color:#292a3c;color:#eee;cursor:pointer;margin-left:8px;position:relative}.m-player .danmaku-controls .danmaku-input-wrap .dms-btn-submit span{display:inline-block;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.m-player .mp-rolling{position:absolute;top:0;width:100%;color:#fff;overflow:hidden;z-index:6;-webkit-transform-origin:right;transform-origin:right}.m-player .mp-rolling .rolling-content{position:relative;white-space:nowrap;display:inline-block}.m-player .mp-logot-box{position:absolute;width:100%;height:100%;left:50%;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);pointer-events:none;z-index:6}@-webkit-keyframes mp-logot-show{0%{opacity:.1}to{opacity:1}}@keyframes mp-logot-show{0%{opacity:.1}to{opacity:1}}.m-player .mp-logot-box .mp-logot{position:absolute;background-repeat:no-repeat;background-size:contain;opacity:0;-webkit-animation:mp-logot-show .35s linear both;animation:mp-logot-show .35s linear both;image-rendering:-moz-crisp-edges;image-rendering:-o-crisp-edges;image-rendering:-webkit-optimize-contrast;image-rendering:crisp-edges;-ms-interpolation-mode:nearest-neighbor}.m-player .mp-logot-box .mp-logot.logot-top-right{right:1.5%;top:3%;-webkit-transform-origin:top right;transform-origin:top right}.m-player .mp-logot-box .mp-logot.logot-top-left{left:1.5%;top:3%;-webkit-transform-origin:top left;transform-origin:top left}.m-player .mp-logot-box .mp-logot.logot-bottom-left{left:1.5%;bottom:3%;-webkit-transform-origin:bottom left;transform-origin:bottom left}.m-player .mp-logot-box .mp-logot.logot-bottom-right{right:1.5%;bottom:3%;-webkit-transform-origin:bottom right;transform-origin:bottom right}.m-player .advertise-wrap{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);z-index:7;width:320px;height:240px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;overflow:hidden;background:rgba(0,0,0,.65);max-height:calc(100% - 40px);max-width:calc(100% - 40px);box-shadow:0 2px 5px 0 rgba(0,0,0,.16)}.m-player .advertise-wrap .ad-tip{position:absolute;bottom:3px;left:3px;display:inline-block;cursor:auto;height:20px;margin:0 2px 0 0;padding:0 4px;line-height:20px;font-size:12px;color:#fff;background:rgba(0,0,0,.5);border-radius:2px}.m-player .advertise-wrap .ad-close{position:absolute;right:4px;top:4px;cursor:pointer}.m-player .advertise-wrap .ad-close .ad-icon{width:18px;height:18px;padding:3px;border-radius:100%;vertical-align:middle;background:rgba(0,0,0,.5)}.m-player .advertise-wrap .ad-close .ad-icon path{transition:fill .3s}.m-player:-webkit-full-screen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player:-webkit-full-screen uni-video{position:relative}.m-player.browser-fullscreen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player.browser-fullscreen uni-video{position:relative}.m-player.page-fullscreen{position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:0!important;box-sizing:border-box!important;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important;width:100%!important;height:100%!important;-webkit-transform:none!important;transform:none!important;margin:0!important;padding:0!important;z-index:1000!important}.m-player.page-fullscreen uni-video{position:relative}.m-player.mp-keyboard-focus .keyboard-input:focus,.m-player.mp-keyboard-focus .mp-menuitem:focus{box-shadow:inset 0 0 0 2px rgba(27,127,204,.8)}.m-player .player-wrapper{height:100%;width:100%;position:relative}.m-player .player-wrapper.mplayer-miniwindow{position:fixed;transition-property:width,height,opacity,bottom,right,border-radius;will-change:bottom,right,border-radius;overflow:hidden;z-index:1000;border-radius:0;opacity:1;background:#000;box-shadow:0 2px 5px 0 rgba(0,0,0,.16)}.m-player .player-wrapper.mplayer-miniwindow.transition-disable{transition-property:none;cursor:move}.m-player .player-wrapper.mplayer-miniwindow .element-hidden,.m-player .player-wrapper.mplayer-miniwindow .mp-popup{visibility:hidden}.m-player .player-wrapper.mplayer-miniwindow uni-video{width:100%!important;height:100%!important}.m-player .player-wrapper.mplayer-miniwindow .scrim-layer{position:absolute;height:100%;width:100%;top:0;z-index:7;background-color:initial;transition-property:background-color;transition-duration:.08s;transition-timing-function:linear}.m-player .player-wrapper .video-wrapper{height:100%;display:flex;justify-content:center;align-items:center}.m-player .player-wrapper .video-wrapper uni-video{-o-object-fit:contain;object-fit:contain;display:block;opacity:0}.m-player .player-wrapper .video-wrapper uni-video.covered{height:100%!important;width:100%!important;-o-object-fit:cover;object-fit:cover}.m-player .player-wrapper .video-wrapper uni-video::cue{color:#fff;background:transparent;text-shadow:0 0 1px #000}.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-text-track-display{margin-top:-5px}.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-overlay-play-button,.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-start-playback-button,.m-player .player-wrapper .video-wrapper uni-video::-webkit-media-controls-volume-slider,.m-player .player-wrapper .video-wrapper uni-video uni-video::-webkit-media-controls-mute-button{display:none}',""]),e.exports=t},"75f3":function(e,t,r){"use strict";var i=r("1424"),s=r.n(i);s.a},"99b7":function(e,t,r){var i=r("4bad");t=i(!1),t.push([e.i,'@charset "UTF-8";\n/**\n * 这里是uni-app内置的常用样式变量\n *\n * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量\n * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App\n *\n */\n/**\n * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能\n *\n * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件\n */\n/* 颜色变量 */\n/* 行为相关颜色 */\n/* 文字基本颜色 */\n/* 背景颜色 */\n/* 边框颜色 */\n/* 尺寸变量 */\n/* 文字尺寸 */\n/* 图片尺寸 */\n/* Border Radius */\n/* 水平间距 */\n/* 垂直间距 */\n/* 透明度 */\n/* 文章场景相关 */.video-box[data-v-4c4d4f71]{width:100%;padding-top:56.2%}',""]),e.exports=t},a567:function(e,t,r){"use strict";function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}r.r(t),r.d(t,"AbrController",(function(){return oi})),r.d(t,"AttrList",(function(){return w})),r.d(t,"AudioStreamController",(function(){return En})),r.d(t,"AudioTrackController",(function(){return bn})),r.d(t,"BasePlaylistController",(function(){return Gr})),r.d(t,"BaseSegment",(function(){return P})),r.d(t,"BaseStreamController",(function(){return Bi})),r.d(t,"BufferController",(function(){return kn})),r.d(t,"CMCDController",(function(){return $o})),r.d(t,"CapLevelController",(function(){return Ma})),r.d(t,"ChunkMetadata",(function(){return mi})),r.d(t,"ContentSteeringController",(function(){return jo})),r.d(t,"DateRange",(function(){return I})),r.d(t,"EMEController",(function(){return Ba})),r.d(t,"ErrorActionFlags",(function(){return Ur})),r.d(t,"ErrorController",(function(){return $r})),r.d(t,"ErrorDetails",(function(){return y})),r.d(t,"ErrorTypes",(function(){return g})),r.d(t,"Events",(function(){return m})),r.d(t,"FPSController",(function(){return Fa})),r.d(t,"Fragment",(function(){return O})),r.d(t,"Hls",(function(){return Ll})),r.d(t,"HlsSkip",(function(){return lr})),r.d(t,"HlsUrlParameters",(function(){return hr})),r.d(t,"KeySystemFormats",(function(){return H})),r.d(t,"KeySystems",(function(){return K})),r.d(t,"Level",(function(){return cr})),r.d(t,"LevelDetails",(function(){return N})),r.d(t,"LevelKey",(function(){return et})),r.d(t,"LoadStats",(function(){return x})),r.d(t,"MetadataSchema",(function(){return Wt})),r.d(t,"NetworkErrorAction",(function(){return Br})),r.d(t,"Part",(function(){return M})),r.d(t,"PlaylistLevelType",(function(){return Bt})),r.d(t,"SubtitleStreamController",(function(){return Tn})),r.d(t,"SubtitleTrackController",(function(){return An})),r.d(t,"TimelineController",(function(){return Ia})),r.d(t,"default",(function(){return Ll})),r.d(t,"getMediaSource",(function(){return lt})),r.d(t,"isMSESupported",(function(){return pl})),r.d(t,"isSupported",(function(){return ml}));var s={exports:{}};(function(e,t){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),t=t.trim(),!t){if(!r.alwaysNormalize)return e;var s=a.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=a.normalizePath(s.path),a.buildURLFromParts(s)}var n=a.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=a.normalizePath(n.path),a.buildURLFromParts(n)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(d.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var h=o.path,c=h.substring(0,h.lastIndexOf("/")+1)+n.path;d.path=a.normalizePath(c)}else d.path=o.path,n.params||(d.params=o.params,n.query||(d.query=o.query));return null===d.path&&(d.path=r.alwaysNormalize?a.normalizePath(n.path):n.path),a.buildURLFromParts(d)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){e=e.split("").reverse().join("").replace(s,"");while(e.length!==(e=e.replace(n,"")).length);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a})()})(s);var n=s.exports;function a(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 o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function d(e){var t=l(e,"string");return"symbol"==typeof t?t:String(t)}function h(e,t,r){return t=d(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c.apply(this,arguments)}const u=Number.isFinite||function(e){return"number"===typeof e&&isFinite(e)},f=Number.isSafeInteger||function(e){return"number"===typeof e&&Math.abs(e)<=p},p=Number.MAX_SAFE_INTEGER||9007199254740991;let m=function(e){return e["MEDIA_ATTACHING"]="hlsMediaAttaching",e["MEDIA_ATTACHED"]="hlsMediaAttached",e["MEDIA_DETACHING"]="hlsMediaDetaching",e["MEDIA_DETACHED"]="hlsMediaDetached",e["BUFFER_RESET"]="hlsBufferReset",e["BUFFER_CODECS"]="hlsBufferCodecs",e["BUFFER_CREATED"]="hlsBufferCreated",e["BUFFER_APPENDING"]="hlsBufferAppending",e["BUFFER_APPENDED"]="hlsBufferAppended",e["BUFFER_EOS"]="hlsBufferEos",e["BUFFER_FLUSHING"]="hlsBufferFlushing",e["BUFFER_FLUSHED"]="hlsBufferFlushed",e["MANIFEST_LOADING"]="hlsManifestLoading",e["MANIFEST_LOADED"]="hlsManifestLoaded",e["MANIFEST_PARSED"]="hlsManifestParsed",e["LEVEL_SWITCHING"]="hlsLevelSwitching",e["LEVEL_SWITCHED"]="hlsLevelSwitched",e["LEVEL_LOADING"]="hlsLevelLoading",e["LEVEL_LOADED"]="hlsLevelLoaded",e["LEVEL_UPDATED"]="hlsLevelUpdated",e["LEVEL_PTS_UPDATED"]="hlsLevelPtsUpdated",e["LEVELS_UPDATED"]="hlsLevelsUpdated",e["AUDIO_TRACKS_UPDATED"]="hlsAudioTracksUpdated",e["AUDIO_TRACK_SWITCHING"]="hlsAudioTrackSwitching",e["AUDIO_TRACK_SWITCHED"]="hlsAudioTrackSwitched",e["AUDIO_TRACK_LOADING"]="hlsAudioTrackLoading",e["AUDIO_TRACK_LOADED"]="hlsAudioTrackLoaded",e["SUBTITLE_TRACKS_UPDATED"]="hlsSubtitleTracksUpdated",e["SUBTITLE_TRACKS_CLEARED"]="hlsSubtitleTracksCleared",e["SUBTITLE_TRACK_SWITCH"]="hlsSubtitleTrackSwitch",e["SUBTITLE_TRACK_LOADING"]="hlsSubtitleTrackLoading",e["SUBTITLE_TRACK_LOADED"]="hlsSubtitleTrackLoaded",e["SUBTITLE_FRAG_PROCESSED"]="hlsSubtitleFragProcessed",e["CUES_PARSED"]="hlsCuesParsed",e["NON_NATIVE_TEXT_TRACKS_FOUND"]="hlsNonNativeTextTracksFound",e["INIT_PTS_FOUND"]="hlsInitPtsFound",e["FRAG_LOADING"]="hlsFragLoading",e["FRAG_LOAD_EMERGENCY_ABORTED"]="hlsFragLoadEmergencyAborted",e["FRAG_LOADED"]="hlsFragLoaded",e["FRAG_DECRYPTED"]="hlsFragDecrypted",e["FRAG_PARSING_INIT_SEGMENT"]="hlsFragParsingInitSegment",e["FRAG_PARSING_USERDATA"]="hlsFragParsingUserdata",e["FRAG_PARSING_METADATA"]="hlsFragParsingMetadata",e["FRAG_PARSED"]="hlsFragParsed",e["FRAG_BUFFERED"]="hlsFragBuffered",e["FRAG_CHANGED"]="hlsFragChanged",e["FPS_DROP"]="hlsFpsDrop",e["FPS_DROP_LEVEL_CAPPING"]="hlsFpsDropLevelCapping",e["MAX_AUTO_LEVEL_UPDATED"]="hlsMaxAutoLevelUpdated",e["ERROR"]="hlsError",e["DESTROYING"]="hlsDestroying",e["KEY_LOADING"]="hlsKeyLoading",e["KEY_LOADED"]="hlsKeyLoaded",e["LIVE_BACK_BUFFER_REACHED"]="hlsLiveBackBufferReached",e["BACK_BUFFER_REACHED"]="hlsBackBufferReached",e["STEERING_MANIFEST_LOADED"]="hlsSteeringManifestLoaded",e}({}),g=function(e){return e["NETWORK_ERROR"]="networkError",e["MEDIA_ERROR"]="mediaError",e["KEY_SYSTEM_ERROR"]="keySystemError",e["MUX_ERROR"]="muxError",e["OTHER_ERROR"]="otherError",e}({}),y=function(e){return e["KEY_SYSTEM_NO_KEYS"]="keySystemNoKeys",e["KEY_SYSTEM_NO_ACCESS"]="keySystemNoAccess",e["KEY_SYSTEM_NO_SESSION"]="keySystemNoSession",e["KEY_SYSTEM_NO_CONFIGURED_LICENSE"]="keySystemNoConfiguredLicense",e["KEY_SYSTEM_LICENSE_REQUEST_FAILED"]="keySystemLicenseRequestFailed",e["KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED"]="keySystemServerCertificateRequestFailed",e["KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED"]="keySystemServerCertificateUpdateFailed",e["KEY_SYSTEM_SESSION_UPDATE_FAILED"]="keySystemSessionUpdateFailed",e["KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED"]="keySystemStatusOutputRestricted",e["KEY_SYSTEM_STATUS_INTERNAL_ERROR"]="keySystemStatusInternalError",e["MANIFEST_LOAD_ERROR"]="manifestLoadError",e["MANIFEST_LOAD_TIMEOUT"]="manifestLoadTimeOut",e["MANIFEST_PARSING_ERROR"]="manifestParsingError",e["MANIFEST_INCOMPATIBLE_CODECS_ERROR"]="manifestIncompatibleCodecsError",e["LEVEL_EMPTY_ERROR"]="levelEmptyError",e["LEVEL_LOAD_ERROR"]="levelLoadError",e["LEVEL_LOAD_TIMEOUT"]="levelLoadTimeOut",e["LEVEL_PARSING_ERROR"]="levelParsingError",e["LEVEL_SWITCH_ERROR"]="levelSwitchError",e["AUDIO_TRACK_LOAD_ERROR"]="audioTrackLoadError",e["AUDIO_TRACK_LOAD_TIMEOUT"]="audioTrackLoadTimeOut",e["SUBTITLE_LOAD_ERROR"]="subtitleTrackLoadError",e["SUBTITLE_TRACK_LOAD_TIMEOUT"]="subtitleTrackLoadTimeOut",e["FRAG_LOAD_ERROR"]="fragLoadError",e["FRAG_LOAD_TIMEOUT"]="fragLoadTimeOut",e["FRAG_DECRYPT_ERROR"]="fragDecryptError",e["FRAG_PARSING_ERROR"]="fragParsingError",e["FRAG_GAP"]="fragGap",e["REMUX_ALLOC_ERROR"]="remuxAllocError",e["KEY_LOAD_ERROR"]="keyLoadError",e["KEY_LOAD_TIMEOUT"]="keyLoadTimeOut",e["BUFFER_ADD_CODEC_ERROR"]="bufferAddCodecError",e["BUFFER_INCOMPATIBLE_CODECS_ERROR"]="bufferIncompatibleCodecsError",e["BUFFER_APPEND_ERROR"]="bufferAppendError",e["BUFFER_APPENDING_ERROR"]="bufferAppendingError",e["BUFFER_STALLED_ERROR"]="bufferStalledError",e["BUFFER_FULL_ERROR"]="bufferFullError",e["BUFFER_SEEK_OVER_HOLE"]="bufferSeekOverHole",e["BUFFER_NUDGE_ON_STALL"]="bufferNudgeOnStall",e["INTERNAL_EXCEPTION"]="internalException",e["INTERNAL_ABORTED"]="aborted",e["UNKNOWN"]="unknown",e}({});const v=function(){},_={trace:v,debug:v,log:v,warn:v,info:v,error:v};let E=_;function b(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):v}function S(e,...t){t.forEach((function(t){E[t]=e[t]?e[t].bind(e):b(t)}))}function T(e,t){if("object"===typeof console&&!0===e||"object"===typeof e){S(e,"debug","log","info","warn","error");try{E.log(`Debug logs enabled for "${t}" in hls.js version 1.5.9`)}catch(r){E=_}}else E=_}const L=E,A=/^(\d+)x(\d+)$/,R=/(.+?)=(".*?"|.*?)(?:,|$)/g;class w{constructor(e){"string"===typeof e&&(e=w.parseAttrList(e)),c(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.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;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.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=A.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={},i='"';R.lastIndex=0;while(null!==(t=R.exec(e))){let e=t[2];0===e.indexOf(i)&&e.lastIndexOf(i)===e.length-1&&(e=e.slice(1,-1));const s=t[1].trim();r[s]=e}return r}}function k(e){return"ID"!==e&&"CLASS"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function D(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class I{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]){L.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=c(new w({}),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"]);u(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(u(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&&u(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class x{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 C={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class P{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[C.AUDIO]:null,[C.VIDEO]:null,[C.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2);let i;i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+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=n.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class O extends P{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 x,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=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(!u(this.programDateTime))return null;const e=u(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,s,n=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:n}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[C.AUDIO]=null,e[C.VIDEO]=null,e[C.AUDIOVIDEO]=null}}class M extends P{constructor(e,t,r,i,s){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 x,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 n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,s),s&&(this.fragOffset=s.fragOffset+s.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)}}const F=10;class N{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&&u(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||F}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){const t=this.driftEnd-this.driftStart;return 1e3*t/e}return 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 B(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function U(e){const t=j(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}function $(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function G(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],s=i[1];t?(e.splice(-1,1),r=B(s)):r=U(s)}}return r}function j(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}const V="undefined"!==typeof self?self:void 0;var K={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},H={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Y(e){switch(e){case H.FAIRPLAY:return K.FAIRPLAY;case H.PLAYREADY:return K.PLAYREADY;case H.WIDEVINE:return K.WIDEVINE;case H.CLEARKEY:return K.CLEARKEY}}var z={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function q(e){if(e===z.WIDEVINE)return K.WIDEVINE}function W(e){switch(e){case K.FAIRPLAY:return H.FAIRPLAY;case K.PLAYREADY:return H.PLAYREADY;case K.WIDEVINE:return H.WIDEVINE;case K.CLEARKEY:return H.CLEARKEY}}function X(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[K.FAIRPLAY,K.WIDEVINE,K.PLAYREADY,K.CLEARKEY].filter(e=>!!t[e]):[];return!i[K.WIDEVINE]&&r&&i.push(K.WIDEVINE),i}const Q=function(e){return null!=V&&null!=(e=V.navigator)&&e.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Z(e,t,r,i){let s;switch(e){case K.FAIRPLAY:s=["cenc","sinf"];break;case K.WIDEVINE:case K.PLAYREADY:s=["cenc"];break;case K.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}return J(s,t,r,i)}function J(e,t,r,i){const s={initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",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}))};return[s]}function ee(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}const te=(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,re=(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,ie=(e,t)=>{const r=t;let i=0;while(te(e,t)){i+=10;const r=se(e,t+6);i+=r,re(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)},se=(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},ne=(e,t)=>te(e,t)&&se(e,t+6)+10<=e.length-t,ae=e=>{const t=de(e);for(let r=0;r<t.length;r++){const e=t[r];if(oe(e))return pe(e)}},oe=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,le=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=se(e,4),i=10;return{type:t,size:r,data:e.subarray(i,i+r)}},de=e=>{let t=0;const r=[];while(te(e,t)){const i=se(e,t+6);t+=10;const s=t+i;while(t+8<s){const i=le(e.subarray(t)),s=he(i);s&&r.push(s),t+=i.size+10}re(e,t)&&(t+=10)}return r},he=e=>"PRIV"===e.type?ce(e):"W"===e.type[0]?fe(e):ue(e),ce=e=>{if(e.size<2)return;const t=me(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}},ue=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=me(e.data.subarray(t),!0);t+=r.length+1;const i=me(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=me(e.data.subarray(1));return{key:e.type,data:t}},fe=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=me(e.data.subarray(t),!0);t+=r.length+1;const i=me(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=me(e.data);return{key:e.type,data:t}},pe=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)}},me=(e,t=!1)=>{const r=ye();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 s,n,a,o="",l=0;while(l<i){if(s=e[l++],0===s&&t)return o;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=e[l++],o+=String.fromCharCode((31&s)<<6|63&n);break;case 14:n=e[l++],a=e[l++],o+=String.fromCharCode((15&s)<<12|(63&n)<<6|(63&a)<<0);break}}return o};let ge;function ye(){if(!navigator.userAgent.includes("PlayStation 4"))return ge||"undefined"===typeof self.TextDecoder||(ge=new self.TextDecoder("utf-8")),ge}const ve={hexDump:function(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},_e=Math.pow(2,32)-1,Ee=[].push,be={video:1,audio:2,id3:3,text:4};function Se(e){return String.fromCharCode.apply(null,e)}function Te(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Le(e,t){const r=Re(e,t);return r<0?4294967296+r:r}function Ae(e,t){let r=Le(e,t);return r*=Math.pow(2,32),r+=Le(e,t+4),r}function Re(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function we(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function ke(e){const t=e.byteLength;for(let r=0;r<t;){const i=Le(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}function De(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let s=0;s<i;){const n=Le(e,s),a=Se(e.subarray(s+4,s+8)),o=n>1?s+n:i;if(a===t[0])if(1===t.length)r.push(e.subarray(s+8,o));else{const i=De(e.subarray(s+8,o),t.slice(1));i.length&&Ee.apply(r,i)}s=o}return r}function Ie(e){const t=[],r=e[0];let i=8;const s=Le(e,i);i+=4;let n=0,a=0;0===r?(n=Le(e,i),a=Le(e,i+4),i+=8):(n=Ae(e,i),a=Ae(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Te(e,i);i+=2;for(let d=0;d<l;d++){let r=i;const n=Le(e,r);r+=4;const a=2147483647&n,l=(2147483648&n)>>>31;if(1===l)return L.warn("SIDX has hierarchical references (not supported)"),null;const d=Le(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:d,info:{duration:d/s,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:n,timescale:s,version:r,referencesCount:l,references:t}}function xe(e){const t=[],r=De(e,["moov","trak"]);for(let s=0;s<r.length;s++){const e=r[s],i=De(e,["tkhd"])[0];if(i){let r=i[0];const s=Le(i,0===r?12:20),n=De(e,["mdia","mdhd"])[0];if(n){r=n[0];const i=Le(n,0===r?12:20),a=De(e,["mdia","hdlr"])[0];if(a){const r=Se(a.subarray(8,12)),n={soun:C.AUDIO,vide:C.VIDEO}[r];if(n){const r=De(e,["mdia","minf","stbl","stsd"])[0],a=Ce(r);t[s]={timescale:i,type:n},t[n]=o({timescale:i,id:s},a)}}}}}const i=De(e,["moov","mvex","trex"]);return i.forEach(e=>{const r=Le(e,4),i=t[r];i&&(i.default={duration:Le(e,12),flags:Le(e,20)})}),t}function Ce(e){const t=e.subarray(8),r=t.subarray(86),i=Se(t.subarray(4,8));let s=i;const n="enca"===i||"encv"===i;if(n){const e=De(t,[i])[0],r=e.subarray("enca"===i?28:78),n=De(r,["sinf"]);n.forEach(e=>{const t=De(e,["schm"])[0];if(t){const r=Se(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=De(e,["frma"])[0];t&&(s=Se(t))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=De(r,["avcC"])[0];s+="."+Oe(e[1])+Oe(e[2])+Oe(e[3]);break}case"mp4a":{const e=De(t,[i])[0],r=De(e.subarray(28),["esds"])[0];if(r&&r.length>12){let e=4;if(3!==r[e++])break;e=Pe(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=Pe(r,e);const i=r[e++];if(64!==i)break;if(s+="."+Oe(i),e+=12,5!==r[e++])break;e=Pe(r,e);const n=r[e++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&r[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=De(r,["hvcC"])[0],t=e[1],i=["","A","B","C"][t>>6],n=31&t,a=Le(e,2),o=(32&t)>>5?"H":"L",l=e[12],d=e.subarray(6,12);s+="."+i+n,s+="."+a.toString(16).toUpperCase(),s+="."+o+l;let h="";for(let r=d.length;r--;){const e=d[r];if(e||h){const t=e.toString(16).toUpperCase();h="."+t+h}}s+=h;break}case"dvh1":case"dvhe":{const e=De(r,["dvcC"])[0],t=e[2]>>1&127,i=e[2]<<5&32|e[3]>>3&31;s+="."+Me(t)+"."+Me(i);break}case"vp09":{const e=De(r,["vpcC"])[0],t=e[4],i=e[5],n=e[6]>>4&15;s+="."+Me(t)+"."+Me(i)+"."+Me(n);break}case"av01":{const e=De(r,["av1C"])[0],t=e[1]>>>5,i=31&e[1],n=e[2]>>>7?"H":"M",a=(64&e[2])>>6,o=(32&e[2])>>5,l=2===t&&a?o?12:10:a?10:8,d=(16&e[2])>>4,h=(8&e[2])>>3,c=(4&e[2])>>2,u=3&e[2],f=1,p=1,m=1,g=0;s+="."+t+"."+Me(i)+n+"."+Me(l)+"."+d+"."+h+c+u+"."+Me(f)+"."+Me(p)+"."+Me(m)+"."+g;break}}return{codec:s,encrypted:n}}function Pe(e,t){const r=t+5;while(128&e[t++]&&t<r);return t}function Oe(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Me(e){return(e<10?"0":"")+e}function Fe(e,t){if(!e||!t)return e;const r=t.keyId;if(r&&t.isCommonEncryption){const t=De(e,["moov","trak"]);t.forEach(e=>{const t=De(e,["mdia","minf","stbl","stsd"])[0],i=t.subarray(8);let s=De(i,["enca"]);const n=s.length>0;n||(s=De(i,["encv"])),s.forEach(e=>{const t=n?e.subarray(28):e.subarray(78),i=De(t,["sinf"]);i.forEach(e=>{const t=Ne(e);if(t){const e=t.subarray(8,24);e.some(e=>0!==e)||(L.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${ve.hexDump(e)} -> ${ve.hexDump(r)}`),t.set(r,8))}})})})}return e}function Ne(e){const t=De(e,["schm"])[0];if(t){const r=Se(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return De(e,["schi","tenc"])[0]}return L.error("[eme] missing 'schm' box"),null}function Be(e,t){return De(t,["moof","traf"]).reduce((t,r)=>{const i=De(r,["tfdt"])[0],s=i[0],n=De(r,["tfhd"]).reduce((t,r)=>{const n=Le(r,4),a=e[n];if(a){let e=Le(i,4);if(1===s){if(e===_e)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=_e+1,e+=Le(i,8)}const r=a.timescale||9e4,n=e/r;if(u(n)&&(null===t||n<t))return n}return t},null);return null!==n&&u(n)&&(null===t||n<t)?n:t},null)}function Ue(e,t){let r=0,i=0,s=0;const n=De(e,["moof","traf"]);for(let a=0;a<n.length;a++){const e=n[a],o=De(e,["tfhd"])[0],l=Le(o,4),d=t[l];if(!d)continue;const h=d.default,c=Le(o,0)|(null==h?void 0:h.flags);let u=null==h?void 0:h.duration;8&c&&(u=Le(o,2&c?12:8));const f=d.timescale||9e4,p=De(e,["trun"]);for(let t=0;t<p.length;t++){if(r=$e(p[t]),!r&&u){const e=Le(p[t],4);r=u*e}d.type===C.VIDEO?i+=r/f:d.type===C.AUDIO&&(s+=r/f)}}if(0===i&&0===s){let t=1/0,r=0,i=0;const s=De(e,["sidx"]);for(let e=0;e<s.length;e++){const n=Ie(s[e]);if(null!=n&&n.references){t=Math.min(t,n.earliestPresentationTime/n.timescale);const e=n.references.reduce((e,t)=>e+t.info.duration||0,0);r=Math.max(r,e+n.earliestPresentationTime/n.timescale),i=r-t}}if(i&&u(i))return i}return i||s}function $e(e){const t=Le(e,0);let r=8;1&t&&(r+=4),4&t&&(r+=4);let i=0;const s=Le(e,4);for(let n=0;n<s;n++){if(256&t){const t=Le(e,r);i+=t,r+=4}512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function Ge(e,t,r){De(t,["moof","traf"]).forEach(t=>{De(t,["tfhd"]).forEach(i=>{const s=Le(i,4),n=e[s];if(!n)return;const a=n.timescale||9e4;De(t,["tfdt"]).forEach(e=>{const t=e[0],i=r*a;if(i){let r=Le(e,4);if(0===t)r-=i,r=Math.max(r,0),we(e,4,r);else{r*=Math.pow(2,32),r+=Le(e,8),r-=i,r=Math.max(r,0);const t=Math.floor(r/(_e+1)),s=Math.floor(r%(_e+1));we(e,4,t),we(e,8,s)}}})})})}function je(e){const t={valid:null,remainder:null},r=De(e,["moof"]);if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=ee(e,0,i.byteOffset-8),t.remainder=ee(e,i.byteOffset-8),t}function Ve(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Ke(e,t){const r=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;const o=De(i,["moof"]);return o.map(o=>{const l=o.byteOffset-8,d=De(o,["traf"]);d.map(o=>{const d=De(o,["tfdt"]).map(e=>{const t=e[0];let r=Le(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Le(e,8)),r/s})[0];return void 0!==d&&(e=d),De(o,["tfhd"]).map(d=>{const h=Le(d,4),c=16777215&Le(d,0),u=0!==(1&c),f=0!==(2&c),p=0!==(8&c);let m=0;const g=0!==(16&c);let y=0;const v=0!==(32&c);let _=8;h===n&&(u&&(_+=8),f&&(_+=4),p&&(m=Le(d,_),_+=4),g&&(y=Le(d,_),_+=4),v&&(_+=4),"video"===t.type&&(a=He(t.codec)),De(o,["trun"]).map(n=>{const o=n[0],d=16777215&Le(n,0),h=0!==(1&d);let c=0;const u=0!==(4&d),f=0!==(256&d);let p=0;const g=0!==(512&d);let v=0;const _=0!==(1024&d),E=0!==(2048&d);let b=0;const S=Le(n,4);let T=8;h&&(c=Le(n,T),T+=4),u&&(T+=4);let L=c+l;for(let l=0;l<S;l++){if(f?(p=Le(n,T),T+=4):p=m,g?(v=Le(n,T),T+=4):v=y,_&&(T+=4),E&&(b=0===o?Le(n,T):Re(n,T),T+=4),t.type===C.VIDEO){let t=0;while(t<v){const n=Le(i,L);if(L+=4,Ye(a,i[L])){const t=i.subarray(L,L+n);ze(t,a?2:1,e+b/s,r)}L+=n,t+=n+4}}e+=p/s}}))})})}),r}function He(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}function Ye(e,t){if(e){const e=t>>1&63;return 39===e||40===e}{const e=31&t;return 6===e}}function ze(e,t,r,i){const s=qe(e);let n=0;n+=t;let a=0,o=0,l=0;while(n<s.length){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(255===l);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(255===l);const e=s.length-n;let t=n;if(o<e)n+=o;else if(o>e){L.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){const e=s[t++];if(181===e){const e=Te(s,t);if(t+=2,49===e){const e=Le(s,t);if(t+=4,1195456820===e){const e=s[t++];if(3===e){const n=s[t++],o=31&n,l=64&n,d=l?2+3*o:0,h=new Uint8Array(d);if(l){h[0]=n;for(let e=1;e<d;e++)h[e]=s[t++]}i.push({type:e,payloadType:a,pts:r,bytes:h})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=s[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const n=o-16,l=new Uint8Array(n);for(let r=0;r<n;r++)l[r]=s[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:me(l),userDataBytes:l})}}}function qe(e){const t=e.byteLength,r=[];let i=1;while(i<t-2)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const s=t-r.length,n=new Uint8Array(s);let a=0;for(i=0;i<s;a++,i++)a===r[0]&&(a++,r.shift()),n[i]=e[a];return n}function We(e){const t=e[0];let r="",i="",s=0,n=0,a=0,o=0,l=0,d=0;if(0===t){while("\0"!==Se(e.subarray(d,d+1)))r+=Se(e.subarray(d,d+1)),d+=1;r+=Se(e.subarray(d,d+1)),d+=1;while("\0"!==Se(e.subarray(d,d+1)))i+=Se(e.subarray(d,d+1)),d+=1;i+=Se(e.subarray(d,d+1)),d+=1,s=Le(e,12),n=Le(e,16),o=Le(e,20),l=Le(e,24),d=28}else if(1===t){d+=4,s=Le(e,d),d+=4;const t=Le(e,d);d+=4;const n=Le(e,d);d+=4,a=2**32*t+n,f(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Le(e,d),d+=4,l=Le(e,d),d+=4;while("\0"!==Se(e.subarray(d,d+1)))r+=Se(e.subarray(d,d+1)),d+=1;r+=Se(e.subarray(d,d+1)),d+=1;while("\0"!==Se(e.subarray(d,d+1)))i+=Se(e.subarray(d,d+1)),d+=1;i+=Se(e.subarray(d,d+1)),d+=1}const h=e.subarray(d,e.byteLength);return{schemeIdUri:r,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:h}}function Xe(e,...t){const r=t.length;let i=8,s=r;while(s--)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=255&i,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}function Qe(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,s,n;if(t){i=1,s=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const r=t[e];if(16!==r.byteLength)throw new RangeError("Invalid key");s.set(r,16*e)}}else i=0,s=new Uint8Array;i>0?(n=new Uint8Array(4),t.length>0&&new DataView(n.buffer).setUint32(0,t.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),Xe([112,115,115,104],new Uint8Array([i,0,0,0]),e,n,s,a,r||new Uint8Array)}function Ze(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;const s=r.getUint32(4);if(1886614376!==s)return null;if(t.version=r.getUint32(8)>>>24,t.version>1)return null;t.systemId=ve.hexDump(new Uint8Array(e,12,16));const n=r.getUint32(28);if(0===t.version){if(i-32<n)return null;t.data=new Uint8Array(e,32,n)}else if(1===t.version){t.kids=[];for(let r=0;r<n;r++)t.kids.push(new Uint8Array(e,32+16*r,16))}return t}let Je={};class et{static clearKeyUriToKeyIdMap(){Je={}}constructor(e,t,r,i=[1],s=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case H.FAIRPLAY:case H.WIDEVINE:case H.PLAYREADY:case H.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!==typeof e&&("AES-128"!==this.method||this.iv||L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=tt(e),r=new et(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}const t=G(this.uri);if(t)switch(this.keyFormat){case H.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case H.PLAYREADY:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Qe(e,null,t);const r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(r)),s=i.substring(i.indexOf("<"),i.length),n=new DOMParser,a=n.parseFromString(s,"text/xml"),o=a.getElementsByTagName("KID")[0];if(o){const e=o.childNodes[0]?o.childNodes[0].nodeValue:o.getAttribute("VALUE");if(e){const t=B(e).subarray(0,16);$(t),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=Je[this.uri];if(!e){const t=Object.keys(Je).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);const r=new DataView(e.buffer,12,4);r.setUint32(0,t),Je[this.uri]=e}this.keyId=e}return this}}function tt(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}const rt=/\{\$([a-zA-Z0-9-_]+)\}/g;function it(e){return rt.test(e)}function st(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(let i=r.length;i--;){const s=r[i],n=t[s];n&&(t[s]=nt(e,n))}}function nt(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(rt,t=>{const i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):s})}return t}function at(e,t,r){let i,s,n=e.variableList;if(n||(e.variableList=n={}),"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}"`);s=e.get(i)}catch(a){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+a.message))}}else i=t.NAME,s=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=s||""}function ot(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 lt(e=!0){if("undefined"===typeof self)return;const t=(e||!self.MediaSource)&&self.ManagedMediaSource;return t||self.MediaSource||self.WebKitMediaSource}function dt(e){return"undefined"!==typeof self&&e===self.ManagedMediaSource}const ht={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ct(e,t){const r=ht[t];return!!r&&!!r[e.slice(0,4)]}function ut(e,t,r=!0){return!e.split(",").some(e=>!ft(e,t,r))}function ft(e,t,r=!0){var i;const s=lt(r);return null!=(i=null==s?void 0:s.isTypeSupported(pt(e,t)))&&i}function pt(e,t){return`${t}/mp4;codecs="${e}"`}function mt(e){if(e){const t=e.substring(0,4);return ht.video[t]}return 2}function gt(e){return e.split(",").reduce((e,t)=>{const r=ht.video[t];return r?(2*r+e)/(e?3:2):(ht.audio[t]+e)/(e?2:1)},0)}const yt={};function vt(e,t=!0){if(yt[e])return yt[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e];for(let i=0;i<r.length;i++)if(ft(r[i],"audio",t))return yt[e]=r[i],r[i];return e}const _t=/flac|opus/i;function Et(e,t=!0){return e.replace(_t,e=>vt(e.toLowerCase(),t))}function bt(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}function St(e){const t=e.split(".");if(t.length>2){let e=t.shift()+".";return e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),e}return e}const Tt=/#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,Lt=/#EXT-X-MEDIA:(.*)/g,At=/^#EXT(?:INF|-X-TARGETDURATION):/m,Rt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),wt=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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class kt{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}static resolve(e,t){return n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return At.test(e)}static parseMasterPlaylist(e,t){const r=it(e),i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},s=[];let n;Tt.lastIndex=0;while(null!=(n=Tt.exec(e)))if(n[1]){var a;const e=new w(n[1]);st(i,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const r=nt(i,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:kt.resolve(r,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),xt(e.CODECS,o),null!=(a=o.unknownCodecs)&&a.length||s.push(o),i.levels.push(o)}else if(n[3]){const e=n[3],r=n[4];switch(e){case"SESSION-DATA":{const e=new w(r);st(i,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[t]=e);break}case"SESSION-KEY":{const e=Dt(r,t,i);e.encrypted&&e.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(e)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${r}"`);break}case"DEFINE":{const e=new w(r);st(i,e,["NAME","VALUE","QUERYPARAM"]),at(i,e,t)}break;case"CONTENT-STEERING":{const e=new w(r);st(i,e,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:kt.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=It(r);break}}const o=s.length>0&&s.length<i.levels.length;return i.levels=o?s:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(e,t,r){let i;const s={},n=r.levels,a={AUDIO:n.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:n.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;Lt.lastIndex=0;while(null!==(i=Lt.exec(e))){const e=new w(i[1]),n=e.TYPE;if(n){const i=a[n],l=s[n]||[];s[n]=l,st(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const d=e.LANGUAGE,h=e["ASSOC-LANGUAGE"],c=e.CHANNELS,u=e.CHARACTERISTICS,f=e["INSTREAM-ID"],p={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||d||"",type:n,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:d,url:e.URI?kt.resolve(e.URI,t):""};if(h&&(p.assocLang=h),c&&(p.channels=c),u&&(p.characteristics=u),f&&(p.instreamId=f),null!=i&&i.length){const e=kt.findGroup(i,p.groupId)||i[0];Ct(p,e,"audioCodec"),Ct(p,e,"textCodec")}l.push(p)}}return s}static parseLevelPlaylist(e,t,r,i,s,n){const a=new N(t),o=a.fragments;let l,d,h,f=null,p=0,m=0,g=0,y=0,v=null,_=new O(i,t),E=-1,b=!1,S=null;Rt.lastIndex=0,a.m3u8=e,a.hasVariableRefs=it(e);while(null!==(l=Rt.exec(e))){b&&(b=!1,_=new O(i,t),_.start=g,_.sn=p,_.cc=y,_.level=r,f&&(_.initSegment=f,_.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null,S&&(_.setByteRange(S),S=null)));const e=l[1];if(e){_.duration=parseFloat(e);const t=(" "+l[2]).slice(1);_.title=t||null,_.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(u(_.duration)){_.start=g,h&&Ft(_,h,a),_.sn=p,_.level=r,_.cc=y,o.push(_);const e=(" "+l[3]).slice(1);_.relurl=nt(a,e),Ot(_,v),v=_,g+=_.duration,p++,m=0,b=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);v?_.setByteRange(e,v):_.setByteRange(e)}else if(l[5])_.rawProgramDateTime=(" "+l[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),-1===E&&(E=o.length);else{if(l=l[0].match(wt),!l){L.warn("No matches on slow regex match for level playlist!");continue}for(d=1;d<l.length;d++)if("undefined"!==typeof l[d])break;const e=(" "+l[d]).slice(1),s=(" "+l[d+1]).slice(1),g=l[d+2]?(" "+l[d+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":a.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":p=a.startSN=parseInt(s);break;case"SKIP":{const e=new w(s);st(a,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(u(t)){a.skippedSegments=t;for(let e=t;e--;)o.unshift(null);p+=t}const r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(a.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(s),1);break;case"VERSION":a.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(s||g)&&_.tagList.push(g?[s,g]:[s]);break;case"DISCONTINUITY":y++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([e]);break;case"BITRATE":_.tagList.push([e,s]);break;case"DATERANGE":{const e=new w(s);st(a,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),st(a,e,e.clientAttrs);const t=new I(e,a.dateRanges[e.ID]);t.isValid||a.skippedSegments?a.dateRanges[t.id]=t:L.warn(`Ignoring invalid DATERANGE tag: "${s}"`),_.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const e=new w(s);st(a,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?ot(a,e,n):at(a,e,t)}break;case"DISCONTINUITY-SEQUENCE":y=parseInt(s);break;case"KEY":{const e=Dt(s,t,a);if(e.isSupported()){if("NONE"===e.method){h=void 0;break}h||(h={}),h[e.keyFormat]&&(h=c({},h)),h[e.keyFormat]=e}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${s}"`);break}case"START":a.startTimeOffset=It(s);break;case"MAP":{const e=new w(s);if(st(a,e,["BYTERANGE","URI"]),_.duration){const s=new O(i,t);Mt(s,e,r,h),f=s,_.initSegment=f,f.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=f.rawProgramDateTime)}else{const t=_.byteRangeEndOffset;if(t){const e=_.byteRangeStartOffset;S=`${t-e}@${e}`}else S=null;Mt(_,e,r,h),f=_,b=!0}break}case"SERVER-CONTROL":{const e=new w(s);a.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),a.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new w(s);a.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=a.partList;e||(e=a.partList=[]);const r=m>0?e[e.length-1]:void 0,i=m++,n=new w(s);st(a,n,["BYTERANGE","URI"]);const o=new M(n,_,t,i,r);e.push(o),_.duration+=o.duration;break}case"PRELOAD-HINT":{const e=new w(s);st(a,e,["URI"]),a.preloadHint=e;break}case"RENDITION-REPORT":{const e=new w(s);st(a,e,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(e);break}default:L.warn("line parsed but not handled: "+l);break}}}v&&!v.relurl?(o.pop(),g-=v.duration,a.partList&&(a.fragmentHint=v)):a.partList&&(Ot(_,v),_.cc=y,a.fragmentHint=_,h&&Ft(_,h,a));const T=o.length,A=o[0],R=o[T-1];if(g+=a.skippedSegments*a.targetduration,g>0&&T&&R){a.averagetargetduration=g/T;const e=R.sn;a.endSN="initSegment"!==e?e:0,a.live||(R.endList=!0),A&&(a.startCC=A.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(g+=a.fragmentHint.duration),a.totalduration=g,a.endCC=y,E>0&&Pt(o,E),a}}function Dt(e,t,r){var i,s;const n=new w(e);st(r,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,h=null!=(s=n.KEYFORMAT)?s:"identity";o&&n.IV&&!l&&L.error("Invalid IV: "+n.IV);const c=o?kt.resolve(o,t):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new et(a,c,h,u,l)}function It(e){const t=new w(e),r=t.decimalFloatingPoint("TIME-OFFSET");return u(r)?r:null}function xt(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>ct(t,e));i.length&&(t[e+"Codec"]=i.join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}function Ct(e,t,r){const i=t[r];i&&(e[r]=i)}function Pt(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}}function Ot(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),u(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function Mt(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 Ft(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 Nt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Bt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Ut(e){const{type:t}=e;switch(t){case Nt.AUDIO_TRACK:return Bt.AUDIO;case Nt.SUBTITLE_TRACK:return Bt.SUBTITLE;default:return Bt.MAIN}}function $t(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class Gt{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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(m.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(m.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,s=r||i,n=new s(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:Nt.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,level:i,pathwayId:s,responseType:"text",type:Nt.LEVEL,url:n,deliveryDirectives:a})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Nt.AUDIO_TRACK,url:s,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Nt.SUBTITLE_TRACK,url:s,deliveryDirectives:n})}load(e){var t;const r=this.hls.config;let i,s=this.getInternalLoader(e);if(s){const t=s.context;if(t&&t.url===e.url&&t.level===e.level)return void L.trace("[playlist-loader]: playlist request ongoing");L.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(i=e.type===Nt.MANIFEST?r.manifestLoadPolicy.default:c({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),u(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Nt.LEVEL&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Nt.AUDIO_TRACK&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Nt.SUBTITLE_TRACK&&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=c({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const n=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const s=this.getInternalLoader(r);this.resetInternalLoader(r.type);const n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),kt.isMediaPlaylist(n)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,s):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)}};s.load(e,a,o)}handleMasterPlaylist(e,t,r,i){const s=this.hls,n=e.data,a=$t(e,r),o=kt.parseMasterPlaylist(n,a);if(o.playlistParsingError)return void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:d,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:f}=o;this.variableList=f;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":y}=kt.parseMasterPlaylistMedia(n,a,o);if(p.length){const e=p.some(e=>!e.url);e||!d[0].audioCodec||d[0].attrs.AUDIO||(L.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 w({}),bitrate:0,url:""}))}s.trigger(m.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:g,captions:y,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:h,sessionKeys:c,startTimeOffset:u,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,s){const n=this.hls,{id:a,level:o,type:l}=r,d=$t(e,r),h=0,c=u(o)?o:u(a)?a:0,f=Ut(r),p=kt.parseLevelPlaylist(e.data,d,c,f,h,this.variableList);if(l===Nt.MANIFEST){const e={attrs:new w({}),bitrate:0,details:p,name:"",url:d};n.trigger(m.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=p,this.handlePlaylistLoaded(p,e,t,r,i,s)}handleManifestParsingError(e,t,r,i,s){this.hls.trigger(m.ERROR,{type:g.NETWORK_ERROR,details:y.MANIFEST_PARSING_ERROR,fatal:t.type===Nt.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:s})}handleNetworkError(e,t,r=!1,i,s){let n=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Nt.LEVEL?n+=`: ${e.level} id: ${e.id}`:e.type!==Nt.AUDIO_TRACK&&e.type!==Nt.SUBTITLE_TRACK||(n+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(n);L.warn("[playlist-loader]: "+n);let l=y.UNKNOWN,d=!1;const h=this.getInternalLoader(e);switch(e.type){case Nt.MANIFEST:l=r?y.MANIFEST_LOAD_TIMEOUT:y.MANIFEST_LOAD_ERROR,d=!0;break;case Nt.LEVEL:l=r?y.LEVEL_LOAD_TIMEOUT:y.LEVEL_LOAD_ERROR,d=!1;break;case Nt.AUDIO_TRACK:l=r?y.AUDIO_TRACK_LOAD_TIMEOUT:y.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Nt.SUBTITLE_TRACK:l=r?y.SUBTITLE_TRACK_LOAD_TIMEOUT:y.SUBTITLE_LOAD_ERROR,d=!1;break}h&&this.resetInternalLoader(e.type);const c={type:g.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:h,context:e,error:a,networkDetails:t,stats:s};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=o({url:r,data:void 0},i)}this.hls.trigger(m.ERROR,c)}handlePlaylistLoaded(e,t,r,i,s,n){const a=this.hls,{type:o,level:l,id:d,groupId:h,deliveryDirectives:c}=i,u=$t(t,i),f=Ut(i),p="number"===typeof i.level&&f===Bt.MAIN?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void a.trigger(m.ERROR,{type:g.NETWORK_ERROR,details:y.LEVEL_EMPTY_ERROR,fatal:!1,url:u,error:e,reason:e.message,response:t,context:i,level:p,parent:f,networkDetails:s,stats:r})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const v=e.playlistParsingError;if(v)a.trigger(m.ERROR,{type:g.NETWORK_ERROR,details:y.LEVEL_PARSING_ERROR,fatal:!1,url:u,error:v,reason:v.message,response:t,context:i,level:p,parent:f,networkDetails:s,stats:r});else switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Nt.MANIFEST:case Nt.LEVEL:a.trigger(m.LEVEL_LOADED,{details:e,level:p||0,id:d||0,stats:r,networkDetails:s,deliveryDirectives:c});break;case Nt.AUDIO_TRACK:a.trigger(m.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:c});break;case Nt.SUBTITLE_TRACK:a.trigger(m.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:h||"",stats:r,networkDetails:s,deliveryDirectives:c});break}}}function jt(e,t){let r;try{r=new Event("addtrack")}catch(i){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Vt(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(i){L.debug("[texttrack-utils]: "+i);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(s){L.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+s)}}"disabled"===r&&(e.mode=r)}function Kt(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function Ht(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){const s=zt(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function Yt(e,t){if(t<e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i=0,s=r;while(i<=s){const n=Math.floor((s+i)/2);if(t<e[n].startTime)s=n-1;else{if(!(t>e[n].startTime&&i<r))return n;i=n+1}}return e[i].startTime-t<t-e[s].startTime?i:s}function zt(e,t,r){const i=[],s=Yt(e,t);if(s>-1)for(let n=s,a=e.length;n<a;n++){const s=e[n];if(s.startTime>=t&&s.endTime<=r)i.push(s);else if(s.startTime>r)return i}return i}function qt(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var Wt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Xt=.25;function Qt(){if("undefined"!==typeof self)return self.VTTCue||self.TextTrackCue}function Zt(e,t,r,i,s){let n=new e(t,r,"");try{n.value=i,s&&(n.type=s)}catch(a){n=new e(t,r,JSON.stringify(s?o({type:s},i):i))}return n}const Jt=(()=>{const e=Qt();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function er(e,t){return e.getTime()/1e3-t}function tr(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class rr{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(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Kt(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;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return jt(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:i}}}=this;if(!r&&!i)return;const{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=Qt();if(n)for(let a=0;a<s.length;a++){const e=s[a].type;if(e===Wt.emsg&&!r||!i)continue;const t=de(s[a].data);if(t){const r=s[a].pts;let i=r+s[a].duration;i>Jt&&(i=Jt);const o=i-r;o<=0&&(i=r+Xt);for(let s=0;s<t.length;s++){const a=t[s];if(!oe(a)){this.updateId3CueEnds(r,e);const t=Zt(n,r,i,a,e);t&&this.id3Track.addCue(t)}}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let s=i.length;s--;){const r=i[s];r.type===t&&r.startTime<e&&r.endTime===Jt&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:s,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=n;if(s&&(a||o)){let e;e="audio"===i?e=>e.type===Wt.audioId3&&o:"video"===i?e=>e.type===Wt.emsg&&a:e=>e.type===Wt.audioId3&&o||e.type===Wt.emsg&&a,Ht(s,t,r,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:i}=this,{dateRanges:s}=t,n=Object.keys(s);if(i){const e=Object.keys(r).filter(e=>!n.includes(e));for(let t=e.length;t--;){const s=e[t];Object.keys(r[s].cues).forEach(e=>{i.removeCue(r[s].cues[e])}),delete r[s]}}const a=t.fragments[t.fragments.length-1];if(0===n.length||!u(null==a?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=a.programDateTime/1e3-a.start,l=Qt();for(let d=0;d<n.length;d++){const e=n[d],t=s[e],i=er(t.startDate,o),a=r[e],h=(null==a?void 0:a.cues)||{};let c=(null==a?void 0:a.durationKnown)||!1,u=Jt;const f=t.endDate;if(f)u=er(f,o),c=!0;else if(t.endOnNext&&!c){const e=n.reduce((e,r)=>{if(r!==t.id){const i=s[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e},null);e&&(u=er(e.startDate,o),c=!0)}const p=Object.keys(t.attr);for(let r=0;r<p.length;r++){const s=p[r];if(!k(s))continue;const n=h[s];if(n)c&&!a.durationKnown&&(n.endTime=u);else if(l){let r=t.attr[s];D(s)&&(r=tr(r));const n=Zt(l,i,u,{key:s,data:r},Wt.dateRange);n&&(n.id=e,this.id3Track.addCue(n),h[s]=n)}}r[e]={cues:h,dateRange:t,durationKnown:c}}}}class ir{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.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:s,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==s?s:n*i);const d=i,h=1;return l+Math.min(this.stallCount*h,d)}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,s=e-t-this.edgeStalled,n=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,s),a)}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(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(m.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(m.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===y.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&L.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:s}=this.config;if(!i||1===s||!t.live)return;const n=this.targetLatency;if(null===n)return;const a=r-n,o=Math.min(this.maxLatency,n+t.targetduration),l=a<o;if(l&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,s)),r=Math.round(2/(1+Math.exp(-.75*a-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 sr=["NONE","TYPE-0","TYPE-1",null];function nr(e){return sr.indexOf(e)>-1}const ar=["SDR","PQ","HLG"];function or(e){return!!e&&ar.indexOf(e)>-1}var lr={No:"",Yes:"YES",v2:"v2"};function dr(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e,s=i<t/2;return t&&s?r?lr.v2:lr.Yes:lr.No}class hr{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 cr{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return ur(this._audioGroups,e)}hasSubtitleGroup(e){return ur(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function ur(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function fr(e,t){const r=t.startPTS;if(u(r)){let i,s=0;t.sn>e.sn?(s=r-e.start,i=e):(s=e.start-r,i=t),i.duration!==s&&(i.duration=s)}else if(t.sn>e.sn){const r=e.cc===t.cc;r&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function pr(e,t,r,i,s,n){const a=i-r;a<=0&&(L.warn("Fragment should have a positive duration",t),i=r+t.duration,n=s+t.duration);let o=r,l=i;const d=t.startPTS,h=t.endPTS;if(u(d)){const e=Math.abs(d-r);u(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),l=Math.min(i,h),i=Math.max(i,h),n=Math.max(n,t.endDTS)}const c=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=o,t.startDTS=s,t.endPTS=i,t.minEndPTS=l,t.endDTS=n;const f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;let p;const m=f-e.startSN,g=e.fragments;for(g[m]=t,p=m;p>0;p--)fr(g[p],g[p-1]);for(p=m;p<g.length-1;p++)fr(g[p],g[p+1]);return e.fragmentHint&&fr(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function mr(e,t){let r=null;const i=e.fragments;for(let l=i.length-1;l>=0;l--){const e=i[l].initSegment;if(e){r=e;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let s,n=0;if(vr(e,t,(e,i)=>{e.relurl&&(n=e.cc-i.cc),u(e.startPTS)&&u(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&&(s=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)}),r){const e=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;e.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(e=>!e),t.deltaUpdateFailed){L.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=gr(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const a=t.fragments;if(n){L.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<a.length;e++)a[e].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),yr(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?pr(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):_r(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const o=t.advancedDateTime;if(t.advanced&&o){const e=t.edge;t.driftStart||(t.driftStartTime=o,t.driftStart=e),t.driftEndTime=o,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function gr(e,t,r){const i=c({},e);return r&&r.forEach(e=>{delete i[e]}),Object.keys(t).forEach(e=>{const r=new I(t[e].attr,i[e]);r.isValid?i[e]=r:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)}),i}function yr(e,t,r){if(e&&t){let i=0;for(let s=0,n=e.length;s<=n;s++){const n=e[s],a=t[s+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?r(n,a):i--}}}function vr(e,t,r){const i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let d=s;d<=n;d++){const e=l[a+d];let s=o[d];i&&!s&&d<i&&(s=t.fragments[d]=e),e&&s&&r(e,s)}}function _r(e,t){const r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||Er(t,i[r].start)}function Er(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function br(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,s=4;if(i.length&&r*s>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function Sr(e,t,r){if(null==e||!e.details)return null;const i=e.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t?s:t<i.startSN&&r&&r.sn===t?r:null)}function Tr(e,t,r){var i;return null!=e&&e.details?Lr(null==(i=e.details)?void 0:i.partList,t,r):null}function Lr(e,t,r){if(e)for(let i=e.length;i--;){const s=e[i];if(s.index===r&&s.fragment.sn===t)return s}return null}function Ar(e){e.forEach((e,t)=>{const{details:r}=e;null!=r&&r.fragments&&r.fragments.forEach(e=>{e.level=t})})}function Rr(e){switch(e.details){case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_TIMEOUT:case y.LEVEL_LOAD_TIMEOUT:case y.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function wr(e,t){const r=Rr(t);return e.default[(r?"timeout":"error")+"Retry"]}function kr(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Dr(e){return o(o({},e),{errorRetry:null,timeoutRetry:null})}function Ir(e,t,r,i){if(!e)return!1;const s=null==i?void 0:i.code,n=t<e.maxNumRetry&&(xr(s)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}function xr(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}const Cr={search:function(e,t){let r=0,i=e.length-1,s=null,n=null;while(r<=i){s=(r+i)/2|0,n=e[s];const a=t(n);if(a>0)r=s+1;else{if(!(a<0))return n;i=s-1}}return null}};function Pr(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!u(t))return null;const i=e[0].programDateTime;if(t<(i||0))return null;const s=e[e.length-1].endProgramDateTime;if(t>=(s||0))return null;r=r||0;for(let n=0;n<e.length;++n){const i=e[n];if(Fr(t,r,i))return i}return null}function Or(e,t,r=0,i=0){let s=null;if(e){s=t[e.sn-t[0].sn+1]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7)}else 0===r&&0===t[0].start&&(s=t[0]);if(s&&(!e||e.level===s.level)&&0===Mr(r,i,s))return s;const n=Cr.search(t,Mr.bind(null,r,i));return!n||n===e&&s?s:n}function Mr(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 Fr(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0)),s=r.endProgramDateTime||0;return s-i>e}function Nr(e,t){return Cr.search(e,e=>e.cc<t?1:e.cc>t?-1:0)}var Br={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ur={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class $r{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=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(m.ERROR,this.onError,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(m.ERROR,this.onError,this),e.off(m.ERROR,this.onErrorOut,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===Bt.MAIN?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 s=this.hls,n=t.context;switch(t.details){case y.FRAG_LOAD_ERROR:case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_ERROR:case y.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case y.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:Br.DoNothing,flags:Ur.None});case y.FRAG_GAP:case y.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Br.SendAlternateToPenaltyBox);case y.LEVEL_EMPTY_ERROR:case y.LEVEL_PARSING_ERROR:{var a,o;const e=t.parent===Bt.MAIN?t.level:s.loadLevel;t.details===y.LEVEL_EMPTY_ERROR&&null!=(a=t.context)&&null!=(o=a.levelDetails)&&o.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case y.LEVEL_LOAD_ERROR:case y.LEVEL_LOAD_TIMEOUT:return void("number"===typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case y.AUDIO_TRACK_LOAD_ERROR:case y.AUDIO_TRACK_LOAD_TIMEOUT:case y.SUBTITLE_LOAD_ERROR:case y.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=s.levels[s.loadLevel];if(e&&(n.type===Nt.AUDIO_TRACK&&e.hasAudioGroup(n.groupId)||n.type===Nt.SUBTITLE_TRACK&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Br.SendAlternateToPenaltyBox,void(t.errorAction.flags=Ur.MoveAllAlternatesMatchingHost)}return;case y.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=s.levels[s.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r?t.errorAction={action:Br.SendAlternateToPenaltyBox,flags:Ur.MoveAllAlternatesMatchingHDCP,hdcpLevel:r}:this.keySystemError(t)}return;case y.BUFFER_ADD_CODEC_ERROR:case y.REMUX_ALLOC_ERROR:case y.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:s.loadLevel));case y.INTERNAL_EXCEPTION:case y.BUFFER_APPENDING_ERROR:case y.BUFFER_FULL_ERROR:case y.LEVEL_SWITCH_ERROR:case y.BUFFER_STALLED_ERROR:case y.BUFFER_SEEK_OVER_HOLE:case y.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Br.DoNothing,flags:Ur.None})}t.type===g.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const r=this.hls,i=wr(r.config.playlistLoadPolicy,e),s=this.playlistError++,n=Ir(i,s,Rr(e),e.response);if(n)return{action:Br.RetryRequest,flags:Ur.None,retryConfig:i,retryCount:s};const a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=s),a}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:s,keyLoadPolicy:n}=t.config,a=wr(e.details.startsWith("key")?n:s,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i){e.details!==y.FRAG_GAP&&i.fragmentError++;const t=Ir(a,o,Rr(e),e.response);if(t)return{action:Br.RetryRequest,flags:Ur.None,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(e,t){const r=this.hls;null!==t&&void 0!==t||(t=r.loadLevel);const i=this.hls.levels[t];if(i){var s,n;const t=e.details;i.loadError++,t===y.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:d,loadLevel:h,minAutoLevel:c,maxAutoLevel:u}=r;r.autoLevelEnabled||(r.loadLevel=-1);const f=null==(s=e.frag)?void 0:s.type,p=f===Bt.AUDIO&&t===y.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===y.BUFFER_ADD_CODEC_ERROR||t===y.BUFFER_APPEND_ERROR),m=p&&d.some(({audioCodec:e})=>i.audioCodec!==e),g="video"===e.sourceBufferName&&(t===y.BUFFER_ADD_CODEC_ERROR||t===y.BUFFER_APPEND_ERROR),v=g&&d.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:_,groupId:E}=null!=(n=e.context)?n:{};for(let r=d.length;r--;){const s=(r+h)%d.length;if(s!==h&&s>=c&&s<=u&&0===d[s].loadError){var a,o;const r=d[s];if(t===y.FRAG_GAP&&e.frag){const t=d[s].details;if(t){const r=Or(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(_===Nt.AUDIO_TRACK&&r.hasAudioGroup(E)||_===Nt.SUBTITLE_TRACK&&r.hasSubtitleGroup(E))continue;if(f===Bt.AUDIO&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===Bt.SUBTITLE&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||m&&i.audioCodec===r.audioCodec||!m&&i.audioCodec!==r.audioCodec||v&&i.codecSet===r.codecSet)continue}l=s;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Br.SendAlternateToPenaltyBox,flags:Ur.None,nextAutoLevel:l}}return{action:Br.SendAlternateToPenaltyBox,flags:Ur.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case Br.DoNothing:break;case Br.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===y.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0;break;case Br.RetryRequest:break}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i,hdcpLevel:s,nextAutoLevel:n}=r;switch(i){case Ur.None:this.switchLevel(e,n);break;case Ur.MoveAllAlternatesMatchingHDCP:s&&(t.maxHdcpLevel=sr[sr.indexOf(s)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,n)}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)}}class Gr{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=L.log.bind(L,t+":"),this.warn=L.warn.bind(L,t+":"),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const i=null==t?void 0:t.renditionReports;if(i){let n=-1;for(let r=0;r<i.length;r++){const a=i[r];let o;try{o=new self.URL(a.URI,t.url).href}catch(s){L.warn("Could not construct new URL for Rendition Report: "+s),o=a.URI||""}if(o===e){n=r;break}o===e.substring(0,o.length)&&(n=r)}if(-1!==n){const e=i[n],s=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn);let a=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=r&&dr(r);return new hr(s,a>=0?a:void 0,o)}}}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:s}=t,n=self.performance.now(),a=s.loading.first?Math.max(0,n-s.loading.first):0;if(i.advancedDateTime=Date.now()-a,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&&mr(r,i),!this.canLoad||!i.live)return;let a,o=void 0,l=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,s=i.lastPartSn,n=i.endSN,d=i.lastPartIndex,h=-1!==d,c=s===n,u=e?0:d;h?(o=c?n+1:s,l=c?u:d+1):o=n+1;const f=i.age,p=f+i.ageHeader;let m=Math.min(p-i.partTarget,1.5*i.targetduration);if(m>0){if(r&&m>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(o+=e,void 0!==l){const e=Math.round(m%i.targetduration/i.partTarget);l+=e}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${f.toFixed(2)}s goal: ${m} skip sn ${e} to part ${l}`)}i.tuneInGoal=m}if(a=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l),e||!c)return void this.loadPlaylist(a)}else(i.canBlockReload||i.canSkipUntil)&&(a=this.getDeliveryDirectives(i,t.deliveryDirectives,o,l));const d=this.hls.mainForwardBufferInfo,h=d?d.end-d.len:0,c=1e3*(i.edge-h),u=br(i,c);i.updated&&n>this.requestScheduled+u&&(this.requestScheduled=s.loading.start),void 0!==o&&i.canBlockReload?this.requestScheduled=s.loading.first+u-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=u);let f=this.requestScheduled-n;f=Math.max(0,f),this.log(`reload live playlist ${e} in ${Math.round(f)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(a),f)}else this.clearTimer()}getDeliveryDirectives(e,t,r,i){let s=dr(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,s=lr.No),new hr(r,i,s)}checkRetry(e){const t=e.details,r=Rr(e),i=e.errorAction,{action:s,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(s===Br.RetryRequest||!i.resolved&&s===Br.SendAlternateToPenaltyBox);if(o){var l;if(this.requestScheduled=-1,n>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=kr(a,n);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}class jr{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 Vr{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 jr(e),this.fast_=new jr(t),this.defaultTTFB_=i,this.ttfb_=new jr(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:s}=this;r.halfLife!==e&&(this.slow_=new jr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new jr(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new jr(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const r=8*t,i=e/1e3,s=r/i;this.fast_.sample(i,s),this.slow_.sample(i,s)}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(){}}const Kr={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Hr={};function Yr(e,t,r,i,s,n){const a=e.audioCodec?e.audioGroups:null,o=null==n?void 0:n.audioCodec,l=null==n?void 0:n.channels,d=l?parseInt(l):o?1/0:2;let h=null;if(null!=a&&a.length)try{h=1===a.length&&a[0]?t.groups[a[0]].channels:a.reduce((e,r)=>{if(r){const i=t.groups[r];if(!i)throw new Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(c){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(s,8e6))||!!h&&u(d)&&Object.keys(h).some(e=>parseInt(e)>d)}function zr(e,t,r){const i=e.videoCodec,s=e.audioCodec;if(!i||!s||!r)return Promise.resolve(Kr);const n={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},a=e.videoRange;"SDR"!==a&&(n.transferFunction=a.toLowerCase());const l=i.split(",").map(e=>({type:"media-source",video:o(o({},n),{},{contentType:pt(e,"video")})}));return s&&e.audioGroups&&e.audioGroups.forEach(e=>{var r;e&&(null==(r=t.groups[e])||r.tracks.forEach(t=>{if(t.groupId===e){const e=t.channels||"",r=parseFloat(e);u(r)&&r>2&&l.push.apply(l,s.split(",").map(e=>({type:"media-source",audio:{contentType:pt(e,"audio"),channels:""+r}})))}}))}),Promise.all(l.map(e=>{const t=qr(e);return Hr[t]||(Hr[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:l,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:l,decodingInfoResults:[],error:e}))}function qr(e){const{audio:t,video:r}=e,i=r||t;if(i){const e=i.contentType.split('"')[1];if(r)return`r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${e}_${Math.ceil(r.bitrate/1e5)}`;if(t)return`c${t.channels}${t.spatialRendering?"s":"n"}_${e}`}return""}function Wr(){if("function"===typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}function Xr(e,t){let r=!1,i=[];return e&&(r="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||ar.slice(0),r=void 0!==t.preferHDR?t.preferHDR:Wr(),i=r?i.filter(e=>"SDR"!==e):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function Qr(e,t,r,i,s){const n=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=a&&2===parseInt(a);let d=!0,h=!1,c=1/0,f=1/0,p=1/0,m=0,g=[];const{preferHDR:y,allowedVideoRanges:v}=Xr(t,s);for(let u=n.length;u--;){const t=e[n[u]];d=t.channels[2]>0,c=Math.min(c,t.minHeight),f=Math.min(f,t.minFramerate),p=Math.min(p,t.minBitrate);const r=v.filter(e=>t.videoRanges[e]>0);r.length>0&&(h=!0,g=r)}c=u(c)?c:0,f=u(f)?f:0;const _=Math.max(1080,c),E=Math.max(30,f);p=u(p)?p:r,r=Math.max(p,r),h||(t=void 0,g=[]);const b=n.reduce((t,i)=>{const s=e[i];if(i===t)return t;if(s.minBitrate>r)return Zr(i,`min bitrate of ${s.minBitrate} > current estimate of ${r}`),t;if(!s.hasDefaultAudio)return Zr(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!==0)return Zr(i,`audio codec preference "${o}" not found`),t;if(a&&!l){if(!s.channels[a])return Zr(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(s.channels)})`),t}else if((!o||l)&&d&&0===s.channels["2"])return Zr(i,"no renditions with stereo sound found"),t;return s.minHeight>_?(Zr(i,`min resolution of ${s.minHeight} > maximum of ${_}`),t):s.minFramerate>E?(Zr(i,`min framerate of ${s.minFramerate} > maximum of ${E}`),t):g.some(e=>s.videoRanges[e]>0)?s.maxScore<m?(Zr(i,`max score of ${s.maxScore} < selected max of ${m}`),t):t&&(gt(i)>=gt(t)||s.fragmentError>e[t].fragmentError)?t:(m=s.maxScore,i):(Zr(i,`no variants with VIDEO-RANGE of ${JSON.stringify(g)} found`),t)},void 0);return{codecSet:b,videoRanges:g,preferHDR:y,minFramerate:f,minBitrate:p}}function Zr(e,t){L.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Jr(e){return e.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function ei(e,t,r,i){return e.slice(r,i+1).reduce((e,r)=>{if(!r.codecSet)return e;const i=r.audioGroups;let s=e[r.codecSet];s||(e[r.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!i,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,r.bitrate);const n=Math.min(r.height,r.width);return s.minHeight=Math.min(s.minHeight,n),s.minFramerate=Math.min(s.minFramerate,r.frameRate),s.maxScore=Math.max(s.maxScore,r.score),s.fragmentError+=r.fragmentError,s.videoRanges[r.videoRange]=(s.videoRanges[r.videoRange]||0)+1,i&&i.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+r.channels[e]}))}),e},{})}function ti(e,t,r){if("attrs"in e){const r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++){const s=t[i];if(ri(e,s,r))return i}return-1}function ri(e,t,r){const{groupId:i,name:s,lang:n,assocLang:a,characteristics:o,default:l}=e,d=e.forced;return(void 0===i||t.groupId===i)&&(void 0===s||t.name===s)&&(void 0===n||t.lang===n)&&(void 0===n||t.assocLang===a)&&(void 0===l||t.default===l)&&(void 0===d||t.forced===d)&&(void 0===o||ii(o,t.characteristics))&&(void 0===r||r(e,t))}function ii(e,t=""){const r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}function si(e,t){const{audioCodec:r,channels:i}=e;return(void 0===r||(t.audioCodec||"").substring(0,4)===r.substring(0,4))&&(void 0===i||i===(t.channels||"2"))}function ni(e,t,r,i,s){const n=t[i],a=t.reduce((e,t,r)=>{const i=t.uri,s=e[i]||(e[i]=[]);return s.push(r),e},{}),o=a[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,h=n.codecSet.substring(0,4),c=ai(t,i,t=>{if(t.videoRange!==l||t.frameRate!==d||t.codecSet.substring(0,4)!==h)return!1;const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return ti(e,n,s)>-1});return c>-1?c:ai(t,i,t=>{const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return ti(e,n,s)>-1})}function ai(e,t,r){for(let i=t;i;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return-1}class oi{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:i,media:s}=r;if(!e||!s)return;const n=performance.now(),a=t?t.stats:e.stats,o=t?t.duration:e.duration,l=n-a.loading.start,d=r.minAutoLevel;if(a.aborted||a.loaded&&a.loaded===a.total||e.level<=d)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!i||s.paused||!s.playbackRate||!s.readyState)return;const h=r.mainForwardBufferInfo;if(null===h)return;const c=this.bwEstimator.getEstimateTTFB(),f=Math.abs(s.playbackRate);if(l<=Math.max(c,o/(2*f)*1e3))return;const p=h.len/f,g=a.loading.first?a.loading.first-a.loading.start:-1,y=a.loaded&&g>-1,v=this.getBwEstimate(),_=r.levels,E=_[e.level],b=a.total||Math.max(a.loaded,Math.round(o*E.averageBitrate/8));let S=y?l-g:l;S<1&&y&&(S=Math.min(l,8*a.loaded/v));const T=y?1e3*a.loaded/S:0,A=T?(b-a.loaded)/T:8*b/v+c/1e3;if(A<=p)return;const R=T?8*T:v;let w,k=Number.POSITIVE_INFINITY;for(w=e.level-1;w>d;w--){const e=_[w].maxBitrate;if(k=this.getTimeToLoadFrag(c/1e3,R,o*e,!_[w].details),k<p)break}if(k>=A)return;if(k>10*o)return;r.nextLoadLevel=r.nextAutoLevel=w,y?this.bwEstimator.sample(l-Math.min(c,g),a.loaded):this.bwEstimator.sampleTTFB(l);const D=_[w].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>D&&this.resetEstimator(D),this.clearTimer(),L.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${p.toFixed(3)} s\n Estimated load time for current fragment: ${A.toFixed(3)} s\n Estimated load time for down switch fragment: ${k.toFixed(3)} s\n TTFB estimate: ${0|g} ms\n Current BW estimate: ${u(v)?0|v:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${w} @ ${0|D} bps`),r.trigger(m.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:a})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new Vr(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(m.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case y.BUFFER_ADD_CODEC_ERROR:case y.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case y.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){const t=performance.now(),r=i?i.stats:e.stats,s=t-r.loading.start,n=r.loading.first?r.loading.first-r.loading.start:-1,a=r.loaded&&n>-1;if(a){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(e,n),r.loaded)}else this.bwEstimator.sampleTTFB(s)}break}}}getTimeToLoadFrag(e,t,r,i){const s=e+r/t,n=i?this.lastLevelLoadSec:0;return s+n}onLevelLoaded(e,t){const r=this.hls.config,{loading:i}=t.stats,s=i.end-i.start;u(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===Bt.MAIN&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,s=this.hls.levels[t.level],n=(s.loaded?s.loaded.bytes:0)+i.loaded,a=(s.loaded?s.loaded.duration:0)+e;s.loaded={bytes:n,duration:a},s.realBitrate=Math.round(8*n/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(m.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,s=null!=i&&i.stats.loaded?i.stats:r.stats;if(s.aborted)return;if(this.ignoreFragment(r))return;const n=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,s.loaded),s.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Bt.MAIN||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(r,t,e,0,i,1,1);if(s>-1)return s;const n=this.hls.firstLevel,a=Math.min(Math.max(n,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),i=this.lastLoadedFragLevel>-1;if(-1!==e&&(!r||!i||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const s=r&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,s)&&t[e].loadError<=t[s].loadError)return e}return this._nextAutoLevel=s,this.nextAutoLevelKey=this.getAutoLevelKey(),s}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:s,minAutoLevel:n}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let d=s.abrBandWidthFactor,h=s.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,n,i,l,0,d,h);if(e>=0)return e}let c=a?Math.min(a,s.maxStarvationDelay):s.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){const t=a?Math.min(a,s.maxLoadingDelay):s.maxLoadingDelay;c=t-e,L.info(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),d=h=1}}const u=this.findBestLevel(o,n,i,l,c,d,h);if(L.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${u}`),u>-1)return u;const f=r.levels[n],p=r.levels[r.loadLevel];return(null==f?void 0:f.bitrate)<(null==p?void 0:p.bitrate)?n:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,s,n,a){var o;const l=i+s,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,{fragCurrent:c,partCurrent:f}=this,{levels:p,allAudioTracks:m,loadLevel:g,config:y}=this.hls;if(1===p.length)return 0;const v=p[h],_=!(null==v||null==(o=v.details)||!o.live),E=-1===g||-1===d;let b,S="SDR",T=(null==v?void 0:v.frameRate)||0;const{audioPreference:A,videoPreference:R}=y,w=this.audioTracksByGroup||(this.audioTracksByGroup=Jr(m));if(E){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=ei(p,w,t,r)),s=Qr(i,S,e,A,R),{codecSet:n,videoRanges:a,minFramerate:o,minBitrate:l,preferHDR:d}=s;b=n,S=d?a[a.length-1]:a[0],T=o,e=Math.max(e,l),L.log("[abr] picked start tier "+JSON.stringify(s))}else b=null==v?void 0:v.codecSet,S=null==v?void 0:v.videoRange;const k=f?f.duration:c?c.duration:0,D=this.bwEstimator.getEstimateTTFB()/1e3,I=[];for(let C=r;C>=t;C--){var x;const t=p[C],o=C>h;if(!t)continue;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"===typeof(null==r?void 0:r.decodingInfo)&&Yr(t,w,S,T,e,A)?(t.supportedPromise=zr(t,w,r),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;const r=this.hls.levels,i=r.indexOf(t);e.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${JSON.stringify(e)}`):e.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${i} ${JSON.stringify(e)}`),i>-1&&r.length>1&&(L.log("[abr] Removing unsupported level "+i),this.hls.removeLevel(i)))})):t.supportedResult=Kr}if(b&&t.codecSet!==b||S&&t.videoRange!==S||o&&T>t.frameRate||!o&&T>0&&T<t.frameRate||t.supportedResult&&(null==(x=t.supportedResult.decodingInfoResults)||!x[0].smooth)){I.push(C);continue}const c=t.details,m=(f?null==c?void 0:c.partTarget:null==c?void 0:c.averagetargetduration)||k;let R;R=o?a*e:n*e;const P=k&&i>=2*k&&0===s?p[C].averageBitrate:p[C].maxBitrate,O=this.getTimeToLoadFrag(D,R,P*m,void 0===c),M=R>=P&&(C===d||0===t.loadError&&0===t.fragmentError)&&(O<=D||!u(O)||_&&!this.bitrateTestDelay||O<l);if(M){const e=this.forcedAutoLevel;return C===g||-1!==e&&e===g||(I.length&&L.trace(`[abr] Skipped level(s) ${I.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${p[I[0]].codecs}" ${p[I[0]].videoRange}; not compatible with "${v.codecs}" ${S}`),L.info(`[abr] switch candidate:${h}->${C} adjustedbw(${Math.round(R)})-bitrate=${Math.round(R-P)} ttfb:${D.toFixed(1)} avgDuration:${m.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${O.toFixed(1)} firstSelection:${E} codecSet:${b} videoRange:${S} hls.loadLevel:${g}`)),E&&(this.firstSelection=C),C}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls,i=Math.min(Math.max(e,r),t);this._nextAutoLevel!==i&&(this.nextAutoLevelKey="",this._nextAutoLevel=i)}}class li{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(){}}var di={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class hi{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(m.BUFFER_APPENDED,this.onBufferAppended,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.BUFFER_APPENDED,this.onBufferAppended,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.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 i=r.length;i--;){const t=r[i];if(!t)break;const s=t.end;if(t.start<=e&&null!==s&&e<=s)return t}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,i=Object.keys(r);for(let s=i.length;s--;){const n=r[i[s]];if((null==n?void 0:n.body.type)===t&&n.buffered){const t=n.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const n=this.fragments[i];if(!n)return;if(s>=n.body.sn)return;if(!n.buffered&&!n.loaded)return void(n.body.type===r&&this.removeFragment(n.body));const a=n.range[e];a&&a.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(n.body),r})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:i}=e;if(!t||"initSegment"===r.sn)return;const s=ui(r),n=this.fragments[s];if(!n||n.buffered&&r.gap)return;const a=!r.relurl;if(Object.keys(t).forEach(e=>{const s=r.elementaryStreams[e];if(!s)return;const o=t[e],l=a||!0===s.partial;n.range[e]=this.getBufferedTimes(r,i,l,o)}),n.loaded=null,Object.keys(n.range).length){n.buffered=!0;const e=n.body.endList=r.endList||n.body.endList;e&&(this.endListFragments[n.body.type]=n),ci(n)||this.removeParts(r.sn-1,r.type)}else this.removeFragment(n.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=ui(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 s={time:[],partial:r},n=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||n;for(let d=0;d<i.length;d++){const e=i.start(d)-this.bufferPadding,t=i.end(d)+this.bufferPadding;if(l>=e&&o<=t){s.time.push({startPTS:Math.max(n,i.start(d)),endPTS:Math.min(a,i.end(d))});break}if(n<t&&a>e){const e=Math.max(n,i.start(d)),t=Math.min(a,i.end(d));t>e&&(s.partial=!0,s.time.push({startPTS:e,endPTS:t}))}else if(a<=e)break}return s}getPartialFragment(e){let t,r,i,s=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const d=o[l];d&&ci(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(s=d.body,n=t)))}),s}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||ci(t))}getState(e){const t=ui(e),r=this.fragments[t];return r?r.buffered?ci(r)?di.PARTIAL:di.OK:di.APPENDING:di.NOT_LOADED}isTimeBuffered(e,t,r){let i,s;for(let n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,s=r.end(n)+this.bufferPadding,e>=i&&t<=s)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 s=i?null:t,n=ui(r);this.fragments[n]={body:r,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:s}=t;if("initSegment"===r.sn)return;const n=r.type;if(i){let e=this.activePartLists[n];e||(this.activePartLists[n]=e=[]),e.push(i)}this.timeRanges=s,Object.keys(s).forEach(e=>{const t=s[e];this.detectEvictedFragments(e,t,n,i)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ui(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,s){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||s)&&this.removeFragment(o)})}removeFragment(e){const t=ui(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 ci(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 ui(e){return`${e.type}_${e.level}_${e.sn}`}const fi={length:0,start:()=>0,end:()=>0};class pi{static isBuffered(e,t){try{if(e){const r=pi.getBuffered(e);for(let e=0;e<r.length;e++)if(t>=r.start(e)&&t<=r.end(e))return!0}}catch(r){}return!1}static bufferInfo(e,t,r){try{if(e){const i=pi.getBuffered(e),s=[];let n;for(n=0;n<i.length;n++)s.push({start:i.start(n),end:i.end(n)});return this.bufferedInfo(s,t,r)}}catch(i){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort((function(e,t){const r=e.start-t.start;return r||t.end-e.end}));let i=[];if(r)for(let l=0;l<e.length;l++){const t=i.length;if(t){const s=i[t-1].end;e[l].start-s<r?e[l].end>s&&(i[t-1].end=e[l].end):i.push(e[l])}else i.push(e[l])}else i=e;let s,n=0,a=t,o=t;for(let l=0;l<i.length;l++){const e=i[l].start,d=i[l].end;if(t+r>=e&&t<d)a=e,o=d,n=o-t;else if(t+r<e){s=e;break}}return{len:n,start:a||0,end:o||0,nextStart:s}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),fi}}}class mi{constructor(e,t,r,i=0,s=-1,n=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=gi(),this.buffering={audio:gi(),video:gi(),audiovideo:gi()},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=s,this.partial=n}}function gi(){return{start:0,executeStart:0,executeEnd:0,end:0}}function yi(e,t){for(let i=0,s=e.length;i<s;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function vi(e,t,r){return!(!t||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function _i(e,t){const r=e.fragments,i=t.fragments;if(!i.length||!r.length)return void L.log("No fragments to align");const s=yi(r,i[0].cc);if(s&&(!s||s.startPTS))return s;L.log("No frag in previous level to align on")}function Ei(e,t){if(e){const r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function bi(e,t){const r=t.fragments;for(let i=0,s=r.length;i<s;i++)Ei(r[i],e);t.fragmentHint&&Ei(t.fragmentHint,e),t.alignedSliding=!0}function Si(e,t,r){t&&(Ti(e,r,t),!r.alignedSliding&&t&&Li(r,t),r.alignedSliding||!t||r.skippedSegments||_r(t,r))}function Ti(e,t,r){if(vi(e,r,t)){const e=_i(r,t);e&&u(e.start)&&(L.log("Adjusting PTS using last level due to CC increase within current level "+t.url),bi(e.start,t))}}function Li(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let s,n;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(s=yi(i,a),n=yi(r,a)),s&&n||(s=i[Math.floor(i.length/2)],n=yi(r,s.cc)||r[Math.floor(r.length/2)]);const o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(n.start-s.start);bi(d,e)}const Ai=Math.pow(2,17);class Ri{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 Di({type:g.NETWORK_ERROR,details:y.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,s=i.fLoader,n=i.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void l(ki(e));e.gap=!1}const d=this.loader=e.loader=s?new s(i):new n(i),h=wi(e),c=Dr(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Ai};e.stats=d.stats,d.load(h,u,{onSuccess:(t,r,i,s)=>{this.resetLoader(e,d);let n=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),a({frag:e,part:null,payload:n,networkDetails:s})},onError:(t,i,s,n)=>{this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:o({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:n}))},onAbort:(t,r,i)=>{this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))},onProgress:(r,i,s,n)=>{t&&t({frag:e,part:null,payload:s,networkDetails:n})}})})}loadPart(e,t,r){this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void l(ki(e,t));const d=this.loader=e.loader=s?new s(i):new n(i),h=wi(e,t),c=Dr(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ai};t.stats=d.stats,d.load(h,u,{onSuccess:(i,s,n,o)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const l={frag:e,part:t,payload:i.data,networkDetails:o};r(l),a(l)},onError:(r,i,s,n)=>{this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:o({url:h.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:s,stats:n}))},onAbort:(r,i,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:(r,i,s)=>{this.resetLoader(e,d),l(new Di({type:g.NETWORK_ERROR,details:y.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(e.duration/t.duration),n=Math.min(Math.round(r.loaded/s),i),a=i-n,o=a*Math.round(r.loaded/n);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);const n=r.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function wi(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(u(s)&&u(n)){var a;let t=s,r=n;if("initSegment"===e.sn&&"AES-128"===(null==(a=e.decryptdata)?void 0:a.method)){const e=n-s;e%16&&(r=n+(16-e%16)),0!==s&&(i.resetIV=!0,t=s-16)}i.rangeStart=t,i.rangeEnd=r}return i}function ki(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:g.MEDIA_ERROR,details:y.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Di(i)}class Di extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Ii{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class xi{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Ci(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?ee(e,0,t-r):e}class Pi{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],s=r[1],n=r[2],a=r[3],o=this.invSubMix,l=o[0],d=o[1],h=o[2],c=o[3],u=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)u[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=u[f],m=u[o],g=u[m];let y=257*u[r]^16843008*r;i[f]=y<<24|y>>>8,s[f]=y<<16|y>>>16,n[f]=y<<8|y>>>24,a[f]=y,y=16843009*g^65537*m^257*o^16843008*f,l[r]=y<<24|y>>>8,d[r]=y<<16|y>>>16,h[r]=y<<8|y>>>24,c[r]=y,f?(f=o^u[u[u[g^o]]],p^=u[u[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;while(i<t.length&&r)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);const n=this.ksRows=4*(s+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),d=this.invKeySchedule=new Uint32Array(n),h=this.sBox,c=this.rcon,u=this.invSubMix,f=u[0],p=u[1],m=u[2],g=u[3];let y,v;for(a=0;a<n;a++)a<s?y=l[a]=t[a]:(v=y,a%s===0?(v=v<<8|v>>>24,v=h[v>>>24]<<24|h[v>>>16&255]<<16|h[v>>>8&255]<<8|h[255&v],v^=c[a/s|0]<<24):s>6&&a%s===4&&(v=h[v>>>24]<<24|h[v>>>16&255]<<16|h[v>>>8&255]<<8|h[255&v]),l[a]=y=(l[a-s]^v)>>>0);for(o=0;o<n;o++)a=n-o,v=3&o?l[a]:l[a-4],d[o]=o<4||a<=4?v:f[h[v>>>24]]^p[h[v>>>16&255]]^m[h[v>>>8&255]]^g[h[255&v]],d[o]=d[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,s=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],d=a[2],h=a[3],c=this.uint8ArrayToUint32Array_(r);let u=c[0],f=c[1],p=c[2],m=c[3];const g=new Int32Array(e),y=new Int32Array(g.length);let v,_,E,b,S,T,L,A,R,w,k,D,I,x;const C=this.networkToHostOrderSwap;while(t<g.length){for(R=C(g[t]),w=C(g[t+1]),k=C(g[t+2]),D=C(g[t+3]),S=R^s[0],T=D^s[1],L=k^s[2],A=w^s[3],I=4,x=1;x<i;x++)v=o[S>>>24]^l[T>>16&255]^d[L>>8&255]^h[255&A]^s[I],_=o[T>>>24]^l[L>>16&255]^d[A>>8&255]^h[255&S]^s[I+1],E=o[L>>>24]^l[A>>16&255]^d[S>>8&255]^h[255&T]^s[I+2],b=o[A>>>24]^l[S>>16&255]^d[T>>8&255]^h[255&L]^s[I+3],S=v,T=_,L=E,A=b,I+=4;v=n[S>>>24]<<24^n[T>>16&255]<<16^n[L>>8&255]<<8^n[255&A]^s[I],_=n[T>>>24]<<24^n[L>>16&255]<<16^n[A>>8&255]<<8^n[255&S]^s[I+1],E=n[L>>>24]<<24^n[A>>16&255]<<16^n[S>>8&255]<<8^n[255&T]^s[I+2],b=n[A>>>24]<<24^n[S>>16&255]<<16^n[T>>8&255]<<8^n[255&L]^s[I+3],y[t]=C(v^u),y[t+1]=C(b^f),y[t+2]=C(E^p),y[t+3]=C(_^m),u=R,f=w,p=k,m=D,t+=4}return y.buffer}}const Oi=16;class Mi{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(r){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Ci(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((i,s)=>{this.softwareDecrypt(new Uint8Array(e),t,r);const n=this.flush();n?i(n.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){const{currentIV:i,currentResult:s,remainderData:n}=this;this.logOnce("JS AES decrypt"),n&&(e=Ve(n,e),this.remainderData=null);const a=this.getValidChunk(e);if(!a.length)return null;i&&(r=i);let o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new Pi),o.expandKey(t);const l=s;return this.currentResult=o.decrypt(a.buffer,0,r),this.currentIV=ee(a,-16).buffer,l||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new xi(this.subtle,t)}return this.fastAesKey.expandKey().then(t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");const i=new Ii(this.subtle,new Uint8Array(r));return i.decrypt(e.buffer,t)}).catch(i=>(L.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%Oi;return r!==e.length&&(t=ee(e,0,r),this.remainderData=ee(e,r)),t}logOnce(e){this.logEnabled&&(L.log("[decrypter]: "+e),this.logEnabled=!1)}}const Fi={toString:function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t}},Ni={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class Bi extends li{constructor(e,t,r,i,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Ni.STOPPED,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=s,this.logPrefix=i,this.log=L.log.bind(L,i+":"),this.warn=L.warn.bind(L,i+":"),this.hls=e,this.fragmentLoader=new Ri(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Mi(e.config),e.on(m.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=Ni.STOPPED}_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],t=pi.isBuffered(this.media,e.start+e.duration/2);return t}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.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===Ni.STOPPED&&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:s}=this,n=r?r.currentTime:0,a=pi.bufferInfo(i||r,n,e.maxBufferHole);if(this.log(`media seeking to ${u(n)?n.toFixed(3):n}, state: ${s}`),this.state===Ni.ENDED)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,s=t.start+t.duration+r;if(!a.len||s<a.start||i>a.end){const e=n>s;(n<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=Ni.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){const i=t=>{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)};this._doFragLoad(e,t,r,i).then(t=>{if(!t)return;const r=this.state;this.fragContextChanged(e)?(r===Ni.FRAG_LOADING||!this.fragCurrent&&r===Ni.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=Ni.IDLE):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(m.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))}).catch(t=>{this.state!==Ni.STOPPED&&this.state!==Ni.ERROR&&(this.warn(t),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this,i=r.getState(e);if(i===di.APPENDING){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,i?i.len:this.config.maxBufferLength),n=this.backtrackFragment,a=n?e.sn-n.sn:0;(1===a||this.reduceMaxBufferLength(s))&&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)===di.PARTIAL&&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(m.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,s=e.decryptdata;if(i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&"AES-128"===s.method){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(t=>{throw r.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(i=>{const s=self.performance.now();return r.trigger(m.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:n,tdecrypt:s}}),t.payload=i,this.completeInitSegmentLoad(t)})}return this.completeInitSegmentLoad(t)}).catch(t=>{this.state!==Ni.STOPPED&&this.state!==Ni.ERROR&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state=Ni.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,i,s,n;const a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===Bt.MAIN?"level":"track"} ${e.level} (frag:[${(null!=(r=e.startPTS)?r:NaN).toFixed(3)}-${(null!=(i=e.endPTS)?i:NaN).toFixed(3)}] > buffer:${a?Fi.toString(pi.getBuffered(a)):"(detached)"})`),"initSegment"!==e.sn){var o;if(e.type!==Bt.SUBTITLE){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Ni.IDLE)}const t=null==(o=this.levels)?void 0:o[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Ni.IDLE,a&&(!this.loadedmetadata&&e.type==Bt.MAIN&&a.buffered.length&&(null==(s=this.fragCurrent)?void 0:s.sn)===(null==(n=this.fragPrevious)?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:s}=e,n=!s||0===s.length||s.some(e=>!e),a=new mi(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var s;const n=null==t?void 0:t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key?!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=Ni.KEY_LOADING,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(m.KEY_LOADED,e),this.state===Ni.KEY_LOADING&&(this.state=Ni.IDLE),e}),this.hls.trigger(m.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(a=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 s=n.partList;if(s&&i){r>e.end&&n.fragmentHint&&(e=n.fragmentHint);const o=this.getNextPart(s,e,r);if(o>-1){const l=s[o];let d;return this.log(`Loading part sn: ${e.sn} p: ${l.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${o}-${s.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Ni.FRAG_LOADING,d=a?a.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(m.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),u(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Ni.FRAG_LOADING;const o=this.config.progressive;let l;return l=o&&a?a.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,o?i:void 0),a]).then(([e])=>(!o&&e&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(m.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((s,n)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const n=i.part;this.hls.trigger(m.FRAG_LOADED,i);const a=Tr(r,e.sn,t.index+1)||Lr(l,e.sn,t.index+1);if(!a)return s({frag:e,part:n,partsLoaded:o});d(a)}).catch(n)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===y.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(m.ERROR,t)}else this.hls.trigger(m.ERROR,{type:g.OTHER_ERROR,details:y.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Ni.PARSING)return void(this.fragCurrent||this.state===Ni.STOPPED||this.state===Ni.ERROR||(this.state=Ni.IDLE));const{frag:r,part:i,level:s}=t,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(r,i,s,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:s,part:n}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${s} of level ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=n>-1?Tr(a,s,n):null,l=o?o.fragment:Sr(a,s,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:a}):null}bufferFragmentData(e,t,r,i,s){var n;if(!e||this.state!==Ni.PARSING)return;const{data1:a,data2:o}=e;let l=a;if(a&&o&&(l=Ve(a,o)),null==(n=l)||!n.length)return;const d={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(m.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!pi.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=pi.bufferInfo(t,r,0),s=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),a=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-a>n&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return u(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:i}}=this,s=pi.bufferInfo(e,t,i);if(0===s.len&&void 0!==s.nextStart){const n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&s.nextStart<n.end)return pi.bufferInfo(e,t,Math.max(s.nextStart,i))}return s}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,r=e||t.maxBufferLength,i=t.maxMaxBufferLength/2;return i>=r&&(t.maxMaxBufferLength=i,this.warn(`Reduce max buffer length to ${i}s`),!0)}getAppendedFrag(e,t=Bt.MAIN){const r=this.fragmentTracker.getAppendedFrag(e,Bt.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:s}=this,n=r[0].start;let a;if(t.live){const o=s.initialLiveManifestSize;if(i<o)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${o})`),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n)&&(a=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=n&&(a=r[0]);if(!a){const r=s.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,r,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===di.OK||r===di.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,s){const n=e.gap,a=this.getNextFragment(this.nextLoadPosition,t);if(null===a)return a;if(e=a,n&&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>=s)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,s=!1,n=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(n=n&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(s||o.independent||n)&&o.fragment===t&&(i=a),s=l}return i}loadedEndOfParts(e,t){const r=e[e.length-1];return r&&t>r.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=Pr(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const s=r.sn+1;if(s>=e.startSN&&s<=e.endSN){const n=t[s-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=Nr(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:s}=this,{fragments:n,endSN:a}=r;const{fragmentHint:o}=r,l=i.maxFragLookUpTolerance,d=r.partList,h=!!(i.lowLatencyMode&&null!=d&&d.length&&o);let c;if(h&&o&&!this.bitrateTest&&(n=n.concat(o),a=o.sn),e<t){const r=e>t-l?0:l;c=Or(s,n,e,r)}else c=n[n.length-1];if(c){const e=c.sn-r.startSN,t=this.fragmentTracker.getState(c);if((t===di.OK||t===di.PARTIAL&&c.gap)&&(s=c),s&&c.sn===s.sn&&(!h||d[0].fragment.sn>c.sn)){const t=s&&c.level===s.level;if(t){const t=n[e+1];c=c.sn<a&&this.fragmentTracker.getState(t)!==di.OK?t:null}}}return c}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,s=r.currentTime,n=e.fragments[0].start,a=e.edge,o=s>=n-t.maxFragLookUpTolerance&&s<=a;if(null!==i&&r.duration>i&&(s<i||!o)){const n=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||s<a-n)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),r.currentTime=i))}}alignPlaylists(e,t,r){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const s=e.fragments[0].start,n=!t,a=e.alignedSliding&&u(s);if(n||!a&&!s){const{fragPrevious:s}=this;Si(s,r,e);const n=e.fragments[0].start;return this.log(`Live playlist sliding: ${n.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${s?s.sn:"na"} fragments: ${i}`),n}return s}waitForCdnTuneIn(e){const t=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*t)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){const i=null!==this.startTimeOffset,s=i?this.startTimeOffset:e.startTimeOffset;null!==s&&u(s)?(r=t+s,s<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${s} found in ${i?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Ni.FRAG_LOADING_WAITING_RETRY)||(this.state=Ni.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;var i;if(this.fragContextChanged(r))return void this.warn(`Frag load error must match current frag to retry ${r.url} > ${null==(i=this.fragCurrent)?void 0:i.url}`);const s=t.details===y.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(r,!0);const n=t.errorAction,{action:a,retryCount:o=0,retryConfig:l}=n||{};if(n&&a===Br.RetryRequest&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);const i=kr(l,o);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${o+1}/${l.maxNumRetry} in ${i}ms`),n.resolved=!0,this.retryDate=self.performance.now()+i,this.state=Ni.FRAG_LOADING_WAITING_RETRY}else if(l&&n){if(this.resetFragmentErrors(e),!(o<l.maxNumRetry))return void L.warn(`${t.details} reached or exceeded max retry (${o})`);s||a===Br.RemoveAlternatePermanently||(n.resolved=!0)}else(null==n?void 0:n.action)===Br.SendAlternateToPenaltyBox?this.state=Ni.WAITING_LEVEL:this.state=Ni.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Ni.PARSING||this.state===Ni.PARSED){const t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len);const s=!i;return s&&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(),s}return!1}resetFragmentErrors(e){e===Bt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ni.STOPPED&&(this.state=Ni.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;const i=pi.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Ni.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Ni.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){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(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){var s;const n=r.details;if(!n)return void this.warn("level.details undefined");const a=Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:pr(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(m.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1);if(!a&&null===(null==(s=this.transmuxer)?void 0:s.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(m.ERROR,{type:g.MEDIA_ERROR,details:y.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=Ni.PARSED,this.hls.trigger(m.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class Ui{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]:$i(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function $i(e,t){const r=new Uint8Array(t);let i=0;for(let s=0;s<e.length;s++){const t=e[s];r.set(t,i),i+=t.length}return r}function Gi(){return"function"===typeof __HLS_WORKER_BUNDLE__}function ji(){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),r=new self.Worker(t);return{worker:r,objectURL:t}}function Vi(e){const t=new self.URL(e,self.location.href).href,r=new self.Worker(t);return{worker:r,scriptURL:t}}function Ki(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Hi{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=Ve(this.cachedData,e),this.cachedData=null);let r,i=ie(e,0),s=i?i.length:0;const n=this._audioTrack,a=this._id3Track,o=i?ae(i):void 0,l=e.length;(null===this.basePTS||0===this.frameIndex&&u(o))&&(this.basePTS=Yi(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Wt.audioId3,duration:Number.POSITIVE_INFINITY});while(s<l){if(this.canParse(e,s)){const t=this.appendFrame(n,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,r=s):s=l}else ne(e,s)?(i=ie(e,s),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Wt.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===l&&r!==l){const t=ee(e,r);this.cachedData?this.cachedData=Ve(this.cachedData,t):this.cachedData=t}}return{audioTrack:n,videoTrack:Ki(),id3Track:a,textTrack:Ki()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ki(),id3Track:this._id3Track,textTrack:Ki()}}destroy(){}}const Yi=(e,t,r)=>{if(u(e))return 90*e;const i=r?9e4*r.baseTime/r.timescale:0;return 9e4*t+i};function zi(e,t,r,i){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),d=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=1+((192&t[r+2])>>>6);const c=(60&t[r+2])>>>2;if(!(c>h.length-1))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,L.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):-1!==l.indexOf("android")?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&c>=6?n=c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(c>=6&&1===a||/vivaldi/i.test(l))||!i&&1===a)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=a<<3,5===s&&(o[1]|=(14&n)>>1,o[2]=(1&n)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d};{const t=new Error("invalid ADTS sampling index:"+c);e.emit(m.ERROR,m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}}function qi(e,t){return 255===e[t]&&240===(246&e[t+1])}function Wi(e,t){return 1&e[t+1]?7:9}function Xi(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Qi(e,t){return t+5<e.length}function Zi(e,t){return t+1<e.length&&qi(e,t)}function Ji(e,t){return Qi(e,t)&&qi(e,t)&&Xi(e,t)<=e.length-t}function es(e,t){if(Zi(e,t)){const r=Wi(e,t);if(t+r>=e.length)return!1;const i=Xi(e,t);if(i<=r)return!1;const s=t+i;return s===e.length||Zi(e,s)}return!1}function ts(e,t,r,i,s){if(!e.samplerate){const n=zi(t,r,i,s);if(!n)return;e.config=n.config,e.samplerate=n.samplerate,e.channelCount=n.channelCount,e.codec=n.codec,e.manifestCodec=n.manifestCodec,L.log(`parsed codec:${e.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function rs(e){return 9216e4/e}function is(e,t){const r=Wi(e,t);if(t+r<=e.length){const i=Xi(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}function ss(e,t,r,i,s){const n=rs(e.samplerate),a=i+s*n,o=is(t,r);let l;if(o){const{frameLength:i,headerLength:s}=o,n=s+i,d=Math.max(0,r+n-t.length);d?(l=new Uint8Array(n-s),l.set(t.subarray(r+s,t.length),0)):l=t.subarray(r+s,r+n);const h={unit:l,pts:a};return d||e.samples.push(h),{sample:h,length:n,missing:d}}const d=t.length-r;l=new Uint8Array(d),l.set(t.subarray(r,t.length),0);const h={unit:l,pts:a};return{sample:h,length:d,missing:-1}}let ns=null;const as=[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],os=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ls=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ds=[0,1,1,4];function hs(e,t,r,i,s){if(r+24>t.length)return;const n=cs(t,r);if(n&&r+n.frameLength<=t.length){const a=9e4*n.samplesPerFrame/n.sampleRate,o=i+s*a,l={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function cs(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,s=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==s&&15!==s&&3!==n){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=3===r?3-i:3===i?3:4,d=1e3*as[14*l+s-1],h=3===r?0:2===r?1:2,c=os[3*h+n],u=3===o?1:2,f=ls[r][i],p=ds[i],m=8*f*p,g=Math.floor(f*d/c+a)*p;if(null===ns){const e=navigator.userAgent||"",t=e.match(/Chrome\/(\d+)/i);ns=t?parseInt(t[1]):0}const y=!!ns&&ns<=87;return y&&2===i&&d>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:g,samplesPerFrame:m}}}function us(e,t){return 255===e[t]&&224===(224&e[t+1])&&0!==(6&e[t+1])}function fs(e,t){return t+1<e.length&&us(e,t)}function ps(e,t){const r=4;return us(e,t)&&r<=e.length-t}function ms(e,t){if(t+1<e.length&&us(e,t)){const r=4,i=cs(e,t);let s=r;null!=i&&i.frameLength&&(s=i.frameLength);const n=t+s;return n===e.length||fs(e,n)}return!1}class gs extends Hi{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;const t=ie(e,0);let r=(null==t?void 0:t.length)||0;if(ms(e,r))return!1;for(let i=e.length;r<i;r++)if(es(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Ji(e,t)}appendFrame(e,t,r){ts(e,this.observer,t,r,e.manifestCodec);const i=ss(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}const ys=/\/emsg[-/]ID3/i;class vs{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 s=this.videoTrack=Ki("video",1),n=this.audioTrack=Ki("audio",1),a=this.txtTrack=Ki("text",1);if(this.id3Track=Ki("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=xe(e);if(o.video){const{id:e,timescale:t,codec:r}=o.video;s.id=e,s.timescale=a.timescale=t,s.codec=r}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;n.id=e,n.timescale=t,n.codec=r}a.id=be.text,s.sampleDuration=0,s.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return ke(e)}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ve(this.remainderData,e));const t=je(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const n=this.extractID3Track(i,t);return s.samples=Ke(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,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=Ke(e,t),{videoTrack:t,audioTrack:Ki(),id3Track:i,textTrack:Ki()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=De(e.samples,["emsg"]);i&&i.forEach(e=>{const i=We(e);if(ys.test(i.schemeIdUri)){const e=u(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale;let s=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);const n=i.payload;r.samples.push({data:n,len:n.byteLength,dts:e,pts:e,type:Wt.emsg,duration:s})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const _s=(e,t)=>{let r=0,i=5;t+=i;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);while(i>0){a[0]=e[t];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,r=r?r<<o|s[0]:s[0],t+=1,i-=o}return r};class Es extends Hi{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const i=bs(e,t,r,this.basePTS,this.frameIndex);if(-1!==i){const t=e.samples[e.samples.length-1];return{sample:t,length:i,missing:0}}}static probe(e){if(!e)return!1;const t=ie(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==ae(t)&&_s(e,r)<16}}function bs(e,t,r,i,s){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const n=t[r+4]>>6;if(n>=3)return-1;const a=[48e3,44100,32e3],o=a[n],l=63&t[r+4],d=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920],h=2*d[3*l+n];if(r+h>t.length)return-1;const c=t[r+6]>>5;let u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));const f=(t[r+6]<<8|t[r+7])>>12-u&1,p=[2,1,2,3,3,4,4,5],m=p[c]+f,g=t[r+5]>>3,y=7&t[r+5],v=new Uint8Array([n<<6|g<<1|y>>2,(3&y)<<6|c<<3|f<<2|l>>4,l<<4&224]),_=1536/o*9e4,E=i+s*_,b=t.subarray(r,r+h);return e.config=v,e.channelCount=m,e.samplerate=o,e.samples.push({unit:b,pts:E}),h}class Ss{constructor(){this.VideoSample=null}createVideoSample(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;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}pushAccessUnit(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&&L.log(e.pts+"/"+e.dts+":"+e.debug)}}class Ts{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");i.set(e.subarray(r,r+s)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>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&&L.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<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>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 s=0;s<e;s++)0!==i&&(t=this.readEG(),i=(r+t+256)%256),r=0===i?r:i}readSPS(){let e,t,r,i=0,s=0,n=0,a=0;const o=this.readUByte.bind(this),l=this.readBits.bind(this),d=this.readUEG.bind(this),h=this.readBoolean.bind(this),c=this.skipBits.bind(this),u=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();const m=o();if(l(5),c(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=d();if(3===e&&c(1),f(),f(),c(1),h())for(t=3!==e?8:12,r=0;r<t;r++)h()&&p(r<6?16:64)}f();const g=d();if(0===g)d();else if(1===g)for(c(1),u(),u(),e=d(),r=0;r<e;r++)u();f(),c(1);const y=d(),v=d(),_=l(1);0===_&&c(1),c(1),h()&&(i=d(),s=d(),n=d(),a=d());let E=[1,1];if(h()&&h()){const e=o();switch(e){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()];break}}return{width:Math.ceil(16*(y+1)-2*i-2*s),height:(2-_)*(v+1)*16-(_?2:4)*(n+a),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Ls extends Ss{parseAVCPES(e,t,r,i,s){const n=this.parseAVCNALu(e,r.data);let a,o=this.VideoSample,l=!1;r.data=null,o&&n.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),n.forEach(i=>{var n;switch(i.type){case 1:{let t=!1;a=!0;const s=i.data;if(l&&s.length>4){const e=new Ts(s).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var d;if(t)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=t;break}case 5:a=!0,null!=(n=o)&&n.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,ze(i.data,1,r.pts,t.samples);break;case 7:{var h,c;a=!0,l=!0;const t=i.data,r=new Ts(t),n=r.readSPS();if(!e.sps||e.width!==n.width||e.height!==n.height||(null==(h=e.pixelRatio)?void 0:h[0])!==n.pixelRatio[0]||(null==(c=e.pixelRatio)?void 0:c[1])!==n.pixelRatio[1]){e.width=n.width,e.height=n.height,e.pixelRatio=n.pixelRatio,e.sps=[t],e.duration=s;const r=t.subarray(1,4);let i="avc1.";for(let e=0;e<3;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),i+=t}e.codec=i}break}case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+i.type+" ");break}if(o&&a){const e=o.units;e.push(i)}}),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const r=t.byteLength;let i=e.naluState||0;const s=i,n=[];let a,o,l,d=0,h=-1,c=0;-1===i&&(h=0,c=31&t[0],i=0,d=1);while(d<r)if(a=t[d++],i)if(1!==i)if(a)if(1===a){if(o=d-i-1,h>=0){const e={data:t.subarray(h,o),type:c};n.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(s&&d<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),o>0&&(r.data=Ve(r.data,t.subarray(0,o)),r.state=0))}d<r?(l=31&t[d],h=d,c=l,i=0):i=-1}else i=0;else i=3;else i=a?0:2;else i=a?0:1;if(h>=0&&i>=0){const e={data:t.subarray(h,r),type:c,state:i};n.push(e)}if(0===n.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=Ve(r.data,t))}return e.naluState=i,n}}class As{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Mi(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const s=i.subarray(16,i.length-i.length%16),n=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(n).then(s=>{const n=new Uint8Array(s);i.set(n,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 s=32;s<e.length-16;s+=160,i+=16)r.set(e.subarray(s,s+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let s=32;s<e.length-16;s+=160,i+=16)e.set(r.subarray(i,i+16),s);return e}decryptAvcSample(e,t,r,i,s){const n=qe(s.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then(a=>{s.data=this.getAvcDecryptedUnit(n,a),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 s=e[t].units;for(;;r++){if(r>=s.length)break;const n=s[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type)&&(this.decryptAvcSample(e,t,r,i,n),!this.decrypter.isSync()))return}}}}const Rs=188;class ws{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._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new Ls}static probe(e){const t=ws.syncOffset(e);return t>0&&L.warn("MPEG2-TS detected but first sync word found @ offset "+t),-1!==t}static syncOffset(e){const t=e.length;let r=Math.min(5*Rs,t-Rs)+1,i=0;while(i<r){let s=!1,n=-1,a=0;for(let o=i;o<t;o+=Rs){if(71!==e[o]||t-o!==Rs&&71!==e[o+Rs]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(r=Math.min(n+99*Rs,e.length-Rs)+1)),s||(s=0===ks(e,o)),s&&a>1&&(0===n&&a>2||o+Rs>r))return n}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:be[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._videoTrack=ws.createTrack("video"),this._audioTrack=ws.createTrack("audio",i),this._id3Track=ws.createTrack("id3"),this._txtTrack=ws.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let s;r||(this.sampleAes=null);const n=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let d=n.pid,h=n.pesData,c=a.pid,u=o.pid,f=a.pesData,p=o.pesData,v=null,_=this.pmtParsed,E=this._pmtId,b=e.length;if(this.remainderData&&(e=Ve(this.remainderData,e),b=e.length,this.remainderData=null),b<Rs&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const S=Math.max(0,ws.syncOffset(e));b-=(b-S)%Rs,b<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let T=0;for(let m=S;m<b;m+=Rs)if(71===e[m]){const t=!!(64&e[m+1]),i=ks(e,m),g=(48&e[m+3])>>4;let y;if(g>1){if(y=m+5+e[m+4],y===m+Rs)continue}else y=m+4;switch(i){case d:t&&(h&&(s=Cs(h))&&this.videoParser.parseAVCPES(n,l,s,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(e.subarray(y,m+Rs)),h.size+=m+Rs-y);break;case c:if(t){if(f&&(s=Cs(f)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,s);break;case"mp3":this.parseMPEGPES(a,s);break;case"ac3":this.parseAC3PES(a,s);break}f={data:[],size:0}}f&&(f.data.push(e.subarray(y,m+Rs)),f.size+=m+Rs-y);break;case u:t&&(p&&(s=Cs(p))&&this.parseID3PES(o,s),p={data:[],size:0}),p&&(p.data.push(e.subarray(y,m+Rs)),p.size+=m+Rs-y);break;case 0:t&&(y+=e[y]+1),E=this._pmtId=Ds(e,y);break;case E:{t&&(y+=e[y]+1);const i=Is(e,y,this.typeSupported,r);d=i.videoPid,d>0&&(n.pid=d,n.segmentCodec=i.segmentVideoCodec),c=i.audioPid,c>0&&(a.pid=c,a.segmentCodec=i.segmentAudioCodec),u=i.id3Pid,u>0&&(o.pid=u),null===v||_||(L.warn(`MPEG-TS PMT found at ${m} after unknown PID '${v}'. Backtracking to sync byte @${S} to parse all TS packets.`),v=null,m=S-188),_=this.pmtParsed=!0;break}case 17:case 8191:break;default:v=i;break}}else T++;if(T>0){const e=new Error(`Found ${T} TS packet/s that do not start with 0x47`);this.observer.emit(m.ERROR,m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message})}n.pesData=h,a.pesData=f,o.pesData=p;const A={audioTrack:a,videoTrack:n,id3Track:o,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._videoTrack,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:s}=e,n=r.pesData,a=t.pesData,o=i.pesData;let l;if(n&&(l=Cs(n))?(this.videoParser.parseAVCPES(r,s,l,!0,this._duration),r.pesData=null):r.pesData=n,a&&(l=Cs(a))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l);break}t.pesData=null}else null!=a&&a.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=Cs(o))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),s=this.sampleAes=new As(this.observer,this.config,t);return this.decrypt(i,s)}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:s}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{r(e)}):r(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let s,n,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,s=i.sample.unit.byteLength;if(-1===t)o=Ve(i.sample.unit,o);else{const n=s-t;i.sample.unit.set(o.subarray(0,t),n),e.samples.push(i.sample),r=i.missing}}for(s=r,n=o.length;s<n-1;s++)if(Zi(o,s))break;if(s!==r){let e;const t=s<n-1;e=t?"AAC PES did not start with ADTS header,offset:"+s:"No ADTS header found in AAC PES";const r=new Error(e);if(L.warn("parsing error: "+e),this.observer.emit(m.ERROR,m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:r,reason:e}),!t)return}if(ts(e,this.observer,o,s,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void L.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=rs(e.samplerate);a=i.sample.pts+t}}let l,d=0;while(s<n){if(l=ss(e,o,s,a,d),s+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;s<n-1;s++)if(Zi(o,s))break}}parseMPEGPES(e,t){const r=t.data,i=r.length;let s=0,n=0;const a=t.pts;if(void 0!==a)while(n<i)if(fs(r,n)){const t=hs(e,r,n,a,s);if(!t)break;n+=t.length,s++}else n++;else L.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const r=t.data,i=t.pts;if(void 0===i)return void L.warn("[tsdemuxer]: AC3 PES unknown PTS");const s=r.length;let n,a=0,o=0;while(o<s&&(n=bs(e,r,o,i,a++))>0)o+=n}}parseID3PES(e,t){if(void 0===t.pts)return void L.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=c({},t,{type:this._videoTrack?Wt.emsg:Wt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function ks(e,t){return((31&e[t+1])<<8)+e[t+2]}function Ds(e,t){return(31&e[t+10])<<8|e[t+11]}function Is(e,t,r,i){const s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},n=(15&e[t+1])<<8|e[t+2],a=t+3+n-4,o=(15&e[t+10])<<8|e[t+11];t+=12+o;while(t<a){const n=ks(e,t),a=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){xs("ADTS AAC");break}case 15:-1===s.audioPid&&(s.audioPid=n);break;case 21:-1===s.id3Pid&&(s.id3Pid=n);break;case 219:if(!i){xs("H.264");break}case 27:-1===s.videoPid&&(s.videoPid=n,s.segmentVideoCodec="avc");break;case 3:case 4:r.mpeg||r.mp3?-1===s.audioPid&&(s.audioPid=n,s.segmentAudioCodec="mp3"):L.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){xs("AC-3");break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=n,s.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&a>0){let i=t+5,o=a;while(o>2){const t=e[i];switch(t){case 106:!0!==r.ac3?L.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=n,s.segmentAudioCodec="ac3");break}const a=e[i+1]+2;i+=a,o-=a}}break;case 194:case 135:throw new Error("Unsupported EC-3 in M2TS found");case 36:throw new Error("Unsupported HEVC in M2TS found")}t+=a+5}return s}function xs(e){L.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Cs(e){let t,r,i,s,n,a=0;const o=e.data;if(!e||0===e.size)return null;while(o[0].length<19&&o.length>1)o[0]=Ve(o[0],o[1]),o.splice(1,1);t=o[0];const l=(t[0]<<16)+(t[1]<<8)+t[2];if(1===l){if(r=(t[4]<<8)+t[5],r&&r>e.size-6)return null;const l=t[7];192&l&&(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?(n=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,s-n>54e5&&(L.warn(Math.round((s-n)/9e4)+"s delta between PTS and DTS, align them"),s=n)):n=s),i=t[8];let d=i+9;if(e.size<=d)return null;e.size-=d;const h=new Uint8Array(e.size);for(let e=0,r=o.length;e<r;e++){t=o[e];let r=t.byteLength;if(d){if(d>r){d-=r;continue}t=t.subarray(d),r-=d,d=0}h.set(t,a),a+=r}return r&&(r-=i+3),{data:h,pts:s,dts:n,len:r}}return null}class Ps extends Hi{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ie(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==ae(t)&&_s(e,r)<=16)return!1;for(let i=e.length;r<i;r++)if(ms(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return ps(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return hs(e,t,r,this.basePTS,this.frameIndex)}}class Os{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":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]);break;default: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]);break}}}const Ms=Math.pow(2,32)-1;class Fs{static init(){let e;for(e in Fs.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Fs.types)Fs.types.hasOwnProperty(e)&&(Fs.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]);Fs.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]),s=new Uint8Array([0,0,0,0,0,0,0,0]);Fs.STTS=Fs.STSC=Fs.STCO=s,Fs.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Fs.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Fs.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Fs.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Fs.FTYP=Fs.box(Fs.types.ftyp,n,o,n,a),Fs.DINF=Fs.box(Fs.types.dinf,Fs.box(Fs.types.dref,i))}static box(e,...t){let r=8,i=t.length;const s=i;while(i--)r+=t[i].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),i=0,r=8;i<s;i++)n.set(t[i],r),r+=t[i].byteLength;return n}static hdlr(e){return Fs.box(Fs.types.hdlr,Fs.HDLR_TYPES[e])}static mdat(e){return Fs.box(Fs.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(Ms+1)),i=Math.floor(t%(Ms+1));return Fs.box(Fs.types.mdhd,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,85,196,0,0]))}static mdia(e){return Fs.box(Fs.types.mdia,Fs.mdhd(e.timescale,e.duration),Fs.hdlr(e.type),Fs.minf(e))}static mfhd(e){return Fs.box(Fs.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?Fs.box(Fs.types.minf,Fs.box(Fs.types.smhd,Fs.SMHD),Fs.DINF,Fs.stbl(e)):Fs.box(Fs.types.minf,Fs.box(Fs.types.vmhd,Fs.VMHD),Fs.DINF,Fs.stbl(e))}static moof(e,t,r){return Fs.box(Fs.types.moof,Fs.mfhd(e),Fs.traf(r,t))}static moov(e){let t=e.length;const r=[];while(t--)r[t]=Fs.trak(e[t]);return Fs.box.apply(null,[Fs.types.moov,Fs.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(Fs.mvex(e)))}static mvex(e){let t=e.length;const r=[];while(t--)r[t]=Fs.trex(e[t]);return Fs.box.apply(null,[Fs.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(Ms+1)),i=Math.floor(t%(Ms+1)),s=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 Fs.box(Fs.types.mvhd,s)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,s;for(i=0;i<t.length;i++)s=t[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return Fs.box(Fs.types.sdtp,r)}static stbl(e){return Fs.box(Fs.types.stbl,Fs.stsd(e),Fs.box(Fs.types.stts,Fs.STTS),Fs.box(Fs.types.stsc,Fs.STSC),Fs.box(Fs.types.stsz,Fs.STSZ),Fs.box(Fs.types.stco,Fs.STCO))}static avc1(e){let t,r,i,s=[],n=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));const a=Fs.box(Fs.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(n))),o=e.width,l=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return Fs.box(Fs.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,Fs.box(Fs.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Fs.box(Fs.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}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 audioStsd(e){const t=e.samplerate;return 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 mp4a(e){return Fs.box(Fs.types.mp4a,Fs.audioStsd(e),Fs.box(Fs.types.esds,Fs.esds(e)))}static mp3(e){return Fs.box(Fs.types[".mp3"],Fs.audioStsd(e))}static ac3(e){return Fs.box(Fs.types["ac-3"],Fs.audioStsd(e),Fs.box(Fs.types.dac3,e.config))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?Fs.box(Fs.types.stsd,Fs.STSD,Fs.mp3(e)):"ac3"===e.segmentCodec?Fs.box(Fs.types.stsd,Fs.STSD,Fs.ac3(e)):Fs.box(Fs.types.stsd,Fs.STSD,Fs.mp4a(e)):Fs.box(Fs.types.stsd,Fs.STSD,Fs.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,i=e.width,s=e.height,n=Math.floor(r/(Ms+1)),a=Math.floor(r%(Ms+1));return Fs.box(Fs.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,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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,s>>8&255,255&s,0,0]))}static traf(e,t){const r=Fs.sdtp(e),i=e.id,s=Math.floor(t/(Ms+1)),n=Math.floor(t%(Ms+1));return Fs.box(Fs.types.traf,Fs.box(Fs.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Fs.box(Fs.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,n>>24,n>>16&255,n>>8&255,255&n])),Fs.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Fs.box(Fs.types.trak,Fs.tkhd(e),Fs.mdia(e))}static trex(e){const t=e.id;return Fs.box(Fs.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,s=12+16*i,n=new Uint8Array(s);let a,o,l,d,h,c;for(t+=8+s,n.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),a=0;a<i;a++)o=r[a],l=o.duration,d=o.size,h=o.flags,c=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*a);return Fs.box(Fs.types.trun,n)}static initSegment(e){Fs.types||Fs.init();const t=Fs.moov(e),r=Ve(Fs.FTYP,t);return r}}Fs.types=void 0,Fs.HDLR_TYPES=void 0,Fs.STTS=void 0,Fs.STSC=void 0,Fs.STCO=void 0,Fs.STSZ=void 0,Fs.VMHD=void 0,Fs.SMHD=void 0,Fs.STSD=void 0,Fs.FTYP=void 0,Fs.DINF=void 0;const Ns=9e4;function Bs(e,t,r=1,i=!1){const s=e*t*r;return i?Math.round(s):s}function Us(e,t,r=1,i=!1){return Bs(e,t,1/r,i)}function $s(e,t=!1){return Bs(e,1e3,1/Ns,t)}function Gs(e,t=1){return Bs(e,Ns,1/t)}const js=1e4,Vs=1024,Ks=1152,Hs=1536;let Ys,zs=null,qs=null;class Ws{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.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===zs){const e=navigator.userAgent||"",t=e.match(/Chrome\/(\d+)/i);zs=t?parseInt(t[1]):0}if(null===qs){const e=navigator.userAgent.match(/Safari\/(\d+)/i);qs=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e.reduce((e,r)=>{const i=r.pts-e;return i<-4294967296?(t=!0,Xs(e,r.pts)):i>0?e:r.pts},e[0].pts);return t&&L.debug("PTS rollover detected"),r}remux(e,t,r,i,s,n,a,o){let l,d,h,c,u,f,p=s,m=s;const g=e.pid>-1,y=t.pid>-1,v=t.samples.length,_=e.samples.length>0,E=a&&v>0||v>1,b=(!g||_)&&(!y||E)||this.ISGenerated||a;if(b){if(this.ISGenerated){var S,T,A,R;const e=this.videoTrackConfig;!e||t.width===e.width&&t.height===e.height&&(null==(S=t.pixelRatio)?void 0:S[0])===(null==(T=e.pixelRatio)?void 0:T[0])&&(null==(A=t.pixelRatio)?void 0:A[1])===(null==(R=e.pixelRatio)?void 0:R[1])||this.resetInitSegment()}else h=this.generateIS(e,t,s,n);const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=Qs(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){L.warn(`[mp4-remuxer]: Dropped ${a} out of ${v} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),f=!1);if(this.ISGenerated){if(_&&E){const r=this.getVideoStartPts(t.samples),i=Xs(e.samples[0].pts,r)-r,s=i/t.inputTimeScale;p+=Math.max(0,s),m+=Math.max(0,-s)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,s,n)),d=this.remuxAudio(e,p,this.isAudioContiguous,n,y||E||o===Bt.AUDIO?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,s,n)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(u=Zs(r,s,this._initPTS,this._initDTS)),i.samples.length&&(c=Js(i,s,this._initPTS))),{audio:d,video:l,initSegment:h,independent:f,text:c,id3:u}}generateIS(e,t,r,i){const s=e.samples,n=t.samples,a=this.typeSupported,o={},l=this._initPTS;let d,h,c,u=!l||i,f="audio/mp4";if(u&&(d=h=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):Fs.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(c=e.inputTimeScale,l&&c===l.timescale?u=!1:d=h=s[0].pts-Math.round(c*r))}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Fs.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(c=t.inputTimeScale,l&&c===l.timescale)u=!1;else{const e=this.getVideoStartPts(n),t=Math.round(c*r);h=Math.min(h,Xs(n[0].dts,e)-t),d=Math.min(d,e-t)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:d,timescale:c},this._initDTS={baseTime:h,timescale:c}):d=c=void 0,{tracks:o,initPTS:d,timescale:c}}remuxVideo(e,t,r,i){const s=e.inputTimeScale,n=e.samples,a=[],o=n.length,l=this._initPTS;let d,h,u=this.nextAvcDts,f=8,p=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,E=!1;if(!r||null===u){const e=t*s,i=n[0].pts-Xs(n[0].dts,n[0].pts);zs&&null!==u&&Math.abs(e-i-u)<15e3?r=!0:u=e-i}const b=l.baseTime*s/l.timescale;for(let c=0;c<o;c++){const e=n[c];e.pts=Xs(e.pts-b,u),e.dts=Xs(e.dts-b,u),e.dts<n[c>0?c-1:c].dts&&(E=!0)}E&&n.sort((function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),d=n[0].dts,h=n[n.length-1].dts;const S=h-d,T=S?Math.round(S/(o-1)):p||e.inputTimeScale/30;if(r){const e=d-u,r=e>T,i=e<-1;if((r||i)&&(r?L.warn(`AVC: ${$s(e,!0)} ms (${e}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${$s(-e,!0)} ms (${e}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!i||u>=n[0].pts||zs)){d=u;const t=n[0].pts-e;if(r)n[0].dts=d,n[0].pts=t;else for(let r=0;r<n.length;r++){if(n[r].dts>t)break;n[r].dts-=e,n[r].pts-=e}L.log(`Video: Initial PTS/DTS adjusted: ${$s(t,!0)}/${$s(d,!0)}, delta: ${$s(e,!0)} ms`)}}d=Math.max(0,d);let A=0,R=0,w=d;for(let c=0;c<o;c++){const e=n[c],t=e.units,r=t.length;let i=0;for(let s=0;s<r;s++)i+=t[s].data.length;R+=i,A+=r,e.length=i,e.dts<w?(e.dts=w,w+=T/4|0||1):w=e.dts,v=Math.min(e.pts,v),_=Math.max(e.pts,_)}h=n[o-1].dts;const k=R+4*A+8;let D;try{D=new Uint8Array(k)}catch(U){return void this.observer.emit(m.ERROR,m.ERROR,{type:g.MUX_ERROR,details:y.REMUX_ALLOC_ERROR,fatal:!1,error:U,bytes:k,reason:"fail allocating video mdat "+k})}const I=new DataView(D.buffer);I.setUint32(0,k),D.set(Fs.types.mdat,4);let x=!1,C=Number.POSITIVE_INFINITY,P=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(let c=0;c<o;c++){const e=n[c],t=e.units;let r,l=0;for(let i=0,s=t.length;i<s;i++){const e=t[i],r=e.data,s=e.data.byteLength;I.setUint32(f,s),f+=4,D.set(r,f),f+=s,l+=4+s}if(c<o-1)p=n[c+1].dts-e.dts,r=n[c+1].pts-e.pts;else{const t=this.config,a=c>0?e.dts-n[c-1].dts:T;if(r=c>0?e.pts-n[c-1].pts:T,t.stretchShortVideoTrack&&null!==this.nextAudioPts){const r=Math.floor(t.maxBufferHole*s),n=(i?v+i*s:this.nextAudioPts)-e.pts;n>r?(p=n-a,p<0?p=a:x=!0,L.log(`[mp4-remuxer]: It is approximately ${n/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}const d=Math.round(e.pts-e.dts);C=Math.min(C,p),O=Math.max(O,p),P=Math.min(P,r),M=Math.max(M,r),a.push(new en(e.key,p,l,d))}if(a.length)if(zs){if(zs<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(qs&&M-P<O-C&&T/O<.025&&0===a[0].cts){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,s=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-s}else a[t].duration=t?a[t-1].duration:T;a[t].cts=0,e=i}}p=x||!p?T:p,this.nextAvcDts=u=h+p,this.videoSampleDuration=p,this.isVideoContiguous=!0;const F=Fs.moof(e.sequenceNumber++,d,c({},e,{samples:a})),N="video",B={data1:F,data2:D,startPTS:v/s,endPTS:(_+p)/s,startDTS:d/s,endDTS:u/s,type:N,hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,B}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Ks;case"ac3":return Hs;default:return Vs}}remuxAudio(e,t,r,i,s){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.getSamplesPerFrame(e),d=l*o,h=this._initPTS,u="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],p=void 0!==s;let v=e.samples,_=u?0:8,E=this.nextAudioPts||-1;const b=t*n,S=h.baseTime*n/h.timescale;if(this.isAudioContiguous=r=r||v.length&&E>0&&(i&&Math.abs(b-E)<9e3||Math.abs(Xs(v[0].pts-S,b)-E)<20*d),v.forEach((function(e){e.pts=Xs(e.pts-S,b)})),!r||E<0){if(v=v.filter(e=>e.pts>=0),!v.length)return;E=0===s?0:i&&!p?Math.max(0,b):v[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=E;r<v.length;r++){const s=v[r],a=s.pts,o=a-i,l=Math.abs(1e3*o/n);if(o<=-t*d&&p)0===r&&(L.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*o/n)} ms.`),this.nextAudioPts=E=i=a);else if(o>=t*d&&l<js&&p){let t=Math.round(o/d);i=a-t*d,i<0&&(t--,i+=d),0===r&&(this.nextAudioPts=E=i),L.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let n=0;n<t;n++){const t=Math.max(i,0);let n=Os.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);n||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),n=s.unit.subarray()),v.splice(r,0,{unit:n,pts:t}),i+=d,r++}}s.pts=i,i+=d}}let T,A=null,R=null,w=0,k=v.length;while(k--)w+=v[k].unit.byteLength;for(let c=0,L=v.length;c<L;c++){const t=v[c],i=t.unit;let s=t.pts;if(null!==R){const e=f[c-1];e.duration=Math.round((s-R)/o)}else{if(r&&"aac"===e.segmentCodec&&(s=E),A=s,!(w>0))return;w+=_;try{T=new Uint8Array(w)}catch(F){return void this.observer.emit(m.ERROR,m.ERROR,{type:g.MUX_ERROR,details:y.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:w,reason:"fail allocating audio mdat "+w})}if(!u){const e=new DataView(T.buffer);e.setUint32(0,w),T.set(Fs.types.mdat,4)}}T.set(i,_);const n=i.byteLength;_+=n,f.push(new en(!0,l,n,0)),R=s}const D=f.length;if(!D)return;const I=f[f.length-1];this.nextAudioPts=E=R+o*I.duration;const x=u?new Uint8Array(0):Fs.moof(e.sequenceNumber++,A/o,c({},e,{samples:f}));e.samples=[];const C=A/n,P=E/n,O="audio",M={data1:x,data2:T,startPTS:C,endPTS:P,startDTS:C,endDTS:P,type:O,hasAudio:!0,hasVideo:!1,nb:D};return this.isAudioContiguous=!0,M}remuxEmptyAudio(e,t,r,i){const s=e.inputTimeScale,n=e.samplerate?e.samplerate:s,a=s/n,o=this.nextAudioPts,l=this._initDTS,d=9e4*l.baseTime/l.timescale,h=(null!==o?o:i.startDTS*s)+d,c=i.endDTS*s+d,u=a*Vs,f=Math.ceil((c-h)/u),p=Os.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!p)return void L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const m=[];for(let g=0;g<f;g++){const e=h+g*u;m.push({unit:p,pts:e,dts:e})}return e.samples=m,this.remuxAudio(e,t,r,!1)}}function Xs(e,t){let r;if(null===t)return e;r=t<e?-8589934592:8589934592;while(Math.abs(e-t)>4294967296)e+=r;return e}function Qs(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}function Zs(e,t,r,i){const s=e.samples.length;if(!s)return;const n=e.inputTimeScale;for(let o=0;o<s;o++){const s=e.samples[o];s.pts=Xs(s.pts-r.baseTime*n/r.timescale,t*n)/n,s.dts=Xs(s.dts-i.baseTime*n/i.timescale,t*n)/n}const a=e.samples;return e.samples=[],{samples:a}}function Js(e,t,r){const i=e.samples.length;if(!i)return;const s=e.inputTimeScale;for(let a=0;a<i;a++){const i=e.samples[a];i.pts=Xs(i.pts-r.baseTime*s/r.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);const n=e.samples;return e.samples=[],{samples:n}}class en{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={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class tn{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(Fe(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=xe(e);i.audio&&(t=sn(i.audio,C.AUDIO)),i.video&&(r=sn(i.video,C.VIDEO));const s={};i.audio&&i.video?s.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?s.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?s.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s}remux(e,t,r,i,s,n){var a,o;let{initPTS:l,lastEndTime:d}=this;const h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};u(d)||(d=this.lastEndTime=s||0);const c=t.samples;if(null==c||!c.length)return h;const f={initPTS:void 0,timescale:1};let p=this.initData;if(null!=(a=p)&&a.length||(this.generateInitSegment(c),p=this.initData),null==(o=p)||!o.length)return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const m=Ue(c,p),g=Be(p,c),y=null===g?s:g;(rn(l,y,s,m)||f.timescale!==l.timescale&&n)&&(f.initPTS=y-s,l&&1===l.timescale&&L.warn("Adjusting initPTS by "+(f.initPTS-l.baseTime)),this.initPTS=l={baseTime:f.initPTS,timescale:1});const v=e?y-l.baseTime/l.timescale:d,_=v+m;Ge(p,c,l.baseTime/l.timescale),m>0?this.lastEndTime=_:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const E=!!p.audio,b=!!p.video;let S="";E&&(S+="audio"),b&&(S+="video");const T={data1:c,startPTS:v,startDTS:v,endPTS:_,endDTS:_,type:S,hasAudio:E,hasVideo:b,nb:1,dropped:0};return h.audio="audio"===T.type?T:void 0,h.video="audio"!==T.type?T:void 0,h.initSegment=f,h.id3=Zs(r,s,l,l),i.samples.length&&(h.text=Js(i,s,l)),h}}function rn(e,t,r,i){if(null===e)return!0;const s=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>s}function sn(e,t){const r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===C.AUDIO){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){const e=!1;return Et(r,e)}const e="mp4a.40.5";return L.info(`Parsed audio codec "${r}" or audio object type not handled. Using "${e}"`),e}return L.warn(`Unhandled video codec "${r}"`),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}try{Ys=self.performance.now.bind(self.performance)}catch(Al){L.debug("Unable to use Performance API on this environment"),Ys=null==V?void 0:V.Date.now}const nn=[{demux:vs,remux:tn},{demux:ws,remux:Ws},{demux:gs,remux:Ws},{demux:Ps,remux:Ws}];nn.splice(2,0,{demux:Es,remux:Ws});class an{constructor(e,t,r,i,s){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const s=r.transmuxing;s.executeStart=Ys();let n=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:h,accurateTimeOffset:c,timeOffset:u,initSegmentChange:f}=i||a,{audioCodec:p,videoCodec:v,defaultInitPts:_,duration:E,initSegmentData:b}=o,S=on(n,t);if(S&&"AES-128"===S.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(n,S.key.buffer,S.iv.buffer).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(n,S.key.buffer,S.iv.buffer);const i=r.part>-1;if(i&&(t=e.flush()),!t)return s.executeEnd=Ys(),ln(r);n=new Uint8Array(t)}}const T=this.needsProbing(d,h);if(T){const e=this.configureTransmuxer(n);if(e)return L.warn("[transmuxer] "+e.message),this.observer.emit(m.ERROR,m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=Ys(),ln(r)}(d||h||f||T)&&this.resetInitSegment(b,p,v,E,t),(d||f||T)&&this.resetInitialTimestamp(_),l||this.resetContiguity();const A=this.transmux(n,S,u,c,r),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,s.executeEnd=Ys(),A}flush(e){const t=e.transmuxing;t.executeStart=Ys();const{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return s.then(()=>this.flush(e));const n=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&n.push(this.push(t,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return t.executeEnd=Ys(),[ln(e)];const d=o.flush(a);return dn(d)?d.then(t=>(this.flushRemux(n,t,e),n)):(this.flushRemux(n,d,e),n)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:s,id3Track:n,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const d=this.remuxer.remux(i,s,n,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=Ys()}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,s){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,s){let n;return n=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,s):this.transmuxUnencrypted(e,r,i,s),n}transmuxUnencrypted(e,t,r,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive),l=this.remuxer.remux(s,n,a,o,t,r,!1,this.id);return{remuxResult:l,chunkMeta:i}}transmuxSampleAes(e,t,r,i,s){return this.demuxer.demuxSampleAes(e,t,r).then(e=>{const t=this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id);return{remuxResult:t,chunkMeta:s}})}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i,vendor:s}=this;let n;for(let c=0,u=nn.length;c<u;c++){var a;if(null!=(a=nn[c].demux)&&a.probe(e)){n=nn[c];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,d=n.remux,h=n.demux;l&&l instanceof d||(this.remuxer=new d(r,t,i,s)),o&&o instanceof h||(this.demuxer=new h(r,t,i),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Mi(this.config)),e}}function on(e,t){let r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}const ln=e=>({remuxResult:{},chunkMeta:e});function dn(e){return"then"in e&&e.then instanceof Function}class hn{constructor(e,t,r,i,s){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=s||null}}class cn{constructor(e,t,r,i,s,n){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=s,this.initSegmentChange=n}}var un={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,a){if("function"!==typeof i)throw new TypeError("The listener must be a function");var o=new s(i,n||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.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 s=0,n=i.length,a=new Array(n);s<n;s++)a[s]=i[s].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,s,n,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,d,h=this._events[o],c=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),c){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,i),!0;case 4:return h.fn.call(h.context,t,i,s),!0;case 5:return h.fn.call(h.context,t,i,s,n),!0;case 6:return h.fn.call(h.context,t,i,s,n,a),!0}for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];h.fn.apply(h.context,l)}else{var u,f=h.length;for(d=0;d<f;d++)switch(h[d].once&&this.removeListener(e,h[d].fn,void 0,!0),c){case 1:h[d].fn.call(h[d].context);break;case 2:h[d].fn.call(h[d].context,t);break;case 3:h[d].fn.call(h[d].context,t,i);break;case 4:h[d].fn.call(h[d].context,t,i,s);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];h[d].fn.apply(h[d].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||s&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,d=[],h=o.length;l<h;l++)(o[l].fn!==t||s&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[n]=1===d.length?d[0]:d:a(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o})(un);var fn=un.exports,pn=i(fn);class mn{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 s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const n=(e,t)=>{t=t||{},t.frag=this.frag,t.id=this.id,e===m.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new pn,this.observer.on(m.FRAG_DECRYPTED,n),this.observer.on(m.ERROR,n);const a=lt(s.preferManagedMediaSource)||{isTypeSupported:()=>!1},o={mpeg:a.isTypeSupported("audio/mpeg"),mp3:a.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:a.isTypeSupported('audio/mp4; codecs="ac-3"')},l=navigator.vendor;if(this.useWorker&&"undefined"!==typeof Worker){const e=s.workerPath||Gi();if(e){try{s.workerPath?(L.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=Vi(s.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=ji()),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})`);s.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(m.ERROR,{type:g.OTHER_ERROR,details:y.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},e.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(s)})}catch(Al){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,Al),this.resetWorker(),this.error=null,this.transmuxer=new an(this.observer,o,s,l,t)}return}}this.transmuxer=new an(this.observer,o,s,l,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,s,n,a,o,l,d){var h,c;l.transmuxing.start=self.performance.now();const{transmuxer:u}=this,f=n?n.start:s.start,p=s.decryptdata,m=this.frag,g=!(m&&s.cc===m.cc),y=!(m&&l.level===m.level),v=m?l.sn-m.sn:-1,_=this.part?l.part-this.part.index:-1,E=0===v&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),b=!y&&(1===v||0===v&&(1===_||E&&_<=0)),S=self.performance.now();(y||v||0===s.stats.parsing.start)&&(s.stats.parsing.start=S),!n||!_&&b||(n.stats.parsing.start=S);const T=!(m&&(null==(h=s.initSegment)?void 0:h.url)===(null==(c=m.initSegment)?void 0:c.url)),A=new cn(g,b,o,y,f,T);if(!b||g||T){L.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${b}\n accurateTimeOffset: ${o}\n timeOffset: ${f}\n initSegmentChange: ${T}`);const e=new hn(r,i,t,a,d);this.configureTransmuxer(e)}if(this.frag=s,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(u){const t=u.push(e,p,l,A);dn(t)?(u.async=!0,t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):(u.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);const i=dn(r);i||t.async?(dn(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(m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,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":L[t.data.logType]&&L[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);break}}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)}}function gn(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!yn(e[r].attrs,t[r].attrs))return!1;return!0}function yn(e,t,r){const i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function vn(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}const _n=100;class En extends Bi{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",Bt.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m.ERROR,this.onError,this),e.on(m.BUFFER_RESET,this.onBufferReset,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m.ERROR,this.onError,this),e.off(m.BUFFER_RESET,this.onBufferReset,this),e.off(m.BUFFER_CREATED,this.onBufferCreated,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s}){if("main"===r){const e=t.cc;this.initPTS[t.cc]={baseTime:i,timescale:s},this.log(`InitPTS for cc: ${e} found from main: ${i}`),this.videoTrackCC=e,this.state===Ni.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels)return this.startPosition=e,void(this.state=Ni.STOPPED);const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(_n),t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=Ni.IDLE):(this.loadedmetadata=!1,this.state=Ni.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Ni.IDLE:this.doTickIdle();break;case Ni.WAITING_TRACK:{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=Ni.WAITING_INIT_PTS}break}case Ni.FRAG_LOADING_WAITING_RETRY:{var t;const e=performance.now(),r=this.retryDate;if(!r||e>=r||null!=(t=this.media)&&t.seeking){const{levels:e,trackId:t}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==e?void 0:e[t])||null),this.state=Ni.IDLE}break}case Ni.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:s}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Ni.FRAG_LOADING;const e=i.flush(),n={frag:t,part:r,payload:e,networkDetails:null};this._handleFragmentLoadProgress(n),s&&super._handleFragmentLoadComplete(n)}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=pi.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole),i=Mr(r.end,this.config.maxFragLookUpTolerance,t);i<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${r.end} is needed`),this.clearWaitingFragment())}}else this.state=Ni.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Ni.IDLE)}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,s=e.config;if(!r&&(this.startFragRequested||!s.startFragPrefetch)||null==t||!t[i])return;const n=t[i],a=n.details;if(!a||a.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(a))return void(this.state=Ni.WAITING_TRACK);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,C.AUDIO,Bt.AUDIO));const l=this.getFwdBufferInfo(o,Bt.AUDIO);if(null===l)return;const{bufferedTrack:d,switchingTrack:h}=this;if(!h&&this._streamEnded(l,a))return e.trigger(m.BUFFER_EOS,{type:"audio"}),void(this.state=Ni.ENDED);const c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Bt.MAIN),u=l.len,f=this.getMaxBufferLength(null==c?void 0:c.len),p=a.fragments,g=p[0].start;let y=this.flushing?this.getLoadPosition():l.end;if(h&&r){const e=this.getLoadPosition();d&&!yn(h.attrs,d.attrs)&&(y=e),a.PTSKnown&&e<g&&(l.end>g||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(u>=f&&!h&&y<p[p.length-1].start)return;let v=this.getNextFragment(y,a),_=!1;if(v&&this.isLoopLoading(v,y)&&(_=!!v.gap,v=this.getNextFragmentLoopLoading(v,a,l,Bt.MAIN,f)),!v)return void(this.bufferFlushed=!0);const E=c&&v.start>c.end+a.targetduration;if(E||(null==c||!c.len)&&l.len){const e=this.getAppendedFrag(v.start,Bt.MAIN);if(null===e)return;if(_||(_=!!e.gap||!!E&&0===c.len),E&&!_||_&&l.nextStart&&l.nextStart<e.end)return}this.loadFragment(v,n,y)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new cr(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(_n):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=Ni.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Ni.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!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(m.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:s,id:n}=t;if(!i)return void this.warn("Audio tracks were reset while loading level "+n);this.log(`Audio track ${n} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);const a=i[n];let o=0;if(s.live||null!=(r=a.details)&&r.live){this.checkLiveUpdate(s);const e=this.mainDetails;if(s.deltaUpdateFailed||!e)return;var l;if(!a.details&&s.hasProgramDateTime&&e.hasProgramDateTime)Li(s,e),o=s.fragments[0].start;else o=this.alignPlaylists(s,a.details,null==(l=this.levelLastLoaded)?void 0:l.details)}a.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(this.mainDetails||s,o),this.state!==Ni.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=Ni.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:s}=e,{config:n,trackId:a,levels:o}=this;if(!o)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=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const h=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let c=this.transmuxer;c||(c=this.transmuxer=new mn(this.hls,Bt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==u){const e=!1,t=i?i.index:-1,n=-1!==t,a=new mi(r.level,r.sn,r.stats.chunkCount,s.byteLength,t,n);c.push(s,f,h,"",r,i,d.totalduration,e,a,u)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new Ui,complete:!1};e.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=Ni.WAITING_INIT_PTS}}_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===Bt.AUDIO)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(m.AUDIO_TRACK_SWITCHED,o({},e)))}this.fragBufferedComplete(r,i)}else if(!this.loadedmetadata&&r.type===Bt.MAIN){const e=this.videoBuffer||this.media;if(e){const t=pi.getBuffered(e);t.length&&(this.loadedmetadata=!0)}}}onError(e,t){var r;if(t.fatal)this.state=Ni.ERROR;else switch(t.details){case y.FRAG_GAP:case y.FRAG_PARSING_ERROR:case y.FRAG_DECRYPT_ERROR:case y.FRAG_LOAD_ERROR:case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_ERROR:case y.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Bt.AUDIO,t);break;case y.AUDIO_TRACK_LOAD_ERROR:case y.AUDIO_TRACK_LOAD_TIMEOUT:case y.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Ni.WAITING_TRACK||(null==(r=t.context)?void 0:r.type)!==Nt.AUDIO_TRACK||(this.state=Ni.IDLE);break;case y.BUFFER_APPEND_ERROR:case y.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===y.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case y.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==C.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==C.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===Ni.ENDED&&(this.state=Ni.IDLE);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Bt.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:d}=a,{details:h}=d,{audio:u,text:f,id3:p,initSegment:g}=s;if(!this.fragContextChanged(o)&&h){if(this.state=Ni.PARSING,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const e=o.initSegment||o;this._bufferInitSegment(d,g.tracks,e,n),i.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:g.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[C.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(C.AUDIO,e,t,r,i),this.bufferFragmentData(u,o,l,n)}if(null!=p&&null!=(t=p.samples)&&t.length){const e=c({id:r,frag:o,details:h},p);i.trigger(m.FRAG_PARSING_METADATA,e)}if(f){const e=c({id:r,frag:o,details:h},f);i.trigger(m.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==Ni.PARSING)return;t.video&&delete t.video;const s=t.audio;if(!s)return;s.id="audio";const n=e.audioCodec;this.log(`Init audio buffer, container:${s.container}, codecs[level/parsed]=[${n}/${s.codec}]`),n&&1===n.split(",").length&&(s.levelCodec=n),this.hls.trigger(m.BUFFER_CODECS,t);const a=s.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger(m.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var s;if(this.fragCurrent=e,this.switchingTrack||i===di.NOT_LOADED||i===di.PARTIAL)if("initSegment"===e.sn)this._loadInitSegment(e,t);else if(null!=(s=t.details)&&s.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=Ni.WAITING_INIT_PTS;const r=this.mainDetails;r&&r.fragments[0].start!==t.details.fragments[0].start&&Li(t.details,r)}else this.startFragRequested=!0,super.loadFragment(e,t,r);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:r}=this,i=null==r?void 0:r.attrs,s=e.attrs;t&&i&&(i.CHANNELS!==s.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(m.AUDIO_TRACK_SWITCHED,o({},e))}}class bn extends Gr{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Audio track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!s&&t){const r=ti(t,e,si);if(r>-1)s=e[r];else{const e=ti(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const a={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(m.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var n;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(n=this.groupIds)?void 0:n.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}else this.shouldReloadPlaylist(s)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Nt.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const i=this.currentTrack;if(i&&ri(e,i,si))return i;const s=ti(e,this.tracksInGroup,si);if(s>-1){const e=this.tracksInGroup[s];return this.setAudioTrack(s),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const s=ni(e,t.levels,r,i,si);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){const t=ti(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn("Invalid audio track id: "+e);this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e],s=i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(m.AUDIO_TRACK_SWITCHING,o({},i)),s)return;const n=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||ri(e,i,si)))return r}if(e){const{name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){const l=t[e];if(ri({name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o},l,si))return e}for(let l=0;l<t.length;l++){const r=t[l];if(yn(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const r=t[l];if(yn(e.attrs,r.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const i=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(m.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}}const Sn=500;class Tn extends Bi{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",Bt.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.ERROR,this.onError,this),e.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.ERROR,this.onError,this),e.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Ni.IDLE,this.setInterval(Sn),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=Ni.IDLE,!i)return;const s=this.tracksBuffered[this.currentTrackId];if(!s)return;let n;const a=r.start;for(let l=0;l<s.length;l++)if(a>=s[l].start&&a<=s[l].end){n=s[l];break}const o=r.start+r.duration;n?n.end=o:(n={start:a,end:o},s.push(n)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}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;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,Bt.SUBTITLE)}}onFragBuffered(e,t){var r;this.loadedmetadata||t.frag.type!==Bt.MAIN||null!=(r=this.media)&&r.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===Bt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ni.STOPPED&&(this.state=Ni.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&gn(this.levels,t)?this.levels=t.map(e=>new cr(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new cr(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Bt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(Sn)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:s}=this,{details:n,id:a}=t;if(!s)return void this.warn("Subtitle tracks were reset while loading level "+a);const o=s[a];if(a>=s.length||!o)return;this.log(`Subtitle track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(n.live||null!=(r=o.details)&&r.live){const e=this.mainDetails;if(n.deltaUpdateFailed||!e)return;const t=e.fragments[0];var d;if(o.details)l=this.alignPlaylists(n,o.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,Er(n,l));else n.hasProgramDateTime&&e.hasProgramDateTime?(Li(n,e),l=n.fragments[0].start):t&&(l=t.start,Er(n,l))}if(o.details=n,this.levelLastLoaded=o,a===i&&(this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(this.mainDetails||n,l),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Ni.IDLE)){const e=Or(null,n.fragments,this.media.currentTime,0);e||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=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 s.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();s.trigger(m.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Ni.IDLE})}}doTick(){if(this.media){if(this.state===Ni.IDLE){const{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;const{config:i}=this,s=this.getLoadPosition(),n=pi.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,i.maxBufferHole),{end:a,len:o}=n,l=this.getFwdBufferInfo(this.media,Bt.MAIN),d=r.details,h=this.getMaxBufferLength(null==l?void 0:l.len)+d.levelTargetDuration;if(o>h)return;const c=d.fragments,u=c.length,f=d.edge;let p=null;const m=this.fragPrevious;if(a<f){const e=i.maxFragLookUpTolerance,t=a>f-e?0:e;p=Or(m,c,Math.max(c[0].start,a),t),!p&&m&&m.start<c[0].start&&(p=c[0])}else p=c[u-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),"initSegment"!==p.sn){const e=p.sn-d.startSN,t=c[e-1];t&&t.cc===p.cc&&this.fragmentTracker.getState(t)===di.NOT_LOADED&&(p=t)}this.fragmentTracker.getState(p)===di.NOT_LOADED&&this.loadFragment(p,r,a)}}else this.state=Ni.IDLE}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Ln(this.tracksBuffered[this.currentTrackId]||[])}}class Ln{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if(r>>>=0,r>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){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}}class An extends Gr{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=qt(this.media.textTracks);for(let i=0;i<t.length;i++)if("hidden"===t[i].mode)e=t[i];else if("showing"===t[i].mode){e=t[i];break}const r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m.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.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);const e=qt(this.media.textTracks);e.forEach(e=>{Kt(e)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Subtitle track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!s&&t){this.selectDefaultTrack=!1;const r=ti(t,e);if(r>-1)s=e[r];else{const e=ti(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const n={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(m.SUBTITLE_TRACKS_UPDATED,n),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const s=t[i];if((!r||s.default)&&(r||e)&&(!e||ri(s,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(yn(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(yn(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if(vn(i,e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Nt.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&ri(e,r))return r;const i=ti(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=ti(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const i=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(m.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=qt(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>vn(r,e))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")}),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!u(e))return void this.warn("Invalid subtitle track id: "+e);this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(m.SUBTITLE_TRACK_SWITCH,{id:e});const s=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;this.log("Switching to subtitle-track "+e+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:n,groupId:a="",name:o,type:l,url:d}=i;this.hls.trigger(m.SUBTITLE_TRACK_SWITCH,{id:n,groupId:a,name:o,type:l,url:d});const h=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(h)}}class Rn{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){const i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}insertAbort(e,t){const r=this.queues[t];r.unshift(e),this.executeNext(t)}appendBlocker(e){let t;const r=new Promise(e=>{t=e}),i={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,e),r}executeNext(e){const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(r){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${r}`),i.onError(r);const t=this.buffers[e];null!=t&&t.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const wn=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class kn{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=e=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:e,mediaSource:t}=this;this.log("Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(m.MEDIA_ATTACHED,{media:e,mediaSource:t})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&L.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=dt(lt(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),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,this.hls=null}registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.BUFFER_RESET,this.onBufferReset,this),e.on(m.BUFFER_APPENDING,this.onBufferAppending,this),e.on(m.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m.BUFFER_EOS,this.onBufferEos,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.FRAG_PARSED,this.onFragParsed,this),e.on(m.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.BUFFER_RESET,this.onBufferReset,this),e.off(m.BUFFER_APPENDING,this.onBufferAppending,this),e.off(m.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.BUFFER_EOS,this.onBufferEos,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.FRAG_PARSED,this.onFragParsed,this),e.off(m.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Rn(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},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,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(e,t){const r=this.media=t.media,i=lt(this.appendSource);if(r&&i){var s;const e=this.mediaSource=new i;this.log("created media source: "+(null==(s=e.constructor)?void 0:s.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming));const t=this._objectUrl=self.URL.createObjectURL(e);if(this.appendSource)try{r.removeAttribute("src");const i=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||i&&e instanceof i,Dn(r),In(r,t),r.load()}catch(n){r.src=t}else r.src=t;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(Al){this.warn(`onMediaDetaching: ${Al.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&Dn(e),e.load()):this.warn("media|source.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(m.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{var r;if(t)this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}catch(Al){this.warn("onBufferReset "+e,Al)}}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length,i=Object.keys(t);if(i.forEach(e=>{if(r){const r=this.tracks[e];if(r&&"function"===typeof r.buffer.changeType){var i;const{id:s,codec:n,levelCodec:a,container:o,metadata:l}=t[e],d=bt(r.codec,r.levelCodec),h=null==d?void 0:d.replace(wn,"$1");let c=bt(n,a);const u=null==(i=c)?void 0:i.replace(wn,"$1");if(c&&h!==u){"audio"===e.slice(0,5)&&(c=Et(c,this.appendSource));const t=`${o};codecs=${c}`;this.appendChangeType(e,t),this.log(`switching codec ${d} to ${c}`),this.tracks[e]={buffer:r.buffer,codec:n,container:o,levelCodec:a,metadata:l,id:s}}}}else this.pendingTracks[e]=t[e]}),r)return;const s=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==s&&(this.log(`${s} bufferCodec event(s) expected ${i.join(",")}`),this.bufferCodecEventsExpected=s),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:r}=this,i={execute:()=>{const i=this.sourceBuffer[e];i&&(this.log(`changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};r.append(i,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:r,operationQueue:i,tracks:s}=this,{data:n,type:a,frag:o,part:l,chunkMeta:d}=t,h=d.buffering[a],c=self.performance.now();h.start=c;const u=o.stats.buffering,f=l?l.stats.buffering:null;0===u.start&&(u.start=c),f&&0===f.start&&(f.start=c);const p=s.audio;let v=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(v=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const _=o.start,E={execute:()=>{if(h.executeStart=self.performance.now(),v){const e=this.sourceBuffer[a];if(e){const t=_-e.timestampOffset;Math.abs(t)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${_} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=_)}}this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();h.executeEnd=h.end=e,0===u.first&&(u.first=e),f&&0===f.first&&(f.first=e);const{sourceBuffer:t}=this,r={};for(const i in t)r[i]=pi.getBuffered(t[i]);this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(m.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:d,parent:o.type,timeRanges:r})},onError:e=>{const t={type:g.MEDIA_ERROR,parent:o.type,details:y.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:l,chunkMeta:d,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=y.BUFFER_FULL_ERROR;else{const e=++this.appendErrors[a];t.details=y.BUFFER_APPEND_ERROR,this.warn(`Failed ${e}/${r.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer`),e>=r.config.appendErrorMaxRetry&&(t.fatal=!0)}r.trigger(m.ERROR,t)}};i.append(E,a,!!this.pendingTracks[a])}onBufferFlushing(e,t){const{operationQueue:r}=this,i=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(m.BUFFER_FLUSHED,{type:e})},onError:t=>{this.warn(`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,s=[],n=i?i.elementaryStreams:r.elementaryStreams;n[C.AUDIOVIDEO]?s.push("audiovideo"):(n[C.AUDIO]&&s.push("audio"),n[C.VIDEO]&&s.push("video"));const a=()=>{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(m.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})};0===s.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(a,s)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){const r=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,this.log(r+" sourceBuffer now EOS"))),e&&!(i&&!i.ended)},!0);r&&(this.log("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?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&this.log("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())}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||null===t)return;const i=this.getSourceBufferTypes();if(!i.length)return;const s=e.config,n=r.currentTime,a=t.levelTargetDuration,o=t.live&&null!==s.liveBackBufferLength?s.liveBackBufferLength:s.backBufferLength;if(u(o)&&o>0){const e=Math.max(o,a),t=Math.floor(n/a)*a-e;this.flushBackBuffer(n,a,t)}if(u(s.frontBufferFlushThreshold)&&s.frontBufferFlushThreshold>0){const e=Math.max(s.maxBufferLength,s.frontBufferFlushThreshold),t=Math.max(e,a),r=Math.floor(n/a)*a+t;this.flushFrontBuffer(n,a,r)}}flushBackBuffer(e,t,r){const{details:i,sourceBuffer:s}=this,n=this.getSourceBufferTypes();n.forEach(n=>{const a=s[n];if(a){const s=pi.getBuffered(a);if(s.length>0&&r>s.start(0)){if(this.hls.trigger(m.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=i&&i.live)this.hls.trigger(m.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(a.ended&&s.end(s.length-1)-e<2*t)return void this.log(`Cannot flush ${n} back buffer while SourceBuffer is in ended state`);this.hls.trigger(m.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:n})}}})}flushFrontBuffer(e,t,r){const{sourceBuffer:i}=this,s=this.getSourceBufferTypes();s.forEach(s=>{const n=i[s];if(n){const i=pi.getBuffered(n),a=i.length;if(a<2)return;const o=i.start(a-1),l=i.end(a-1);if(r>o||e>=o&&e<=l)return;if(n.ended&&e-l<2*t)return void this.log(`Cannot flush ${s} front buffer while SourceBuffer is in ended state`);this.hls.trigger(m.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:s})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:r,mediaSource:i}=this,s=e.fragments[0].start+e.totalduration,n=r.duration,a=u(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(s>a&&s>n||!u(n))&&(this.log("Updating Media Source duration to "+s.toFixed(3)),i.duration=s)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments,i=r.length;if(i&&e.live&&null!=t&&t.setLiveSeekableRange){const i=Math.max(0,r[0].start),s=Math.max(i,i+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${i}-${s}.`),t.setLiveSeekableRange(i,s)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&(!e||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(m.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(m.ERROR,{type:g.MEDIA_ERROR,details:y.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 s in e)if(!t[s]){var i;const n=e[s];if(!n)throw Error(`source buffer exists for track ${s}, however track does not`);let a=-1===(null==(i=n.levelCodec)?void 0:i.indexOf(","))?n.levelCodec:n.codec;a&&"audio"===s.slice(0,5)&&(a=Et(a,this.appendSource));const o=`${n.container};codecs=${a}`;this.log(`creating sourceBuffer(${o})`);try{const e=t[s]=r.addSourceBuffer(o),i=s;this.addBufferListener(i,"updatestart",this._onSBUpdateStart),this.addBufferListener(i,"updateend",this._onSBUpdateEnd),this.addBufferListener(i,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(i,"bufferedchange",(e,t)=>{const r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(m.BUFFER_FLUSHED,{type:s})}),this.tracks[s]={buffer:e,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(Al){this.error("error while trying to add sourceBuffer: "+Al.message),this.hls.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:Al,sourceBufferName:s,mimeType:o})}}}get mediaSrc(){var e;const t=(null==(e=this.media)?void 0:e.firstChild)||this.media;return null==t?void 0:t.src}_onSBUpdateStart(e){const{operationQueue:t}=this,r=t.current(e);r.onStart()}_onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const{operationQueue:r}=this,i=r.current(e);i.onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(""+i,t),this.hls.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const s=this.operationQueue.current(e);s&&s.onError(i)}removeExecutor(e,t,r){const{media:i,mediaSource:s,operationQueue:n,sourceBuffer:a}=this,o=a[e];if(!i||!s||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void n.shiftAndExecuteNext(e);const l=u(i.duration)?i.duration:1/0,d=u(s.duration)?s.duration:1/0,h=Math.max(0,t),c=Math.min(r,l,d);c>h&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${h},${c}] from the ${e} SourceBuffer`),o.remove(h,c)):n.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.sourceBuffer[t];if(r)r.ended=!1,r.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return this.log("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 s=r.bind(this,e);this.listeners[e].push({event:t,listener:s}),i.addEventListener(t,s)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}}function Dn(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function In(e,t){const r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}const xn={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},Cn=e=>String.fromCharCode(xn[e]||e),Pn=15,On=100,Mn={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Fn={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Nn={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Bn={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Un=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class $n{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"===typeof t?t():t;L.log(`${this.time} [${e}] ${r}`)}}}const Gn=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class jn{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Vn{constructor(){this.uchar=" ",this.penState=new jn}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Kn{constructor(e){this.chars=[],this.pos=0,this.currPenState=new jn,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<On;t++)this.chars.push(new Vn);this.logger=e}equals(e){for(let t=0;t<On;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<On;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<On;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>On&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=On)}moveCursor(e){const t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Cn(e);this.pos>=On?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<On;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<On;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);const t=this.chars[this.pos];t.setPenState(this.currPenState)}}class Hn{constructor(e){this.rows=[],this.currRow=Pn-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Pn;t++)this.rows.push(new Kn(e));this.logger=e}reset(){for(let e=0;e<Pn;e++)this.rows[e].clear();this.currRow=Pn-1}equals(e){let t=!0;for(let r=0;r<Pn;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Pn;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Pn;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){const e=this.rows[this.currRow];e.backSpace()}clearToEndOfRow(){const e=this.rows[this.currRow];e.clearToEndOfRow()}insertChar(e){const t=this.rows[this.currRow];t.insertChar(e)}setPen(e){const t=this.rows[this.currRow];t.setPenStyles(e)}moveCursor(e){const t=this.rows[this.currRow];t.moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);const t=this.rows[this.currRow];t.setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let t=0;t<Pn;t++)this.rows[t].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(let n=0;n<this.nrRollUpRows;n++)this.rows[t-this.nrRollUpRows+n+1].copy(r.rows[e+n])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"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 s=0;s<Pn;s++){const r=this.rows[s].getTextString();r&&(i=s+1,e?t.push("Row "+i+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Yn{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 Hn(r),this.nonDisplayedMemory=new Hn(r),this.lastOutputScreen=new Hn(r),this.currRollUpRow=this.displayedMemory.rows[Pn-1],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[Pn-1],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 r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+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 zn{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Xn(),this.logger=void 0;const i=this.logger=new $n;this.channels=[null,new Yn(e,t,i),new Yn(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){const e=127&t[r],i=127&t[r+1];let s=!1,n=null;if(0===e&&0===i)continue;this.logger.log(3,()=>"["+Gn([t[r],t[r+1]])+"] -> ("+Gn([e,i])+")");const a=this.cmdHistory,o=e>=16&&e<=31;if(o){if(Wn(e,i,a)){qn(null,null,a),this.logger.log(3,()=>"Repeated command ("+Gn([e,i])+") is dropped");continue}qn(e,i,this.cmdHistory),s=this.parseCmd(e,i),s||(s=this.parseMidrow(e,i)),s||(s=this.parsePAC(e,i)),s||(s=this.parseBackgroundAttributes(e,i))}else qn(null,null,a);if(!s&&(n=this.parseChars(e,i),n)){const e=this.currentChannel;if(e&&e>0){const t=this.channels[e];t.insertChars(n)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}s||n||this.logger.log(2,()=>"Couldn't parse cleaned data "+Gn([e,i])+" orig: "+Gn([t[r],t[r+1]]))}}parseCmd(e,t){const r=(20===e||28===e||21===e||29===e)&&t>=32&&t<=47,i=(23===e||31===e)&&t>=33&&t<=35;if(!r&&!i)return!1;const s=20===e||21===e||23===e?1:2,n=this.channels[s];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),this.currentChannel=s,!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 ("+Gn([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;const i=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,s=(16===e||24===e)&&t>=64&&t<=95;if(!i&&!s)return!1;const n=e<=23?1:2;r=t>=64&&t<=95?1===n?Mn[e]:Nn[e]:1===n?Fn[e]:Bn[e];const a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),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===(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,s=null;if(e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,()=>"Special char '"+Cn(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+Gn(i).join(",")),i}parseBackgroundAttributes(e,t){const r=(16===e||24===e)&&t>=32&&t<=47,i=(23===e||31===e)&&t>=45&&t<=47;if(!r&&!i)return!1;let s;const n={};16===e||24===e?(s=Math.floor((t-32)/2),n.background=Un[s],t%2===1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));const a=e<=23?1:2,o=this.channels[a];return o.setBkgData(n),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}qn(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function qn(e,t,r){r.a=e,r.b=t}function Wn(e,t,r){return r.a===e&&r.b===t}function Xn(){return{a:null,b:null}}class Qn{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Zn=function(){if(null!=V&&V.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(t){return r(e,t)}function s(e){return r(t,e)}function n(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function a(e,t,r){const a=this,o={enumerable:!0};a.hasBeenReset=!1;let l="",d=!1,h=e,c=t,u=r,f=null,p="",m=!0,g="auto",y="start",v=50,_="middle",E=50,b="middle";Object.defineProperty(a,"id",n({},o,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(a,"pauseOnExit",n({},o,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(a,"startTime",n({},o,{get:function(){return h},set:function(e){if("number"!==typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"endTime",n({},o,{get:function(){return c},set:function(e){if("number"!==typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"text",n({},o,{get:function(){return u},set:function(e){u=""+e,this.hasBeenReset=!0}})),Object.defineProperty(a,"region",n({},o,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"vertical",n({},o,{get:function(){return p},set:function(e){const t=i(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");p=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"snapToLines",n({},o,{get:function(){return m},set:function(e){m=!!e,this.hasBeenReset=!0}})),Object.defineProperty(a,"line",n({},o,{get:function(){return g},set:function(e){if("number"!==typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"lineAlign",n({},o,{get:function(){return y},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"position",n({},o,{get:function(){return v},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",n({},o,{get:function(){return _},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",n({},o,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",n({},o,{get:function(){return b},set:function(e){const t=s(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),a.displayState=void 0}return a.prototype.getCueAsHTML=function(){const e=self.WebVTT;return e.convertCueToDOMTree(self,this.text)},a}();class Jn{decode(e,t){if(!e)return"";if("string"!==typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function ea(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 ta{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<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function ra(e,t,r,i){const s=i?e.split(i):[e];for(const n in s){if("string"!==typeof s[n])continue;const e=s[n].split(r);if(2!==e.length)continue;const i=e[0],a=e[1];t(i,a)}}const ia=new Zn(0,0,""),sa="middle"===ia.align?"middle":"center";function na(e,t,r){const i=e;function s(){const t=ea(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(e,t){const i=new ta;ra(e,(function(e,t){let s;switch(e){case"region":for(let s=r.length-1;s>=0;s--)if(r[s].id===t){i.set(e,r[s].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),i.integer(e,s[0]),i.percent(e,s[0])&&i.set("snapToLines",!1),i.alt(e,s[0],["auto"]),2===s.length&&i.alt("lineAlign",s[1],["start",sa,"end"]);break;case"position":s=t.split(","),i.percent(e,s[0]),2===s.length&&i.alt("positionAlign",s[1],["start",sa,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",sa,"end","left","right"]);break}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let s=i.get("line","auto");"auto"===s&&-1===ia.line&&(s=-1),t.line=s,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",sa);let n=i.get("position","auto");"auto"===n&&50===ia.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=s(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),a(),t.endTime=s(),a(),n(e,t)}function aa(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class oa{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Jn,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;e=aa(e);while(r<e.length&&"\r"!==e[r]&&"\n"!==e[r])++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){ra(e,(function(e,t){}),/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;while(t.buffer){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Zn(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{na(e,t.cue,t.regionList)}catch(s){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(s){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const la=/\r\n|\n\r|\n|\r/g,da=function(e,t,r=0){return e.slice(r,r+t.length)===t},ha=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!u(t)||!u(r)||!u(i)||!u(s))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*i,t+=36e5*s,t},ca=function(e){let t=5381,r=e.length;while(r)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function ua(e,t,r){return ca(e.toString())+ca(t.toString())+ca(r)}const fa=function(e,t,r){let i=e[t],s=e[i.prevCC];if(!s||!s.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);while(null!=(n=s)&&n.new){var n;e.ccOffset+=i.start-s.start,i.new=!1,i=s,s=e[i.prevCC]}e.presentationOffset=r};function pa(e,t,r,i,s,n,a){const o=new oa,l=me(new Uint8Array(e)).trim().replace(la,"\n").split("\n"),d=[],h=t?Gs(t.baseTime,t.timescale):0;let c,u="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const n=r[i];let a=r.ccOffset;const o=(f-h)/9e4;if(null!=n&&n.new&&(void 0!==p?a=r.ccOffset=n.start:fa(r,i,o)),o){if(!t)return void(c=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,u=Xs(9e4*(e.startTime+a-p),9e4*s)/9e4;e.startTime=Math.max(u,0),e.endTime=Math.max(u+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=ua(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){c=e},o.onflush=function(){c?a(c):n(d)},l.forEach(e=>{if(m){if(da(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{da(e,"LOCAL:")?u=e.slice(6):da(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=ha(u)/1e3}catch(t){c=t}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const ma="stpp.ttml.im1t",ga=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ya=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,va={left:"start",center:"center",right:"end",start:"start",end:"end"};function _a(e,t,r,i){const s=De(new Uint8Array(e),["mdat"]);if(0===s.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=s.map(e=>me(e)),a=Us(t.baseTime,1,t.timescale);try{n.forEach(e=>r(Ea(e,a)))}catch(o){i(o)}}function Ea(e,t){const r=new DOMParser,i=r.parseFromString(e,"text/xml"),s=i.getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((e,t)=>(e[t]=s.getAttribute("ttp:"+t)||n[t],e),{}),o="preserve"!==s.getAttribute("xml:space"),l=Sa(ba(s,"styling","style")),d=Sa(ba(s,"layout","region")),h=ba(s,"body","[begin]");return[].map.call(h,e=>{const r=Ta(e,o);if(!r||!e.hasAttribute("begin"))return null;const i=wa(e.getAttribute("begin"),a),s=wa(e.getAttribute("dur"),a);let n=wa(e.getAttribute("end"),a);if(null===i)throw Ra(e);if(null===n){if(null===s)throw Ra(e);n=i+s}const h=new Zn(i-t,n-t,r);h.id=ua(h.startTime,h.endTime,h.text);const u=d[e.getAttribute("region")],f=l[e.getAttribute("style")],p=La(u,f,l),{textAlign:m}=p;if(m){const e=va[m];e&&(h.lineAlign=e),h.align=m}return c(h,p),h}).filter(e=>null!==e)}function ba(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function Sa(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function Ta(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var s;return"br"===r.nodeName&&i?e+"\n":null!=(s=r.childNodes)&&s.length?Ta(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function La(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return a&&r.hasOwnProperty(a)&&(s=r[a]),n.reduce((r,n)=>{const a=Aa(t,i,n)||Aa(e,i,n)||Aa(s,i,n);return a&&(r[n]=a),r},{})}function Aa(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function Ra(e){return new Error("Could not parse ttml timestamp "+e)}function wa(e,t){if(!e)return null;let r=ea(e);return null===r&&(ga.test(e)?r=ka(e,t):ya.test(e)&&(r=Da(e,t))),r}function ka(e,t){const r=ga.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}function Da(e,t){const r=ya.exec(e),i=Number(r[1]),s=r[2];switch(s){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}class Ia{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Oa(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(m.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(m.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new Qn(this,"textTrack1"),t=new Qn(this,"textTrack2"),r=new Qn(this,"textTrack3"),i=new Qn(this,"textTrack4");this.cea608Parser1=new zn(1,e,t),this.cea608Parser2=new zn(3,r,i)}}addCues(e,t,r,i,s){let n=!1;for(let a=s.length;a--;){const e=s[a],i=Pa(e[0],e[1],t,r);if(i>=0&&(e[0]=Math.min(e[0],t),e[1]=Math.max(e[1],r),n=!0,i/(r-t)>.5))return}if(n||s.push([t,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[e];this.Cues.newCue(s,t,r,i)}else{const s=this.Cues.newCue(null,t,r,i);this.hls.trigger(m.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s}){const{unparsedVttFrags:n}=this;"main"===r&&(this.initPTS[t.cc]={baseTime:i,timescale:s}),n.length&&(this.unparsedVttFrags=[],n.forEach(e=>{this.onFragLoaded(m.FRAG_LOADED,e)}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){const s=r.textTracks[i];if(Ca(s,{name:e,lang:t,attrs:{}}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:s,languageCode:n}=t[e],a=this.getExistingTrack(s,n);if(a)r[e]=a,Kt(r[e]),jt(r[e],i);else{const t=this.createTextTrack("captions",s,n);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r=t.label,i={_id:e,label:r,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(m.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Kt(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Oa(),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 r=0;r<t.length;r++)Kt(t[r])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===ma);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){const e=gn(this.tracks,r);if(e)return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?qt(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&Ca(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)Kt(i);else{const t=xa(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){const e=t.filter(e=>null!==e).map(e=>e.label);e.length&&L.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(m.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}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){if(this.enabled&&t.frag.type===Bt.MAIN){var r,i;const{cea608Parser1:e,cea608Parser2:s,lastSn:n}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&s&&(o!==n+1||o===n&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),s.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===Bt.SUBTITLE)if(i.byteLength){const e=r.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===ma?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;_a(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{L.log("Failed to parse IMSC1: "+t),r.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:s,unparsedVttFrags:n}=this,a=s.length-1;if(!s[r.cc]&&-1===a)return void n.push(e);const o=this.hls,l=null!=(t=r.initSegment)&&t.data?Ve(r.initSegment.data,new Uint8Array(i)):i;pa(l,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const s="Missing initPTS for VTT MPEGTS"===t.message;s?n.push(e):this._fallbackToIMSC1(r,i),L.log("Failed to parse VTT cue: "+t),s&&a>r.cc||o.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||_a(t,this.initPTS[e.cc],()=>{r.textCodec=ma,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=>Vt(r,e))}else{const i=this.tracks[t];if(!i)return;const s=i.default?"default":"subtitles"+t;r.trigger(m.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Bt.SUBTITLE&&this.onFragLoaded(m.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:i}=this;if(!this.enabled||!r||!i)return;const{frag:s,samples:n}=t;if(s.type!==Bt.MAIN||"NONE"!==this.closedCaptionsForLevel(s))for(let a=0;a<n.length;a++){const e=n[a].bytes;if(e){const t=this.extractCea608Data(e);r.addData(n[a].pts,t[0]),i.addData(n[a].pts,t[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:s}){const{media:n}=this;if(n&&!(n.currentTime<r)){if(!s||"video"===s){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>Ht(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Ht(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let s=0;s<r;s++){const r=e[i++],s=127&e[i++],n=127&e[i++];if(0===s&&0===n)continue;const a=0!==(4&r);if(a){const e=3&r;0!==e&&1!==e||(t[e].push(s),t[e].push(n))}}return t}}function xa(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function Ca(e,t){return!!e&&e.kind===xa(t)&&vn(t,e)}function Pa(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}function Oa(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Ma{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.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.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,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&u(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){const r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,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,Ma.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,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(t){}return e}isLevelAllowed(e){const t=this.restrictedLevels;return!t.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 s=e.length-1;const n=Math.max(t,r);for(let a=0;a<e.length;a+=1){const t=e[a];if((t.width>=n||t.height>=n)&&i(t,e[a+1])){s=a;break}}return s}}class Fa{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(m.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(m.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,s=r-this.lastDroppedFrames,n=t-this.lastDecodedFrames,a=1e3*s/e,o=this.hls;if(o.trigger(m.FPS_DROP,{currentDropped:s,currentDecoded:n,totalDroppedFrames:r}),a>0&&s>o.config.fpsDroppedMonitoringThreshold*n){let e=o.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(m.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.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)}}const Na="[eme]";class Ba{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=Ba.CDMCleanupPromise?[Ba.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=L.debug.bind(L,Na),this.log=L.log.bind(L,Na),this.warn=L.warn.bind(L,Na),this.error=L.error.bind(L,Na),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(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=t[e];if(i)return i.licenseUrl;if(e===K.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),s=t.map(e=>e.videoCodec).filter(r);return i.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,r)=>{const n=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,s).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?n(e):r(t instanceof Ua?t:new Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};n(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!==typeof r){let e="Configured requestMediaKeySystemAccess is not a function "+r;return null===Q&&"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=Z(e,t,r,this.config.drmSystemOptions),s=this.keySystemAccessPromises[e];let n=null==s?void 0:s.keySystemAccess;if(!n){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(i)}`),n=this.requestMediaKeySystemAccess(e,i);const t=this.keySystemAccessPromises[e]={keySystemAccess:n};return n.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),n.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 n.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${ve.hexDump(e.keyId||[])}`);const i=r.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t),s="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,s,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 ve.hexDump(e.keyId)}updateKeySession(e,t){var r;const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${ve.hexDump((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=X(this.config),s=e.map(Y).filter(e=>!!e&&-1!==i.indexOf(e));return this.getKeySystemSelectionPromise(s).then(({keySystem:e})=>{const i=W(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 s=this.keyIdToKeySessionPromise[r];return s||(s=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:s})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(r,s).then(()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:r,mediaKeys:s,decryptdata:t}),i="cenc";return this.generateRequestWithPreferredKeySession(e,i,t.pssh,"playlist-key")}))),s.catch(e=>this.handleError(e))),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ua?this.hls.trigger(m.ERROR,e.data):this.hls.trigger(m.ERROR,{type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=Y(e.keyFormat),r=t?[t]:X(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=X(this.config)),0===e.length)throw new Ua({type:g.KEY_SYSTEM_ERROR,details:y.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,s;if("sinf"===t&&this.config.drmSystems[K.FAIRPLAY]){const e=Se(new Uint8Array(r));try{const t=B(JSON.parse(e).sinf),r=Ne(new Uint8Array(t));if(!r)return;i=r.subarray(8,24),s=K.FAIRPLAY}catch(d){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const e=Ze(r);if(null===e)return;0===e.version&&e.systemId===z.WIDEVINE&&e.data&&(i=e.data.subarray(8,24)),s=q(e.systemId)}if(!s||!i)return;const n=ve.hexDump(i),{keyIdToKeySessionPromise:a,mediaKeySessions:o}=this;let l=a[n];for(let h=0;h<o.length;h++){const e=o[h],s=e.decryptdata;if(s.pssh||!s.keyId)continue;const d=ve.hexDump(s.keyId);if(n===d||-1!==s.uri.replace(/-/g,"").indexOf(n)){l=a[d],delete a[d],s.pssh=new Uint8Array(r),s.keyId=i,l=a[n]=l.then(()=>this.generateRequestWithPreferredKeySession(e,t,r,"encrypted-event-key-match"));break}}l||(l=a[n]=this.getKeySystemSelectionPromise([s]).then(({keySystem:e,mediaKeys:s})=>{var a;this.throwIfDestroyed();const o=new et("ISO-23001-7",n,null!=(a=W(e))?a:"");return o.pssh=new Uint8Array(r),o.keyId=i,this.attemptSetMediaKeys(e,s).then(()=>{this.throwIfDestroyed();const i=this.createMediaKeySessionContext({decryptdata:o,keySystem:e,mediaKeys:s});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 s,n;const a=null==(s=this.config.drmSystems)||null==(n=s[e.keySystem])?void 0:n.generateRequest;if(a)try{const i=a.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(f){var o;if(this.warn(f.message),null!=(o=this.hls)&&o.config.debug)throw f}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 d=new pn,h=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void d.emit("error",new Error("invalid state"));const{messageType:i,message:s}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,s).catch(e=>{this.handleError(e),d.emit("error",e)}):"license-release"===i?e.keySystem===K.FAIRPLAY&&(this.updateKeySession(e,j("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${i}"`)},c=e._onkeystatuseschange=t=>{const r=e.mediaKeysSession;if(!r)return void d.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const i=e.keyStatus;d.emit("keyStatus",i),"expired"===i&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",h),e.mediaKeysSession.addEventListener("keystatuseschange",c);const u=new Promise((e,t)=>{d.on("error",t),d.on("keyStatus",r=>{r.startsWith("usable")?e():"output-restricted"===r?t(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.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 Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)}).then(()=>u).catch(t=>{throw d.removeAllListeners(),this.removeSession(e),t}).then(()=>(d.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${ve.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${ve.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=t.loader,i=new r(t),s=this.getServerCertificateUrl(e);return s?(this.log(`Fetching server certificate for "${e}"`),new Promise((r,n)=>{const a={responseType:"arraybuffer",url:s},l=t.certLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,i,s)=>{r(e.data)},onError:(t,r,i,l)=>{n(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:o({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${s}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,i)=>{n(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${s})`))},onAbort:(e,t,r)=>{n(new Error("aborted"))}};i.load(a,d,h)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,s)=>{e.setServerCertificate(r).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${null==r?void 0:r.byteLength}) on "${t}"`),i(e)}).catch(e=>{s(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.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 Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(r,"application/xml"),s=i.querySelectorAll("HttpHeader");if(s.length>0){let t;for(let r=0,i=s.length;r<i;r++){var n,a;t=s[r];const i=null==(n=t.querySelector("name"))?void 0:n.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return j(atob(l))}setupLicenseXHR(e,t,r,i){const s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return s.call(this.hls,e,t,r,i)}).catch(n=>{if(!r.decryptdata)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);const s=r||i;return{xhr:e,licenseChallenge:s}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,s)=>{const n=this.getLicenseServerUrl(e.keySystem);this.log("Sending license request to URL: "+n);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log("License received "+(t instanceof ArrayBuffer?t.byteLength:t));const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,n,e)}catch(o){this.error(o)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)s(new Ua({type:g.KEY_SYSTEM_ERROR,details:y.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:n,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${n}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,n,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==K.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)})})}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={},et.clearKeyUriToKeyIdMap();const r=t.length;Ba.CDMCleanupPromise=Promise.all(t.map(e=>this.removeSession(e)).concat(null==e?void 0:e.setMediaKeys(null).catch(e=>{this.log("Could not clear media keys: "+e)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(e=>{this.log("Could not close sessions and clear media keys: "+e)})}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),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),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)})}}}Ba.CDMCleanupPromise=void 0;class Ua 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 $a,Ga,ja;(function(e){e["MANIFEST"]="m",e["AUDIO"]="a",e["VIDEO"]="v",e["MUXED"]="av",e["INIT"]="i",e["CAPTION"]="c",e["TIMED_TEXT"]="tt",e["KEY"]="k",e["OTHER"]="o"})($a||($a={})),function(e){e["DASH"]="d",e["HLS"]="h",e["SMOOTH"]="s",e["OTHER"]="o"}(Ga||(Ga={})),function(e){e["OBJECT"]="CMCD-Object",e["REQUEST"]="CMCD-Request",e["SESSION"]="CMCD-Session",e["STATUS"]="CMCD-Status"}(ja||(ja={}));const Va={[ja.OBJECT]:["br","d","ot","tb"],[ja.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[ja.SESSION]:["cid","pr","sf","sid","st","v"],[ja.STATUS]:["bs","rtp"]};class Ka{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(e=>e instanceof Ka?e:new Ka(e))),this.value=e,this.params=t}}class Ha{constructor(e){this.description=void 0,this.description=e}}const Ya="Dict";function za(e){return Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"===typeof e?JSON.stringify(e):String(e)}function qa(e,t,r,i){return new Error(`failed to ${e} "${za(t)}" as ${r}`,{cause:i})}const Wa="Bare Item",Xa="Boolean",Qa="Byte Sequence",Za="Decimal",Ja="Integer";function eo(e){return e<-999999999999999||999999999999999<e}const to=/[\x00-\x1f\x7f]+/,ro="Token",io="Key";function so(e,t,r){return qa("serialize",e,t,r)}function no(e){if("boolean"!==typeof e)throw so(e,Xa);return e?"?1":"?0"}function ao(e){return btoa(String.fromCharCode(...e))}function oo(e){if(!1===ArrayBuffer.isView(e))throw so(e,Qa);return`:${ao(e)}:`}function lo(e){if(eo(e))throw so(e,Ja);return e.toString()}function ho(e){return"@"+lo(e.getTime()/1e3)}function co(e,t){if(e<0)return-co(-e,t);const r=Math.pow(10,t),i=Math.abs(e*r%1-.5)<Number.EPSILON;if(i){const t=Math.floor(e*r);return(t%2===0?t:t+1)/r}return Math.round(e*r)/r}function uo(e){const t=co(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw so(e,Za);const r=t.toString();return r.includes(".")?r:r+".0"}const fo="String";function po(e){if(to.test(e))throw so(e,fo);return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function mo(e){return e.description||e.toString().slice(7,-1)}function go(e){const t=mo(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw so(t,ro);return t}function yo(e){switch(typeof e){case"number":if(!u(e))throw so(e,Wa);return Number.isInteger(e)?lo(e):uo(e);case"string":return po(e);case"symbol":return go(e);case"boolean":return no(e);case"object":if(e instanceof Date)return ho(e);if(e instanceof Uint8Array)return oo(e);if(e instanceof Ha)return go(e);default:throw so(e,Wa)}}function vo(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw so(e,io);return e}function _o(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?";"+vo(e):`;${vo(e)}=${yo(t)}`).join("")}function Eo(e){return e instanceof Ka?`${yo(e.value)}${_o(e.params)}`:yo(e)}function bo(e){return`(${e.value.map(Eo).join(" ")})${_o(e.params)}`}function So(e,t={whitespace:!0}){if("object"!==typeof e)throw so(e,Ya);const r=e instanceof Map?e.entries():Object.entries(e),i=null!=t&&t.whitespace?" ":"";return Array.from(r).map(([e,t])=>{t instanceof Ka===!1&&(t=new Ka(t));let r=vo(e);return!0===t.value?r+=_o(t.params):(r+="=",Array.isArray(t.value)?r+=bo(t):r+=Eo(t)),r}).join(","+i)}function To(e,t){return So(e,t)}const Lo=e=>"ot"===e||"sf"===e||"st"===e,Ao=e=>"number"===typeof e?u(e):null!=e&&""!==e&&!1!==e;function Ro(e,t){const r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;const s=r.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);while(s[0]===n[0])s.shift(),n.shift();while(n.length)n.shift(),s.unshift("..");return s.join("/")}function wo(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)});return r}}}const ko=e=>Math.round(e),Do=(e,t)=>(null!=t&&t.baseUrl&&(e=Ro(e,t.baseUrl)),encodeURIComponent(e)),Io=e=>100*ko(e/100),xo={br:ko,d:ko,bl:Io,dl:Io,mtp:Io,nor:Do,rtp:Io,tb:ko};function Co(e,t){const r={};if(null==e||"object"!==typeof e)return r;const i=Object.keys(e).sort(),s=c({},xo,null==t?void 0:t.formatters),n=null==t?void 0:t.filter;return i.forEach(i=>{if(null!=n&&n(i))return;let a=e[i];const o=s[i];o&&(a=o(a,t)),"v"===i&&1===a||"pr"==i&&1===a||Ao(a)&&(Lo(i)&&"string"===typeof a&&(a=new Ha(a)),r[i]=a)}),r}function Po(e,t={}){return e?To(Co(e,t),c({whitespace:!1},t)):""}function Oo(e,t={}){if(!e)return{};const r=Object.entries(e),i=Object.entries(Va).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{})),s=r.reduce((e,t)=>{var r;const[s,n]=t,a=(null==(r=i.find(e=>e[1].includes(s)))?void 0:r[0])||ja.REQUEST;return null!=e[a]||(e[a]={}),e[a][s]=n,e},{});return Object.entries(s).reduce((e,[r,i])=>(e[r]=Po(i,t),e),{})}function Mo(e,t,r){return c(e,Oo(t,r))}const Fo="CMCD";function No(e,t={}){if(!e)return"";const r=Po(e,t);return`${Fo}=${encodeURIComponent(r)}`}const Bo=/CMCD=[^&#]+/;function Uo(e,t,r){const i=No(t,r);if(!i)return e;if(Bo.test(e))return e.replace(Bo,i);const s=e.includes("?")?"&":"?";return`${e}${s}${i}`}class $o{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.includeKeys=void 0,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:$a.MANIFEST,su:!this.initialized})}catch(t){L.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=e=>{try{const t=e.frag,r=this.hls.levels[t.level],i=this.getObjectType(t),s={d:1e3*t.duration,ot:i};i!==$a.VIDEO&&i!==$a.AUDIO&&i!=$a.MUXED||(s.br=r.bitrate/1e3,s.tb=this.getTopBandwidth(i)/1e3,s.bl=this.getBufferLength(i)),this.apply(e,s)}catch(t){L.warn("Could not generate segment CMCD data.",t)}},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||wo(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHED,this.onMediaDetached,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHED,this.onMediaDetached,this),e.off(m.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=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:Ga.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){c(t,this.createData());const r=t.ot===$a.INIT||t.ot===$a.VIDEO||t.ot===$a.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{})),this.useHeaders?(e.headers||(e.headers={}),Mo(e.headers,t)):e.url=Uo(e.url,t)}getObjectType(e){const{type:t}=e;return"subtitle"===t?$a.TIMED_TEXT:"initSegment"===e.sn?$a.INIT:"audio"===t?$a.AUDIO:"main"===t?this.hls.audioTracks.length?$a.VIDEO:$a.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===$a.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}for(const s of t)s.bitrate>r&&(r=s.bitrate);return r>0?r:NaN}getBufferLength(e){const t=this.hls.media,r=e===$a.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;const i=pi.bufferInfo(r,t.currentTime,this.config.maxBufferHole);return 1e3*i.len}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)}}}}const Go=3e5;class jo{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==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((null==r?void 0:r.action)===Br.SendAlternateToPenaltyBox&&r.flags===Ur.MoveAllAlternatesMatchingHost){const e=this.levels;let i=this.pathwayPriority,s=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:n}=t.context;r&&e?s=this.getPathwayForGroupId(r,n,s):i&&(s=i)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!i&&e&&(i=e.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==s),r.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${s} levels: ${e?e.length:e} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}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]>Go&&delete r[e]});for(let s=0;s<e.length;s++){const i=e[s];if(i in r)continue;if(i===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(t=this.getLevelsForPathway(i),t.length>0){this.log(`Setting Pathway to "${i}"`),this.pathwayId=i,Ar(t),this.hls.trigger(m.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[n];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=n);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let s=0;s<i.length;s++)if(t===Nt.AUDIO_TRACK&&i[s].hasAudioGroup(e)||t===Nt.SUBTITLE_TRACK&&i[s].hasSubtitleGroup(e))return i[s].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:s,"BASE-ID":n,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===s))return;const o=this.getLevelsForPathway(n).map(e=>{const t=new w(e.attrs);t["PATHWAY-ID"]=s;const n=t.AUDIO&&`${t.AUDIO}_clone_${s}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${s}`;n&&(r[t.AUDIO]=n,t.AUDIO=n),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=Ko(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),d=new cr({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let r=1;r<e.audioGroups.length;r++)d.addGroupId("audio",`${e.audioGroups[r]}_clone_${s}`);if(e.subtitleGroups)for(let r=1;r<e.subtitleGroups.length;r++)d.addGroupId("text",`${e.subtitleGroups[r]}_clone_${s}`);return d});t.push(...o),Vo(this.audioTracks,r,a,s),Vo(this.subtitleTracks,i,a,s)})}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(d){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 s={responseType:"json",url:i.href},n=t.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,s)=>{this.log(`Loaded steering manifest: "${i}"`);const n=e.data;if(1!==n.VERSION)return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(d){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+a)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const h={steeringManifest:n,url:i.toString()};this.hls.trigger(m.STEERING_MANIFEST_LOADED,h),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 s=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,s);else{const e=this.loader;if("function"===typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},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(s,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;const r=null==(t=this.hls)?void 0:t.media;!r||r.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}function Vo(e,t,r,i){e&&Object.keys(t).forEach(s=>{const n=e.filter(e=>e.groupId===s).map(e=>{const n=c({},e);return n.details=void 0,n.attrs=new w(n.attrs),n.url=n.attrs.URI=Ko(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[s],n.attrs["PATHWAY-ID"]=i,n});e.push(...n)})}function Ko(e,t,r,i){const{HOST:s,PARAMS:n,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(e=>{e&&l.searchParams.set(e,n[e])}),l.href}const Ho=/^age:\s*[\d.]+\s*$/im;class Yo{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=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new x,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=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||!t)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(!this.stats.aborted)return s(r,t.url)}).catch(e=>(r.open("GET",t.url,!0),s(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=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:n}=r.loadPolicy;if(i)for(const a in i)e.setRequestHeader(a,i[a]);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=s&&u(s)?s:n,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,s=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,n="text"!==t.responseType;if(i>=200&&i<300&&(n&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const s=n?t.response:t.responseText,a="arraybuffer"===t.responseType?s.byteLength:s.length;if(r.loaded=r.total=a,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(r,e,s,t),!this.callbacks)return;const l={url:t.responseURL,data:s,code:i};this.callbacks.onSuccess(l,r,e,t)}else{const n=s.loadPolicy.errorRetry,a=r.retry,o={url:e.url,data:void 0,code:i};Ir(n,a,!1,o)?this.retry(n):(L.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,r=this.stats.retry;if(Ir(t,r,!0))this.retry(t);else{var i;L.warn("timeout while loading "+(null==(i=this.context)?void 0:i.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=kr(e,r.retry),r.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0: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&&Ho.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}}function zo(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}const qo=/(\d+)-(\d+)\/(\d+)/;class Wo{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Jo,this.controller=new self.AbortController,this.stats=new x}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(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 s=Xo(e,this.controller.signal),n=r.onProgress,a="arraybuffer"===e.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=l&&u(l)?l:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},t.timeout),self.fetch(this.request).then(s=>{this.response=this.loader=s;const o=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},d-(o-i.loading.start)),!s.ok){const{status:e,statusText:t}=s;throw new el(t||"fetch, bad network response",e,s)}return i.loading.first=o,i.total=Zo(s.headers)||i.total,n&&u(t.highWaterMark)?this.loadProgressively(s,i,e,t.highWaterMark,n):a?s.arrayBuffer():"json"===e.responseType?s.json():s.text()}).then(s=>{const a=this.response;if(!a)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=s[o];l&&(i.loaded=i.total=l);const d={url:a.url,data:s,code:a.status};n&&!u(t.highWaterMark)&&n(i,e,s,a),r.onSuccess(d,i,e,a)}).catch(t=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const s=t&&t.code||0,n=t?t.message:null;r.onError({code:s,text:n},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,s){const n=new Ui,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return n.dataLength&&s(t,r,n.flush(),e),Promise.resolve(new ArrayBuffer(0));const l=a.value,d=l.length;return t.loaded+=d,d<i||n.dataLength?(n.push(l),n.dataLength>=i&&s(t,r,n.flush(),e)):s(t,r,l,e),o()}).catch(()=>Promise.reject());return o()}}function Xo(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(c({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}function Qo(e){const t=qo.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Zo(e){const t=e.get("Content-Range");if(t){const e=Qo(t);if(u(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}function Jo(e,t){return new self.Request(e.url,t)}class el extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const tl=/\s/,rl={newCue(e,t,r,i){const s=[];let n,a,o,l,d;const h=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,d="",!n.isEmpty()){var c;for(let e=0;e<n.chars.length;e++)tl.test(n.chars[e].uchar)&&o?l++:(d+=n.chars[e].uchar,o=!1);n.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=aa(d.trim()),f=ua(t,r,i);null!=e&&null!=(c=e.cues)&&c.getCueById(f)||(a=new h(t,r,i),a.id=f,a.line=u+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),s.push(a))}return e&&s.length&&(s.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),s.forEach(t=>Vt(e,t))),s}},il={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},sl=o(o({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold: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:Yo,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:oi,bufferController:kn,capLevelController:Ma,errorController:$r,fpsController:Fa,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Q,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:il},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},nl()),{},{subtitleStreamController:Tn,subtitleTrackController:An,timelineController:Ia,audioStreamController:En,audioTrackController:bn,emeController:Ba,cmcdController:$o,contentSteeringController:jo});function nl(){return{cueHandler:rl,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function al(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=ol(e),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(e=>{const i=("level"===e?"playlist":e)+"LoadPolicy",n=void 0===t[i],a=[];s.forEach(s=>{const o=`${e}Loading${s}`,l=t[o];if(void 0!==l&&n){a.push(o);const e=r[i].default;switch(t[i]={default:e},s){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;break}}}),a.length&&L.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${i}": ${JSON.stringify(t[i])}`)}),o(o({},r),t)}function ol(e){return e&&"object"===typeof e?Array.isArray(e)?e.map(ol):Object.keys(e).reduce((t,r)=>(t[r]=ol(e[r]),t),{}):e}function ll(e){const t=e.loader;if(t!==Wo&&t!==Yo)L.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{const t=zo();t&&(e.loader=Wo,e.progressive=!0,e.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let dl;class hl extends Gr{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){const e=this._levels;e.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,i=[],s={},n={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{var t,d;const h=e.attrs;let{audioCodec:c,videoCodec:u}=e;-1!==(null==(t=c)?void 0:t.indexOf("mp4a.40.34"))&&(dl||(dl=/chrome|firefox/i.test(navigator.userAgent)),dl&&(e.audioCodec=c=void 0)),c&&(e.audioCodec=c=Et(c,r)),0===(null==(d=u)?void 0:d.indexOf("avc1"))&&(u=e.videoCodec=St(u));const{width:f,height:p,unknownCodecs:m}=e;if(a||(a=!(!f||!p)),o||(o=!!u),l||(l=!!c),null!=m&&m.length||c&&!ut(c,"audio",r)||u&&!ut(u,"video",r))return;const{CODECS:g,"FRAME-RATE":y,"HDCP-LEVEL":v,"PATHWAY-ID":_,RESOLUTION:E,"VIDEO-RANGE":b}=h,S=(_||".")+"-",T=`${S}${e.bitrate}-${E}-${y}-${g}-${b}-${v}`;if(s[T])if(s[T].uri===e.url||e.attrs["PATHWAY-ID"])s[T].addGroupId("audio",h.AUDIO),s[T].addGroupId("text",h.SUBTITLES);else{const t=n[T]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=new cr(e);s[T]=r,i.push(r)}else{const t=new cr(e);s[T]=t,n[T]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}filterAndSortMediaOptions(e,t,r,i,s){let n=[],a=[],o=e;if((r||i)&&s&&(o=o.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>(!!e||!(!r||!i))&&or(t))),0===o.length)return void Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}});if(t.audioTracks){const{preferManagedMediaSource:e}=this.hls.config;n=t.audioTracks.filter(t=>!t.audioCodec||ut(t.audioCodec,"audio",e)),cl(n)}t.subtitles&&(a=t.subtitles,cl(a));const l=o.slice(0);o.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return ar.indexOf(e.videoRange)-ar.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=mt(e.videoCodec),i=mt(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=gt(e.codecSet),i=gt(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let d=l[0];if(this.steering&&(o=this.steering.filterParsedLevels(o),o.length!==l.length))for(let f=0;f<l.length;f++)if(l[f].pathwayId===o[0].pathwayId){d=l[f];break}this._levels=o;for(let f=0;f<o.length;f++)if(o[f]===d){var h;this._firstLevel=f;const e=d.bitrate,t=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${o.length} level(s) found, first bitrate: ${e}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const r=Math.min(e,this.hls.config.abrEwmaDefaultEstimateMax);r>t&&t===sl.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=r)}break}const c=s&&!i,u={levels:o,audioTracks:n,subtitleTracks:a,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:i,altAudio:!c&&n.some(e=>!!e.url)};this.hls.trigger(m.MANIFEST_PARSED,u),(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(m.ERROR,{type:g.OTHER_ERROR,details:y.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,s=i?i.attrs["PATHWAY-ID"]:void 0,n=t[e],a=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,r===e&&n.details&&i&&s===a)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const o={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(m.LEVEL_SWITCHING,o);const l=n.details;if(!l||l.live){const e=this.switchParams(n.uri,null==i?void 0:i.details,l);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.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===Nt.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Bt.MAIN){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;const r=this._levels[t.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:s}=t,n=this._levels[i];var a;if(!n)return this.warn("Invalid level index "+i),void(null!=(a=t.deliveryDirectives)&&a.skip&&(s.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(i,t,n.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}const n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(m.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));Ar(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(m.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(m.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function cl(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}class ul{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.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=y.KEY_LOAD_ERROR,r,i,s){return new Di({type:g.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:i}=e;for(let e=0;e<t.length;e++){const s=t[e];if(i<=s.cc&&("initSegment"===r||"initSegment"===s.sn||r<s.sn)){this.emeController.selectKeySystemFormat(s).then(e=>{s.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 s=e.decryptdata;if(!s){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,y.KEY_LOAD_ERROR,r))}const n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,y.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));let a=this.keyUriToKeyInfo[n];if(null!=(r=a)&&r.decryptdata.key)return s.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});var o;if(null!=(i=a)&&i.keyLoadPromise)switch(null==(o=a.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then(t=>(s.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:a}))}switch(a=this.keyUriToKeyInfo[n]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,y.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.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=r.loader,s=new i(r);return t.keyLoader=e.loader=s,e.keyLoadPromise=new Promise((i,n)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=r.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(e,t,r,s)=>{const{frag:a,keyInfo:o,url:l}=r;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return n(this.createKeyLoadError(a,y.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,i({frag:a,keyInfo:o})},onError:(e,r,i,s)=>{this.resetLoader(r),n(this.createKeyLoadError(t,y.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,o({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,y.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,y.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};s.load(a,d,h)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,s=r.loader;t.keyLoader===s&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],s&&s.destroy()}}function fl(){return self.SourceBuffer||self.WebKitSourceBuffer}function pl(){const e=lt();if(!e)return!1;const t=fl();return!t||t.prototype&&"function"===typeof t.prototype.appendBuffer&&"function"===typeof t.prototype.remove}function ml(){if(!pl())return!1;const e=lt();return"function"===typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(pt(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(pt(t,"audio"))))}function gl(){var e;const t=fl();return"function"===typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}const yl=250,vl=2,_l=.1,El=.05;class bl{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:s}=this;if(null===i)return;const{currentTime:n,seeking:a}=i,o=this.seeking&&!a,l=!this.seeking&&a;if(this.seeking=a,n!==e){if(this.moved=!0,a||(this.nudgeRetry=0),null!==s){if(this.stallReported){const e=self.performance.now()-s;L.warn(`playback not stuck anymore @${n}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null}return}if(l||o)return void(this.stalled=null);if(i.paused&&!a||i.ended||0===i.playbackRate||!pi.getBuffered(i).length)return void(this.nudgeRetry=0);const d=pi.bufferInfo(i,n,0),h=d.nextStart||0;if(a){const e=d.len>vl,r=!h||t&&t.start<=n||h-n>vl&&!this.fragmentTracker.getPartialFragment(n);if(e||r)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var c;const e=d.len>0;if(!e&&!h)return;const t=Math.max(h,d.start||0)-n,r=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,s=null==r||null==(c=r.details)?void 0:c.live,a=s?2*r.details.targetduration:vl,o=this.fragmentTracker.getPartialFragment(n);if(t>0&&(t<=a||o))return void(i.paused||this._trySkipBufferHole(o))}const u=self.performance.now();if(null===s)return void(this.stalled=u);const f=u-s;if(!a&&f>=yl&&(this._reportStall(d),!this.media))return;const p=pi.bufferInfo(i,n,r.maxBufferHole);this._tryFixBufferStall(p,f)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:i,media:s}=this;if(null===s)return;const n=s.currentTime,a=i.getPartialFragment(n);if(a){const e=this._trySkipBufferHole(a);if(e||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-n<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(L.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)})`);L.warn(i.message),t.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.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 s=i.currentTime,n=pi.bufferInfo(i,s,0),a=s<n.start?n.start:n.nextStart;if(a){const o=n.len<=t.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,d=a-s;if(d>0&&(o||l)){if(d>t.maxBufferHole){const{fragmentTracker:t}=this;let r=!1;if(0===s){const e=t.getAppendedFrag(0,Bt.MAIN);e&&a<e.end&&(r=!0)}if(!r){const r=e||t.getAppendedFrag(s,Bt.MAIN);if(r){let e=!1,i=r.end;while(i<a){const r=t.getPartialFragment(i);if(!r){e=!0;break}i+=r.duration}if(e)return 0}}}const n=Math.max(a+El,s+_l);if(L.warn(`skipping hole, adjusting currentTime from ${s} to ${n}`),this.moved=!0,this.stalled=null,i.currentTime=n,e&&!e.gap){const t=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${n}`);r.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return n}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:r,nudgeRetry:i}=this;if(null===r)return;const s=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){const n=s+(i+1)*e.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${s} to ${n}`);L.warn(a.message),r.currentTime=n,t.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const r=new Error(`Playhead still not moving while enough data buffered @${s} after ${e.nudgeMaxRetry} nudges`);L.error(r.message),t.trigger(m.ERROR,{type:g.MEDIA_ERROR,details:y.BUFFER_STALLED_ERROR,error:r,fatal:!0})}}}const Sl=100;class Tl extends Bi{constructor(e,t,r){super(e,t,r,"[stream-controller]",Bt.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(m.ERROR,this.onError,this),e.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this),e.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(m.ERROR,this.onError,this),e.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(m.BUFFER_CREATED,this.onBufferCreated,this),e.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(Sl),this.level=-1,!this.startFragRequested){let e=r.startLevel;-1===e&&(r.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=r.firstAutoLevel),r.nextLoadLevel=e,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=Ni.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Ni.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ni.WAITING_LEVEL:{const{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=Ni.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=Ni.IDLE;break}break}case Ni.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),r=this.retryDate;if(!r||t>=r||null!=(e=this.media)&&e.seeking){const{levels:e,level:t}=this,r=null==e?void 0:e[t];this.resetStartWhenNotLoaded(r||null),this.state=Ni.IDLE}}break}this.state===Ni.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const s=e.nextLoadLevel;if(null==r||!r[s])return;const n=r[s],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(m.BUFFER_EOS,e),void(this.state=Ni.ENDED)}e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const l=n.details;if(!l||this.state===Ni.WAITING_LEVEL||l.live&&this.levelLastLoaded!==n)return this.level=s,void(this.state=Ni.WAITING_LEVEL);const d=a.len,h=this.getMaxBufferLength(n.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const c=this.backtrackFragment?this.backtrackFragment.start:a.end;let u=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&u&&"initSegment"!==u.sn&&this.fragmentTracker.getState(u)!==di.OK){var f;const e=(null!=(f=this.backtrackFragment)?f:u).sn,t=e-l.startSN,r=l.fragments[t-1];r&&u.cc===r.cc&&(u=r,this.fragmentTracker.removeFragment(r))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(u&&this.isLoopLoading(u,c)){const e=u.gap;if(!e){const e=this.audioOnly&&!this.altAudio?C.AUDIO:C.VIDEO,t=(e===C.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Bt.MAIN)}u=this.getNextFragmentLoopLoading(u,l,a,Bt.MAIN,h)}u&&(!u.initSegment||u.initSegment.data||this.bitrateTest||(u=u.initSegment),this.loadFragment(u,n,c))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);this.fragCurrent=e,i===di.NOT_LOADED||i===di.PARTIAL?"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,Bt.MAIN)}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 s=this.getLevelDetails();if(null!=s&&s.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){const t=this.hls.nextLoadLevel,i=e[t],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*i.maxBitrate/(1e3*s)+1:0}else r=0;const n=this.getBufferedFrag(t.currentTime+r);if(n){const e=this.followingBufferedFrag(n);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(n.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));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 Ni.KEY_LOADING:case Ni.FRAG_LOADING:case Ni.FRAG_LOADING_WAITING_RETRY:case Ni.PARSING:case Ni.PARSED:this.state=Ni.IDLE;break}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 bl(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;u(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(m.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,i=!1;t.levels.forEach(e=>{const t=e.audioCodec;t&&(r=r||-1!==t.indexOf("mp4a.40.2"),i=i||-1!==t.indexOf("mp4a.40.5"))}),this.audioCodecSwitch=r&&i&&!gl(),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!==Ni.IDLE)return;const i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=Ni.WAITING_LEVEL)}onLevelLoaded(e,t){var r;const{levels:i}=this,s=t.level,n=t.details,a=n.totalduration;if(!i)return void this.warn("Levels were reset while loading level "+s);this.log(`Level ${s} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""}, cc [${n.startCC}, ${n.endCC}] duration:${a}`);const o=i[s],l=this.fragCurrent;!l||this.state!==Ni.FRAG_LOADING&&this.state!==Ni.FRAG_LOADING_WAITING_RETRY||l.level!==t.level&&l.loader&&this.abortCurrentFrag();let d=0;if(n.live||null!=(r=o.details)&&r.live){var h;if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;d=this.alignPlaylists(n,o.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(o.details=n,this.levelLastLoaded=o,this.hls.trigger(m.LEVEL_UPDATED,{details:n,level:s}),this.state===Ni.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=Ni.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,d),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:s}=e,{levels:n}=this;if(!n)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 a=n[r.level],o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,d=o.PTSKnown||!o.live,h=null==(t=r.initSegment)?void 0:t.data,c=this._getAudioCodec(a),u=this.transmuxer=this.transmuxer||new mn(this.hls,Bt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new mi(r.level,r.sn,r.stats.chunkCount,s.byteLength,f,p),g=this.initPTS[r.cc];u.push(s,h,c,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.altAudio,i=!!t.url;if(!i){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(m.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(m.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,s,n=!1;for(const a in r){const e=r[a];if("main"===e.id){if(s=a,i=e,"video"===a){const e=r[a];e&&(this.videoBuffer=e.buffer)}}else n=!0}n&&i?(this.log(`Alternate track found, use ${s}.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!==Bt.MAIN)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===Ni.PARSED&&(this.state=Ni.IDLE));const s=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}onError(e,t){var r;if(t.fatal)this.state=Ni.ERROR;else switch(t.details){case y.FRAG_GAP:case y.FRAG_PARSING_ERROR:case y.FRAG_DECRYPT_ERROR:case y.FRAG_LOAD_ERROR:case y.FRAG_LOAD_TIMEOUT:case y.KEY_LOAD_ERROR:case y.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Bt.MAIN,t);break;case y.LEVEL_LOAD_ERROR:case y.LEVEL_LOAD_TIMEOUT:case y.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Ni.WAITING_LEVEL||(null==(r=t.context)?void 0:r.type)!==Nt.LEVEL||(this.state=Ni.IDLE);break;case y.BUFFER_APPEND_ERROR:case y.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===y.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case y.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!pi.getBuffered(e).length){const e=this.state!==Ni.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Ni.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==C.AUDIO||this.audioOnly&&!this.altAudio){const e=(t===C.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,Bt.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),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&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=pi.getBuffered(e),s=i.length?i.start(0):0,n=s-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),r+=n,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{const{hls:i}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Ni.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const s=e.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),i.trigger(m.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:d}=a,{video:h,text:c,id3:f,initSegment:p}=s,{details:g}=d,y=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Ni.PARSING,p){if(null!=p&&p.tracks){const e=o.initSegment||o;this._bufferInitSegment(d,p.tracks,e,n),i.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}const e=p.initPTS,t=p.timescale;u(e)&&(this.initPTS[o.cc]={baseTime:e,timescale:t},i.trigger(m.INIT_PTS_FOUND,{frag:o,id:r,initPTS:e,timescale:t}))}if(h&&g&&"initSegment"!==o.sn){const e=g.fragments[o.sn-1-g.startSN],t=o.sn===g.startSN,r=!e||o.cc>e.cc;if(!1!==s.independent){const{startPTS:e,endPTS:i,startDTS:s,endDTS:a}=h;if(l)l.elementaryStreams[h.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),h.dropped&&h.independent){const s=this.getMainFwdBufferInfo(),n=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:e;if(!t&&n<l-this.config.maxBufferHole&&!r)return void this.backtrack(o);r&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,i,o.start,a,!0)}else t&&e>vl&&(o.gap=!0);o.setElementaryStreamInfo(h.type,e,i,s,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,n,t||r)}else{if(!t&&!r)return void this.backtrack(o);o.gap=!0}}if(y){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=y;l&&(l.elementaryStreams[C.AUDIO]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(C.AUDIO,e,t,r,i),this.bufferFragmentData(y,o,l,n)}if(g&&null!=f&&null!=(t=f.samples)&&t.length){const e={id:r,frag:o,details:g,samples:f.samples};i.trigger(m.FRAG_PARSING_METADATA,e)}if(g&&c){const e={id:r,frag:o,details:g,samples:c.samples};i.trigger(m.FRAG_PARSING_USERDATA,e)}}}_bufferInitSegment(e,t,r,i){if(this.state!==Ni.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:s,video:n,audiovideo:a}=t;if(s){let t=e.audioCodec;const r=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==s.metadata.channelCount&&-1===r.indexOf("firefox")&&(t="mp4a.40.5")),t&&-1!==t.indexOf("mp4a.40.5")&&-1!==r.indexOf("android")&&"audio/mpeg"!==s.container&&(t="mp4a.40.2",this.log("Android: force audio codec to "+t)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),s.levelCodec=t,s.id="main",this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${s.codec}]`)}n&&(n.levelCodec=e.videoCodec,n.id="main",this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${n.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),this.hls.trigger(m.BUFFER_CODECS,t),Object.keys(t).forEach(e=>{const s=t[e],n=s.initSegment;null!=n&&n.byteLength&&this.hls.trigger(m.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Bt.MAIN)}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=Ni.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(pi.isBuffered(e,r)?t=this.getAppendedFrag(r):pi.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||(this.fragPlaying=t,this.hls.trigger(m.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(m.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&&u(t)&&u(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 Ll{static get version(){return"1.5.9"}static isMSESupported(){return pl()}static isSupported(){return ml()}static getMediaSource(){return lt()}static get Events(){return m}static get ErrorTypes(){return g}static get ErrorDetails(){return y}static get DefaultConfig(){return Ll.defaultConfig?Ll.defaultConfig:sl}static set DefaultConfig(e){Ll.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new pn,this._autoLevelCapping=-1,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,this.triggeringException=void 0,T(e.debug||!1,"Hls instance");const t=this.config=al(Ll.DefaultConfig,e);this.userConfig=e,t.progressive&&ll(t);const{abrController:r,bufferController:i,capLevelController:s,errorController:n,fpsController:a}=t,o=new n(this),l=this.abrController=new r(this),d=this.bufferController=new i(this),h=this.capLevelController=new s(this),c=new a(this),u=new Gt(this),f=new rr(this),p=t.contentSteeringController,g=p?new p(this):null,y=this.levelController=new hl(this,g),v=new hi(this),_=new ul(this.config),E=this.streamController=new Tl(this,v,_);h.setStreamController(E),c.setStreamController(E);const b=[u,y,E];g&&b.splice(1,0,g),this.networkControllers=b;const S=[l,d,h,c,f,v];this.audioTrackController=this.createController(t.audioTrackController,b);const L=t.audioStreamController;L&&b.push(new L(this,v,_)),this.subtitleTrackController=this.createController(t.subtitleTrackController,b);const A=t.subtitleStreamController;A&&b.push(new A(this,v,_)),this.createController(t.timelineController,S),_.emeController=this.emeController=this.createController(t.emeController,S),this.cmcdController=this.createController(t.cmcdController,S),this.latencyController=this.createController(ir,S),this.coreComponents=S,b.push(o);const R=o.onErrorOut;"function"===typeof R&&this.on(m.ERROR,R,o)}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(r){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const t=e===m.ERROR;this.trigger(m.ERROR,{type:g.OTHER_ERROR,details:y.INTERNAL_EXCEPTION,fatal:t,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(m.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){L.log("attachMedia"),this._media=e,this.trigger(m.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(m.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,i=this.url=n.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(m.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){L.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.log("set firstLevel:"+e),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){L.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}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){nr(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}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<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,r)for(let s=i;s--;){const t=e[s].attrs["HDCP-LEVEL"];if(t&&t<=r)return s}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}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 allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}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}}Ll.defaultConfig=void 0},bf15:function(module,exports,__webpack_require__){"use strict";(function(module){var __WEBPACK_AMD_DEFINE_FACTORY__,__WEBPACK_AMD_DEFINE_RESULT__;
|
||
/*!
|
||
* Mui Player Javascript Library v1.8.1 @Professional edition
|
||
* Date:2023-01-28
|
||
* Released under GPL-3.0 license
|
||
* https://muiplayer.js.org/
|
||
*/function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;t=function(){};return{s:t,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return n=e.done,e},e:function(e){a=!0,s=e},f:function(){try{n||null==r.return||r.return()}finally{if(a)throw s}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function _typeof(e){return(_typeof="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)}!function(e,t){"object"==_typeof(exports)&&"object"==_typeof(module)?module.exports=t():_typeof(__webpack_require__("3c35"))?(__WEBPACK_AMD_DEFINE_FACTORY__=t,__WEBPACK_AMD_DEFINE_RESULT__="function"===typeof __WEBPACK_AMD_DEFINE_FACTORY__?__WEBPACK_AMD_DEFINE_FACTORY__.call(exports,__webpack_require__,exports,module):__WEBPACK_AMD_DEFINE_FACTORY__,void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)):e.MuiPlayer=t()}(window,(function(){var MuiPlayer=function MuiPlayer(config){var _this=this;_this._global_={};var webpagePlugin="",mobilePlugin="",hls=null,flv=null,option=config||{},plugins=option.plugins||[];this._event_={};var con="string"==typeof option.container?document.querySelector(option.container):option.container,$CONSTANT,$habit,$node,$global,element,$el,variable,$data,$method;con&&($CONSTANT={unitLengthReg:/^(auto|inherit|initial|\d+(\.\d+)?(\%|px|cm|mm|em|rem|vw|vh|)?)$/i,encodeKey:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"},$habit={themeColor:"#1e98d4"},$node={video:'\x3c!-- HTML5 Video --\x3e<div class="video-wrapper"><video width="100%" height="100%"></video></div>',mplayerPoster:'<div class="mplayer-poster" id="mplayer-poster"></div>',mplayerCover:'\x3c!-- 媒体播放遮罩层 --\x3e<div class="mplayer-cover" id="mplayer-cover"></div>',mplayerLoading:'\x3c!-- Mplayer加载Loading --\x3e<div class="mplayer-loading"id="mplayer-loading"control><svg viewBox="25 25 50 50"class="mplayer-loading__circular"><circle cx="50"cy="50"r="20"fill="none"></circle></svg></div>',mplayerError:'\x3c!-- 视频加载错误显示 --\x3e<div class="mplayer-error"id="mplayer-error"control><div class="errop-tip">视频加载失败,点击刷新</div><svg t="1575125481608"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="5893"width="28"height="28"><path d="M513.34 831.74C337.03 831.74 193.6 688.31 193.6 512c0-71.09 23.31-138.85 65.53-194.03v51.61c0 17.67 14.33 32 32 32s32-14.33 32-32V239.45c0-5.87-1.59-11.36-4.34-16.09-0.06-0.1-0.11-0.2-0.17-0.3-0.16-0.28-0.34-0.55-0.51-0.82-0.13-0.2-0.26-0.41-0.39-0.61-0.08-0.13-0.17-0.25-0.26-0.37a35.5 35.5 0 0 0-1.58-2.13c-6.81-8.35-16.96-12.35-26.95-11.69h-130c-17.67 0-32 14.33-32 32s14.33 32 32 32h55.35C159.8 339 129.6 423.35 129.6 512c0 51.79 10.15 102.05 30.17 149.38 19.33 45.7 46.99 86.74 82.23 121.97 35.23 35.23 76.27 62.9 121.97 82.23 47.33 20.02 97.59 30.17 149.38 30.17 17.67 0 32-14.33 32-32s-14.34-32.01-32.01-32.01zM855.38 762.3h-51.23c19.81-23 36.93-48.3 50.75-75.22 27.6-53.74 42.18-114.28 42.18-175.08 0-51.79-10.15-102.05-30.17-149.38-19.33-45.7-46.99-86.73-82.23-121.97-35.23-35.23-76.27-62.9-121.97-82.23-47.33-20.02-97.59-30.17-149.38-30.17-17.67 0-32 14.33-32 32s14.33 32 32 32c176.31 0 319.74 143.44 319.74 319.74 0 78.31-27.68 151.61-77.6 209.05l0.24-56.04c0.08-17.67-14.19-32.06-31.86-32.14h-0.14c-17.61 0-31.92 14.24-32 31.86l-0.55 129.43a31.988 31.988 0 0 0 9.32 22.71 31.68 31.68 0 0 0 5.33 4.3c0.02 0.01 0.04 0.02 0.06 0.04 0.48 0.31 0.97 0.61 1.47 0.89l0.15 0.09c0.5 0.28 1 0.54 1.51 0.8 0.03 0.01 0.05 0.03 0.08 0.04 1.64 0.8 3.34 1.46 5.1 1.98 0.01 0 0.02 0.01 0.03 0.01 0.55 0.16 1.1 0.3 1.66 0.43 0.07 0.02 0.15 0.03 0.22 0.05 0.5 0.11 1 0.21 1.5 0.3 0.1 0.02 0.2 0.04 0.3 0.05 0.48 0.08 0.96 0.15 1.44 0.21 0.11 0.01 0.23 0.03 0.34 0.04 0.48 0.05 0.95 0.09 1.43 0.12l0.34 0.03c0.53 0.03 1.07 0.04 1.61 0.05h132.31c17.67 0 32-14.33 32-32s-14.31-31.99-31.98-31.99z"p-id="5894"fill="#ffffff"></path></svg></div>',mplayerHeader:'\x3c!-- Mplayer 顶部导航 --\x3e<div class="mplayer-header"id="mplayer-header"><div class="title-groupt"id="title-groupt"><button class="player-btn header-control back-button keyboard-input"id="back-button"control><svg id="back-icon-svg"t="1573891955387"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="4550"width="18"height="18"><path d="M305.519192 557.640404c-11.636364 0-23.40202-4.39596-32.323232-13.317172-17.842424-17.842424-17.842424-46.674747 0-64.517171L683.830303 69.30101c17.842424-17.842424 46.674747-17.842424 64.517172 0 17.842424 17.842424 17.842424 46.674747 0 64.517172L337.713131 544.323232c-8.921212 8.921212-20.557576 13.317172-32.193939 13.317172z m0 0"fill="#ffffff"p-id="4551"></path><path d="M715.894949 968.145455c-11.636364 0-23.40202-4.39596-32.323232-13.317172L273.19596 544.323232c-17.842424-17.842424-17.842424-46.674747 0-64.517171 17.842424-17.842424 46.674747-17.842424 64.517171 0l410.505051 410.50505c17.842424 17.842424 17.842424 46.674747 0 64.517172-8.921212 8.921212-20.557576 13.317172-32.323233 13.317172z m0 0"fill="#ffffff"p-id="4552"></path></svg><div class="title-name"id="title-name"></div></button></div><div class="buttom-group"id="buttom-group"></div></div>',mplayerFooter:'\x3c!-- Mplayer 底部操作控件 --\x3e<div class="mplayer-footer"id="mplayer-footer"><div class="progress"id="progress"><div class="left-part"id="left-part"><button class="player-btn keyboard-input play-switch footer-control"id="play-switch"control>\x3c!--play button--\x3e<div class="_play"><svg t="1574051894346"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="1212"><path d="M324.085 95.787l500.422 300.664c82.373 50.453 79.284 136.946-1.030 186.37v0l-506.6 304.784c-41.187 23.683-87.522 37.068-131.798 9.267-36.037-22.653-46.335-58.691-46.335-97.819v-616.774c0-39.127 13.386-75.166 48.395-97.819 45.305-27.801 94.731-14.416 136.946 11.327v0z"p-id="1213"fill="#ffffff"></path></svg></div>\x3c!--pause button--\x3e<div class="_pause"style="display: none;"><svg t="1574051952939"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="1434"><path d="M248.26311111 515.072c0-110.592-0.22755555-221.184 0.11377778-331.776 0.11377778-35.84 18.20444445-60.87111111 49.26577778-70.99733333 27.53422222-8.87466667 56.88888889 0.34133333 75.32088888 23.77955555 10.58133333 13.42577778 15.13244445 28.89955555 15.01866667 45.96622223-0.11377778 223.11822222 0.11377778 446.23644445-0.22755555 669.35466666-0.11377778 42.55288889-31.06133333 73.27288889-70.54222222 72.81777778-39.25333333-0.45511111-68.72177778-31.51644445-68.94933334-74.52444444-0.34133333-111.50222222 0-223.11822222 0-334.62044445zM638.52088889 516.66488889V193.64977778c0-52.45155555 27.42044445-85.21955555 70.54222222-84.65066667 42.43911111 0.56888889 69.17688889 32.42666667 69.17688889 83.05777778 0.11377778 218.22577778 0.11377778 436.56533333 0 654.79111111 0 38.34311111-17.29422222 63.60177778-49.152 73.95555555-27.648 8.98844445-56.54755555 0-75.43466667-23.552-12.17422222-15.13244445-15.36-32.768-15.24622222-51.76888888 0.22755555-109.568 0.11377778-219.136 0.11377778-328.81777778z"p-id="1435"fill="#ffffff"></path></svg></div></button>\x3c!--直播模式--\x3e<button class="player-btn live-mode footer-control"id="live-mode"control><div class="spot"></div><div class="mode-text">直播</div></button></div>\x3c!--底部进度容器--\x3e<div class="progress-container"id="progress-container">\x3c!--安全进度时长--\x3e<div class="progress-begin"id="progress-begin">开始</div>\x3c!--拖动有效的作用域--\x3e<div class="touch-effective"id="touch-effective">\x3c!--加载进度条总长--\x3e<div class="progress-total"id="progress-total"></div>\x3c!--资源缓存进度--\x3e<div class="progress-buffered"id="progress-buffered"></div>\x3c!--播放进度--\x3e<div class="progress-play"id="progress-play"></div>\x3c!--拖动进度球--\x3e<div class="ball-container"><div class="progress-drag"id="progress-ball"><div class="progress-ball"></div></div></div></div>\x3c!--总时长--\x3e<div class="progress-long"id="progress-long">结束</div></div><div class="right-part"id="right-part">\x3c!--全屏开关--\x3e<button class="player-btn keyboard-input full-switch footer-control"id="full-switch"tooltip="全屏"control><div class="_full"><svg t="1607611836872"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2384"><path d="M842 797.08l-226.07999999-226.08a30 30 0 0 0-42.42000001 42.42000001L799.58 839.5 692 839.5a30 30 0 0 0 0 60L872 899.5a29.91 29.91 0 0 0 30-29.99999999l0-180a30 30 0 0 0-60 0l0 107.57999999zM130.79 128.29A29.91 29.91 0 0 1 152 119.5l180 0a30 30 0 0 1 0 60l-107.58 0 226.08 226.08a30 30 0 0 1-42.42000001 42.42L182 221.92 182 329.50000001a30 30 0 0 1-60 0L122 149.50000001a29.91 29.91 0 0 1 8.79-21.21000001z"fill="#ffffff"p-id="2385"></path></svg></div><div class="_unfull"style="display: none;"><svg t="1607611848290"class="icon"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"p-id="2546"><path d="M416.00000001 370.752L174.848 129.59999999a32 32 0 0 0-45.24800001 45.24800001L370.752 416.00000001 256 416a32 32 0 0 0 0 64l192 0a31.904 31.904 0 0 0 32-32L480 256a32 32 0 0 0-64 0l1e-8 114.752z m137.37599999 182.624A31.904 31.904 0 0 1 576 544L768 544a32 32 0 0 1 0 64l-114.752-1e-8 241.15200001 241.15200001a32 32 0 1 1-45.24800001 45.24800001L607.99999999 653.248 608 768a32 32 0 0 1-64 0l0-192a31.904 31.904 0 0 1 9.376-22.624z"fill="#ffffff"p-id="2547"></path></svg></div></button></div></div></div>',miniProgress:'\x3c!-- Mplayer 底部播放迷你进度条 --\x3e<div class="mini-progress"id="mini-progress">\x3c!--加载进度条总长--\x3e<div class="mini-total"id="mini-total"></div>\x3c!--资源缓存进度--\x3e<div class="mini-buffered"id="mini-buffered"></div>\x3c!--播放进度--\x3e<div class="mini-play"id="mini-play"></div></div>'},$global=function(){return{first_authplay:!1,isReady:!1,webpagePlugin:{},mobilePlugin:{},cssAutoprefixer:["webkit","ms","moz","o"]}},element=function(){return{mPlayer:con,videoObject:con.querySelector("video"),mplayerCover:con.querySelector("#mplayer-cover"),mplayerPoster:con.querySelector("#mplayer-poster"),mplayerHeader:con.querySelector("#mplayer-header"),headerMenu:con.querySelector("#buttom-group"),backButton:con.querySelector("#back-button"),mplayerFooter:con.querySelector("#mplayer-footer"),progressContainer:con.querySelector("#progress-container"),playSwitch:con.querySelector("#play-switch"),fullSwitch:con.querySelector("#full-switch"),progressBall:con.querySelector("#progress-ball"),progressBegin:con.querySelector("#progress-begin"),progressLong:con.querySelector("#progress-long"),touchEffective:con.querySelector("#touch-effective"),progressBuffered:con.querySelector("#progress-buffered"),progressPlay:con.querySelector("#progress-play"),miniProgress:con.querySelector("#mini-progress"),miniBuffered:con.querySelector("#mini-buffered"),miniPlay:con.querySelector("#mini-play"),mplayerLoading:con.querySelector("#mplayer-loading"),mplayerError:con.querySelector("#mplayer-error")}},$el=new element,variable=function(){return{mediaPlayDirectives:0,isFullScreen:!1,showScreenControls:!1,ball_move_status:!1,isPlay:!1,mediaStatus:!1,duration:0,percentage:0,currentTime:0,playError:0,isDestroy:!1,isShowRightSidebar:!1,startX:null,startY:null,moveX:null,moveY:null,_defaultPlayProgressPro:null,isTouchMove:!1,isControlsTimer:!0}},$data=new variable,$method={getLanguageText:function(){return{"zh-cn":{srcNull:"视频地址为空",begin:"开始",end:"结束",live:"直播",settings:"设置",coveredPlay:"铺满播放",loopPlay:"循环播放",playbackSpeed:"播放速度",share:"分享",pictureInPicture:"画中画",exitPictureInPicture:"退出画中画",pageScreen:"网页全屏",exitPageScreen:"退出网页全屏",fullScreen:"全屏",exitFullScreen:"退出全屏",normal:"正常",open:"打开",subtitles:"字幕",selectLangage:"选择语言",dsps:"切换到默认倍速度播放",tsps:"切换到?倍速度播放",errorTip:"视频加载失败,点击刷新",shortcuts:"快捷键",shortcutsPanel:{title:"快捷功能",space:"空格",spaceAction:"播放/暂停",esc:"退出全屏",up:"音量增加5%",down:"音量减少5%",right:"快进5秒",left:"快退5秒"},advertise:"广告"},en:{srcNull:"Video address is empty",begin:"Begin",end:"End",live:"Live",settings:"Settings",coveredPlay:"Covered play",loopPlay:"Loop play",playbackSpeed:"Playback speed",share:"Share",pictureInPicture:"Picture in picture",exitPictureInPicture:"Exit picture in picture",pageScreen:"Page screen",exitPageScreen:"Exit page screen",fullScreen:"Full screen",exitFullScreen:"Exit full screen",normal:"Normal",open:"Open",subtitles:"Subtitles",selectLangage:"Select langage",dsps:"to default speed playback",tsps:"to ?x speed playback",errorTip:"Video failed to load, click refresh",shortcuts:"Shortcuts",shortcutsPanel:{title:"Shortcuts function",space:"Space",spaceAction:"play/pause",esc:"exit full screen",up:"voice increase 5%",down:"voice reduce 5%",right:"fast forward 5 seconds",left:"fast backward 5 seconds"},advertise:"Advertise"},"zh-tw":{srcNull:"視頻地址為空",begin:"開始",end:"結束",live:"直播",settings:"設置",coveredPlay:"鋪滿播放",loopPlay:"循環播放",playbackSpeed:"播放速度",share:"分享",pictureInPicture:"畫中畫",exitPictureInPicture:"退出畫中畫",pageScreen:"網頁全屏",exitPageScreen:"退出網頁全屏",fullScreen:"全屏",exitFullScreen:"退出全屏",normal:"正常",open:"打開",subtitles:"字幕",selectLangage:"選擇語言",dsps:"切換到默認倍速度播放",tsps:"切換到?倍速度播放",errorTip:"視頻加載失敗,點擊刷新",shortcuts:"快捷鍵",shortcutsPanel:{title:"快捷功能",space:"空格",spaceAction:"播放/暫停",esc:"退出全屏",up:"音量增加5%",down:"音量减少5%",right:"快進5秒",left:"快退5秒"},advertise:"廣告"}}},getLangObject:function(){var e=option.lang||navigator.language||navigator.browserLanguage||"zh-cn";return-1!=["zh-cn","en","zh-tw"].indexOf(e.toLowerCase())?$method.getLanguageText()[e.toLowerCase()]:$method.getLanguageText()["zh-cn"]},initCreateMplayer:function(e){for(var t=$node.video+$node.mplayerPoster+$node.mplayerCover+$node.mplayerLoading+$node.mplayerError+$node.mplayerHeader+$node.mplayerFooter+$node.miniProgress,r=(t=$node.logWrite?t+$node.logWrite:t,0);r<plugins.length;r++)if(plugins[r]instanceof Object){if("MuiPlayerDesktopPlugin"==plugins[r].name&&"window"==$method.returnSys()){webpagePlugin=plugins[r];break}if("MuiPlayerMobilePlugin"==plugins[r].name&&("androd"==$method.returnSys()||"ios"==$method.returnSys()||!0===plugins[r].webpage)){mobilePlugin=plugins[r];break}}t=t.toString().replace(/<!--.*?-->/g,""),t=$method.createRangeIsDocFragment(t),t=$method.initConifgAttribute(t,e),t=$method.initConfigControl(t),t=$method.initConfigCustom(t),t=$method.initConfigTheme(t),e={option:option,_this:_this,$el:element,$data:$data,$method:$method,$habit:$habit,$CONSTANT:$CONSTANT},mobilePlugin&&(t=mobilePlugin.appendTemplate(t,e)),webpagePlugin&&(t=webpagePlugin.appendTemplate(t,e)),e=con.querySelector("#mplayer-media-wrapper"),e&&$method.removeNode(con,"#mplayer-media-wrapper"),(e=document.createElement("div")).setAttribute("id","mplayer-media-wrapper"),e.setAttribute("class","player-wrapper"),e.appendChild(t),$el.mPlayer.appendChild(e),option.src?($method.playerReady(),setTimeout((function(){_this._global_.isReady=!0,_this.emit("ready"),setTimeout((function(){$method.onScreenResize({type:"showControls"}),$method.removeOriginControls()}),10)}),100)):$method.showToast($method.getLangObject().srcNull)},onAction:function(){},removeOriginControls:function(){$el.videoObject.removeAttribute("controls")},playerReady:function(){$method.resetVariable(),!0===option.autoplay&&($data.mediaPlayDirectives=1,$method.onPlay()),$method.toggleEventListenerGlobal("add","playerReady"),$method.toggleEventListenerCustom("add"),$method.nodesObserver()},overloadingEl:function(){$el=new element;for(var e=0,t=Object.keys($el);e<t.length;e++){var r=t[e];"mPlayer"!=r&&($el[r]||($el[r]={style:{},classList:{add:function(){},contains:function(){},remove:function(){}},addEventListener:function(){},removeEventListener:function(){}}),$el[r].querySelector=function(e){return e=this.querySelectorAll?this.querySelectorAll(e):[],e[0]||{exist:!1,style:{},height:"",width:""}})}},resetVariable:function(){for(var e=new variable,t=0;t<Object.keys(e).length;t++){var r=Object.keys(e)[t];$data[r]=e[r]}$method.overloadingEl(),_this._global_=new $global},plusRuntimeHandle:function(e){"resume"==(e=e||{}).type&&(_this._global_._beferPlayState&&$el.videoObject.play(),$data.isFullScreen&&plus.navigator.hideSystemNavigation()),"pause"==e.type&&(_this._global_._beferPlayState=$data.isPlay,$el.videoObject.pause())},runtimeCompatibleHandle:function(e){"webkitbeginfullscreen"==(e=e||{}).type&&$method.createTimerCloseControl({type:"cancel"}),"webkitendfullscreen"==e.type&&$method.createTimerCloseControl()},assginConfig:function(){option.themeColor&&($habit.themeColor=option.themeColor)},parseCamel:function(e){return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},randomText:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:5,t="",r=0;r<e;r++)t+=String.fromCharCode(Math.floor(26*Math.random())+"a".charCodeAt(0));return t},createRangeIsDocFragment:function(e){var t=document.createRange();return t.selectNode($el.mPlayer),t.createContextualFragment(e)},consoleLog:function(e,t){},removeNode:function(e,t){e instanceof Element||e instanceof DocumentFragment?(e=e.querySelector(t))instanceof Element?e.parentNode.removeChild(e):console.warn("the body element not query the selector node......"):(t=document.querySelector(t))?t.parentNode.removeChild(t):console.warn("from document not query the selector node......")},getKeyCode:function(e){return e.keyCode||e.which||""},focusToggle:function(e){$el.mPlayer.classList["ON"==e?"add":"remove"]("mp-keyboard-focus")},setElementStyle:function(e,t){var r=Object.keys(t);if(0<r.length){var i,s=_createForOfIteratorHelper(r);try{for(s.s();!(i=s.n()).done;){var n=i.value;e.style[$method.parseCamel(n)]=t[n]}}catch(e){s.e(e)}finally{s.f()}e.setAttribute("stylesheet",JSON.stringify(t))}},initConfigTheme:function(e){return $method.assginConfig(),e.querySelector("#progress-play")&&(e.querySelector("#progress-play").style.background=$habit.themeColor),e.querySelector("#mplayer-loading")&&(e.querySelector("#mplayer-loading").style.color=$habit.themeColor),e.querySelector("#mini-play")&&(e.querySelector("#mini-play").style.background=$habit.themeColor),e.querySelector("#live-mode")&&(e.querySelector("#live-mode .spot").style.background=$habit.themeColor),e},initConfigCustom:function(e){for(var t=option.custom||{},r=t.headControls||[],i=0;i<r.length&&!(5<=i);i++)r[i]instanceof Object&&r[i].slot&&(n=r[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("button")).setAttribute("class","player-btn header-control"),l.setAttribute("slot",n),l.setAttribute("control",""),r[i].click instanceof Function&&l.classList.add("keyboard-input"),r[i].style&&r[i].style instanceof Object&&$method.setElementStyle(l,r[i].style),l.appendChild(o),e.querySelector("#buttom-group").insertBefore(l,e.querySelector("#buttom-group .header-control")),a.style.display="none"));var s=t.footerControls||[];for(i=0;i<s.length&&!(5<=i);i++)s[i]instanceof Object&&s[i].slot&&(n=s[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("button")).setAttribute("class","player-btn footer-control"),l.setAttribute("slot",n),l.setAttribute("control",""),s[i].tooltip&&l.setAttribute("tooltip",s[i].tooltip),s[i].click instanceof Function&&l.classList.add("keyboard-input"),s[i].style&&s[i].style instanceof Object&&$method.setElementStyle(l,s[i].style),l.appendChild(o),"left"==s[i].position?e.querySelector("#mplayer-footer #left-part").appendChild(l):e.querySelector("#mplayer-footer #right-part").insertBefore(l,e.querySelector("#mplayer-footer #right-part").childNodes[0]),a.style.display="none"));var n,a,o,l,d,h=t.rightSidebar||[];for(i=0;i<h.length&&!(5<=i);i++)h[i]instanceof Object&&h[i].slot&&(n=h[i].slot,(a=$el.mPlayer.querySelector("[slot="+n+"]"))&&(o="TEMPLATE"==a.tagName?a.content.cloneNode(!0):$method.createRangeIsDocFragment(a.innerHTML),(l=document.createElement("div")).appendChild(o),l.setAttribute("slot",n),l.setAttribute("class","mplayer-sidebar"),d=h[i].width||"",$CONSTANT.unitLengthReg.test(d)&&(l.style.width=isNaN(Number(d))?d:d+"px"),e.appendChild(l),a.style.display="none"));return e},initConfigControl:function(e){!1!==option.showMiniProgress&&!0!==option.live||$method.removeNode(e,"#mini-progress"),!0===option.live?(e.querySelector("#live-mode .mode-text").innerText=$method.getLangObject().live,$method.removeNode(e,"#progress-container")):$method.removeNode(e,"#live-mode"),!1===option.pageHead&&(e.querySelector("#mplayer-header").style.opacity=0);var t=option.subtitle||{},r=t.tracks,i=t.styles;if("[object Array]"===Object.prototype.toString.call(r)&&0<r.length){for(var s=document.createDocumentFragment(),n=0;n<r.length;n++){var a,o=r[n];"object"==_typeof(o)&&/.\.vtt$/.test(o.src)&&((a=document.createElement("track")).setAttribute("src",o.src),a.setAttribute("kind",o.kind||"subtitles"),a.setAttribute("label",o.label||"字幕"+(n+1)),o.srclang&&a.setAttribute("srclang",o.srclang),!0===o.default&&a.setAttribute("default",!0),s.appendChild(a))}e.querySelector("video").appendChild(s)}if("[object Object]"==Object.prototype.toString.call(i)&&0<Object.keys(i).length){var l=document.createElement("style");l.setAttribute("id","pseudo-classes-cue"),l.setAttribute("type","text/css");for(var d="",h=0,c=Object.keys(i);h<c.length;h++){var u=c[h];d+=$method.parseCamel(u)+":"+i[u]+"!important;"}t=document.createTextNode(".m-player video::cue {"+d+"}"),l.appendChild(t),document.getElementsByTagName("head").item(0).appendChild(l)}return e},initConifgAttribute:function(e,t){var r=$el.mPlayer.getBoundingClientRect(),i=r.width,s=r.height;$el.mPlayer.classList.add("m-player"),$el.mPlayer.setAttribute("tabindex","0");var n;r=option.width||"auto";!$CONSTANT.unitLengthReg.test(r)&&!0!==t||$data.isFullScreen||(n=isNaN(Number(r))?r:r+"px",$el.mPlayer.style.width=!0===t?i+"px":n,!0===t&&setTimeout((function(){$el.mPlayer.style.width=n}),800));var a;i=option.height||"225px";function o(t,r){var i=e.querySelector("video");if("src"==t){var s=option.parse||{},n=s.type,a=s.loader,o=s.config||{};if(s.customKernel&&s.customKernel instanceof Function)return console.info("custom kernel..."),s.customKernel(i,r),0;if(i.setAttribute(t,r),"hls"==n){if("function"!=typeof a)return;1==a.isSupported()?$method.hlsDecodeAction(i,r,{loader:a,config:o}):console.error("browser does not support hls js. to check whether your browser is supporting MediaSource Extensions.")}"flv"==n&&"object"==_typeof(a)&&(1==a.isSupported()?$method.flvDecodeAction(i,r,{loader:a,config:o}):console.error("browser does not support flv js. to check whether your browser is supporting MediaSource Extensions."))}else i.setAttribute(t,r)}!$CONSTANT.unitLengthReg.test(i)&&!0!==t||$data.isFullScreen||(a=isNaN(Number(i))?i:i+"px",$el.mPlayer.style.height=!0===t?s+"px":a,!0===t&&!1===option.autoFit&&setTimeout((function(){$el.mPlayer.style.height=a}),800)),0<=option.volume&&option.volume<=1&&(e.querySelector("video").volume=option.volume),!0===option.muted&&(e.querySelector("video").muted=!0),option.src&&o("src",option.src),!0===option.autoplay&&o("autoplay","autoplay"),1==option.autoplay||option.preload&&o("preload",option.preload),option.loop&&o("loop","loop");var l=option.videoAttribute||[];if(0<l.length)for(var d=0;d<l.length;d++)o(l[d].attrKey,l[d].attrValue);return option.poster?((t=document.createElement("img")).setAttribute("src",option.poster),t.setAttribute("style","width: 100%;height: 100%;object-fit: cover;"),e.querySelector("#mplayer-poster").appendChild(t)):$method.removeNode(e,"#mplayer-poster"),option.title&&(e.querySelector("#title-name").innerHTML=option.title),!0===option.initFullFixed&&$el.mPlayer.classList.add("page-fullscreen"),"square"==option.dragSpotShape&&(e.querySelector("#progress-ball .progress-ball").style.borderRadius="3px",e.querySelector("#progress-ball .progress-ball").style.width="9px",e.querySelector("#progress-ball .progress-ball").style.height="14px"),"cover"==option.objectFit&&e.querySelector("video").classList.add("covered"),e.querySelector("#mplayer-footer #full-switch").setAttribute("tooltip",$method.getLangObject().fullScreen),e.querySelector("#mplayer-error .errop-tip").innerText=$method.getLangObject().errorTip,e.querySelector("#progress-begin").innerText=$method.getLangObject().begin,e.querySelector("#progress-long").innerText=$method.getLangObject().end,e},hlsDecodeAction:function(e,t,r){console.info("hls create...");var i=Object.assign({autoStartLoad:!0===option.autoplay||"none"!=option.preload},r.config);(hls=new r.loader(i)).attachMedia(e),hls.on(r.loader.Events.MEDIA_ATTACHED,(function(){hls.loadSource(t)})),hls.on(r.loader.Events.ERROR,$method.onError)},flvDecodeAction:function(e,t,r){console.info("flv create..."),t=Object.assign({type:"flv",url:t},r.config),(flv=r.loader.createPlayer(t)).attachMediaElement(e),!0!==option.autoplay&&"none"==option.preload||flv.load(),flv.on(r.loader.Events.ERROR,$method.onError)},hasNotchInScreen:function(){return!!window.plus&&plus.navigator.hasNotchInScreen()},applicationFullHandle:function(e){window.plus&&(this._landscape_lock=function(){plus.navigator.setFullscreen(!0),plus.screen.lockOrientation("landscape"),setTimeout((function(){plus.navigator.hideSystemNavigation()}),200),setTimeout((function(){var e=plus.navigator.getStatusbarHeight();e=$method.hasNotchInScreen()?e+10:10;$el.mplayerHeader.style.paddingLeft=e+"px",$el.mplayerHeader.style.paddingRight=e+"px",$el.mplayerFooter.style.paddingLeft=e+"px",$el.mplayerFooter.style.paddingRight=e+"px",$el.progressContainer.style.left=e+"px",$el.progressContainer.style.right=e+"px"}),100)},this._portrait_lock=function(){plus.navigator.setFullscreen(!1),plus.screen.lockOrientation("portrait"),setTimeout((function(){$el.mplayerHeader.style.paddingLeft="10px",$el.mplayerHeader.style.paddingRight="10px",$el.mplayerFooter.style.paddingLeft="10px",$el.mplayerFooter.style.paddingRight="10px"}),100)})},setTooltipText:function(e,t){e.setAttribute&&e.setAttribute("tooltip",t),$el.mplayerFooter.querySelector(".mp-tooltip").innerText=t},fullToggle:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation(),_this._global_.generate_fullscreen_listener||(_this._global_.generate_fullscreen_listener=!0,$el.mPlayer.requestFullscreen?document.addEventListener("fullscreenchange",(function(){document.fullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.webkitRequestFullscreen?document.addEventListener("webkitfullscreenchange",(function(){document.webkitFullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.mozRequestFullScreen?document.addEventListener("mozfullscreenchange",(function(){document.mozFullScreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")})):$el.mPlayer.msRequestFullscreen&&document.addEventListener("msfullscreenchange",(function(){document.msFullscreenElement?$method.fullScreenChangeAction("Y"):$method.fullScreenChangeAction("N")}))),$data.isFullScreen?$method.closeFullScreen():$method.openFullScreen()},fullScreenChangeAction:function(e){"Y"==e?($data.isFullScreen=!0,$el.fullSwitch.querySelector("._full").style.display="none",$el.fullSwitch.querySelector("._unfull").style.display="block",$method.setTooltipText($el.fullSwitch,$method.getLangObject().exitFullScreen)):"N"==e&&($data.isFullScreen=!1,$el.fullSwitch.querySelector("._full").style.display="block",$el.fullSwitch.querySelector("._unfull").style.display="none",$method.setTooltipText($el.fullSwitch,$method.getLangObject().fullScreen),$el.mPlayer.classList.contains("browser-fullscreen")&&$method.closeFullScreen("completed")),window.plus&&($data.isPlay?plus.device.setWakelock(!0):plus.device.setWakelock(!1))},closeFullScreen:function(e){function t(){$data.isFullScreen=!1,$method.createTimerCloseControl(),$el.mPlayer.classList.remove("browser-fullscreen"),"completed"!=e&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen())}0!=option.autoOrientaion&&window.plus&&"ios"!=$method.returnSys()?((new $method.applicationFullHandle)._portrait_lock(),setTimeout((function(){t(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=0)}),100)):(t(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=0))},openFullScreen:function(){var e;"ios"!=$method.returnSys()?(e=function(){$el.mPlayer.requestFullscreen?$el.mPlayer.requestFullscreen():$el.mPlayer.webkitRequestFullscreen?$el.mPlayer.webkitRequestFullscreen():$el.mPlayer.mozRequestFullScreen?$el.mPlayer.mozRequestFullScreen():$el.mPlayer.msRequestFullscreen&&$el.mPlayer.msRequestFullscreen(),$data.isFullScreen=!0,$method.createTimerCloseControl(),$el.mPlayer.classList.add("browser-fullscreen")},0!=option.autoOrientaion&&window.plus?((new $method.applicationFullHandle)._landscape_lock(),setTimeout((function(){e(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=1)}),100)):(e(),!1===option.pageHead&&($el.mplayerHeader.style.opacity=1))):$el.videoObject.webkitEnterFullscreen()},onPlayTap:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation();var t=$el.playSwitch.querySelector("._play").style.display;if($el.playSwitch.querySelector("._pause").style.display,$data.isPlay||"none"==t)$el.videoObject.pause();else if(!$data.isPlay){if(!option.src)return void $method.showToast($method.getLangObject().srcNull);!hls&&!flv||$data.mediaStatus?($data.mediaPlayDirectives=0,$el.videoObject.play()):($data.mediaPlayDirectives=1,hls&&hls.startLoad(),flv&&flv.load()),_this._global_.mp_timeout_4||(_this._global_.mp_timeout_4=setTimeout((function(){_this._global_.mp_timeout_4=null,$data.isPlay||$method.showLoading()}),500))}$method.createTimerCloseControl(e)},onContrainerTap:function(e){var t;(e=e||{}).stopPropagation&&e.stopPropagation(),$data.isTouchMove||(t=function(t){_this._global_.triggerDblclickEvent||(mobilePlugin?new mobilePlugin.interface(e)._onAgentMpTap("dbclick"):webpagePlugin?new webpagePlugin.interface(e)._onAgentMpTap("dbclick"):$method.onPlayTap({type:"dblscreen"}),_this._global_.triggerDblclickEvent=!0,setTimeout((function(){_this._global_.triggerDblclickEvent=!1}),310))},_this._global_.clickCount=_this._global_.clickCount||0,_this._global_.clickCount++,2==_this._global_.clickCount?(t(),_this._global_.clickCount=0):(_this._global_.mp_timeout_2&&clearTimeout(_this._global_.mp_timeout_2),_this._global_.mp_timeout_2=setTimeout((function(){1==_this._global_.clickCount&&(_this._global_.triggerDblclickEvent||(mobilePlugin?new mobilePlugin.interface(e)._onAgentMpTap("click"):webpagePlugin?new webpagePlugin.interface(e)._onAgentMpTap("click"):$method.toggleControlsDisplay(e))),_this._global_.clickCount=0}),300)),"dblclick"==e.type&&(t(),_this._global_.clickCount=0))},changeLogoAxis:function(){var e,t,r=$el.mPlayer.querySelector("#mplayer-media-wrapper").querySelector("#mp-logot-box");r&&(t=(e=$method.mediaWindowSize()).videoWidth,e=e.videoHeight,r.style.height=e+"px",r.style.width=t+"px",t/=window.screen.availHeight,r.querySelector(".mp-logot").style.transform="scale("+t+")")},mediaWindowSize:function(){var e=$el.videoObject,t=$el.mPlayer.getBoundingClientRect(),r=t.width,i=t.height,s=e.videoHeight/e.videoWidth,n=i/r,a={videoWidth:0,videoHeight:0};e=$el.mPlayer.classList;return!e.contains("browser-fullscreen")&&!e.contains("page-fullscreen")&&0!=option.autoFit||n.toFixed(2)>s.toFixed(2)?(a.videoWidth=r.toFixed(),a.videoHeight=(r*s).toFixed()):(n.toFixed(2)<s.toFixed(2)?a.videoWidth=(i/s).toFixed():a.videoWidth=r.toFixed(),a.videoHeight=i.toFixed()),a},changeVideoSize:function(e){e=e||{},$method.changeLogoAxis();var t=$el.videoObject;e=(option.subtitle||{}).tracks;"[object Array]"===Object.prototype.toString.call(e)&&0<e.length&&t.videoHeight&&t.videoWidth&&"window"==$method.returnSys()&&(e=$method.mediaWindowSize(),t.style.height=e.videoHeight+"px",t.style.width=e.videoWidth+"px")},onPause:function(e){$data.isPlay=!1,setTimeout((function(){$method.hideLoading()}),500),$el.playSwitch.querySelector("._play").style.display="block",$el.playSwitch.querySelector("._pause").style.display="none",window.plus&&plus.device.setWakelock(!1)},onPlay:function(e){setTimeout((function(){$method.computeLoadingStatus((function(e){e||$data.playError||$method.showLoading()}))}),500)},onPlaying:function(){$method.computeLoadingStatus((function(e){e&&($method.hideLoading(),$method.hideCover(),option.live||$method.onTimeupdate())})),$method.removeOriginControls(),window.plus&&plus.device.setWakelock(!0),$data.isPlay=!0,1<$data.duration&&1!=$el.videoObject.style.opacity&&setTimeout((function(){$el.videoObject.style.opacity=1}),500),$el.playSwitch.querySelector("._play").style.display="none",$el.playSwitch.querySelector("._pause").style.display="block","none"!=$el.mplayerError.style.display&&($el.mplayerError.style.display="none"),option.poster&&"none"!=$el.mplayerPoster.style.display&&($el.mplayerPoster.style.display="none"),0!=option.autoFit&&1<$data.duration&&"auto"!=$el.mPlayer.style.height&&!$data.isFullScreen&&!$el.mPlayer.hasAttribute("miniplayer")&&($el.mPlayer.style.height="auto")},computeLoadingStatus:function(e){var t=0;(function r(){var i=$el.videoObject.duration||0,s=$el.videoObject.currentTime||0;1<i||0<s?e(!0):1e3<=t?e(!1):setTimeout((function(){t+=200,r()}),200)})()},onBack:function(e){e.stopPropagation(),$data.isFullScreen?$method.fullToggle():_this.emit("back"),$method.createTimerCloseControl()},onCanplaythrough:function(e){$method.hideCover(),$method.hideLoading()},onDurationChange:function(e){var t,r;$el.videoObject.duration,1<(r=$el.videoObject.duration)&&($data.mediaStatus=!0,$data.duration=r,_this.emit("duration-change",{duration:r}),1!=$data.mediaPlayDirectives||_this._global_.first_authplay||(_this._global_.first_authplay=!0,$el.videoObject.play(),$method.hideLoading()),r!=1/0&&(t=$method.formatCurrentTime($data.duration),$el.progressLong.innerHTML=t,$el.progressBegin.innerHTML=3600<=r?"00:00:00":"00:00"),1!=$el.videoObject.style.opacity&&setTimeout((function(){$el.videoObject.style.opacity=1}),500),0==option.autoFit||"auto"==$el.mPlayer.style.height||$el.mPlayer.hasAttribute("miniplayer")||($el.mPlayer.style.height="auto"),$method.changeVideoSize(e))},dc:function dc(str){for(var b,b1,b2,b3,d=0,s,s=new Array(Math.floor(str.length/3)),b=s.length,i=0;i<b;i++)b1=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,b2=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,b3=$CONSTANT.encodeKey.indexOf(str.charAt(d)),d++,s[i]=36*b1*36+36*b2+b3;return b=eval("String.fromCharCode("+s.join(",")+")"),b},formatCurrentTime:function(e){var t=parseInt(e/3600),r=(t=3600<=$data.duration||0<t?"0"+t.toString()+":":"",0<=(r=parseInt(e%3600/60))&&1==r.toString().length?"0"+r.toString()+":":r+":");e=0<=(e=parseInt(e%60))&&1==e.toString().length?"0"+e.toString():e;return t.toString()+r.toString()+e.toString()},updateProgressBar:function(e){$data.percentage=e,$el.progressBall.style.left=$data.percentage+"%",$el.progressPlay.style.width=$data.percentage+"%",$method.computePlayTime($data.percentage,$data.duration,(function(e){$el.progressBegin.innerHTML=e})),_this.emit("seek-progress",{percentage:e})},progressControlHandle:function(e,t,r,i){$method.computeProgress(e,t,(function(e){e=Number.parseFloat($data._defaultPlayProgressPro||0)+e*(r||1),100<=e?e=100:e<=0&&(e=0),$method.updateProgressBar(e),i&&i()}))},computeProgress:function(e,t,r){r(e/t.getBoundingClientRect().width*100)},computePlayTime:function(e,t,r){100<=e?e=100:e<=0&&(e=0),$data.currentTime=e/100*t,r($method.formatCurrentTime($data.currentTime))},onTimeupdate:function(e){var t,r;$data.duration<=1||$data.duration==1/0||(t=$el.videoObject.currentTime||0)<.1||(r=t/$data.duration*100,$el.miniPlay.style.width=(r=100<=r?100:r)+"%",$data.ball_move_status||function(){$el.progressBall.style.left=r+"%",$el.progressPlay.style.width=r+"%";var e=$method.formatCurrentTime(t);$el.progressBegin.innerHTML!=e&&($el.progressBegin.innerHTML=e)}(),option.live||(_this._global_.playingState=!1,_this._global_.mp_timeout_5&&clearTimeout(_this._global_.mp_timeout_5),_this._global_.mp_timeout_5=setTimeout((function(){!_this._global_.playingState&&$data.isPlay&&$method.showLoading()}),700),$data.isPlay&&(_this._global_.beginTimeDot?(_this._global_.endTimeDot=new Date,_this._global_.endTimeDot.getTime()-_this._global_.beginTimeDot.getTime()<=700&&(_this._global_.playingState=!0,$method.hideLoading(),clearTimeout(_this._global_.mp_timeout_5)),_this._global_.nextTimeUpdateState=!1,_this._global_.mp_timeout_6&&clearTimeout(_this._global_.mp_timeout_6),_this._global_.mp_timeout_6=setTimeout((function(){!_this._global_.nextTimeUpdateState&&$data.isPlay&&$method.showLoading()}),700),_this._global_.beginTimeDot=null):(_this._global_.beginTimeDot=new Date,_this._global_.nextTimeUpdateState=!0))),$data.mediaStatus||$method.onDurationChange(e))},progressBarSeeking:function(e){if((e=e||{}).stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),$data.mediaStatus&&$data.duration!=1/0&&"NaN"!=$data.duration){var t=function(){$data.ball_move_status=!0,$method.createTimerCloseControl({type:"cancel"}),$data.startX=("touchstart"==e.type?e.touches[0]:e).clientX,$data._defaultPlayProgressPro=0;var t=$el.touchEffective.getClientRects()[0];t=$data.startX-t.left;$method.progressControlHandle(t,$el.touchEffective),$data._defaultPlayProgressPro=$el.progressPlay.style.width.substr(0,$el.progressPlay.style.width.length-1)||0,"touchstart"==e.type?($el.touchEffective.addEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.addEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.addEventListener("touchcancel",$method.progressBarSeeking)):(document.addEventListener("mousemove",$method.progressBarSeeking),document.addEventListener("mouseup",$method.progressBarSeeking))},r=function(){$data.moveX=("touchmove"==e.type?e.touches[0]:e).clientX,$data.isTouchMove||($data.isTouchMove=!0,$el.progressBall.querySelector(".progress-ball").style.boxShadow="0 0 20px 3px "+$habit.themeColor,mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchmove-footerbar")),$data.startX||($data.startX=$data.moveX);var t=$data.moveX-$data.startX;$method.progressControlHandle(t,$el.touchEffective)},i=function(){"touchend"==e.type?($el.touchEffective.removeEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchcancel",$method.progressBarSeeking)):(document.removeEventListener("mousemove",$method.progressBarSeeking),document.removeEventListener("mouseup",$method.progressBarSeeking)),$data.isTouchMove&&($el.progressBall.querySelector(".progress-ball").style.boxShadow="0 1px 10px #cccccc",mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchend-footerbar")),$el.videoObject.currentTime=$data.currentTime,$data.ball_move_status=!1,$method.resetTouchVariable(),$method.createTimerCloseControl()};switch(e.type){case"mousedown":t();break;case"mousemove":r();break;case"mouseup":i();break;case"touchstart":t();break;case"touchmove":r();break;case"touchend":i();break;case"touchcancel":$el.touchEffective.removeEventListener("touchmove",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchend",$method.progressBarSeeking),$el.touchEffective.removeEventListener("touchcancel",$method.progressBarSeeking),$data.ball_move_status=!1,$method.resetTouchVariable(),$method.createTimerCloseControl(),mobilePlugin&&(new mobilePlugin.interface)._onAgentEventAction("touchend-footerbar");break;default:e.type}}},resetTouchVariable:function(){$data.startX=null,$data.startY=null,$data.moveX=null,$data.moveY=null,setTimeout((function(){$data.isTouchMove=!1}),50)},createTimerCloseControl:function(e){var t;e=e||{},0!=$data.isControlsTimer&&("cancel"!=e.type?(t=function(){_this._global_.mp_timeout_3=setTimeout((function(){$method.toggleControlsDisplay({type:e.type||"timer"})}),option.closeControlsTimer||3500)},_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3),t()):_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3))},closeMpSidebar:function(){for(var e=!1,t=$el.mPlayer.querySelectorAll(".mplayer-sidebar"),r=0;r<t.length;r++)t[r].classList.contains("open")&&(t[r].classList.remove("open"),e=!($data.isShowRightSidebar=!1),"object"==_typeof(_this._global_.webpagePlugin)&&"removeEventListener"==_this._global_.webpagePlugin.eventStatus&&(new webpagePlugin.interface)._addEvent());return e},toggleControlsDisplay:function(e){(e=e||{type:""}).stopPropagation&&e.stopPropagation();var t=$method.closeMpSidebar();if(!t&&"DOMContentLoaded"!=e.type&&"resize"!=e.type&&"orientationchange"!=e.type){var r=["webkitTransform","transform","msTransform"],i=function(){$el.mplayerHeader.classList.toggle("show",!0)},s=function(){$el.mplayerHeader.classList.toggle("show",!1);for(var e=$el.mplayerHeader.getBoundingClientRect().height,t=0;t<r.length;t++)$el.mplayerHeader.style[r[t]]="translateY("+-e+"px)"},n=function(){$el.mplayerFooter.classList.toggle("show",!0),$el.miniProgress.style.opacity=0};t=function(){$el.mplayerFooter.classList.toggle("show",!1);for(var e=$el.mplayerFooter.getBoundingClientRect().height,t=$el.progressContainer.classList.contains("upper-position")?Number.parseInt($el.progressContainer.getBoundingClientRect().height/2)+1:0,i=0;i<r.length;i++)$el.mplayerFooter.style[r[i]]="translateY("+(e+t)+"px)";$el.miniProgress.style.opacity=1};return"showControls"==e.type?(n(),i(),$data.showScreenControls=!0,$method.createTimerCloseControl(),void _this.emit("controls-toggle",{show:!0})):"hideControls"==e.type?(t(),s(),$data.showScreenControls=!1,$method.createTimerCloseControl({type:"cancel"}),void _this.emit("controls-toggle",{show:!1})):void(("timer"!=e.type&&"dblscreen"!=e.type||0!=$data.showScreenControls)&&($data.showScreenControls?(t(),s(),$data.showScreenControls=!1,_this.emit("controls-toggle",{show:!1})):(n(),i(),$data.showScreenControls=!0,$method.createTimerCloseControl(),_this.emit("controls-toggle",{show:!0}),window.plus&&$data.isFullScreen&&plus.navigator.hideSystemNavigation())))}},onWaiting:function(){$data.isPlay=!1,_this._global_.mp_timeout_1||(_this._global_.mp_timeout_1=setTimeout((function(){$data.isPlay||$method.showLoading(),_this._global_.mp_timeout_1=null}),500))},onError:function(e){console.error(e);var t=arguments;$data.isDestroy&&1<=$data.playError||setTimeout((function(){(0===($el.videoObject.readyState||0)||$el.videoObject.duration<=1)&&($data.playError++,hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),$el.mplayerError.style.display="block",$el.videoObject.style.opacity=0,$method.showCover(),$method.hideLoading(),$method.toggleControlsDisplay({type:"hideControls"}),$method.toggleEventListenerGlobal("remove"),$method.toggleEventListenerCustom("remove"),$el.mplayerError.addEventListener("click",(function(e){e.stopPropagation(),$method.reloadUrl()}),{once:!0}),_this.emit("error",_toConsumableArray(t)))}),3e3)},reloadUrl:function(e){$method.destroy(),$method.createTimerCloseControl({type:"cancel"}),e&&(option.src=e),$data.isFullScreen&&setTimeout((function(){$method.openFullScreen(),$method.fullScreenChangeAction("Y")}),50),$method.initCreateMplayer(!0)},destroy:function(){var e,t,r,i;$el.mPlayer.querySelector("#mplayer-media-wrapper video")&&($data.isDestroy=!0,$method.toggleEventListenerGlobal("remove"),$method.toggleEventListenerCustom("remove"),$el.mPlayer.classList.remove("fullscreen-scaling"),hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),t=(e=$el.mPlayer.querySelector("#mplayer-media-wrapper")).querySelector("video"),r=(i=e.getBoundingClientRect()).height,i=i.width,document.pictureInPictureElement==t&&document.exitPictureInPicture(),e.style.height=r+"px",e.style.width=i+"px",t.pause(),t.removeAttribute("src"),e.innerHTML="",_this.emit("destroy"))},onProgress:function(){var e=$el.videoObject.buffered;if(0<e.length&&0<$data.duration){if(e.end(0)==$data.duration)return $el.miniBuffered.style.width="100%",$el.progressBuffered.style.width="100%",void($el.progressBuffered.style.borderRadius="5px");for(var t=0;t<e.length;t++){e.start(t);var r=e.end(t);if(r>$data.currentTime){r=r/$data.duration*100,$el.progressBuffered.style.width=r+"%",$el.miniBuffered.style.width=r+"%";break}}}},showLoading:function(){"inline-block"!=$el.mplayerLoading.style.display&&($el.mplayerLoading.style.display="inline-block")},hideLoading:function(){"none"!=$el.mplayerLoading.style.display&&($el.mplayerLoading.style.display="none")},showCover:function(){$el.mplayerCover.style.opacity<=0&&($el.mplayerCover.style.zIndex=8,$el.mplayerCover.style.opacity=.2)},hideCover:function(){"0"!=$el.mplayerCover.style.opacity&&($el.mplayerCover.style.opacity=0,$el.mplayerCover.style.zIndex=-1)},showToast:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t={message:"",duration:1500,style:{}};"string"==typeof e&&(t.message=e),"object"==_typeof(e)&&Object.keys(t).forEach((function(r){e[r]&&(t[r]=e[r])}));var r,i=0<("number"==typeof t.duration&&t.duration)?t.duration:1500,s=$el.mPlayer.querySelector("#mplayer-media-wrapper");s.querySelector("#mplayer-toast")&&$method.removeNode(s,"#mplayer-toast"),(r=document.createElement("div")).setAttribute("class","mplayer-toast toast-scaling"),r.setAttribute("id","mplayer-toast"),r.innerHTML=t.message,"[object Object]"==Object.prototype.toString.call(t.style)&&Object.keys(t.style).forEach((function(e){r.style[e]=t.style[e]})),s.appendChild(r),r.addEventListener("click",(function(e){e.stopPropagation()})),r.addEventListener("touchstart",(function(e){e.stopPropagation()})),_this._global_.handleIconTimer_2&&window.clearTimeout(_this._global_.handleIconTimer_2),_this._global_.handleIconTimer_2=setTimeout((function(){$method.removeNode(s,"#mplayer-toast")}),i)},toggleControlsStyle:function(e){for(var t,r=(option.custom||{}).footerControls||[],i=0;i<r.length;i++)!0!==r[i].oftenShow&&(t=r[i].slot,(t=$el.mplayerFooter.querySelector("[slot="+t+"]"))&&("portrait"==e&&(t.style.display="none"),"landscape"==e&&(t.style.display="block")))},onDocVisibilitychange:function(e){!1!==$data.showScreenControls&&$method.createTimerCloseControl({type:"visible"==document.visibilityState?"":"cancel"})},onScreenResize:function(e){function t(){$method.toggleControlsDisplay(e),$el.progressContainer.classList.remove("upper-position"),$method.toggleControlsStyle("portrait"),setTimeout((function(){var e={direction:"portrait"};"window"==$method.returnSys()&&(e.fullscreen=$data.isFullScreen),_this.emit("fullscreen-change",e)}),10),window.plus&&setTimeout((function(){plus.navigator.showSystemNavigation()}),200)}function r(){$method.toggleControlsDisplay(e),$el.progressContainer.classList.add("upper-position"),$method.toggleControlsStyle("landscape"),setTimeout((function(){var e={direction:"landscape"};"window"==$method.returnSys()&&(e.fullscreen=$data.isFullScreen),_this.emit("fullscreen-change",e)}),10),window.plus&&$data.isFullScreen&&setTimeout((function(){plus.navigator.hideSystemNavigation()}),200)}(e=e||{type:""}).stopPropagation&&e.stopPropagation(),$method.createTimerCloseControl(),$method.changeVideoSize(e),window.orientation||0==window.orientation?(0==window.orientation||180==window.orientation?t:r)():setTimeout((function(){(500<=$el.mPlayer.getBoundingClientRect().width?r:t)()}),0),0==$data.showScreenControls&&$method.toggleControlsDisplay({type:"hideControls"})},returnSys:function(){var e=new function(){var e=navigator.userAgent;return navigator.appVersion,{ios:!!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),android:-1<e.indexOf("Android")||-1<e.indexOf("Linux"),iPhone:-1<e.indexOf("iPhone"),iPad:-1<e.indexOf("iPad")}};return e.iPhone||e.iPad||e.ios?"ios":e.android?"androd":"window"},nodesObserver:function(){var e=new MutationObserver((function(e,t){var r,i=_createForOfIteratorHelper(e);try{for(i.s();!(r=i.n()).done;){var s=r.value;if("childList"===s.type){var n,a=_createForOfIteratorHelper(s.removedNodes);try{for(a.s();!(n=a.n()).done;){var o=n.value;if(o instanceof HTMLVideoElement){hls&&hls.media&&(hls.destroy(),hls=""),flv&&(flv.destroy(),flv=""),document.pictureInPictureElement==o&&document.exitPictureInPicture(),o.pause(),o.removeAttribute("src"),t.disconnect();break}}}catch(e){a.e(e)}finally{a.f()}}}}catch(e){i.e(e)}finally{i.f()}})),t=$el.mPlayer.querySelector(".video-wrapper");e.observe(t,{childList:!0})},toggleEventListenerCustom:function(e){var t=option.custom||{},r="add"==e?"addEventListener":"removeEventListener",i=t.headControls||[];if(0<i.length)for(var s=0;s<i.length;s++)!i[s].click instanceof Function||(a=i[s].slot,(o=$el.headerMenu.querySelector("[slot="+a+"]"))instanceof Element&&o[r]("click",i[s].click));var n=t.footerControls||[];if(0<n.length){var a,o;for(s=0;s<n.length;s++)!n[s].click instanceof Function||(a=n[s].slot,(o=$el.mplayerFooter.querySelector("[slot="+a+"]"))instanceof Element&&o[r]("click",n[s].click))}},toggleEventListenerGlobal:function(e,t){var r,i="add"==e?"addEventListener":"removeEventListener";r="onorientationchange"in window?"orientationchange":"resize",window[i](r,$method.onScreenResize),$el.backButton[i]("click",$method.onBack),$el.fullSwitch[i]("click",$method.fullToggle),$el.playSwitch[i]("click",$method.onPlayTap),$el.mPlayer[i]("click",$method.onContrainerTap),$el.mPlayer[i]("dblclick",$method.onContrainerTap),$el.touchEffective instanceof Element&&$el.touchEffective[i]("touchstart",$method.progressBarSeeking),$el.touchEffective instanceof Element&&$el.touchEffective[i]("mousedown",$method.progressBarSeeking),$el.videoObject[i]("webkitbeginfullscreen",$method.runtimeCompatibleHandle),$el.videoObject[i]("webkitendfullscreen",$method.runtimeCompatibleHandle),document[i]("resume",$method.plusRuntimeHandle),document[i]("pause",$method.plusRuntimeHandle),document[i]("visibilitychange",$method.onDocVisibilitychange),"playerReady"==t&&function(){$el.mplayerCover.addEventListener("touchstart",(function(e){e.stopPropagation()})),$el.mplayerCover.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("click",(function(e){e.stopPropagation()})),$el.mplayerHeader.addEventListener("dblclick",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("click",(function(e){e.stopPropagation()})),$el.mplayerFooter.addEventListener("dblclick",(function(e){e.stopPropagation()})),$el.mplayerError.addEventListener("touchstart",(function(e){e.stopPropagation()})),$el.mplayerError.addEventListener("touchmove",(function(e){e.stopPropagation()})),$el.videoObject.addEventListener("canplaythrough",$method.onCanplaythrough),$el.videoObject.addEventListener("durationchange",$method.onDurationChange),option.live||$el.videoObject.addEventListener("timeupdate",$method.onTimeupdate),$el.videoObject.addEventListener("play",$method.onPlay),$el.videoObject.addEventListener("playing",$method.onPlaying),$el.videoObject.addEventListener("pause",$method.onPause),$el.videoObject.addEventListener("waiting",$method.onWaiting),$el.videoObject.addEventListener("error",$method.onError),option.live||$el.videoObject.addEventListener("progress",$method.onProgress);for(var e=$el.mPlayer.querySelectorAll(".mplayer-sidebar"),t=0;t<e.length;t++)e[t].addEventListener("touchstart",(function(e){e.stopPropagation()})),e[t].addEventListener("touchmove",(function(e){e.stopPropagation()})),e[t].addEventListener("touchend",(function(e){e.stopPropagation()})),e[t].addEventListener("click",(function(e){e.stopPropagation()})),e[t].addEventListener("dblclick",(function(e){e.stopPropagation()}))}()}},this.showRightSidebar=function(e){e=$el.mPlayer.querySelector("#mplayer-media-wrapper [slot="+e+"]"),e&&e.classList.contains("mplayer-sidebar")&&($method.createTimerCloseControl({type:"cancel"}),$method.toggleControlsDisplay({type:"sidebarRight"}),e.classList.add("open"),$data.isShowRightSidebar=!0,webpagePlugin&&(new webpagePlugin.interface)._removeEvent())},this.toggleControls=function(e){return!0===e?0==$data.showScreenControls?$method.toggleControlsDisplay({type:"showControls"}):$method.createTimerCloseControl():!1===e?1==$data.showScreenControls&&$method.toggleControlsDisplay({type:"hideControls"}):$method.toggleControlsDisplay(),e=new Object,e.closeTimer=function(){_this._global_.mp_timeout_3&&clearTimeout(_this._global_.mp_timeout_3),$data.isControlsTimer=!1},e.openTimer=function(){$data.isControlsTimer=!0},e},this.showToast=function(e){$method.showToast(e)},this.showLoading=function(){$method.showLoading()},this.hideLoading=function(){$method.hideLoading()},this.video=function(){return $el.videoObject},this.reloadUrl=function(e){$method.reloadUrl(e)},this.destroy=function(){$method.destroy()},this.openFullScreen=function(){$method.openFullScreen()},this.closeFullScreen=function(){$method.closeFullScreen()},this.sendError=function(e){$method.onError(e)},this.getControls=function(){return setTimeout((function(){$method.overloadingEl()}),10),$el.mPlayer.querySelectorAll("[control]")},"interactive"==document.readyState||"complete"==document.readyState?$method.initCreateMplayer():document.addEventListener("readystatechange",(function(){"interactive"==document.readyState&&$method.initCreateMplayer()})))};return MuiPlayer.prototype.on=function(e,t,r){this._event_[e]||(this._event_[e]=[]),this._event_[e]["MASTER"==r?"unshift":"push"](t)},MuiPlayer.prototype.off=function(e,t){this._event_[e]&&(t?0<=(t=this._event_[e].indexOf(t))&&this._event_[e].splice(t,1):this._event_[e]=void 0)},MuiPlayer.prototype.emit=function(e,t){if(this._event_[e])for(var r=0;r<this._event_[e].length;r++){var i=this._event_[e][r];t instanceof Array?i.apply(this,t):i(t)}},MuiPlayer.prototype.once=function(e,t){var r=this;this.on(e,(function i(){t.apply(this,Array.prototype.slice.call(arguments)),setTimeout((function(){r.off(e,i)}),200)}))},MuiPlayer}))}).call(this,__webpack_require__("62e4")(module))},d4f0:function(e,t,r){"use strict";r("7a82");var i=r("4ea4").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=i(r("c7eb")),n=i(r("1da1"));r("a9e3");var a=r("365c"),o=i(r("2cb3")),l={components:{LiveVideo:o.default},props:{id:{type:[String,Number]}},data:function(){return{address:"",type:"",expires:"",timer:null}},created:function(){this.init()},methods:{init:function(){var e=this;return(0,n.default)((0,s.default)().mark((function t(){var r,i,n,o,l,d;return(0,s.default)().wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.id){t.next=2;break}return t.abrupt("return");case 2:return t.prev=2,t.next=5,a.http.get("/api/devices/".concat(e.id,"/live"));case 5:r=t.sent,i=r.data,n=i.data,o=n.address,l=n.type,d=n.expires,e.address=o,e.type=l,e.expires=d,e.reinit(),t.next=18;break;case 15:t.prev=15,t.t0=t["catch"](2),console.log(t.t0);case 18:case"end":return t.stop()}}),t,null,[[2,15]])})))()},reinit:function(){var e=this;!this.expires||this.expires<=0||(this.timer=setTimeout((function(){e.init()}),1e3*this.expires))}},beforeDestroy:function(){this.timer&&clearTimeout(this.timer)}};t.default=l},d4f6:function(e,t,r){"use strict";var i;r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return n})),r.d(t,"a",(function(){return i}));var s=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("v-uni-view",{staticClass:"relative video-box"},[r("v-uni-view",{staticClass:"absolute top-0 left-0 w-full h-full"},["iframe"==e.type?r("iframe",{staticClass:"w-full h-full",attrs:{src:e.url}}):r("div",{ref:"muiPlayer"})])],1)},n=[]},df7c:function(e,t,r){(function(e){function r(e,t){for(var r=0,i=e.length-1;i>=0;i--){var s=e[i];"."===s?e.splice(i,1):".."===s?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}function i(e){"string"!==typeof e&&(e+="");var t,r=0,i=-1,s=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!s){r=t+1;break}}else-1===i&&(s=!1,i=t+1);return-1===i?"":e.slice(r,i)}function s(e,t){if(e.filter)return e.filter(t);for(var r=[],i=0;i<e.length;i++)t(e[i],i,e)&&r.push(e[i]);return r}t.resolve=function(){for(var t="",i=!1,n=arguments.length-1;n>=-1&&!i;n--){var a=n>=0?arguments[n]:e.cwd();if("string"!==typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,i="/"===a.charAt(0))}return t=r(s(t.split("/"),(function(e){return!!e})),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),a="/"===n(e,-1);return e=r(s(e.split("/"),(function(e){return!!e})),!i).join("/"),e||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(s(e,(function(e,t){if("string"!==typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,r){function i(e){for(var t=0;t<e.length;t++)if(""!==e[t])break;for(var r=e.length-1;r>=0;r--)if(""!==e[r])break;return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var s=i(e.split("/")),n=i(r.split("/")),a=Math.min(s.length,n.length),o=a,l=0;l<a;l++)if(s[l]!==n[l]){o=l;break}var d=[];for(l=o;l<s.length;l++)d.push("..");return d=d.concat(n.slice(o)),d.join("/")},t.sep="/",t.delimiter=":",t.dirname=function(e){if("string"!==typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,s=!0,n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),47===t){if(!s){i=n;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"/":e.slice(0,i)},t.basename=function(e,t){var r=i(e);return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r},t.extname=function(e){"string"!==typeof e&&(e+="");for(var t=-1,r=0,i=-1,s=!0,n=0,a=e.length-1;a>=0;--a){var o=e.charCodeAt(a);if(47!==o)-1===i&&(s=!1,i=a+1),46===o?-1===t?t=a:1!==n&&(n=1):-1!==t&&(n=-1);else if(!s){r=a+1;break}}return-1===t||-1===i||0===n||1===n&&t===i-1&&t===r+1?"":e.slice(t,i)};var n="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)}}).call(this,r("4362"))},e2e5:function(e,t,r){"use strict";r("7a82");var i=r("4ea4").default;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,r("3315");var s=i(r("bf15")),n=i(r("fc78")),a=i(r("a567")),o={props:{url:{type:String,default:null},type:{type:String}},mounted:function(){this.videoPlayer()},methods:{videoPlayer:function(){var e=this;if("iframe"==this.type)console.log("=====");else{var t={};t="m3u8"==this.type?{type:"hls",loader:a.default,config:{debug:!1}}:{type:"flv",loader:n.default,config:{debug:!1}},this.mp=new s.default({container:this.$refs.muiPlayer,live:!0,src:this.url,autoplay:!0,muted:!0,parse:t,pageHead:!1,width:"100%",height:"100%",autoFit:!1,objectFit:"contain",videoAttribute:[{attrKey:"webkit-playsinline",attrValue:"webkit-playsinline"},{attrKey:"playsinline",attrValue:"playsinline"},{attrKey:"x5-video-player-type",attrValue:"h5-page"}],custom:{footerControls:[{style:{}}]}});var r=this.mp.video();this.$nextTick((function(){e.mp.on("ready",(function(t){r.play(),r.addEventListener("play",(function(t){e.$emit("onPlayFn")})),r.addEventListener("ended",(function(t){e.$emit("onEndedFn")}))}))}))}}}};t.default=o},e52e:function(e,t,r){"use strict";r.r(t);var i=r("d4f0"),s=r.n(i);for(var n in i)["default"].indexOf(n)<0&&function(e){r.d(t,e,(function(){return i[e]}))}(n);t["default"]=s.a},fc78:function(e,t,r){(function(t){(function(t,r){e.exports=r()})(self,(function(){return function(){var e={"./node_modules/es6-promise/dist/es6-promise.js":
|
||
/*!******************************************************!*\
|
||
!*** ./node_modules/es6-promise/dist/es6-promise.js ***!
|
||
\******************************************************/function(e,r,i){
|
||
/*!
|
||
* @overview es6-promise - a tiny implementation of Promises/A+.
|
||
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
||
* @license Licensed under MIT license
|
||
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
||
* @version v4.2.8+1e68dce6
|
||
*/
|
||
(function(t,r){e.exports=r()})(0,(function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function r(e){return"function"===typeof e}var s=void 0;s=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var n=s,a=0,o=void 0,l=void 0,d=function(e,t){S[a]=e,S[a+1]=t,a+=2,2===a&&(l?l(T):A())};function h(e){l=e}function c(e){d=e}var u="undefined"!==typeof window?window:void 0,f=u||{},p=f.MutationObserver||f.WebKitMutationObserver,m="undefined"===typeof self&&"undefined"!==typeof t&&"[object process]"==={}.toString.call(t),g="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel;function y(){return function(){return t.nextTick(T)}}function v(){return"undefined"!==typeof o?function(){o(T)}:b()}function _(){var e=0,t=new p(T),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function E(){var e=new MessageChannel;return e.port1.onmessage=T,function(){return e.port2.postMessage(0)}}function b(){var e=setTimeout;return function(){return e(T,1)}}var S=new Array(1e3);function T(){for(var e=0;e<a;e+=2){var t=S[e],r=S[e+1];t(r),S[e]=void 0,S[e+1]=void 0}a=0}function L(){try{var e=Function("return this")().require("vertx");return o=e.runOnLoop||e.runOnContext,v()}catch(t){return b()}}var A=void 0;function R(e,t){var r=this,i=new this.constructor(D);void 0===i[k]&&W(i);var s=r._state;if(s){var n=arguments[s-1];d((function(){return H(s,i,n,r._result)}))}else V(r,i,e,t);return i}function w(e){var t=this;if(e&&"object"===typeof e&&e.constructor===t)return e;var r=new t(D);return U(r,e),r}A=m?y():p?_():g?E():void 0===u?L():b();var k=Math.random().toString(36).substring(2);function D(){}var I=void 0,x=1,C=2;function P(){return new TypeError("You cannot resolve a promise with itself")}function O(){return new TypeError("A promises callback cannot return that same promise.")}function M(e,t,r,i){try{e.call(t,r,i)}catch(s){return s}}function F(e,t,r){d((function(e){var i=!1,s=M(r,t,(function(r){i||(i=!0,t!==r?U(e,r):G(e,r))}),(function(t){i||(i=!0,j(e,t))}),"Settle: "+(e._label||" unknown promise"));!i&&s&&(i=!0,j(e,s))}),e)}function N(e,t){t._state===x?G(e,t._result):t._state===C?j(e,t._result):V(t,void 0,(function(t){return U(e,t)}),(function(t){return j(e,t)}))}function B(e,t,i){t.constructor===e.constructor&&i===R&&t.constructor.resolve===w?N(e,t):void 0===i?G(e,t):r(i)?F(e,t,i):G(e,t)}function U(t,r){if(t===r)j(t,P());else if(e(r)){var i=void 0;try{i=r.then}catch(s){return void j(t,s)}B(t,r,i)}else G(t,r)}function $(e){e._onerror&&e._onerror(e._result),K(e)}function G(e,t){e._state===I&&(e._result=t,e._state=x,0!==e._subscribers.length&&d(K,e))}function j(e,t){e._state===I&&(e._state=C,e._result=t,d($,e))}function V(e,t,r,i){var s=e._subscribers,n=s.length;e._onerror=null,s[n]=t,s[n+x]=r,s[n+C]=i,0===n&&e._state&&d(K,e)}function K(e){var t=e._subscribers,r=e._state;if(0!==t.length){for(var i=void 0,s=void 0,n=e._result,a=0;a<t.length;a+=3)i=t[a],s=t[a+r],i?H(r,i,s,n):s(n);e._subscribers.length=0}}function H(e,t,i,s){var n=r(i),a=void 0,o=void 0,l=!0;if(n){try{a=i(s)}catch(d){l=!1,o=d}if(t===a)return void j(t,O())}else a=s;t._state!==I||(n&&l?U(t,a):!1===l?j(t,o):e===x?G(t,a):e===C&&j(t,a))}function Y(e,t){try{t((function(t){U(e,t)}),(function(t){j(e,t)}))}catch(r){j(e,r)}}var z=0;function q(){return z++}function W(e){e[k]=z++,e._state=void 0,e._result=void 0,e._subscribers=[]}function X(){return new Error("Array Methods must be provided an Array")}var Q=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(D),this.promise[k]||W(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?G(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&G(this.promise,this._result))):j(this.promise,X())}return e.prototype._enumerate=function(e){for(var t=0;this._state===I&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var r=this._instanceConstructor,i=r.resolve;if(i===w){var s=void 0,n=void 0,a=!1;try{s=e.then}catch(l){a=!0,n=l}if(s===R&&e._state!==I)this._settledAt(e._state,t,e._result);else if("function"!==typeof s)this._remaining--,this._result[t]=e;else if(r===ie){var o=new r(D);a?j(o,n):B(o,e,s),this._willSettleAt(o,t)}else this._willSettleAt(new r((function(t){return t(e)})),t)}else this._willSettleAt(i(e),t)},e.prototype._settledAt=function(e,t,r){var i=this.promise;i._state===I&&(this._remaining--,e===C?j(i,r):this._result[t]=r),0===this._remaining&&G(i,this._result)},e.prototype._willSettleAt=function(e,t){var r=this;V(e,void 0,(function(e){return r._settledAt(x,t,e)}),(function(e){return r._settledAt(C,t,e)}))},e}();function Z(e){return new Q(this,e).promise}function J(e){var t=this;return n(e)?new t((function(r,i){for(var s=e.length,n=0;n<s;n++)t.resolve(e[n]).then(r,i)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))}function ee(e){var t=this,r=new t(D);return j(r,e),r}function te(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function re(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var ie=function(){function e(t){this[k]=q(),this._result=this._state=void 0,this._subscribers=[],D!==t&&("function"!==typeof t&&te(),this instanceof e?Y(this,t):re())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,i=t.constructor;return r(e)?t.then((function(t){return i.resolve(e()).then((function(){return t}))}),(function(t){return i.resolve(e()).then((function(){throw t}))})):t.then(e,e)},e}();function se(){var e=void 0;if("undefined"!==typeof i.g)e=i.g;else if("undefined"!==typeof self)e=self;else try{e=Function("return this")()}catch(s){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var r=null;try{r=Object.prototype.toString.call(t.resolve())}catch(s){}if("[object Promise]"===r&&!t.cast)return}e.Promise=ie}return ie.prototype.then=R,ie.all=Z,ie.race=J,ie.resolve=w,ie.reject=ee,ie._setScheduler=h,ie._setAsap=c,ie._asap=d,ie.polyfill=se,ie.Promise=ie,ie}))},"./node_modules/events/events.js":
|
||
/*!***************************************!*\
|
||
!*** ./node_modules/events/events.js ***!
|
||
\***************************************/function(e){"use strict";var t,r="object"===typeof Reflect?Reflect:null,i=r&&"function"===typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};function s(e){console&&console.warn&&console.warn(e)}t=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}e.exports=a,e.exports.once=v,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function l(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var n,a,o;if(l(r),a=e._events,void 0===a?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]),void 0===o)o=a[t]=r,++e._eventsCount;else if("function"===typeof o?o=a[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=d(e),n>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,s(h)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=c.bind(i);return s.listener=r,i.wrapFn=s,s}function f(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"===typeof s?r?[s.listener||s]:[s]:r?y(s):m(s,s.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"===typeof r)return 1;if(void 0!==r)return r.length}return 0}function m(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function g(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function y(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function v(e,t){return new Promise((function(r,i){function s(r){e.removeListener(t,n),i(r)}function n(){"function"===typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}E(e,t,n,{once:!0}),"error"!==t&&_(e,s,{once:!0})}))}function _(e,t,r){"function"===typeof e.on&&E(e,"error",t,r)}function E(e,t,r,i){if("function"===typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!==typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(n){i.once&&e.removeEventListener(t,s),r(n)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!==typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!==typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return d(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,n=this._events;if(void 0!==n)s=s&&void 0===n.error;else if(!s)return!1;if(s){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=n[e];if(void 0===l)return!1;if("function"===typeof l)i(l,this,t);else{var d=l.length,h=m(l,d);for(r=0;r<d;++r)i(h[r],this,t)}return!0},a.prototype.addListener=function(e,t){return h(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return h(this,e,t,!0)},a.prototype.once=function(e,t){return l(t),this.on(e,u(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,u(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,i,s,n,a;if(l(t),i=this._events,void 0===i)return this;if(r=i[e],void 0===r)return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!==typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){a=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():g(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,a||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,i;if(r=this._events,void 0===r)return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,n=Object.keys(r);for(i=0;i<n.length;++i)s=n[i],"removeListener"!==s&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=r[e],"function"===typeof t)this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return f(this,e,!0)},a.prototype.rawListeners=function(e){return f(this,e,!1)},a.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},"./node_modules/webworkify-webpack/index.js":
|
||
/*!**************************************************!*\
|
||
!*** ./node_modules/webworkify-webpack/index.js ***!
|
||
\**************************************************/function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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.oe=function(e){throw console.error(e),e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var s="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+s+").*?\\)";function a(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e){return!isNaN(1*e)}function l(e,t,i){var l={};l[i]=[];var d=t.toString(),h=d.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!h)return l;var c,u=h[1],f=new RegExp("(\\\\n|\\W)"+a(u)+n,"g");while(c=f.exec(d))"dll-reference"!==c[3]&&l[i].push(c[3]);f=new RegExp("\\("+a(u)+'\\("(dll-reference\\s('+s+'))"\\)\\)'+n,"g");while(c=f.exec(d))e[c[2]]||(l[i].push(c[1]),e[c[2]]=r(c[1]).m),l[c[2]]=l[c[2]]||[],l[c[2]].push(c[4]);for(var p=Object.keys(l),m=0;m<p.length;m++)for(var g=0;g<l[p[m]].length;g++)o(l[p[m]][g])&&(l[p[m]][g]=1*l[p[m]][g]);return l}function d(e){var t=Object.keys(e);return t.reduce((function(t,r){return t||e[r].length>0}),!1)}function h(e,t){var r={main:[t]},i={main:[]},s={main:{}};while(d(r))for(var n=Object.keys(r),a=0;a<n.length;a++){var o=n[a],h=r[o],c=h.pop();if(s[o]=s[o]||{},!s[o][c]&&e[o][c]){s[o][c]=!0,i[o]=i[o]||[],i[o].push(c);for(var u=l(e,e[o][c],o),f=Object.keys(u),p=0;p<f.length;p++)r[f[p]]=r[f[p]]||[],r[f[p]]=r[f[p]].concat(u[f[p]])}}return i}e.exports=function(e,t){t=t||{};var s={main:r.m},n=t.all?{main:Object.keys(s.main)}:h(s,e),a="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){var t=0;while(n[e][t])t++;n[e].push(t),s[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map((function(t){return JSON.stringify(t)+": "+s[e][t].toString()})).join(",")+"});\n"})),a=a+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map((function(e){return JSON.stringify(e)+": "+s.main[e].toString()})).join(",")+"}))(self);";var o=new window.Blob([a],{type:"text/javascript"});if(t.bare)return o;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,d=l.createObjectURL(o),c=new window.Worker(d);return c.objectURL=d,c}},"./src/config.js":
|
||
/*!***********************!*\
|
||
!*** ./src/config.js ***!
|
||
\***********************/function(e,t,r){"use strict";r.r(t),r.d(t,{defaultConfig:function(){return i},createDefaultConfig:function(){return s}});var i={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function s(){return Object.assign({},i)}},"./src/core/features.js":
|
||
/*!******************************!*\
|
||
!*** ./src/core/features.js ***!
|
||
\******************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../io/io-controller.js */"./src/io/io-controller.js"),s=r(/*! ../config.js */"./src/config.js"),n=function(){function e(){}return e.supportMSEH264Playback=function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},e.supportNetworkStreamIO=function(){var e=new i.default({},(0,s.createDefaultConfig)()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t},e.getNetworkLoaderTypeName=function(){var e=new i.default({},(0,s.createDefaultConfig)()),t=e.loaderType;return e.destroy(),t},e.supportNativeMediaPlayback=function(t){void 0==e.videoElement&&(e.videoElement=window.document.createElement("video"));var r=e.videoElement.canPlayType(t);return"probably"===r||"maybe"==r},e.getFeatureList=function(){var t={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return t.mseFlvPlayback=e.supportMSEH264Playback(),t.networkStreamIO=e.supportNetworkStreamIO(),t.networkLoaderName=e.getNetworkLoaderTypeName(),t.mseLiveFlvPlayback=t.mseFlvPlayback&&t.networkStreamIO,t.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),t.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),t.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),t},e}();t["default"]=n},"./src/core/media-info.js":
|
||
/*!********************************!*\
|
||
!*** ./src/core/media-info.js ***!
|
||
\********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,r=this._search(t.times,e);return{index:r,milliseconds:t.times[r],fileposition:t.filepositions[r]}},e.prototype._search=function(e,t){var r=0,i=e.length-1,s=0,n=0,a=i;t<e[0]&&(r=0,n=a+1);while(n<=a){if(s=n+Math.floor((a-n)/2),s===i||t>=e[s]&&t<e[s+1]){r=s;break}e[s]<t?n=s+1:a=s-1}return r},e}();t["default"]=i},"./src/core/media-segment-info.js":
|
||
/*!****************************************!*\
|
||
!*** ./src/core/media-segment-info.js ***!
|
||
\****************************************/function(e,t,r){"use strict";r.r(t),r.d(t,{SampleInfo:function(){return i},MediaSegmentInfo:function(){return s},IDRSampleList:function(){return n},MediaSegmentInfoList:function(){return a}});var i=function(){function e(e,t,r,i,s){this.dts=e,this.pts=t,this.duration=r,this.originalDts=i,this.isSyncPoint=s,this.fileposition=null}return e}(),s=function(){function e(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}return e.prototype.appendSyncPoint=function(e){e.isSyncPoint=!0,this.syncPoints.push(e)},e}(),n=function(){function e(){this._list=[]}return e.prototype.clear=function(){this._list=[]},e.prototype.appendArray=function(e){var t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))},e.prototype.getLastSyncPointBeforeDts=function(e){if(0==this._list.length)return null;var t=this._list,r=0,i=t.length-1,s=0,n=0,a=i;e<t[0].dts&&(r=0,n=a+1);while(n<=a){if(s=n+Math.floor((a-n)/2),s===i||e>=t[s].dts&&e<t[s+1].dts){r=s;break}t[s].dts<e?n=s+1:a=s-1}return this._list[r]},e}(),a=function(){function e(e){this._type=e,this._list=[],this._lastAppendLocation=-1}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._list.length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return 0===this._list.length},e.prototype.clear=function(){this._list=[],this._lastAppendLocation=-1},e.prototype._searchNearestSegmentBefore=function(e){var t=this._list;if(0===t.length)return-2;var r=t.length-1,i=0,s=0,n=r,a=0;if(e<t[0].originalBeginDts)return a=-1,a;while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>t[i].lastSample.originalDts&&e<t[i+1].originalBeginDts){a=i;break}t[i].originalBeginDts<e?s=i+1:n=i-1}return a},e.prototype._searchNearestSegmentAfter=function(e){return this._searchNearestSegmentBefore(e)+1},e.prototype.append=function(e){var t=this._list,r=e,i=this._lastAppendLocation,s=0;-1!==i&&i<t.length&&r.originalBeginDts>=t[i].lastSample.originalDts&&(i===t.length-1||i<t.length-1&&r.originalBeginDts<t[i+1].originalBeginDts)?s=i+1:t.length>0&&(s=this._searchNearestSegmentBefore(r.originalBeginDts)+1),this._lastAppendLocation=s,this._list.splice(s,0,r)},e.prototype.getLastSegmentBefore=function(e){var t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null},e.prototype.getLastSampleBefore=function(e){var t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){var t=this._searchNearestSegmentBefore(e),r=this._list[t].syncPoints;while(0===r.length&&t>0)t--,r=this._list[t].syncPoints;return r.length>0?r[r.length-1]:null},e}()},"./src/core/mse-controller.js":
|
||
/*!************************************!*\
|
||
!*** ./src/core/mse-controller.js ***!
|
||
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./mse-events.js */"./src/core/mse-events.js"),l=r(/*! ./media-segment-info.js */"./src/core/media-segment-info.js"),d=r(/*! ../utils/exception.js */"./src/utils/exception.js"),h=function(){function e(e){this.TAG="MSEController",this._config=e,this._emitter=new(s()),this._config.isLive&&void 0==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new l.IDRSampleList}return e.prototype.destroy=function(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaSource)throw new d.IllegalStateException("MediaSource has been attached to an HTMLMediaElement!");var t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL},e.prototype.detachMediaElement=function(){if(this._mediaSource){var e=this._mediaSource;for(var t in this._sourceBuffers){var r=this._pendingSegments[t];r.splice(0,r.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;var i=this._sourceBuffers[t];if(i){if("closed"!==e.readyState){try{e.removeSourceBuffer(i)}catch(s){n.default.e(this.TAG,s.message)}i.removeEventListener("error",this.e.onSourceBufferError),i.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(s){n.default.e(this.TAG,s.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)},e.prototype.appendInitSegment=function(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);var r=e,i=""+r.container;r.codec&&r.codec.length>0&&(i+=";codecs="+r.codec);var s=!1;if(n.default.v(this.TAG,"Received Initialization Segment, mimeType: "+i),this._lastInitSegments[r.type]=r,i!==this._mimeTypes[r.type]){if(this._mimeTypes[r.type])n.default.v(this.TAG,"Notice: "+r.type+" mimeType changed, origin: "+this._mimeTypes[r.type]+", target: "+i);else{s=!0;try{var l=this._sourceBuffers[r.type]=this._mediaSource.addSourceBuffer(i);l.addEventListener("error",this.e.onSourceBufferError),l.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(d){return n.default.e(this.TAG,d.message),void this._emitter.emit(o.default.ERROR,{code:d.code,msg:d.message})}}this._mimeTypes[r.type]=i}t||this._pendingSegments[r.type].push(r),s||this._sourceBuffers[r.type]&&!this._sourceBuffers[r.type].updating&&this._doAppendSegments(),a.default.safari&&"audio/mpeg"===r.container&&r.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=r.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var r=this._sourceBuffers[t.type];!r||r.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){for(var t in this._sourceBuffers)if(this._sourceBuffers[t]){var r=this._sourceBuffers[t];if("open"===this._mediaSource.readyState)try{r.abort()}catch(h){n.default.e(this.TAG,h.message)}this._idrList.clear();var i=this._pendingSegments[t];if(i.splice(0,i.length),"closed"!==this._mediaSource.readyState){for(var s=0;s<r.buffered.length;s++){var o=r.buffered.start(s),l=r.buffered.end(s);this._pendingRemoveRanges[t].push({start:o,end:l})}if(r.updating||this._doRemoveRanges(),a.default.safari){var d=this._lastInitSegments[t];d&&(this._pendingSegments[t].push(d),r.updating||this._doAppendSegments())}}}},e.prototype.endOfStream=function(){var e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)},e.prototype.getNearestKeyframe=function(e){return this._idrList.getLastSyncPointBeforeDts(e)},e.prototype._needCleanupSourceBuffer=function(){if(!this._config.autoCleanupSourceBuffer)return!1;var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var r=this._sourceBuffers[t];if(r){var i=r.buffered;if(i.length>=1&&e-i.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e=this._mediaElement.currentTime;for(var t in this._sourceBuffers){var r=this._sourceBuffers[t];if(r){for(var i=r.buffered,s=!1,n=0;n<i.length;n++){var a=i.start(n),o=i.end(n);if(a<=e&&e<o+3){if(e-a>=this._config.autoCleanupMaxBackwardDuration){s=!0;var l=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:a,end:l})}}else o<e&&(s=!0,this._pendingRemoveRanges[t].push({start:a,end:o}))}s&&!r.updating&&this._doRemoveRanges()}}},e.prototype._updateMediaSourceDuration=function(){var e=this._sourceBuffers;if(0!==this._mediaElement.readyState&&"open"===this._mediaSource.readyState&&!(e.video&&e.video.updating||e.audio&&e.audio.updating)){var t=this._mediaSource.duration,r=this._pendingMediaDuration;r>0&&(isNaN(t)||r>t)&&(n.default.v(this.TAG,"Update MediaSource duration from "+t+" to "+r),this._mediaSource.duration=r),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){for(var e in this._pendingRemoveRanges)if(this._sourceBuffers[e]&&!this._sourceBuffers[e].updating){var t=this._sourceBuffers[e],r=this._pendingRemoveRanges[e];while(r.length&&!t.updating){var i=r.shift();t.remove(i.start,i.end)}}},e.prototype._doAppendSegments=function(){var e=this._pendingSegments;for(var t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){var r=e[t].shift();if(r.timestampOffset){var i=this._sourceBuffers[t].timestampOffset,s=r.timestampOffset/1e3,a=Math.abs(i-s);a>.1&&(n.default.v(this.TAG,"Update MPEG audio timestampOffset from "+i+" to "+s),this._sourceBuffers[t].timestampOffset=s),delete r.timestampOffset}if(!r.data||0===r.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(r.data),this._isBufferFull=!1,"video"===t&&r.hasOwnProperty("info")&&this._idrList.appendArray(r.info.syncPoints)}catch(l){this._pendingSegments[t].unshift(r),22===l.code?(this._isBufferFull||this._emitter.emit(o.default.BUFFER_FULL),this._isBufferFull=!0):(n.default.e(this.TAG,l.message),this._emitter.emit(o.default.ERROR,{code:l.code,msg:l.message}))}}},e.prototype._onSourceOpen=function(){if(n.default.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){var e=this._pendingSourceBufferInit;while(e.length){var t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(o.default.SOURCE_OPEN)},e.prototype._onSourceEnded=function(){n.default.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){n.default.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(o.default.UPDATE_END)},e.prototype._onSourceBufferError=function(e){n.default.e(this.TAG,"SourceBuffer Error: "+e)},e}();t["default"]=h},"./src/core/mse-events.js":
|
||
/*!********************************!*\
|
||
!*** ./src/core/mse-events.js ***!
|
||
\********************************/function(e,t,r){"use strict";r.r(t);var i={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};t["default"]=i},"./src/core/transmuxer.js":
|
||
/*!********************************!*\
|
||
!*** ./src/core/transmuxer.js ***!
|
||
\********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),a=r.n(n),o=r(/*! ../utils/logger.js */"./src/utils/logger.js"),l=r(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),d=r(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),h=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),c=r(/*! ./media-info.js */"./src/core/media-info.js"),u=function(){function e(e,t){if(this.TAG="Transmuxer",this._emitter=new(s()),t.enableWorker&&"undefined"!==typeof Worker)try{this._worker=a()(/*! ./transmuxing-worker */"./src/core/transmuxing-worker.js"),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},l.default.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:l.default.getConfig()})}catch(i){o.default.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new d.default(e,t)}else this._controller=new d.default(e,t);if(this._controller){var r=this._controller;r.on(h.default.IO_ERROR,this._onIOError.bind(this)),r.on(h.default.DEMUX_ERROR,this._onDemuxError.bind(this)),r.on(h.default.INIT_SEGMENT,this._onInitSegment.bind(this)),r.on(h.default.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),r.on(h.default.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),r.on(h.default.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),r.on(h.default.MEDIA_INFO,this._onMediaInfo.bind(this)),r.on(h.default.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),r.on(h.default.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),r.on(h.default.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),r.on(h.default.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}return e.prototype.destroy=function(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),l.default.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.hasWorker=function(){return null!=this._worker},e.prototype.open=function(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()},e.prototype.close=function(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()},e.prototype.seek=function(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)},e.prototype.pause=function(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()},e.prototype.resume=function(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()},e.prototype._onInitSegment=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.INIT_SEGMENT,e,t)}))},e.prototype._onMediaSegment=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.MEDIA_SEGMENT,e,t)}))},e.prototype._onLoadingComplete=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(h.default.LOADING_COMPLETE)}))},e.prototype._onRecoveredEarlyEof=function(){var e=this;Promise.resolve().then((function(){e._emitter.emit(h.default.RECOVERED_EARLY_EOF)}))},e.prototype._onMediaInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.MEDIA_INFO,e)}))},e.prototype._onMetaDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.METADATA_ARRIVED,e)}))},e.prototype._onScriptDataArrived=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.SCRIPTDATA_ARRIVED,e)}))},e.prototype._onStatisticsInfo=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.STATISTICS_INFO,e)}))},e.prototype._onIOError=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.IO_ERROR,e,t)}))},e.prototype._onDemuxError=function(e,t){var r=this;Promise.resolve().then((function(){r._emitter.emit(h.default.DEMUX_ERROR,e,t)}))},e.prototype._onRecommendSeekpoint=function(e){var t=this;Promise.resolve().then((function(){t._emitter.emit(h.default.RECOMMEND_SEEKPOINT,e)}))},e.prototype._onLoggingConfigChanged=function(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})},e.prototype._onWorkerMessage=function(e){var t=e.data,r=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case h.default.INIT_SEGMENT:case h.default.MEDIA_SEGMENT:this._emitter.emit(t.msg,r.type,r.data);break;case h.default.LOADING_COMPLETE:case h.default.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case h.default.MEDIA_INFO:Object.setPrototypeOf(r,c.default.prototype),this._emitter.emit(t.msg,r);break;case h.default.METADATA_ARRIVED:case h.default.SCRIPTDATA_ARRIVED:case h.default.STATISTICS_INFO:this._emitter.emit(t.msg,r);break;case h.default.IO_ERROR:case h.default.DEMUX_ERROR:this._emitter.emit(t.msg,r.type,r.info);break;case h.default.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,r);break;case"logcat_callback":o.default.emitter.emit("log",r.type,r.logcat);break;default:break}},e}();t["default"]=u},"./src/core/transmuxing-controller.js":
|
||
/*!********************************************!*\
|
||
!*** ./src/core/transmuxing-controller.js ***!
|
||
\********************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./media-info.js */"./src/core/media-info.js"),l=r(/*! ../demux/flv-demuxer.js */"./src/demux/flv-demuxer.js"),d=r(/*! ../remux/mp4-remuxer.js */"./src/remux/mp4-remuxer.js"),h=r(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),c=r(/*! ../io/io-controller.js */"./src/io/io-controller.js"),u=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),f=function(){function e(e,t){this.TAG="TransmuxingController",this._emitter=new(s()),this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!==typeof e.cors&&(e.cors=!0),"boolean"!==typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;var r=0;this._mediaDataSource.segments.forEach((function(i){i.timestampBase=r,r+=i.duration,i.cors=e.cors,i.withCredentials=e.withCredentials,t.referrerPolicy&&(i.referrerPolicy=t.referrerPolicy)})),isNaN(r)||this._mediaDataSource.duration===r||(this._mediaDataSource.duration=r),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}return e.prototype.destroy=function(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},e.prototype._loadSegment=function(e,t){this._currentSegmentIndex=e;var r=this._mediaDataSource.segments[e],i=this._ioctl=new c.default(r,this._config,e);i.onError=this._onIOException.bind(this),i.onSeeked=this._onIOSeeked.bind(this),i.onComplete=this._onIOComplete.bind(this),i.onRedirect=this._onIORedirect.bind(this),i.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):i.onDataArrival=this._onInitChunkArrival.bind(this),i.open(t)},e.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},e.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},e.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},e.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},e.prototype.seek=function(e){if(null!=this._mediaInfo&&this._mediaInfo.isSeekable()){var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var r=this._mediaInfo.segments[t];if(void 0==r)this._pendingSeekTime=e;else{var i=r.getNearestKeyframe(e);this._remuxer.seek(i.milliseconds),this._ioctl.seek(i.fileposition),this._pendingResolveSeekPoint=i.milliseconds}}else{var s=this._mediaInfo.segments[t];if(void 0==s)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{i=s.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,i.fileposition),this._pendingResolveSeekPoint=i.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}},e.prototype._searchSegmentIndexContains=function(e){for(var t=this._mediaDataSource.segments,r=t.length-1,i=0;i<t.length;i++)if(e<t[i].timestampBase){r=i-1;break}return r},e.prototype._onInitChunkArrival=function(e,t){var r=this,i=null,s=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,s=this._demuxer.parseChunks(e,t);else if((i=l.default.probe(e)).match){this._demuxer=new l.default(i,this._config),this._remuxer||(this._remuxer=new d.default(this._config));var a=this._mediaDataSource;void 0==a.duration||isNaN(a.duration)||(this._demuxer.overridedDuration=a.duration),"boolean"===typeof a.hasAudio&&(this._demuxer.overridedHasAudio=a.hasAudio),"boolean"===typeof a.hasVideo&&(this._demuxer.overridedHasVideo=a.hasVideo),this._demuxer.timestampBase=a.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),s=this._demuxer.parseChunks(e,t)}else i=null,n.default.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then((function(){r._internalAbort()})),this._emitter.emit(u.default.DEMUX_ERROR,h.default.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),s=0;return s},e.prototype._onMediaInfo=function(e){var t=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,o.default.prototype));var r=Object.assign({},e);Object.setPrototypeOf(r,o.default.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=r,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=t._pendingSeekTime;t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(u.default.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(u.default.SCRIPTDATA_ARRIVED,e)},e.prototype._onIOSeeked=function(){this._remuxer.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e,r=t+1;r<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(r)):(this._remuxer.flushStashedSamples(),this._emitter.emit(u.default.LOADING_COMPLETE),this._disableStatisticsReporter())},e.prototype._onIORedirect=function(e){var t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(u.default.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,t){n.default.e(this.TAG,"IOException: type = "+e+", code = "+t.code+", msg = "+t.msg),this._emitter.emit(u.default.IO_ERROR,e,t),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,t){n.default.e(this.TAG,"DemuxException: type = "+e+", info = "+t),this._emitter.emit(u.default.DEMUX_ERROR,e,t)},e.prototype._onRemuxerInitSegmentArrival=function(e,t){this._emitter.emit(u.default.INIT_SEGMENT,e,t)},e.prototype._onRemuxerMediaSegmentArrival=function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(u.default.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var r=t.info.syncPoints,i=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,a.default.safari&&r.length>0&&r[0].originalDts===i&&(i=r[0].pts),this._emitter.emit(u.default.RECOMMEND_SEEKPOINT,i)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],r=Object.assign({},t);r.duration=this._mediaInfo.duration,r.segmentCount=this._mediaInfo.segmentCount,delete r.segments,delete r.keyframesIndex,this._emitter.emit(u.default.MEDIA_INFO,r)},e.prototype._reportStatisticsInfo=function(){var e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(u.default.STATISTICS_INFO,e)},e}();t["default"]=f},"./src/core/transmuxing-events.js":
|
||
/*!****************************************!*\
|
||
!*** ./src/core/transmuxing-events.js ***!
|
||
\****************************************/function(e,t,r){"use strict";r.r(t);var i={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};t["default"]=i},"./src/core/transmuxing-worker.js":
|
||
/*!****************************************!*\
|
||
!*** ./src/core/transmuxing-worker.js ***!
|
||
\****************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logging-control.js */"./src/utils/logging-control.js"),s=r(/*! ../utils/polyfill.js */"./src/utils/polyfill.js"),n=r(/*! ./transmuxing-controller.js */"./src/core/transmuxing-controller.js"),a=r(/*! ./transmuxing-events.js */"./src/core/transmuxing-events.js"),o=function(e){var t=null,r=v.bind(this);function o(t,r){var i={msg:a.default.INIT_SEGMENT,data:{type:t,data:r}};e.postMessage(i,[r.data])}function l(t,r){var i={msg:a.default.MEDIA_SEGMENT,data:{type:t,data:r}};e.postMessage(i,[r.data])}function d(){var t={msg:a.default.LOADING_COMPLETE};e.postMessage(t)}function h(){var t={msg:a.default.RECOVERED_EARLY_EOF};e.postMessage(t)}function c(t){var r={msg:a.default.MEDIA_INFO,data:t};e.postMessage(r)}function u(t){var r={msg:a.default.METADATA_ARRIVED,data:t};e.postMessage(r)}function f(t){var r={msg:a.default.SCRIPTDATA_ARRIVED,data:t};e.postMessage(r)}function p(t){var r={msg:a.default.STATISTICS_INFO,data:t};e.postMessage(r)}function m(t,r){e.postMessage({msg:a.default.IO_ERROR,data:{type:t,info:r}})}function g(t,r){e.postMessage({msg:a.default.DEMUX_ERROR,data:{type:t,info:r}})}function y(t){e.postMessage({msg:a.default.RECOMMEND_SEEKPOINT,data:t})}function v(t,r){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:r}})}s.default.install(),e.addEventListener("message",(function(s){switch(s.data.cmd){case"init":t=new n.default(s.data.param[0],s.data.param[1]),t.on(a.default.IO_ERROR,m.bind(this)),t.on(a.default.DEMUX_ERROR,g.bind(this)),t.on(a.default.INIT_SEGMENT,o.bind(this)),t.on(a.default.MEDIA_SEGMENT,l.bind(this)),t.on(a.default.LOADING_COMPLETE,d.bind(this)),t.on(a.default.RECOVERED_EARLY_EOF,h.bind(this)),t.on(a.default.MEDIA_INFO,c.bind(this)),t.on(a.default.METADATA_ARRIVED,u.bind(this)),t.on(a.default.SCRIPTDATA_ARRIVED,f.bind(this)),t.on(a.default.STATISTICS_INFO,p.bind(this)),t.on(a.default.RECOMMEND_SEEKPOINT,y.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(s.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":var v=s.data.param;i.default.applyConfig(v),!0===v.enableCallback?i.default.addLogListener(r):i.default.removeLogListener(r);break}}))};t["default"]=o},"./src/demux/amf-parser.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/demux/amf-parser.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ../utils/utf8-conv.js */"./src/utils/utf8-conv.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),o=function(){function e(){}return e.parseScriptData=function(t,r,s){var n={};try{var a=e.parseValue(t,r,s),o=e.parseValue(t,r+a.size,s-a.size);n[a.data]=o.data}catch(l){i.default.e("AMF",l.toString())}return n},e.parseObject=function(t,r,i){if(i<3)throw new n.IllegalStateException("Data not enough when parse ScriptDataObject");var s=e.parseString(t,r,i),a=e.parseValue(t,r+s.size,i-s.size),o=a.objectEnd;return{data:{name:s.data,value:a.data},size:s.size+a.size,objectEnd:o}},e.parseVariable=function(t,r,i){return e.parseObject(t,r,i)},e.parseString=function(e,t,r){if(r<2)throw new n.IllegalStateException("Data not enough when parse String");var i,o=new DataView(e,t,r),l=o.getUint16(0,!a);return i=l>0?(0,s.default)(new Uint8Array(e,t+2,l)):"",{data:i,size:2+l}},e.parseLongString=function(e,t,r){if(r<4)throw new n.IllegalStateException("Data not enough when parse LongString");var i,o=new DataView(e,t,r),l=o.getUint32(0,!a);return i=l>0?(0,s.default)(new Uint8Array(e,t+4,l)):"",{data:i,size:4+l}},e.parseDate=function(e,t,r){if(r<10)throw new n.IllegalStateException("Data size invalid when parse Date");var i=new DataView(e,t,r),s=i.getFloat64(0,!a),o=i.getInt16(8,!a);return s+=60*o*1e3,{data:new Date(s),size:10}},e.parseValue=function(t,r,s){if(s<1)throw new n.IllegalStateException("Data not enough when parse Value");var o,l=new DataView(t,r,s),d=1,h=l.getUint8(0),c=!1;try{switch(h){case 0:o=l.getFloat64(1,!a),d+=8;break;case 1:var u=l.getUint8(1);o=!!u,d+=1;break;case 2:var f=e.parseString(t,r+1,s-1);o=f.data,d+=f.size;break;case 3:o={};var p=0;9===(16777215&l.getUint32(s-4,!a))&&(p=3);while(d<s-4){var m=e.parseObject(t,r+d,s-d-p);if(m.objectEnd)break;o[m.data.name]=m.data.value,d+=m.size}if(d<=s-3){var g=16777215&l.getUint32(d-1,!a);9===g&&(d+=3)}break;case 8:o={},d+=4;p=0;9===(16777215&l.getUint32(s-4,!a))&&(p=3);while(d<s-8){var y=e.parseVariable(t,r+d,s-d-p);if(y.objectEnd)break;o[y.data.name]=y.data.value,d+=y.size}if(d<=s-3){g=16777215&l.getUint32(d-1,!a);9===g&&(d+=3)}break;case 9:o=void 0,d=1,c=!0;break;case 10:o=[];var v=l.getUint32(1,!a);d+=4;for(var _=0;_<v;_++){var E=e.parseValue(t,r+d,s-d);o.push(E.data),d+=E.size}break;case 11:var b=e.parseDate(t,r+1,s-1);o=b.data,d+=b.size;break;case 12:var S=e.parseString(t,r+1,s-1);o=S.data,d+=S.size;break;default:d=s,i.default.w("AMF","Unsupported AMF value type "+h)}}catch(T){i.default.e("AMF",T.toString())}return{data:o,size:d,objectEnd:c}},e}();t["default"]=o},"./src/demux/demux-errors.js":
|
||
/*!***********************************!*\
|
||
!*** ./src/demux/demux-errors.js ***!
|
||
\***********************************/function(e,t,r){"use strict";r.r(t);var i={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};t["default"]=i},"./src/demux/exp-golomb.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/demux/exp-golomb.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/exception.js */"./src/utils/exception.js"),s=function(){function e(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}return e.prototype.destroy=function(){this._buffer=null},e.prototype._fillCurrentWord=function(){var e=this._total_bytes-this._buffer_index;if(e<=0)throw new i.IllegalStateException("ExpGolomb: _fillCurrentWord() but no bytes available");var t=Math.min(4,e),r=new Uint8Array(4);r.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(r.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t},e.prototype.readBits=function(e){if(e>32)throw new i.InvalidArgumentException("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}var r=this._current_word_bits_left?this._current_word:0;r>>>=32-this._current_word_bits_left;var s=e-this._current_word_bits_left;this._fillCurrentWord();var n=Math.min(s,this._current_word_bits_left),a=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,r=r<<n|a,r},e.prototype.readBool=function(){return 1===this.readBits(1)},e.prototype.readByte=function(){return this.readBits(8)},e.prototype._skipLeadingZero=function(){var e;for(e=0;e<this._current_word_bits_left;e++)if(0!==(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}();t["default"]=s},"./src/demux/flv-demuxer.js":
|
||
/*!**********************************!*\
|
||
!*** ./src/demux/flv-demuxer.js ***!
|
||
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./amf-parser.js */"./src/demux/amf-parser.js"),n=r(/*! ./sps-parser.js */"./src/demux/sps-parser.js"),a=r(/*! ./demux-errors.js */"./src/demux/demux-errors.js"),o=r(/*! ../core/media-info.js */"./src/core/media-info.js"),l=r(/*! ../utils/exception.js */"./src/utils/exception.js");function d(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}var h=function(){function e(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new o.default,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){var e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}return e.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},e.probe=function(e){var t=new Uint8Array(e),r={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return r;var i=(4&t[4])>>>2!==0,s=0!==(1&t[4]),n=d(t,5);return n<9?r:{match:!0,consumed:n,dataOffset:n,hasAudioTrack:i,hasVideoTrack:s}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new o.default},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(t,r){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new l.IllegalStateException("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var s=0,n=this._littleEndian;if(0===r){if(!(t.byteLength>13))return 0;var a=e.probe(t);s=a.dataOffset}if(this._firstParse){this._firstParse=!1,r+s!==this._dataOffset&&i.default.w(this.TAG,"First time parsing but chunk byteStart invalid!");var o=new DataView(t,s),d=o.getUint32(0,!n);0!==d&&i.default.w(this.TAG,"PrevTagSize0 !== 0 !!!"),s+=4}while(s<t.byteLength){this._dispatch=!0;o=new DataView(t,s);if(s+11+4>t.byteLength)break;var h=o.getUint8(0),c=16777215&o.getUint32(0,!n);if(s+11+c+4>t.byteLength)break;if(8===h||9===h||18===h){var u=o.getUint8(4),f=o.getUint8(5),p=o.getUint8(6),m=o.getUint8(7),g=p|f<<8|u<<16|m<<24,y=16777215&o.getUint32(7,!n);0!==y&&i.default.w(this.TAG,"Meet tag which has StreamID != 0!");var v=s+11;switch(h){case 8:this._parseAudioData(t,v,c,g);break;case 9:this._parseVideoData(t,v,c,g,r+s);break;case 18:this._parseScriptData(t,v,c);break}var _=o.getUint32(11+c,!n);_!==11+c&&i.default.w(this.TAG,"Invalid PrevTagSize "+_),s+=11+c+4}else i.default.w(this.TAG,"Unsupported tag type "+h+", skipped"),s+=11+c+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),s},e.prototype._parseScriptData=function(e,t,r){var n=s.default.parseScriptData(e,t,r);if(n.hasOwnProperty("onMetaData")){if(null==n.onMetaData||"object"!==typeof n.onMetaData)return void i.default.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&i.default.w(this.TAG,"Found another onMetaData tag!"),this._metadata=n;var a=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},a)),"boolean"===typeof a.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=a.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"===typeof a.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=a.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"===typeof a.audiodatarate&&(this._mediaInfo.audioDataRate=a.audiodatarate),"number"===typeof a.videodatarate&&(this._mediaInfo.videoDataRate=a.videodatarate),"number"===typeof a.width&&(this._mediaInfo.width=a.width),"number"===typeof a.height&&(this._mediaInfo.height=a.height),"number"===typeof a.duration){if(!this._durationOverrided){var o=Math.floor(a.duration*this._timescale);this._duration=o,this._mediaInfo.duration=o}}else this._mediaInfo.duration=0;if("number"===typeof a.framerate){var l=Math.floor(1e3*a.framerate);if(l>0){var d=l/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=d,this._referenceFrameRate.fps_num=l,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=d}}if("object"===typeof a.keyframes){this._mediaInfo.hasKeyframesIndex=!0;var h=a.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(h),a.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=a,i.default.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(n).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},n))},e.prototype._parseKeyframesIndex=function(e){for(var t=[],r=[],i=1;i<e.times.length;i++){var s=this._timestampBase+Math.floor(1e3*e.times[i]);t.push(s),r.push(e.filepositions[i])}return{times:t,filepositions:r}},e.prototype._parseAudioData=function(e,t,r,s){if(r<=1)i.default.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");else if(!0!==this._hasAudioFlagOverrided||!1!==this._hasAudio){this._littleEndian;var n=new DataView(e,t,r),o=n.getUint8(0),l=o>>>4;if(2===l||10===l){var d=0,h=(12&o)>>>2;if(h>=0&&h<=4){d=this._flvSoundRateTable[h];var c=1&o,u=this._audioMetadata,f=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),u=this._audioMetadata={},u.type="audio",u.id=f.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=d,u.channelCount=0===c?1:2),10===l){var p=this._parseAACAudioData(e,t+1,r-1);if(void 0==p)return;if(0===p.packetType){u.config&&i.default.w(this.TAG,"Found another AudioSpecificConfig!");var m=p.data;u.audioSampleRate=m.samplingRate,u.channelCount=m.channelCount,u.codec=m.codec,u.originalCodec=m.originalCodec,u.config=m.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,i.default.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",u);var g=this._mediaInfo;g.audioCodec=u.originalCodec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}else if(1===p.packetType){var y=this._timestampBase+s,v={unit:p.data,length:p.data.byteLength,dts:y,pts:y};f.samples.push(v),f.length+=p.data.length}else i.default.e(this.TAG,"Flv: Unsupported AAC data type "+p.packetType)}else if(2===l){if(!u.codec){m=this._parseMP3AudioData(e,t+1,r-1,!0);if(void 0==m)return;u.audioSampleRate=m.samplingRate,u.channelCount=m.channelCount,u.codec=m.codec,u.originalCodec=m.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,i.default.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u);g=this._mediaInfo;g.audioCodec=u.codec,g.audioSampleRate=u.audioSampleRate,g.audioChannelCount=u.channelCount,g.audioDataRate=m.bitRate,g.hasVideo?null!=g.videoCodec&&(g.mimeType='video/x-flv; codecs="'+g.videoCodec+","+g.audioCodec+'"'):g.mimeType='video/x-flv; codecs="'+g.audioCodec+'"',g.isComplete()&&this._onMediaInfo(g)}var _=this._parseMP3AudioData(e,t+1,r-1,!1);if(void 0==_)return;y=this._timestampBase+s;var E={unit:_,length:_.byteLength,dts:y,pts:y};f.samples.push(E),f.length+=_.length}}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+h)}else this._onError(a.default.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+l)}},e.prototype._parseAACAudioData=function(e,t,r){if(!(r<=1)){var s={},n=new Uint8Array(e,t,r);return s.packetType=n[0],0===n[0]?s.data=this._parseAACAudioSpecificConfig(e,t+1,r-1):s.data=n.subarray(1),s}i.default.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,t,r){var i=new Uint8Array(e,t,r),s=null,n=0,o=0,l=0,d=null;if(n=o=i[0]>>>3,l=(7&i[0])<<1|i[1]>>>7,l<0||l>=this._mpegSamplingRates.length)this._onError(a.default.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var h=this._mpegSamplingRates[l],c=(120&i[1])>>>3;if(!(c<0||c>=8)){5===n&&(d=(7&i[1])<<1|i[2]>>>7,(124&i[2])>>>2);var u=self.navigator.userAgent.toLowerCase();return-1!==u.indexOf("firefox")?l>=6?(n=5,s=new Array(4),d=l-3):(n=2,s=new Array(2),d=l):-1!==u.indexOf("android")?(n=2,s=new Array(2),d=l):(n=5,d=l,s=new Array(4),l>=6?d=l-3:1===c&&(n=2,s=new Array(2),d=l)),s[0]=n<<3,s[0]|=(15&l)>>>1,s[1]=(15&l)<<7,s[1]|=(15&c)<<3,5===n&&(s[1]|=(15&d)>>>1,s[2]=(1&d)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:h,channelCount:c,codec:"mp4a.40."+n,originalCodec:"mp4a.40."+o}}this._onError(a.default.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,t,r,s){if(!(r<4)){this._littleEndian;var n=new Uint8Array(e,t,r),a=null;if(s){if(255!==n[0])return;var o=n[1]>>>3&3,l=(6&n[1])>>1,d=(240&n[2])>>>4,h=(12&n[2])>>>2,c=n[3]>>>6&3,u=3!==c?2:1,f=0,p=0,m="mp3";switch(o){case 0:f=this._mpegAudioV25SampleRateTable[h];break;case 2:f=this._mpegAudioV20SampleRateTable[h];break;case 3:f=this._mpegAudioV10SampleRateTable[h];break}switch(l){case 1:34,d<this._mpegAudioL3BitRateTable.length&&(p=this._mpegAudioL3BitRateTable[d]);break;case 2:33,d<this._mpegAudioL2BitRateTable.length&&(p=this._mpegAudioL2BitRateTable[d]);break;case 3:32,d<this._mpegAudioL1BitRateTable.length&&(p=this._mpegAudioL1BitRateTable[d]);break}a={bitRate:p,samplingRate:f,channelCount:u,codec:m,originalCodec:m}}else a=n;return a}i.default.w(this.TAG,"Flv: Invalid MP3 packet, header missing!")},e.prototype._parseVideoData=function(e,t,r,s,n){if(r<=1)i.default.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");else if(!0!==this._hasVideoFlagOverrided||!1!==this._hasVideo){var o=new Uint8Array(e,t,r)[0],l=(240&o)>>>4,d=15&o;7===d?this._parseAVCVideoPacket(e,t+1,r-1,s,n,l):this._onError(a.default.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+d)}},e.prototype._parseAVCVideoPacket=function(e,t,r,s,n,o){if(r<4)i.default.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var l=this._littleEndian,d=new DataView(e,t,r),h=d.getUint8(0),c=16777215&d.getUint32(0,!l),u=c<<8>>8;if(0===h)this._parseAVCDecoderConfigurationRecord(e,t+4,r-4);else if(1===h)this._parseAVCVideoData(e,t+4,r-4,s,n,o,u);else if(2!==h)return void this._onError(a.default.FORMAT_ERROR,"Flv: Invalid video packet type "+h)}},e.prototype._parseAVCDecoderConfigurationRecord=function(e,t,r){if(r<7)i.default.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var s=this._videoMetadata,o=this._videoTrack,l=this._littleEndian,d=new DataView(e,t,r);s?"undefined"!==typeof s.avcc&&i.default.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),s=this._videoMetadata={},s.type="video",s.id=o.id,s.timescale=this._timescale,s.duration=this._duration);var h=d.getUint8(0),c=d.getUint8(1);d.getUint8(2),d.getUint8(3);if(1===h&&0!==c)if(this._naluLengthSize=1+(3&d.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var u=31&d.getUint8(5);if(0!==u){u>1&&i.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+u);for(var f=6,p=0;p<u;p++){var m=d.getUint16(f,!l);if(f+=2,0!==m){var g=new Uint8Array(e,t+f,m);f+=m;var y=n.default.parseSPS(g);if(0===p){s.codecWidth=y.codec_size.width,s.codecHeight=y.codec_size.height,s.presentWidth=y.present_size.width,s.presentHeight=y.present_size.height,s.profile=y.profile_string,s.level=y.level_string,s.bitDepth=y.bit_depth,s.chromaFormat=y.chroma_format,s.sarRatio=y.sar_ratio,s.frameRate=y.frame_rate,!1!==y.frame_rate.fixed&&0!==y.frame_rate.fps_num&&0!==y.frame_rate.fps_den||(s.frameRate=this._referenceFrameRate);var v=s.frameRate.fps_den,_=s.frameRate.fps_num;s.refSampleDuration=s.timescale*(v/_);for(var E=g.subarray(1,4),b="avc1.",S=0;S<3;S++){var T=E[S].toString(16);T.length<2&&(T="0"+T),b+=T}s.codec=b;var L=this._mediaInfo;L.width=s.codecWidth,L.height=s.codecHeight,L.fps=s.frameRate.fps,L.profile=s.profile,L.level=s.level,L.refFrames=y.ref_frames,L.chromaFormat=y.chroma_format_string,L.sarNum=s.sarRatio.width,L.sarDen=s.sarRatio.height,L.videoCodec=b,L.hasAudio?null!=L.audioCodec&&(L.mimeType='video/x-flv; codecs="'+L.videoCodec+","+L.audioCodec+'"'):L.mimeType='video/x-flv; codecs="'+L.videoCodec+'"',L.isComplete()&&this._onMediaInfo(L)}}}var A=d.getUint8(f);if(0!==A){A>1&&i.default.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+A),f++;for(p=0;p<A;p++){m=d.getUint16(f,!l);f+=2,0!==m&&(f+=m)}s.avcc=new Uint8Array(r),s.avcc.set(new Uint8Array(e,t,r),0),i.default.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",s)}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS")}else this._onError(a.default.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));else this._onError(a.default.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord")}},e.prototype._parseAVCVideoData=function(e,t,r,s,n,a,o){var l=this._littleEndian,d=new DataView(e,t,r),h=[],c=0,u=0,f=this._naluLengthSize,p=this._timestampBase+s,m=1===a;while(u<r){if(u+4>=r){i.default.w(this.TAG,"Malformed Nalu near timestamp "+p+", offset = "+u+", dataSize = "+r);break}var g=d.getUint32(u,!l);if(3===f&&(g>>>=8),g>r-f)return void i.default.w(this.TAG,"Malformed Nalus near timestamp "+p+", NaluSize > DataSize!");var y=31&d.getUint8(u+f);5===y&&(m=!0);var v=new Uint8Array(e,t+u,f+g),_={type:y,data:v};h.push(_),c+=v.byteLength,u+=f+g}if(h.length){var E=this._videoTrack,b={units:h,length:c,isKeyframe:m,dts:p,cts:o,pts:p+o};m&&(b.fileposition=n),E.samples.push(b),E.length+=c}},e}();t["default"]=h},"./src/demux/sps-parser.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/demux/sps-parser.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./exp-golomb.js */"./src/demux/exp-golomb.js"),s=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,r=t.byteLength,i=new Uint8Array(r),s=0,n=0;n<r;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(i[s]=t[n],s++);return new Uint8Array(i.buffer,0,s)},e.parseSPS=function(t){var r=e._ebsp2rbsp(t),s=new i.default(r);s.readByte();var n=s.readByte();s.readByte();var a=s.readByte();s.readUEG();var o=e.getProfileString(n),l=e.getLevelString(a),d=1,h=420,c=[0,420,422,444],u=8;if((100===n||110===n||122===n||244===n||44===n||83===n||86===n||118===n||128===n||138===n||144===n)&&(d=s.readUEG(),3===d&&s.readBits(1),d<=3&&(h=c[d]),u=s.readUEG()+8,s.readUEG(),s.readBits(1),s.readBool()))for(var f=3!==d?8:12,p=0;p<f;p++)s.readBool()&&(p<6?e._skipScalingList(s,16):e._skipScalingList(s,64));s.readUEG();var m=s.readUEG();if(0===m)s.readUEG();else if(1===m){s.readBits(1),s.readSEG(),s.readSEG();var g=s.readUEG();for(p=0;p<g;p++)s.readSEG()}var y=s.readUEG();s.readBits(1);var v=s.readUEG(),_=s.readUEG(),E=s.readBits(1);0===E&&s.readBits(1),s.readBits(1);var b=0,S=0,T=0,L=0,A=s.readBool();A&&(b=s.readUEG(),S=s.readUEG(),T=s.readUEG(),L=s.readUEG());var R=1,w=1,k=0,D=!0,I=0,x=0,C=s.readBool();if(C){if(s.readBool()){var P=s.readByte(),O=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],M=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];P>0&&P<16?(R=O[P-1],w=M[P-1]):255===P&&(R=s.readByte()<<8|s.readByte(),w=s.readByte()<<8|s.readByte())}if(s.readBool()&&s.readBool(),s.readBool()&&(s.readBits(4),s.readBool()&&s.readBits(24)),s.readBool()&&(s.readUEG(),s.readUEG()),s.readBool()){var F=s.readBits(32),N=s.readBits(32);D=s.readBool(),I=N,x=2*F,k=I/x}}var B=1;1===R&&1===w||(B=R/w);var U=0,$=0;if(0===d)U=1,$=2-E;else{var G=3===d?1:2,j=1===d?2:1;U=G,$=j*(2-E)}var V=16*(v+1),K=16*(_+1)*(2-E);V-=(b+S)*U,K-=(T+L)*$;var H=Math.ceil(V*B);return s.destroy(),s=null,{profile_string:o,level_string:l,bit_depth:u,ref_frames:y,chroma_format:h,chroma_format_string:e.getChromaFormatString(h),frame_rate:{fixed:D,fps:k,fps_den:x,fps_num:I},sar_ratio:{width:R,height:w},codec_size:{width:V,height:K},present_size:{width:H,height:K}}},e._skipScalingList=function(e,t){for(var r=8,i=8,s=0,n=0;n<t;n++)0!==i&&(s=e.readSEG(),i=(r+s+256)%256),r=0===i?r:i},e.getProfileString=function(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},e.getLevelString=function(e){return(e/10).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},e}();t["default"]=s},"./src/flv.js":
|
||
/*!********************!*\
|
||
!*** ./src/flv.js ***!
|
||
\********************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./utils/polyfill.js */"./src/utils/polyfill.js"),s=r(/*! ./core/features.js */"./src/core/features.js"),n=r(/*! ./io/loader.js */"./src/io/loader.js"),a=r(/*! ./player/flv-player.js */"./src/player/flv-player.js"),o=r(/*! ./player/native-player.js */"./src/player/native-player.js"),l=r(/*! ./player/player-events.js */"./src/player/player-events.js"),d=r(/*! ./player/player-errors.js */"./src/player/player-errors.js"),h=r(/*! ./utils/logging-control.js */"./src/utils/logging-control.js"),c=r(/*! ./utils/exception.js */"./src/utils/exception.js");function u(e,t){var r=e;if(null==r||"object"!==typeof r)throw new c.InvalidArgumentException("MediaDataSource must be an javascript object!");if(!r.hasOwnProperty("type"))throw new c.InvalidArgumentException("MediaDataSource must has type field to indicate video file type!");switch(r.type){case"flv":return new a.default(r,t);default:return new o.default(r,t)}}function f(){return s.default.supportMSEH264Playback()}function p(){return s.default.getFeatureList()}i.default.install();var m={};m.createPlayer=u,m.isSupported=f,m.getFeatureList=p,m.BaseLoader=n.BaseLoader,m.LoaderStatus=n.LoaderStatus,m.LoaderErrors=n.LoaderErrors,m.Events=l.default,m.ErrorTypes=d.ErrorTypes,m.ErrorDetails=d.ErrorDetails,m.FlvPlayer=a.default,m.NativePlayer=o.default,m.LoggingControl=h.default,Object.defineProperty(m,"version",{enumerable:!0,get:function(){return"1.6.2"}}),t["default"]=m},"./src/index.js":
|
||
/*!**********************!*\
|
||
!*** ./src/index.js ***!
|
||
\**********************/function(e,t,r){e.exports=r(/*! ./flv.js */"./src/flv.js").default},"./src/io/fetch-stream-loader.js":
|
||
/*!***************************************!*\
|
||
!*** ./src/io/fetch-stream-loader.js ***!
|
||
\***************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/browser.js */"./src/utils/browser.js"),s=r(/*! ./loader.js */"./src/io/loader.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),o=function(e){function t(t,r){var i=e.call(this,"fetch-stream-loader")||this;return i.TAG="FetchStreamLoader",i._seekHandler=t,i._config=r,i._needStash=!0,i._requestAbort=!1,i._contentLength=null,i._receivedLength=0,i}return a(t,e),t.isSupported=function(){try{var e=i.default.msedge&&i.default.version.minor>=15048,t=!i.default.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(r){return!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){var r=this;this._dataSource=e,this._range=t;var i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);var a=this._seekHandler.getConfig(i,t),o=new self.Headers;if("object"===typeof a.headers){var l=a.headers;for(var d in l)l.hasOwnProperty(d)&&o.append(d,l[d])}var h={method:"GET",headers:o,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"===typeof this._config.headers)for(var d in this._config.headers)o.append(d,this._config.headers[d]);!1===e.cors&&(h.mode="same-origin"),e.withCredentials&&(h.credentials="include"),e.referrerPolicy&&(h.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,h.signal=this._abortController.signal),this._status=s.LoaderStatus.kConnecting,self.fetch(a.url,h).then((function(e){if(r._requestAbort)return r._status=s.LoaderStatus.kIdle,void e.body.cancel();if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==a.url&&r._onURLRedirect){var t=r._seekHandler.removeURLParameters(e.url);r._onURLRedirect(t)}var i=e.headers.get("Content-Length");return null!=i&&(r._contentLength=parseInt(i),0!==r._contentLength&&r._onContentLengthKnown&&r._onContentLengthKnown(r._contentLength)),r._pump.call(r,e.body.getReader())}if(r._status=s.LoaderStatus.kError,!r._onError)throw new n.RuntimeException("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);r._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){if(!r._abortController||!r._abortController.signal.aborted){if(r._status=s.LoaderStatus.kError,!r._onError)throw e;r._onError(s.LoaderErrors.EXCEPTION,{code:-1,msg:e.message})}}))},t.prototype.abort=function(){if(this._requestAbort=!0,(this._status!==s.LoaderStatus.kBuffering||!i.default.chrome)&&this._abortController)try{this._abortController.abort()}catch(e){}},t.prototype._pump=function(e){var t=this;return e.read().then((function(r){if(r.done)if(null!==t._contentLength&&t._receivedLength<t._contentLength){t._status=s.LoaderStatus.kError;var i=s.LoaderErrors.EARLY_EOF,a={code:-1,msg:"Fetch stream meet Early-EOF"};if(!t._onError)throw new n.RuntimeException(a.msg);t._onError(i,a)}else t._status=s.LoaderStatus.kComplete,t._onComplete&&t._onComplete(t._range.from,t._range.from+t._receivedLength-1);else{if(t._abortController&&t._abortController.signal.aborted)return void(t._status=s.LoaderStatus.kComplete);if(!0===t._requestAbort)return t._status=s.LoaderStatus.kComplete,e.cancel();t._status=s.LoaderStatus.kBuffering;var o=r.value.buffer,l=t._range.from+t._receivedLength;t._receivedLength+=o.byteLength,t._onDataArrival&&t._onDataArrival(o,l,t._receivedLength),t._pump(e)}})).catch((function(e){if(t._abortController&&t._abortController.signal.aborted)t._status=s.LoaderStatus.kComplete;else if(11!==e.code||!i.default.msedge){t._status=s.LoaderStatus.kError;var r=0,a=null;if(19!==e.code&&"network error"!==e.message||!(null===t._contentLength||null!==t._contentLength&&t._receivedLength<t._contentLength)?(r=s.LoaderErrors.EXCEPTION,a={code:e.code,msg:e.message}):(r=s.LoaderErrors.EARLY_EOF,a={code:e.code,msg:"Fetch stream meet Early-EOF"}),!t._onError)throw new n.RuntimeException(a.msg);t._onError(r,a)}}))},t}(s.BaseLoader);t["default"]=o},"./src/io/io-controller.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/io/io-controller.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),n=r(/*! ./loader.js */"./src/io/loader.js"),a=r(/*! ./fetch-stream-loader.js */"./src/io/fetch-stream-loader.js"),o=r(/*! ./xhr-moz-chunked-loader.js */"./src/io/xhr-moz-chunked-loader.js"),l=r(/*! ./xhr-range-loader.js */"./src/io/xhr-range-loader.js"),d=r(/*! ./websocket-loader.js */"./src/io/websocket-loader.js"),h=r(/*! ./range-seek-handler.js */"./src/io/range-seek-handler.js"),c=r(/*! ./param-seek-handler.js */"./src/io/param-seek-handler.js"),u=r(/*! ../utils/exception.js */"./src/utils/exception.js"),f=function(){function e(e,t,r){this.TAG="IOController",this._config=t,this._extraData=r,this._stashInitialSize=393216,void 0!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new s.default,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return e.prototype.destroy=function(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},e.prototype.isWorking=function(){return this._loader&&this._loader.isWorking()&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){return this._loader.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){return this._dataSource.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){return null!=this._redirectedURL||void 0!=this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){return this._redirectedURL||this._dataSource.redirectedURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){return this._loaderClass===l.default?this._loader.currentSpeed:this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){return this._loader.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new h.default(this._config.rangeLoadZeroStart);else if("param"===e.seekType){var t=e.seekParamStart||"bstart",r=e.seekParamEnd||"bend";this._seekHandler=new c.default(t,r)}else{if("custom"!==e.seekType)throw new u.InvalidArgumentException("Invalid seekType in config: "+e.seekType);if("function"!==typeof e.customSeekHandler)throw new u.InvalidArgumentException("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=d.default;else if(a.default.isSupported())this._loaderClass=a.default;else if(o.default.isSupported())this._loaderClass=o.default;else{if(!l.default.isSupported())throw new u.RuntimeException("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=l.default}},e.prototype._createLoader=function(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)},e.prototype.open=function(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;var r={from:e,to:-1};this._currentRange={from:r.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,r),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!==typeof e||0===e.length)throw new u.InvalidArgumentException("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){var t=this._stashSize;while(t+1048576<e)t*=2;if(t+=1048576,t!==this._bufferSize){var r=new ArrayBuffer(t);if(this._stashUsed>0){var i=new Uint8Array(this._stashBuffer,0,this._stashUsed),s=new Uint8Array(r,0,t);s.set(i,0)}this._stashBuffer=r,this._bufferSize=t}},e.prototype._normalizeSpeed=function(e){var t=this._speedNormalizeList,r=t.length-1,i=0,s=0,n=r;if(e<t[0])return t[0];while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>=t[i]&&e<t[i+1])return t[i];t[i]<e?s=i+1:n=i-1}},e.prototype._adjustStashSize=function(e){var t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);var r=1024*t+1048576;this._bufferSize<r&&this._expandBuffer(r),this._stashSize=1024*t},e.prototype._dispatchChunks=function(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)},e.prototype._onURLRedirect=function(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)},e.prototype._onContentLengthKnown=function(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)},e.prototype._onLoaderChunkArrival=function(e,t,r){if(!this._onDataArrival)throw new u.IllegalStateException("IOController: No existing consumer (onDataArrival) callback!");if(!this._paused){this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);var i=this._speedSampler.lastSecondKBps;if(0!==i){var s=this._normalizeSpeed(i);this._speedNormalized!==s&&(this._speedNormalized=s,this._adjustStashSize(s))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){l=new Uint8Array(this._stashBuffer,0,this._stashSize);l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{l=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){var n=this._stashBuffer.slice(0,this._stashUsed);a=this._dispatchChunks(n,this._stashByteStart);if(a<n.byteLength){if(a>0){d=new Uint8Array(n,a);l.set(d,0),this._stashUsed=d.byteLength,this._stashByteStart+=a}}else this._stashUsed=0,this._stashByteStart+=a;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),l=new Uint8Array(this._stashBuffer,0,this._bufferSize)),l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{a=this._dispatchChunks(e,t);if(a<e.byteLength){o=e.byteLength-a;o>this._bufferSize&&(this._expandBuffer(o),l=new Uint8Array(this._stashBuffer,0,this._bufferSize)),l.set(new Uint8Array(e,a),0),this._stashUsed+=o,this._stashByteStart=t+a}}}else if(0===this._stashUsed){var a=this._dispatchChunks(e,t);if(a<e.byteLength){var o=e.byteLength-a;o>this._bufferSize&&this._expandBuffer(o);var l=new Uint8Array(this._stashBuffer,0,this._bufferSize);l.set(new Uint8Array(e,a),0),this._stashUsed+=o,this._stashByteStart=t+a}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);var l=new Uint8Array(this._stashBuffer,0,this._bufferSize);l.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;var a=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(a<this._stashUsed&&a>0){var d=new Uint8Array(this._stashBuffer,a);l.set(d,0)}this._stashUsed-=a,this._stashByteStart+=a}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart),s=t.byteLength-r;if(r<t.byteLength){if(!e){if(r>0){var n=new Uint8Array(this._stashBuffer,0,this._bufferSize),a=new Uint8Array(t,r);n.set(a,0),this._stashUsed=a.byteLength,this._stashByteStart+=r}return 0}i.default.w(this.TAG,s+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,s}return 0},e.prototype._onLoaderComplete=function(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,t){switch(i.default.e(this.TAG,"Loader error, code = "+t.code+", msg = "+t.msg),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF),e){case n.LoaderErrors.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var r=this._currentRange.to+1;return void(r<this._totalLength&&(i.default.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(r,!1)))}e=n.LoaderErrors.UNRECOVERABLE_EARLY_EOF;break;case n.LoaderErrors.UNRECOVERABLE_EARLY_EOF:case n.LoaderErrors.CONNECTING_TIMEOUT:case n.LoaderErrors.HTTP_STATUS_CODE_INVALID:case n.LoaderErrors.EXCEPTION:break}if(!this._onError)throw new u.RuntimeException("IOException: "+t.msg);this._onError(e,t)},e}();t["default"]=f},"./src/io/loader.js":
|
||
/*!**************************!*\
|
||
!*** ./src/io/loader.js ***!
|
||
\**************************/function(e,t,r){"use strict";r.r(t),r.d(t,{LoaderStatus:function(){return s},LoaderErrors:function(){return n},BaseLoader:function(){return a}});var i=r(/*! ../utils/exception.js */"./src/utils/exception.js"),s={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},n={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},a=function(){function e(e){this._type=e||"undefined",this._status=s.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=s.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===s.kConnecting||this._status===s.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){throw new i.NotImplementedException("Unimplemented abstract function!")},e.prototype.abort=function(){throw new i.NotImplementedException("Unimplemented abstract function!")},e}()},"./src/io/param-seek-handler.js":
|
||
/*!**************************************!*\
|
||
!*** ./src/io/param-seek-handler.js ***!
|
||
\**************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(e,t){this._startName=e,this._endName=t}return e.prototype.getConfig=function(e,t){var r=e;if(0!==t.from||-1!==t.to){var i=!0;-1===r.indexOf("?")&&(r+="?",i=!1),i&&(r+="&"),r+=this._startName+"="+t.from.toString(),-1!==t.to&&(r+="&"+this._endName+"="+t.to.toString())}return{url:r,headers:{}}},e.prototype.removeURLParameters=function(e){var t=e.split("?")[0],r=void 0,i=e.indexOf("?");-1!==i&&(r=e.substring(i+1));var s="";if(void 0!=r&&r.length>0)for(var n=r.split("&"),a=0;a<n.length;a++){var o=n[a].split("="),l=a>0;o[0]!==this._startName&&o[0]!==this._endName&&(l&&(s+="&"),s+=n[a])}return 0===s.length?t:t+"?"+s},e}();t["default"]=i},"./src/io/range-seek-handler.js":
|
||
/*!**************************************!*\
|
||
!*** ./src/io/range-seek-handler.js ***!
|
||
\**************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(e){this._zeroStart=e||!1}return e.prototype.getConfig=function(e,t){var r={};if(0!==t.from||-1!==t.to){var i=void 0;i=-1!==t.to?"bytes="+t.from.toString()+"-"+t.to.toString():"bytes="+t.from.toString()+"-",r["Range"]=i}else this._zeroStart&&(r["Range"]="bytes=0-");return{url:e,headers:r}},e.prototype.removeURLParameters=function(e){return e},e}();t["default"]=i},"./src/io/speed-sampler.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/io/speed-sampler.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}return e.prototype.reset=function(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0},e.prototype.addBytes=function(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())},Object.defineProperty(e.prototype,"currentKBps",{get:function(){this.addBytes(0);var e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecondKBps",{get:function(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}();t["default"]=i},"./src/io/websocket-loader.js":
|
||
/*!************************************!*\
|
||
!*** ./src/io/websocket-loader.js ***!
|
||
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ./loader.js */"./src/io/loader.js"),s=r(/*! ../utils/exception.js */"./src/utils/exception.js"),n=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),a=function(e){function t(){var t=e.call(this,"websocket-loader")||this;return t.TAG="WebSocketLoader",t._needStash=!0,t._ws=null,t._requestAbort=!1,t._receivedLength=0,t}return n(t,e),t.isSupported=function(){try{return"undefined"!==typeof self.WebSocket}catch(e){return!1}},t.prototype.destroy=function(){this._ws&&this.abort(),e.prototype.destroy.call(this)},t.prototype.open=function(e){try{var t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=i.LoaderStatus.kConnecting}catch(n){this._status=i.LoaderStatus.kError;var r={code:n.code,msg:n.message};if(!this._onError)throw new s.RuntimeException(r.msg);this._onError(i.LoaderErrors.EXCEPTION,r)}},t.prototype.abort=function(){var e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=i.LoaderStatus.kComplete},t.prototype._onWebSocketOpen=function(e){this._status=i.LoaderStatus.kBuffering},t.prototype._onWebSocketClose=function(e){!0!==this._requestAbort?(this._status=i.LoaderStatus.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1},t.prototype._onWebSocketMessage=function(e){var t=this;if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){var r=new FileReader;r.onload=function(){t._dispatchArrayBuffer(r.result)},r.readAsArrayBuffer(e.data)}else{this._status=i.LoaderStatus.kError;var n={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new s.RuntimeException(n.msg);this._onError(i.LoaderErrors.EXCEPTION,n)}},t.prototype._dispatchArrayBuffer=function(e){var t=e,r=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,r,this._receivedLength)},t.prototype._onWebSocketError=function(e){this._status=i.LoaderStatus.kError;var t={code:e.code,msg:e.message};if(!this._onError)throw new s.RuntimeException(t.msg);this._onError(i.LoaderErrors.EXCEPTION,t)},t}(i.BaseLoader);t["default"]=a},"./src/io/xhr-moz-chunked-loader.js":
|
||
/*!******************************************!*\
|
||
!*** ./src/io/xhr-moz-chunked-loader.js ***!
|
||
\******************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./loader.js */"./src/io/loader.js"),n=r(/*! ../utils/exception.js */"./src/utils/exception.js"),a=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),o=function(e){function t(t,r){var i=e.call(this,"xhr-moz-chunked-loader")||this;return i.TAG="MozChunkedLoader",i._seekHandler=t,i._config=r,i._needStash=!0,i._xhr=null,i._requestAbort=!1,i._contentLength=null,i._receivedLength=0,i}return a(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(t){return i.default.w("MozChunkedLoader",t.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},t.prototype.open=function(e,t){this._dataSource=e,this._range=t;var r=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(r=e.redirectedURL);var i=this._seekHandler.getConfig(r,t);this._requestURL=i.url;var n=this._xhr=new XMLHttpRequest;if(n.open("GET",i.url,!0),n.responseType="moz-chunked-arraybuffer",n.onreadystatechange=this._onReadyStateChange.bind(this),n.onprogress=this._onProgress.bind(this),n.onloadend=this._onLoadEnd.bind(this),n.onerror=this._onXhrError.bind(this),e.withCredentials&&(n.withCredentials=!0),"object"===typeof i.headers){var a=i.headers;for(var o in a)a.hasOwnProperty(o)&&n.setRequestHeader(o,a[o])}if("object"===typeof this._config.headers){a=this._config.headers;for(var o in a)a.hasOwnProperty(o)&&n.setRequestHeader(o,a[o])}this._status=s.LoaderStatus.kConnecting,n.send()},t.prototype.abort=function(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=s.LoaderStatus.kComplete},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){var r=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(r)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=s.LoaderStatus.kError,!this._onError)throw new n.RuntimeException("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(s.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=s.LoaderStatus.kBuffering}},t.prototype._onProgress=function(e){if(this._status!==s.LoaderStatus.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,r,this._receivedLength)}},t.prototype._onLoadEnd=function(e){!0!==this._requestAbort?this._status!==s.LoaderStatus.kError&&(this._status=s.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1},t.prototype._onXhrError=function(e){this._status=s.LoaderStatus.kError;var t=0,r=null;if(this._contentLength&&e.loaded<this._contentLength?(t=s.LoaderErrors.EARLY_EOF,r={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=s.LoaderErrors.EXCEPTION,r={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new n.RuntimeException(r.msg);this._onError(t,r)},t}(s.BaseLoader);t["default"]=o},"./src/io/xhr-range-loader.js":
|
||
/*!************************************!*\
|
||
!*** ./src/io/xhr-range-loader.js ***!
|
||
\************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./speed-sampler.js */"./src/io/speed-sampler.js"),n=r(/*! ./loader.js */"./src/io/loader.js"),a=r(/*! ../utils/exception.js */"./src/utils/exception.js"),o=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),l=function(e){function t(t,r){var i=e.call(this,"xhr-range-loader")||this;return i.TAG="RangeLoader",i._seekHandler=t,i._config=r,i._needStash=!1,i._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],i._currentChunkSizeKB=384,i._currentSpeedNormalized=0,i._zeroSpeedChunkCount=0,i._xhr=null,i._speedSampler=new s.default,i._requestAbort=!1,i._waitForTotalLength=!1,i._totalLengthReceived=!1,i._currentRequestURL=null,i._currentRedirectedURL=null,i._currentRequestRange=null,i._totalLength=null,i._contentLength=null,i._receivedLength=0,i._lastTimeLoaded=0,i}return o(t,e),t.isSupported=function(){try{var e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(t){return i.default.w("RangeLoader",t.message),!1}},t.prototype.destroy=function(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),e.prototype.destroy.call(this)},Object.defineProperty(t.prototype,"currentSpeed",{get:function(){return this._speedSampler.lastSecondKBps},enumerable:!1,configurable:!0}),t.prototype.open=function(e,t){this._dataSource=e,this._range=t,this._status=n.LoaderStatus.kConnecting;var r=!1;void 0!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(r=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||r?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))},t.prototype._openSubRange=function(){var e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,r=t+e;null!=this._contentLength&&r-this._range.from>=this._contentLength&&(r=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:r},this._internalOpen(this._dataSource,this._currentRequestRange)},t.prototype._internalOpen=function(e,t){this._lastTimeLoaded=0;var r=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?r=this._currentRedirectedURL:void 0!=e.redirectedURL&&(r=e.redirectedURL));var i=this._seekHandler.getConfig(r,t);this._currentRequestURL=i.url;var s=this._xhr=new XMLHttpRequest;if(s.open("GET",i.url,!0),s.responseType="arraybuffer",s.onreadystatechange=this._onReadyStateChange.bind(this),s.onprogress=this._onProgress.bind(this),s.onload=this._onLoad.bind(this),s.onerror=this._onXhrError.bind(this),e.withCredentials&&(s.withCredentials=!0),"object"===typeof i.headers){var n=i.headers;for(var a in n)n.hasOwnProperty(a)&&s.setRequestHeader(a,n[a])}if("object"===typeof this._config.headers){n=this._config.headers;for(var a in n)n.hasOwnProperty(a)&&s.setRequestHeader(a,n[a])}s.send()},t.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=n.LoaderStatus.kComplete},t.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},t.prototype._onReadyStateChange=function(e){var t=e.target;if(2===t.readyState){if(void 0!=t.responseURL){var r=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&r!==this._currentRedirectedURL&&(this._currentRedirectedURL=r,this._onURLRedirect&&this._onURLRedirect(r))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=n.LoaderStatus.kBuffering}else{if(this._status=n.LoaderStatus.kError,!this._onError)throw new a.RuntimeException("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(n.LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}},t.prototype._onProgress=function(e){if(this._status!==n.LoaderStatus.kError){if(null===this._contentLength){var t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;var r=e.total;this._internalAbort(),null!=r&0!==r&&(this._totalLength=r)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var i=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(i)}},t.prototype._normalizeSpeed=function(e){var t=this._chunkSizeKBList,r=t.length-1,i=0,s=0,n=r;if(e<t[0])return t[0];while(s<=n){if(i=s+Math.floor((n-s)/2),i===r||e>=t[i]&&e<t[i+1])return t[i];t[i]<e?s=i+1:n=i-1}},t.prototype._onLoad=function(e){if(this._status!==n.LoaderStatus.kError)if(this._waitForTotalLength)this._waitForTotalLength=!1;else{this._lastTimeLoaded=0;var t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){var r=this._normalizeSpeed(t);this._currentSpeedNormalized!==r&&(this._currentSpeedNormalized=r,this._currentChunkSizeKB=r)}var i=e.target.response,s=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;var a=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():a=!0,this._onDataArrival&&this._onDataArrival(i,s,this._receivedLength),a&&(this._status=n.LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}},t.prototype._onXhrError=function(e){this._status=n.LoaderStatus.kError;var t=0,r=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=n.LoaderErrors.EARLY_EOF,r={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=n.LoaderErrors.EXCEPTION,r={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new a.RuntimeException(r.msg);this._onError(t,r)},t}(n.BaseLoader);t["default"]=l},"./src/player/flv-player.js":
|
||
/*!**********************************!*\
|
||
!*** ./src/player/flv-player.js ***!
|
||
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ../utils/logger.js */"./src/utils/logger.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ./player-events.js */"./src/player/player-events.js"),l=r(/*! ../core/transmuxer.js */"./src/core/transmuxer.js"),d=r(/*! ../core/transmuxing-events.js */"./src/core/transmuxing-events.js"),h=r(/*! ../core/mse-controller.js */"./src/core/mse-controller.js"),c=r(/*! ../core/mse-events.js */"./src/core/mse-events.js"),u=r(/*! ./player-errors.js */"./src/player/player-errors.js"),f=r(/*! ../config.js */"./src/config.js"),p=r(/*! ../utils/exception.js */"./src/utils/exception.js"),m=function(){function e(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(s()),this._config=(0,f.createDefaultConfig)(),"object"===typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new p.InvalidArgumentException("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var r=a.default.chrome&&(a.default.version.major<50||50===a.default.version.major&&a.default.version.build<2661);this._alwaysSeekKeyframe=!!(r||a.default.msedge||a.default.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var r=this;e===o.default.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){r._emitter.emit(o.default.MEDIA_INFO,r.mediaInfo)})):e===o.default.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){r._emitter.emit(o.default.STATISTICS_INFO,r.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){var t=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new h.default(this._config),this._msectl.on(c.default.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(c.default.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(c.default.SOURCE_OPEN,(function(){t._mseSourceOpened=!0,t._hasPendingLoad&&(t._hasPendingLoad=!1,t.load())})),this._msectl.on(c.default.ERROR,(function(e){t._emitter.emit(o.default.ERROR,u.ErrorTypes.MEDIA_ERROR,u.ErrorDetails.MEDIA_MSE_ERROR,e)})),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(r){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new p.IllegalStateException("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p.IllegalStateException("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new l.default(this._mediaDataSource,this._config),this._transmuxer.on(d.default.INIT_SEGMENT,(function(t,r){e._msectl.appendInitSegment(r)})),this._transmuxer.on(d.default.MEDIA_SEGMENT,(function(t,r){if(e._msectl.appendMediaSegment(r),e._config.lazyLoad&&!e._config.isLive){var i=e._mediaElement.currentTime;r.info.endDts>=1e3*(i+e._config.lazyLoadMaxDuration)&&null==e._progressChecker&&(n.default.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(d.default.LOADING_COMPLETE,(function(){e._msectl.endOfStream(),e._emitter.emit(o.default.LOADING_COMPLETE)})),this._transmuxer.on(d.default.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(o.default.RECOVERED_EARLY_EOF)})),this._transmuxer.on(d.default.IO_ERROR,(function(t,r){e._emitter.emit(o.default.ERROR,u.ErrorTypes.NETWORK_ERROR,t,r)})),this._transmuxer.on(d.default.DEMUX_ERROR,(function(t,r){e._emitter.emit(o.default.ERROR,u.ErrorTypes.MEDIA_ERROR,t,{code:-1,msg:r})})),this._transmuxer.on(d.default.MEDIA_INFO,(function(t){e._mediaInfo=t,e._emitter.emit(o.default.MEDIA_INFO,Object.assign({},t))})),this._transmuxer.on(d.default.METADATA_ARRIVED,(function(t){e._emitter.emit(o.default.METADATA_ARRIVED,t)})),this._transmuxer.on(d.default.SCRIPTDATA_ARRIVED,(function(t){e._emitter.emit(o.default.SCRIPTDATA_ARRIVED,t)})),this._transmuxer.on(d.default.STATISTICS_INFO,(function(t){e._statisticsInfo=e._fillStatisticsInfo(t),e._emitter.emit(o.default.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(d.default.RECOMMEND_SEEKPOINT,(function(t){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=t/1e3)})),this._transmuxer.open()))},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){return Object.assign({},this._mediaInfo)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)},enumerable:!1,configurable:!0}),e.prototype._fillStatisticsInfo=function(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,r=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var s=this._mediaElement.getVideoPlaybackQuality();r=s.totalVideoFrames,i=s.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(r=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=r,e.droppedFrames=i),e},e.prototype._onmseUpdateEnd=function(){if(this._config.lazyLoad&&!this._config.isLive){for(var e=this._mediaElement.buffered,t=this._mediaElement.currentTime,r=0,i=0;i<e.length;i++){var s=e.start(i),a=e.end(i);if(s<=t&&t<a){s,r=a;break}}r>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(n.default.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){n.default.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e=this._mediaElement.currentTime,t=this._mediaElement.buffered,r=!1,i=0;i<t.length;i++){var s=t.start(i),a=t.end(i);if(e>=s&&e<a){e>=a-this._config.lazyLoadRecoverDuration&&(r=!0);break}}r&&(window.clearInterval(this._progressChecker),this._progressChecker=null,r&&(n.default.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))},e.prototype._isTimepointBuffered=function(e){for(var t=this._mediaElement.buffered,r=0;r<t.length;r++){var i=t.start(r),s=t.end(r);if(e>=i&&e<s)return!0}return!1},e.prototype._internalSeek=function(e){var t=this._isTimepointBuffered(e),r=!1,i=0;if(e<1&&this._mediaElement.buffered.length>0){var s=this._mediaElement.buffered.start(0);(s<1&&e<s||a.default.safari)&&(r=!0,i=a.default.safari?.1:s)}if(r)this._requestSetTime=!0,this._mediaElement.currentTime=i;else if(t){if(this._alwaysSeekKeyframe){var n=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=n?n.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)},e.prototype._checkAndApplyUnbufferedSeekpoint=function(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){var e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)},e.prototype._checkAndResumeStuckPlayback=function(e){var t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){var r=t.buffered;r.length>0&&t.currentTime<r.start(0)&&(n.default.w(this.TAG,"Playback seems stuck at "+t.currentTime+", seek to "+r.start(0)),this._requestSetTime=!0,this._mediaElement.currentTime=r.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)},e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)},e.prototype._onvSeeking=function(e){var t=this._mediaElement.currentTime,r=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&r.length>0){var i=r.start(0);if(i<1&&t<i||a.default.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=a.default.safari?.1:i)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){var s=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=s&&(this._requestSetTime=!0,this._mediaElement.currentTime=s.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}},e.prototype._onvCanPlay=function(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)},e.prototype._onvStalled=function(e){this._checkAndResumeStuckPlayback(!0)},e.prototype._onvProgress=function(e){this._checkAndResumeStuckPlayback()},e}();t["default"]=m},"./src/player/native-player.js":
|
||
/*!*************************************!*\
|
||
!*** ./src/player/native-player.js ***!
|
||
\*************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ./player-events.js */"./src/player/player-events.js"),a=r(/*! ../config.js */"./src/config.js"),o=r(/*! ../utils/exception.js */"./src/utils/exception.js"),l=function(){function e(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(s()),this._config=(0,a.createDefaultConfig)(),"object"===typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new o.InvalidArgumentException("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new o.InvalidArgumentException("NativePlayer("+e.type+") doesn't support multipart playback!");this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}return e.prototype.destroy=function(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,t){var r=this;e===n.default.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){r._emitter.emit(n.default.MEDIA_INFO,r.mediaInfo)})):e===n.default.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then((function(){r._emitter.emit(n.default.STATISTICS_INFO,r.statisticsInfo)})),this._emitter.addListener(e,t)},e.prototype.off=function(e,t){this._emitter.removeListener(e,t)},e.prototype.attachMediaElement=function(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}},e.prototype.detachMediaElement=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.load=function(){if(!this._mediaElement)throw new o.IllegalStateException("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){return this._mediaElement.play()},e.prototype.pause=function(){this._mediaElement.pause()},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buffered",{get:function(){return this._mediaElement.buffered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._mediaElement.duration},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._mediaElement.volume},set:function(e){this._mediaElement.volume=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"muted",{get:function(){return this._mediaElement.muted},set:function(e){this._mediaElement.muted=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){return this._mediaElement?this._mediaElement.currentTime:0},set:function(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mediaInfo",{get:function(){var e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statisticsInfo",{get:function(){var e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;var t=!0,r=0,i=0;if(this._mediaElement.getVideoPlaybackQuality){var s=this._mediaElement.getVideoPlaybackQuality();r=s.totalVideoFrames,i=s.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(r=this._mediaElement.webkitDecodedFrameCount,i=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=r,e.droppedFrames=i),e},enumerable:!1,configurable:!0}),e.prototype._onvLoadedMetadata=function(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(n.default.MEDIA_INFO,this.mediaInfo)},e.prototype._reportStatisticsInfo=function(){this._emitter.emit(n.default.STATISTICS_INFO,this.statisticsInfo)},e}();t["default"]=l},"./src/player/player-errors.js":
|
||
/*!*************************************!*\
|
||
!*** ./src/player/player-errors.js ***!
|
||
\*************************************/function(e,t,r){"use strict";r.r(t),r.d(t,{ErrorTypes:function(){return n},ErrorDetails:function(){return a}});var i=r(/*! ../io/loader.js */"./src/io/loader.js"),s=r(/*! ../demux/demux-errors.js */"./src/demux/demux-errors.js"),n={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},a={NETWORK_EXCEPTION:i.LoaderErrors.EXCEPTION,NETWORK_STATUS_CODE_INVALID:i.LoaderErrors.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:i.LoaderErrors.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:i.LoaderErrors.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:s.default.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:s.default.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:s.default.CODEC_UNSUPPORTED}},"./src/player/player-events.js":
|
||
/*!*************************************!*\
|
||
!*** ./src/player/player-events.js ***!
|
||
\*************************************/function(e,t,r){"use strict";r.r(t);var i={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};t["default"]=i},"./src/remux/aac-silent.js":
|
||
/*!*********************************!*\
|
||
!*** ./src/remux/aac-silent.js ***!
|
||
\*********************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.getSilentFrame=function(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])}return null},e}();t["default"]=i},"./src/remux/mp4-generator.js":
|
||
/*!************************************!*\
|
||
!*** ./src/remux/mp4-generator.js ***!
|
||
\************************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.init=function(){for(var t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=e.constants={};r.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),r.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),r.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),r.STSC=r.STCO=r.STTS,r.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),r.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),r.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),r.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=8,r=null,i=Array.prototype.slice.call(arguments,1),s=i.length,n=0;n<s;n++)t+=i[n].byteLength;r=new Uint8Array(t),r[0]=t>>>24&255,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r.set(e,4);var a=8;for(n=0;n<s;n++)r.set(i[n],a),a+=i[n].byteLength;return r},e.generateInitSegment=function(t){var r=e.box(e.types.ftyp,e.constants.FTYP),i=e.moov(t),s=new Uint8Array(r.byteLength+i.byteLength);return s.set(r,0),s.set(i,r.byteLength),s},e.moov=function(t){var r=e.mvhd(t.timescale,t.duration),i=e.trak(t),s=e.mvex(t);return e.box(e.types.moov,r,i,s)},e.mvhd=function(t,r){return e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,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]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var r=t.id,i=t.duration,s=t.presentWidth,n=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>>8&255,255&s,0,0,n>>>8&255,255&n,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var r=t.timescale,i=t.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))},e.hdlr=function(t){var r=null;return r="audio"===t.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,r)},e.minf=function(t){var r=null;return r="audio"===t.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,r,e.dinf(),e.stbl(t))},e.dinf=function(){var t=e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF));return t},e.stbl=function(t){var r=e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO));return r},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var r=t.channelCount,i=t.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types[".mp3"],s)},e.mp4a=function(t){var r=t.channelCount,i=t.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types.mp4a,s,e.esds(t))},e.esds=function(t){var r=t.config||[],i=r.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(r).concat([6,1,2]));return e.box(e.types.esds,s)},e.avc1=function(t){var r=t.avcc,i=t.codecWidth,s=t.codecHeight,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,s>>>8&255,255&s,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,n,e.box(e.types.avcC,r))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var r=t.id,i=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,i)},e.moof=function(t,r){return e.box(e.types.moof,e.mfhd(t.sequenceNumber),e.traf(t,r))},e.mfhd=function(t){var r=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t]);return e.box(e.types.mfhd,r)},e.traf=function(t,r){var i=t.id,s=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),n=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r])),a=e.sdtp(t),o=e.trun(t,a.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,s,n,o,a)},e.sdtp=function(t){for(var r=t.samples||[],i=r.length,s=new Uint8Array(4+i),n=0;n<i;n++){var a=r[n].flags;s[n+4]=a.isLeading<<6|a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return e.box(e.types.sdtp,s)},e.trun=function(t,r){var i=t.samples||[],s=i.length,n=12+16*s,a=new Uint8Array(n);r+=8+n,a.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var o=0;o<s;o++){var l=i[o].duration,d=i[o].size,h=i[o].flags,c=i[o].cts;a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.isNonSync,0,0,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o)}return e.box(e.types.trun,a)},e.mdat=function(t){return e.box(e.types.mdat,t)},e}();i.init(),t["default"]=i},"./src/remux/mp4-remuxer.js":
|
||
/*!**********************************!*\
|
||
!*** ./src/remux/mp4-remuxer.js ***!
|
||
\**********************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger.js */"./src/utils/logger.js"),s=r(/*! ./mp4-generator.js */"./src/remux/mp4-generator.js"),n=r(/*! ./aac-silent.js */"./src/remux/aac-silent.js"),a=r(/*! ../utils/browser.js */"./src/utils/browser.js"),o=r(/*! ../core/media-segment-info.js */"./src/core/media-segment-info.js"),l=r(/*! ../utils/exception.js */"./src/utils/exception.js"),d=function(){function e(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new o.MediaSegmentInfoList("audio"),this._videoSegmentInfoList=new o.MediaSegmentInfoList("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!a.default.chrome||!(a.default.version.major<50||50===a.default.version.major&&a.default.version.build<2661)),this._fillSilentAfterSeek=a.default.msedge||a.default.msie,this._mp3UseMpegAudio=!a.default.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,t){if(!this._onMediaSegment)throw new l.IllegalStateException("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,t){var r=null,i="mp4",n=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(i="mpeg",n="",r=new Uint8Array):r=s.default.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,r=s.default.generateInitSegment(t)}if(!this._onInitSegment)throw new l.IllegalStateException("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:r.buffer,codec:n,container:e+"/"+i,mediaDuration:t.duration})},e.prototype._calculateDtsBase=function(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,t=this._audioStashedLastSample,r={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(r.samples.push(e),r.length=e.length);var i={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(i.samples.push(t),i.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(r,!0),this._remuxAudio(i,!0)},e.prototype._remuxAudio=function(e,t){if(null!=this._audioMeta){var r=e,l=r.samples,d=void 0,h=-1,c=-1,u=this._audioMeta.refSampleDuration,f="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,p=this._dtsBaseInited&&void 0===this._audioNextDts,m=!1;if(l&&0!==l.length&&(1!==l.length||t)){var g=0,y=null,v=0;f?(g=0,v=r.length):(g=8,v=8+r.length);var _=null;if(l.length>1&&(_=l.pop(),v-=_.length),null!=this._audioStashedLastSample){var E=this._audioStashedLastSample;this._audioStashedLastSample=null,l.unshift(E),v+=E.length}null!=_&&(this._audioStashedLastSample=_);var b=l[0].dts-this._dtsBase;if(this._audioNextDts)d=b-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())d=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(m=!0);else{var S=this._audioSegmentInfoList.getLastSampleBefore(b);if(null!=S){var T=b-(S.originalDts+S.duration);T<=3&&(T=0);var L=S.dts+S.duration+T;d=b-L}else d=0}if(m){var A=b-d,R=this._videoSegmentInfoList.getLastSegmentBefore(b);if(null!=R&&R.beginDts<A){var w=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(w){var k=R.beginDts,D=A-R.beginDts;i.default.v(this.TAG,"InsertPrefixSilentAudio: dts: "+k+", duration: "+D),l.unshift({unit:w,dts:k,pts:k}),v+=w.byteLength}}else m=!1}for(var I=[],x=0;x<l.length;x++){E=l[x];var C=E.unit,P=E.dts-this._dtsBase,O=(k=P,!1),M=null,F=0;if(!(P<-.001)){if("mp3"!==this._audioMeta.codec){var N=P,B=3;if(this._audioNextDts&&(N=this._audioNextDts),d=P-N,d<=-B*u){i.default.w(this.TAG,"Dropping 1 audio frame (originalDts: "+P+" ms ,curRefDts: "+N+" ms) due to dtsCorrection: "+d+" ms overlap.");continue}if(d>=B*u&&this._fillAudioTimestampGap&&!a.default.safari){O=!0;var U=Math.floor(d/u);i.default.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\noriginalDts: "+P+" ms, curRefDts: "+N+" ms, dtsCorrection: "+Math.round(d)+" ms, generate: "+U+" frames"),k=Math.floor(N),F=Math.floor(N+u)-k;w=n.default.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==w&&(i.default.w(this.TAG,"Unable to generate silent frame for "+this._audioMeta.originalCodec+" with "+this._audioMeta.channelCount+" channels, repeat last frame"),w=C),M=[];for(var $=0;$<U;$++){N+=u;var G=Math.floor(N),j=Math.floor(N+u)-G,V={dts:G,pts:G,cts:0,unit:w,size:w.byteLength,duration:j,originalDts:P,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};M.push(V),v+=V.size}this._audioNextDts=N+u}else k=Math.floor(N),F=Math.floor(N+u)-k,this._audioNextDts=N+u}else{if(k=P-d,x!==l.length-1){var K=l[x+1].dts-this._dtsBase-d;F=K-k}else if(null!=_){K=_.dts-this._dtsBase-d;F=K-k}else F=I.length>=1?I[I.length-1].duration:Math.floor(u);this._audioNextDts=k+F}-1===h&&(h=k),I.push({dts:k,pts:k,cts:0,unit:E.unit,size:E.unit.byteLength,duration:F,originalDts:P,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),O&&I.push.apply(I,M)}}if(0===I.length)return r.samples=[],void(r.length=0);f?y=new Uint8Array(v):(y=new Uint8Array(v),y[0]=v>>>24&255,y[1]=v>>>16&255,y[2]=v>>>8&255,y[3]=255&v,y.set(s.default.types.mdat,4));for(x=0;x<I.length;x++){C=I[x].unit;y.set(C,g),g+=C.byteLength}var H=I[I.length-1];c=H.dts+H.duration;var Y=new o.MediaSegmentInfo;Y.beginDts=h,Y.endDts=c,Y.beginPts=h,Y.endPts=c,Y.originalBeginDts=I[0].originalDts,Y.originalEndDts=H.originalDts+H.duration,Y.firstSample=new o.SampleInfo(I[0].dts,I[0].pts,I[0].duration,I[0].originalDts,!1),Y.lastSample=new o.SampleInfo(H.dts,H.pts,H.duration,H.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(Y),r.samples=I,r.sequenceNumber++;var z=null;z=f?new Uint8Array:s.default.moof(r,h),r.samples=[],r.length=0;var q={type:"audio",data:this._mergeBoxes(z,y).buffer,sampleCount:I.length,info:Y};f&&p&&(q.timestampOffset=h),this._onMediaSegment("audio",q)}}},e.prototype._remuxVideo=function(e,t){if(null!=this._videoMeta){var r=e,i=r.samples,n=void 0,a=-1,l=-1,d=-1,h=-1;if(i&&0!==i.length&&(1!==i.length||t)){var c=8,u=null,f=8+e.length,p=null;if(i.length>1&&(p=i.pop(),f-=p.length),null!=this._videoStashedLastSample){var m=this._videoStashedLastSample;this._videoStashedLastSample=null,i.unshift(m),f+=m.length}null!=p&&(this._videoStashedLastSample=p);var g=i[0].dts-this._dtsBase;if(this._videoNextDts)n=g-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())n=0;else{var y=this._videoSegmentInfoList.getLastSampleBefore(g);if(null!=y){var v=g-(y.originalDts+y.duration);v<=3&&(v=0);var _=y.dts+y.duration+v;n=g-_}else n=0}for(var E=new o.MediaSegmentInfo,b=[],S=0;S<i.length;S++){m=i[S];var T=m.dts-this._dtsBase,L=m.isKeyframe,A=T-n,R=m.cts,w=A+R;-1===a&&(a=A,d=w);var k=0;if(S!==i.length-1){var D=i[S+1].dts-this._dtsBase-n;k=D-A}else if(null!=p){D=p.dts-this._dtsBase-n;k=D-A}else k=b.length>=1?b[b.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(L){var I=new o.SampleInfo(A,w,k,m.dts,!0);I.fileposition=m.fileposition,E.appendSyncPoint(I)}b.push({dts:A,pts:w,cts:R,units:m.units,size:m.length,isKeyframe:L,duration:k,originalDts:T,flags:{isLeading:0,dependsOn:L?2:1,isDependedOn:L?1:0,hasRedundancy:0,isNonSync:L?0:1}})}u=new Uint8Array(f),u[0]=f>>>24&255,u[1]=f>>>16&255,u[2]=f>>>8&255,u[3]=255&f,u.set(s.default.types.mdat,4);for(S=0;S<b.length;S++){var x=b[S].units;while(x.length){var C=x.shift(),P=C.data;u.set(P,c),c+=P.byteLength}}var O=b[b.length-1];if(l=O.dts+O.duration,h=O.pts+O.duration,this._videoNextDts=l,E.beginDts=a,E.endDts=l,E.beginPts=d,E.endPts=h,E.originalBeginDts=b[0].originalDts,E.originalEndDts=O.originalDts+O.duration,E.firstSample=new o.SampleInfo(b[0].dts,b[0].pts,b[0].duration,b[0].originalDts,b[0].isKeyframe),E.lastSample=new o.SampleInfo(O.dts,O.pts,O.duration,O.originalDts,O.isKeyframe),this._isLive||this._videoSegmentInfoList.append(E),r.samples=b,r.sequenceNumber++,this._forceFirstIDR){var M=b[0].flags;M.dependsOn=2,M.isNonSync=0}var F=s.default.moof(r,a);r.samples=[],r.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(F,u).buffer,sampleCount:b.length,info:E})}}},e.prototype._mergeBoxes=function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(e,0),r.set(t,e.byteLength),r},e}();t["default"]=d},"./src/utils/browser.js":
|
||
/*!******************************!*\
|
||
!*** ./src/utils/browser.js ***!
|
||
\******************************/function(e,t,r){"use strict";r.r(t);var i={};function s(){var e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],r=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],s={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:r[0]||""},n={};if(s.browser){n[s.browser]=!0;var a=s.majorVersion.split(".");n.version={major:parseInt(s.majorVersion,10),string:s.version},a.length>1&&(n.version.minor=parseInt(a[1],10)),a.length>2&&(n.version.build=parseInt(a[2],10))}if(s.platform&&(n[s.platform]=!0),(n.chrome||n.opr||n.safari)&&(n.webkit=!0),n.rv||n.iemobile){n.rv&&delete n.rv;var o="msie";s.browser=o,n[o]=!0}if(n.edge){delete n.edge;var l="msedge";s.browser=l,n[l]=!0}if(n.opr){var d="opera";s.browser=d,n[d]=!0}if(n.safari&&n.android){var h="android";s.browser=h,n[h]=!0}for(var c in n.name=s.browser,n.platform=s.platform,i)i.hasOwnProperty(c)&&delete i[c];Object.assign(i,n)}s(),t["default"]=i},"./src/utils/exception.js":
|
||
/*!********************************!*\
|
||
!*** ./src/utils/exception.js ***!
|
||
\********************************/function(e,t,r){"use strict";r.r(t),r.d(t,{RuntimeException:function(){return s},IllegalStateException:function(){return n},InvalidArgumentException:function(){return a},NotImplementedException:function(){return o}});var i=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),s=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),n=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!1,configurable:!0}),t}(s),a=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!1,configurable:!0}),t}(s),o=function(e){function t(t){return e.call(this,t)||this}return i(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!1,configurable:!0}),t}(s)},"./src/utils/logger.js":
|
||
/*!*****************************!*\
|
||
!*** ./src/utils/logger.js ***!
|
||
\*****************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=function(){function e(){}return e.e=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",i),e.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))},e.i=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),e.ENABLE_INFO&&(console.info?console.info(i):console.log(i))},e.w=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),e.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))},e.d=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",i),e.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))},e.v=function(t,r){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var i="["+t+"] > "+r;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",i),e.ENABLE_VERBOSE&&console.log(i)},e}();n.GLOBAL_TAG="flv.js",n.FORCE_GLOBAL_TAG=!1,n.ENABLE_ERROR=!0,n.ENABLE_INFO=!0,n.ENABLE_WARN=!0,n.ENABLE_DEBUG=!0,n.ENABLE_VERBOSE=!0,n.ENABLE_CALLBACK=!1,n.emitter=new(s()),t["default"]=n},"./src/utils/logging-control.js":
|
||
/*!**************************************!*\
|
||
!*** ./src/utils/logging-control.js ***!
|
||
\**************************************/function(e,t,r){"use strict";r.r(t);var i=r(/*! events */"./node_modules/events/events.js"),s=r.n(i),n=r(/*! ./logger.js */"./src/utils/logger.js"),a=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return n.default.FORCE_GLOBAL_TAG},set:function(t){n.default.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return n.default.GLOBAL_TAG},set:function(t){n.default.GLOBAL_TAG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return n.default.ENABLE_VERBOSE&&n.default.ENABLE_DEBUG&&n.default.ENABLE_INFO&&n.default.ENABLE_WARN&&n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_VERBOSE=t,n.default.ENABLE_DEBUG=t,n.default.ENABLE_INFO=t,n.default.ENABLE_WARN=t,n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return n.default.ENABLE_DEBUG},set:function(t){n.default.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return n.default.ENABLE_VERBOSE},set:function(t){n.default.ENABLE_VERBOSE=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return n.default.ENABLE_INFO},set:function(t){n.default.ENABLE_INFO=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return n.default.ENABLE_WARN},set:function(t){n.default.ENABLE_WARN=t,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return n.default.ENABLE_ERROR},set:function(t){n.default.ENABLE_ERROR=t,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:n.default.GLOBAL_TAG,forceGlobalTag:n.default.FORCE_GLOBAL_TAG,enableVerbose:n.default.ENABLE_VERBOSE,enableDebug:n.default.ENABLE_DEBUG,enableInfo:n.default.ENABLE_INFO,enableWarn:n.default.ENABLE_WARN,enableError:n.default.ENABLE_ERROR,enableCallback:n.default.ENABLE_CALLBACK}},e.applyConfig=function(e){n.default.GLOBAL_TAG=e.globalTag,n.default.FORCE_GLOBAL_TAG=e.forceGlobalTag,n.default.ENABLE_VERBOSE=e.enableVerbose,n.default.ENABLE_DEBUG=e.enableDebug,n.default.ENABLE_INFO=e.enableInfo,n.default.ENABLE_WARN=e.enableWarn,n.default.ENABLE_ERROR=e.enableError,n.default.ENABLE_CALLBACK=e.enableCallback},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var r=e.getConfig();t.emit("change",r)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){n.default.emitter.addListener("log",t),n.default.emitter.listenerCount("log")>0&&(n.default.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){n.default.emitter.removeListener("log",t),0===n.default.emitter.listenerCount("log")&&(n.default.ENABLE_CALLBACK=!1,e._notifyChange())},e}();a.emitter=new(s()),t["default"]=a},"./src/utils/polyfill.js":
|
||
/*!*******************************!*\
|
||
!*** ./src/utils/polyfill.js ***!
|
||
\*******************************/function(e,t,r){"use strict";r.r(t);var i=function(){function e(){}return e.install=function(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var i=arguments[r];if(void 0!==i&&null!==i)for(var s in i)i.hasOwnProperty(s)&&(t[s]=i[s])}return t},"function"!==typeof self.Promise&&r(/*! es6-promise */"./node_modules/es6-promise/dist/es6-promise.js").polyfill()},e}();i.install(),t["default"]=i},"./src/utils/utf8-conv.js":
|
||
/*!********************************!*\
|
||
!*** ./src/utils/utf8-conv.js ***!
|
||
\********************************/function(e,t,r){"use strict";function i(e,t,r){var i=e;if(t+r<i.length){while(r--)if(128!==(192&i[++t]))return!1;return!0}return!1}function s(e){var t=[],r=e,s=0,n=e.length;while(s<n)if(r[s]<128)t.push(String.fromCharCode(r[s])),++s;else{if(r[s]<192);else if(r[s]<224){if(i(r,s,1)){var a=(31&r[s])<<6|63&r[s+1];if(a>=128){t.push(String.fromCharCode(65535&a)),s+=2;continue}}}else if(r[s]<240){if(i(r,s,2)){a=(15&r[s])<<12|(63&r[s+1])<<6|63&r[s+2];if(a>=2048&&55296!==(63488&a)){t.push(String.fromCharCode(65535&a)),s+=3;continue}}}else if(r[s]<248&&i(r,s,3)){a=(7&r[s])<<18|(63&r[s+1])<<12|(63&r[s+2])<<6|63&r[s+3];if(a>65536&&a<1114112){a-=65536,t.push(String.fromCharCode(a>>>10|55296)),t.push(String.fromCharCode(1023&a|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}r.r(t),t["default"]=s}},r={};function i(t){var s=r[t];if(void 0!==s)return s.exports;var n=r[t]={exports:{}};return e[t].call(n.exports,n,n.exports,i),n.exports}i.m=e,function(){i.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return i.d(t,{a:t}),t}}(),function(){i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}}(),function(){i.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}();var s=i("./src/index.js");return s}()}))}).call(this,r("4362"))}}]); |