@castlabs/prestoplay 6.26.0 → 6.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +114 -113
  6. package/cjs/cl.conviva.js +29 -29
  7. package/cjs/cl.core.js +620 -621
  8. package/cjs/cl.crypto.js +7 -7
  9. package/cjs/cl.dash.js +84 -84
  10. package/cjs/cl.externs.js +83 -51
  11. package/cjs/cl.freewheel.js +25 -25
  12. package/cjs/cl.hls.js +79 -77
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +23 -23
  15. package/cjs/cl.ima.js +24 -24
  16. package/cjs/cl.mediatailor.js +3 -3
  17. package/cjs/cl.mse.js +350 -342
  18. package/cjs/cl.muxdata.js +15 -15
  19. package/cjs/cl.onboard.js +3 -3
  20. package/cjs/cl.persistent.js +15 -15
  21. package/cjs/cl.playlist.js +6 -6
  22. package/cjs/cl.sessions.js +16 -16
  23. package/cjs/cl.simid.js +17 -17
  24. package/cjs/cl.smooth.js +67 -67
  25. package/cjs/cl.thumbnails.js +26 -26
  26. package/cjs/cl.tizen.js +69 -68
  27. package/cjs/cl.ttml.js +29 -29
  28. package/cjs/cl.verimatrix.js +5 -5
  29. package/cjs/cl.vimond.js +12 -12
  30. package/cjs/cl.vr.js +19 -19
  31. package/cjs/cl.vtt.js +14 -14
  32. package/cjs/cl.yospace.js +4 -4
  33. package/cjs/cl.youbora.js +37 -37
  34. package/cjs/polyfill.min.js +15 -3
  35. package/cl.adobe.js +3 -3
  36. package/cl.airplay.js +3 -3
  37. package/cl.broadpeak.js +5 -5
  38. package/cl.cast.js +92 -90
  39. package/cl.conviva.js +27 -27
  40. package/cl.core.js +498 -503
  41. package/cl.crypto.js +9 -9
  42. package/cl.dash.js +82 -82
  43. package/cl.externs.js +83 -51
  44. package/cl.freewheel.js +19 -19
  45. package/cl.hls.js +80 -79
  46. package/cl.hlssmpte.js +5 -5
  47. package/cl.htmlcue.js +26 -26
  48. package/cl.ima.js +17 -17
  49. package/cl.mediatailor.js +3 -3
  50. package/cl.mse.js +305 -301
  51. package/cl.muxdata.js +13 -13
  52. package/cl.onboard.js +4 -4
  53. package/cl.persistent.js +11 -11
  54. package/cl.playlist.js +5 -5
  55. package/cl.sessions.js +10 -10
  56. package/cl.simid.js +14 -14
  57. package/cl.smooth.js +60 -60
  58. package/cl.thumbnails.js +19 -19
  59. package/cl.tizen.js +57 -57
  60. package/cl.ttml.js +22 -22
  61. package/cl.verimatrix.js +4 -4
  62. package/cl.vimond.js +8 -8
  63. package/cl.vr.js +15 -15
  64. package/cl.vtt.js +12 -12
  65. package/cl.yospace.js +3 -3
  66. package/cl.youbora.js +29 -29
  67. package/package.json +1 -1
  68. package/typings.d.ts +83 -0
package/cl.freewheel.js CHANGED
@@ -1,19 +1,19 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var aV="clpp-freewheel",bV="clpp.freewheel.AdsManagerFactory",cV="freewheel",dV=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},eV=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Pf&&b.push("serverUrl");typeof a.profileId!==_.Pf&&b.push("profileId");typeof a.videoAssetId!==_.Pf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
- if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},fV=function(){return _.x(function*(){var a=new _.Kv;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},gV=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.ag,a.I.bind(a));a.j.on(a.m,_.Mf,a.H.bind(a))},jV=function(a){return _.x(function*(){a.G.length?(hV(a),a.f=a.G.shift(),a.f.play()):(iV(a),yield a.m.a.play())})},iV=function(a){const b=a.m.kd(cV).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},hV=function(a){const b=a.m.kd(cV).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(aV),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},kV=function(a){a.F.length?(hV(a),a.f=a.F.shift(),a.f.play()):iV(a)},lV=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.F(b,d))},mV=class extends _.Sv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.rp(_.Cd,{id:aV}),this.f=_.rp(_.w,{"class":_.Zc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return cV}Pc(){return this.a}xh(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",mV);mV.prototype.getAdVideo=mV.prototype.xh;mV.prototype.getAdContainer=mV.prototype.Pc;mV.Id=cV;mV.AD_CONTAINER_ID=aV;_.Mr(new class{create(){return new mV}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}ob(){return"FreeWheel AdManager SDK"}pb(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Pf?a:""}Qb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getPosition(){return 0}getSkipTimeOffset(){return 0}Tb(){return!1}qb(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}fb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}eb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Qa(){return 0}Ra(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
- case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Ra()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Hb(){switch(this.Ra()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}sb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}gb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
8
- Y.prototype.getVideoElement=Y.prototype.Sb;Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.canSeek=Y.prototype.canSeek;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.gb;Y.prototype.getPositionInSequence=Y.prototype.sb;Y.prototype.getPodTimeOffset=Y.prototype.Hb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Ra;
9
- Y.prototype.getMediaBitrate=Y.prototype.Qa;Y.prototype.getMediaHeight=Y.prototype.eb;Y.prototype.getMediaWidth=Y.prototype.fb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.qb;Y.prototype.isBumper=Y.prototype.Tb;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getPosition=Y.prototype.getPosition;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;
10
- Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;Y.prototype.getSourceId=Y.prototype.Qb;Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.ub;Y.prototype.getAdManagerVersion=Y.prototype.pb;Y.prototype.getAdManagerName=Y.prototype.ob;var nV=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Kb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- nV.prototype.hasPostroll=nV.prototype.Jb;nV.prototype.hasPreroll=nV.prototype.Kb;nV.prototype.getCuePoints=nV.prototype.getCuePoints;var oV=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Rt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.Ij;this.w=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{eV(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Pf&&typeof b.siteSectionId!==
12
- _.t||a.a.setSiteSection(b.siteSectionId);const c=yield fV();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,dV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ee&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
13
- if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);gV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.x(function*(){yield jV(a)})}o(){}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}l(){return!0}h(){const a=this;return _.x(function*(){a.j.release();
14
- a.w&&(a.w.stop(),a.w=null);iV(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.F(_.pc,{adsTimeline:new nV(this.a)})),this.w=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.kd(cV).f);else this.m.onError(new _.I(1,
15
- 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){lV(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;lV(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:jV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:iV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:kV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:lV(this,_.hc,a);lV(this,
16
- _.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:lV(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:lV(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:lV(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:lV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:lV(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:lV(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:lV(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:lV(this,
17
- _.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:lV(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:lV(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:lV(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();hV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Zo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Yo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Oo:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);kV(this);break;case _.Wo:case _.Po:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- oV.prototype.getPosition=oV.prototype.getPosition;oV.prototype.setVolume=oV.prototype.setVolume;oV.prototype.getVolume=oV.prototype.getVolume;oV.prototype.skip=oV.prototype.skip;oV.prototype.pause=oV.prototype.pause;oV.prototype.resume=oV.prototype.resume;_.pp(new class{constructor(){this.Ta=new _.T(bV)}name(){return bV}a(a,b){return a.namespace()!==_.dd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ta.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new oV(a)}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var bV="clpp-freewheel",cV="clpp.freewheel.AdsManagerFactory",dV="freewheel",eV=function(a){switch(a){case 0:return tv.freewheel.SDK.ADUNIT_PREROLL;case 1:return tv.freewheel.SDK.ADUNIT_MIDROLL;case 2:return tv.freewheel.SDK.ADUNIT_POSTROLL;default:return""}},fV=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Qf&&b.push("serverUrl");typeof a.profileId!==_.Qf&&b.push("profileId");typeof a.videoAssetId!==_.Qf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},gV=function(){return _.w(function*(){var a=new _.Av;let b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_NONE;const c=yield a.canPlay(!1);a=yield a.canPlay(!0);c?b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_ATTENDED:a&&(b=tv.freewheel.SDK.VIDEO_ASSET_AUTO_PLAY_TYPE_UNATTENDED);return b})},hV=function(a){a.j.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.K.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.M.bind(a));a.j.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.L.bind(a));a.j.on(a.a,tv.freewheel.SDK.EVENT_AD,a.J.bind(a));a.j.on(a.m,_.cg,a.I.bind(a));a.j.on(a.m,_.Nf,a.H.bind(a))},kV=function(a){return _.w(function*(){a.G.length?(iV(a),a.f=a.G.shift(),a.f.play()):(jV(a),yield a.m.a.play())})},jV=function(a){const b=a.m.cd(dV).Ic();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},iV=function(a){const b=a.m.cd(dV).Ic();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(bV),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},lV=function(a){a.F.length?(iV(a),a.f=a.F.shift(),a.f.play()):jV(a)},mV=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.C(b,d))},nV=class extends _.Iv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Lp(_.Dd,{id:bV}),this.f=_.Lp(_.t,{"class":_.Zc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return dV}Ic(){return this.a}oh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",nV);nV.prototype.getAdVideo=nV.prototype.oh;nV.prototype.getAdContainer=nV.prototype.Ic;nV.Id=dV;nV.AD_CONTAINER_ID=bV;_.fs(new class{create(){return new nV}});var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}kb(){return"FreeWheel AdManager SDK"}lb(){return tv.freewheel.SDK.version}rb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Qf?a:""}Mb(){return""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getPosition(){return 0}getSkipTimeOffset(){return 0}Pb(){return!1}nb(){return this.a&&this.a.getEventCallbackUrls(tv.freewheel.SDK.EVENT_AD_CLICK,tv.freewheel.SDK.EVENT_TYPE_CLICK)[0]||""}getMediaUrl(){return this.a?this.a.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl():""}bb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ab(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Na(){return 0}Oa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Oa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Eb(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}pb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}cb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Ob(){return null}};
8
+ X.prototype.getVideoElement=X.prototype.Ob;X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.canSeek=X.prototype.canSeek;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.cb;X.prototype.getPositionInSequence=X.prototype.pb;X.prototype.getPodTimeOffset=X.prototype.Eb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Oa;
9
+ X.prototype.getMediaBitrate=X.prototype.Na;X.prototype.getMediaHeight=X.prototype.ab;X.prototype.getMediaWidth=X.prototype.bb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.nb;X.prototype.isBumper=X.prototype.Pb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getPosition=X.prototype.getPosition;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;
10
+ X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;X.prototype.getSourceId=X.prototype.Mb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.rb;X.prototype.getAdManagerVersion=X.prototype.lb;X.prototype.getAdManagerName=X.prototype.kb;var oV=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Gb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ oV.prototype.hasPostroll=oV.prototype.Fb;oV.prototype.hasPreroll=oV.prototype.Gb;oV.prototype.getCuePoints=oV.prototype.getCuePoints;var pV=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Kt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.xk;this.w=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{fV(b)}catch(d){return a.m.onError(d),a.A.resolve(),a.A}a.C.setNetwork(b.networkId);a.C.setServer(b.serverUrl);a.a=a.C.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Qf&&typeof b.siteSectionId!==
12
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield gV();a.a.setVideoAsset(b.videoAssetId,a.m.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,eV(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Fe&&Object.keys(b.keyValues).forEach(d=>a.a.addKeyValue(d,b.keyValues[d]));a.a.setParameter(tv.freewheel.SDK.PARAMETER_EXTENSION_CONTENT_VIDEO_ENABLED,!1,tv.freewheel.SDK.PARAMETER_LEVEL_GLOBAL);
13
+ if(Array.isArray(b.parameters))for(const d of b.parameters)a.a.setParameter(d.name,d.value,d.level);hV(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.w(function*(){yield kV(a)})}o(){}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}l(){return!0}h(){const a=this;return _.w(function*(){a.j.release();
14
+ a.w&&(a.w.stop(),a.w=null);jV(a);a.a&&(a.a.dispose(),a.a=null)})}K(a){if(a.success)this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.F=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.C(_.pc,{adsTimeline:new oV(this.a)})),this.w=new _.yv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.cd(dV).f);else this.m.onError(new _.I(1,
15
+ 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){mV(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;mV(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:kV(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:jV(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:lV(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:mV(this,_.kc,a);mV(this,
16
+ _.ac,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:mV(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:mV(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:mV(this,_.cc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:mV(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:mV(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:mV(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:mV(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:mV(this,
17
+ _.fc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:mV(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:mV(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:mV(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.I(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}I(){if(!this.f){var a=this.m.getPosition();if(this.f=this.B.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.B.findIndex(c=>c===this.f);this.B.splice(b,1);this.m.pause();iV(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.sp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.rp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.hp:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);lV(this);break;case _.pp:case _.ip:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ pV.prototype.getPosition=pV.prototype.getPosition;pV.prototype.setVolume=pV.prototype.setVolume;pV.prototype.getVolume=pV.prototype.getVolume;pV.prototype.skip=pV.prototype.skip;pV.prototype.pause=pV.prototype.pause;pV.prototype.resume=pV.prototype.resume;_.Jp(new class{constructor(){this.Qa=new _.S(cV)}name(){return cV}a(a,b){return a.namespace()!==_.ed&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Qa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new pV(a)}});};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,79 +1,80 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var NJ="CLOSED-CAPTIONS",OJ="Could not parse MP4 segment start time.",PJ="DURATION",QJ="EXT-X-DATERANGE",RJ="EXT-X-DISCONTINUITY",SJ="EXT-X-KEY",TJ="EXT-X-MAP",UJ="EXT-X-MEDIA",VJ="EXT-X-MEDIA-SEQUENCE",WJ="EXT-X-STREAM-INF",XJ="Failed to infer discontinuity number",YJ="Guessing audio-only",ZJ="METHOD",$J="SAMPLE-AES-CTR",aK="SUBTITLES",bK="application/vnd.apple.mpegurl",cK="manifestloaded",dK="sample",eK=function(a,b){return _.J(a,b,void 0,{required:!0})},fK=function(a){if(1>a.a)throw _.dm();
2
- --a.a},gK=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ee&&e&&typeof e===_.Ee){if(!gK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},hK=function(a,b){if(!gK(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ee&&e&&typeof e===_.Ee&&hK(d,e))return!0}return!1},iK=function(a){if(null!==a&&void 0!==a)return Number(a)},jK=function(a,b){return a.filter(c=>c.name===b)},kK=function(a){const b=
3
- /^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Ta),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.G,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.G,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},lK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=eK(d,
4
- _.sb);return c.includes(d)})},mK=function(a,b){return a.some(c=>c.name===b)},nK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.G,4,4024,{missingTag:b});return a},oK=function(a){var b=nK(a,"EXT-X-TILES");if(!b)return{nd:1,Kd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,PJ);a=_.yC(a);return{nd:a.nd,Kd:a.Kd,durationPerTile:b?Number(b):null}},pK=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});
5
- a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},qK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pK(c))b(d,c)})},rK=function(a){return a.some(b=>mK(b.ha,"EXT-X-ENDLIST"))},sK=function(a){return a.type===_.p||a.type===_.w},tK=function(a){if(nK(a,"EXT-X-ENDLIST"))return _.Db;a=nK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.I(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);
6
- },uK=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vK=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.G,4,4044,"Invalid byte range, offset is required but missing.");
7
- if(null==b)throw new _.I(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ma:d,ja:e}},wK=function(a,b){a=nK(a,"EXT-X-BYTERANGE");return vK(a?a.value:null,b)},xK=function(a){a=nK(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},yK=function(a,b){b=void 0===b?{}:b;const c={Lf:!1,gh:!1,hh:null,Nh:null,ug:null};a=nK(a,"EXT-X-SERVER-CONTROL",{required:b.Ag});if(!a)return c;const d=e=>null==e?null:Number(e);
8
- c.Lf="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.gh="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.hh=d(_.J(a,"CAN-SKIP-UNTIL"));c.Nh=d(_.J(a,"HOLD-BACK"));c.ug=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.Ag}));return c},zK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return vK(a,b,c)},AK=function(a){const b=jK(a,UJ),c=jK(a,WJ);a=jK(a,"EXT-X-IMAGE-STREAM-INF");return{Bc:{Gf:lK(b,[_.uB,_.Cb]),closedCaptions:lK(b,NJ),Gi:lK(b,aK)},Ld:c,He:a}},CK=function(a,b){const c=wK(a.ha,null);return new BK(0,0,0,()=>
9
- [a.a],c.ma,c.ja,0,b)},DK=function(a){let b=Infinity,c=Infinity;pK(a).filter(sK).forEach(d=>{{d=d.U;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Vc:b,duration:c}},EK=function(a){return a.map(b=>{({duration:b}=DK(b));return b}).reduce((b,c)=>b+c,0)},FK=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},GK=function(a,b,c,d,e){if(b===_.Db)return{delay:0,Jd:0};b=nK(a,"EXT-X-PART-INF");if(c&&b){e=Number(eK(b,"PART-TARGET"));
10
- if(null!=d)return{delay:d,Jd:e};({ug:d}=yK(a,{Ag:!0}));return{delay:d,Jd:e}}a=nK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Jd:e}:{delay:3*a,Jd:e}},IK=function(a){const b=new Map;a.forEach(c=>{var d=`${HK(c).type}:${HK(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},JK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.La);a=_.Di(a||_.fg);const d=eK(c,_.Fa),e=eK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,
11
- a)}return b},KK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},LK=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>HK(d).Da===c)||null},MK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},NK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{fg:b,item:d,ji:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{fg:b,ji:c,item:d,next:void 0})},OK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},PK=function(a,b){const c=new Map,d=new URL(b);
12
- a.forEach(e=>{var f=_.J(e,_.Ta),g=_.J(e,"QUERYPARAM");if(f)g=eK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.G,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.G,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},QK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.G,4,4044,`Undefined variable '${d}'`);return c})},
13
- RK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=QK(d.value,b)})})},UK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=SK(a,b[e]);d.push(f);if(f.name===WJ){const g=b[e+1];if(!g)throw new _.I(_.G,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.kj(_.ub,g));e++}}b=jK(d,"EXT-X-DEFINE");kK(b);b=PK(b,c);a.a=b;RK(d,a.a);return new TK(c,0,d)},YK=function(a,b,c){const {vi:d,Kh:e,Pi:f}=VK(b),g=WK(a,f,c);b=e.map(k=>SK(a,k,g));const h=XK(a,c,d,g);return new TK(c,
14
- 1,b,h)},ZK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.G,4,4015);b=b.slice(1);return 0===OK(b)?UK(a,b,c):YK(a,b,c)},VK=function(a){const b=[],c=[],d=[];for(const e of a)$K.test(e)?d.push(e):aL.test(e)?c.push(e):b.push(e);return{vi:b,Kh:c,Pi:d}},WK=function(a,b,c){b=b.map(e=>SK(a,e));kK(b);const d=PK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.G,
15
- 4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},SK=function(a,b,c){a=_.mj(a.h++,b);c&&RK([a],c);return a},XK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=SK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.sb)?g.push(h):f.push(h)):(mK(f,"EXT-X-GAP")||(h=QK(h,d),h=_.ij(h,b),e.push(new bL(h,f,g))),f=[],g=[])});0<g.length&&e.push(new bL(null,f,g));return e},cL=function(a,b,c){const d=
16
- [],e=[];e.push(new _.kj(_.la,"0"));e.push(new _.kj(_.ub,b));c.length&&e.push(new _.kj(_.pa,c));d.push(new _.lj(a.h++,WJ,e));return new TK(b,0,d)},dL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},eL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},fL=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},gL=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+
17
- ("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.G,4,4030);}fL(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|
18
- a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}fL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},hL=function(a,b){let c=null,d=0;try{(new _.tm).N(_.Ae,_.mm).N(_.cg,_.mm).N(_.re,_.mm).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Mv.error("Unable to find timescale in init segment!"),new _.I(_.G,4,4030,OJ,c);let e=0,f=!1;try{(new _.tm).N("moof",_.mm).N("traf",_.mm).ea("tfdt",g=>{var h=d;if(0===g.version)h=
19
- _.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.G,4,4030,OJ,c);return e},iL=function(a){for(;a.getPosition()<a.Pa()-1;){const b=a.getPosition();if(71===_.em(a))return fK(a),b}return-1},jL=function(a){function b(){d.seek(e+188);f=_.em(d);71!==f&&
20
- (d.seek(e+192),f=_.em(d));71!==f&&(d.seek(e+204),f=_.em(d));71!==f&&c();fK(d)}function c(){throw new _.I(_.G,4,4030);}const d=new _.pn(new DataView(a),!1);let e=0,f=0;e=iL(d);0>e&&(_.Mv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.em(d);71!==f&&c();a=_.fm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.em(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.em(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.em(d)>>6;0!==a&&1!==a||c();
21
- 0===_.em(d)&&c();a=_.em(d);const g=_.fm(d),h=_.fm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},mL=function(a){const b=kL(a),c=lL(a);a.forEach(d=>{const e=d.U,f=e.findIndex(h=>h.ra===b);let g=e.findIndex(h=>h.ra===c+1);-1===g&&(g=e.length);d.U=e.slice(f,g)})},lL=function(a){a=a.map(b=>b.U[b.U.length-1].ra);return Math.min(...a)},kL=function(a){a=a.map(b=>b.U[0].ra);return Math.max(...a)},pL=function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("PlayReady in HLS is only supported with [",
22
- nL.join(", "),"], not",b),null;a=eK(a,_.ub);b=_.zt(a);a=null;b=_.K(b.data);try{a=_.gC(_.wn(b))}catch(c){a=b}return _.uC(_.rd,[{initDataType:_.Uc,initData:a}],"")},rL=function(a){if(0===a.length)return qL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.De))return a[0];a=a.filter(c=>c.type===dK);const b=_.fi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:dK,drmInfos:b}},uL=function(a,b){return sL(a).map(c=>tL(c.ha,b)).filter(Boolean)},sL=function(a){return a.filter(b=>
23
- mK(b.ha,SJ))},tL=function(a,b){a=jK(a,SJ).filter(d=>"AES-128"!==eK(d,ZJ));if(0===a.length)return null;var c=eK(a[0],ZJ);if(1===a.length&&"NONE"===c)return qL();c=a.map(d=>eK(d,ZJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===$J))throw vL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=wL[e]||null;d=f?f(d,b):null}d||vL.warn("Unsupported HLS KEYFORMAT",
24
- e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.G,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:dK,drmInfos:a}},qL=function(){return{type:_.De,drmInfos:[],keyId:null}},xL=function(a,b,c){a=jK(a,SJ)[0];if(!a||"AES-128"!==eK(a,ZJ))return null;var d=_.J(a,"IV","");d?c={iv:_.Pl((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Sl(new Uint8Array(12),eL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
25
- generatedIv:f}=c;return{method:"AES-128",url:_.ij(eK(a,_.ub),b),iv:e,generatedIv:f}},yL=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.bD(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.bD(b.Ea(),b.ma,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
26
- e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.G,4,4030,"Failed to fetch the media segment.");}}})},zL=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Bc){var g=yield yL(a,c,f);g=_.K(g.data);if(!fL(g))throw new _.I(_.G,4,4030,"AAC segment does not contain an ID3 tag.");return gL(g)}if(d===_.rg||d===
27
- _.Gc)return g=[yL(a,c,f)],b&&g.push(yL(a,b,!0)),g=yield Promise.all(g),hL(g[0].data,(g[1]||g[0]).data);if(d===_.qg)return g=yield yL(a,c,f),jL(g.data);if(!_.Ks(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.G,4,4030);})},AL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},BL=function(a,b){a=a.streams.find(c=>{c=c.U;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.U.find(c=>c.position===b)||null},HK=function(a){return a.streams[0]},
28
- CL=function(a,b){a.streams.forEach(c=>{c.se=b})},DL=function(a,b){a.streams.forEach(c=>{c.width=b})},EL=function(a,b){a.streams.forEach(c=>{c.height=b})},FL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},GL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},HL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},IL=function(a,b){const c=new Set(a.map(d=>d.ra));return b.filter(d=>!c.has(d.ra))},KL=function(a,b){for(;a[0].ra<b[0].ra;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
29
- d.startTime&&c.endTime===d.endTime||JL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&JL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},PL=function(a,b,c,d,e){var f=b[0].length();f=dL(f).map(g=>{var h=HL(b,g)||[];const k=AL(c,g)||[];g=AL(d,g)||[];{const l=[...LL(h),...k,...g].filter(Boolean);ML(l);const {ra:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ra:m}}return h});e&&NL(f[0]);
30
- OL(f);return f},LL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},NL=function(a){const b=LL(a.variants)[0].U[0].Ca;a.startTime+=b;a.endTime+=b},OL=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},JL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;QL(a.variants,b.variants);RL(pK(a),pK(b))},QL=function(a,b){const c=new Map(a.map(d=>[FK(d),
31
- d]));b.forEach(d=>{c.get(FK(d)).drmInfos=d.drmInfos})},RL=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.U=d.U;d.U.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.U);e.Vc=d.Vc;e.Le=d.Le;e.duration=d.duration;e.Tf=d.Tf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},ML=function(a){const b=SL(a);a.forEach(c=>{_.YC(c.segmentIndex,b);c.duration=b;c.Le=c.Vc+b})},SL=function(a){let b=Infinity;a.filter(sK).forEach(c=>{b=
32
- Math.min(b,c.duration)});return b},TL=function(a,b){qK(b,(c,d)=>{_.kD(a,c.U,d.startTime)});_.cD(a.a,b[0].startTime,b[b.length-1].endTime)},UL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},VL=function(a,b){return _.x(function*(){var c=_.sj([b],a.a.attemptParameters);c.type=1;c=yield a.H(c);let d="";try{d=_.Si(c.data)}catch(e){throw new _.I(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},fM=function(a,b){return _.x(function*(){var c=
33
- WL(a,b,a.w,"");if(1===c.type){var d=c.U[0].a;c=XL(d);if(!c)throw new _.I(_.G,4,4021,`Unknown file extension ${d}`);d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");c=cL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=AK(c.ha);c=YL(d.Bc.Gf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield ZL(a,d);var f=e.Xh;const g=e.periods;var h=e.li;const k=e.Ii;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.G,7,7001);$L(a,g);h=aM(a,f.delay,g,h);bM(a)||(a.G=f.Jd,
34
- cM(a));dM(a,h,g);f=eM(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},hM=function(a,b){return Promise.all(b.map(c=>gM(a,c)))},jM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!bM(a),f=nK(c.ha,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].U,f=f[f.length-1].ra):
35
- f=0;if(e&&0<f)try{{const k=nK(c.ha,VJ);if(!k)throw iM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(XJ);const l=Number(k.value),m=BL(d,l);if(!m)throw iM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(XJ);var h=m.ra}g=h;break a}catch(k){throw new _.I(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=
36
- c.U||[];for(const k of c)mK(k.ha,RJ)&&g++,k.ra=g});mL(b)},mM=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,ah:e}=yield kM(a,b);var f=a.f.periods[0].variants;a.a.lowLatencyMode&&null!==a.o&&(f=f.filter(g=>g.id===a.o.id));f=f.map(g=>{const h=LK(g.audio,e),k=LK(g.video,e);g=lM(a,h,k,g.bandwidth);if(!g)throw new _.I(_.G,4,4047,{message:"Video and audio are encrypted in an incompatible way.",rj:k?HK(k).Da:void 0,audio:h?HK(h).Da:void 0});return g});return PL(a.D.configurationId,
37
- f,c,d,!0)})},$L=function(a,b){bM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.xE(b,-a.I))},nM=function(a,b){b=b.flatMap(d=>d.U[0].ha);b=nK(b,"EXT-X-PROGRAM-DATE-TIME");if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},oM=function(a,b,c){b=b.find(d=>null!==nK(d.ha,QJ));if(!b)return[];if(null===c)throw new _.I(_.G,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");
38
- return b.ha.filter(d=>d.name===QJ).map(d=>{a:{var e=a.C,f=!bM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.nu.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);f=k.getTime()/1E3+e;g={id:g,startTime:f,startDate:k,pe:h};h=iK(_.J(d,PJ));void 0!==h&&0<=h&&(g.duration=h);var l=iK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=
39
- m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var q=null;else{k={};for(q of v)q.name.trim().startsWith("X-")&&(k[q.name]=q.value);q=_.ah(k)?k:null}}q=q||{};(k=_.J(d,"CUE"))&&(q.CUE=k.split(","));if(_.Bi(m)){k=d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Lb:m[_.Lb]=u.value;break;case _.Kb:m[_.Kb]=u.value;break;case _.Qb:m[_.Qb]=iK(u.value);break;case _.Mb:m[_.Mb]=iK(u.value);break;
40
- case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Nb:m[_.Nb]=u.value.split(",")}m[_.Lb]&&m[_.Kb]||!m[_.Lb]&&!m[_.Kb]?(_.nu.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.ah(m)?m:null}if(null===u){_.nu.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",d);d=null;break a}q=Object.assign(q,u)}_.ah(q)&&(g.customAttributes=q);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Sh;d=g}}return d}).filter(Boolean)},eM=function(a,
41
- b){const c=new Set(b.map(d=>d.id));a.B.forEach((d,e)=>{c.has(e)||a.B.delete(e)});for(const d of b){if((b=a.B.get(d.id))&&b.pe!==d.pe)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,pe:d.pe,endTime:d.endTime,id:d.id,type:_.Sh,eventElement:null};b&&!hK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},pM=function(a,b,
42
- c){a.A=_.Db;_.gD(b,!0);b.f=c[c.length-1].endTime},WL=function(a,b,c,d){a=ZK(a.R,b,c);a.verbatimUri=d;return a},YL=function(a){return a.filter(b=>b.name===UJ&&_.J(b,_.sb)===_.uB&&!_.J(b,_.ub)).map(b=>{const c=MK(b),d=_.J(b,_.La)||_.fg;return{groupId:eK(b,_.Fa),id:_.xJ++,label:eK(b,_.Ta),language:d,channelsCount:c,primary:"YES"===_.J(b,"DEFAULT")}})},ZL=function(a,b){return _.x(function*(){var c=JK(b.Bc.closedCaptions),d=qM(a,b.Ld),e=yield rM(a,b),f=Object.values(e).flat().map(h=>h.playlist);jM(a,f);
43
- f=f[0];var g=tK(f.ha);a.A=g;a.K=yK(f.ha);f=GK(f.ha,g,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield sM(a,e.Hf,d);c=yield tM(a,e.Ld,g,c);d=yield uM(a,e.Fi,d);g=yield vM(a,e.He);d=PL(a.D.configurationId,c,d,g,!bM(a));a.D.filterAllPeriods(d);c=[...e.Ld,...e.Hf].map(h=>h.playlist);e=nM(a,c);c=oM(a,c,e);return{periods:d,li:e,Ii:c,Xh:f}})},aM=function(a,b,c,d){let e=!0,f=null,g=0;bM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.AJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);
44
- _.gD(a,e);TL(a,c);d&&_.fD(a,d);return a},cM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Vc);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.Vc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},dM=function(a,b,c){c=EK(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,
45
- b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Db&&(b.f=c)},kM=function(a,b){return _.x(function*(){const c=g=>HK(g.stream).type===_.w||HK(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=HK(h.stream);k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Da,
46
- Md:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return wM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);xM(a,d.concat(f));e=f.filter(g=>HK(g).type===_.$B);f=f.filter(g=>HK(g).type===_.ce);return{textStreams:e,thumbStreams:f,ah:d}})},lM=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.AC(l.drmInfos,m.drmInfos)?_.zC(l.drmInfos,m.drmInfos):
47
- null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.fg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new yM(f)},wM=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Tc,g=b.ic,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,q=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Md,A=_.Di(f||_.fg);if(1!==c.type)throw new _.I(_.G,
48
- 4,4017);const D=yield zM(a,c,e,d),E=a.a.lowLatencyMode?_.RB:_.QB;let oa=m;e!==_.H||m||(oa=_.$B);const te=tK(c.ha);m=D.map(ic=>{const Ob=ic.U,Xd=ic.nh,Pb=ic.mimeType,jc=ic.ra,kc=Ob[0].startTime,Gb=Ob[Ob.length-1].endTime,hb=Gb-kc,ua=new _.BJ(Ob),zb=Ob[0].initSegment||null;return{id:null===g?_.xJ++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ua.f.bind(ua),getSegmentReference:ua.get.bind(ua),adjustSegmentDurations:ua.h.bind(ua),getDuration:ua.getDuration.bind(ua),
49
- segmentIndex:ua,segmentLookupStrategy:E,initSegmentReference:zb,mimeType:Pb,codecs:d,kind:oa,Tf:Xd.type,encrypted:Xd.type===dK,aesEncrypted:ic.aesEncrypted,keyId:Xd.keyId,language:A,originalLanguage:f||_.fg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:q,spatialAudio:u,closedCaptions:v,U:Ob,drmInfos:Xd.drmInfos,ra:jc,Da:c.verbatimUri,se:c.a,Vc:kc,Le:Gb,duration:hb,
50
- groupId:h,ij:te,muxedAudioId:k}});return new AM(m)})},xM=function(a,b){b.forEach(c=>{a.j.a.set(HK(c).Da,c)})},qM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.uB);b=_.J(f,_.Cb);var e=_.J(f,aK);const g=BM(a,f);if(e){const h=_.dk(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=CM(_.p,g),c.set(`${"audio"}:${d}`,e));b&&(d=CM(_.w,g),c.set(`${"video"}:${b}`,d))}return c},rM=function(a,b){return _.x(function*(){const c=yield Promise.all([DM(a,b.Bc.Gf),DM(a,b.Bc.Gi),
51
- DM(a,b.Ld),DM(a,b.He)]),[d,e,f,g]=c;return{Hf:d,Fi:e,Ld:f,He:g}})},sM=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[EM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>EM(a,e,c)));d=yield Promise.all(d);return IK(d)})},tM=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(eK(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield FM(a,h,c,d,e);f=f.map(k=>FM(a,k,c,d,e));f=yield Promise.all(f);
52
- f.splice(g,0,h);return f.reduce(_.rC,[])})},uM=function(a,b,c){return Promise.all(b.map(d=>EM(a,d,c)))},vM=function(a,b){return Promise.all(b.map(c=>GM(a,c)))},HM=function(a,b){return _.x(function*(){const c=_.ij(b.verbatimUri,a.w),{response:d,text:e}=yield VL(a,c);return WL(a,e,d.uri,b.verbatimUri)})},IM=function(a,b,c){return _.x(function*(){const d=yield wM(a,{playlist:c,codecs:b.codecs,type:b.type,Tc:b.originalLanguage,ic:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,
53
- channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Md:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&GL(d,b.bandwidth);return d})},bM=function(a){return a.A===_.Db},DM=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield JM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},gM=function(a,b){return _.x(function*(){var c=new _.oi(HK(b).se);if(a.a.lowLatencyMode&&a.K&&a.K.Lf){var d=
54
- b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Yh:d.position,ei:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Yh,e=e.ei,f=_.hj(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.gj(f,!0),d=new _.vi(d),_.ri(c,d)}const {response:g,text:h}=yield VL(a,c.toString());c=HK(b).Da;d=HK(b).se;e=g.uri;d!==e&&(d=e,CL(b,d));c=WL(a,h,d,c);return{stream:b,playlist:c}})},BM=function(a,b){var c=_.J(b,
55
- _.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=KK(c);b=new Set;const d=[];for(const e of c)c=_.GC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},CM=function(a,b){if(1===b.length)return b[0];a=_.dk(a,b);if(null!=a)return a;throw new _.I(_.G,4,4025,{codecList:b});},EM=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return KM(a,e.verbatimUri,()=>_.x(function*(){const f=eK(d,_.Fa),g=uK(eK(d,_.sb));var h=eK(d,_.sb).toUpperCase();
56
- if(uK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.$B;h===NJ&&(l=_.MB);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.La);const m=_.J(d,_.Ta),n=_.J(d,"DEFAULT"),q=g===_.p?MK(d):null;var u=g===_.p?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield wM(a,{playlist:e,codecs:k,type:g,Tc:l,primary:"YES"===n,name:m,channelsCount:q,spatialAudio:u,groupId:f,kind:h,ic:null,closedCaptions:null,Md:null})}))})},GM=function(a,b){return _.x(function*(){const c=
57
- b.tag,d=b.playlist;return KM(a,d.verbatimUri,()=>_.x(function*(){var e=_.J(c,_.pa)||"jpg",f=_.J(c,_.La);const g=_.J(c,_.Ta);e=yield wM(a,{playlist:d,codecs:e,type:_.ce,Tc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,ic:null,groupId:null,Md:null});(f=_.J(c,_.la))&&GL(e,Number(f));return e}))})},FM=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(eK(f,_.la));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.lb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,
58
- _.lb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:iK(h),width:iK(k),height:iK(l)}}else h=null;if(f=yield LM(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const q of h){m=(q?HK(q).Da:"")+" - "+(n?HK(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=lM(a,n,q,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},MM=function(a,
59
- b,c,d,e,f){let g=BM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.dk(_.w,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.w,g=[g.join(",")]):d&&f?(a.g.debug(YJ),c=_.p,b=!0):e?(a.g.debug(YJ),c=_.p):(a.g.debug("Guessing video-only"),c=_.w):(c=_.p,a.g.debug(YJ));return{type:c,Zg:g,Oh:b}},KM=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},LM=
60
- function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.uB),k=_.J(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>HK(u).Da===l);const {type:m,Zg:n,Oh:q}=MM(a,f,c,k.audio.length,k.video.length,g);f=null;q||(f=yield NM(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.p&&c&&k.video.forEach(u=>{DL(u,c.width);EL(u,c.height);FL(u,c.frameRate)});return k})},NM=function(a,b,c,d,e,f){return _.x(function*(){const g=
61
- b.tag,h=b.playlist;return KM(a,h.verbatimUri,()=>_.x(function*(){var k=_.J(g,NJ);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.uB)||void 0)&&a.J.has(k)?k:void 0;var m=CM(d,c);if(k){const n=CM(_.p,c);m+=`,${n}`}return yield wM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Tc:null,name:null,channelsCount:null,spatialAudio:!1,ic:null,groupId:null,muxedAudioId:k,Md:f})}))})},zM=function(a,b,c,d){return _.x(function*(){var e=b.verbatimUri,f=b.U;var g=void 0===g?0:g;
62
- var h=(h=nK(b.ha,VJ))?Number(h.value):g;g=[];e=yield OM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)mK(m.ha,RJ)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield PM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;QM(g);return g})},JM=function(a,b){return _.x(function*(){var c=b.name!==UJ?!0:_.J(b,_.sb)===aK;c=_.J(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.ij(c,a.w),e=Date.now(),{response:f,text:g}=yield VL(a,
63
- d);a.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-e,type:"media"}}));return WL(a,g,f.uri,c)})},QM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},RM=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.ub))||null).map(b=>_.mu(b));if(1<(new Set(a)).size)throw new _.I(_.G,4,4044,"Unexpected change in file format.");},SM=function(a,b,c){a=jK(a.ha,TJ);if(1<a.length)throw new _.I(_.G,
64
- 4,4020);a=a[0];if(!a)return null;const d=eK(a,_.ub),e=_.ij(d,b);b=zK(a,null,!0);return new _.wJ(()=>[e],b.ma,b.ja,c)},TM=function(a,b,c,d,e,f,g){const h=[];for(const q of NK(b.f)){b=q.fg;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,PJ));n=m+n;k=zK(u,k?null:l.ja,k);l=_.J(u,_.ub);const v=(l=_.ij(l,g))?[l]:[];m=new BK(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},UM=function(a,b,c,d,e,f,g,h,k,l,m){const n=
65
- c.ha;var q=c.a;0<jK(n,TJ).length&&(m=SM(c,k,g));const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ma:0,ja:null};let y=null;u?({duration:c}=xK(n),a=e+c,q=wK(n,b?b.ja:null)):(b=TM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ce?oK(n):null;d=new BK(d,e,a,()=>v,q.ma,q.ja,f,g,!1,null,h?h.nd:null,h?h.Kd:null,h?h.durationPerTile:null,y,m);d.ra=l;return d},OM=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.C)return a.C;if(!bM(a)&&a.f)try{var k=a.j.get(c);
66
- var l=k?BL(k,e)||null:null;if(!l)throw new _.I(_.G,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ca;a.g.debug(`Setting playlist start time to ${m}.`);return a.C=m}catch(n){if(h=a.j.get(c))m=h.streams[h.streams.length-1].U,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].U[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.G,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
67
- uri:c});}m=yield VM(a,f,g,h);l=xL(h.ha,a.w,e);k=SM(h,b,l);h=yield WM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},PM=function(a,b,c,d,e,f,g,h){return _.x(function*(){var k=c[0],l=null==h;RM(c);const m=yield VM(a,f,g,k);var n=h?h.Vh:null;if(mK(c[0].ha,SJ)||null===n)n=uL(c,m),n=0===n.length?[qL()]:n;else{var q=uL(c,m);n=[n,...q]}q=n;n=q[q.length-1];q=rL(q);let u=h?h.Wh:null;var v=XM(u,k.ha,a.w,d);let y=SM(k,b,v)||(h?h.Ph:null);const A=k.ra;k=l?e:yield YM(a,A,y,k,d,
68
- v,m,g);l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const oa=l[l.length-1]||null,te=0===E?0:oa.endTime,ic=d+E,Ob=XM(u,D.ha,a.w,ic);(u=Ob)&&(v=!0);if(D=UM(a,oa,D,ic,te,k,Ob,f,b,A,y))y=D.initSegment,l.push(D)}return{U:l,nh:q,Vh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,ra:A,Ph:y,Wh:u}})},VM=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=nK(d.ha,TJ);f=f?eK(f,_.ub):null;return ZM(a,b,c,e,f)})},WM=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=
69
- CK(c,d);return zL(a.S,b,g,e,f,null!=d)})},XM=function(a,b,c,d){return b.some(e=>e.name===SJ&&"NONE"===_.J(e,ZJ))?null:(b=xL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Sl(new Uint8Array(12),eL(d))}):a},YM=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.L.has(b))return a.L.get(b);const k=yield WM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},ZM=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.gk(f,b,
70
- c);if(g)return g;g=_.sj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},XL=a=>{a=_.mu(a)||"";return null!=_.lu.video[a]?_.w:null!=_.lu.audio[a]?_.p:null},TK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.G,4,4043,"Media playlist must have at least one full segment!");
71
- }this.a=a;this.verbatimUri="";this.type=b;this.ha=c;this.U=1===b?d:null}},bL=class{constructor(a,b,c){c=void 0===c?[]:c;this.ha=b;this.a=a;this.f=c;this.ra=-1}},BK=class extends _.wD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,u,void 0===v?null:v);this.ra=0}},$K=/^#EXT-X-DEFINE/,aL=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,
72
- $M=class{constructor(){this.h=0;this.a=new Map}},aN=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},iM=new _.T("clpp.hls.DiscontinuityUtils");var wL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.qg)throw new _.I(_.G,4,4041);if(eK(a,ZJ)===$J)throw new _.I(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.uC(_.pd,[{initDataType:_.If,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":pL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":pL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eK(a,ZJ);if(!nL.includes(b))return oL.error("Widevine in HLS is only supported with [",
73
- nL.join(", "),"], not",b),null;b=eK(a,_.ub);b=_.zt(b);b=_.K(b.data);b=_.uC(_.td,[{initDataType:_.Uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},nL=["SAMPLE-AES",$J],oL=new _.T("clpp.hls.DrmParser");var vL=new _.T("clpp.hls.EncryptionUtils");var bN=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.oj()}}};var AM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var yM=class{constructor(a){this.a=a}length(){return this.a.length}};var cN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new aN;this.w="";this.R=new $M;this.G=0;this.o=null;this.l=new _.wk(()=>{this.Vb()});this.A=_.Db;this.f=null;this.F=new _.pu;this.K=this.C=null;this.g=new _.T("clpp.hls.HlsParser");this.L=new Map;this.S=new bN(this.H.bind(this));this.P=!1;this.I=null;this.M=!1;this.B=new Map;this.J=new Set}configure(a){this.a=a;this.S.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.x(function*(){if(c.P)throw Error("start() may be called only once!");
74
- c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield VL(c,a);c.D.onEvent(new _.F(cK,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield fM(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.M=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=this.o=null;this.B.clear();this.J.clear();return Promise.all(a)}update(){const a=this;return _.x(function*(){const b=a.f;if(!bM(a)&&
75
- b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=UL(a);d=d.filter(h=>g.includes(HK(h).Da))}var e=yield hM(a,d);d=e.map(g=>g.playlist);jM(a,d);e=yield mM(a,e);IL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});$L(a,e);var f=nM(a,d);f=oM(a,d,f);b.cues=eM(a,f);KL(b.periods,e);TL(c,e);if(d=rK(d))!0!==a.a.keepTimelineLive&&pM(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();
76
- a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.x(function*(){const d=a.id;var e=c.f.periods.find(k=>k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.li(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,k);return IM(c,k,l)}))}if(e.video){const k=e.video;g=KM(c,k.verbatimUri,()=>_.x(function*(){const l=yield HM(c,
77
- k);return IM(c,k,l)}))}f=yield f;g=yield g;e=lM(c,f,g,e.bandwidth,e.id);let h;e&&(e=PL(c.D.configurationId,[e],[],[],!bM(c)),c.D.filterAllPeriods(e),e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.li(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.x(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=
78
- c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.li(`Could not load text stream with id: ${a}`);const g=yield KM(c,f.verbatimUri,()=>_.x(function*(){const h=yield HM(c,f);return IM(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.li(`Could not load text stream with id: ${a}`);return d})}Vb(){const a=this;return _.x(function*(){a.g.debug(_.GB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
79
- _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.I(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.Bj(this.F,a);return a.T}};_.z("clpp.hls.HlsComponent",class extends _.Dv{f(){_.dt.m3u8=cN;_.bt[_.pl]=cN;_.bt[bK]=cN}a(){_.VD("m3u8");_.WD(_.pl);_.WD(bK)}id(){return"hls"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var JJ="CLOSED-CAPTIONS",KJ="Could not parse MP4 segment start time.",LJ="DURATION",MJ="EXT-X-DATERANGE",NJ="EXT-X-DISCONTINUITY",OJ="EXT-X-KEY",PJ="EXT-X-MAP",QJ="EXT-X-MEDIA",RJ="EXT-X-MEDIA-SEQUENCE",SJ="EXT-X-PROGRAM-DATE-TIME",TJ="EXT-X-STREAM-INF",UJ="Failed to infer discontinuity number",VJ="Guessing audio-only",WJ="METHOD",XJ="SAMPLE-AES-CTR",YJ="SUBTITLES",ZJ="_HLS_part",$J="application/vnd.apple.mpegurl",aK="manifestloaded",bK="sample",cK=function(a,b){return _.J(a,b,void 0,
2
+ {required:!0})},dK=function(a){if(1>a.a)throw _.xm();--a.a},eK=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Fe&&e&&typeof e===_.Fe){if(!eK(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},fK=function(a,b){if(!eK(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Fe&&e&&typeof e===_.Fe&&fK(d,e))return!0}return!1},gK=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{Wf:b,
3
+ item:d,Zh:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{Wf:b,Zh:c,item:d,next:void 0})},hK=function(a){if(null!==a&&void 0!==a)return Number(a)},iK=function(a,b){return a.filter(c=>c.name===b)},jK=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.J(d,"VALUE"),f=_.J(d,_.Ta),g=_.J(d,"IMPORT"),h=_.J(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);
4
+ if(!b.test(d))throw new _.I(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},kK=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=cK(d,_.sb);return c.includes(d)})},lK=function(a,b){return a.some(c=>c.name===b)},mK=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.F,4,4024,{missingTag:b});return a},nK=function(a){var b=mK(a,"EXT-X-TILES");if(!b)return{fd:1,Bd:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=_.J(b,
5
+ LJ);a=_.nC(a);return{fd:a.fd,Bd:a.Bd,durationPerTile:b?Number(b):null}},oK=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},pK=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of oK(c))b(d,c)})},qK=function(a){return a.some(b=>lK(b.ba,"EXT-X-ENDLIST"))},rK=function(a){return a.type===_.q||a.type===_.t},sK=function(a){if(mK(a,"EXT-X-ENDLIST"))return _.Db;
6
+ a=mK(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.I(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},tK=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.H,"CLOSED-CAPTIONS":_.H}[a.toUpperCase()];if(!a)throw new _.I(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},uK=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.F,4,4044,"Byte range length must be positive.");
7
+ if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ma:d,ja:e}},vK=function(a,b){a=mK(a,"EXT-X-BYTERANGE");return uK(a?a.value:null,b)},wK=function(a){a=mK(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.F,
8
+ 4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},xK=function(a,b){b=void 0===b?{}:b;const c={Af:!1,Yg:!1,Zg:null,Ch:null,lg:null};a=mK(a,"EXT-X-SERVER-CONTROL",{required:b.rg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Af="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.Yg="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.Zg=d(_.J(a,"CAN-SKIP-UNTIL"));c.Ch=d(_.J(a,"HOLD-BACK"));c.lg=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.rg}));return c},yK=function(a,b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");
9
+ return uK(a,b,c)},zK=function(a){const b=iK(a,QJ),c=iK(a,TJ);a=iK(a,"EXT-X-IMAGE-STREAM-INF");return{wc:{vf:kK(b,[_.kB,_.Cb]),closedCaptions:kK(b,JJ),yi:kK(b,YJ)},Cd:c,ze:a}},BK=function(a,b){const c=vK(a.ba,null);return new AK(0,0,0,()=>[a.a],c.ma,c.ja,0,b)},CK=function(a){let b=Infinity,c=Infinity;oK(a).filter(rK).forEach(d=>{{d=d.S;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Oc:b,duration:c}},DK=function(a){return a.map(b=>{({duration:b}=
10
+ CK(b));return b}).reduce((b,c)=>b+c,0)},EK=function(a){return(a.video?a.video.Ca:"")+" - "+(a.audio?a.audio.Ca:"")},FK=function(a,b,c,d,e){if(b===_.Db)return{delay:0,zd:0};b=mK(a,"EXT-X-PART-INF");if(c&&b){e=Number(cK(b,"PART-TARGET"));if(null!=d)return{delay:d,zd:e};({lg:d}=xK(a,{rg:!0}));return{delay:d,zd:e}}a=mK(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,zd:e}:{delay:3*a,zd:e}},HK=function(a){const b=new Map;a.forEach(c=>{var d=`${GK(c).type}:${GK(c).groupId}`;
11
+ b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},IK=function(a){const b=new Map;for(const c of a){a=_.J(c,_.La);a=_.$i(a||_.hg);const d=cK(c,_.Fa),e=cK(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},JK=function(a){return a.filter(b=>"mp4a.40.34"!==b)},KK=function(a,b){if(!a)return null;const c=a.Ca;return b.find(d=>GK(d).Ca===c)||null},LK=function(a){return(a=_.J(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},MK=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?
12
+ 1:0},NK=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.J(e,_.Ta),g=_.J(e,"QUERYPARAM");if(f)g=cK(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.I(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},OK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.F,
13
+ 4,4044,`Undefined variable '${d}'`);return c})},PK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=OK(d.value,b)})})},SK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=QK(a,b[e]);d.push(f);if(f.name===TJ){const g=b[e+1];if(!g)throw new _.I(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.ej(_.ub,g));e++}}b=iK(d,"EXT-X-DEFINE");jK(b);b=NK(b,c);a.a=b;PK(d,a.a);return new RK(c,0,d)},WK=function(a,b,c){const {ji:d,Bh:e,Hi:f}=TK(b),g=UK(a,f,
14
+ c);b=e.map(k=>QK(a,k,g));const h=VK(a,c,d,g);return new RK(c,1,b,h)},XK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.I(_.F,4,4015);b=b.slice(1);return 0===MK(b)?SK(a,b,c):WK(a,b,c)},TK=function(a){const b=[],c=[],d=[];for(const e of a)YK.test(e)?d.push(e):ZK.test(e)?c.push(e):b.push(e);return{ji:b,Bh:c,Hi:d}},UK=function(a,b,c){b=b.map(e=>QK(a,e));jK(b);const d=NK(b,c);b.map(e=>_.J(e,"IMPORT")).filter(Boolean).forEach(e=>
15
+ {const f=a.a.get(e);if(null==f)throw new _.I(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},QK=function(a,b,c){a=_.gj(a.h++,b);c&&PK([a],c);return a},VK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=QK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.J(h,_.sb)?g.push(h):f.push(h)):(lK(f,"EXT-X-GAP")||(h=OK(h,d),h=_.Ti(h,b),e.push(new $K(h,f,g))),f=[],g=[])});0<g.length&&e.push(new $K(null,
16
+ f,g));return e},aL=function(a,b,c){const d=[],e=[];e.push(new _.ej(_.ma,"0"));e.push(new _.ej(_.ub,b));c.length&&e.push(new _.ej(_.pa,c));d.push(new _.fj(a.h++,TJ,e));return new RK(b,0,d)},bL=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},cL=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},dL=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},eL=function(a){function b(h,
17
+ k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.I(_.F,4,4030);}dL(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),
18
+ f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}dL(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},fL=function(a,b){let c=null,d=0;try{(new _.Nm).N(_.Be,_.Gm).N(_.eg,_.Gm).N(_.te,_.Gm).fa("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.O(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Cv.error("Unable to find timescale in init segment!"),new _.I(_.F,4,4030,KJ,c);let e=0,f=!1;try{(new _.Nm).N("moof",_.Gm).N("traf",_.Gm).fa("tfdt",
19
+ g=>{var h=d;if(0===g.version)h=_.O(g.reader)/h;else{{const k=_.O(g.reader),l=_.O(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.I(_.F,4,4030,KJ,c);return e},gL=function(a){for(;a.getPosition()<a.Ma()-1;){const b=a.getPosition();if(71===_.ym(a))return dK(a),b}return-1},hL=function(a){function b(){d.seek(e+
20
+ 188);f=_.ym(d);71!==f&&(d.seek(e+192),f=_.ym(d));71!==f&&(d.seek(e+204),f=_.ym(d));71!==f&&c();dK(d)}function c(){throw new _.I(_.F,4,4030);}const d=new _.Jn(new DataView(a),!1);let e=0,f=0;e=gL(d);0>e&&(_.Cv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.ym(d);71!==f&&c();a=_.zm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.ym(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.ym(d),d.skip(a));if(1!==_.O(d)>>8){b();continue}d.skip(3);a=_.ym(d)>>
21
+ 6;0!==a&&1!==a||c();0===_.ym(d)&&c();a=_.ym(d);const g=_.zm(d),h=_.zm(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},kL=function(a){const b=iL(a),c=jL(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.ra===b);let g=e.findIndex(h=>h.ra===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},jL=function(a){a=a.map(b=>b.S[b.S.length-1].ra);return Math.min(...a)},iL=function(a){a=a.map(b=>b.S[0].ra);return Math.max(...a)},nL=function(a){var b=cK(a,WJ);if(!lL.includes(b))return mL.error("PlayReady in HLS is only supported with [",
22
+ lL.join(", "),"], not",b),null;a=cK(a,_.ub);b=_.Gk(a);a=null;b=_.G(b.data);try{a=_.XB(_.Qn(b))}catch(c){a=b}return _.jC(_.sd,[{initDataType:_.Uc,initData:a}],"")},pL=function(a){if(0===a.length)return oL();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ee))return a[0];a=a.filter(c=>c.type===bK);const b=_.hi(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:bK,drmInfos:b}},sL=function(a,b){return qL(a).map(c=>rL(c.ba,b)).filter(Boolean)},qL=function(a){return a.filter(b=>
23
+ lK(b.ba,OJ))},rL=function(a,b){a=iK(a,OJ).filter(d=>"AES-128"!==cK(d,WJ));if(0===a.length)return null;var c=cK(a[0],WJ);if(1===a.length&&"NONE"===c)return oL();c=a.map(d=>cK(d,WJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===XJ))throw tL.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.J(d,"KEYFORMAT","identity");{const f=uL[e]||null;d=f?f(d,b):null}d||tL.warn("Unsupported HLS KEYFORMAT",
24
+ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.F,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:bK,drmInfos:a}},oL=function(){return{type:_.Ee,drmInfos:[],keyId:null}},vL=function(a,b,c){a=iK(a,OJ)[0];if(!a||"AES-128"!==cK(a,WJ))return null;var d=_.J(a,"IV","");d?c={iv:_.Ck((d||"0x").slice(2)),generatedIv:!1}:(d=_.J(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Fk(new Uint8Array(12),cL(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
25
+ generatedIv:f}=c;return{method:"AES-128",url:_.Ti(cK(a,_.ub),b),iv:e,generatedIv:f}},wL=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.UC(b.Da(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.UC(b.Da(),b.ma,b.ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
26
+ e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.I(_.F,4,4030,"Failed to fetch the media segment.");}}})},xL=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Dc){var g=yield wL(a,c,f);g=_.G(g.data);if(!dL(g))throw new _.I(_.F,4,4030,"AAC segment does not contain an ID3 tag.");return eL(g)}if(d===_.tg||d===
27
+ _.Gc)return g=[wL(a,c,f)],b&&g.push(wL(a,b,!0)),g=yield Promise.all(g),fL(g[0].data,(g[1]||g[0]).data);if(d===_.sg)return g=yield wL(a,c,f),hL(g.data);if(!_.dt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.F,4,4030);})},yL=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},zL=function(a,b){a=a.streams.find(c=>{c=c.S;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.S.find(c=>c.position===b)||null},GK=function(a){return a.streams[0]},
28
+ AL=function(a,b){a.streams.forEach(c=>{c.ke=b})},BL=function(a,b){a.streams.forEach(c=>{c.width=b})},CL=function(a,b){a.streams.forEach(c=>{c.height=b})},DL=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},EL=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},FL=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},GL=function(a,b){const c=new Set(a.map(d=>d.ra));return b.filter(d=>!c.has(d.ra))},IL=function(a,b){for(;a[0].ra<b[0].ra;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
29
+ d.startTime&&c.endTime===d.endTime||HL(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&HL(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},NL=function(a,b,c,d,e){var f=b[0].length();f=bL(f).map(g=>{var h=FL(b,g)||[];const k=yL(c,g)||[];g=yL(d,g)||[];{const l=[...JL(h),...k,...g].filter(Boolean);KL(l);const {ra:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ra:m}}return h});e&&LL(f[0]);
30
+ ML(f);return f},JL=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},LL=function(a){const b=JL(a.variants)[0].S[0].Ba;a.startTime+=b;a.endTime+=b},ML=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},HL=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;OL(a.variants,b.variants);PL(oK(a),oK(b))},OL=function(a,b){const c=new Map(a.map(d=>[EK(d),
31
+ d]));b.forEach(d=>{c.get(EK(d)).drmInfos=d.drmInfos})},PL=function(a,b){const c=new Map(a.map(d=>[d.Ca,d]));b.forEach(d=>{const e=c.get(d.Ca);e.S=d.S;d.S.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.S);e.Oc=d.Oc;e.Ce=d.Ce;e.duration=d.duration;e.Jf=d.Jf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},KL=function(a){const b=QL(a);a.forEach(c=>{_.QC(c.segmentIndex,b);c.duration=b;c.Ce=c.Oc+b})},QL=function(a){let b=Infinity;a.filter(rK).forEach(c=>{b=
32
+ Math.min(b,c.duration)});return b},UL=function(a){if(!(2>a.length)&&RL(a)){a=a.map(e=>({playlist:e,Ff:SL(e.S[0])}));var b=a.map(e=>e.Ff),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.Ff;0<f.S.length&&1E3<c-e;){var g=f.S.shift(),h=f.S[0];if(!h)break;TL(g,h);h=SL(h);null!=h?e=h:({duration:h}=wK(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.S.length))throw new _.I(_.F,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>
33
+ e.S.length));a.forEach(e=>{for(;e.S.length>d;)e.S.pop()})}}},RL=function(a){return a.every(b=>!!SL(b.S[0]))},TL=function(a,b){a&&b&&[PJ,OJ].forEach(c=>{if(!lK(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},VL=function(a,b){pK(b,(c,d)=>{_.cD(a,c.S,d.startTime)});_.VC(a.a,b[0].startTime,b[b.length-1].endTime)},WL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Ca)},XL=function(a,b){return _.w(function*(){var c=_.mj([b],a.a.attemptParameters);
34
+ c.type=1;c=yield a.H(c);let d="";try{d=_.Bi(c.data)}catch(e){throw new _.I(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},hM=function(a,b){return _.w(function*(){var c=YL(a,b,a.w,"");if(1===c.type){var d=c.S[0].a;c=ZL(d);if(!c)throw new _.I(_.F,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=aL(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=zK(c.ba);c=$L(d.wc.vf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield aM(a,d);
35
+ var f=e.Mh;const g=e.periods;var h=e.ai;const k=e.Ai;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.F,7,7001);bM(a,g);h=cM(a,f.delay,g,h);dM(a)||(a.G=f.zd,eM(a));fM(a,h,g);f=gM(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},jM=function(a,b){return Promise.all(b.map(c=>
36
+ iM(a,c)))},lM=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!dM(a),f=mK(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].S,f=f[f.length-1].ra):f=0;if(e&&0<f)try{{const k=mK(c.ba,RJ);if(!k)throw kM.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(UJ);const l=Number(k.value),m=zL(d,l);if(!m)throw kM.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
37
+ ` (segment position = ${l})`),Error(UJ);var h=m.ra}g=h;break a}catch(k){throw new _.I(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)lK(k.ba,NJ)&&g++,k.ra=g});kL(b)},oM=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,Tg:e}=yield mM(a,b);var f=a.f.periods[0].variants;a.a.lowLatencyMode&&null!==a.o&&(f=f.filter(g=>g.id===a.o.id));f=f.map(g=>{const h=KK(g.audio,e),k=KK(g.video,e);g=nM(a,h,k,g.bandwidth);
38
+ if(!g)throw new _.I(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",jj:k?GK(k).Ca:void 0,audio:h?GK(h).Ca:void 0});return g});return NL(a.D.configurationId,f,c,d,!0)})},bM=function(a,b){dM(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.lE(b,-a.I))},pM=function(a,b){b=b.flatMap(d=>d.S[0].ba);b=mK(b,SJ);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),
39
+ null):c/1E3},qM=function(a,b,c){b=b.find(d=>null!==mK(d.ba,MJ));if(!b)return[];if(null===c)throw new _.I(_.F,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");return b.ba.filter(d=>d.name===MJ).map(d=>{a:{var e=a.C,f=!dM(a),g=_.J(d,"ID"),h=_.J(d,"START-DATE");if(null===g||null===h)_.du.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",d),d=null;else{e=f?e-c:-c;var k=new Date(h);f=k.getTime()/1E3+e;
40
+ g={id:g,startTime:f,startDate:k,ge:h};h=hK(_.J(d,LJ));void 0!==h&&0<=h&&(g.duration=h);var l=hK(_.J(d,"PLANNED-DURATION"));void 0!==l&&0<=l&&(g.plannedDuration=l);var m=_.J(d,"CLASS");null!==m&&(g.schemeIdUri=m);var n=_.J(d,"END-DATE");n=n?new Date(n):null;null!==n&&n.getTime()>=k.getTime()&&(g.endDate=n);{const v=d.attributes;if(null==v)var p=null;else{k={};for(p of v)p.name.trim().startsWith("X-")&&(k[p.name]=p.value);p=_.ch(k)?k:null}}p=p||{};(k=_.J(d,"CUE"))&&(p.CUE=k.split(","));if(_.Yi(m)){k=
41
+ d.attributes;if(null==k)var u=null;else{m={};for(u of k)switch(u.name){case _.Lb:m[_.Lb]=u.value;break;case _.Kb:m[_.Kb]=u.value;break;case _.Ob:m[_.Ob]=hK(u.value);break;case _.Mb:m[_.Mb]=hK(u.value);break;case "X-SNAP":m["X-SNAP"]=u.value.split(",");break;case _.Nb:m[_.Nb]=u.value.split(",")}m[_.Lb]&&m[_.Kb]||!m[_.Lb]&&!m[_.Kb]?(_.du.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),u=null):u=_.ch(m)?m:null}if(null===u){_.du.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",
42
+ d);d=null;break a}p=Object.assign(p,u)}_.ch(p)&&(g.customAttributes=p);g.endTime=n?n.getTime()/1E3+e:h?f+h:l?f+l:f;g.type=_.Uh;d=g}}return d}).filter(Boolean)},gM=function(a,b){const c=new Set(b.map(d=>d.id));a.B.forEach((d,e)=>{c.has(e)||a.B.delete(e)});for(const d of b){if((b=a.B.get(d.id))&&b.ge!==d.ge)a.D.onError(new _.I(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,
43
+ value:"",startTime:d.startTime,ge:d.ge,endTime:d.endTime,id:d.id,type:_.Uh,eventElement:null};b&&!fK(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},rM=function(a,b,c){a.A=_.Db;_.ZC(b,!0);b.f=c[c.length-1].endTime},YL=function(a,b,c,d){a=XK(a.R,b,c);a.verbatimUri=d;return a},$L=function(a){return a.filter(b=>b.name===QJ&&_.J(b,_.sb)===_.kB&&!_.J(b,_.ub)).map(b=>{const c=LK(b),d=_.J(b,_.La)||_.hg;return{groupId:cK(b,_.Fa),id:_.tJ++,label:cK(b,_.Ta),language:d,channelsCount:c,primary:"YES"===
44
+ _.J(b,"DEFAULT")}})},aM=function(a,b){return _.w(function*(){var c=IK(b.wc.closedCaptions),d=sM(a,b.Cd),e=yield tM(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=sK(g.ba);a.A=h;lM(a,f);!dM(a)&&UL(f);a.K=xK(g.ba);f=FK(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield uM(a,e.wf,d);c=yield vM(a,e.Cd,g,c);d=yield wM(a,e.xi,d);g=yield xM(a,e.ze);d=NL(a.D.configurationId,c,d,g,!dM(a));a.D.filterAllPeriods(d);c=[...e.Cd,...e.wf].map(k=>k.playlist);
45
+ e=pM(a,c);c=qM(a,c,e);return{periods:d,ai:e,Ai:c,Mh:f}})},cM=function(a,b,c,d){let e=!0,f=null,g=0;dM(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.wJ(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.ZC(a,e);VL(a,c);d&&_.YC(a,d);return a},eM=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Oc);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],
46
+ 95443.7176888889>b.Oc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},fM=function(a,b,c){c=DK(c);"LIVE"===a.A||"EVENT"===a.A?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.A===_.Db&&(b.f=c)},mM=function(a,b){return _.w(function*(){const c=g=>GK(g.stream).type===_.t||GK(g.stream).type===_.q;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=GK(h.stream);k={language:k.language,
47
+ channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.Ca,Dd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return yM(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);zM(a,d.concat(f));e=f.filter(g=>GK(g).type===_.QB);f=f.filter(g=>GK(g).type===_.ee);return{textStreams:e,thumbStreams:f,Tg:d}})},nM=function(a,
48
+ b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||null:null,l=h,m=k;l=l&&m?_.pC(l.drmInfos,m.drmInfos)?_.oC(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.hg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new AM(f)},yM=function(a,b){return _.w(function*(){const c=b.playlist,
49
+ d=b.codecs,e=b.type,f=b.Mc,g=b.dc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,u=b.spatialAudio,v=b.closedCaptions,y=b.Dd,A=_.$i(f||_.hg);if(1!==c.type)throw new _.I(_.F,4,4017);const D=yield BM(a,c,e,d),E=a.a.lowLatencyMode?_.HB:_.GB;let ha=m;e!==_.H||m||(ha=_.QB);const ad=sK(c.ba);m=D.map(hc=>{const Qb=hc.S,Xd=hc.eh,Rb=hc.mimeType,ic=hc.ra,jc=Qb[0].startTime,Fb=Qb[Qb.length-1].endTime,hb=Fb-jc,va=new _.xJ(Qb),yb=Qb[0].initSegment||null;return{id:null===
50
+ g?_.tJ++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:va.f.bind(va),getSegmentReference:va.get.bind(va),adjustSegmentDurations:va.h.bind(va),getDuration:va.getDuration.bind(va),segmentIndex:va,segmentLookupStrategy:E,initSegmentReference:yb,mimeType:Rb,codecs:d,kind:ha,Jf:Xd.type,encrypted:Xd.type===bK,aesEncrypted:hc.aesEncrypted,keyId:Xd.keyId,language:A,originalLanguage:f||_.hg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?
51
+ y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:v,S:Qb,drmInfos:Xd.drmInfos,ra:ic,Ca:c.verbatimUri,ke:c.a,Oc:jc,Ce:Fb,duration:hb,groupId:h,aj:ad,muxedAudioId:k}});return new CM(m)})},zM=function(a,b){b.forEach(c=>{a.j.a.set(GK(c).Ca,c)})},sM=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,_.kB);b=_.J(f,_.Cb);var e=_.J(f,YJ);const g=DM(a,f);if(e){const h=_.jl(_.H,g);c.set(`${_.H}:${e}`,h);e=g.indexOf(h);
52
+ -1<e&&g.splice(e,1)}d&&(e=EM(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=EM(_.t,g),c.set(`${"video"}:${b}`,d))}return c},tM=function(a,b){return _.w(function*(){const c=yield Promise.all([FM(a,b.wc.vf),FM(a,b.wc.yi),FM(a,b.Cd),FM(a,b.ze)]),[d,e,f,g]=c;return{wf:d,xi:e,Cd:f,ze:g}})},uM=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[GM(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>GM(a,e,c)));d=yield Promise.all(d);return HK(d)})},vM=function(a,b,c,d){return _.w(function*(){const e=
53
+ new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(cK(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield HM(a,h,c,d,e);f=f.map(k=>HM(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.fC,[])})},wM=function(a,b,c){return Promise.all(b.map(d=>GM(a,d,c)))},xM=function(a,b){return Promise.all(b.map(c=>IM(a,c)))},JM=function(a,b){return _.w(function*(){const c=_.Ti(b.verbatimUri,a.w),{response:d,text:e}=yield XL(a,c);return YL(a,e,d.uri,b.verbatimUri)})},
54
+ KM=function(a,b,c){return _.w(function*(){const d=yield yM(a,{playlist:c,codecs:b.codecs,type:b.type,Mc:b.originalLanguage,dc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,Dd:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&EL(d,b.bandwidth);return d})},dM=function(a){return a.A===_.Db},FM=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>
55
+ _.w(function*(){const d=yield LM(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},iM=function(a,b){return _.w(function*(){var c=new URL(GK(b).ke);if(a.a.lowLatencyMode&&a.K&&a.K.Af){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={Nh:d.position,Uh:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Uh,d.set("_HLS_msn",e.Nh.toString()),null===f&&d.get(ZJ)&&d.delete(ZJ),null!==f&&d.set(ZJ,f.toString())}const {response:g,text:h}=
56
+ yield XL(a,c.toString());c=GK(b).Ca;d=GK(b).ke;e=g.uri;d!==e&&(d=e,AL(b,d));c=YL(a,h,d,c);return{stream:b,playlist:c}})},DM=function(a,b){var c=_.J(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=JK(c);b=new Set;const d=[];for(const e of c)c=_.uC(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},EM=function(a,b){if(1===b.length)return b[0];a=_.jl(a,b);if(null!=a)return a;throw new _.I(_.F,4,4025,{codecList:b});},GM=function(a,b,c){return _.w(function*(){const d=
57
+ b.tag,e=b.playlist;return MM(a,e.verbatimUri,()=>_.w(function*(){const f=cK(d,_.Fa),g=tK(cK(d,_.sb));var h=cK(d,_.sb).toUpperCase();if(tK(h)!==_.H)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.QB;h===JJ&&(l=_.BB);k&&(l=_.Wd);h=l}k=c.get(`${g}:${f}`)||"";l=_.J(d,_.La);const m=_.J(d,_.Ta),n=_.J(d,"DEFAULT"),p=g===_.q?LK(d):null;var u=g===_.q?(u=_.J(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield yM(a,{playlist:e,codecs:k,type:g,Mc:l,primary:"YES"===
58
+ n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,dc:null,closedCaptions:null,Dd:null})}))})},IM=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return MM(a,d.verbatimUri,()=>_.w(function*(){var e=_.J(c,_.pa)||"jpg",f=_.J(c,_.La);const g=_.J(c,_.Ta);e=yield yM(a,{playlist:d,codecs:e,type:_.ee,Mc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,dc:null,groupId:null,Dd:null});(f=_.J(c,_.ma))&&EL(e,Number(f));return e}))})},HM=function(a,b,c,
59
+ d,e){return _.w(function*(){var f=b.tag,g=Number(cK(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.lb)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.lb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:hK(h),width:hK(k),height:hK(l)}}else h=null;if(f=yield NM(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?GK(p).Ca:"")+" - "+(n?GK(n).Ca:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");
60
+ continue}const u=nM(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},OM=function(a,b,c,d,e,f){let g=DM(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.jl(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(VJ),c=_.q,b=!0):e?(a.g.debug(VJ),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(VJ));return{type:c,
61
+ Rg:g,Dh:b}},MM=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||null;c=c();a.j.set(b,c);return c},NM=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.J(f,_.kB),k=_.J(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>GK(u).Ca===l);const {type:m,Rg:n,Dh:p}=OM(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield PM(a,b,n,m,e,c));
62
+ if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{BL(u,c.width);CL(u,c.height);DL(u,c.frameRate)});return k})},PM=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return MM(a,h.verbatimUri,()=>_.w(function*(){var k=_.J(g,JJ);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.J(g,_.kB)||void 0)&&a.J.has(k)?k:void 0;var m=EM(d,c);if(k){const n=EM(_.q,c);m+=`,${n}`}return yield yM(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Mc:null,name:null,
63
+ channelsCount:null,spatialAudio:!1,dc:null,groupId:null,muxedAudioId:k,Dd:f})}))})},BM=function(a,b,c,d){return _.w(function*(){var e=b.verbatimUri,f=b.S;var g=void 0===g?0:g;var h=(h=mK(b.ba,RJ))?Number(h.value):g;g=[];e=yield QM(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)lK(m.ba,NJ)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield RM(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;SM(g);return g})},LM=function(a,
64
+ b){return _.w(function*(){var c=b.name!==QJ?!0:_.J(b,_.sb)===YJ;c=_.J(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.Ti(c,a.w),e=Date.now(),{response:f,text:g}=yield XL(a,d);a.D.onEvent(new _.C(aK,{detail:{duration:Date.now()-e,type:"media"}}));return YL(a,g,f.uri,c)})},SM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},TM=function(a,b,c){a=iK(a.ba,
65
+ PJ);if(1<a.length)throw new _.I(_.F,4,4020);a=a[0];if(!a)return null;const d=cK(a,_.ub),e=_.Ti(d,b);b=yK(a,null,!0);return new _.sJ(()=>[e],b.ma,b.ja,c)},UM=function(a,b,c,d,e,f,g){const h=[];for(const p of gK(b.f)){b=p.Wf;const u=p.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(u,LJ));n=m+n;k=yK(u,k?null:l.ja,k);l=_.J(u,_.ub);const v=(l=_.Ti(l,g))?[l]:[];m=new AK(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.J(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},
66
+ VM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<iK(n,PJ).length&&(m=TM(c,k,g));const u=null!=p,v=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;p={ma:0,ja:null};let y=null;u?({duration:c}=wK(n),a=e+c,p=vK(n,b?b.ja:null)):(b=UM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ee?nK(n):null;d=new AK(d,e,a,()=>v,p.ma,p.ja,f,g,!1,null,h?h.fd:null,h?h.Bd:null,h?h.durationPerTile:null,y,m);d.ra=l;return d},QM=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.C)return a.C;
67
+ if(!dM(a)&&a.f)try{var k=a.j.get(c);var l=k?zL(k,e)||null:null;if(!l)throw new _.I(_.F,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.Ba;a.g.debug(`Setting playlist start time to ${m}.`);return a.C=m}catch(n){if(h=a.j.get(c))m=h.streams[h.streams.length-1].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",
68
+ uri:c});}m=yield WM(a,f,g,h);l=vL(h.ba,a.w,e);k=TM(h,b,l);h=yield XM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},RM=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0],l=null==h;const m=yield WM(a,f,g,k);var n=h?h.Kh:null;if(lK(c[0].ba,OJ)||null===n)n=sL(c,m),n=0===n.length?[oL()]:n;else{var p=sL(c,m);n=[n,...p]}p=n;n=p[p.length-1];p=pL(p);let u=h?h.Lh:null;var v=YM(u,k.ba,a.w,d);let y=TM(k,b,v)||(h?h.Eh:null);const A=k.ra;k=l?e:yield ZM(a,A,y,k,d,v,m,g);
69
+ l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const ha=l[l.length-1]||null,ad=0===E?0:ha.endTime,hc=d+E,Qb=YM(u,D.ba,a.w,hc);(u=Qb)&&(v=!0);if(D=VM(a,ha,D,hc,ad,k,Qb,f,b,A,y))y=D.initSegment,l.push(D)}return{S:l,eh:p,Kh:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,ra:A,Eh:y,Lh:u}})},WM=function(a,b,c,d){return _.w(function*(){const e=d.a;var f=mK(d.ba,PJ);f=f?cK(f,_.ub):null;return $M(a,b,c,e,f)})},XM=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=BK(c,
70
+ d);return xL(a.T,b,g,e,f,null!=d)})},YM=function(a,b,c,d){return b.some(e=>e.name===OJ&&"NONE"===_.J(e,WJ))?null:(b=vL(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Fk(new Uint8Array(12),cL(d))}):a},ZM=function(a,b,c,d,e,f,g,h){return _.w(function*(){if(a.L.has(b))return a.L.get(b);const k=yield XM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.L.set(b,k);return k})},$M=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.ml(f,b,c);if(g)return g;
71
+ g=_.mj([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},ZL=a=>{a=_.Vi(a)||"";return null!=_.cu.video[a]?_.t:null!=_.cu.audio[a]?_.q:null},RK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.F,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.F,4,4043,"Media playlist must have at least one full segment!");
72
+ }this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.S=1===b?d:null}},$K=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ra=-1}},AK=class extends _.pD{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,v){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===v?null:v);this.ra=0}},YK=/^#EXT-X-DEFINE/,ZK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,
73
+ aN=class{constructor(){this.h=0;this.a=new Map}},bN=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},kM=new _.S("clpp.hls.DiscontinuityUtils");var uL={"com.apple.streamingkeydelivery":function(a,b){if(b===_.sg)throw new _.I(_.F,4,4041);if(cK(a,WJ)===XJ)throw new _.I(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.jC(_.qd,[{initDataType:_.Jf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":nL,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":nL,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=cK(a,WJ);if(!lL.includes(b))return mL.error("Widevine in HLS is only supported with [",
74
+ lL.join(", "),"], not",b),null;b=cK(a,_.ub);b=_.Gk(b);b=_.G(b.data);b=_.jC(_.ud,[{initDataType:_.Uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},lL=["SAMPLE-AES",XJ],mL=new _.S("clpp.hls.DrmParser");var tL=new _.S("clpp.hls.EncryptionUtils");var cN=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.ij()}}};var CM=class{constructor(a){this.streams=a}length(){return this.streams.length}};var AM=class{constructor(a){this.a=a}length(){return this.a.length}};var SL=a=>{if(!a)return null;a=mK(a.ba,SJ);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var dN=class{constructor(){this.a=this.D=null;this.h=1;this.j=new bN;this.w="";this.R=new aN;this.G=0;this.o=null;this.l=new _.Mj(()=>{this.Rb()});this.A=_.Db;this.f=null;this.F=new _.eu;this.K=this.C=null;this.g=new _.S("clpp.hls.HlsParser");this.L=new Map;this.T=new cN(this.H.bind(this));this.P=!1;this.I=null;this.M=!1;this.B=new Map;this.J=new Set}configure(a){this.a=a;this.T.a=a}setCurrentVariant(a){this.o=a}start(a,b){const c=this;return _.w(function*(){if(c.P)throw Error("start() may be called only once!");
75
+ c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield XL(c,a);c.D.onEvent(new _.C(aK,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield hM(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.M=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=this.o=null;this.B.clear();this.J.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.f;if(!dM(a)&&
76
+ b){var c=b.presentationTimeline;"LIVE"===a.A&&(a.C=null);var d=Array.from(a.j.values());if(a.a.lowLatencyMode&&null!==a.o){const g=WL(a);d=d.filter(h=>g.includes(GK(h).Ca))}var e=yield jM(a,d);d=e.map(g=>g.playlist);lM(a,d);e=yield oM(a,e);GL(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});bM(a,e);var f=pM(a,d);f=qM(a,d,f);b.cues=gM(a,f);IL(b.periods,e);VL(c,e);if(d=qK(d))!0!==a.a.keepTimelineLive&&rM(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();
77
+ a.M&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.w(function*(){const d=a.id;var e=c.f.periods.find(k=>k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.ni(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=MM(c,k.verbatimUri,()=>_.w(function*(){const l=yield JM(c,k);return KM(c,k,l)}))}if(e.video){const k=e.video;g=MM(c,k.verbatimUri,()=>_.w(function*(){const l=yield JM(c,
78
+ k);return KM(c,k,l)}))}f=yield f;g=yield g;e=nM(c,f,g,e.bandwidth,e.id);let h;e&&(e=NL(c.D.configurationId,[e],[],[],!dM(c)),c.D.filterAllPeriods(e),e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.ni(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.w(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=
79
+ c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.ni(`Could not load text stream with id: ${a}`);const g=yield MM(c,f.verbatimUri,()=>_.w(function*(){const h=yield JM(c,f);return KM(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.ni(`Could not load text stream with id: ${a}`);return d})}Rb(){const a=this;return _.w(function*(){a.g.debug(_.wB);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
80
+ _.I))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.I(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.vj(this.F,a);return a.U}};_.x("clpp.hls.HlsComponent",class extends _.uv{f(){_.st.m3u8=dN;_.rt[_.Ql]=dN;_.rt[$J]=dN}a(){_.ND("m3u8");_.OD(_.Ql);_.OD($J)}id(){return"hls"}});};f.call(g, window);