@castlabs/prestoplay 6.14.0 → 6.15.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 (62) hide show
  1. package/CHANGELOG.md +25 -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 +113 -111
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +550 -529
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +74 -73
  10. package/cjs/cl.externs.js +191 -64
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +69 -68
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -30
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +290 -275
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +13 -13
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.simid.js +15 -15
  22. package/cjs/cl.smooth.js +72 -71
  23. package/cjs/cl.thumbnails.js +26 -26
  24. package/cjs/cl.tizen.js +70 -70
  25. package/cjs/cl.ttml.js +28 -28
  26. package/cjs/cl.verimatrix.js +5 -5
  27. package/cjs/cl.vimond.js +13 -13
  28. package/cjs/cl.vr.js +19 -19
  29. package/cjs/cl.vtt.js +14 -14
  30. package/cjs/cl.youbora.js +20 -20
  31. package/cl.adobe.js +3 -3
  32. package/cl.airplay.js +3 -3
  33. package/cl.broadpeak.js +5 -5
  34. package/cl.cast.js +89 -88
  35. package/cl.conviva.js +27 -27
  36. package/cl.core.js +457 -438
  37. package/cl.crypto.js +9 -9
  38. package/cl.dash.js +70 -68
  39. package/cl.externs.js +187 -64
  40. package/cl.freewheel.js +19 -19
  41. package/cl.hls.js +71 -69
  42. package/cl.hlssmpte.js +5 -5
  43. package/cl.htmlcue.js +26 -26
  44. package/cl.ima.js +17 -17
  45. package/cl.mse.js +255 -240
  46. package/cl.muxdata.js +13 -13
  47. package/cl.onboard.js +4 -4
  48. package/cl.persistent.js +11 -11
  49. package/cl.playlist.js +5 -5
  50. package/cl.simid.js +13 -13
  51. package/cl.smooth.js +59 -59
  52. package/cl.thumbnails.js +19 -19
  53. package/cl.tizen.js +57 -57
  54. package/cl.ttml.js +22 -22
  55. package/cl.verimatrix.js +4 -4
  56. package/cl.vimond.js +8 -8
  57. package/cl.vr.js +15 -15
  58. package/cl.vtt.js +12 -12
  59. package/cl.youbora.js +15 -15
  60. package/clpp.styles.css +2 -0
  61. package/package.json +1 -1
  62. package/typings.d.ts +387 -90
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 hO="clpp-freewheel",iO="clpp.freewheel.AdsManagerFactory",jO="freewheel",kO=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""}},lO=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.vf&&b.push("serverUrl");typeof a.profileId!==_.vf&&b.push("profileId");typeof a.videoAssetId!==_.vf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},mO=function(){return _.x(function*(){var a=new _.ct;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})},nO=function(a){a.h.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.h.on(a.a,
3
- tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.h.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.h.on(a.m,_.Cf,a.F.bind(a));a.h.on(a.m,_.sf,a.C.bind(a))},qO=function(a){return _.x(function*(){a.B.length?(oO(a),a.f=a.B.shift(),a.f.play()):(pO(a),yield a.m.a.play())})},pO=function(a){const b=a.m.bc(jO).wc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},oO=function(a){const b=a.m.bc(jO).wc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(hO),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},rO=function(a){a.A.length?(oO(a),a.f=a.A.shift(),a.f.play()):pO(a)},sO=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new Y(a.a,c,d)});a.m.trigger(new _.F(b,d))},tO=class extends _.kt{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.Ln(_.zd,{id:hO}),this.f=_.Ln(_.w,{"class":_.Xc}),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 jO}wc(){return this.a}lg(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",tO);tO.prototype.getAdVideo=tO.prototype.lg;tO.prototype.getAdContainer=tO.prototype.wc;tO.Id=jO;tO.AD_CONTAINER_ID=hO;_.so(new class{create(){return new tO}});var Y=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}rb(){return"FreeWheel AdManager SDK"}sb(){return tv.freewheel.SDK.version}yb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.vf?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getSkipTimeOffset(){return 0}fc(){return!1}Jb(){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():""}vb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ub(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}kb(){return 0}Wa(){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.Wa()){case 0:return 0;case 2:return-1}return this.h.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Kb(){switch(this.Wa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Lb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}xb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
- Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.xb;Y.prototype.getPositionInSequence=Y.prototype.Lb;Y.prototype.getPodTimeOffset=Y.prototype.Kb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.Wa;Y.prototype.getMediaBitrate=Y.prototype.kb;Y.prototype.getMediaHeight=Y.prototype.ub;
9
- Y.prototype.getMediaWidth=Y.prototype.vb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.Jb;Y.prototype.isBumper=Y.prototype.fc;Y.prototype.getSkipTimeOffset=Y.prototype.getSkipTimeOffset;Y.prototype.getDuration=Y.prototype.getDuration;Y.prototype.getTitle=Y.prototype.getTitle;Y.prototype.getAdvertiserName=Y.prototype.getAdvertiserName;Y.prototype.getAdSystem=Y.prototype.getAdSystem;Y.prototype.getApiFramework=Y.prototype.getApiFramework;
10
- Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.yb;Y.prototype.getAdManagerVersion=Y.prototype.sb;Y.prototype.getAdManagerName=Y.prototype.rb;var uO=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()}})}Mb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}lb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- uO.prototype.hasPostroll=uO.prototype.lb;uO.prototype.hasPreroll=uO.prototype.Mb;uO.prototype.getCuePoints=uO.prototype.getCuePoints;var vO=class{constructor(a){this.g=new _.R("clpp.freewheel.AdsManager");this.m=a;this.h=new _.ir;this.w=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.B=[];this.o=[];this.A=[];this.l=new _.wm;this.j=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{lO(b)}catch(d){return a.m.onError(d),a.l.resolve(),a.l}a.w.setNetwork(b.networkId);a.w.setServer(b.serverUrl);a.a=a.w.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.vf&&typeof b.siteSectionId!==
12
- _.r||a.a.setSiteSection(b.siteSectionId);const c=yield mO();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,kO(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.ve&&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);nO(a);a.a.submitRequest();return a.l})}start(){const a=this;return _.x(function*(){yield qO(a)})}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}dispose(){const a=this;return _.x(function*(){a.h.release();
14
- a.j&&(a.j.stop(),a.j=null);pO(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.o=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.F(_.nc,{adsTimeline:new uO(this.a)})),this.j=new _.at(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.bc(jO).f);else this.m.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.l.resolve()}J(a){sO(this,_.Wb,a);this.j.start()}I(a){this.f=null;a=a.slot;sO(this,_.Xb);this.j.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:qO(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:pO(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:rO(this)}}G(a){const b=a.subType;this.g.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:sO(this,_.jc,a);sO(this,
16
- _.cc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:sO(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:sO(this,_.bc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:sO(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:sO(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:sO(this,_.ac,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:sO(this,_.$b,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:sO(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:sO(this,
17
- _.hc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:sO(this,_.ic,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:sO(this,_.Zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:sO(this,_.gc,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]}))}}F(){if(!this.f){var a=this.m.getPosition();if(this.f=this.o.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.o.findIndex(c=>c===this.f);this.o.splice(b,1);this.m.pause();oO(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.rn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.qn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.fn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);rO(this);break;case _.on:case _.nn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- vO.prototype.getPosition=vO.prototype.getPosition;vO.prototype.setVolume=vO.prototype.setVolume;vO.prototype.getVolume=vO.prototype.getVolume;vO.prototype.skip=vO.prototype.skip;vO.prototype.pause=vO.prototype.pause;vO.prototype.resume=vO.prototype.resume;vO.prototype.start=vO.prototype.start;var wO=class{constructor(){this.a=new _.R(iO)}name(){return iO}da(a,b){return a.namespace()===_.dd?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new vO(a)}};wO.prototype.create=wO.prototype.create;wO.prototype.isSupported=wO.prototype.da;wO.prototype.name=wO.prototype.name;_.In(new wO);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var QP="clpp-freewheel",RP="clpp.freewheel.AdsManagerFactory",SP="freewheel",TP=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""}},UP=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.Lf&&b.push("serverUrl");typeof a.profileId!==_.Lf&&b.push("profileId");typeof a.videoAssetId!==_.Lf&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.G(1,9,12001,{missingKeys:b.join(", ")});},VP=function(){return _.w(function*(){var a=new _.Yt;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})},WP=function(a){a.g.on(a.a,tv.freewheel.SDK.EVENT_REQUEST_COMPLETE,a.H.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_SLOT_STARTED,a.J.bind(a));a.g.on(a.a,
3
+ tv.freewheel.SDK.EVENT_SLOT_ENDED,a.I.bind(a));a.g.on(a.a,tv.freewheel.SDK.EVENT_AD,a.G.bind(a));a.g.on(a.m,_.Sf,a.F.bind(a));a.g.on(a.m,_.If,a.C.bind(a))},ZP=function(a){return _.w(function*(){a.B.length?(XP(a),a.f=a.B.shift(),a.f.play()):(YP(a),yield a.m.a.play())})},YP=function(a){const b=a.m.bc(SP).wc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},XP=function(a){const b=a.m.bc(SP).wc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(QP),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},$P=function(a){a.A.length?(XP(a),a.f=a.A.shift(),a.f.play()):YP(a)},aQ=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.m.trigger(new _.C(b,d))},bQ=class extends _.hu{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.oo(_.Gd,{id:QP}),this.f=_.oo(_.t,{"class":_.dd}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.G(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return SP}wc(){return this.a}wg(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",bQ);bQ.prototype.getAdVideo=bQ.prototype.wg;bQ.prototype.getAdContainer=bQ.prototype.wc;bQ.Id=SP;bQ.AD_CONTAINER_ID=QP;_.Vo(new class{create(){return new bQ}});var X=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}rb(){return"FreeWheel AdManager SDK"}sb(){return tv.freewheel.SDK.version}yb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Lf?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getSkipTimeOffset(){return 0}gc(){return!1}Lb(){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():""}vb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ub(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}jb(){return 0}Va(){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.Va()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Mb(){switch(this.Va()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Nb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}xb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
+ X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.xb;X.prototype.getPositionInSequence=X.prototype.Nb;X.prototype.getPodTimeOffset=X.prototype.Mb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Va;X.prototype.getMediaBitrate=X.prototype.jb;X.prototype.getMediaHeight=X.prototype.ub;
9
+ X.prototype.getMediaWidth=X.prototype.vb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Lb;X.prototype.isBumper=X.prototype.gc;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;
10
+ X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.yb;X.prototype.getAdManagerVersion=X.prototype.sb;X.prototype.getAdManagerName=X.prototype.rb;var cQ=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()}})}Ob(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}lb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ cQ.prototype.hasPostroll=cQ.prototype.lb;cQ.prototype.hasPreroll=cQ.prototype.Ob;cQ.prototype.getCuePoints=cQ.prototype.getCuePoints;var dQ=class{constructor(a){this.h=new _.Q("clpp.freewheel.AdsManager");this.m=a;this.g=new _.as;this.w=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.B=[];this.o=[];this.A=[];this.l=new _.Ym;this.j=null}load(){const a=this;return _.w(function*(){const b=a.m.getConfiguration().freewheel||{};try{UP(b)}catch(d){return a.m.onError(d),a.l.resolve(),a.l}a.w.setNetwork(b.networkId);a.w.setServer(b.serverUrl);a.a=a.w.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.Lf&&typeof b.siteSectionId!==
12
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield VP();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,TP(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.De&&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);WP(a);a.a.submitRequest();return a.l})}start(){const a=this;return _.w(function*(){yield ZP(a)})}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}dispose(){const a=this;return _.w(function*(){a.g.release();
14
+ a.j&&(a.j.stop(),a.j=null);YP(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.B=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.o=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.m.trigger(new _.C(_.tc,{adsTimeline:new cQ(this.a)})),this.j=new _.Wt(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.bc(SP).f);else this.m.onError(new _.G(1,
15
+ 9,10003,{errorType:0},void 0));this.l.resolve()}J(a){aQ(this,_.bc,a);this.j.start()}I(a){this.f=null;a=a.slot;aQ(this,_.cc);this.j.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:ZP(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:YP(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:$P(this)}}G(a){const b=a.subType;this.h.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:aQ(this,_.pc,a);aQ(this,
16
+ _.ic,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:aQ(this,_.qc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:aQ(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:aQ(this,_.kc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:aQ(this,_.rc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:aQ(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:aQ(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:aQ(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:aQ(this,
17
+ _.nc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:aQ(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:aQ(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:aQ(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.m.onError(new _.G(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]}))}}F(){if(!this.f){var a=this.m.getPosition();if(this.f=this.o.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.o.findIndex(c=>c===this.f);this.o.splice(b,1);this.m.pause();XP(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Tn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Sn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.In:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);$P(this);break;case _.Qn:case _.Pn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ dQ.prototype.getPosition=dQ.prototype.getPosition;dQ.prototype.setVolume=dQ.prototype.setVolume;dQ.prototype.getVolume=dQ.prototype.getVolume;dQ.prototype.skip=dQ.prototype.skip;dQ.prototype.pause=dQ.prototype.pause;dQ.prototype.resume=dQ.prototype.resume;dQ.prototype.start=dQ.prototype.start;var eQ=class{constructor(){this.a=new _.Q(RP)}name(){return RP}isSupported(a,b){return a.namespace()===_.kd?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new dQ(a)}};eQ.prototype.create=eQ.prototype.create;eQ.prototype.isSupported=eQ.prototype.isSupported;eQ.prototype.name=eQ.prototype.name;_.lo(new eQ);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,69 +1,71 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var HD="CLOSED-CAPTIONS",ID="Could not parse MP4 segment start time.",JD="DURATION",KD="EXT-X-STREAM-INF",LD="Failed to infer discontinuity number",MD="Guessing audio-only",ND="METHOD",OD="SAMPLE-AES-CTR",PD="SUBTITLES",QD="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",RD="application/vnd.apple.mpegurl",SD="sample",TD="whole-segment",UD=function(a,b){return _.I(a,b,void 0,{required:!0})},VD=function(a){if(1>a.a)throw _.Pk();--a.a},WD=function(a){if(null!==a&&void 0!==
2
- a)return Number(a)},XD=function(a,b){return a.filter(c=>c.name===b)},YD=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=UD(d,_.Eb);return c.includes(d)})},ZD=function(a,b){return a.some(c=>c.name===b)},$D=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,4,4024,{missingTag:b});return a},aE=function(a){var b=$D(a,"EXT-X-TILES");if(!b)return{$e:1,Bf:1,durationPerTile:null};a=_.I(b,"LAYOUT")||"1x1";b=(b=_.I(b,JD))?Number(b):null;const [c,
3
- d]=a.split("x").map(e=>parseInt(e,10));return{$e:c,Bf:d,durationPerTile:b}},bE=function(a,b){return _.by([a],[b])[0]},cE=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)},dE=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of cE(c))b(d,c)})},eE=function(a){return a.some(b=>ZD(b.X,_.Ca))},fE=function(a){return a.type===_.p||a.type===_.w},gE=
4
- function(a){const b=$D(a,_.Ha);if($D(a,_.Ca))return _.vx;if(!b)return"LIVE";if(b.value===_.vx)return _.vx;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);},hE=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.u,"CLOSED-CAPTIONS":_.u}[a.toUpperCase()];if(!a)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},iE=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(_.G,
5
- 4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ua:d,ia:e}},jE=function(a,b){a=$D(a,_.ya);return iE(a?a.value:null,b)},kE=function(a){a=$D(a,"EXTINF",{required:!0}).value.split(",");
6
- return{duration:Number(a[0]),title:a[1]||null}},lE=function(a,b){b=void 0===b?{}:b;const c={gd:!1,Wf:!1,Xf:null,ug:null,nf:null};a=$D(a,_.La,{required:b.sf});if(!a)return c;const d=e=>null==e?null:Number(e);c.gd="YES"===_.I(a,"CAN-BLOCK-RELOAD");c.Wf="YES"===_.I(a,"CAN-SKIP-DATERANGES");c.Xf=d(_.I(a,"CAN-SKIP-UNTIL"));c.ug=d(_.I(a,"HOLD-BACK"));c.nf=d(_.I(a,"PART-HOLD-BACK",void 0,{required:b.sf}));return c},mE=function(a,b,c){c=void 0===c?!1:c;a=_.I(a,"BYTERANGE");return iE(a,b,c)},oE=function(a,
7
- b){const c=jE(a.X,null);return new nE(0,0,0,()=>[a.a],c.ua,c.ia,0,b)},pE=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.ki(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},qE=function(a){let b=Infinity,c=Infinity;cE(a).filter(fE).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{Cc:b,duration:c}},rE=function(a){return a.map(b=>{({duration:b}=qE(b));return b}).reduce((b,
8
- c)=>b+c,0)},sE=function(a){return(a.video?a.video.xa:"")+" - "+(a.audio?a.audio.xa:"")},tE=function(a,b,c,d){if(b===_.vx)return{delay:0,lc:0};b=$D(a,_.Ga);if(c&&b){c=Number(UD(b,"PART-TARGET"));if(null!=d)return{delay:d,lc:c};({nf:d}=lE(a,{sf:!0}));return{delay:d,lc:c}}a=$D(a,_.Ma,{required:!0});a=Number(a.value);return null!=d?{delay:d,lc:a}:{delay:3*a,lc:a}},uE=function(a){const b=[];dE(a,c=>{b.push(c.Ag)});return{delay:Math.max(...b.map(c=>c.delay)),lc:Math.min(...b.map(c=>c.lc))}},wE=function(a){const b=
9
- new Map;a.forEach(c=>{var d=vE(c).groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},xE=function(a){const b=new Map;for(const c of a){a=_.I(c,_.Za);a=_.Eh(a||_.Ff);const d=UD(c,_.Sa),e=UD(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},zE=function(a){a=a.audio.concat(a.video);for(const b of a)a=vE(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),yE(b,a)},AE=function(a,b){if(!a)return null;const c=a.xa;return b.find(d=>vE(d).xa===c)||null},BE=function(a){for(const b of a)if(b.startsWith("#EXT-")&&
10
- (a=_.pi(0,b),_.Ir.has(a.name)))return 1;return 0},CE=function(a){a=XD(a,"EXT-X-DEFINE").map(b=>{const c=_.I(b,"NAME");if(!c)return null;b=UD(b,"VALUE");return{name:c,value:b}}).filter(Boolean);return new Map(a.map(b=>[b.name,b.value]))},DE=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.G,4,4044,`Undefined variable '${d}'`);return c})},EE=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=DE(d.value,b)})})},FE=function(a,b,c){EE(a,c);
11
- b.forEach(d=>{EE(d.X,c)})},IE=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=GE(a,b[e]);d.push(f);if(f.name===KD){const g=b[e+1];if(!g)throw new _.H(_.G,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.ni(_.Gb,g));e++}}a.a=CE(d);FE(d,[],a.a);return new HE(c,0,d)},LE=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=GE(a,b[e]);if(_.Jr.has(f.name))break;d.push(f);e++}b=JE(a,c,b.slice(e));e=b.S;d=d.concat(b.X);a=KE(a,d);FE(d,e,a);return new HE(c,1,
12
- d,b.S)},ME=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 _.H(_.G,4,4015);return 0===BE(b)?IE(a,b,c):LE(a,b,c)},GE=function(a,b){return _.pi(a.f++,b)},JE=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=GE(a,h),_.Ir.has(h.name)||_.Lr.has(h.name)?d.push(h):_.Kr.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ia&&"PART"===_.I(h,_.Eb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||
13
- (h=bE(b,h.trim()),e.push(new NE(h,f,g)),f=[],g=[])});0<g.length&&e.push(new NE(null,f,g));return{S:e,X:d}},KE=function(a,b){const c=XD(b,"EXT-X-DEFINE"),d=CE(b);c.map(e=>_.I(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.H(_.G,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},OE=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},PE=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&
14
- 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},QE=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(_.G,4,4030);}PE(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===
15
- 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}}PE(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},RE=function(a,b){let c=null,d=0;try{(new _.fl).L(_.qe,_.Yk).L(_.Df,_.Yk).L(_.le,_.Yk).$("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.dt.error("Unable to find timescale in init segment!"),
16
- new _.H(_.G,4,4030,ID,c);let e=0,f=!1;try{(new _.fl).L("moof",_.Yk).L("traf",_.Yk).$("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.G,4,4030,ID,c);return e},SE=function(a){for(;a.getPosition()<a.Ca()-1;){const b=
17
- a.getPosition();if(71===_.Qk(a))return VD(a),b}return-1},TE=function(a){function b(){d.seek(e+188);f=_.Qk(d);71!=f&&(d.seek(e+192),f=_.Qk(d));71!=f&&(d.seek(e+204),f=_.Qk(d));71!=f&&c();VD(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.Sl(new DataView(a),!1);let e=0,f=0;e=SE(d);0>e&&(_.dt.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Qk(d);71!=f&&c();a=_.Rk(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Qk(d)&48)>>4;0!=a&&
18
- 2!=a||c();3==a&&(a=_.Qk(d),d.skip(a));if(1!=_.P(d)>>8){b();continue}d.skip(3);a=_.Qk(d)>>6;0!=a&&1!=a||c();0==_.Qk(d)&&c();a=_.Qk(d);const g=_.Rk(d),h=_.Rk(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},WE=function(a){const b=UE(a),c=VE(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.fa===b);let g=e.findIndex(h=>h.fa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},VE=function(a){a=a.map(b=>b.S[b.S.length-1].fa);return Math.min(...a)},UE=function(a){a=a.map(b=>b.S[0].fa);return Math.max(...a)},
19
- ZE=function(a){var b=UD(a,ND);if(!XE.includes(b))return YE.error("PlayReady in HLS is only supported with [",XE.join(", "),"], not",b),null;a=UD(a,_.Gb);b=_.Vq(a);a=null;b=_.J(b.data);try{a=_.Sx(_.Zl(b))}catch(c){a=b}return _.cy(_.pd,[{initDataType:_.Sc,initData:a}],"")},aF=function(a){if(0===a.length)return $E();if(a.some(c=>c.type===TD)||a.every(c=>c.type===_.ue))return a[0];a=a.filter(c=>c.type===SD);const b=_.ih(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:SD,drmInfos:b}},
20
- dF=function(a){a=bF(a);if(a.some(b=>cF(b))&&1<a.length)throw new _.H(_.G,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},cF=function(a){return XD(a.X,_.Da).some(b=>"AES-128"===_.I(b,ND))},fF=function(a,b,c){return bF(a).map(d=>eF(d.X,b,c))},gF=function(a){return a.filter(b=>ZD(b.X,_.Da)).length},bF=function(a){return a.filter(b=>ZD(b.X,_.Da))},eF=function(a,b,c){a=XD(a,_.Da);if(0===a.length)return null;var d=UD(a[0],ND);if(1===a.length){if("NONE"===d)return $E();
21
- if("AES-128"===d)return a=a[0],d=_.I(a,"IV",""),{type:TD,keyInfo:{method:"AES-128",url:bE(b,UD(a,_.Gb)),iv:d?_.hi((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>UD(e,ND));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===OD))throw hF.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.I(e,"KEYFORMAT","identity");{const g=iF[f]||null;e=g?g(e,c):null}e||hF.warn("Unsupported HLS KEYFORMAT",
22
- f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.G,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:SD,drmInfos:b}},$E=function(){return{type:_.ue,keyInfo:null,drmInfos:[],keyId:null}},jF=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.Fy(b.La(),b.ua,b.ua+2048-1,a.a.attemptParameters);e.type=2;const f=_.Fy(b.La(),b.ua,b.ia,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===
23
- 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.",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(_.G,4,4030,"Failed to fetch the media segment.");}}})},kF=function(a,b,c,d,e,f){return _.x(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===
24
- d||d===_.Fc||d===_.Ec)return 0;if(d===_.Dc){var g=yield jF(a,c,f);const h=_.J(g.data);return PE(h)?QE(h):TE(g.data)}if(d===_.Rf||d===_.Gc)return g=[jF(a,c,f)],b&&g.push(jF(a,b,!0)),g=yield Promise.all(g),RE(g[0].data,(g[1]||g[0]).data);if(d===_.Pf)return g=yield jF(a,c,f),TE(g.data);if(!_.ly(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},lF=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},yE=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},
25
- mF=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},vE=function(a){return a.streams[0]},nF=function(a,b){a.streams.forEach(c=>{c.Gd=b})},oF=function(a,b){a.streams.forEach(c=>{c.width=b})},pF=function(a,b){a.streams.forEach(c=>{c.height=b})},qF=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},rF=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},sF=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>
26
- null==c)?null:a},tF=function(a,b){const c=new Set(a.map(d=>d.fa));return b.filter(d=>!c.has(d.fa))},wF=function(a,b){for(;a[0].fa<b[0].fa;)a.splice(0,1);var c=a[0];let d=b[0];uF(c,d)||vF(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&!uF(c,d)&&vF(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},xF=function(a,b){const c=a[a.length-1];var d=b.findIndex(f=>f.fa===c.fa);const e=b[d];uF(c,e)||vF(c,e);for(d+=1;d<b.length;d++)a.push(b[d])},CF=function(a,b,c,d){var e=a[0].length();e=OE(e).map(f=>{var g=sF(a,f)||
27
- [];const h=lF(b,f)||[];{f=lF(c,f)||[];const k=[...yF(g),...h,...f].filter(Boolean);zF(k);const {fa:l,duration:m}=k[0];g={variants:g,textStreams:h,thumbStreams:f,startTime:0,id:`P${l}`,endTime:m,duration:m,fa:l}}return g});d&&AF(e[0]);BF(e);return e},yF=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},AF=function(a){const b=yF(a.variants)[0].S[0].wa;a.startTime+=b;a.endTime+=b},BF=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=
28
- d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},uF=function(a,b){return a.startTime===b.startTime&&a.endTime===b.endTime},vF=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;DF(a.variants,b.variants);EF(cE(a),cE(b))},DF=function(a,b){const c=new Map(a.map(d=>[sE(d),d]));b.forEach(d=>{c.get(sE(d)).drmInfos=d.drmInfos})},EF=function(a,b){const c=new Map(a.map(d=>[d.xa,d]));b.forEach(d=>{const e=c.get(d.xa);e.S=d.S;e.segmentIndex.replace(d.S);e.Cc=d.Cc;e.ae=
29
- d.ae;e.duration=d.duration;e.Re=d.Re;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},zF=function(a){const b=FF(a);a.forEach(c=>{_.By(c.segmentIndex,b);c.duration=b;c.ae=c.Cc+b})},FF=function(a){let b=Infinity;a.filter(fE).forEach(c=>{b=Math.min(b,c.duration)});return b},GF=function(a,b){dE(b,(c,d)=>{_.Jy(a,c.S,d.startTime)})},HF=function(a){return null===a.h?[]:[a.h.audio,a.h.video].filter(b=>b).map(b=>b.xa)},IF=function(a,b){return _.x(function*(){var c=_.ui([b],a.a.attemptParameters);
30
- c.type=1;c=yield a.C(c);let d="";try{d=_.Rh(c.data)}catch(e){throw new _.H(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},MF=function(a,b){return _.x(function*(){var c=JF(a,b,a.o,"");if(1===c.type){c=_.Er(c.S[0].a)||"";c=null!=_.Dr.video[c]?_.w:null!=_.Dr.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.J;var e=a.o;d=a.a.hlsDefaultCodecs||d;var f=[];const q=[];q.push(new _.ni(_.la,"0"));q.push(new _.ni(_.Gb,e));d.length&&
31
- q.push(new _.ni(_.na,d));f.push(new _.oi(c.f++,KD,q));c=new HE(e,0,f)}}d=c.X;c=XD(d,"EXT-X-MEDIA");e=XD(d,KD);d=XD(d,"EXT-X-IMAGE-STREAM-INF");c={Bc:{Rf:YD(c,["AUDIO",_.Nb]),closedCaptions:YD(c,HD),bh:YD(c,PD)},cd:e,Vd:d};const {periods:g,pf:h,zf:k}=yield KF(a,c);if(!a.D)throw new _.H(_.G,7,7001);c=uE(g[0]);e=!0;d=null;f=0;LF(a)||(e=!1,d=0,f=c.delay);d=f=new _.xD(d,f,!0,void 0,!!a.a.lowLatencyMode);d.j=e;d.l=e;GF(f,g);h&&(f.G={offsetDateTime:h-_.Oy(f,0),seekRangeStartDateTime:h});e=f;if(!LF(a)){a.G=
32
- c.lc;c=0;for(var l of a.f.values())c=Math.max(c,l.streams[0].Cc);for(l=0;95443.7176888889<=c;)l+=95443.7176888889,c-=95443.7176888889;if(l){a.g.debug("Offsetting live streams by",l,"to compensate for rollover");for(var m of a.f.values())c=m.streams[0],95443.7176888889>c.Cc?(a.g.debug("Offset applied to",c.type),c.segmentIndex.offset(l)):a.g.debug("Offset NOT applied to",c.type)}}m=rE(g);"LIVE"===a.l||"EVENT"===a.l?(m=Math.max(m,e.F),isNaN(a.a.availabilityWindowOverride)||(m=a.a.availabilityWindowOverride),
33
- e.w=m):a.l===_.vx&&(e.f=m);if(k)for(var n of k)a.D.onTimelineCueAdded({schemeIdUri:n.schemeIdUri,Pa:n.Pa,value:"",startTime:n.startTime,endTime:n.endTime,id:n.id,type:_.Wg,eventElement:null});n={presentationTimeline:e,adaptedPeriods:[...g],periods:g,offlineSessionIds:[],minBufferTime:0};a.g.debug("HLS playlist parsed",n);return n})},OF=function(a,b){return Promise.all(b.map(c=>NF(a,c)))},QF=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!LF(a),f=$D(c.X,_.Ba);if(f)var g=Number(f.value);else{d?
34
- (f=d.streams[d.streams.length-1].S,f=f[f.length-1].fa):f=0;if(e&&0<f)try{{const k=$D(c.X,_.Fa);if(!k)throw PF.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(LD);const l=Number(k.value),m=mF(d,l);if(!m)throw PF.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(LD);var h=m.fa}g=h;break a}catch(k){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");
35
- }g=0}}c=c.S||[];for(const k of c)ZD(k.X,_.Aa)&&g++,k.fa=g});WE(b)},TF=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,Sf:e}=yield RF(a,b);var f=a.w.periods[0].variants;a.a.lowLatencyMode&&null!==a.h&&(f=f.filter(g=>g.id===a.h.id));f=f.map(g=>{const h=AE(g.audio,e),k=AE(g.video,e);g=SF(a,h,k,g.bandwidth);if(!g)throw new _.H(_.G,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Eh:k?vE(k).xa:void 0,audio:h?vE(h).xa:void 0});return g});return CF(f,c,d,!0)})},
36
- VF=function(a,b,c){UF(a,_.vx);b.j=!0;b.l=!0;b.f=c[c.length-1].endTime},UF=function(a,b){a.l=b;LF(a)&&a.j.stop()},JF=function(a,b,c,d){a=ME(a.J,b,c);a.a=d;WF(a);return a},KF=function(a,b){return _.x(function*(){var c=xE(b.Bc.closedCaptions),d=XF(a,b.cd),e=yield YF(a,b);const f=Object.values(e).flat().map(h=>h.Ga);QF(a,f);var g=yield ZF(a,e.Ie,d);c=yield $F(a,e.cd,g,c);d=yield aG(a,e.ah,d);g=yield bG(a,e.Vd);e=cG(a,e);c=CF(c,d,g,!LF(a));a.D.filterAllPeriods(c);return LF(a)?(d=null,e&&(d=dG(f,e)),{periods:c,
37
- pf:null,zf:d}):{periods:c,pf:e,zf:null}})},RF=function(a,b){return _.x(function*(){const c=g=>vE(g.stream).type===_.w||vE(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=vE(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.xa,Ed:{width:k.width,height:k.height,frameRate:k.frameRate}};h=
38
- Object.assign({},{Ga:h.Ga},k);return eG(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);fG(a,d.concat(f));e=f.filter(g=>vE(g).type===_.Nx);f=f.filter(g=>vE(g).type===_.Ud);return{textStreams:e,thumbStreams:f,Sf:d}})},SF=function(a,b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.jy(k.drmInfos,l.drmInfos)?_.iy(k.drmInfos,l.drmInfos):null:k?k.drmInfos:l?l.drmInfos:null;if(!k)return null;l=d;g={id:a.H++,language:g?
39
- g.language:_.Ff,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new gG(e)},eG=function(a,b){return _.x(function*(){const c=b.Ga,d=b.codecs,e=b.type,f=b.Sc,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,q=b.closedCaptions,t=b.Ed,v=_.Eh(f||_.Ff);if(1!==c.type)throw new _.H(_.G,4,4017);var y=gE(c.X);UF(a,y);const A=tE(c.X,y,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);
40
- y=yield hG(a,c,e,d);const D=a.a.lowLatencyMode?_.vB:_.Dx;let E=k;e!==_.u||k||(E=_.Nx);const {gd:O}=lE(c.X);k=y.map(sb=>{const Mb=sb.S,$c=sb.cg,Qf=sb.mimeType;sb=sb.fa;const Ua=Mb[0].startTime,Yd=Mb[Mb.length-1].endTime,uc=Yd-Ua,ea=new _.yD(Mb),ab=Mb[0].initSegment||null;return{id:a.H++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ea.f.bind(ea),getSegmentReference:ea.get.bind(ea),adjustSegmentDurations:ea.h.bind(ea),getDuration:ea.getDuration.bind(ea),segmentIndex:ea,
41
- segmentLookupStrategy:D,initSegmentReference:ab,mimeType:Qf,codecs:d,kind:E,Re:$c.type,encrypted:$c.type===SD,keyId:$c.keyId,language:v,originalLanguage:f||_.Ff,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:t?t.frameRate:void 0,width:t?t.width:void 0,height:t?t.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:$c.keyInfo,S:Mb,drmInfos:$c.drmInfos,fa:sb,xa:c.a,Gd:c.f,Cc:Ua,ae:Yd,duration:uc,gd:O,groupId:g,Ag:A}});return new iG(k)})},
42
- fG=function(a,b){b.forEach(c=>{a.f.a.set(vE(c).xa,c)})},XF=function(a,b){const c=new Map;for(const f of b){var d=_.I(f,"AUDIO");b=_.I(f,_.Nb);var e=_.I(f,PD);const g=jG(a,f);if(e){const h=_.bj(_.u,g);c.set(e,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=kG(_.p,g),c.set(d,e));b&&(d=kG(_.w,g),c.set(b,d))}return c},YF=function(a,b){return _.x(function*(){const c=yield Promise.all([lG(a,b.Bc.Rf),lG(a,b.Bc.bh),lG(a,b.cd),lG(a,b.Vd)]),[d,e,f,g]=c;return{Ie:d,ah:e,cd:f,Vd:g}})},ZF=function(a,b,c){return _.x(function*(){if(0===
43
- b.length)return new Map;var d=[mG(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>mG(a,e,c)));d=yield Promise.all(d);return wE(d)})},$F=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(UD(f[k].tag,_.la));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield nG(a,h,c,d,e);f=f.map(k=>nG(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.$x,[])})},aG=function(a,b,c){return Promise.all(b.map(d=>mG(a,d,c)))},
44
- bG=function(a,b){return Promise.all(b.map(c=>oG(a,c)))},cG=function(a,b){b=[...b.cd,...b.Ie].map(d=>d.Ga).flatMap(d=>d.S[0].X);b=$D(b,_.Ja);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},LF=function(a){return a.l===_.vx},dG=function(a,b){return(a=a.find(c=>null!==$D(c.X,_.za)))?a.X.filter(c=>c.name===_.za).map(c=>{a:{var d=_.I(c,"ID"),e=_.I(c,"START-DATE");if(null===d||null===
45
- e)_.Hr.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",c),c=null;else{var f=new Date(e);e=f.getTime()/1E3-b;d={id:d,startTime:e,startDate:f};var g=WD(_.I(c,JD));void 0!==g&&0<=g&&(d.duration=g);var h=WD(_.I(c,"PLANNED-DURATION"));void 0!==h&&0<=h&&(d.plannedDuration=h);var k=_.I(c,"CLASS");null!==k&&(d.schemeIdUri=k);var l=_.I(c,"END-DATE");l=l?new Date(l):null;null!==l&&l.getTime()>=f.getTime()&&(d.endDate=l);{const q=c.attributes;if(null==
46
- q)var m=null;else{f={};for(m of q)m.name.startsWith("X-")&&(f[m.name]=m.value);m=_.xg(f)?f:null}}m=m||{};if(k===_.od){f=c.attributes;if(null==f)var n=null;else{k={};for(n of f)switch(n.name){case _.Tb:k[_.Tb]=n.value;break;case _.Sb:k[_.Sb]=n.value;break;case _.Vb:k[_.Vb]=WD(n.value);break;case _.Ub:k[_.Ub]=WD(n.value);break;case "X-SNAP":k["X-SNAP"]=n.value.split(",");break;case "X-RESTRICT":k["X-SNAP"]=n.value.split(",")}k[_.Tb]&&k[_.Sb]||!k[_.Tb]&&!k[_.Sb]?(_.Hr.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),
47
- n=null):n=_.xg(k)?k:null}if(null===n){_.Hr.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",c);c=null;break a}m=Object.assign(m,n)}_.xg(m)&&(d.Pa=m);d.endTime=l?l.getTime()/1E3:g?e+g:h?e+h:e;d.type="hls-daterange";c=d}}return c}).filter(Boolean):null},lG=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield pG(a,c);return d?{tag:c,Ga:d}:null})))).filter(Boolean)})},NF=function(a,b){return _.x(function*(){var c=new _.sh(vE(b).Gd);
48
- if(a.a.lowLatencyMode&&vE(b).gd){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={Dg:d.position,Jg:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Dg,e=e.Jg,f=_.Oi(c.a.toString()),f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.Ni(f,!0),d=new _.zh(d),_.vh(c,d)}const {response:g,text:h}=yield IF(a,c.toString());c=vE(b).xa;d=vE(b).Gd;e=g.uri;d!==e&&(d=e,nF(b,d));c=JF(a,h,d,c);return{stream:b,Ga:c}})},
49
- jG=function(a,b){var c=_.I(b,_.na,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.ry(e)[0],b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},kG=function(a,b){if(1===b.length)return b[0];a=_.bj(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},mG=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.Ga;return qG(a,e.a,()=>_.x(function*(){const f=UD(d,_.Sa),g=hE(UD(d,_.Eb));var h=UD(d,_.Eb).toUpperCase();
50
- if(hE(h)!==_.u)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.Nx;h===HD&&(l=_.Ax);k&&(l=_.Od);h=l}k=c.get(f)||"";l=_.I(d,_.Za);const m=_.I(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var t=_.I(d,"CHANNELS");t=g===_.p?t?parseInt(t.split("/")[0],10):null:null;var v=g===_.p?(v=_.I(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield eG(a,{Ga:e,codecs:k,type:g,Sc:l,primary:!!n&&!!q,name:m,channelsCount:t,spatialAudio:v,groupId:f,
51
- kind:h,closedCaptions:null,Ed:null})}))})},oG=function(a,b){return _.x(function*(){const c=b.tag,d=b.Ga;return qG(a,d.a,()=>_.x(function*(){var e=_.I(c,_.na)||"jpg",f=_.I(c,_.Za);const g=_.I(c,"NAME");e=yield eG(a,{Ga:d,codecs:e,type:_.Ud,Sc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,groupId:null,Ed:null});(f=_.I(c,_.la))&&rF(e,Number(f));return e}))})},nG=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(UD(f,_.la));if(null!=f.getAttribute("FRAME-RATE")||
52
- null!=f.getAttribute(_.ub)){var h=_.I(f,"FRAME-RATE");f=_.I(f,_.ub);var [k,l]=f?f.split("x"):[null,null];h={frameRate:WD(h),width:WD(k),height:WD(l)}}else h=null;if(f=yield rG(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const q of h){m=(q?vE(q).xa:"")+" - "+(n?vE(n).xa:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const t=SF(a,n,q,g);null==t?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):
53
- (f.push(t),e.add(m))}g=f}else g=[];return g})},rG=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=b.Ga;let h=jG(a,f);var k=_.I(f,"AUDIO"),l=_.I(f,_.Nb),m=k||l;m=m&&d.has(m)?d.get(m):[];k={audio:k?m:[],video:l?m:[]};a.g.debug("Guessing stream type for",f.toString());f=!1;const n=g.a;g=k.audio.find(q=>q.xa===n);l=_.bj(_.w,h);l=c||l;1!==h.length||l?!m.length&&1<h.length?(a.g.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.g.debug(MD),g=_.p,f=!0):k.video.length?
54
- (a.g.debug(MD),g=_.p):(a.g.debug("Guessing video-only"),g=_.w):(g=_.p,a.g.debug(MD));l=null;f||(l=yield sG(a,b,h,g,e,c));if(null==l)return null;k[g]=[l];g===_.p&&c&&m.forEach(q=>{oF(q,c.width);pF(q,c.height);qF(q,c.frameRate)});zE(k);return k})},sG=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.Ga;return qG(a,h.a,()=>_.x(function*(){var k=_.I(g,HD);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=kG(d,c);return yield eG(a,{Ga:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,
55
- Sc:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Ed:f})}))})},qG=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},hG=function(a,b,c,d){return _.x(function*(){var e=b.a,f=b.S;var g=void 0===g?0:g;var h=(h=$D(b.X,_.Fa))?Number(h.value):g;g=[];!LF(a)&&dF(f);e=yield tG(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)ZD(m.X,_.Aa)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);
56
- f=k}for(m=0;m<f.length;m++)k=f[m],l=yield uG(a,b.f,k,h,e,c,d,g[g.length-1]||null,f.length),g.push(l),h+=k.length;vG(g);return g})},pG=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.I(b,_.Eb)===PD;c=_.I(b,_.Gb,void 0,{required:c});if(!c)return null;const d=bE(a.o,c),{response:e,text:f}=yield IF(a,d);return JF(a,f,e.uri,c)})},WF=function(a){1===a.type&&a.S.forEach((b,c)=>{if(ZD(b.X,_.Ea)&&!ZD(b.X,_.Aa)&&0<c)throw new _.H(_.G,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");
57
- })},vG=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},wG=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.I(c,_.Gb))||null).map(b=>_.Er(b));if(1<(new Set(a)).size)throw new _.H(_.G,4,4044,"Unexpected change in file format.");},xG=function(a,b,c){a=XD(a.X,_.Ea);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=UD(a,_.Gb),e=bE(b,d);b=mE(a,null,
58
- !0);return new _.uD(()=>[e],b.ua,b.ia,c)},yG=function(a,b,c,d,e,f,g){const h=[];for(const q of _.gy(b.f)){b=q.bf;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.I(t,JD));n=m+n;k=mE(t,k?null:l.ia,k);l=_.I(t,_.Gb);const v=(l=bE(g,l))?[l]:[];m=new nE(c,m,n,()=>v,k.ua,k.ia,e,f,!1,null,null,null,null);if("YES"===_.I(t,"INDEPENDENT")||0===b)m.h=!0;h.push(m)}}return h},zG=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.X;var q=c.a;const t=null!=q,v=q?[q]:[];if(!t&&!a.a.lowLatencyMode)return null;
59
- a=0;q={ua:0,ia:null};let y=null;t?({duration:c}=kE(n),a=e+c,q=jE(n,b?b.ia:null)):(b=yG(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.Ud?aE(n):null;d=new nE(d,e,a,()=>v,q.ua,q.ia,f,g,!1,null,h?h.$e:null,h?h.Bf:null,h?h.durationPerTile:null,y);d.fa=l;d.initSegment=m||void 0;return d},tG=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.B)return a.B;if(!LF(a)&&a.w)try{var k=a.f.get(c);var l=k?mF(k,e)||null:null;if(!l)throw new _.H(_.G,4,4030,"Segment not found in pervious playlist update.");
60
- var m=l.startTime+l.wa;a.g.debug(`Setting playlist start time to ${m}.`);return a.B=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].S,m=m[m.length-1],a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.G,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield AG(a,f,g,h);k=eF(h.X,a.o,m)||$E();l=xG(h,b,k.keyInfo);k=pE(k.keyInfo,e);h=yield BG(a,
61
- l,h,k,m,g);a.g.debug(`Setting playlist start time to ${h}.`);return a.B=h})},uG=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;wG(c);const n=yield AG(a,f,g,l);var q=a.o,t=h?h.zg:null;var v=1===k;if(c.slice(1).some(cF))throw new _.H(_.G,4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");
62
- if(ZD(c[0].X,_.Da)||null===t)if((t=eF(c[0].X,q,n))&&t.type===TD){if(1<gF(c))throw new _.H(_.G,4,4046,QD+`${v?"playlist":"discontinuity"}.`);v=[t]}else v=fF(c,q,n),v=0===v.length?[$E()]:v;else if(q=fF(c,q,n),t.type===_.ue||t.type===SD)v=[t,...q];else{if(0<gF(c))throw new _.H(_.G,4,4046,QD+`${v?"playlist":"discontinuity"}.`);v=[t]}q=v;v=q[q.length-1];q=aF(q);t=xG(l,b,q.keyInfo)||(h?h.vg:null);var y=pE(q.keyInfo,d);const A=l.fa;l=m?e:yield CG(a,A,t,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];
63
- const E=m[m.length-1]||null,O=0===y?0:E.endTime,sb=d+y,Mb=pE(q.keyInfo,sb);(D=zG(a,E,D,sb,O,l,Mb,f,b,A,t))&&m.push(D)}return{S:m,cg:q,zg:v,mimeType:n,endTime:m[m.length-1].endTime,fa:A,vg:t}})},AG=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=$D(d.X,_.Ea);f=f?UD(f,_.Gb):null;return DG(a,b,c,e,f)})},BG=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=oE(c,d);return kF(a.K,b,g,e,f,null!=d)})},CG=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.F.has(b))return a.F.get(b);
64
- const k=yield BG(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.F.set(b,k);return k})},DG=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.ej(f,b,c);if(g)return g;g=_.ui([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.C(g)).headers["content-type"];if(!g)throw new _.H(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},HE=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.G,4,
65
- 4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.G,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.X=c;this.S=1===b?d:null}},NE=class{constructor(a,b,c){c=void 0===c?[]:c;this.X=b;this.a=a;this.f=c;this.fa=-1}},nE=class extends _.Ty{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:
66
- q,t);this.initSegment=void 0;this.fa=0}},EG=class{constructor(){this.f=0;this.a=new Map}},FG=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},PF=new _.R("clpp.hls.DiscontinuityUtils");var iF={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Pf)throw new _.H(_.G,4,4041);if(UD(a,ND)===OD)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.cy(_.nd,[{initDataType:_.pf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":ZE,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":ZE,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=UD(a,ND);if(!XE.includes(b))return YE.error("Widevine in HLS is only supported with [",
67
- XE.join(", "),"], not",b),null;b=UD(a,_.Gb);b=_.Vq(b);b=_.J(b.data);b=_.cy(_.rd,[{initDataType:_.Sc,initData:b}],"");if(a=_.I(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},XE=["SAMPLE-AES",OD],YE=new _.R("clpp.hls.DrmParser");var hF=new _.R("clpp.hls.EncryptionUtils");var GG=class{constructor(a){this.g=new _.R("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.ri()}}};var iG=class{constructor(a){this.streams=a}length(){return this.streams.length}};var gG=class{constructor(a){this.a=a}length(){return this.a.length}};var HG=class{constructor(){this.a=this.D=null;this.H=1;this.f=new FG;this.o="";this.J=new EG;this.G=0;this.h=null;this.j=new _.mj(()=>{this.Bb()});this.l=_.vx;this.w=null;this.A=new _.Mr;this.B=null;this.g=new _.R("clpp.hls.HlsParser");this.F=new Map;this.K=new GG(this.C.bind(this));this.I=!1}configure(a){this.a=a;this.K.a=a}setCurrentVariant(a){this.h=a}start(a,b){const c=this;return _.x(function*(){if(c.I)throw Error("start() may be called only once!");c.I=!0;c.D=b;const {response:d,text:e}=yield IF(c,
68
- a);c.o=d.uri;const f=yield MF(c,e);c.w=f;const g=c.G;0<g&&c.j.ca(g);return f})}stop(){this.j&&(this.j.stop(),this.j=null);const a=[];this.A&&(a.push(this.A.destroy()),this.A=null);this.f.clear();this.w=this.a=this.D=this.h=null;return Promise.all(a)}onExpirationUpdated(){}update(){const a=this;return _.x(function*(){const b=a.w;if(!LF(a)&&b){var c=b.presentationTimeline;"LIVE"===a.l&&(a.B=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&null!==a.h){const f=HF(a);d=d.filter(g=>f.includes(vE(g).xa))}var e=
69
- yield OF(a,d);d=e.map(f=>f.Ga);QF(a,d);e=yield TF(a,e);tF(b.periods,e).forEach(f=>{a.D.filterNewPeriod(f)});wF(b.periods,e);xF(b.adaptedPeriods,e);GF(c,e);eE(d)&&VF(a,c,e)}})}Bb(){const a=this;return _.x(function*(){a.g.debug(_.ux);if(a.D)try{yield a.update(),a.j.ca(a.G)}catch(b){if(!(b instanceof _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.j.ca(.1))}})}C(a){if(!this.A)throw new _.H(_.G,7,7001);a=this.D.networkingEngine.fetch(a);_.Bi(this.A,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Ks{f(){_.tq.m3u8=HG;_.rq[_.hk]=HG;_.rq[RD]=HG}a(){_.$y("m3u8");_.az(_.hk);_.az(RD)}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 mF="CLOSED-CAPTIONS",nF="Could not parse MP4 segment start time.",oF="DURATION",pF="EXT-X-STREAM-INF",qF="Failed to infer discontinuity number",rF="Guessing audio-only",sF="METHOD",tF="SAMPLE-AES-CTR",uF="SUBTITLES",vF="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",wF="application/vnd.apple.mpegurl",xF="sample",yF="whole-segment",zF=function(a,b){return _.H(a,b,void 0,{required:!0})},AF=function(a){if(1>a.a)throw _.ql();--a.a},BF=function(a){if(null!==a&&void 0!==
2
+ a)return Number(a)},CF=function(a,b){return a.filter(c=>c.name===b)},DF=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=zF(d,_.Jb);return c.includes(d)})},EF=function(a,b){return a.some(c=>c.name===b)},FF=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.G(_.E,4,4024,{missingTag:b});return a},GF=function(a){var b=FF(a,"EXT-X-TILES");if(!b)return{Rc:1,hd:1,durationPerTile:null};a=_.H(b,"LAYOUT")||"1x1";b=_.H(b,oF);a=_.dz(a);return{Rc:a.Rc,
3
+ hd:a.hd,durationPerTile:b?Number(b):null}},HF=function(a,b){return _.Zy([a],[b])[0]},IF=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)},JF=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of IF(c))b(d,c)})},KF=function(a){return a.some(b=>EF(b.Z,_.Ea))},LF=function(a){return a.type===_.p||a.type===_.t},MF=function(a,b){const c=FF(a,_.Ea);
4
+ if(b&&c)return _.Tb;a=FF(a,_.Ka);if(!a)return"LIVE";if(a.value===_.Tb)return _.Tb;if("EVENT"===a.value)return"EVENT";throw new _.G(_.E,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},NF=function(a){a={AUDIO:_.p,VIDEO:_.t,SUBTITLES:_.F,"CLOSED-CAPTIONS":_.F}[a.toUpperCase()];if(!a)throw new _.G(_.E,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},OF=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 _.G(_.E,4,4044,
5
+ "Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.G(_.E,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.G(_.E,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.G(_.E,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{sa:d,ia:e}},PF=function(a,b){a=FF(a,_.Aa);return OF(a?a.value:null,b)},QF=function(a){a=FF(a,"EXTINF",{required:!0}).value.split(",");
6
+ return{duration:Number(a[0]),title:a[1]||null}},RF=function(a,b){b=void 0===b?{}:b;const c={nd:!1,gg:!1,hg:null,Jg:null,Af:null};a=FF(a,_.Oa,{required:b.Ff});if(!a)return c;const d=e=>null==e?null:Number(e);c.nd="YES"===_.H(a,"CAN-BLOCK-RELOAD");c.gg="YES"===_.H(a,"CAN-SKIP-DATERANGES");c.hg=d(_.H(a,"CAN-SKIP-UNTIL"));c.Jg=d(_.H(a,"HOLD-BACK"));c.Af=d(_.H(a,"PART-HOLD-BACK",void 0,{required:b.Ff}));return c},SF=function(a,b,c){c=void 0===c?!1:c;a=_.H(a,"BYTERANGE");return OF(a,b,c)},UF=function(a,
7
+ b){const c=PF(a.Z,null);return new TF(0,0,0,()=>[a.a],c.sa,c.ia,0,b)},VF=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.Di(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},WF=function(a){let b=Infinity,c=Infinity;IF(a).filter(LF).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{Bc:b,duration:c}},XF=function(a){return a.map(b=>{({duration:b}=WF(b));return b}).reduce((b,
8
+ c)=>b+c,0)},YF=function(a){return(a.video?a.video.va:"")+" - "+(a.audio?a.audio.va:"")},ZF=function(a,b,c,d){if(b===_.Tb)return{delay:0,mc:0};b=FF(a,_.Ia);if(c&&b){c=Number(zF(b,"PART-TARGET"));if(null!=d)return{delay:d,mc:c};({Af:d}=RF(a,{Ff:!0}));return{delay:d,mc:c}}a=FF(a,_.Pa,{required:!0});a=Number(a.value);return null!=d?{delay:d,mc:a}:{delay:3*a,mc:a}},$F=function(a){const b=[];JF(a,c=>{b.push(c.Qg)});return{delay:Math.max(...b.map(c=>c.delay)),mc:Math.min(...b.map(c=>c.mc))}},bG=function(a){const b=
9
+ new Map;a.forEach(c=>{var d=aG(c).groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},cG=function(a){const b=new Map;for(const c of a){a=_.H(c,_.bb);a=_.Xh(a||_.Wf);const d=zF(c,_.Ua),e=zF(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},eG=function(a){a=a.audio.concat(a.video);for(const b of a)a=aG(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),dG(b,a)},fG=function(a,b){if(!a)return null;const c=a.va;return b.find(d=>aG(d).va===c)||null},gG=function(a){for(const b of a)if(b.startsWith("#EXT-")&&
10
+ (a=_.Ii(0,b),_.As.has(a.name)))return 1;return 0},hG=function(a){a=CF(a,"EXT-X-DEFINE").map(b=>{const c=_.H(b,"NAME");if(!c)return null;b=zF(b,"VALUE");return{name:c,value:b}}).filter(Boolean);return new Map(a.map(b=>[b.name,b.value]))},iG=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.G(_.E,4,4044,`Undefined variable '${d}'`);return c})},jG=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=iG(d.value,b)})})},kG=function(a,b,c){jG(a,c);
11
+ b.forEach(d=>{jG(d.Z,c)})},nG=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=lG(a,b[e]);d.push(f);if(f.name===pF){const g=b[e+1];if(!g)throw new _.G(_.E,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.Gi(_.Lb,g));e++}}a.a=hG(d);kG(d,[],a.a);return new mG(c,0,d)},qG=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=lG(a,b[e]);if(_.Bs.has(f.name))break;d.push(f);e++}b=oG(a,c,b.slice(e));e=b.S;d=d.concat(b.Z);a=pG(a,d);kG(d,e,a);return new mG(c,1,
12
+ d,b.S)},rG=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 _.G(_.E,4,4015);return 0===gG(b)?nG(a,b,c):qG(a,b,c)},lG=function(a,b){return _.Ii(a.f++,b)},oG=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=lG(a,h),_.As.has(h.name)||_.Ds.has(h.name)?d.push(h):_.Cs.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.La&&"PART"===_.H(h,_.Jb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||
13
+ (h=HF(b,h.trim()),e.push(new sG(h,f,g)),f=[],g=[])});0<g.length&&e.push(new sG(null,f,g));return{S:e,Z:d}},pG=function(a,b){const c=CF(b,"EXT-X-DEFINE"),d=hG(b);c.map(e=>_.H(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.G(_.E,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},tG=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},uG=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&
14
+ 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},vG=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 _.G(_.E,4,4030);}uG(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===
15
+ 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}}uG(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},wG=function(a,b){let c=null,d=0;try{(new _.Gl).M(_.ze,_.zl).M(_.Tf,_.zl).M(_.ue,_.zl).ba("mdhd",g=>{g.reader.skip(0===g.version?8:16);d=_.O(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.$t.error("Unable to find timescale in init segment!"),
16
+ new _.G(_.E,4,4030,nF,c);let e=0,f=!1;try{(new _.Gl).M("moof",_.zl).M("traf",_.zl).ba("tfdt",g=>{var h=d;if(0===g.version)h=_.O(g.reader)/h;else{{const k=_.O(g.reader),l=_.O(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.G(_.E,4,4030,nF,c);return e},xG=function(a){for(;a.getPosition()<a.Aa()-1;){const b=
17
+ a.getPosition();if(71===_.rl(a))return AF(a),b}return-1},yG=function(a){function b(){d.seek(e+188);f=_.rl(d);71!==f&&(d.seek(e+192),f=_.rl(d));71!==f&&(d.seek(e+204),f=_.rl(d));71!==f&&c();AF(d)}function c(){throw new _.G(_.E,4,4030);}const d=new _.sm(new DataView(a),!1);let e=0,f=0;e=xG(d);0>e&&(_.$t.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.rl(d);71!==f&&c();a=_.sl(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.rl(d)&48)>>4;
18
+ 0!==a&&2!==a||c();3===a&&(a=_.rl(d),d.skip(a));if(1!==_.O(d)>>8){b();continue}d.skip(3);a=_.rl(d)>>6;0!==a&&1!==a||c();0===_.rl(d)&&c();a=_.rl(d);const g=_.sl(d),h=_.sl(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},BG=function(a){const b=zG(a),c=AG(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.fa===b);let g=e.findIndex(h=>h.fa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},AG=function(a){a=a.map(b=>b.S[b.S.length-1].fa);return Math.min(...a)},zG=function(a){a=a.map(b=>b.S[0].fa);
19
+ return Math.max(...a)},EG=function(a){var b=zF(a,sF);if(!CG.includes(b))return DG.error("PlayReady in HLS is only supported with [",CG.join(", "),"], not",b),null;a=zF(a,_.Lb);b=_.Lr(a);a=null;b=_.I(b.data);try{a=_.Ny(_.zm(b))}catch(c){a=b}return _.$y(_.wd,[{initDataType:_.Zc,initData:a}],"")},GG=function(a){if(0===a.length)return FG();if(a.some(c=>c.type===yF)||a.every(c=>c.type===_.Ce))return a[0];a=a.filter(c=>c.type===xF);const b=_.Bh(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-
20
+ 1].keyId,type:xF,drmInfos:b}},JG=function(a){a=HG(a);if(a.some(b=>IG(b))&&1<a.length)throw new _.G(_.E,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},IG=function(a){return CF(a.Z,_.Fa).some(b=>"AES-128"===_.H(b,sF))},LG=function(a,b,c){return HG(a).map(d=>KG(d.Z,b,c))},MG=function(a){return a.filter(b=>EF(b.Z,_.Fa)).length},HG=function(a){return a.filter(b=>EF(b.Z,_.Fa))},KG=function(a,b,c){a=CF(a,_.Fa);if(0===a.length)return null;var d=zF(a[0],sF);if(1===
21
+ a.length){if("NONE"===d)return FG();if("AES-128"===d)return a=a[0],d=_.H(a,"IV",""),{type:yF,keyInfo:{method:"AES-128",url:HF(b,zF(a,_.Lb)),iv:d?_.Ai((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>zF(e,sF));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===tF))throw NG.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.G(_.E,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.H(e,"KEYFORMAT","identity");{const g=OG[f]||null;e=g?g(e,
22
+ c):null}e||NG.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.G(_.E,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:xF,drmInfos:b}},FG=function(){return{type:_.Ce,keyInfo:null,drmInfos:[],keyId:null}},PG=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.Az(b.Ja(),b.sa,b.sa+2048-1,a.a.attemptParameters);e.type=2;const f=_.Az(b.Ja(),b.sa,b.ia,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);
23
+ try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.h.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.",e.uris[0]);try{return yield a.f(f)}catch(h){throw a.h.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.G(_.E,4,4030,"Failed to fetch the media segment.");}}})},QG=function(a,b,c,d,e,f){return _.w(function*(){a.h.debug("Fetching segment to find start time");
24
+ if("audio/mpeg"===d||d===_.Lc||d===_.Hc)return 0;if(d===_.Gc){var g=yield PG(a,c,f);const h=_.I(g.data);return uG(h)?vG(h):yG(g.data)}if(d===_.kg||d===_.Mc)return g=[PG(a,c,f)],b&&g.push(PG(a,b,!0)),g=yield Promise.all(g),wG(g[0].data,(g[1]||g[0]).data);if(d===_.jg)return g=yield PG(a,c,f),yG(g.data);if(!_.Mp(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.G(_.E,4,4030);})},RG=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},dG=function(a,b){a.streams.forEach(c=>
25
+ {c.codecs=b.join(",")})},SG=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},aG=function(a){return a.streams[0]},TG=function(a,b){a.streams.forEach(c=>{c.Md=b})},UG=function(a,b){a.streams.forEach(c=>{c.width=b})},VG=function(a,b){a.streams.forEach(c=>{c.height=b})},WG=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},XG=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},YG=function(a,b){a=a.map(c=>
26
+ c.a[b]);return a.some(c=>null==c)?null:a},ZG=function(a,b){const c=new Set(a.map(d=>d.fa));return b.filter(d=>!c.has(d.fa))},bH=function(a,b){for(;a[0].fa<b[0].fa;)a.splice(0,1);var c=a[0];let d=b[0];$G(c,d)||aH(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&!$G(c,d)&&aH(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},cH=function(a,b){const c=a[a.length-1];var d=b.findIndex(f=>f.fa===c.fa);const e=b[d];$G(c,e)||aH(c,e);for(d+=1;d<b.length;d++)a.push(b[d])},hH=function(a,b,c,d,e){var f=b[0].length();f=tG(f).map(g=>
27
+ {var h=YG(b,g)||[];const k=RG(c,g)||[];g=RG(d,g)||[];{const l=[...dH(h),...k,...g].filter(Boolean);eH(l);const {fa:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,fa:m}}return h});e&&fH(f[0]);gH(f);return f},dH=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},fH=function(a){const b=dH(a.variants)[0].S[0].ua;a.startTime+=b;a.endTime+=b},gH=function(a){for(let b=0;b<a.length;b++){const c=
28
+ a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},$G=function(a,b){return a.startTime===b.startTime&&a.endTime===b.endTime},aH=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;iH(a.variants,b.variants);jH(IF(a),IF(b))},iH=function(a,b){const c=new Map(a.map(d=>[YF(d),d]));b.forEach(d=>{c.get(YF(d)).drmInfos=d.drmInfos})},jH=function(a,b){const c=new Map(a.map(d=>[d.va,d]));b.forEach(d=>{const e=c.get(d.va);e.S=d.S;e.segmentIndex.replace(d.S);
29
+ e.Bc=d.Bc;e.fe=d.fe;e.duration=d.duration;e.af=d.af;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},eH=function(a){const b=kH(a);a.forEach(c=>{_.wz(c.segmentIndex,b);c.duration=b;c.fe=c.Bc+b})},kH=function(a){let b=Infinity;a.filter(LF).forEach(c=>{b=Math.min(b,c.duration)});return b},lH=function(a,b){JF(b,(c,d)=>{_.Jz(a,c.S,d.startTime)});_.Bz(a.a,b[0].startTime,b[b.length-1].endTime)},mH=function(a){return null===a.j?[]:[a.j.audio,a.j.video].filter(b=>b).map(b=>b.va)},nH=function(a,
30
+ b){return _.w(function*(){var c=_.Ni([b],a.a.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.ji(c.data)}catch(e){throw new _.G(_.E,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},sH=function(a,b){return _.w(function*(){var c=oH(a,b,a.w,"");if(1===c.type){c=_.ws(c.S[0].a)||"";c=null!=_.vs.video[c]?_.t:null!=_.vs.audio[c]?_.p:null;var d="";c===_.t?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.w;d=a.a.hlsDefaultCodecs||d;var f=[];const q=
31
+ [];q.push(new _.Gi(_.ma,"0"));q.push(new _.Gi(_.Lb,e));d.length&&q.push(new _.Gi(_.pa,d));f.push(new _.Hi(c.f++,pF,q));c=new mG(e,0,f)}}d=c.Z;c=CF(d,"EXT-X-MEDIA");e=CF(d,pF);d=CF(d,"EXT-X-IMAGE-STREAM-INF");c={Ac:{bg:DF(c,["AUDIO",_.Sb]),closedCaptions:DF(c,mF),rh:DF(c,uF)},jd:e,ae:d};const {periods:g,Df:h,Kf:k}=yield pH(a,c);if(!a.D)throw new _.G(_.E,7,7001);e=$F(g[0]);qH(a,g);c=!0;d=null;f=0;rH(a)||(c=!1,d=0,f=e.delay);d=new _.$E(a.a.timeline||{},d,f,!0,void 0,!!a.a.lowLatencyMode);_.Fz(d,c);lH(d,
32
+ g);h&&_.Ez(d,h);c=d;if(!rH(a)){a.C=e.mc;e=0;for(var l of a.f.values())e=Math.max(e,l.streams[0].Bc);for(l=0;95443.7176888889<=e;)l+=95443.7176888889,e-=95443.7176888889;if(l){a.h.debug("Offsetting live streams by",l,"to compensate for rollover");for(var m of a.f.values())e=m.streams[0],95443.7176888889>e.Bc?(a.h.debug("Offset applied to",e.type),e.segmentIndex.offset(l)):a.h.debug("Offset NOT applied to",e.type)}}m=XF(g);"LIVE"===a.l||"EVENT"===a.l?(m=Math.max(m,c.H),isNaN(a.a.availabilityWindowOverride)||
33
+ (m=a.a.availabilityWindowOverride),c.A=m):a.l===_.Tb&&(c.f=m);if(k)for(var n of k)a.D.onTimelineCueAdded({configurationId:a.D.configurationId,schemeIdUri:n.schemeIdUri,Na:n.Na,value:"",startTime:n.startTime,endTime:n.endTime,id:n.id,type:_.mh,eventElement:null});n={presentationTimeline:c,adaptedPeriods:[...g],periods:g,minBufferTime:0};a.h.debug("HLS playlist parsed",n);return n})},uH=function(a,b){return Promise.all(b.map(c=>tH(a,c)))},wH=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!rH(a),
34
+ f=FF(c.Z,_.Da);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].S,f=f[f.length-1].fa):f=0;if(e&&0<f)try{{const k=FF(c.Z,_.Ha);if(!k)throw vH.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(qF);const l=Number(k.value),m=SG(d,l);if(!m)throw vH.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(qF);var h=m.fa}g=h;break a}catch(k){throw new _.G(_.E,
35
+ 4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.S||[];for(const k of c)EF(k.Z,_.Ca)&&g++,k.fa=g});BG(b)},zH=function(a,b){return _.w(function*(){const {textStreams:c,thumbStreams:d,cg:e}=yield xH(a,b);var f=a.o.periods[0].variants;a.a.lowLatencyMode&&null!==a.j&&(f=f.filter(g=>g.id===a.j.id));f=f.map(g=>{const h=fG(g.audio,e),k=fG(g.video,e);g=yH(a,h,k,g.bandwidth);if(!g)throw new _.G(_.E,4,4047,{message:"Video and audio are encrypted in an incompatible way.",
36
+ Vh:k?aG(k).va:void 0,audio:h?aG(h).va:void 0});return g});return hH(a.D.configurationId,f,c,d,!0)})},qH=function(a,b){rH(a)||2!==a.a.timeline.version||(a.G||(a.G=b[0].startTime),_.qB(b,-a.G))},AH=function(a,b,c){a.l=_.Tb;_.Fz(b,!0);b.f=c[c.length-1].endTime},oH=function(a,b,c,d){a=rG(a.K,b,c);a.a=d;BH(a);return a},pH=function(a,b){return _.w(function*(){var c=cG(b.Ac.closedCaptions),d=CH(a,b.jd),e=yield DH(a,b);const f=Object.values(e).flat().map(h=>h.playlist);wH(a,f);var g=yield EH(a,e.Se,d);c=
37
+ yield FH(a,e.jd,g,c);d=yield GH(a,e.qh,d);g=yield HH(a,e.ae);e=IH(a,e);c=hH(a.D.configurationId,c,d,g,!rH(a));a.D.filterAllPeriods(c);return rH(a)?(d=null,e&&(d=JH(f,e)),{periods:c,Df:e,Kf:d}):{periods:c,Df:e,Kf:null}})},xH=function(a,b){return _.w(function*(){const c=g=>aG(g.stream).type===_.t||aG(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=aG(h.stream);k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,
38
+ primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,codecs:k.codecs,name:k.originalId,uri:k.va,Kd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return KH(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);LH(a,d.concat(f));e=f.filter(g=>aG(g).type===_.Iy);f=f.filter(g=>aG(g).type===_.be);return{textStreams:e,thumbStreams:f,cg:d}})},yH=function(a,b,c,d){const e=[],f=(c||b).length();for(let m=0;m<f;m++){var g=b?b.streams[m]||null:
39
+ null,h=c?c.streams[m]||null:null,k=g,l=h;k=k&&l?_.hz(k.drmInfos,l.drmInfos)?_.gz(k.drmInfos,l.drmInfos):null:k?k.drmInfos:l?l.drmInfos:null;if(!k)return null;l=d;g={id:a.N++,language:g?g.language:_.Wf,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new MH(e)},KH=function(a,b){return _.w(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.Xc,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,
40
+ n=b.spatialAudio,q=b.closedCaptions,u=b.Kd,v=_.Xh(f||_.Wf);if(1!==c.type)throw new _.G(_.E,4,4017);var y=MF(c.Z,null==a.o);a.l=y;const A=ZF(c.Z,y,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);y=yield NH(a,c,e,d);const D=a.a.lowLatencyMode?_.KC:_.zy;let M=k;e!==_.F||k||(M=_.Iy);const {nd:da}=RF(c.Z);k=y.map(sb=>{const Qb=sb.S,id=sb.ng,Uf=sb.mimeType;sb=sb.fa;const Va=Qb[0].startTime,ce=Qb[Qb.length-1].endTime,Ec=ce-Va,ea=new _.aF(Qb),$a=Qb[0].initSegment||null;return{id:_.eF++,originalId:l,
41
+ createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ea.f.bind(ea),getSegmentReference:ea.get.bind(ea),adjustSegmentDurations:ea.g.bind(ea),getDuration:ea.getDuration.bind(ea),segmentIndex:ea,segmentLookupStrategy:D,initSegmentReference:$a,mimeType:Uf,codecs:d,kind:M,af:id.type,encrypted:id.type===xF,keyId:id.keyId,language:v,originalLanguage:f||_.Wf,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:
42
+ void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:id.keyInfo,S:Qb,drmInfos:id.drmInfos,fa:sb,va:c.a,Md:c.f,Bc:Va,fe:ce,duration:Ec,nd:da,groupId:g,Qg:A}});return new OH(k)})},LH=function(a,b){b.forEach(c=>{a.f.a.set(aG(c).va,c)})},CH=function(a,b){const c=new Map;for(const f of b){var d=_.H(f,"AUDIO");b=_.H(f,_.Sb);var e=_.H(f,uF);const g=PH(a,f);if(e){const h=_.uj(_.F,g);c.set(e,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=QH(_.p,g),c.set(d,e));b&&(d=QH(_.t,
43
+ g),c.set(b,d))}return c},DH=function(a,b){return _.w(function*(){const c=yield Promise.all([RH(a,b.Ac.bg),RH(a,b.Ac.rh),RH(a,b.jd),RH(a,b.ae)]),[d,e,f,g]=c;return{Se:d,qh:e,jd:f,ae:g}})},EH=function(a,b,c){return _.w(function*(){if(0===b.length)return new Map;var d=[SH(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>SH(a,e,c)));d=yield Promise.all(d);return bG(d)})},FH=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=
44
+ Number(zF(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield TH(a,h,c,d,e);f=f.map(k=>TH(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.Xy,[])})},GH=function(a,b,c){return Promise.all(b.map(d=>SH(a,d,c)))},HH=function(a,b){return Promise.all(b.map(c=>UH(a,c)))},IH=function(a,b){b=[...b.jd,...b.Se].map(d=>d.playlist).flatMap(d=>d.S[0].Z);b=FF(b,_.Ma);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.h.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+
45
+ `value (value: ${b.value}).`),null):c/1E3},rH=function(a){return a.l===_.Tb},JH=function(a,b){return(a=a.find(c=>null!==FF(c.Z,_.Ba)))?a.Z.filter(c=>c.name===_.Ba).map(c=>{a:{var d=_.H(c,"ID"),e=_.H(c,"START-DATE");if(null===d||null===e)_.zs.warn("Invalid EXT-X-DATERANGE missing mandatory ID or START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",c),c=null;else{var f=new Date(e);e=f.getTime()/1E3-b;d={id:d,startTime:e,startDate:f};var g=BF(_.H(c,oF));void 0!==g&&0<=g&&(d.duration=g);var h=BF(_.H(c,
46
+ "PLANNED-DURATION"));void 0!==h&&0<=h&&(d.plannedDuration=h);var k=_.H(c,"CLASS");null!==k&&(d.schemeIdUri=k);var l=_.H(c,"END-DATE");l=l?new Date(l):null;null!==l&&l.getTime()>=f.getTime()&&(d.endDate=l);{const q=c.attributes;if(null==q)var m=null;else{f={};for(m of q)m.name.startsWith("X-")&&(f[m.name]=m.value);m=_.Ng(f)?f:null}}m=m||{};if(k===_.vd){f=c.attributes;if(null==f)var n=null;else{k={};for(n of f)switch(n.name){case _.Zb:k[_.Zb]=n.value;break;case _.Yb:k[_.Yb]=n.value;break;case _.ac:k[_.ac]=
47
+ BF(n.value);break;case _.$b:k[_.$b]=BF(n.value);break;case "X-SNAP":k["X-SNAP"]=n.value.split(",");break;case "X-RESTRICT":k["X-SNAP"]=n.value.split(",")}k[_.Zb]&&k[_.Yb]||!k[_.Zb]&&!k[_.Yb]?(_.zs.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),n=null):n=_.Ng(k)?k:null}if(null===n){_.zs.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",c);c=null;break a}m=Object.assign(m,n)}_.Ng(m)&&(d.Na=m);d.endTime=l?l.getTime()/1E3:g?e+g:h?e+h:e;d.type=
48
+ "hls-daterange";c=d}}return c}).filter(Boolean):null},RH=function(a,b){return _.w(function*(){return(yield Promise.all(b.map(c=>_.w(function*(){const d=yield VH(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},tH=function(a,b){return _.w(function*(){var c=new _.Jh(aG(b).Md);if(a.a.lowLatencyMode&&aG(b).nd){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={Tg:d.position,Zg:e&&0<e.length?f:null}}else d=null;if(e=d)d=e.Tg,e=e.Zg,f=_.ij(c.a.toString()),
49
+ f._HLS_msn=d.toString(),null===e&&f._HLS_part&&delete f._HLS_part,null!==e&&(f._HLS_part=e.toString()),d=_.hj(f,!0),d=new _.Qh(d),_.Mh(c,d)}const {response:g,text:h}=yield nH(a,c.toString());c=aG(b).va;d=aG(b).Md;e=g.uri;d!==e&&(d=e,TG(b,d));c=oH(a,h,d,c);return{stream:b,playlist:c}})},PH=function(a,b){var c=_.H(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.lz(e)[0],b.has(c)?a.h.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));
50
+ return d},QH=function(a,b){if(1===b.length)return b[0];a=_.uj(a,b);if(null!=a)return a;throw new _.G(_.E,4,4025,{codecList:b});},SH=function(a,b,c){return _.w(function*(){const d=b.tag,e=b.playlist;return WH(a,e.a,()=>_.w(function*(){const f=zF(d,_.Ua),g=NF(zF(d,_.Jb));var h=zF(d,_.Jb).toUpperCase();if(NF(h)!==_.F)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.Iy;h===mF&&(l=_.wy);k&&(l=_.Wd);h=l}k=c.get(f)||"";l=_.H(d,_.bb);const m=_.H(d,"NAME"),
51
+ n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.H(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.H(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield KH(a,{playlist:e,codecs:k,type:g,Xc:l,primary:!!n&&!!q,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,closedCaptions:null,Kd:null})}))})},UH=function(a,b){return _.w(function*(){const c=b.tag,d=b.playlist;return WH(a,d.a,()=>_.w(function*(){var e=_.H(c,_.pa)||"jpg",f=_.H(c,_.bb);const g=
52
+ _.H(c,"NAME");e=yield KH(a,{playlist:d,codecs:e,type:_.be,Xc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,groupId:null,Kd:null});(f=_.H(c,_.ma))&&XG(e,Number(f));return e}))})},TH=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=Number(zF(f,_.ma));if(null!=f.getAttribute("FRAME-RATE")||null!=f.getAttribute(_.Ab)){var h=_.H(f,"FRAME-RATE");f=_.H(f,_.Ab);var [k,l]=f?f.split("x"):[null,null];h={frameRate:BF(h),width:BF(k),height:BF(l)}}else h=null;if(f=
53
+ yield XH(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const n of m)for(const q of h){m=(q?aG(q).va:"")+" - "+(n?aG(n).va:"");if(e.has(m)){a.h.debug("Skipping variant which only differs in text streams.");continue}const u=yH(a,n,q,g);null==u?a.h.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(u),e.add(m))}g=f}else g=[];return g})},XH=function(a,b,c,d,e){return _.w(function*(){var f=b.tag,g=b.playlist;let h=PH(a,f);var k=_.H(f,"AUDIO"),l=_.H(f,
54
+ _.Sb),m=k||l;m=m&&d.has(m)?d.get(m):[];k={audio:k?m:[],video:l?m:[]};a.h.debug("Guessing stream type for",f.toString());f=!1;const n=g.a;g=k.audio.find(q=>q.va===n);l=_.uj(_.t,h);l=c||l;1!==h.length||l?!m.length&&1<h.length?(a.h.debug("Guessing multiplexed audio+video"),g=_.t,h=[h.join(",")]):k.audio.length&&g?(a.h.debug(rF),g=_.p,f=!0):k.video.length?(a.h.debug(rF),g=_.p):(a.h.debug("Guessing video-only"),g=_.t):(g=_.p,a.h.debug(rF));l=null;f||(l=yield YH(a,b,h,g,e,c));if(null==l)return null;k[g]=
55
+ [l];g===_.p&&c&&m.forEach(q=>{UG(q,c.width);VG(q,c.height);WG(q,c.frameRate)});eG(k);return k})},YH=function(a,b,c,d,e,f){return _.w(function*(){const g=b.tag,h=b.playlist;return WH(a,h.a,()=>_.w(function*(){var k=_.H(g,mF);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=QH(d,c);return yield KH(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,Xc:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Kd:f})}))})},WH=function(a,b,c){if(a.f.has(b))return a=a.f.get(b),Promise.resolve(a);
56
+ if(a.f.f.has(b))return a.f.f.get(b)||null;c=c();a.f.set(b,c);return c},NH=function(a,b,c,d){return _.w(function*(){var e=b.a,f=b.S;var g=void 0===g?0:g;var h=(h=FF(b.Z,_.Ha))?Number(h.value):g;g=[];!rH(a)&&JG(f);e=yield ZH(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)EF(m.Z,_.Ca)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield $H(a,b.f,k,h,e,c,d,g[g.length-1]||null,f.length),g.push(l),h+=k.length;aI(g);return g})},VH=function(a,
57
+ b){return _.w(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.H(b,_.Jb)===uF;c=_.H(b,_.Lb,void 0,{required:c});if(!c)return null;const d=HF(a.w,c),{response:e,text:f}=yield nH(a,d);return oH(a,f,e.uri,c)})},BH=function(a){1===a.type&&a.S.forEach((b,c)=>{if(EF(b.Z,_.Ga)&&!EF(b.Z,_.Ca)&&0<c)throw new _.G(_.E,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},aI=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.G(_.E,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");
58
+ },bI=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.H(c,_.Lb))||null).map(b=>_.ws(b));if(1<(new Set(a)).size)throw new _.G(_.E,4,4044,"Unexpected change in file format.");},cI=function(a,b,c){a=CF(a.Z,_.Ga);if(1<a.length)throw new _.G(_.E,4,4020);a=a[0];if(!a)return null;const d=zF(a,_.Lb),e=HF(b,d);b=SF(a,null,!0);return new _.XE(()=>[e],b.sa,b.ia,c)},dI=function(a,b,c,d,e,f,g){const h=[];for(const q of _.ez(b.f)){b=q.nf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.H(u,
59
+ oF));n=m+n;k=SF(u,k?null:l.ia,k);l=_.H(u,_.Lb);const v=(l=HF(g,l))?[l]:[];m=new TF(c,m,n,()=>v,k.sa,k.ia,e,f,!1,null,null,null,null);if("YES"===_.H(u,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},eI=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.Z;var q=c.a;const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={sa:0,ia:null};let y=null;u?({duration:c}=QF(n),a=e+c,q=PF(n,b?b.ia:null)):(b=dI(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.be?GF(n):null;d=new TF(d,e,a,()=>v,q.sa,
60
+ q.ia,f,g,!1,null,h?h.Rc:null,h?h.hd:null,h?h.durationPerTile:null,y);d.fa=l;d.initSegment=m||void 0;return d},ZH=function(a,b,c,d,e,f,g){return _.w(function*(){var h=d[0];if(null!=a.B)return a.B;if(!rH(a)&&a.o)try{var k=a.f.get(c);var l=k?SG(k,e)||null:null;if(!l)throw new _.G(_.E,4,4030,"Segment not found in pervious playlist update.");var m=l.startTime+l.ua;a.h.debug(`Setting playlist start time to ${m}.`);return a.B=m}catch(n){if(h=a.f.get(c))m=h.streams[h.streams.length-1].S,m=m[m.length-1],a.h.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].S[0].position} - ${m.position}`+
61
+ `, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.G(_.E,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield fI(a,f,g,h);k=KG(h.Z,a.w,m)||FG();l=cI(h,b,k.keyInfo);k=VF(k.keyInfo,e);h=yield gI(a,l,h,k,m,g);a.h.debug(`Setting playlist start time to ${h}.`);return a.B=h})},$H=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){var l=c[0],m=null==h;bI(c);const n=yield fI(a,f,g,l);var q=a.w,u=h?h.Pg:null;var v=1===k;if(c.slice(1).some(IG))throw new _.G(_.E,
62
+ 4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");if(EF(c[0].Z,_.Fa)||null===u)if((u=KG(c[0].Z,q,n))&&u.type===yF){if(1<MG(c))throw new _.G(_.E,4,4046,vF+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=LG(c,q,n),v=0===v.length?[FG()]:v;else if(q=LG(c,q,n),u.type===_.Ce||
63
+ u.type===xF)v=[u,...q];else{if(0<MG(c))throw new _.G(_.E,4,4046,vF+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=GG(q);u=cI(l,b,q.keyInfo)||(h?h.Kg:null);var y=VF(q.keyInfo,d);const A=l.fa;l=m?e:yield hI(a,A,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];const M=m[m.length-1]||null,da=0===y?0:M.endTime,sb=d+y,Qb=VF(q.keyInfo,sb);(D=eI(a,M,D,sb,da,l,Qb,f,b,A,u))&&m.push(D)}return{S:m,ng:q,Pg:v,mimeType:n,endTime:m[m.length-1].endTime,fa:A,Kg:u}})},fI=function(a,b,c,d){return _.w(function*(){const e=
64
+ d.a;var f=FF(d.Z,_.Ga);f=f?zF(f,_.Lb):null;return iI(a,b,c,e,f)})},gI=function(a,b,c,d,e,f){return _.w(function*(){if(null==c.a)return 0;const g=UF(c,d);return QG(a.L,b,g,e,f,null!=d)})},hI=function(a,b,c,d,e,f,g,h){return _.w(function*(){if(a.H.has(b))return a.H.get(b);const k=yield gI(a,c,d,f,g,h);a.h.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.H.set(b,k);return k})},iI=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.xj(f,b,c);if(g)return g;g=_.Ni([d],
65
+ a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.G(_.E,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},mG=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.G(_.E,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.G(_.E,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.Z=c;this.S=1===b?d:null}},sG=class{constructor(a,
66
+ b,c){c=void 0===c?[]:c;this.Z=b;this.a=a;this.f=c;this.fa=-1}},TF=class extends _.Wz{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,u){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,u);this.initSegment=void 0;this.fa=0}},jI=class{constructor(){this.f=0;this.a=new Map}},kI=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)||
67
+ null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},vH=new _.Q("clpp.hls.DiscontinuityUtils");var OG={"com.apple.streamingkeydelivery":function(a,b){if(b===_.jg)throw new _.G(_.E,4,4041);if(zF(a,sF)===tF)throw new _.G(_.E,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.$y(_.ud,[{initDataType:_.Ff,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":EG,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":EG,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=zF(a,sF);if(!CG.includes(b))return DG.error("Widevine in HLS is only supported with [",
68
+ CG.join(", "),"], not",b),null;b=zF(a,_.Lb);b=_.Lr(b);b=_.I(b.data);b=_.$y(_.yd,[{initDataType:_.Zc,initData:b}],"");if(a=_.H(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},CG=["SAMPLE-AES",tF],DG=new _.Q("clpp.hls.DrmParser");var NG=new _.Q("clpp.hls.EncryptionUtils");var lI=class{constructor(a){this.h=new _.Q("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.Ki()}}};var OH=class{constructor(a){this.streams=a}length(){return this.streams.length}};var MH=class{constructor(a){this.a=a}length(){return this.a.length}};var mI=class{constructor(){this.a=this.D=null;this.N=1;this.f=new kI;this.w="";this.K=new jI;this.C=0;this.j=null;this.g=new _.Nj(()=>{this.Ab()});this.l=_.Tb;this.o=null;this.A=new _.Es;this.B=null;this.h=new _.Q("clpp.hls.HlsParser");this.H=new Map;this.L=new lI(this.F.bind(this));this.J=!1;this.G=null;this.I=!1}configure(a){this.a=a;this.L.a=a}setCurrentVariant(a){this.j=a}start(a,b){const c=this;return _.w(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,
69
+ text:e}=yield nH(c,a);c.w=d.uri;const f=yield sH(c,e);c.o=f;const g=c.C;c.g&&0<g&&c.g.da(g);return f})}requestStop(){this.I=!0}stop(){this.g&&(this.g.stop(),this.g=null);const a=[];this.A&&(a.push(this.A.destroy()),this.A=null);this.f.clear();this.o=this.a=this.D=this.j=null;return Promise.all(a)}update(){const a=this;return _.w(function*(){const b=a.o;if(!rH(a)&&b){var c=b.presentationTimeline;"LIVE"===a.l&&(a.B=null);var d=Array.from(a.f.values());if(a.a.lowLatencyMode&&null!==a.j){const f=mH(a);
70
+ d=d.filter(g=>f.includes(aG(g).va))}var e=yield uH(a,d);d=e.map(f=>f.playlist);wH(a,d);e=yield zH(a,e);ZG(b.periods,e).forEach(f=>{a.D.filterNewPeriod(f)});qH(a,e);bH(b.periods,e);cH(b.adaptedPeriods,e);lH(c,e);if(d=KF(d))!0!==a.a.keepTimelineLive&&AH(a,c,e),a.g.stop(),a.g=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.I&&(yield a.stop())}})}Ab(){const a=this;return _.w(function*(){a.h.debug(_.ry);if(a.D)try{yield a.update(),a.g&&0<a.C&&a.g.da(a.C)}catch(b){if(!(b instanceof
71
+ _.G))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.g&&a.g.da(.1))}})}F(a){if(!this.A)throw new _.G(_.E,7,7001);a=this.D.networkingEngine.fetch(a);_.Ui(this.A,a);return a.P}};_.x("clpp.hls.HlsComponent",class extends _.Ft{f(){_.jr.m3u8=mI;_.hr[_.Ik]=mI;_.hr[wF]=mI}a(){_.uA("m3u8");_.vA(_.Ik);_.vA(wF)}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 ZN=function(a){a.a.one(a.m,_.ge,()=>YN(a))},YN=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.mc,d=>$N(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ne).forEach(d=>{$N(a,{track:d})});!aO(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."),bO(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.")},$N=function(a,b){b=b.track;b.kind===_.ne&&(a.g.info("The metadata track has been added."),b.mode=_.Sd,a.a.on(b,_.vd,c=>cO(a,c)))},aO=function(a){return a.some(b=>b.kind===_.ne)},bO=function(a,b){const c=a.m.getTrackManager(),d=c.ja(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ta(d);a.a.on(b.textTracks,_.mc,g=>{g.track.kind===_.ne&&(a.a.off(b.textTracks,_.mc,f),c.ta(d))});c.ta(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- cO=function(a,b){const c=dO(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 eO(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Vh(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)}}})},dO=function(a){return(a=a.m.getTrackManager().qa())&&a.language&&a.language.toLowerCase()},
4
- eO=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.Bg(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=_.Bg(a)?a:null}}};var fO=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.ir;this.h=(a=_.Xq[_.xc]||null)?new a(this.m.getConfiguration()):null;this.g=new _.R("clpp.hlssmpte.ImageCueHandler");this.f=null;ZN(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var gO=class extends _.kt{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Aj()){var b=a.getConfiguration();b=_.vg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Kc&&(b.patchMetadataTrack=!1);_.Cg(b.timestampOffset)||(b.timestampOffset=0);this.a=new fO(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.x(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",gO);
5
- gO.Id="hlssmpte";_.so(new class{create(){return new gO}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var HP=function(a){a.a.one(a.m,_.pe,()=>GP(a))},GP=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.g){a.a.on(b.textTracks,_.sc,d=>IP(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.we).forEach(d=>{IP(a,{track:d})});!JP(c)&&a.l&&(a.h.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),KP(a,b))}else a.h.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
+ else a.h.warn("A video element is not available. Skipping.")},IP=function(a,b){b=b.track;b.kind===_.we&&(a.h.info("The metadata track has been added."),b.mode=_.$d,a.a.on(b,_.Cd,c=>LP(a,c)))},JP=function(a){return a.some(b=>b.kind===_.we)},KP=function(a,b){const c=a.m.getTrackManager(),d=c.ja(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ra(d);a.a.on(b.textTracks,_.sc,g=>{g.track.kind===_.we&&(a.a.off(b.textTracks,_.sc,f),c.ra(d))});c.ra(e)}else a.h.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ LP=function(a,b){const c=MP(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 NP(d);if(e.f===c&&null!==e.a){a.f=d;d=a.g.parseMedia(_.ni(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)}}})},MP=function(a){return(a=a.m.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
4
+ NP=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(_.Rg(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=_.Rg(a)?a:null}}};var OP=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.as;this.g=(a=_.Pr(_.Cc))?new a(this.m.getConfiguration()):null;this.h=new _.Q("clpp.hlssmpte.ImageCueHandler");this.f=null;HP(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var PP=class extends _.hu{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.bk()){var b=a.getConfiguration();b=_.Lg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Rc&&(b.patchMetadataTrack=!1);_.Sg(b.timestampOffset)||(b.timestampOffset=0);this.a=new OP(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",PP);
5
+ PP.Id="hlssmpte";_.Vo(new class{create(){return new PP}});};f.call(g, window);