@castlabs/prestoplay 6.29.0 → 6.30.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 (66) hide show
  1. package/CHANGELOG.md +22 -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 +129 -127
  6. package/cjs/cl.conviva.js +32 -32
  7. package/cjs/cl.core.js +619 -621
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +92 -89
  10. package/cjs/cl.externs.js +36 -35
  11. package/cjs/cl.freewheel.js +25 -25
  12. package/cjs/cl.hls.js +78 -79
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +30 -30
  15. package/cjs/cl.ima.js +25 -24
  16. package/cjs/cl.mediatailor.js +3 -3
  17. package/cjs/cl.mse.js +352 -351
  18. package/cjs/cl.muxdata.js +14 -14
  19. package/cjs/cl.onboard.js +4 -4
  20. package/cjs/cl.persistent.js +15 -15
  21. package/cjs/cl.playlist.js +6 -6
  22. package/cjs/cl.simid.js +16 -16
  23. package/cjs/cl.smooth.js +71 -71
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +71 -71
  26. package/cjs/cl.ttml.js +29 -29
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +12 -12
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.yospace.js +4 -4
  32. package/cjs/cl.youbora.js +38 -38
  33. package/cjs/polyfill.min.js +2 -2
  34. package/cl.adobe.js +3 -3
  35. package/cl.airplay.js +3 -3
  36. package/cl.broadpeak.js +6 -6
  37. package/cl.cast.js +101 -99
  38. package/cl.conviva.js +27 -27
  39. package/cl.core.js +486 -486
  40. package/cl.crypto.js +9 -9
  41. package/cl.dash.js +84 -83
  42. package/cl.externs.js +36 -35
  43. package/cl.freewheel.js +19 -19
  44. package/cl.hls.js +82 -82
  45. package/cl.hlssmpte.js +5 -5
  46. package/cl.htmlcue.js +26 -26
  47. package/cl.ima.js +19 -18
  48. package/cl.mediatailor.js +2 -2
  49. package/cl.mse.js +303 -303
  50. package/cl.muxdata.js +13 -13
  51. package/cl.onboard.js +4 -4
  52. package/cl.persistent.js +11 -11
  53. package/cl.playlist.js +5 -5
  54. package/cl.simid.js +14 -14
  55. package/cl.smooth.js +60 -60
  56. package/cl.thumbnails.js +19 -19
  57. package/cl.tizen.js +56 -56
  58. package/cl.ttml.js +22 -22
  59. package/cl.verimatrix.js +4 -4
  60. package/cl.vimond.js +8 -8
  61. package/cl.vr.js +14 -14
  62. package/cl.vtt.js +12 -12
  63. package/cl.yospace.js +3 -3
  64. package/cl.youbora.js +31 -31
  65. package/package.json +1 -1
  66. package/typings.d.ts +11 -1
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 $T="clpp-freewheel",aU="clpp.freewheel.AdsManagerFactory",bU="freewheel",cU=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""}},dU=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Tf&&b.push("serverUrl");typeof a.profileId!==_.Tf&&b.push("profileId");typeof a.videoAssetId!==_.Tf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},eU=function(){return _.w(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})},fU=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,_.fg,a.I.bind(a));a.j.on(a.m,_.Qf,a.H.bind(a))},iU=function(a){return _.w(function*(){a.G.length?(gU(a),a.f=a.G.shift(),a.f.play()):(hU(a),yield a.m.a.play())})},hU=function(a){const b=a.m.jd(bU).Mc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},gU=function(a){const b=a.m.jd(bU).Mc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase($T),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},jU=function(a){a.F.length?(gU(a),a.f=a.F.shift(),a.f.play()):hU(a)},kU=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 _.G(b,d))},lU=class extends _.Uv{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Di(_.Ed,{id:$T}),this.f=_.Di(_.t,{"class":_.bd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return bU}Mc(){return this.a}Jh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",lU);lU.prototype.getAdVideo=lU.prototype.Jh;lU.prototype.getAdContainer=lU.prototype.Mc;lU.Id=bU;lU.AD_CONTAINER_ID=$T;var mU=class{create(){return new lU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}lb(){return"FreeWheel AdManager SDK"}nb(){return tv.freewheel.SDK.version}sb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Tf?a:""}Nb(){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}Rb(){return!1}ob(){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():""}cb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}bb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Oa(){return 0}Pa(){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.Pa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Gb(){switch(this.Pa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}qb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}eb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Pb(){return null}};
8
- X.prototype.getVideoElement=X.prototype.Pb;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.eb;X.prototype.getPositionInSequence=X.prototype.qb;X.prototype.getPodTimeOffset=X.prototype.Gb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Pa;
9
- X.prototype.getMediaBitrate=X.prototype.Oa;X.prototype.getMediaHeight=X.prototype.bb;X.prototype.getMediaWidth=X.prototype.cb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.ob;X.prototype.isBumper=X.prototype.Rb;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.Nb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.sb;X.prototype.getAdManagerVersion=X.prototype.nb;X.prototype.getAdManagerName=X.prototype.lb;var nU=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()}})}Ib(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Hb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- nU.prototype.hasPostroll=nU.prototype.Hb;nU.prototype.hasPreroll=nU.prototype.Ib;nU.prototype.getCuePoints=nU.prototype.getCuePoints;var oU=class{constructor(a){this.g=new _.S("clpp.freewheel.AdsManager");this.m=a;this.j=new _.Qt;this.C=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.G=[];this.B=[];this.F=[];this.A=new _.Jl;this.w=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{dU(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!==_.Tf&&typeof b.siteSectionId!==
12
- _.r||a.a.setSiteSection(b.siteSectionId);const c=yield eU();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,cU(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.He&&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);fU(a);a.a.submitRequest();return a.A})}start(){const a=this;return _.w(function*(){yield iU(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);hU(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 _.G(_.pc,{adsTimeline:new nU(this.a)})),this.w=new _.Iv(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.jd(bU).f);else this.m.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.A.resolve()}M(a){kU(this,_.Sb,a);this.w.start()}L(a){this.f=null;a=a.slot;kU(this,_.Tb);this.w.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:iU(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:hU(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:jU(this)}}J(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:kU(this,_.lc,a);kU(this,
16
- _.dc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:kU(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:kU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:kU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:kU(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:kU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:kU(this,_.Vb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:kU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:kU(this,
17
- _.jc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:kU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:kU(this,_.Ub,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:kU(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.H(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();gU(this);this.f.play()}}}H(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);jU(this);break;case _.Fs:case _.ys:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- oU.prototype.getPosition=oU.prototype.getPosition;oU.prototype.setVolume=oU.prototype.setVolume;oU.prototype.getVolume=oU.prototype.getVolume;oU.prototype.skip=oU.prototype.skip;oU.prototype.pause=oU.prototype.pause;oU.prototype.resume=oU.prototype.resume;_.Fh(new class{constructor(){this.Ra=new _.S(aU)}name(){return aU}a(a,b){return a.namespace()!==_.gd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Ra.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new oU(a)}});_.Wn(new mU);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var ST="clpp-freewheel",TT="clpp.freewheel.AdsManagerFactory",UT="freewheel",VT=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""}},WT=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Tf&&b.push("serverUrl");typeof a.profileId!==_.Tf&&b.push("profileId");typeof a.videoAssetId!==_.Tf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.I(1,9,12001,{missingKeys:b.join(", ")});},XT=function(){return _.w(function*(){var a=new _.Ev;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})},YT=function(a){a.h.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.L.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.P.bind(a));a.h.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.M.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_AD,a.K.bind(a));a.h.on(a.m,_.fg,a.J.bind(a));a.h.on(a.m,_.Qf,a.I.bind(a))},ZT=function(a){const b=a.m.md(UT).Pc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},$T=function(a){const b=a.m.md(UT).Pc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(ST),a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},aU=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||
4
+ c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.H(b,d))},bU=class extends _.Ov{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Bi(_.Fd,{id:ST}),this.f=_.Bi(_.t,{"class":_.cd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,!0),a.getSurface().hide(this.a);else a.onError(new _.I(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),
5
+ this.f=this.a=null)}id(){return UT}Pc(){return this.a}Qh(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",bU);bU.prototype.getAdVideo=bU.prototype.Qh;bU.prototype.getAdContainer=bU.prototype.Pc;bU.Id=UT;bU.AD_CONTAINER_ID=ST;var cU=class{create(){return new bU}};var X=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}nb(){return"FreeWheel AdManager SDK"}ob(){return tv.freewheel.SDK.version}ub(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Tf?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}Ub(){return!1}pb(){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():""}eb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}cb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}Pa(){return 0}Qa(){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.Qa()){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.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}rb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}fb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}canSeek(){return!1}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}Sb(){return null}};
8
+ X.prototype.getVideoElement=X.prototype.Sb;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.fb;X.prototype.getPositionInSequence=X.prototype.rb;X.prototype.getPodTimeOffset=X.prototype.Hb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Qa;
9
+ X.prototype.getMediaBitrate=X.prototype.Pa;X.prototype.getMediaHeight=X.prototype.cb;X.prototype.getMediaWidth=X.prototype.eb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.pb;X.prototype.isBumper=X.prototype.Ub;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.Qb;X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.ub;X.prototype.getAdManagerVersion=X.prototype.ob;X.prototype.getAdManagerName=X.prototype.nb;var dU=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()}})}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}Ib(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ dU.prototype.hasPostroll=dU.prototype.Ib;dU.prototype.hasPreroll=dU.prototype.Jb;dU.prototype.getCuePoints=dU.prototype.getCuePoints;var eU=class{constructor(a){this.g=new _.T("clpp.freewheel.AdsManager");this.m=a;this.h=new _.Kt;this.F=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.H=[];this.C=[];this.G=[];this.B=new _.Hl;this.w=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{WT(b)}catch(d){return a.m.onError(d),a.B.resolve(),a.B}a.F.setNetwork(b.networkId);a.F.setServer(b.serverUrl);a.a=a.F.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Tf&&typeof b.siteSectionId!==
12
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield XT();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,VT(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.He&&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);YT(a);a.a.submitRequest();return a.B})}A(){if(this.H.length){$T(this);this.f=this.H.shift();this.f.play();var a=!1}else ZT(this),a=!0;return 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}j(){const a=
14
+ this;return _.w(function*(){a.h.release();a.w&&(a.w.stop(),a.w=null);ZT(a);a.a&&(a.a.dispose(),a.a=null)})}L(a){if(a.success)this.H=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.C=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.G=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.H(_.pc,{adsTimeline:new dU(this.a)})),this.w=new _.Cv(this.m.getSurface(),(b,c)=>this.a.resize(b,
15
+ c),this.m.md(UT).f);else this.m.onError(new _.I(1,9,10003,{errorType:0},void 0));this.B.resolve()}P(a){aU(this,_.Tb,a);this.w.start()}M(a){this.f=null;a=a.slot;aU(this,_.Ub);this.w.stop();ZT(this);a&&a.getTimePositionClass()===tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL||this.m.play()}K(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:aU(this,_.lc,a);aU(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:aU(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:aU(this,
16
+ _.Yb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:aU(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:aU(this,_.nc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:aU(this,_.Xb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:aU(this,_.Wb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:aU(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:aU(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:aU(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:aU(this,_.Vb,
17
+ a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:aU(this,_.ic,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]}))}}J(){if(!this.f){var a=this.m.getPosition();if(this.f=this.C.find(b=>.5>Math.abs(a-b.getTimePosition()))||null){const b=this.C.findIndex(c=>c===this.f);this.C.splice(b,1);this.m.pause();$T(this);
18
+ this.f.play()}}}I(a){if((a=a.detail)&&this.a)switch(a.currentState){case 3:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case 4:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case 5:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);this.G.length?($T(this),this.f=this.G.shift(),this.f.play()):ZT(this);break;case _.zs:case _.ps:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};eU.prototype.getPosition=eU.prototype.getPosition;
19
+ eU.prototype.setVolume=eU.prototype.setVolume;eU.prototype.getVolume=eU.prototype.getVolume;eU.prototype.skip=eU.prototype.skip;eU.prototype.pause=eU.prototype.pause;eU.prototype.resume=eU.prototype.resume;_.Fh(new class{constructor(){this.Sa=new _.T(TT)}name(){return TT}a(a,b){return a.namespace()!==_.hd&&b&&b.freewheel?window.tv&&tv.freewheel&&tv.freewheel.SDK?!0:(this.Sa.warn("FreeWheel SDK is not loaded."),!1):!1}create(a){return new eU(a)}});_.Qn(new cU);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,82 +1,82 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var OI="CLOSED-CAPTIONS",PI="Could not parse MP4 segment start time.",QI="DURATION",RI="EXT-X-DATERANGE",SI="EXT-X-DISCONTINUITY",TI="EXT-X-KEY",UI="EXT-X-MAP",VI="EXT-X-MEDIA",WI="EXT-X-MEDIA-SEQUENCE",XI="EXT-X-PROGRAM-DATE-TIME",YI="EXT-X-STREAM-INF",ZI="Failed to infer discontinuity number",$I="Guessing audio-only",aJ="METHOD",bJ="SAMPLE-AES-CTR",cJ="SUBTITLES",dJ="_HLS_part",eJ="application/vnd.apple.mpegurl",fJ="manifestloaded",gJ="sample",hJ=function(a,b){return _.K(a,b,void 0,
2
- {required:!0})},iJ=function(a){if(1>a.a)throw _.Zo();--a.a},jJ=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===_.He&&e&&typeof e===_.He){if(!jJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},kJ=function(a,b){if(!jJ(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===_.He&&e&&typeof e===_.He&&kJ(d,e))return!0}return!1},lJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
3
- for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.He&&typeof d===_.He){if(lJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},mJ=function*(a){let b=-1,c=void 0,d=void 0;for(const e of a)0<=b&&(yield{kg:b,item:d,yi:c,next:e}),b++,c=d,d=e;-1!==b&&(yield{kg:b,
4
- yi:c,item:d,next:void 0})},nJ=function(a){if(null!==a&&void 0!==a)return Number(a)},oJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},pJ=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},qJ=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},rJ=function(a,b){return a.filter(c=>c.name===b)},sJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=
5
- _.K(d,"VALUE"),f=_.K(d,_.Sa),g=_.K(d,"IMPORT"),h=_.K(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.C,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.C,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.C,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},tJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=hJ(d,_.sb);return c.includes(d)})},uJ=function(a,b){return a.some(c=>
6
- c.name===b)},vJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.C,4,4024,{missingTag:b});return a},wJ=function(a){var b=vJ(a,"EXT-X-TILES");if(!b)return{od:1,Ld:1,durationPerTile:null};a=_.K(b,"LAYOUT")||"1x1";b=_.K(b,QI);a=_.GB(a);return{od:a.od,Ld:a.Ld,durationPerTile:b?Number(b):null}},xJ=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=>
7
- b.add(c));return Array.from(b)},yJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of xJ(c))b(d,c)})},zJ=function(a){return a.some(b=>uJ(b.aa,"EXT-X-ENDLIST"))},AJ=function(a){return a.type===_.q||a.type===_.t},BJ=function(a){if(vJ(a,"EXT-X-ENDLIST"))return _.Db;a=vJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.H(_.C,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},CJ=function(a){a={AUDIO:_.q,VIDEO:_.t,
8
- SUBTITLES:_.J,"CLOSED-CAPTIONS":_.J}[a.toUpperCase()];if(!a)throw new _.H(_.C,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},DJ=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 _.H(_.C,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.C,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.C,4,4044,"Invalid byte range, offset is required but missing.");
9
- if(null==b)throw new _.H(_.C,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}},EJ=function(a,b){a=vJ(a,"EXT-X-BYTERANGE");return DJ(a?a.value:null,b)},FJ=function(a){a=vJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.H(_.C,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},GJ=function(a,b){b=void 0===b?{}:b;const c={Of:!1,th:!1,uh:null,Xh:null,Cg:null};a=vJ(a,"EXT-X-SERVER-CONTROL",
10
- {required:b.Lg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Of="YES"===_.K(a,"CAN-BLOCK-RELOAD");c.th="YES"===_.K(a,"CAN-SKIP-DATERANGES");c.uh=d(_.K(a,"CAN-SKIP-UNTIL"));c.Xh=d(_.K(a,"HOLD-BACK"));c.Cg=d(_.K(a,"PART-HOLD-BACK",void 0,{required:b.Lg}));return c},HJ=function(a,b,c){c=void 0===c?!1:c;a=_.K(a,"BYTERANGE");return DJ(a,b,c)},IJ=function(a){const b=rJ(a,VI),c=rJ(a,YI);a=rJ(a,"EXT-X-IMAGE-STREAM-INF");return{Bc:{If:tJ(b,[_.sA,_.Cb]),closedCaptions:tJ(b,OI),Si:tJ(b,cJ)},Md:c,Ke:a}},
11
- KJ=function(a,b){const c=EJ(a.aa,null);return new JJ(0,0,0,()=>[a.a],c.ma,c.ja,0,b)},LJ=function(a){let b=Infinity,c=Infinity;xJ(a).filter(AJ).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{Tc:b,duration:c}},MJ=function(a){return a.map(b=>{({duration:b}=LJ(b));return b}).reduce((b,c)=>b+c,0)},NJ=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},OJ=function(a,b,c,d,e){if(b===_.Db)return{delay:0,Kd:0};b=
12
- vJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(hJ(b,"PART-TARGET"));if(null!=d)return{delay:d,Kd:e};({Cg:d}=GJ(a,{Lg:!0}));return{delay:d,Kd:e}}a=vJ(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,Kd:e}:{delay:3*a,Kd:e}},QJ=function(a){const b=new Map;a.forEach(c=>{var d=`${PJ(c).type}:${PJ(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},RJ=function(a){const b=new Map;for(const c of a){a=_.K(c,_.Ka);a=_.Nn(a||_.kg);const d=hJ(c,
13
- _.Ea),e=hJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},SJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},TJ=function(a,b,c,d,e){var f=e&&e.Hd,g=e&&e.schemeIdUri,h=_.K(a,"ID");f=_.K(a,"START-DATE")||f;if(null===h||!f)return _.mv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Hd:f};f=nJ(_.K(a,QI));void 0!==f&&0<=
14
- f&&(h.duration=f);f=nJ(_.K(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.K(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.K(a,"END-DATE"))?new Date(f):null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.fh(d)?d:null}k=k||{};(d=_.K(a,"CUE"))&&(k.CUE=d.split(","));if(_.ik(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Kb:d[_.Kb]=
15
- l.value;break;case _.Jb:d[_.Jb]=l.value;break;case _.Qb:d[_.Qb]=nJ(l.value);break;case _.Ob:d[_.Ob]=nJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;case _.Pb:d[_.Pb]=l.value.split(",")}l=_.fh(d)?d:null}l&&(k=Object.assign(k,l))}_.fh(k)&&(h.customAttributes=k);if(lJ(e,h))return _.mv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.ch(e,h);if(_.ik(g)&&!_.jk(h.customAttributes))return _.mv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),
16
- null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=_.de;return h},UJ=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>PJ(d).Da===c)||null},VJ=function(a){return(a=_.K(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},WJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},XJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.K(e,_.Sa),g=_.K(e,"QUERYPARAM");if(f)g=hJ(e,
17
- "VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.C,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.C,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},YJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.C,4,4044,`Undefined variable '${d}'`);return c})},ZJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=YJ(d.value,
18
- b)})})},bK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=$J(a,b[e]);d.push(f);if(f.name===YI){const g=b[e+1];if(!g)throw new _.H(_.C,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.rr(_.ub,g));e++}}b=rJ(d,"EXT-X-DEFINE");sJ(b);b=XJ(b,c);a.a=b;ZJ(d,a.a);return new aK(c,0,d)},fK=function(a,b,c){const {Fi:d,Wh:e,bj:f}=cK(b),g=dK(a,f,c);b=e.map(k=>$J(a,k,g));const h=eK(a,c,d,g);return new aK(c,1,b,h)},gK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>d.trim()).filter(d=>
19
- d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.C,4,4015);b=b.slice(1);return 0===WJ(b)?bK(a,b,c):fK(a,b,c)},cK=function(a){const b=[],c=[],d=[];for(const e of a)hK.test(e)?d.push(e):iK.test(e)?c.push(e):b.push(e);return{Fi:b,Wh:c,bj:d}},dK=function(a,b,c){b=b.map(e=>$J(a,e));sJ(b);const d=XJ(b,c);b.map(e=>_.K(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.H(_.C,4,4044,`Cannot import variable '${e}' as it is not defined `+
20
- "in the master playlist");d.set(e,f)});return d},$J=function(a,b,c){a=_.tr(a.h++,b);c&&ZJ([a],c);return a},eK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=$J(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.K(h,_.sb)?g.push(h):f.push(h)):(uJ(f,"EXT-X-GAP")||(h=YJ(h,d),h=_.Wm(h,b),e.push(new jK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new jK(null,f,g));return e},kK=function(a,b,c){const d=[],e=[];e.push(new _.rr(_.ma,"0"));e.push(new _.rr(_.ub,
21
- b));c.length&&e.push(new _.rr(_.pa,c));d.push(new _.sr(a.h++,YI,e));return new aK(b,0,d)},lK=function(a){function b(h,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 _.H(_.C,4,4030);}qJ(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===
22
- 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|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}qJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},mK=function(a,b){let c=null,d=0;try{(new _.op).N(_.De,_.hp).N(_.hg,_.hp).N(_.ye,_.hp).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.M(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.Sv.error("Unable to find timescale in init segment!"),
23
- new _.H(_.C,4,4030,PI,c);let e=0,f=!1;try{(new _.op).N("moof",_.hp).N("traf",_.hp).ea("tfdt",g=>{var h=d;if(0===g.version)h=_.M(g.reader)/h;else{{const k=_.M(g.reader),l=_.M(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 _.H(_.C,4,4030,PI,c);return e},nK=function(a){for(;a.getPosition()<a.Na()-1;){const b=
24
- a.getPosition();if(71===_.$o(a))return iJ(a),b}return-1},oK=function(a){function b(){d.seek(e+188);f=_.$o(d);71!==f&&(d.seek(e+192),f=_.$o(d));71!==f&&(d.seek(e+204),f=_.$o(d));71!==f&&c();iJ(d)}function c(){throw new _.H(_.C,4,4030);}const d=new _.gq(new DataView(a),!1);let e=0,f=0;e=nK(d);0>e&&(_.Sv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.$o(d);71!==f&&c();a=_.ap(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.$o(d)&48)>>4;
25
- 0!==a&&2!==a||c();3===a&&(a=_.$o(d),d.skip(a));if(1!==_.M(d)>>8){b();continue}d.skip(3);a=_.$o(d)>>6;0!==a&&1!==a||c();0===_.$o(d)&&c();a=_.$o(d);const g=_.ap(d),h=_.ap(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},rK=function(a){const b=pK(a),c=qK(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.sa===b);let g=e.findIndex(h=>h.sa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},qK=function(a){a=a.map(b=>b.S[b.S.length-1].sa);return Math.min(...a)},pK=function(a){a=a.map(b=>b.S[0].sa);
26
- return Math.max(...a)},uK=function(a){var b=hJ(a,aJ);if(!sK.includes(b))return tK.error("PlayReady in HLS is only supported with [",sK.join(", "),"], not",b),null;a=hJ(a,_.ub);b=_.mm(a);a=null;b=_.F(b.data);try{a=_.gB(_.nq(b))}catch(c){a=b}return _.uB(_.td,[{initDataType:_.Uc,initData:a}],"")},wK=function(a){if(0===a.length)return vK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ge))return a[0];a=a.filter(c=>c.type===gJ);const b=_.ci(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-
27
- 1].keyId,type:gJ,drmInfos:b}},zK=function(a,b){return xK(a).map(c=>yK(c.aa,b)).filter(Boolean)},xK=function(a){return a.filter(b=>uJ(b.aa,TI))},yK=function(a,b){a=rJ(a,TI).filter(d=>"AES-128"!==hJ(d,aJ));if(0===a.length)return null;var c=hJ(a[0],aJ);if(1===a.length&&"NONE"===c)return vK();c=a.map(d=>hJ(d,aJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===bJ))throw AK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.H(_.C,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");
28
- a=a.map(d=>{const e=_.K(d,"KEYFORMAT","identity");{const f=BK[e]||null;d=f?f(d,b):null}d||AK.warn("Unsupported HLS KEYFORMAT",e);return d}).filter(Boolean);if(0===a.length)throw new _.H(_.C,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:gJ,drmInfos:a}},vK=function(){return{type:_.Ge,drmInfos:[],keyId:null}},CK=function(a,b,c){a=rJ(a,TI)[0];if(!a||"AES-128"!==hJ(a,aJ))return null;var d=_.K(a,"IV","");d?c={iv:_.im((d||"0x").slice(2)),generatedIv:!1}:(d=
29
- _.K(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.lm(new Uint8Array(12),pJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,generatedIv:f}=c;return{method:"AES-128",url:_.Wm(hJ(a,_.ub),b),iv:e,generatedIv:f}},DK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.bC(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.bC(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.",
30
- 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 _.H(_.C,4,4030,"Failed to fetch the media segment.");}}})},EK=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 DK(a,c,f);g=_.F(g.data);if(!qJ(g))throw new _.H(_.C,4,4030,"AAC segment does not contain an ID3 tag.");return lK(g)}if(d===_.zg||d===
31
- _.Gc)return g=[DK(a,c,f)],b&&g.push(DK(a,b,!0)),g=yield Promise.all(g),mK(g[0].data,(g[1]||g[0]).data);if(d===_.yg)return g=yield DK(a,c,f),oK(g.data);if(!_.mt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.C,4,4030);})},FK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},GK=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},PJ=function(a){return a.streams[0]},
32
- HK=function(a,b){a.streams.forEach(c=>{c.xe=b})},IK=function(a,b){a.streams.forEach(c=>{c.width=b})},JK=function(a,b){a.streams.forEach(c=>{c.height=b})},KK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},LK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},MK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},NK=function(a,b){const c=new Set(a.map(d=>d.sa));return b.filter(d=>!c.has(d.sa))},PK=function(a,b){for(;a[0].sa<b[0].sa;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
33
- d.startTime&&c.endTime===d.endTime||OK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&OK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},UK=function(a,b,c,d,e){var f=b[0].length();f=oJ(f).map(g=>{var h=MK(b,g)||[];const k=FK(c,g)||[];g=FK(d,g)||[];{const l=[...QK(h),...k,...g].filter(Boolean);RK(l);const {sa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,sa:m}}return h});e&&SK(f[0]);
34
- TK(f);return f},QK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},SK=function(a){const b=QK(a.variants)[0].S[0].Ca;a.startTime+=b;a.endTime+=b},TK=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}},OK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;VK(a.variants,b.variants);WK(xJ(a),xJ(b))},VK=function(a,b){const c=new Map(a.map(d=>[NJ(d),
35
- d]));b.forEach(d=>{c.get(NJ(d)).drmInfos=d.drmInfos})},WK=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.S=d.S;d.S.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.S);e.Tc=d.Tc;e.Ne=d.Ne;e.duration=d.duration;e.Xf=d.Xf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},RK=function(a){const b=XK(a);a.forEach(c=>{_.YB(c.segmentIndex,b);c.duration=b;c.Ne=c.Tc+b})},XK=function(a){let b=Infinity;a.filter(AJ).forEach(c=>{b=
36
- Math.min(b,c.duration)});return b},aL=function(a){if(!(2>a.length)&&YK(a)){a=a.map(e=>({playlist:e,Tf:ZK(e.S[0])}));var b=a.map(e=>e.Tf),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.Tf;0<f.S.length&&1E3<c-e;){var g=f.S.shift(),h=f.S[0];if(!h)break;$K(g,h);h=ZK(h);null!=h?e=h:({duration:h}=FJ(g.aa),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.S.length))throw new _.H(_.C,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>
37
- e.S.length));a.forEach(e=>{for(;e.S.length>d;)e.S.pop()})}}},YK=function(a){return a.every(b=>!!ZK(b.S[0]))},$K=function(a,b){a&&b&&[UI,TI].forEach(c=>{if(!uJ(b.aa,c)){var d=a.aa.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.aa.push(e)})}})},bL=function(a,b){yJ(b,(c,d)=>{_.oC(a,c.S,d.startTime)});_.gC(a.a,b[0].startTime,b[b.length-1].endTime)},cL=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},dL=function(a,b){return _.w(function*(){var c=_.yk([b],a.a.attemptParameters);
38
- c.type=1;c=yield a.H(c);let d="";try{d=_.pi(c.data)}catch(e){throw new _.H(_.C,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},oL=function(a,b){return _.w(function*(){var c=eL(a,b,a.w,"");if(1===c.type){var d=c.S[0].a;c=fL(d);if(!c)throw new _.H(_.C,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=kK(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=IJ(c.aa);c=gL(d.Bc.If);c.forEach(m=>{a.J.add(m.groupId)});var e=yield hL(a,d);
39
- var f=e.fi;const g=e.periods;var h=e.zi;const k=e.Ui;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.H(_.C,7,7001);iL(a,g);h=jL(a,f.delay,g,h);kL(a)||(a.G=f.Kd,lL(a));mL(a,h,g);f=nL(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})},qL=function(a,b){return Promise.all(b.map(c=>
40
- pL(a,c)))},sL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!kL(a),f=vJ(c.aa,"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].sa):f=0;if(e&&0<f)try{{const k=vJ(c.aa,WI);if(!k)throw rL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(ZI);const l=Number(k.value),m=GK(d,l);if(!m)throw rL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
41
- ` (segment position = ${l})`),Error(ZI);var h=m.sa}g=h;break a}catch(k){throw new _.H(_.C,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)uJ(k.aa,SI)&&g++,k.sa=g});rK(b)},vL=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,oh:e}=yield tL(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=UJ(g.audio,e),k=UJ(g.video,e);g=uL(a,h,k,g.bandwidth);
42
- if(!g)throw new _.H(_.C,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Ej:k?PJ(k).Da:void 0,audio:h?PJ(h).Da:void 0});return g});return UK(a.D.configurationId,f,c,d,!0)})},iL=function(a,b){kL(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.oD(b,-a.I))},wL=function(a,b){b=b.flatMap(d=>d.S[0].aa);b=vJ(b,XI);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}).`),
43
- null):c/1E3},xL=function(a,b,c){b=b.find(e=>null!==vJ(e.aa,RI));if(!b)return[];if(null===c)throw new _.H(_.C,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.aa.filter(e=>e.name===RI);b=new Map;for(const e of d)d=(d=_.K(e,"ID"))?b.get(d):void 0,(d=TJ(e,c,a.C,!kL(a),d))&&b.set(d.id,d);return Array.from(b.values())},nL=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.Hd!==
44
- d.Hd)a.D.onError(new _.H(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,Hd:d.Hd,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!kJ(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},yL=function(a,b,c){a.A=_.Db;_.kC(b,!0);b.f=c[c.length-1].endTime},eL=function(a,b,c,d){a=gK(a.R,b,c);a.verbatimUri=d;return a},gL=function(a){return a.filter(b=>
45
- b.name===VI&&_.K(b,_.sb)===_.sA&&!_.K(b,_.ub)).map(b=>{const c=VJ(b),d=_.K(b,_.Ka)||_.kg;return{groupId:hJ(b,_.Ea),id:_.vI++,label:hJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.K(b,"DEFAULT")}})},hL=function(a,b){return _.w(function*(){var c=RJ(b.Bc.closedCaptions),d=zL(a,b.Md),e=yield AL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=BJ(g.aa);a.A=h;sL(a,f);!kL(a)&&aL(f);a.K=GJ(g.aa);f=OJ(g.aa,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);
46
- g=yield BL(a,e.Jf,d);c=yield CL(a,e.Md,g,c);d=yield DL(a,e.Ri,d);g=yield EL(a,e.Ke);d=UK(a.D.configurationId,c,d,g,!kL(a));a.D.filterAllPeriods(d);c=[...e.Md,...e.Jf].map(k=>k.playlist);e=wL(a,c);c=xL(a,c,e);return{periods:d,zi:e,Ui:c,fi:f}})},jL=function(a,b,c,d){let e=!0,f=null,g=0;kL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.zI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.kC(a,e);bL(a,c);d&&_.jC(a,d);return a},lL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Tc);
47
- 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.Tc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},mL=function(a,b,c){c=MJ(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)},tL=function(a,
48
- b){return _.w(function*(){const c=g=>PJ(g.stream).type===_.t||PJ(g.stream).type===_.q;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=PJ(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,Nd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return FL(a,h)});
49
- return Promise.all(g)};d=yield f(d);f=yield f(e);GL(a,d.concat(f));e=f.filter(g=>PJ(g).type===_.YA);f=f.filter(g=>PJ(g).type===_.ge);return{textStreams:e,thumbStreams:f,oh:d}})},uL=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?_.NB(l.drmInfos,m.drmInfos)?_.MB(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:_.kg,primary:!!h&&h.primary||
50
- !!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new HL(f)},FL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Rc,g=b.hc,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.Nd,A=_.Nn(f||_.kg);if(1!==c.type)throw new _.H(_.C,4,4017);const D=yield IL(a,c,e,d),E=a.a.lowLatencyMode?_.PA:_.OA;let fa=m;e!==_.J||m||(fa=_.YA);const Vc=
51
- BJ(c.aa);m=D.map(ac=>{const Lb=ac.S,Od=ac.zh,Mb=ac.mimeType,bc=ac.sa,cc=Lb[0].startTime,Bb=Lb[Lb.length-1].endTime,fb=Bb-cc,ua=new _.AI(Lb),rb=Lb[0].initSegment||null;return{id:null===g?_.vI++: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),segmentIndex:ua,segmentLookupStrategy:E,initSegmentReference:rb,mimeType:Mb,codecs:d,kind:fa,Xf:Od.type,
52
- encrypted:Od.type===gJ,aesEncrypted:ac.aesEncrypted,keyId:Od.keyId,language:A,originalLanguage:f||_.kg,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:p,spatialAudio:u,closedCaptions:v,S:Lb,drmInfos:Od.drmInfos,sa:bc,Da:c.verbatimUri,xe:c.a,Tc:cc,Ne:Bb,duration:fb,groupId:h,vj:Vc,muxedAudioId:k}});return new JL(m)})},GL=function(a,b){b.forEach(c=>{a.j.a.set(PJ(c).Da,
53
- c)})},zL=function(a,b){const c=new Map;for(const f of b){var d=_.K(f,_.sA);b=_.K(f,_.Cb);var e=_.K(f,cJ);const g=KL(a,f);if(e){const h=_.Lr(_.J,g);c.set(`${_.J}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=LL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=LL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},AL=function(a,b){return _.w(function*(){const c=yield Promise.all([ML(a,b.Bc.If),ML(a,b.Bc.Si),ML(a,b.Md),ML(a,b.Ke)]),[d,e,f,g]=c;return{Jf:d,Ri:e,Md:f,Ke:g}})},BL=function(a,b,c){return _.w(function*(){if(0===
54
- b.length)return new Map;var d=[NL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>NL(a,e,c)));d=yield Promise.all(d);return QJ(d)})},CL=function(a,b,c,d){return _.w(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(hJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield OL(a,h,c,d,e);f=f.map(k=>OL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.rB,[])})},DL=function(a,b,c){return Promise.all(b.map(d=>NL(a,d,c)))},
55
- EL=function(a,b){return Promise.all(b.map(c=>PL(a,c)))},QL=function(a,b){return _.w(function*(){const c=_.Wm(b.verbatimUri,a.w),{response:d,text:e}=yield dL(a,c);return eL(a,e,d.uri,b.verbatimUri)})},RL=function(a,b,c){return _.w(function*(){const d=yield FL(a,{playlist:c,codecs:b.codecs,type:b.type,Rc:b.originalLanguage,hc: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,Nd:{width:b.width,
56
- height:b.height,frameRate:b.frameRate}});b.bandwidth&&LK(d,b.bandwidth);return d})},kL=function(a){return a.A===_.Db},ML=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield SL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},pL=function(a,b){return _.w(function*(){var c=new URL(PJ(b).xe);if(a.a.lowLatencyMode&&a.K&&a.K.Of){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={gi:d.position,ri:e&&
57
- 0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.ri,d.set("_HLS_msn",e.gi.toString()),null===f&&d.get(dJ)&&d.delete(dJ),null!==f&&d.set(dJ,f.toString())}const {response:g,text:h}=yield dL(a,c.toString());c=PJ(b).Da;d=PJ(b).xe;e=g.uri;d!==e&&(d=e,HK(b,d));c=eL(a,h,d,c);return{stream:b,playlist:c}})},KL=function(a,b){var c=_.K(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=SJ(c);b=new Set;const d=[];for(const e of c)c=_.xB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):
58
- (d.push(e),b.add(c));return d},LL=function(a,b){if(1===b.length)return b[0];a=_.Lr(a,b);if(null!=a)return a;throw new _.H(_.C,4,4025,{codecList:b});},NL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return TL(a,e.verbatimUri,()=>_.w(function*(){const f=hJ(d,_.Ea),g=CJ(hJ(d,_.sb));var h=hJ(d,_.sb).toUpperCase();if(CJ(h)!==_.J)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.YA;h===OI&&(l=_.JA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||
59
- "";l=_.K(d,_.Ka);const m=_.K(d,_.Sa),n=_.K(d,"DEFAULT"),p=g===_.q?VJ(d):null;var u=g===_.q?(u=_.K(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield FL(a,{playlist:e,codecs:k,type:g,Rc:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,closedCaptions:null,Nd:null})}))})},PL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return TL(a,d.verbatimUri,()=>_.w(function*(){var e=_.K(c,_.pa)||"jpg",f=_.K(c,_.Ka);const g=_.K(c,_.Sa);e=yield FL(a,{playlist:d,
60
- codecs:e,type:_.ge,Rc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,hc:null,groupId:null,Nd:null});(f=_.K(c,_.ma))&&LK(e,Number(f));return e}))})},OL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(hJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.kb)){var h=_.K(f,"FRAME-RATE");f=_.K(f,_.kb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:nJ(h),width:nJ(k),height:nJ(l)}}else h=null;if(f=yield UL(a,b,h,c,d)){h=f.video;f=f.audio;var m=
61
- 0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?PJ(p).Da:"")+" - "+(n?PJ(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=uL(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})},VL=function(a,b,c,d,e,f){let g=KL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Lr(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),
62
- c=_.t,g=[g.join(",")]):d&&f?(a.g.debug($I),c=_.q,b=!0):e?(a.g.debug($I),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug($I));return{type:c,mh:g,Yh:b}},TL=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},UL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.K(f,_.sA),k=_.K(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};
63
- const l=g.verbatimUri;g=k.audio.find(u=>PJ(u).Da===l);const {type:m,mh:n,Yh:p}=VL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield WL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{IK(u,c.width);JK(u,c.height);KK(u,c.frameRate)});return k})},WL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return TL(a,h.verbatimUri,()=>_.w(function*(){var k=_.K(g,OI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.K(g,_.sA)||void 0)&&a.J.has(k)?
64
- k:void 0;var m=LL(d,c);if(k){const n=LL(_.q,c);m+=`,${n}`}return yield FL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Rc:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,Nd:f})}))})},IL=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=vJ(b.aa,WI))?Number(h.value):g;g=[];e=yield XL(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)uJ(m.aa,SI)&&0<l.length&&(k.push(l),l=
65
- []),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield YL(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;ZL(g);return g})},SL=function(a,b){return _.w(function*(){var c=b.name!==VI?!0:_.K(b,_.sb)===cJ;c=_.K(b,_.ub,void 0,{required:c});if(!c)return null;const d=_.Wm(c,a.w),e=Date.now(),{response:f,text:g}=yield dL(a,d);a.D.onEvent(new _.G(fJ,{detail:{duration:Date.now()-e,type:"media"}}));return eL(a,g,f.uri,c)})},ZL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.C,
66
- 4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},$L=function(a,b,c){a=rJ(a.aa,UI);if(1<a.length)throw new _.H(_.C,4,4020);a=a[0];if(!a)return null;const d=hJ(a,_.ub),e=_.Wm(d,b);b=HJ(a,null,!0);return new _.wI(()=>[e],b.ma,b.ja,c)},aM=function(a,b,c,d,e,f,g){const h=[];for(const p of mJ(b.f)){b=p.kg;const u=p.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.K(u,QI));n=m+n;k=HJ(u,k?null:l.ja,k);l=_.K(u,_.ub);const v=
67
- (l=_.Wm(l,g))?[l]:[];m=new JJ(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.K(u,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},bM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.aa;var p=c.a;0<rJ(n,UI).length&&(m=$L(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}=FJ(n),a=e+c,p=EJ(n,b?b.ja:null)):(b=aM(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ge?wJ(n):null;d=new JJ(d,e,a,()=>v,p.ma,p.ja,f,g,!1,null,h?
68
- h.od:null,h?h.Ld:null,h?h.durationPerTile:null,y,m);d.sa=l;return d},XL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.C)return a.C;if(!kL(a)&&a.f)try{var k=a.j.get(c);var l=k?GK(k,e)||null:null;if(!l)throw new _.H(_.C,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].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+
69
- `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.C,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield cM(a,f,g,h);l=CK(h.aa,a.w,e);k=$L(h,b,l);h=yield dM(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},YL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0],l=null==h;const m=yield cM(a,f,g,k);var n=h?h.di:null;if(uJ(c[0].aa,TI)||null===n)n=zK(c,m),n=0===n.length?[vK()]:n;else{var p=zK(c,m);n=[n,
70
- ...p]}p=n;n=p[p.length-1];p=wK(p);let u=h?h.ei:null;var v=eM(u,k.aa,a.w,d);let y=$L(k,b,v)||(h?h.Zh:null);const A=k.sa;k=l?e:yield fM(a,A,y,k,d,v,m,g);l=[];v=!1;for(let E=0;E<c.length;E++){var D=c[E];const fa=l[l.length-1]||null,Vc=0===E?0:fa.endTime,ac=d+E,Lb=eM(u,D.aa,a.w,ac);(u=Lb)&&(v=!0);if(D=bM(a,fa,D,ac,Vc,k,Lb,f,b,A,y))y=D.initSegment,l.push(D)}return{S:l,zh:p,di:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,sa:A,Zh:y,ei:u}})},cM=function(a,b,c,d){return _.w(function*(){const e=
71
- d.a;var f=vJ(d.aa,UI);f=f?hJ(f,_.ub):null;return gM(a,b,c,e,f)})},dM=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=KJ(c,d);return EK(a.T,b,g,e,f,null!=d)})},eM=function(a,b,c,d){return b.some(e=>e.name===TI&&"NONE"===_.K(e,aJ))?null:(b=CK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.lm(new Uint8Array(12),pJ(d))}):a},fM=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 dM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+
72
- `${k} s.`);a.L.set(b,k);return k})},gM=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Or(f,b,c);if(g)return g;g=_.yk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.H(_.C,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},fL=a=>{a=_.Xm(a)||"";return null!=_.Du.video[a]?_.t:null!=_.Du.audio[a]?_.q:null},aK=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.C,
73
- 4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.C,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.aa=c;this.S=1===b?d:null}},jK=class{constructor(a,b,c){c=void 0===c?[]:c;this.aa=b;this.a=a;this.f=c;this.sa=-1}},JJ=class extends _.BC{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:
74
- n,void 0===p?null:p,u,void 0===v?null:v);this.sa=0}},hK=/^#EXT-X-DEFINE/,iK=/^#(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)/,hM=class{constructor(){this.h=0;this.a=new Map}},iM=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)||
75
- null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},rL=new _.S("clpp.hls.DiscontinuityUtils");var BK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.yg)throw new _.H(_.C,4,4041);if(hJ(a,aJ)===bJ)throw new _.H(_.C,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.uB(_.rd,[{initDataType:_.Mf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":uK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":uK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=hJ(a,aJ);if(!sK.includes(b))return tK.error("Widevine in HLS is only supported with [",
76
- sK.join(", "),"], not",b),null;b=hJ(a,_.ub);b=_.mm(b);b=_.F(b.data);b=_.uB(_.vd,[{initDataType:_.Uc,initData:b}],"");if(a=_.K(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},sK=["SAMPLE-AES",bJ],tK=new _.S("clpp.hls.DrmParser");var AK=new _.S("clpp.hls.EncryptionUtils");var jM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.uk()}}};var JL=class{constructor(a){this.streams=a}length(){return this.streams.length}};var HL=class{constructor(a){this.a=a}length(){return this.a.length}};var ZK=a=>{if(!a)return null;a=vJ(a.aa,XI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var kM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new iM;this.w="";this.R=new hM;this.G=0;this.o=null;this.l=new _.Ni(()=>{this.Tb()});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 jM(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!");
77
- c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield dL(c,a);c.D.onEvent(new _.G(fJ,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield oL(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(!kL(a)&&
78
- 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=cL(a);d=d.filter(h=>g.includes(PJ(h).Da))}var e=yield qL(a,d);d=e.map(g=>g.playlist);sL(a,d);e=yield vL(a,e);NK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});iL(a,e);var f=wL(a,d);f=xL(a,d,f);b.cues=nL(a,f);PK(b.periods,e);bL(c,e);if(d=zJ(d))!0!==a.a.keepTimelineLive&&yL(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();
79
- 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 _.sl(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=TL(c,k.verbatimUri,()=>_.w(function*(){const l=yield QL(c,k);return RL(c,k,l)}))}if(e.video){const k=e.video;g=TL(c,k.verbatimUri,()=>_.w(function*(){const l=yield QL(c,
80
- k);return RL(c,k,l)}))}f=yield f;g=yield g;e=uL(c,f,g,e.bandwidth,e.id);let h;e&&(e=UK(c.D.configurationId,[e],[],[],!kL(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 _.sl(`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=
81
- c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.sl(`Could not load text stream with id: ${a}`);const g=yield TL(c,f.verbatimUri,()=>_.w(function*(){const h=yield QL(c,f);return RL(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 _.sl(`Could not load text stream with id: ${a}`);return d})}Tb(){const a=this;return _.w(function*(){a.g.debug(_.EA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
82
- _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}H(a){if(!this.F)throw new _.H(_.C,7,7001);a=this.D.networkingEngine.fetch(a);_.Il(this.F,a);return a.U}};_.x("clpp.hls.HlsComponent",class extends _.Ev{install(){_.Kt.m3u8=kM;_.Jt[_.wl]=kM;_.Jt[eJ]=kM}uninstall(){_.XC("m3u8");_.YC(_.wl);_.YC(eJ)}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 HI="CLOSED-CAPTIONS",II="Could not parse MP4 segment start time.",JI="DURATION",KI="EXT-X-DATERANGE",LI="EXT-X-DISCONTINUITY",MI="EXT-X-KEY",NI="EXT-X-MAP",OI="EXT-X-MEDIA",PI="EXT-X-MEDIA-SEQUENCE",QI="EXT-X-PROGRAM-DATE-TIME",RI="EXT-X-STREAM-INF",SI="Failed to infer discontinuity number",TI="Guessing audio-only",UI="METHOD",VI="SAMPLE-AES-CTR",WI="SUBTITLES",XI="_HLS_part",YI="application/vnd.apple.mpegurl",ZI="manifestloaded",$I="sample",aJ=function(a,b){return _.L(a,b,void 0,
2
+ {required:!0})},bJ=function(a){if(1>a.a)throw _.To();--a.a},cJ=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===_.He&&e&&typeof e===_.He){if(!cJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},dJ=function(a,b){if(!cJ(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===_.He&&e&&typeof e===_.He&&dJ(d,e))return!0}return!1},eJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
3
+ for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.He&&typeof d===_.He){if(eJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},fJ=function(a){if(null!==a&&void 0!==a)return Number(a)},gJ=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},hJ=function(a){return new Uint8Array([a>>
4
+ 24&255,a>>16&255,a>>8&255,a&255])},iJ=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},jJ=function(a,b){return a.filter(c=>c.name===b)},kJ=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.L(d,"VALUE"),f=_.L(d,_.Sa),g=_.L(d,"IMPORT"),h=_.L(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.I(_.D,4,4044,{message:"Invalid tag.",text:d.toString()});
5
+ d=f||g||h;if(c.has(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.I(_.D,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},lJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=aJ(d,_.tb);return c.includes(d)})},mJ=function(a,b){return a.some(c=>c.name===b)},nJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.I(_.D,4,4024,{missingTag:b});return a},oJ=function(a){var b=nJ(a,
6
+ "EXT-X-TILES");if(!b)return{sd:1,Nd:1,durationPerTile:null};a=_.L(b,"LAYOUT")||"1x1";b=_.L(b,JI);a=_.zB(a);return{sd:a.sd,Nd:a.Nd,durationPerTile:b?Number(b):null}},pJ=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)},qJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of pJ(c))b(d,c)})},rJ=function(a){return a.some(b=>mJ(b.aa,"EXT-X-ENDLIST"))},
7
+ sJ=function(a){return a.type===_.q||a.type===_.t},tJ=function(a){if(nJ(a,"EXT-X-ENDLIST"))return _.Fb;a=nJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Fb)return _.Fb;if("EVENT"===a.value)return"EVENT";throw new _.I(_.D,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},uJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.K,"CLOSED-CAPTIONS":_.K}[a.toUpperCase()];if(!a)throw new _.I(_.D,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},vJ=function(a,b,c){c=void 0===
8
+ c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.I(_.D,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.I(_.D,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.I(_.D,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.I(_.D,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}},wJ=function(a,b){a=nJ(a,"EXT-X-BYTERANGE");
9
+ return vJ(a?a.value:null,b)},xJ=function(a){a=nJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.I(_.D,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},yJ=function(a,b){b=void 0===b?{}:b;const c={Wf:!1,Ah:!1,Bh:null,di:null,Jg:null};a=nJ(a,"EXT-X-SERVER-CONTROL",{required:b.Sg});if(!a)return c;const d=e=>null==e?null:Number(e);c.Wf="YES"===_.L(a,"CAN-BLOCK-RELOAD");c.Ah="YES"===_.L(a,"CAN-SKIP-DATERANGES");c.Bh=d(_.L(a,"CAN-SKIP-UNTIL"));
10
+ c.di=d(_.L(a,"HOLD-BACK"));c.Jg=d(_.L(a,"PART-HOLD-BACK",void 0,{required:b.Sg}));return c},zJ=function(a,b,c){c=void 0===c?!1:c;a=_.L(a,"BYTERANGE");return vJ(a,b,c)},AJ=function(a){const b=jJ(a,OI),c=jJ(a,RI);a=jJ(a,"EXT-X-IMAGE-STREAM-INF");return{Ec:{Qf:lJ(b,[_.lA,_.Db]),closedCaptions:lJ(b,HI),Yi:lJ(b,WI)},Od:c,Qe:a}},CJ=function(a,b){const c=wJ(a.aa,null);return new BJ(0,0,0,()=>[a.a],c.ma,c.ja,0,b)},DJ=function(a){let b=Infinity,c=Infinity;pJ(a).filter(sJ).forEach(d=>{{d=d.S;var e=d[0].startTime;
11
+ const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{Wc:b,duration:c}},EJ=function(a){return a.map(b=>{({duration:b}=DJ(b));return b}).reduce((b,c)=>b+c,0)},FJ=function(a){return(a.video?a.video.Da:"")+" - "+(a.audio?a.audio.Da:"")},GJ=function(a,b,c,d,e){if(b===_.Fb)return{delay:0,Md:0};b=nJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(aJ(b,"PART-TARGET"));if(null!=d)return{delay:d,Md:e};({Jg:d}=yJ(a,{Sg:!0}));return{delay:d,Md:e}}a=nJ(a,"EXT-X-TARGETDURATION",{required:!0});
12
+ a=Number(a.value);e=e||a;return null!=d?{delay:d,Md:e}:{delay:3*a,Md:e}},IJ=function(a){const b=new Map;a.forEach(c=>{var d=`${HJ(c).type}:${HJ(c).groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},JJ=function(a){const b=new Map;for(const c of a){a=_.L(c,_.Ka);a=_.Hn(a||_.kg);const d=aJ(c,_.Ea),e=aJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},KJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},LJ=function(a,b,c,d,e){var f=e&&e.Kd,g=e&&e.schemeIdUri,
13
+ h=_.L(a,"ID");f=_.L(a,"START-DATE")||f;if(null===h||!f)return _.fv.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Kd:f};f=fJ(_.L(a,JI));void 0!==f&&0<=f&&(h.duration=f);f=fJ(_.L(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.L(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.L(a,"END-DATE"))?new Date(f):null;null!==
14
+ f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.fh(d)?d:null}k=k||{};(d=_.L(a,"CUE"))&&(k.CUE=d.split(","));if(_.gk(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Mb:d[_.Mb]=l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Rb:d[_.Rb]=fJ(l.value);break;case _.Pb:d[_.Pb]=fJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;case _.Qb:d[_.Qb]=
15
+ l.value.split(",")}l=_.fh(d)?d:null}l&&(k=Object.assign(k,l))}_.fh(k)&&(h.customAttributes=k);if(eJ(e,h))return _.fv.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.ch(e,h);if(_.gk(g)&&!_.hk(h.customAttributes))return _.fv.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=
16
+ _.de;return h},MJ=function(a,b){if(!a)return null;const c=a.Da;return b.find(d=>HJ(d).Da===c)||null},NJ=function(a){return(a=_.L(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},OJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},PJ=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.L(e,_.Sa),g=_.L(e,"QUERYPARAM");if(f)g=aJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.I(_.D,4,4044,`Query param '${g}' missing in playlist URI.`);
17
+ if(!f)throw new _.I(_.D,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},QJ=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.I(_.D,4,4044,`Undefined variable '${d}'`);return c})},RJ=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=QJ(d.value,b)})})},UJ=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=SJ(a,b[e]);d.push(f);if(f.name===RI){const g=b[e+1];if(!g)throw new _.I(_.D,
18
+ 4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.lr(_.vb,g));e++}}b=jJ(d,"EXT-X-DEFINE");kJ(b);b=PJ(b,c);a.a=b;RJ(d,a.a);return new TJ(c,0,d)},YJ=function(a,b,c){const {Li:d,ci:e,ij:f}=VJ(b),g=WJ(a,f,c);b=e.map(k=>SJ(a,k,g));const h=XJ(a,c,d,g);return new TJ(c,1,b,h)},ZJ=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(_.D,4,4015);b=b.slice(1);return 0===OJ(b)?UJ(a,b,
19
+ c):YJ(a,b,c)},VJ=function(a){const b=[],c=[],d=[];for(const e of a)$J.test(e)?d.push(e):aK.test(e)?c.push(e):b.push(e);return{Li:b,ci:c,ij:d}},WJ=function(a,b,c){b=b.map(e=>SJ(a,e));kJ(b);const d=PJ(b,c);b.map(e=>_.L(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.I(_.D,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},SJ=function(a,b,c){a=_.nr(a.h++,b);c&&RJ([a],c);return a},XJ=function(a,b,c,d){const e=
20
+ [];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=SJ(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.L(h,_.tb)?g.push(h):f.push(h)):(mJ(f,"EXT-X-GAP")||(h=QJ(h,d),h=_.Qm(h,b),e.push(new bK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new bK(null,f,g));return e},cK=function(a,b,c){const d=[],e=[];e.push(new _.lr(_.ma,"0"));e.push(new _.lr(_.vb,b));c.length&&e.push(new _.lr(_.pa,c));d.push(new _.mr(a.h++,RI,e));return new TJ(b,0,d)},dK=function(a){function b(h,k,l){let m="";for(;k<
21
+ 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(_.D,4,4030);}iJ(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
+ 22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}iJ(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},eK=function(a,b){let c=null,d=0;try{(new _.ip).N(_.De,_.bp).N(_.hg,_.bp).N(_.ye,_.bp).ea("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.N(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(_.D,4,4030,II,c);let e=0,f=!1;try{(new _.ip).N("moof",_.bp).N("traf",_.bp).ea("tfdt",g=>{var h=d;if(0===
23
+ g.version)h=_.N(g.reader)/h;else{{const k=_.N(g.reader),l=_.N(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(_.D,4,4030,II,c);return e},fK=function(a){for(;a.getPosition()<a.Oa()-1;){const b=a.getPosition();if(71===_.Uo(a))return bJ(a),b}return-1},gK=function(a){function b(){d.seek(e+188);f=_.Uo(d);
24
+ 71!==f&&(d.seek(e+192),f=_.Uo(d));71!==f&&(d.seek(e+204),f=_.Uo(d));71!==f&&c();bJ(d)}function c(){throw new _.I(_.D,4,4030);}const d=new _.aq(new DataView(a),!1);let e=0,f=0;e=fK(d);0>e&&(_.Mv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Uo(d);71!==f&&c();a=_.Vo(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Uo(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Uo(d),d.skip(a));if(1!==_.N(d)>>8){b();continue}d.skip(3);a=_.Uo(d)>>6;0!==a&&1!==
25
+ a||c();0===_.Uo(d)&&c();a=_.Uo(d);const g=_.Vo(d),h=_.Vo(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},jK=function(a){const b=hK(a),c=iK(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.sa===b);let g=e.findIndex(h=>h.sa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},iK=function(a){a=a.map(b=>b.S[b.S.length-1].sa);return Math.min(...a)},hK=function(a){a=a.map(b=>b.S[0].sa);return Math.max(...a)},mK=function(a){var b=aJ(a,UI);if(!kK.includes(b))return lK.error("PlayReady in HLS is only supported with [",
26
+ kK.join(", "),"], not",b),null;a=aJ(a,_.vb);b=_.gm(a);a=null;b=_.G(b.data);try{a=_.$A(_.hq(b))}catch(c){a=b}return _.nB(_.ud,[{initDataType:_.Wc,initData:a}],"")},oK=function(a){if(0===a.length)return nK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Ge))return a[0];a=a.filter(c=>c.type===$I);const b=_.ci(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:$I,drmInfos:b}},rK=function(a,b){return pK(a).map(c=>qK(c.aa,b)).filter(Boolean)},pK=function(a){return a.filter(b=>
27
+ mJ(b.aa,MI))},qK=function(a,b){a=jJ(a,MI).filter(d=>"AES-128"!==aJ(d,UI));if(0===a.length)return null;var c=aJ(a[0],UI);if(1===a.length&&"NONE"===c)return nK();c=a.map(d=>aJ(d,UI));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===VI))throw sK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.I(_.D,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.L(d,"KEYFORMAT","identity");{const f=tK[e]||null;d=f?f(d,b):null}d||sK.warn("Unsupported HLS KEYFORMAT",
28
+ e);return d}).filter(Boolean);if(0===a.length)throw new _.I(_.D,4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:$I,drmInfos:a}},nK=function(){return{type:_.Ge,drmInfos:[],keyId:null}},uK=function(a,b,c){a=jJ(a,MI)[0];if(!a||"AES-128"!==aJ(a,UI))return null;var d=_.L(a,"IV","");d?c={iv:_.cm((d||"0x").slice(2)),generatedIv:!1}:(d=_.L(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.fm(new Uint8Array(12),hJ(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,
29
+ generatedIv:f}=c;return{method:"AES-128",url:_.Qm(aJ(a,_.vb),b),iv:e,generatedIv:f}},vK=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.VB(b.Ea(),b.ma,b.ma+2048-1,a.a.attemptParameters);e.type=2;const f=_.VB(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.",
30
+ 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(_.D,4,4030,"Failed to fetch the media segment.");}}})},wK=function(a,b,c,d,e,f){return _.w(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Gc||d===_.Fc)return 0;if(d===_.Ec){var g=yield vK(a,c,f);g=_.G(g.data);if(!iJ(g))throw new _.I(_.D,4,4030,"AAC segment does not contain an ID3 tag.");return dK(g)}if(d===_.zg||d===
31
+ _.Hc)return g=[vK(a,c,f)],b&&g.push(vK(a,b,!0)),g=yield Promise.all(g),eK(g[0].data,(g[1]||g[0]).data);if(d===_.yg)return g=yield vK(a,c,f),gK(g.data);if(!_.gt(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.I(_.D,4,4030);})},xK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},yK=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},HJ=function(a){return a.streams[0]},
32
+ zK=function(a,b){a.streams.forEach(c=>{c.Be=b})},AK=function(a,b){a.streams.forEach(c=>{c.width=b})},BK=function(a,b){a.streams.forEach(c=>{c.height=b})},CK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},DK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},EK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},FK=function(a,b){const c=new Set(a.map(d=>d.sa));return b.filter(d=>!c.has(d.sa))},HK=function(a,b){for(;a[0].sa<b[0].sa;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===
33
+ d.startTime&&c.endTime===d.endTime||GK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&GK(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},MK=function(a,b,c,d,e){var f=b[0].length();f=gJ(f).map(g=>{var h=EK(b,g)||[];const k=xK(c,g)||[];g=xK(d,g)||[];{const l=[...IK(h),...k,...g].filter(Boolean);JK(l);const {sa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,sa:m}}return h});e&&KK(f[0]);
34
+ LK(f);return f},IK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},KK=function(a){const b=IK(a.variants)[0].S[0].Ca;a.startTime+=b;a.endTime+=b},LK=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}},GK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;NK(a.variants,b.variants);OK(pJ(a),pJ(b))},NK=function(a,b){const c=new Map(a.map(d=>[FJ(d),
35
+ d]));b.forEach(d=>{c.get(FJ(d)).drmInfos=d.drmInfos})},OK=function(a,b){const c=new Map(a.map(d=>[d.Da,d]));b.forEach(d=>{const e=c.get(d.Da);e.S=d.S;d.S.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.S);e.Wc=d.Wc;e.Ue=d.Ue;e.duration=d.duration;e.eg=d.eg;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},JK=function(a){const b=PK(a);a.forEach(c=>{_.RB(c.segmentIndex,b);c.duration=b;c.Ue=c.Wc+b})},PK=function(a){let b=Infinity;a.filter(sJ).forEach(c=>{b=
36
+ Math.min(b,c.duration)});return b},TK=function(a){if(!(2>a.length)&&QK(a)){a=a.map(e=>({playlist:e,ag:RK(e.S[0])}));var b=a.map(e=>e.ag),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.ag;0<f.S.length&&1E3<c-e;){var g=f.S.shift(),h=f.S[0];if(!h)break;SK(g,h);h=RK(h);null!=h?e=h:({duration:h}=xJ(g.aa),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.S.length))throw new _.I(_.D,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>
37
+ e.S.length));a.forEach(e=>{for(;e.S.length>d;)e.S.pop()})}}},QK=function(a){return a.every(b=>!!RK(b.S[0]))},SK=function(a,b){a&&b&&[NI,MI].forEach(c=>{if(!mJ(b.aa,c)){var d=a.aa.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.aa.push(e)})}})},UK=function(a,b){qJ(b,(c,d)=>{_.hC(a,c.S,d.startTime)});_.$B(a.a,b[0].startTime,b[b.length-1].endTime)},VK=function(a){return null===a.o?[]:[a.o.audio,a.o.video].filter(b=>b).map(b=>b.Da)},WK=function(a,b){return _.w(function*(){var c=_.wk([b],a.a.attemptParameters);
38
+ c.type=1;c=yield a.H(c);let d="";try{d=_.ni(c.data)}catch(e){throw new _.I(_.D,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},gL=function(a,b){return _.w(function*(){var c=XK(a,b,a.w,"");if(1===c.type){var d=c.S[0].a;c=YK(d);if(!c)throw new _.I(_.D,4,4021,`Unknown file extension ${d}`);d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=cK(a.R,a.w,a.a.hlsDefaultCodecs||d)}d=AJ(c.aa);c=ZK(d.Ec.Qf);c.forEach(m=>{a.J.add(m.groupId)});var e=yield $K(a,d);
39
+ var f=e.mi;const g=e.periods;var h=e.Fi;const k=e.$i;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.I(_.D,7,7001);aL(a,g);h=bL(a,f.delay,g,h);cL(a)||(a.G=f.Md,dL(a));eL(a,h,g);f=fL(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})},iL=function(a,b){return Promise.all(b.map(c=>
40
+ hL(a,c)))},kL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!cL(a),f=nJ(c.aa,"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].sa):f=0;if(e&&0<f)try{{const k=nJ(c.aa,PI);if(!k)throw jL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(SI);const l=Number(k.value),m=yK(d,l);if(!m)throw jL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
41
+ ` (segment position = ${l})`),Error(SI);var h=m.sa}g=h;break a}catch(k){throw new _.I(_.D,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)mJ(k.aa,LI)&&g++,k.sa=g});jK(b)},nL=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,vh:e}=yield lL(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=MJ(g.audio,e),k=MJ(g.video,e);g=mL(a,h,k,g.bandwidth);
42
+ if(!g)throw new _.I(_.D,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Lj:k?HJ(k).Da:void 0,audio:h?HJ(h).Da:void 0});return g});return MK(a.D.configurationId,f,c,d,!0)})},aL=function(a,b){cL(a)||2!==a.a.timeline.version||(a.I||(a.I=b[0].startTime),_.hD(b,-a.I))},oL=function(a,b){b=b.flatMap(d=>d.S[0].aa);b=nJ(b,QI);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}).`),
43
+ null):c/1E3},pL=function(a,b,c){b=b.find(e=>null!==nJ(e.aa,KI));if(!b)return[];if(null===c)throw new _.I(_.D,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.aa.filter(e=>e.name===KI);b=new Map;for(const e of d)d=(d=_.L(e,"ID"))?b.get(d):void 0,(d=LJ(e,c,a.C,!cL(a),d))&&b.set(d.id,d);return Array.from(b.values())},fL=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.Kd!==
44
+ d.Kd)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,Kd:d.Kd,endTime:d.endTime,id:d.id,type:_.de,eventElement:null};b&&!dJ(b,e)||a.B.set(d.id,e)}return Array.from(a.B.values())},qL=function(a,b,c){a.A=_.Fb;_.dC(b,!0);b.f=c[c.length-1].endTime},XK=function(a,b,c,d){a=ZJ(a.R,b,c);a.verbatimUri=d;return a},ZK=function(a){return a.filter(b=>
45
+ b.name===OI&&_.L(b,_.tb)===_.lA&&!_.L(b,_.vb)).map(b=>{const c=NJ(b),d=_.L(b,_.Ka)||_.kg;return{groupId:aJ(b,_.Ea),id:_.oI++,label:aJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.L(b,"DEFAULT")}})},$K=function(a,b){return _.w(function*(){var c=JJ(b.Ec.closedCaptions),d=rL(a,b.Od),e=yield sL(a,b),f=Object.values(e).flat().map(k=>k.playlist),g=f[0];const h=tJ(g.aa);a.A=h;kL(a,f);!cL(a)&&TK(f);a.K=yJ(g.aa);f=GJ(g.aa,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);
46
+ g=yield tL(a,e.Rf,d);c=yield uL(a,e.Od,g,c);d=yield vL(a,e.Xi,d);g=yield wL(a,e.Qe);d=MK(a.D.configurationId,c,d,g,!cL(a));a.D.filterAllPeriods(d);c=[...e.Od,...e.Rf].map(k=>k.playlist);e=oL(a,c);c=pL(a,c,e);return{periods:d,Fi:e,$i:c,mi:f}})},bL=function(a,b,c,d){let e=!0,f=null,g=0;cL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=void 0;a=new _.sI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.dC(a,e);UK(a,c);d&&_.cC(a,d);return a},dL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].Wc);
47
+ 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.Wc?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},eL=function(a,b,c){c=EJ(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===_.Fb&&(b.f=c)},lL=function(a,
48
+ b){return _.w(function*(){const c=g=>HJ(g.stream).type===_.t||HJ(g.stream).type===_.q;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=HJ(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,Pd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return xL(a,h)});
49
+ return Promise.all(g)};d=yield f(d);f=yield f(e);yL(a,d.concat(f));e=f.filter(g=>HJ(g).type===_.RA);f=f.filter(g=>HJ(g).type===_.ge);return{textStreams:e,thumbStreams:f,vh:d}})},mL=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?_.GB(l.drmInfos,m.drmInfos)?_.FB(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:_.kg,primary:!!h&&h.primary||
50
+ !!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new zL(f)},xL=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Uc,g=b.lc,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.Pd,A=_.Hn(f||_.kg);if(1!==c.type)throw new _.I(_.D,4,4017);const E=yield AL(a,c,e,d),B=a.a.lowLatencyMode?_.IA:_.HA;let F=m;e!==_.K||m||(F=_.RA);const ia=
51
+ tJ(c.aa);m=E.map(Xa=>{const cb=Xa.S,rc=Xa.Gh,Ob=Xa.mimeType,cc=Xa.sa,dc=cb[0].startTime,Eb=cb[cb.length-1].endTime,ib=Eb-dc,wa=new _.tI(cb),wb=cb[0].initSegment||null;return{id:null===g?_.oI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:wa.f.bind(wa),getSegmentReference:wa.get.bind(wa),adjustSegmentDurations:wa.h.bind(wa),getDuration:wa.getDuration.bind(wa),segmentIndex:wa,segmentLookupStrategy:B,initSegmentReference:wb,mimeType:Ob,codecs:d,kind:F,eg:rc.type,
52
+ encrypted:rc.type===$I,aesEncrypted:Xa.aesEncrypted,keyId:rc.keyId,language:A,originalLanguage:f||_.kg,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:p,spatialAudio:u,closedCaptions:v,S:cb,drmInfos:rc.drmInfos,sa:cc,Da:c.verbatimUri,Be:c.a,Wc:dc,Ue:Eb,duration:ib,groupId:h,Cj:ia,muxedAudioId:k}});return new BL(m)})},yL=function(a,b){b.forEach(c=>{a.j.a.set(HJ(c).Da,
53
+ c)})},rL=function(a,b){const c=new Map;for(const f of b){var d=_.L(f,_.lA);b=_.L(f,_.Db);var e=_.L(f,WI);const g=CL(a,f);if(e){const h=_.Fr(_.K,g);c.set(`${_.K}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=DL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=DL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},sL=function(a,b){return _.w(function*(){const c=yield Promise.all([EL(a,b.Ec.Qf),EL(a,b.Ec.Yi),EL(a,b.Od),EL(a,b.Qe)]),[d,e,f,g]=c;return{Rf:d,Xi:e,Od:f,Qe:g}})},tL=function(a,b,c){return _.w(function*(){if(0===
54
+ b.length)return new Map;var d=[FL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>FL(a,e,c)));d=yield Promise.all(d);return IJ(d)})},uL=function(a,b,c,d){return _.w(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(aJ(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield GL(a,h,c,d,e);f=f.map(k=>GL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.kB,[])})},vL=function(a,b,c){return Promise.all(b.map(d=>FL(a,d,c)))},
55
+ wL=function(a,b){return Promise.all(b.map(c=>HL(a,c)))},IL=function(a,b){return _.w(function*(){const c=_.Qm(b.verbatimUri,a.w),{response:d,text:e}=yield WK(a,c);return XK(a,e,d.uri,b.verbatimUri)})},JL=function(a,b,c){return _.w(function*(){const d=yield xL(a,{playlist:c,codecs:b.codecs,type:b.type,Uc:b.originalLanguage,lc: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,Pd:{width:b.width,
56
+ height:b.height,frameRate:b.frameRate}});b.bandwidth&&DK(d,b.bandwidth);return d})},cL=function(a){return a.A===_.Fb},EL=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield KL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},hL=function(a,b){return _.w(function*(){var c=new URL(HJ(b).Be);if(a.a.lowLatencyMode&&a.K&&a.K.Wf){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={ni:d.position,Ai:e&&
57
+ 0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Ai,d.set("_HLS_msn",e.ni.toString()),null===f&&d.get(XI)&&d.delete(XI),null!==f&&d.set(XI,f.toString())}const {response:g,text:h}=yield WK(a,c.toString());c=HJ(b).Da;d=HJ(b).Be;e=g.uri;d!==e&&(d=e,zK(b,d));c=XK(a,h,d,c);return{stream:b,playlist:c}})},CL=function(a,b){var c=_.L(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=KJ(c);b=new Set;const d=[];for(const e of c)c=_.qB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):
58
+ (d.push(e),b.add(c));return d},DL=function(a,b){if(1===b.length)return b[0];a=_.Fr(a,b);if(null!=a)return a;throw new _.I(_.D,4,4025,{codecList:b});},FL=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return LL(a,e.verbatimUri,()=>_.w(function*(){const f=aJ(d,_.Ea),g=uJ(aJ(d,_.tb));var h=aJ(d,_.tb).toUpperCase();if(uJ(h)!==_.K)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.RA;h===HI&&(l=_.CA);k&&(l=_.Zd);h=l}k=c.get(`${g}:${f}`)||
59
+ "";l=_.L(d,_.Ka);const m=_.L(d,_.Sa),n=_.L(d,"DEFAULT"),p=g===_.q?NJ(d):null;var u=g===_.q?(u=_.L(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield xL(a,{playlist:e,codecs:k,type:g,Uc:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,lc:null,closedCaptions:null,Pd:null})}))})},HL=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return LL(a,d.verbatimUri,()=>_.w(function*(){var e=_.L(c,_.pa)||"jpg",f=_.L(c,_.Ka);const g=_.L(c,_.Sa);e=yield xL(a,{playlist:d,
60
+ codecs:e,type:_.ge,Uc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,lc:null,groupId:null,Pd:null});(f=_.L(c,_.ma))&&DK(e,Number(f));return e}))})},GL=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(aJ(f,_.ma));if(f.hasAttribute("FRAME-RATE")||f.hasAttribute(_.mb)){var h=_.L(f,"FRAME-RATE");f=_.L(f,_.mb);var [k,l]=f?f.split("x"):[null,null];h={frameRate:fJ(h),width:fJ(k),height:fJ(l)}}else h=null;if(f=yield ML(a,b,h,c,d)){h=f.video;f=f.audio;var m=
61
+ 0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const p of h){m=(p?HJ(p).Da:"")+" - "+(n?HJ(n).Da:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=mL(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})},NL=function(a,b,c,d,e,f){let g=CL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.Fr(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),
62
+ c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(TI),c=_.q,b=!0):e?(a.g.debug(TI),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(TI));return{type:c,th:g,ei:b}},LL=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},ML=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist,h=_.L(f,_.lA),k=_.L(f,_.Db);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};
63
+ const l=g.verbatimUri;g=k.audio.find(u=>HJ(u).Da===l);const {type:m,th:n,ei:p}=NL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield OL(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{AK(u,c.width);BK(u,c.height);CK(u,c.frameRate)});return k})},OL=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return LL(a,h.verbatimUri,()=>_.w(function*(){var k=_.L(g,HI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.L(g,_.lA)||void 0)&&a.J.has(k)?
64
+ k:void 0;var m=DL(d,c);if(k){const n=DL(_.q,c);m+=`,${n}`}return yield xL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,Uc:null,name:null,channelsCount:null,spatialAudio:!1,lc:null,groupId:null,muxedAudioId:k,Pd:f})}))})},AL=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=nJ(b.aa,PI))?Number(h.value):g;g=[];e=yield PL(a,b.a,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)mJ(m.aa,LI)&&0<l.length&&(k.push(l),l=
65
+ []),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield QL(a,b.a,k,h,e,c,d,g[g.length-1]||null),g.push(l),h+=k.length;RL(g);return g})},KL=function(a,b){return _.w(function*(){var c=b.name!==OI?!0:_.L(b,_.tb)===WI;c=_.L(b,_.vb,void 0,{required:c});if(!c)return null;const d=_.Qm(c,a.w),e=Date.now(),{response:f,text:g}=yield WK(a,d);a.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-e,type:"media"}}));return XK(a,g,f.uri,c)})},RL=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.I(_.D,
66
+ 4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},SL=function(a,b,c){a=jJ(a.aa,NI);if(1<a.length)throw new _.I(_.D,4,4020);a=a[0];if(!a)return null;const d=aJ(a,_.vb),e=_.Qm(d,b);b=zJ(a,null,!0);return new _.pI(()=>[e],b.ma,b.ja,c)},TL=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.L(u,JI));n=m+n;k=zJ(u,k?null:l.ja,k);l=String(_.L(u,_.vb));
67
+ const v=(l=_.Qm(l,g))?[l]:[];m=new BJ(c,m,n,()=>v,k.ma,k.ja,e,f,!1,null,null,null,null);if("YES"===_.L(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},UL=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.aa;var p=c.a;0<jJ(n,NI).length&&(m=SL(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}=xJ(n),a=e+c,p=wJ(n,b?b.ja:null)):(b=TL(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ge?oJ(n):null;d=new BJ(d,e,a,()=>v,p.ma,p.ja,f,g,!1,
68
+ null,h?h.sd:null,h?h.Nd:null,h?h.durationPerTile:null,y,m);d.sa=l;return d},PL=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.C)return a.C;if(!cL(a)&&a.f)try{var k=a.j.get(c);var l=k?yK(k,e)||null:null;if(!l)throw new _.I(_.D,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].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+
69
+ `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.I(_.D,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield VL(a,f,g,h);l=uK(h.aa,a.w,e);k=SL(h,b,l);h=yield WL(a,k,h,l,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.C=h})},QL=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c[0],l=null==h;const m=yield VL(a,f,g,k);var n=h?h.ki:null;if(mJ(c[0].aa,MI)||null===n)n=rK(c,m),n=0===n.length?[nK()]:n;else{var p=rK(c,m);n=[n,
70
+ ...p]}p=n;n=p[p.length-1];p=oK(p);let u=h?h.li:null;var v=XL(u,k.aa,a.w,d);let y=SL(k,b,v)||(h?h.fi:null);const A=k.sa;k=l?e:yield YL(a,A,y,k,d,v,m,g);l=[];v=!1;for(let B=0;B<c.length;B++){var E=c[B];const F=l[l.length-1]||null,ia=0===B?0:F.endTime,Xa=d+B,cb=XL(u,E.aa,a.w,Xa);(u=cb)&&(v=!0);if(E=UL(a,F,E,Xa,ia,k,cb,f,b,A,y))y=E.initSegment,l.push(E)}return{S:l,Gh:p,ki:n,aesEncrypted:v,mimeType:m,endTime:l[l.length-1].endTime,sa:A,fi:y,li:u}})},VL=function(a,b,c,d){return _.w(function*(){const e=d.a;
71
+ var f=nJ(d.aa,NI);f=f?aJ(f,_.vb):null;return ZL(a,b,c,e,f)})},WL=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=CJ(c,d);return wK(a.T,b,g,e,f,null!=d)})},XL=function(a,b,c,d){return b.some(e=>e.name===MI&&"NONE"===_.L(e,UI))?null:(b=uK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.fm(new Uint8Array(12),hJ(d))}):a},YL=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 WL(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+
72
+ `${k} s.`);a.L.set(b,k);return k})},ZL=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ir(f,b,c);if(g)return g;g=_.wk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.H(g)).headers["content-type"];if(!g)throw new _.I(_.D,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},YK=a=>{a=_.Rm(a)||"";return null!=_.wu.video[a]?_.t:null!=_.wu.audio[a]?_.q:null},TJ=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.I(_.D,
73
+ 4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.I(_.D,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.aa=c;this.S=1===b?d:null}},bK=class{constructor(a,b,c){c=void 0===c?[]:c;this.aa=b;this.a=a;this.f=c;this.sa=-1}},BJ=class extends _.uC{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:
74
+ n,void 0===p?null:p,u,void 0===v?null:v);this.sa=0}},$J=/^#EXT-X-DEFINE/,aK=/^#(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)/,$L=class{constructor(){this.h=0;this.a=new Map}},aM=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)||
75
+ null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},jL=new _.T("clpp.hls.DiscontinuityUtils");var tK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.yg)throw new _.I(_.D,4,4041);if(aJ(a,UI)===VI)throw new _.I(_.D,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.nB(_.sd,[{initDataType:_.Mf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":mK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":mK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=aJ(a,UI);if(!kK.includes(b))return lK.error("Widevine in HLS is only supported with [",
76
+ kK.join(", "),"], not",b),null;b=aJ(a,_.vb);b=_.gm(b);b=_.G(b.data);b=_.nB(_.wd,[{initDataType:_.Wc,initData:b}],"");if(a=_.L(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},kK=["SAMPLE-AES",VI],lK=new _.T("clpp.hls.DrmParser");var sK=new _.T("clpp.hls.EncryptionUtils");var bM=class{constructor(a){this.g=new _.T("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.sk()}}};var BL=class{constructor(a){this.streams=a}length(){return this.streams.length}};var zL=class{constructor(a){this.a=a}length(){return this.a.length}};var RK=a=>{if(!a)return null;a=nJ(a.aa,QI);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var cM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new aM;this.w="";this.R=new $L;this.G=0;this.o=null;this.l=new _.Li(()=>{this.Wb()});this.A=_.Fb;this.f=null;this.F=new _.Zt;this.K=this.C=null;this.g=new _.T("clpp.hls.HlsParser");this.L=new Map;this.T=new bM(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!");
77
+ c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield WK(c,a);c.D.onEvent(new _.H(ZI,{detail:{duration:Date.now()-d,type:"master"}}));c.w=e.uri;d=yield gL(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(!cL(a)&&
78
+ 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=VK(a);d=d.filter(h=>g.includes(HJ(h).Da))}var e=yield iL(a,d);d=e.map(g=>g.playlist);kL(a,d);e=yield nL(a,e);FK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});aL(a,e);var f=oL(a,d);f=pL(a,d,f);b.cues=fL(a,f);HK(b.periods,e);UK(c,e);if(d=rJ(d))!0!==a.a.keepTimelineLive&&qL(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();
79
+ 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 _.ql(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=LL(c,k.verbatimUri,()=>_.w(function*(){const l=yield IL(c,k);return JL(c,k,l)}))}if(e.video){const k=e.video;g=LL(c,k.verbatimUri,()=>_.w(function*(){const l=yield IL(c,
80
+ k);return JL(c,k,l)}))}f=yield f;g=yield g;e=mL(c,f,g,e.bandwidth,e.id);let h;e&&(e=MK(c.D.configurationId,[e],[],[],!cL(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 _.ql(`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=
81
+ c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.ql(`Could not load text stream with id: ${a}`);const g=yield LL(c,f.verbatimUri,()=>_.w(function*(){const h=yield IL(c,f);return JL(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 _.ql(`Could not load text stream with id: ${a}`);return d})}Wb(){const a=this;return _.w(function*(){a.g.debug(_.xA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof
82
+ _.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(_.D,7,7001);a=this.D.networkingEngine.fetch(a);_.Gl(this.F,a);return a.U}};_.x("clpp.hls.HlsComponent",class extends _.yv{install(){_.Et.m3u8=cM;_.Dt[_.ul]=cM;_.Dt[YI]=cM}uninstall(){_.QC("m3u8");_.RC(_.ul);_.RC(YI)}id(){return"hls"}});};f.call(g, window);
package/cl.hlssmpte.js CHANGED
@@ -1,5 +1,5 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var RT=function(a){a.a.one(a.m,_.te,()=>QT(a))},QT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>ST(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Ae).forEach(d=>{ST(a,{track:d})});!TT(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),UT(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
- else a.g.warn("A video element is not available. Skipping.")},ST=function(a,b){b=b.track;b.kind===_.Ae&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Ad,c=>VT(a,c)))},TT=function(a){return a.some(b=>b.kind===_.Ae)},UT=function(a,b){const c=a.m.getTrackManager(),d=c.pa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ya(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.Ae&&(a.a.off(b.textTracks,_.oc,f),c.ya(d))});c.ya(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- VT=function(a,b){const c=WT(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new XT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.ti(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},WT=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
4
- XT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.jh(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.jh(a)?a:null}}};var YT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Qt;this.h=(a=_.At(_.Ac))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;RT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var ZT=class extends _.Uv{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.aj()){var b=a.getConfiguration();b=_.dh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.kh(b.timestampOffset)||(b.timestampOffset=0);this.a=new YT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",ZT);
5
- ZT.Id="hlssmpte";_.Wn(new class{create(){return new ZT}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var JT=function(a){a.a.one(a.m,_.te,()=>IT(a))},IT=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.oc,d=>KT(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.Ae).forEach(d=>{KT(a,{track:d})});!LT(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),MT(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
+ else a.g.warn("A video element is not available. Skipping.")},KT=function(a,b){b=b.track;b.kind===_.Ae&&(a.g.info("The metadata track has been added."),b.mode=_.ce,a.a.on(b,_.Bd,c=>NT(a,c)))},LT=function(a){return a.some(b=>b.kind===_.Ae)},MT=function(a,b){const c=a.m.getTrackManager(),d=c.pa(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.oc,g=>{g.track.kind===_.Ae&&(a.a.off(b.textTracks,_.oc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ NT=function(a,b){const c=OT(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new PT(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.ri(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},OT=function(a){return(a=a.m.getTrackManager().va())&&a.language&&a.language.toLowerCase()},
4
+ PT=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.jh(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.jh(a)?a:null}}};var QT=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Kt;this.h=(a=_.ut(_.Bc))?new a(this.m.getConfiguration()):null;this.g=new _.T("clpp.hlssmpte.ImageCueHandler");this.f=null;JT(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var RT=class extends _.Ov{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Zi()){var b=a.getConfiguration();b=_.dh(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Nc&&(b.patchMetadataTrack=!1);_.kh(b.timestampOffset)||(b.timestampOffset=0);this.a=new QT(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",RT);
5
+ RT.Id="hlssmpte";_.Qn(new class{create(){return new RT}});};f.call(g, window);