@castlabs/prestoplay 6.17.0 → 6.17.1

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 (63) hide show
  1. package/CHANGELOG.md +6 -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 +98 -98
  6. package/cjs/cl.conviva.js +31 -31
  7. package/cjs/cl.core.js +372 -369
  8. package/cjs/cl.crypto.js +8 -8
  9. package/cjs/cl.dash.js +71 -71
  10. package/cjs/cl.externs.js +1 -1
  11. package/cjs/cl.freewheel.js +21 -21
  12. package/cjs/cl.hls.js +67 -67
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -29
  15. package/cjs/cl.ima.js +22 -22
  16. package/cjs/cl.mse.js +302 -302
  17. package/cjs/cl.muxdata.js +14 -14
  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.sessions.js +15 -15
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +71 -71
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +64 -64
  26. package/cjs/cl.ttml.js +28 -28
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +9 -9
  29. package/cjs/cl.vr.js +18 -18
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.youbora.js +14 -14
  32. package/cl.adobe.js +3 -3
  33. package/cl.airplay.js +3 -3
  34. package/cl.broadpeak.js +5 -5
  35. package/cl.cast.js +83 -83
  36. package/cl.conviva.js +26 -26
  37. package/cl.core.js +324 -323
  38. package/cl.crypto.js +8 -8
  39. package/cl.dash.js +69 -69
  40. package/cl.externs.js +1 -1
  41. package/cl.freewheel.js +15 -15
  42. package/cl.hls.js +72 -72
  43. package/cl.hlssmpte.js +5 -5
  44. package/cl.htmlcue.js +26 -26
  45. package/cl.ima.js +15 -15
  46. package/cl.mse.js +267 -268
  47. package/cl.muxdata.js +11 -11
  48. package/cl.onboard.js +4 -4
  49. package/cl.persistent.js +10 -10
  50. package/cl.playlist.js +5 -5
  51. package/cl.sessions.js +10 -10
  52. package/cl.simid.js +13 -13
  53. package/cl.smooth.js +59 -59
  54. package/cl.thumbnails.js +19 -19
  55. package/cl.tizen.js +54 -54
  56. package/cl.ttml.js +22 -22
  57. package/cl.verimatrix.js +4 -4
  58. package/cl.vimond.js +6 -6
  59. package/cl.vr.js +14 -14
  60. package/cl.vtt.js +11 -11
  61. package/cl.youbora.js +12 -12
  62. package/package.json +1 -1
  63. package/typings.d.ts +3 -2
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 SR="clpp-freewheel",TR="clpp.freewheel.AdsManagerFactory",UR="freewheel",VR=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""}},WR=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Nf&&b.push("serverUrl");typeof a.profileId!==_.Nf&&b.push("profileId");typeof a.videoAssetId!==_.Nf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
- if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},YR=function(){return _.x(function*(){var a=new _.fu;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})},ZR=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,_.Uf,a.F.bind(a));a.g.on(a.m,_.Kf,a.C.bind(a))},bS=function(a){return _.x(function*(){a.B.length?($R(a),a.f=a.B.shift(),a.f.play()):(aS(a),yield a.m.a.play())})},aS=function(a){const b=a.m.cc(UR).xc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},$R=function(a){const b=a.m.cc(UR).xc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(SR),
4
- a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},cS=function(a){a.A.length?($R(a),a.f=a.A.shift(),a.f.play()):aS(a)},dS=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 _.E(b,d))},eS=class extends _.pu{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.ro(_.Gd,{id:SR}),this.f=_.ro(_.w,{"class":_.ed}),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 UR}xc(){return this.a}wg(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",eS);eS.prototype.getAdVideo=eS.prototype.wg;eS.prototype.getAdContainer=eS.prototype.xc;eS.Id=UR;eS.AD_CONTAINER_ID=SR;_.Yo(new class{create(){return new eS}});var Y=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}vb(){return"FreeWheel AdManager SDK"}wb(){return tv.freewheel.SDK.version}Cb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Nf?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var UR="clpp-freewheel",VR="clpp.freewheel.AdsManagerFactory",WR="freewheel",YR=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""}},ZR=function(a){const b=[];typeof a.networkId!==_.t&&b.push("networkId");typeof a.serverUrl!==_.Mf&&b.push("serverUrl");typeof a.profileId!==_.Mf&&b.push("profileId");typeof a.videoAssetId!==_.Mf&&typeof a.videoAssetId!==_.t&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},$R=function(){return _.x(function*(){var a=new _.hu;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})},aS=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,_.Tf,a.F.bind(a));a.g.on(a.m,_.Jf,a.C.bind(a))},dS=function(a){return _.x(function*(){a.B.length?(bS(a),a.f=a.B.shift(),a.f.play()):(cS(a),yield a.m.a.play())})},cS=function(a){const b=a.m.cc(WR).xc();b&&a.m.getSurface().hide(b);a.m.getSurface().showMediaElement()},bS=function(a){const b=a.m.cc(WR).xc();b&&(a.m.getSurface().show(b),a.m.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(UR),
4
+ a.m.isMuted()?a.setVolume(0):a.setVolume(a.m.getVolume()||1))},eS=function(a){a.A.length?(bS(a),a.f=a.A.shift(),a.f.play()):cS(a)},fS=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 _.E(b,d))},gS=class extends _.ru{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.ro(_.Fd,{id:UR}),this.f=_.ro(_.w,{"class":_.dd}),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 WR}xc(){return this.a}wg(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",gS);gS.prototype.getAdVideo=gS.prototype.wg;gS.prototype.getAdContainer=gS.prototype.xc;gS.Id=WR;gS.AD_CONTAINER_ID=UR;_.ap(new class{create(){return new gS}});var Y=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}vb(){return"FreeWheel AdManager SDK"}wb(){return tv.freewheel.SDK.version}Cb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.Mf?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
6
  0}getSkipTimeOffset(){return 0}gc(){return!1}Mb(){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():""}zb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}yb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}nb(){return 0}ab(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
7
  case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.ab()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Nb(){switch(this.ab()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Ob(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}Bb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
8
  Y.prototype.getWrapperCreativeIds=Y.prototype.getWrapperCreativeIds;Y.prototype.getWrapperAdSystems=Y.prototype.getWrapperAdSystems;Y.prototype.getWrapperAdIds=Y.prototype.getWrapperAdIds;Y.prototype.getSequenceLength=Y.prototype.Bb;Y.prototype.getPositionInSequence=Y.prototype.Ob;Y.prototype.getPodTimeOffset=Y.prototype.Nb;Y.prototype.getPodIndex=Y.prototype.getPodIndex;Y.prototype.getPodType=Y.prototype.ab;Y.prototype.getMediaBitrate=Y.prototype.nb;Y.prototype.getMediaHeight=Y.prototype.yb;
9
9
  Y.prototype.getMediaWidth=Y.prototype.zb;Y.prototype.getMediaUrl=Y.prototype.getMediaUrl;Y.prototype.getClickThroughUrl=Y.prototype.Mb;Y.prototype.isBumper=Y.prototype.gc;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.Cb;Y.prototype.getAdManagerVersion=Y.prototype.wb;Y.prototype.getAdManagerName=Y.prototype.vb;var fS=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()}})}Pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- fS.prototype.hasPostroll=fS.prototype.pb;fS.prototype.hasPreroll=fS.prototype.Pb;fS.prototype.getCuePoints=fS.prototype.getCuePoints;var gS=class{constructor(a){this.h=new _.R("clpp.freewheel.AdsManager");this.m=a;this.g=new _.hs;this.w=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.B=[];this.o=[];this.A=[];this.l=new _.an;this.j=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{WR(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!==_.Nf&&typeof b.siteSectionId!==
12
- _.t||a.a.setSiteSection(b.siteSectionId);const c=yield YR();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,VR(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);ZR(a);a.a.submitRequest();return a.l})}start(){const a=this;return _.x(function*(){yield bS(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.g.release();
14
- a.j&&(a.j.stop(),a.j=null);aS(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 _.E(_.uc,{adsTimeline:new fS(this.a)})),this.j=new _.du(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.cc(UR).f);else this.m.onError(new _.H(1,
15
- 9,10003,{errorType:0},void 0));this.l.resolve()}J(a){dS(this,_.cc,a);this.j.start()}I(a){this.f=null;a=a.slot;dS(this,_.dc);this.j.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:bS(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:aS(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:cS(this)}}G(a){const b=a.subType;this.h.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:dS(this,_.qc,a);dS(this,
16
- _.ic,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:dS(this,_.rc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:dS(this,_.hc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:dS(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:dS(this,_.sc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:dS(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:dS(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:dS(this,_.mc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:dS(this,
17
- _.oc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:dS(this,_.pc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:dS(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:dS(this,_.nc,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();$R(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Wn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Vn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Ln:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);cS(this);break;case _.Tn:case _.Sn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- gS.prototype.getPosition=gS.prototype.getPosition;gS.prototype.setVolume=gS.prototype.setVolume;gS.prototype.getVolume=gS.prototype.getVolume;gS.prototype.skip=gS.prototype.skip;gS.prototype.pause=gS.prototype.pause;gS.prototype.resume=gS.prototype.resume;gS.prototype.start=gS.prototype.start;var hS=class{constructor(){this.a=new _.R(TR)}name(){return TR}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 gS(a)}};hS.prototype.create=hS.prototype.create;hS.prototype.isSupported=hS.prototype.isSupported;hS.prototype.name=hS.prototype.name;_.oo(new hS);};f.call(g, window);
10
+ Y.prototype.getCreativeId=Y.prototype.getCreativeId;Y.prototype.getId=Y.prototype.getId;Y.prototype.getTechnology=Y.prototype.Cb;Y.prototype.getAdManagerVersion=Y.prototype.wb;Y.prototype.getAdManagerName=Y.prototype.vb;var hS=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()}})}Pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}pb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ hS.prototype.hasPostroll=hS.prototype.pb;hS.prototype.hasPreroll=hS.prototype.Pb;hS.prototype.getCuePoints=hS.prototype.getCuePoints;var iS=class{constructor(a){this.h=new _.R("clpp.freewheel.AdsManager");this.m=a;this.g=new _.ks;this.w=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.B=[];this.o=[];this.A=[];this.l=new _.an;this.j=null}load(){const a=this;return _.x(function*(){const b=a.m.getConfiguration().freewheel||{};try{ZR(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!==_.Mf&&typeof b.siteSectionId!==
12
+ _.t||a.a.setSiteSection(b.siteSectionId);const c=yield $R();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,YR(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Ce&&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);aS(a);a.a.submitRequest();return a.l})}start(){const a=this;return _.x(function*(){yield dS(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.g.release();
14
+ a.j&&(a.j.stop(),a.j=null);cS(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 _.E(_.tc,{adsTimeline:new hS(this.a)})),this.j=new _.fu(this.m.getSurface(),(b,c)=>this.a.resize(b,c),this.m.cc(WR).f);else this.m.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.l.resolve()}J(a){fS(this,_.bc,a);this.j.start()}I(a){this.f=null;a=a.slot;fS(this,_.cc);this.j.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:dS(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:cS(this);this.m.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:eS(this)}}G(a){const b=a.subType;this.h.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:fS(this,_.pc,a);fS(this,
16
+ _.hc,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:fS(this,_.qc,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:fS(this,_.gc,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:fS(this,_.jc,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:fS(this,_.rc,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:fS(this,_.fc,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:fS(this,_.ec,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:fS(this,_.lc,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:fS(this,
17
+ _.nc,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:fS(this,_.oc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:fS(this,_.dc,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:fS(this,_.mc,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();bS(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Wn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Vn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Ln:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);eS(this);break;case _.Tn:case _.Sn:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ iS.prototype.getPosition=iS.prototype.getPosition;iS.prototype.setVolume=iS.prototype.setVolume;iS.prototype.getVolume=iS.prototype.getVolume;iS.prototype.skip=iS.prototype.skip;iS.prototype.pause=iS.prototype.pause;iS.prototype.resume=iS.prototype.resume;iS.prototype.start=iS.prototype.start;var jS=class{constructor(){this.a=new _.R(VR)}name(){return VR}isSupported(a,b){return a.namespace()===_.jd?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new iS(a)}};jS.prototype.create=jS.prototype.create;jS.prototype.isSupported=jS.prototype.isSupported;jS.prototype.name=jS.prototype.name;_.oo(new jS);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,72 +1,72 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var oH="CLOSED-CAPTIONS",pH="Could not parse MP4 segment start time.",qH="DURATION",rH="EXT-X-STREAM-INF",sH="Failed to infer discontinuity number",tH="Guessing audio-only",uH="METHOD",vH="SAMPLE-AES-CTR",wH="SUBTITLES",xH="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",yH="application/vnd.apple.mpegurl",zH="sample",AH="whole-segment",BH=function(a,b){return _.I(a,b,void 0,{required:!0})},CH=function(a){if(1>a.a)throw _.tl();--a.a},DH=function(a){if(null!==a&&void 0!==
2
- a)return Number(a)},EH=function(a,b){return a.filter(c=>c.name===b)},FH=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.I(d,"VALUE"),f=_.I(d,"NAME"),g=_.I(d,"IMPORT"),h=_.I(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
3
- c.add(d)})},GH=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=BH(d,_.Kb);return c.includes(d)})},HH=function(a,b){return a.some(c=>c.name===b)},IH=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.F,4,4024,{missingTag:b});return a},JH=function(a){var b=IH(a,"EXT-X-TILES");if(!b)return{Rc:1,jd:1,durationPerTile:null};a=_.I(b,"LAYOUT")||"1x1";b=_.I(b,qH);a=_.XA(a);return{Rc:a.Rc,jd:a.jd,durationPerTile:b?Number(b):null}},KH=function(a,
4
- b,c){c=void 0===c?!0:c;a=new _.Lh(a);b=new _.Lh(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},LH=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)},MH=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of LH(c))b(d,c)})},NH=function(a){return a.some(b=>HH(b.$,_.Fa))},OH=function(a){return a.type===_.p||a.type===_.w},PH=function(a,b){const c=
5
- IH(a,_.Fa);if(b&&c)return _.Tb;a=IH(a,_.La);if(!a)return"LIVE";if(a.value===_.Tb)return _.Tb;if("EVENT"===a.value)return"EVENT";throw new _.H(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},QH=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.H(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},RH=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(_.F,
6
- 4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ua:d,ka:e}},SH=function(a,b){a=IH(a,_.Ba);return RH(a?a.value:null,b)},TH=function(a){a=IH(a,"EXTINF",{required:!0}).value.split(",");
7
- return{duration:Number(a[0]),title:a[1]||null}},UH=function(a,b){b=void 0===b?{}:b;const c={od:!1,gg:!1,hg:null,Kg:null,Bf:null};a=IH(a,_.Oa,{required:b.Ff});if(!a)return c;const d=e=>null==e?null:Number(e);c.od="YES"===_.I(a,"CAN-BLOCK-RELOAD");c.gg="YES"===_.I(a,"CAN-SKIP-DATERANGES");c.hg=d(_.I(a,"CAN-SKIP-UNTIL"));c.Kg=d(_.I(a,"HOLD-BACK"));c.Bf=d(_.I(a,"PART-HOLD-BACK",void 0,{required:b.Ff}));return c},VH=function(a,b,c){c=void 0===c?!1:c;a=_.I(a,"BYTERANGE");return RH(a,b,c)},XH=function(a,
8
- b){const c=SH(a.$,null);return new WH(0,0,0,()=>[a.a],c.ua,c.ka,0,b)},YH=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.Fi(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},ZH=function(a){let b=Infinity,c=Infinity;LH(a).filter(OH).forEach(d=>{{d=d.V;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}},$H=function(a){return a.map(b=>{({duration:b}=ZH(b));return b}).reduce((b,
9
- c)=>b+c,0)},aI=function(a){return(a.video?a.video.ya:"")+" - "+(a.audio?a.audio.ya:"")},bI=function(a,b,c,d){if(b===_.Tb)return{delay:0,mc:0};b=IH(a,_.Ja);if(c&&b){c=Number(BH(b,"PART-TARGET"));if(null!=d)return{delay:d,mc:c};({Bf:d}=UH(a,{Ff:!0}));return{delay:d,mc:c}}a=IH(a,_.Qa,{required:!0});a=Number(a.value);return null!=d?{delay:d,mc:a}:{delay:3*a,mc:a}},cI=function(a){const b=[];MH(a,c=>{b.push(c.Rg)});return{delay:Math.max(...b.map(c=>c.delay)),mc:Math.min(...b.map(c=>c.mc))}},eI=function(a){const b=
10
- new Map;a.forEach(c=>{var d=dI(c).groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},fI=function(a){const b=new Map;for(const c of a){a=_.I(c,_.cb);a=_.Zh(a||_.Xf);const d=BH(c,_.Va),e=BH(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},hI=function(a){a=a.audio.concat(a.video);for(const b of a)a=dI(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),gI(b,a)},iI=function(a,b){if(!a)return null;const c=a.ya;return b.find(d=>dI(d).ya===c)||null},jI=function(a){for(const b of a)if(b.startsWith("#EXT-")&&
11
- (a=_.Ki(0,b),_.Hs.has(a.name)))return 1;return 0},kI=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.F,4,4044,`Undefined variable '${d}'`);return c})},lI=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=kI(d.value,b)})})},mI=function(a,b,c){lI(a,c);b.forEach(d=>{d.a&&(d.a=kI(d.a,c));lI(d.$,c);lI(d.f,c)})},nI=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.I(e,"NAME"),g=_.I(e,"QUERYPARAM");if(f)g=BH(e,"VALUE"),c.set(f,
12
- g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},qI=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=oI(a,b[e]);d.push(f);if(f.name===rH){const g=b[e+1];if(!g)throw new _.H(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.Ii(_.Mb,g));e++}}b=EH(d,
13
- "EXT-X-DEFINE");FH(b);b=nI(b,c);a.a=b;mI(d,[],a.a);return new pI(c,0,d)},tI=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=oI(a,b[e]);if(_.Is.has(f.name))break;d.push(f);e++}b=rI(a,c,b.slice(e));e=b.V;d=d.concat(b.$);a=sI(a,d,c);mI(d,e,a);return new pI(c,1,d,b.V)},uI=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(_.F,4,4015);return 0===jI(b)?qI(a,b,c):tI(a,b,c)},oI=function(a,b){return _.Ki(a.f++,
14
- b)},rI=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=oI(a,h),_.Hs.has(h.name)||_.Ks.has(h.name)?d.push(h):_.Js.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ma&&"PART"===_.I(h,_.Kb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=KH(b,h.trim(),!1),e.push(new vI(h,f,g)),f=[],g=[])});0<g.length&&e.push(new vI(null,f,g));return{V:e,$:d}},sI=function(a,b,c){b=EH(b,"EXT-X-DEFINE");FH(b);const d=nI(b,c);b.map(e=>_.I(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=
15
- a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},wI=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},xI=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},yI=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]<<
16
- 21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.F,4,4030);}xI(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}xI(a,e)||d();
17
- e+=10;e+=f}while(e<a.byteLength);return d()},zI=function(a,b){let c=null,d=0;try{(new _.Jl).M(_.ze,_.Cl).M(_.Vf,_.Cl).M(_.ue,_.Cl).ba("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 _.hu.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030,pH,c);let e=0,f=!1;try{(new _.Jl).M("moof",_.Cl).M("traf",_.Cl).ba("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>=
18
- 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(_.F,4,4030,pH,c);return e},AI=function(a){for(;a.getPosition()<a.Da()-1;){const b=a.getPosition();if(71===_.ul(a))return CH(a),b}return-1},BI=function(a){function b(){d.seek(e+188);f=_.ul(d);71!==f&&(d.seek(e+192),f=_.ul(d));71!==f&&(d.seek(e+204),f=_.ul(d));71!==f&&c();
19
- CH(d)}function c(){throw new _.H(_.F,4,4030);}const d=new _.vm(new DataView(a),!1);let e=0,f=0;e=AI(d);0>e&&(_.hu.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.ul(d);71!==f&&c();a=_.vl(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.ul(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.ul(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.ul(d)>>6;0!==a&&1!==a||c();0===_.ul(d)&&c();a=_.ul(d);const g=_.vl(d),h=_.vl(d);return(1073741824*
20
- ((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},EI=function(a){const b=CI(a),c=DI(a);a.forEach(d=>{const e=d.V,f=e.findIndex(h=>h.ga===b);let g=e.findIndex(h=>h.ga===c+1);-1===g&&(g=e.length);d.V=e.slice(f,g)})},DI=function(a){a=a.map(b=>b.V[b.V.length-1].ga);return Math.min(...a)},CI=function(a){a=a.map(b=>b.V[0].ga);return Math.max(...a)},HI=function(a){var b=BH(a,uH);if(!FI.includes(b))return GI.error("PlayReady in HLS is only supported with [",FI.join(", "),"], not",b),null;a=BH(a,_.Mb);b=_.Qr(a);
21
- a=null;b=_.J(b.data);try{a=_.GA(_.Cm(b))}catch(c){a=b}return _.TA(_.xd,[{initDataType:_.$c,initData:a}],"")},JI=function(a){if(0===a.length)return II();if(a.some(c=>c.type===AH)||a.every(c=>c.type===_.Ce))return a[0];a=a.filter(c=>c.type===zH);const b=_.Bh(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:zH,drmInfos:b}},MI=function(a){a=KI(a);if(a.some(b=>LI(b))&&1<a.length)throw new _.H(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");
22
- },LI=function(a){return EH(a.$,_.Ga).some(b=>"AES-128"===_.I(b,uH))},OI=function(a,b,c){return KI(a).map(d=>NI(d.$,b,c))},PI=function(a){return a.filter(b=>HH(b.$,_.Ga)).length},KI=function(a){return a.filter(b=>HH(b.$,_.Ga))},NI=function(a,b,c){a=EH(a,_.Ga);if(0===a.length)return null;var d=BH(a[0],uH);if(1===a.length){if("NONE"===d)return II();if("AES-128"===d)return a=a[0],d=_.I(a,"IV",""),{type:AH,keyInfo:{method:"AES-128",url:KH(b,BH(a,_.Mb)),iv:d?_.Ci((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=
23
- a.map(e=>BH(e,uH));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===vH))throw QI.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.I(e,"KEYFORMAT","identity");{const g=RI[f]||null;e=g?g(e,c):null}e||QI.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||
24
- null,type:zH,drmInfos:b}},II=function(){return{type:_.Ce,keyInfo:null,drmInfos:[],keyId:null}},SI=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.wB(b.Oa(),b.ua,b.ua+2048-1,a.a.attemptParameters);e.type=2;const f=_.wB(b.Oa(),b.ua,b.ka,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.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.",
25
- 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 _.H(_.F,4,4030,"Failed to fetch the media segment.");}}})},TI=function(a,b,c,d,e,f){return _.x(function*(){a.h.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Ic||d===_.Hc)return 0;if(d===_.Gc){var g=yield SI(a,c,f);const h=_.J(g.data);return xI(h)?yI(h):BI(g.data)}if(d===_.ig||d===_.Jc)return g=[SI(a,c,f)],b&&g.push(SI(a,b,!0)),g=yield Promise.all(g),
26
- zI(g[0].data,(g[1]||g[0]).data);if(d===_.hg)return g=yield SI(a,c,f),BI(g.data);if(!_.Pp(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.F,4,4030);})},UI=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},gI=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},dI=function(a){return a.streams[0]},VI=function(a,b){a.streams.forEach(c=>{c.Md=b})},WI=function(a,b){a.streams.forEach(c=>{c.width=b})},XI=function(a,b){a.streams.forEach(c=>{c.height=b})},
27
- YI=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},ZI=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},$I=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},aJ=function(a,b){const c=new Set(a.map(d=>d.ga));return b.filter(d=>!c.has(d.ga))},dJ=function(a,b){for(;a[0].ga<b[0].ga;)a.splice(0,1);var c=a[0];let d=b[0];bJ(c,d)||cJ(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&!bJ(c,d)&&cJ(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},eJ=function(a,b){const c=a[a.length-1];var d=b.findIndex(f=>
28
- f.ga===c.ga);const e=b[d];bJ(c,e)||cJ(c,e);for(d+=1;d<b.length;d++)a.push(b[d])},jJ=function(a,b,c,d,e){var f=b[0].length();f=wI(f).map(g=>{var h=$I(b,g)||[];const k=UI(c,g)||[];g=UI(d,g)||[];{const l=[...fJ(h),...k,...g].filter(Boolean);gJ(l);const {ga:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ga:m}}return h});e&&hJ(f[0]);iJ(f);return f},fJ=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},
29
- hJ=function(a){const b=fJ(a.variants)[0].V[0].xa;a.startTime+=b;a.endTime+=b},iJ=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},bJ=function(a,b){return a.startTime===b.startTime&&a.endTime===b.endTime},cJ=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;kJ(a.variants,b.variants);lJ(LH(a),LH(b))},kJ=function(a,b){const c=new Map(a.map(d=>[aI(d),d]));b.forEach(d=>{c.get(aI(d)).drmInfos=
30
- d.drmInfos})},lJ=function(a,b){const c=new Map(a.map(d=>[d.ya,d]));b.forEach(d=>{const e=c.get(d.ya);e.V=d.V;e.segmentIndex.replace(d.V);e.Cc=d.Cc;e.ge=d.ge;e.duration=d.duration;e.bf=d.bf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},gJ=function(a){const b=mJ(a);a.forEach(c=>{_.sB(c.segmentIndex,b);c.duration=b;c.ge=c.Cc+b})},mJ=function(a){let b=Infinity;a.filter(OH).forEach(c=>{b=Math.min(b,c.duration)});return b},nJ=function(a,b){MH(b,(c,d)=>{_.FB(a,c.V,d.startTime)});_.xB(a.a,
31
- b[0].startTime,b[b.length-1].endTime)},oJ=function(a){return null===a.j?[]:[a.j.audio,a.j.video].filter(b=>b).map(b=>b.ya)},pJ=function(a,b){return _.x(function*(){var c=_.Pi([b],a.a.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.li(c.data)}catch(e){throw new _.H(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},uJ=function(a,b){return _.x(function*(){var c=qJ(a,b,a.w,"");if(1===c.type){c=_.Ds(c.V[0].a)||"";c=null!=_.Cs.video[c]?_.w:null!=_.Cs.audio[c]?
32
- _.p:null;var d="";c===_.w?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=[];q.push(new _.Ii(_.ma,"0"));q.push(new _.Ii(_.Mb,e));d.length&&q.push(new _.Ii(_.pa,d));f.push(new _.Ji(c.f++,rH,q));c=new pI(e,0,f)}}d=c.$;c=EH(d,"EXT-X-MEDIA");e=EH(d,rH);d=EH(d,"EXT-X-IMAGE-STREAM-INF");c={Bc:{bg:GH(c,["AUDIO",_.Sb]),closedCaptions:GH(c,oH),sh:GH(c,wH)},kd:e,be:d};const {periods:g,Ef:h,Kf:k}=yield rJ(a,c);if(!a.D)throw new _.H(_.F,7,7001);e=cI(g[0]);
33
- sJ(a,g);c=!0;d=null;f=0;tJ(a)||(c=!1,d=0,f=e.delay);d=new _.aH(a.a.timeline||{},d,f,!0,void 0,!!a.a.lowLatencyMode);_.BB(d,c);nJ(d,g);h&&_.AB(d,h);c=d;if(!tJ(a)){a.C=e.mc;e=0;for(var l of a.f.values())e=Math.max(e,l.streams[0].Cc);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.Cc?(a.h.debug("Offset applied to",e.type),e.segmentIndex.offset(l)):
34
- a.h.debug("Offset NOT applied to",e.type)}}m=$H(g);"LIVE"===a.l||"EVENT"===a.l?(m=Math.max(m,c.H),isNaN(a.a.availabilityWindowOverride)||(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,Ta:n.Ta,value:"",startTime:n.startTime,endTime:n.endTime,id:n.id,type:_.oh,eventElement:null});n={presentationTimeline:c,adaptedPeriods:[...g],periods:g,minBufferTime:0};a.h.debug("HLS playlist parsed",
35
- n);return n})},wJ=function(a,b){return Promise.all(b.map(c=>vJ(a,c)))},yJ=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!tJ(a),f=IH(c.$,_.Ea);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].V,f=f[f.length-1].ga):f=0;if(e&&0<f)try{{const k=IH(c.$,_.Ia);if(!k)throw xJ.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(sH);const l=Number(k.value),m=d.find(l);if(!m)throw xJ.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
36
- ` (segment position = ${l})`),Error(sH);var h=m.ga}g=h;break a}catch(k){throw new _.H(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.V||[];for(const k of c)HH(k.$,_.Da)&&g++,k.ga=g});EI(b)},BJ=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,cg:e}=yield zJ(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=iI(g.audio,e),k=iI(g.video,e);g=AJ(a,h,k,g.bandwidth);
37
- if(!g)throw new _.H(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Wh:k?dI(k).ya:void 0,audio:h?dI(h).ya:void 0});return g});return jJ(a.D.configurationId,f,c,d,!0)})},sJ=function(a,b){tJ(a)||2!==a.a.timeline.version||(a.G||(a.G=b[0].startTime),_.dD(b,-a.G))},CJ=function(a,b,c){a.l=_.Tb;_.BB(b,!0);b.f=c[c.length-1].endTime},qJ=function(a,b,c,d){a=uI(a.K,b,c);a.a=d;DJ(a);return a},rJ=function(a,b){return _.x(function*(){var c=fI(b.Bc.closedCaptions),d=EJ(a,b.kd),e=yield FJ(a,
38
- b);const f=Object.values(e).flat().map(h=>h.playlist);yJ(a,f);var g=yield GJ(a,e.Te,d);c=yield HJ(a,e.kd,g,c);d=yield IJ(a,e.rh,d);g=yield JJ(a,e.be);e=KJ(a,e);c=jJ(a.D.configurationId,c,d,g,!tJ(a));a.D.filterAllPeriods(c);return tJ(a)?(d=null,null!=e&&(d=LJ(f,e)),{periods:c,Ef:e,Kf:d}):{periods:c,Ef:e,Kf:null}})},zJ=function(a,b){return _.x(function*(){const c=g=>dI(g.stream).type===_.w||dI(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=dI(h.stream);k={language:k.language,
39
- 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.ya,Kd:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return MJ(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);NJ(a,d.concat(f));e=f.filter(g=>dI(g).type===_.BA);f=f.filter(g=>dI(g).type===_.be);return{textStreams:e,thumbStreams:f,cg:d}})},AJ=function(a,
40
- 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?_.aB(k.drmInfos,l.drmInfos)?_.$A(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:_.Xf,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new OJ(e)},MJ=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,
41
- e=b.type,f=b.Xc,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,q=b.closedCaptions,u=b.Kd,v=_.Zh(f||_.Xf);if(1!==c.type)throw new _.H(_.F,4,4017);var y=PH(c.$,null==a.o);a.l=y;const B=bI(c.$,y,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);y=yield PJ(a,c,e,d);const D=a.a.lowLatencyMode?_.qA:_.pA;let M=k;e!==_.G||k||(M=_.BA);const {od:da}=UH(c.$);k=y.map(ub=>{const Ub=ub.V,pd=ub.ng,fg=ub.mimeType;ub=ub.ga;const Wa=Ub[0].startTime,ke=Ub[Ub.length-1].endTime,
42
- Oc=ke-Wa,ea=new _.bH(Ub),$a=Ub[0].initSegment||null;return{id:_.fH++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ea.find.bind(ea),getSegmentReference:ea.get.bind(ea),adjustSegmentDurations:ea.f.bind(ea),getDuration:ea.getDuration.bind(ea),segmentIndex:ea,segmentLookupStrategy:D,initSegmentReference:$a,mimeType:fg,codecs:d,kind:M,bf:pd.type,encrypted:pd.type===zH,keyId:pd.keyId,language:v,originalLanguage:f||_.Xf,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
43
- frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:pd.keyInfo,V:Ub,drmInfos:pd.drmInfos,ga:ub,ya:c.a,Md:c.f,Cc:Wa,ge:ke,duration:Oc,od:da,groupId:g,Rg:B}});return new QJ(k)})},NJ=function(a,b){b.forEach(c=>{a.f.a.set(dI(c).ya,c)})},EJ=function(a,b){const c=new Map;for(const f of b){var d=_.I(f,"AUDIO");b=_.I(f,_.Sb);var e=_.I(f,wH);const g=RJ(a,f);if(e){const h=_.wj(_.G,g);c.set(e,h);e=g.indexOf(h);
44
- -1<e&&g.splice(e,1)}d&&(e=SJ(_.p,g),c.set(d,e));b&&(d=SJ(_.w,g),c.set(b,d))}return c},FJ=function(a,b){return _.x(function*(){const c=yield Promise.all([TJ(a,b.Bc.bg),TJ(a,b.Bc.sh),TJ(a,b.kd),TJ(a,b.be)]),[d,e,f,g]=c;return{Te:d,rh:e,kd:f,be:g}})},GJ=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[UJ(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>UJ(a,e,c)));d=yield Promise.all(d);return eI(d)})},HJ=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];
45
- let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(BH(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield VJ(a,h,c,d,e);f=f.map(k=>VJ(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.QA,[])})},IJ=function(a,b,c){return Promise.all(b.map(d=>UJ(a,d,c)))},JJ=function(a,b){return Promise.all(b.map(c=>WJ(a,c)))},KJ=function(a,b){b=[...b.kd,...b.Te].map(d=>d.playlist).flatMap(d=>d.V[0].$);b=IH(b,_.Na);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?
46
- (a.h.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},tJ=function(a){return a.l===_.Tb},LJ=function(a,b){return(a=a.find(c=>null!==IH(c.$,_.Ca)))?a.$.filter(c=>c.name===_.Ca).map(c=>{a:{var d=_.I(c,"ID"),e=_.I(c,"START-DATE");if(null===d||null===e)_.Gs.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=
47
- DH(_.I(c,qH));void 0!==g&&0<=g&&(d.duration=g);var h=DH(_.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==q)var m=null;else{f={};for(m of q)m.name.startsWith("X-")&&(f[m.name]=m.value);m=_.Pg(f)?f:null}}m=m||{};if(k===_.wd){f=c.attributes;if(null==f)var n=null;else{k={};for(n of f)switch(n.name){case _.$b:k[_.$b]=
48
- n.value;break;case _.Zb:k[_.Zb]=n.value;break;case _.bc:k[_.bc]=DH(n.value);break;case _.ac:k[_.ac]=DH(n.value);break;case "X-SNAP":k["X-SNAP"]=n.value.split(",");break;case "X-RESTRICT":k["X-SNAP"]=n.value.split(",")}k[_.$b]&&k[_.Zb]||!k[_.$b]&&!k[_.Zb]?(_.Gs.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),n=null):n=_.Pg(k)?k:null}if(null===n){_.Gs.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",c);c=null;break a}m=Object.assign(m,n)}_.Pg(m)&&
49
- (d.Ta=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},TJ=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield XJ(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},vJ=function(a,b){return _.x(function*(){var c=new _.Lh(dI(b).Md);if(a.a.lowLatencyMode&&dI(b).od){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={Ug:d.position,$g:e&&0<e.length?
50
- f:null}}else d=null;if(e=d)d=e.Ug,e=e.$g,f=_.ij(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=_.hj(f,!0),d=new _.Sh(d),_.Oh(c,d)}const {response:g,text:h}=yield pJ(a,c.toString());c=dI(b).ya;d=dI(b).Md;e=g.uri;d!==e&&(d=e,VI(b,d));c=qJ(a,h,d,c);return{stream:b,playlist:c}})},RJ=function(a,b){var c=_.I(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.fB(e),b.has(c)?
51
- a.h.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},SJ=function(a,b){if(1===b.length)return b[0];a=_.wj(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},UJ=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return YJ(a,e.a,()=>_.x(function*(){const f=BH(d,_.Va),g=QH(BH(d,_.Kb));var h=BH(d,_.Kb).toUpperCase();if(QH(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.BA;h===oH&&(l=_.lA);k&&(l=
52
- _.Wd);h=l}k=c.get(f)||"";l=_.I(d,_.cb);const m=_.I(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.I(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.I(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield MJ(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})}))})},WJ=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return YJ(a,d.a,()=>
53
- _.x(function*(){var e=_.I(c,_.pa)||"jpg",f=_.I(c,_.cb);const g=_.I(c,"NAME");e=yield MJ(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=_.I(c,_.ma))&&ZI(e,Number(f));return e}))})},VJ=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(BH(f,_.ma));if(null!=f.getAttribute("FRAME-RATE")||null!=f.getAttribute(_.Bb)){var h=_.I(f,"FRAME-RATE");f=_.I(f,_.Bb);var [k,l]=f?f.split("x"):[null,null];
54
- h={frameRate:DH(h),width:DH(k),height:DH(l)}}else h=null;if(f=yield ZJ(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?dI(q).ya:"")+" - "+(n?dI(n).ya:"");if(e.has(m)){a.h.debug("Skipping variant which only differs in text streams.");continue}const u=AJ(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})},ZJ=function(a,b,c,d,e){return _.x(function*(){var f=
55
- b.tag,g=b.playlist;let h=RJ(a,f);var k=_.I(f,"AUDIO"),l=_.I(f,_.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.ya===n);l=_.wj(_.w,h);l=c||l;1!==h.length||l?!m.length&&1<h.length?(a.h.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.h.debug(tH),g=_.p,f=!0):k.video.length?(a.h.debug(tH),g=_.p):(a.h.debug("Guessing video-only"),g=_.w):(g=_.p,a.h.debug(tH));
56
- l=null;f||(l=yield $J(a,b,h,g,e,c));if(null==l)return null;k[g]=[l];g===_.p&&c&&m.forEach(q=>{WI(q,c.width);XI(q,c.height);YI(q,c.frameRate)});hI(k);return k})},$J=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return YJ(a,h.a,()=>_.x(function*(){var k=_.I(g,oH);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=SJ(d,c);return yield MJ(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})}))})},
57
- YJ=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},PJ=function(a,b,c,d){return _.x(function*(){var e=b.a,f=b.V;var g=void 0===g?0:g;var h=(h=IH(b.$,_.Ia))?Number(h.value):g;g=[];!tJ(a)&&MI(f);e=yield aK(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)HH(m.$,_.Da)&&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 bK(a,b.f,k,h,e,c,d,g[g.length-
58
- 1]||null,f.length),g.push(l),h+=k.length;cK(g);return g})},XJ=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.I(b,_.Kb)===wH;c=_.I(b,_.Mb,void 0,{required:c});if(!c)return null;const d=KH(a.w,c),{response:e,text:f}=yield pJ(a,d);return qJ(a,f,e.uri,c)})},DJ=function(a){1===a.type&&a.V.forEach((b,c)=>{if(HH(b.$,_.Ha)&&!HH(b.$,_.Da)&&0<c)throw new _.H(_.F,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},cK=function(a){if(1<
59
- (new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},dK=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.I(c,_.Mb))||null).map(b=>_.Ds(b));if(1<(new Set(a)).size)throw new _.H(_.F,4,4044,"Unexpected change in file format.");},eK=function(a,b,c){a=EH(a.$,_.Ha);if(1<a.length)throw new _.H(_.F,4,4020);a=a[0];if(!a)return null;const d=BH(a,_.Mb),e=KH(b,d);b=VH(a,null,!0);return new _.YG(()=>
60
- [e],b.ua,b.ka,c)},fK=function(a,b,c,d,e,f,g){const h=[];for(const q of _.YA(b.f)){b=q.pf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.I(u,qH));n=m+n;k=VH(u,k?null:l.ka,k);l=_.I(u,_.Mb);const v=(l=KH(g,l))?[l]:[];m=new WH(c,m,n,()=>v,k.ua,k.ka,e,f,!1,null,null,null,null);if("YES"===_.I(u,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},gK=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.$;var q=c.a;const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ua:0,
61
- ka:null};let y=null;u?({duration:c}=TH(n),a=e+c,q=SH(n,b?b.ka:null)):(b=fK(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.be?JH(n):null;d=new WH(d,e,a,()=>v,q.ua,q.ka,f,g,!1,null,h?h.Rc:null,h?h.jd:null,h?h.durationPerTile:null,y);d.ga=l;d.initSegment=m||void 0;return d},aK=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.B)return a.B;if(!tJ(a)&&a.o)try{var k=a.f.get(c);var l=k?k.find(e)||null:null;if(!l)throw new _.H(_.F,4,4030,"Segment not found in pervious playlist update.");
62
- var m=l.startTime+l.xa;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].V,m=m[m.length-1],a.h.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].V[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield hK(a,f,g,h);k=NI(h.$,a.w,m)||II();l=eK(h,b,k.keyInfo);k=YH(k.keyInfo,e);h=yield iK(a,
63
- l,h,k,m,g);a.h.debug(`Setting playlist start time to ${h}.`);return a.B=h})},bK=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;dK(c);const n=yield hK(a,f,g,l);var q=a.w,u=h?h.Qg:null;var v=1===k;if(c.slice(1).some(LI))throw new _.H(_.F,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.");
64
- if(HH(c[0].$,_.Ga)||null===u)if((u=NI(c[0].$,q,n))&&u.type===AH){if(1<PI(c))throw new _.H(_.F,4,4046,xH+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=OI(c,q,n),v=0===v.length?[II()]:v;else if(q=OI(c,q,n),u.type===_.Ce||u.type===zH)v=[u,...q];else{if(0<PI(c))throw new _.H(_.F,4,4046,xH+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=JI(q);u=eK(l,b,q.keyInfo)||(h?h.Lg:null);var y=YH(q.keyInfo,d);const B=l.ga;l=m?e:yield jK(a,B,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];
65
- const M=m[m.length-1]||null,da=0===y?0:M.endTime,ub=d+y,Ub=YH(q.keyInfo,ub);(D=gK(a,M,D,ub,da,l,Ub,f,b,B,u))&&m.push(D)}return{V:m,ng:q,Qg:v,mimeType:n,endTime:m[m.length-1].endTime,ga:B,Lg:u}})},hK=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=IH(d.$,_.Ha);f=f?BH(f,_.Mb):null;return kK(a,b,c,e,f)})},iK=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=XH(c,d);return TI(a.L,b,g,e,f,null!=d)})},jK=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.H.has(b))return a.H.get(b);
66
- const k=yield iK(a,c,d,f,g,h);a.h.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.H.set(b,k);return k})},kK=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.zj(f,b,c);if(g)return g;g=_.Pi([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.H(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},pI=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.F,4,
67
- 4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.$=c;this.V=1===b?d:null}},vI=class{constructor(a,b,c){c=void 0===c?[]:c;this.$=b;this.a=a;this.f=c;this.ga=-1}},WH=class extends _.SB{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:
68
- q,u);this.initSegment=void 0;this.ga=0}},lK=class{constructor(){this.f=0;this.a=new Map}},mK=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()}},xJ=new _.R("clpp.hls.DiscontinuityUtils");var RI={"com.apple.streamingkeydelivery":function(a,b){if(b===_.hg)throw new _.H(_.F,4,4041);if(BH(a,uH)===vH)throw new _.H(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.TA(_.vd,[{initDataType:_.Gf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":HI,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":HI,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=BH(a,uH);if(!FI.includes(b))return GI.error("Widevine in HLS is only supported with [",
69
- FI.join(", "),"], not",b),null;b=BH(a,_.Mb);b=_.Qr(b);b=_.J(b.data);b=_.TA(_.zd,[{initDataType:_.$c,initData:b}],"");if(a=_.I(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},FI=["SAMPLE-AES",vH],GI=new _.R("clpp.hls.DrmParser");var QI=new _.R("clpp.hls.EncryptionUtils");var nK=class{constructor(a){this.h=new _.R("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.Mi()}}};var QJ=class{constructor(a){this.streams=a}length(){return this.streams.length}find(a){const b=this.streams.find(c=>{c=c.V;return c[0].position<=a&&a<=c[c.length-1].position});return null==b?null:b.V.find(c=>c.position===a)||null}};var OJ=class{constructor(a){this.a=a}length(){return this.a.length}};var oK=class{constructor(){this.a=this.D=null;this.N=1;this.f=new mK;this.w="";this.K=new lK;this.C=0;this.j=null;this.g=new _.Qj(()=>{this.Eb()});this.l=_.Tb;this.o=null;this.A=new _.Ls;this.B=null;this.h=new _.R("clpp.hls.HlsParser");this.H=new Map;this.L=new nK(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 _.x(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,
70
- text:e}=yield pJ(c,a);c.w=d.uri;const f=yield uJ(c,e);c.o=f;const g=c.C;c.g&&0<g&&c.g.fa(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 _.x(function*(){const b=a.o;if(!tJ(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=oJ(a);
71
- d=d.filter(g=>f.includes(dI(g).ya))}var e=yield wJ(a,d);d=e.map(f=>f.playlist);yJ(a,d);e=yield BJ(a,e);aJ(b.periods,e).forEach(f=>{a.D.filterNewPeriod(f)});sJ(a,e);dJ(b.periods,e);eJ(b.adaptedPeriods,e);nJ(c,e);if(d=NH(d))!0!==a.a.keepTimelineLive&&CJ(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())}})}Eb(){const a=this;return _.x(function*(){a.h.debug(_.gA);if(a.D)try{yield a.update(),a.g&&0<a.C&&a.g.fa(a.C)}catch(b){if(!(b instanceof
72
- _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.g&&a.g.fa(.1))}})}F(a){if(!this.A)throw new _.H(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Wi(this.A,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Nt{f(){_.qr.m3u8=oK;_.or[_.Lk]=oK;_.or[yH]=oK}a(){_.qC("m3u8");_.rC(_.Lk);_.rC(yH)}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 qH="CLOSED-CAPTIONS",rH="Could not parse MP4 segment start time.",sH="DURATION",tH="EXT-X-STREAM-INF",uH="Failed to infer discontinuity number",vH="Guessing audio-only",wH="METHOD",xH="SAMPLE-AES-CTR",yH="SUBTITLES",zH="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",AH="application/vnd.apple.mpegurl",BH="sample",CH="whole-segment",DH=function(a,b){return _.I(a,b,void 0,{required:!0})},EH=function(a){if(1>a.a)throw _.tl();--a.a},FH=function(a){if(null!==a&&void 0!==
2
+ a)return Number(a)},GH=function(a,b){return a.filter(c=>c.name===b)},HH=function(a){const b=/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.I(d,"VALUE"),f=_.I(d,"NAME"),g=_.I(d,"IMPORT"),h=_.I(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.H(_.F,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.H(_.F,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);
3
+ c.add(d)})},IH=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=DH(d,_.Jb);return c.includes(d)})},JH=function(a,b){return a.some(c=>c.name===b)},KH=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.F,4,4024,{missingTag:b});return a},LH=function(a){var b=KH(a,"EXT-X-TILES");if(!b)return{Rc:1,jd:1,durationPerTile:null};a=_.I(b,"LAYOUT")||"1x1";b=_.I(b,sH);a=_.ZA(a);return{Rc:a.Rc,jd:a.jd,durationPerTile:b?Number(b):null}},MH=function(a,
4
+ b,c){c=void 0===c?!0:c;a=new _.Lh(a);b=new _.Lh(b);b=a.resolve(b).toString();return c?b:decodeURI(b)},NH=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)},OH=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of NH(c))b(d,c)})},PH=function(a){return a.some(b=>JH(b.$,_.Fa))},QH=function(a){return a.type===_.p||a.type===_.w},RH=function(a,b){const c=
5
+ KH(a,_.Fa);if(b&&c)return _.Sb;a=KH(a,_.La);if(!a)return"LIVE";if(a.value===_.Sb)return _.Sb;if("EVENT"===a.value)return"EVENT";throw new _.H(_.F,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);},SH=function(a){a={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.G,"CLOSED-CAPTIONS":_.G}[a.toUpperCase()];if(!a)throw new _.H(_.F,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},TH=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(_.F,
6
+ 4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.F,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.F,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.F,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ua:d,ka:e}},UH=function(a,b){a=KH(a,_.Ba);return TH(a?a.value:null,b)},VH=function(a){a=KH(a,"EXTINF",{required:!0}).value.split(",");
7
+ return{duration:Number(a[0]),title:a[1]||null}},WH=function(a,b){b=void 0===b?{}:b;const c={od:!1,gg:!1,hg:null,Kg:null,Bf:null};a=KH(a,_.Oa,{required:b.Ff});if(!a)return c;const d=e=>null==e?null:Number(e);c.od="YES"===_.I(a,"CAN-BLOCK-RELOAD");c.gg="YES"===_.I(a,"CAN-SKIP-DATERANGES");c.hg=d(_.I(a,"CAN-SKIP-UNTIL"));c.Kg=d(_.I(a,"HOLD-BACK"));c.Bf=d(_.I(a,"PART-HOLD-BACK",void 0,{required:b.Ff}));return c},XH=function(a,b,c){c=void 0===c?!1:c;a=_.I(a,"BYTERANGE");return TH(a,b,c)},ZH=function(a,
8
+ b){const c=UH(a.$,null);return new YH(0,0,0,()=>[a.a],c.ua,c.ka,0,b)},$H=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.Fi(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},aI=function(a){let b=Infinity,c=Infinity;NH(a).filter(QH).forEach(d=>{{d=d.V;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}},bI=function(a){return a.map(b=>{({duration:b}=aI(b));return b}).reduce((b,
9
+ c)=>b+c,0)},cI=function(a){return(a.video?a.video.ya:"")+" - "+(a.audio?a.audio.ya:"")},dI=function(a,b,c,d){if(b===_.Sb)return{delay:0,mc:0};b=KH(a,_.Ja);if(c&&b){c=Number(DH(b,"PART-TARGET"));if(null!=d)return{delay:d,mc:c};({Bf:d}=WH(a,{Ff:!0}));return{delay:d,mc:c}}a=KH(a,_.Qa,{required:!0});a=Number(a.value);return null!=d?{delay:d,mc:a}:{delay:3*a,mc:a}},eI=function(a){const b=[];OH(a,c=>{b.push(c.Rg)});return{delay:Math.max(...b.map(c=>c.delay)),mc:Math.min(...b.map(c=>c.mc))}},gI=function(a){const b=
10
+ new Map;a.forEach(c=>{var d=fI(c).groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},hI=function(a){const b=new Map;for(const c of a){a=_.I(c,_.cb);a=_.Zh(a||_.Xf);const d=DH(c,_.Va),e=DH(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},jI=function(a){a=a.audio.concat(a.video);for(const b of a)a=fI(b).codecs.split(",").filter(c=>"mp4a.40.34"!==c),iI(b,a)},kI=function(a,b){if(!a)return null;const c=a.ya;return b.find(d=>fI(d).ya===c)||null},lI=function(a){for(const b of a)if(b.startsWith("#EXT-")&&
11
+ (a=_.Ki(0,b),_.Ks.has(a.name)))return 1;return 0},mI=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.H(_.F,4,4044,`Undefined variable '${d}'`);return c})},nI=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=mI(d.value,b)})})},oI=function(a,b,c){nI(a,c);b.forEach(d=>{d.a&&(d.a=mI(d.a,c));nI(d.$,c);nI(d.f,c)})},pI=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.I(e,"NAME"),g=_.I(e,"QUERYPARAM");if(f)g=DH(e,"VALUE"),c.set(f,
12
+ g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.H(_.F,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.H(_.F,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},sI=function(a,b,c){const d=[];for(let e=1;e<b.length;e++){const f=qI(a,b[e]);d.push(f);if(f.name===tH){const g=b[e+1];if(!g)throw new _.H(_.F,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.Ii(_.Lb,g));e++}}b=GH(d,
13
+ "EXT-X-DEFINE");HH(b);b=pI(b,c);a.a=b;oI(d,[],a.a);return new rI(c,0,d)},vI=function(a,b,c){let d=[];for(var e=1;e<b.length;){const f=qI(a,b[e]);if(_.Ls.has(f.name))break;d.push(f);e++}b=tI(a,c,b.slice(e));e=b.V;d=d.concat(b.$);a=uI(a,d,c);oI(d,e,a);return new rI(c,1,d,b.V)},wI=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(_.F,4,4015);return 0===lI(b)?sI(a,b,c):vI(a,b,c)},qI=function(a,b){return _.Ki(a.f++,
14
+ b)},tI=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=qI(a,h),_.Ks.has(h.name)||_.Ns.has(h.name)?d.push(h):_.Ms.has(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===_.Ma&&"PART"===_.I(h,_.Jb)&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=MH(b,h.trim(),!1),e.push(new xI(h,f,g)),f=[],g=[])});0<g.length&&e.push(new xI(null,f,g));return{V:e,$:d}},uI=function(a,b,c){b=GH(b,"EXT-X-DEFINE");HH(b);const d=pI(b,c);b.map(e=>_.I(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=
15
+ a.a.get(e);if(null==f)throw new _.H(_.F,4,4044,`Cannot import variable '${e}' as it is not defined `+"in the master playlist");d.set(e,f)});return d},yI=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},zI=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},AI=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]<<
16
+ 21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.F,4,4030);}zI(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}zI(a,e)||d();
17
+ e+=10;e+=f}while(e<a.byteLength);return d()},BI=function(a,b){let c=null,d=0;try{(new _.Jl).M(_.ye,_.Cl).M(_.Uf,_.Cl).M(_.te,_.Cl).ba("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 _.ju.error("Unable to find timescale in init segment!"),new _.H(_.F,4,4030,rH,c);let e=0,f=!1;try{(new _.Jl).M("moof",_.Cl).M("traf",_.Cl).ba("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>=
18
+ 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(_.F,4,4030,rH,c);return e},CI=function(a){for(;a.getPosition()<a.Da()-1;){const b=a.getPosition();if(71===_.ul(a))return EH(a),b}return-1},DI=function(a){function b(){d.seek(e+188);f=_.ul(d);71!==f&&(d.seek(e+192),f=_.ul(d));71!==f&&(d.seek(e+204),f=_.ul(d));71!==f&&c();
19
+ EH(d)}function c(){throw new _.H(_.F,4,4030);}const d=new _.vm(new DataView(a),!1);let e=0,f=0;e=CI(d);0>e&&(_.ju.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.ul(d);71!==f&&c();a=_.vl(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.ul(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.ul(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.ul(d)>>6;0!==a&&1!==a||c();0===_.ul(d)&&c();a=_.ul(d);const g=_.vl(d),h=_.vl(d);return(1073741824*
20
+ ((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},GI=function(a){const b=EI(a),c=FI(a);a.forEach(d=>{const e=d.V,f=e.findIndex(h=>h.ga===b);let g=e.findIndex(h=>h.ga===c+1);-1===g&&(g=e.length);d.V=e.slice(f,g)})},FI=function(a){a=a.map(b=>b.V[b.V.length-1].ga);return Math.min(...a)},EI=function(a){a=a.map(b=>b.V[0].ga);return Math.max(...a)},JI=function(a){var b=DH(a,wH);if(!HI.includes(b))return II.error("PlayReady in HLS is only supported with [",HI.join(", "),"], not",b),null;a=DH(a,_.Lb);b=_.Vr(a);
21
+ a=null;b=_.J(b.data);try{a=_.IA(_.Cm(b))}catch(c){a=b}return _.VA(_.wd,[{initDataType:_.Zc,initData:a}],"")},LI=function(a){if(0===a.length)return KI();if(a.some(c=>c.type===CH)||a.every(c=>c.type===_.Be))return a[0];a=a.filter(c=>c.type===BH);const b=_.Bh(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:BH,drmInfos:b}},OI=function(a){a=MI(a);if(a.some(b=>NI(b))&&1<a.length)throw new _.H(_.F,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");
22
+ },NI=function(a){return GH(a.$,_.Ga).some(b=>"AES-128"===_.I(b,wH))},QI=function(a,b,c){return MI(a).map(d=>PI(d.$,b,c))},RI=function(a){return a.filter(b=>JH(b.$,_.Ga)).length},MI=function(a){return a.filter(b=>JH(b.$,_.Ga))},PI=function(a,b,c){a=GH(a,_.Ga);if(0===a.length)return null;var d=DH(a[0],wH);if(1===a.length){if("NONE"===d)return KI();if("AES-128"===d)return a=a[0],d=_.I(a,"IV",""),{type:CH,keyInfo:{method:"AES-128",url:MH(b,DH(a,_.Lb)),iv:d?_.Ci((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=
23
+ a.map(e=>DH(e,wH));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===xH))throw SI.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.F,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.I(e,"KEYFORMAT","identity");{const g=TI[f]||null;e=g?g(e,c):null}e||SI.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.F,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||
24
+ null,type:BH,drmInfos:b}},KI=function(){return{type:_.Be,keyInfo:null,drmInfos:[],keyId:null}},UI=function(a,b,c){return _.x(function*(){const d=b.f(),e=_.yB(b.Oa(),b.ua,b.ua+2048-1,a.a.attemptParameters);e.type=2;const f=_.yB(b.Oa(),b.ua,b.ka,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.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.",
25
+ 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 _.H(_.F,4,4030,"Failed to fetch the media segment.");}}})},VI=function(a,b,c,d,e,f){return _.x(function*(){a.h.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Hc||d===_.Gc)return 0;if(d===_.Fc){var g=yield UI(a,c,f);const h=_.J(g.data);return zI(h)?AI(h):DI(g.data)}if(d===_.ig||d===_.Ic)return g=[UI(a,c,f)],b&&g.push(UI(a,b,!0)),g=yield Promise.all(g),
26
+ BI(g[0].data,(g[1]||g[0]).data);if(d===_.hg)return g=yield UI(a,c,f),DI(g.data);if(!_.Sp(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.F,4,4030);})},WI=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},iI=function(a,b){a.streams.forEach(c=>{c.codecs=b.join(",")})},fI=function(a){return a.streams[0]},XI=function(a,b){a.streams.forEach(c=>{c.Nd=b})},YI=function(a,b){a.streams.forEach(c=>{c.width=b})},ZI=function(a,b){a.streams.forEach(c=>{c.height=b})},
27
+ $I=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},aJ=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},bJ=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},cJ=function(a,b){const c=new Set(a.map(d=>d.ga));return b.filter(d=>!c.has(d.ga))},fJ=function(a,b){for(;a[0].ga<b[0].ga;)a.splice(0,1);var c=a[0];let d=b[0];dJ(c,d)||eJ(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&!dJ(c,d)&&eJ(c,d);for(c=e+1;c<b.length;)a.push(b[c]),c++},gJ=function(a,b){const c=a[a.length-1];var d=b.findIndex(f=>
28
+ f.ga===c.ga);const e=b[d];dJ(c,e)||eJ(c,e);for(d+=1;d<b.length;d++)a.push(b[d])},lJ=function(a,b,c,d,e){var f=b[0].length();f=yI(f).map(g=>{var h=bJ(b,g)||[];const k=WI(c,g)||[];g=WI(d,g)||[];{const l=[...hJ(h),...k,...g].filter(Boolean);iJ(l);const {ga:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ga:m}}return h});e&&jJ(f[0]);kJ(f);return f},hJ=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},
29
+ jJ=function(a){const b=hJ(a.variants)[0].V[0].xa;a.startTime+=b;a.endTime+=b},kJ=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},dJ=function(a,b){return a.startTime===b.startTime&&a.endTime===b.endTime},eJ=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;mJ(a.variants,b.variants);nJ(NH(a),NH(b))},mJ=function(a,b){const c=new Map(a.map(d=>[cI(d),d]));b.forEach(d=>{c.get(cI(d)).drmInfos=
30
+ d.drmInfos})},nJ=function(a,b){const c=new Map(a.map(d=>[d.ya,d]));b.forEach(d=>{const e=c.get(d.ya);e.V=d.V;e.segmentIndex.replace(d.V);e.Cc=d.Cc;e.ge=d.ge;e.duration=d.duration;e.bf=d.bf;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},iJ=function(a){const b=oJ(a);a.forEach(c=>{_.uB(c.segmentIndex,b);c.duration=b;c.ge=c.Cc+b})},oJ=function(a){let b=Infinity;a.filter(QH).forEach(c=>{b=Math.min(b,c.duration)});return b},pJ=function(a,b){OH(b,(c,d)=>{_.HB(a,c.V,d.startTime)});_.zB(a.a,
31
+ b[0].startTime,b[b.length-1].endTime)},qJ=function(a){return null===a.j?[]:[a.j.audio,a.j.video].filter(b=>b).map(b=>b.ya)},rJ=function(a,b){return _.x(function*(){var c=_.Pi([b],a.a.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.li(c.data)}catch(e){throw new _.H(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},wJ=function(a,b){return _.x(function*(){var c=sJ(a,b,a.w,"");if(1===c.type){c=_.Gs(c.V[0].a)||"";c=null!=_.Fs.video[c]?_.w:null!=_.Fs.audio[c]?
32
+ _.p:null;var d="";c===_.w?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=[];q.push(new _.Ii(_.ma,"0"));q.push(new _.Ii(_.Lb,e));d.length&&q.push(new _.Ii(_.pa,d));f.push(new _.Ji(c.f++,tH,q));c=new rI(e,0,f)}}d=c.$;c=GH(d,"EXT-X-MEDIA");e=GH(d,tH);d=GH(d,"EXT-X-IMAGE-STREAM-INF");c={Bc:{bg:IH(c,["AUDIO",_.Rb]),closedCaptions:IH(c,qH),sh:IH(c,yH)},kd:e,be:d};const {periods:g,Ef:h,Kf:k}=yield tJ(a,c);if(!a.D)throw new _.H(_.F,7,7001);e=eI(g[0]);
33
+ uJ(a,g);c=!0;d=null;f=0;vJ(a)||(c=!1,d=0,f=e.delay);d=new _.bH(a.a.timeline||{},d,f,!0,void 0,!!a.a.lowLatencyMode);_.DB(d,c);pJ(d,g);h&&_.CB(d,h);c=d;if(!vJ(a)){a.C=e.mc;e=0;for(var l of a.f.values())e=Math.max(e,l.streams[0].Cc);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.Cc?(a.h.debug("Offset applied to",e.type),e.segmentIndex.offset(l)):
34
+ a.h.debug("Offset NOT applied to",e.type)}}m=bI(g);"LIVE"===a.l||"EVENT"===a.l?(m=Math.max(m,c.H),isNaN(a.a.availabilityWindowOverride)||(m=a.a.availabilityWindowOverride),c.A=m):a.l===_.Sb&&(c.f=m);if(k)for(var n of k)a.D.onTimelineCueAdded({configurationId:a.D.configurationId,schemeIdUri:n.schemeIdUri,Ta:n.Ta,value:"",startTime:n.startTime,endTime:n.endTime,id:n.id,type:_.oh,eventElement:null});n={presentationTimeline:c,adaptedPeriods:[...g],periods:g,minBufferTime:0};a.h.debug("HLS playlist parsed",
35
+ n);return n})},yJ=function(a,b){return Promise.all(b.map(c=>xJ(a,c)))},AJ=function(a,b){b.forEach(c=>{a:{var d=a.f.get(c.a),e=!vJ(a),f=KH(c.$,_.Ea);if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].V,f=f[f.length-1].ga):f=0;if(e&&0<f)try{{const k=KH(c.$,_.Ia);if(!k)throw zJ.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(uH);const l=Number(k.value),m=d.find(l);if(!m)throw zJ.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
36
+ ` (segment position = ${l})`),Error(uH);var h=m.ga}g=h;break a}catch(k){throw new _.H(_.F,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.V||[];for(const k of c)JH(k.$,_.Da)&&g++,k.ga=g});GI(b)},DJ=function(a,b){return _.x(function*(){const {textStreams:c,thumbStreams:d,cg:e}=yield BJ(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=kI(g.audio,e),k=kI(g.video,e);g=CJ(a,h,k,g.bandwidth);
37
+ if(!g)throw new _.H(_.F,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Wh:k?fI(k).ya:void 0,audio:h?fI(h).ya:void 0});return g});return lJ(a.D.configurationId,f,c,d,!0)})},uJ=function(a,b){vJ(a)||2!==a.a.timeline.version||(a.G||(a.G=b[0].startTime),_.fD(b,-a.G))},EJ=function(a,b,c){a.l=_.Sb;_.DB(b,!0);b.f=c[c.length-1].endTime},sJ=function(a,b,c,d){a=wI(a.K,b,c);a.a=d;FJ(a);return a},tJ=function(a,b){return _.x(function*(){var c=hI(b.Bc.closedCaptions),d=GJ(a,b.kd),e=yield HJ(a,
38
+ b);const f=Object.values(e).flat().map(h=>h.playlist);AJ(a,f);var g=yield IJ(a,e.Te,d);c=yield JJ(a,e.kd,g,c);d=yield KJ(a,e.rh,d);g=yield LJ(a,e.be);e=MJ(a,e);c=lJ(a.D.configurationId,c,d,g,!vJ(a));a.D.filterAllPeriods(c);return vJ(a)?(d=null,null!=e&&(d=NJ(f,e)),{periods:c,Ef:e,Kf:d}):{periods:c,Ef:e,Kf:null}})},BJ=function(a,b){return _.x(function*(){const c=g=>fI(g.stream).type===_.w||fI(g.stream).type===_.p;var d=b.filter(c),e=b.filter(g=>!c(g)),f=g=>{g=g.map(h=>{var k=fI(h.stream);k={language:k.language,
39
+ 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.ya,Ld:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist},k);return OJ(a,h)});return Promise.all(g)};d=yield f(d);f=yield f(e);PJ(a,d.concat(f));e=f.filter(g=>fI(g).type===_.DA);f=f.filter(g=>fI(g).type===_.ae);return{textStreams:e,thumbStreams:f,cg:d}})},CJ=function(a,
40
+ 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?_.cB(k.drmInfos,l.drmInfos)?_.bB(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:_.Xf,primary:!!g&&g.primary||!!h&&h.primary,audio:g,video:h,bandwidth:l,drmInfos:k,allowedByApplication:!0,allowedByKeySystem:!0};e.push(g)}return new QJ(e)},OJ=function(a,b){return _.x(function*(){const c=b.playlist,d=b.codecs,
41
+ e=b.type,f=b.Xc,g=b.groupId,h=b.primary;var k=b.kind;const l=b.name,m=b.channelsCount,n=b.spatialAudio,q=b.closedCaptions,u=b.Ld,v=_.Zh(f||_.Xf);if(1!==c.type)throw new _.H(_.F,4,4017);var y=RH(c.$,null==a.o);a.l=y;const B=dI(c.$,y,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay);y=yield RJ(a,c,e,d);const D=a.a.lowLatencyMode?_.sA:_.rA;let M=k;e!==_.G||k||(M=_.DA);const {od:da}=WH(c.$);k=y.map(ub=>{const Ub=ub.V,pd=ub.ng,gg=ub.mimeType;ub=ub.ga;const Wa=Ub[0].startTime,ke=Ub[Ub.length-1].endTime,
42
+ Oc=ke-Wa,ea=new _.cH(Ub),$a=Ub[0].initSegment||null;return{id:_.gH++,originalId:l,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:ea.find.bind(ea),getSegmentReference:ea.get.bind(ea),adjustSegmentDurations:ea.f.bind(ea),getDuration:ea.getDuration.bind(ea),segmentIndex:ea,segmentLookupStrategy:D,initSegmentReference:$a,mimeType:gg,codecs:d,kind:M,bf:pd.type,encrypted:pd.type===BH,keyId:pd.keyId,language:v,originalLanguage:f||_.Xf,label:l,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
43
+ frameRate:u?u.frameRate:void 0,width:u?u.width:void 0,height:u?u.height:void 0,bandwidth:void 0,roles:[],channelsCount:m,spatialAudio:n,closedCaptions:q,keyInfo:pd.keyInfo,V:Ub,drmInfos:pd.drmInfos,ga:ub,ya:c.a,Nd:c.f,Cc:Wa,ge:ke,duration:Oc,od:da,groupId:g,Rg:B}});return new SJ(k)})},PJ=function(a,b){b.forEach(c=>{a.f.a.set(fI(c).ya,c)})},GJ=function(a,b){const c=new Map;for(const f of b){var d=_.I(f,"AUDIO");b=_.I(f,_.Rb);var e=_.I(f,yH);const g=TJ(a,f);if(e){const h=_.wj(_.G,g);c.set(e,h);e=g.indexOf(h);
44
+ -1<e&&g.splice(e,1)}d&&(e=UJ(_.p,g),c.set(d,e));b&&(d=UJ(_.w,g),c.set(b,d))}return c},HJ=function(a,b){return _.x(function*(){const c=yield Promise.all([VJ(a,b.Bc.bg),VJ(a,b.Bc.sh),VJ(a,b.kd),VJ(a,b.be)]),[d,e,f,g]=c;return{Te:d,rh:e,kd:f,be:g}})},IJ=function(a,b,c){return _.x(function*(){if(0===b.length)return new Map;var d=[WJ(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>WJ(a,e,c)));d=yield Promise.all(d);return gI(d)})},JJ=function(a,b,c,d){return _.x(function*(){const e=new Set;var f=[...b];
45
+ let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(DH(f[k].tag,_.ma));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield XJ(a,h,c,d,e);f=f.map(k=>XJ(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.SA,[])})},KJ=function(a,b,c){return Promise.all(b.map(d=>WJ(a,d,c)))},LJ=function(a,b){return Promise.all(b.map(c=>YJ(a,c)))},MJ=function(a,b){b=[...b.kd,...b.Te].map(d=>d.playlist).flatMap(d=>d.V[0].$);b=KH(b,_.Na);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?
46
+ (a.h.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},vJ=function(a){return a.l===_.Sb},NJ=function(a,b){return(a=a.find(c=>null!==KH(c.$,_.Ca)))?a.$.filter(c=>c.name===_.Ca).map(c=>{a:{var d=_.I(c,"ID"),e=_.I(c,"START-DATE");if(null===d||null===e)_.Js.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=
47
+ FH(_.I(c,sH));void 0!==g&&0<=g&&(d.duration=g);var h=FH(_.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==q)var m=null;else{f={};for(m of q)m.name.startsWith("X-")&&(f[m.name]=m.value);m=_.Pg(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]=
48
+ n.value;break;case _.Yb:k[_.Yb]=n.value;break;case _.ac:k[_.ac]=FH(n.value);break;case _.$b:k[_.$b]=FH(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]?(_.Js.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),n=null):n=_.Pg(k)?k:null}if(null===n){_.Js.warn("Invalid interstitial attributes, ignoring the EXT-X-DATERANGE tag.",c);c=null;break a}m=Object.assign(m,n)}_.Pg(m)&&
49
+ (d.Ta=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},VJ=function(a,b){return _.x(function*(){return(yield Promise.all(b.map(c=>_.x(function*(){const d=yield ZJ(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},xJ=function(a,b){return _.x(function*(){var c=new _.Lh(fI(b).Nd);if(a.a.lowLatencyMode&&fI(b).od){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={Ug:d.position,$g:e&&0<e.length?
50
+ f:null}}else d=null;if(e=d)d=e.Ug,e=e.$g,f=_.ij(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=_.hj(f,!0),d=new _.Sh(d),_.Oh(c,d)}const {response:g,text:h}=yield rJ(a,c.toString());c=fI(b).ya;d=fI(b).Nd;e=g.uri;d!==e&&(d=e,XI(b,d));c=sJ(a,h,d,c);return{stream:b,playlist:c}})},TJ=function(a,b){var c=_.I(b,_.pa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.hB(e),b.has(c)?
51
+ a.h.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},UJ=function(a,b){if(1===b.length)return b[0];a=_.wj(a,b);if(null!=a)return a;throw new _.H(_.F,4,4025,{codecList:b});},WJ=function(a,b,c){return _.x(function*(){const d=b.tag,e=b.playlist;return $J(a,e.a,()=>_.x(function*(){const f=DH(d,_.Va),g=SH(DH(d,_.Jb));var h=DH(d,_.Jb).toUpperCase();if(SH(h)!==_.G)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.DA;h===qH&&(l=_.nA);k&&(l=
52
+ _.Vd);h=l}k=c.get(f)||"";l=_.I(d,_.cb);const m=_.I(d,"NAME"),n=d.getAttribute("DEFAULT"),q=d.getAttribute("AUTOSELECT");var u=_.I(d,"CHANNELS");u=g===_.p?u?parseInt(u.split("/")[0],10):null:null;var v=g===_.p?(v=_.I(d,"CHANNELS"))?v.includes("/JOC"):!1:!1;return yield OJ(a,{playlist:e,codecs:k,type:g,Xc:l,primary:!!n&&!!q,name:m,channelsCount:u,spatialAudio:v,groupId:f,kind:h,closedCaptions:null,Ld:null})}))})},YJ=function(a,b){return _.x(function*(){const c=b.tag,d=b.playlist;return $J(a,d.a,()=>
53
+ _.x(function*(){var e=_.I(c,_.pa)||"jpg",f=_.I(c,_.cb);const g=_.I(c,"NAME");e=yield OJ(a,{playlist:d,codecs:e,type:_.ae,Xc:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,groupId:null,Ld:null});(f=_.I(c,_.ma))&&aJ(e,Number(f));return e}))})},XJ=function(a,b,c,d,e){return _.x(function*(){var f=b.tag,g=Number(DH(f,_.ma));if(null!=f.getAttribute("FRAME-RATE")||null!=f.getAttribute(_.Bb)){var h=_.I(f,"FRAME-RATE");f=_.I(f,_.Bb);var [k,l]=f?f.split("x"):[null,null];
54
+ h={frameRate:FH(h),width:FH(k),height:FH(l)}}else h=null;if(f=yield aK(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?fI(q).ya:"")+" - "+(n?fI(n).ya:"");if(e.has(m)){a.h.debug("Skipping variant which only differs in text streams.");continue}const u=CJ(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})},aK=function(a,b,c,d,e){return _.x(function*(){var f=
55
+ b.tag,g=b.playlist;let h=TJ(a,f);var k=_.I(f,"AUDIO"),l=_.I(f,_.Rb),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.ya===n);l=_.wj(_.w,h);l=c||l;1!==h.length||l?!m.length&&1<h.length?(a.h.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.h.debug(vH),g=_.p,f=!0):k.video.length?(a.h.debug(vH),g=_.p):(a.h.debug("Guessing video-only"),g=_.w):(g=_.p,a.h.debug(vH));
56
+ l=null;f||(l=yield bK(a,b,h,g,e,c));if(null==l)return null;k[g]=[l];g===_.p&&c&&m.forEach(q=>{YI(q,c.width);ZI(q,c.height);$I(q,c.frameRate)});jI(k);return k})},bK=function(a,b,c,d,e,f){return _.x(function*(){const g=b.tag,h=b.playlist;return $J(a,h.a,()=>_.x(function*(){var k=_.I(g,qH);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=UJ(d,c);return yield OJ(a,{playlist:h,codecs:k,type:d,closedCaptions:l,primary:!1,kind:null,Xc:null,name:null,channelsCount:null,spatialAudio:!1,groupId:null,Ld:f})}))})},
57
+ $J=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},RJ=function(a,b,c,d){return _.x(function*(){var e=b.a,f=b.V;var g=void 0===g?0:g;var h=(h=KH(b.$,_.Ia))?Number(h.value):g;g=[];!vJ(a)&&OI(f);e=yield cK(a,b.f,e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)JH(m.$,_.Da)&&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 dK(a,b.f,k,h,e,c,d,g[g.length-
58
+ 1]||null,f.length),g.push(l),h+=k.length;eK(g);return g})},ZJ=function(a,b){return _.x(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.I(b,_.Jb)===yH;c=_.I(b,_.Lb,void 0,{required:c});if(!c)return null;const d=MH(a.w,c),{response:e,text:f}=yield rJ(a,d);return sJ(a,f,e.uri,c)})},FJ=function(a){1===a.type&&a.V.forEach((b,c)=>{if(JH(b.$,_.Ha)&&!JH(b.$,_.Da)&&0<c)throw new _.H(_.F,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},eK=function(a){if(1<
59
+ (new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.F,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},fK=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.I(c,_.Lb))||null).map(b=>_.Gs(b));if(1<(new Set(a)).size)throw new _.H(_.F,4,4044,"Unexpected change in file format.");},gK=function(a,b,c){a=GH(a.$,_.Ha);if(1<a.length)throw new _.H(_.F,4,4020);a=a[0];if(!a)return null;const d=DH(a,_.Lb),e=MH(b,d);b=XH(a,null,!0);return new _.ZG(()=>
60
+ [e],b.ua,b.ka,c)},hK=function(a,b,c,d,e,f,g){const h=[];for(const q of _.$A(b.f)){b=q.pf;const u=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.I(u,sH));n=m+n;k=XH(u,k?null:l.ka,k);l=_.I(u,_.Lb);const v=(l=MH(g,l))?[l]:[];m=new YH(c,m,n,()=>v,k.ua,k.ka,e,f,!1,null,null,null,null);if("YES"===_.I(u,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},iK=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.$;var q=c.a;const u=null!=q,v=q?[q]:[];if(!u&&!a.a.lowLatencyMode)return null;a=0;q={ua:0,
61
+ ka:null};let y=null;u?({duration:c}=VH(n),a=e+c,q=UH(n,b?b.ka:null)):(b=hK(b,c,d,e,f,g,k),a=b[b.length-1].endTime,y=b);h=h===_.ae?LH(n):null;d=new YH(d,e,a,()=>v,q.ua,q.ka,f,g,!1,null,h?h.Rc:null,h?h.jd:null,h?h.durationPerTile:null,y);d.ga=l;d.initSegment=m||void 0;return d},cK=function(a,b,c,d,e,f,g){return _.x(function*(){var h=d[0];if(null!=a.B)return a.B;if(!vJ(a)&&a.o)try{var k=a.f.get(c);var l=k?k.find(e)||null:null;if(!l)throw new _.H(_.F,4,4030,"Segment not found in pervious playlist update.");
62
+ var m=l.startTime+l.xa;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].V,m=m[m.length-1],a.h.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].V[0].position} - ${m.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h);throw new _.H(_.F,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}m=yield jK(a,f,g,h);k=PI(h.$,a.w,m)||KI();l=gK(h,b,k.keyInfo);k=$H(k.keyInfo,e);h=yield kK(a,
63
+ l,h,k,m,g);a.h.debug(`Setting playlist start time to ${h}.`);return a.B=h})},dK=function(a,b,c,d,e,f,g,h,k){return _.x(function*(){var l=c[0],m=null==h;fK(c);const n=yield jK(a,f,g,l);var q=a.w,u=h?h.Qg:null;var v=1===k;if(c.slice(1).some(NI))throw new _.H(_.F,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.");
64
+ if(JH(c[0].$,_.Ga)||null===u)if((u=PI(c[0].$,q,n))&&u.type===CH){if(1<RI(c))throw new _.H(_.F,4,4046,zH+`${v?"playlist":"discontinuity"}.`);v=[u]}else v=QI(c,q,n),v=0===v.length?[KI()]:v;else if(q=QI(c,q,n),u.type===_.Be||u.type===BH)v=[u,...q];else{if(0<RI(c))throw new _.H(_.F,4,4046,zH+`${v?"playlist":"discontinuity"}.`);v=[u]}q=v;v=q[q.length-1];q=LI(q);u=gK(l,b,q.keyInfo)||(h?h.Lg:null);var y=$H(q.keyInfo,d);const B=l.ga;l=m?e:yield lK(a,B,u,l,d,y,n,g);m=[];for(y=0;y<c.length;y++){var D=c[y];
65
+ const M=m[m.length-1]||null,da=0===y?0:M.endTime,ub=d+y,Ub=$H(q.keyInfo,ub);(D=iK(a,M,D,ub,da,l,Ub,f,b,B,u))&&m.push(D)}return{V:m,ng:q,Qg:v,mimeType:n,endTime:m[m.length-1].endTime,ga:B,Lg:u}})},jK=function(a,b,c,d){return _.x(function*(){const e=d.a;var f=KH(d.$,_.Ha);f=f?DH(f,_.Lb):null;return mK(a,b,c,e,f)})},kK=function(a,b,c,d,e,f){return _.x(function*(){if(null==c.a)return 0;const g=ZH(c,d);return VI(a.L,b,g,e,f,null!=d)})},lK=function(a,b,c,d,e,f,g,h){return _.x(function*(){if(a.H.has(b))return a.H.get(b);
66
+ const k=yield kK(a,c,d,f,g,h);a.h.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.H.set(b,k);return k})},mK=function(a,b,c,d,e){return _.x(function*(){const f=[d,e].filter(Boolean);var g=_.zj(f,b,c);if(g)return g;g=_.Pi([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.H(_.F,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},rI=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.F,4,
67
+ 4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.F,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.$=c;this.V=1===b?d:null}},xI=class{constructor(a,b,c){c=void 0===c?[]:c;this.$=b;this.a=a;this.f=c;this.ga=-1}},YH=class extends _.UB{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:
68
+ q,u);this.initSegment=void 0;this.ga=0}},nK=class{constructor(){this.f=0;this.a=new Map}},oK=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()}},zJ=new _.R("clpp.hls.DiscontinuityUtils");var TI={"com.apple.streamingkeydelivery":function(a,b){if(b===_.hg)throw new _.H(_.F,4,4041);if(DH(a,wH)===xH)throw new _.H(_.F,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.VA(_.ud,[{initDataType:_.Ff,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":JI,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":JI,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=DH(a,wH);if(!HI.includes(b))return II.error("Widevine in HLS is only supported with [",
69
+ HI.join(", "),"], not",b),null;b=DH(a,_.Lb);b=_.Vr(b);b=_.J(b.data);b=_.VA(_.yd,[{initDataType:_.Zc,initData:b}],"");if(a=_.I(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},HI=["SAMPLE-AES",xH],II=new _.R("clpp.hls.DrmParser");var SI=new _.R("clpp.hls.EncryptionUtils");var pK=class{constructor(a){this.h=new _.R("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.Mi()}}};var SJ=class{constructor(a){this.streams=a}length(){return this.streams.length}find(a){const b=this.streams.find(c=>{c=c.V;return c[0].position<=a&&a<=c[c.length-1].position});return null==b?null:b.V.find(c=>c.position===a)||null}};var QJ=class{constructor(a){this.a=a}length(){return this.a.length}};var qK=class{constructor(){this.a=this.D=null;this.N=1;this.f=new oK;this.w="";this.K=new nK;this.C=0;this.j=null;this.g=new _.Qj(()=>{this.Eb()});this.l=_.Sb;this.o=null;this.A=new _.Os;this.B=null;this.h=new _.R("clpp.hls.HlsParser");this.H=new Map;this.L=new pK(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 _.x(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,
70
+ text:e}=yield rJ(c,a);c.w=d.uri;const f=yield wJ(c,e);c.o=f;const g=c.C;c.g&&0<g&&c.g.fa(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 _.x(function*(){const b=a.o;if(!vJ(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=qJ(a);
71
+ d=d.filter(g=>f.includes(fI(g).ya))}var e=yield yJ(a,d);d=e.map(f=>f.playlist);AJ(a,d);e=yield DJ(a,e);cJ(b.periods,e).forEach(f=>{a.D.filterNewPeriod(f)});uJ(a,e);fJ(b.periods,e);gJ(b.adaptedPeriods,e);pJ(c,e);if(d=PH(d))!0!==a.a.keepTimelineLive&&EJ(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())}})}Eb(){const a=this;return _.x(function*(){a.h.debug(_.iA);if(a.D)try{yield a.update(),a.g&&0<a.C&&a.g.fa(a.C)}catch(b){if(!(b instanceof
72
+ _.H))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.g&&a.g.fa(.1))}})}F(a){if(!this.A)throw new _.H(_.F,7,7001);a=this.D.networkingEngine.fetch(a);_.Wi(this.A,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Pt{f(){_.tr.m3u8=qK;_.rr[_.Lk]=qK;_.rr[AH]=qK}a(){_.sC("m3u8");_.tC(_.Lk);_.tC(AH)}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 JR=function(a){a.a.one(a.m,_.me,()=>IR(a))},IR=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.g){a.a.on(b.textTracks,_.tc,d=>KR(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.we).forEach(d=>{KR(a,{track:d})});!LR(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."),MR(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.")},KR=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=>NR(a,c)))},LR=function(a){return a.some(b=>b.kind===_.we)},MR=function(a,b){const c=a.m.getTrackManager(),d=c.la(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ta(d);a.a.on(b.textTracks,_.tc,g=>{g.track.kind===_.we&&(a.a.off(b.textTracks,_.tc,f),c.ta(d))});c.ta(e)}else a.h.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- NR=function(a,b){const c=OR(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 PR(d);if(e.f===c&&null!==e.a){a.f=d;d=a.g.parseMedia(_.pi(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)}}})},OR=function(a){return(a=a.m.getTrackManager().qa())&&a.language&&a.language.toLowerCase()},
4
- PR=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.A(a)){a:{var b=a.info;if(_.Tg(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=_.Tg(a)?a:null}}};var QR=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.hs;this.g=(a=_.Wr(_.Dc))?new a(this.m.getConfiguration()):null;this.h=new _.R("clpp.hlssmpte.ImageCueHandler");this.f=null;JR(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var RR=class extends _.pu{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.ek()){var b=a.getConfiguration();b=_.Ng(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Pc&&(b.patchMetadataTrack=!1);_.Ug(b.timestampOffset)||(b.timestampOffset=0);this.a=new QR(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",RR);
5
- RR.Id="hlssmpte";_.Yo(new class{create(){return new RR}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var LR=function(a){a.a.one(a.m,_.le,()=>KR(a))},KR=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.g){a.a.on(b.textTracks,_.sc,d=>MR(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.ve).forEach(d=>{MR(a,{track:d})});!NR(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."),OR(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.")},MR=function(a,b){b=b.track;b.kind===_.ve&&(a.h.info("The metadata track has been added."),b.mode=_.Zd,a.a.on(b,_.Bd,c=>PR(a,c)))},NR=function(a){return a.some(b=>b.kind===_.ve)},OR=function(a,b){const c=a.m.getTrackManager(),d=c.la(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ta(d);a.a.on(b.textTracks,_.sc,g=>{g.track.kind===_.ve&&(a.a.off(b.textTracks,_.sc,f),c.ta(d))});c.ta(e)}else a.h.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ PR=function(a,b){const c=QR(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 RR(d);if(e.f===c&&null!==e.a){a.f=d;d=a.g.parseMedia(_.pi(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)}}})},QR=function(a){return(a=a.m.getTrackManager().qa())&&a.language&&a.language.toLowerCase()},
4
+ RR=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.A(a)){a:{var b=a.info;if(_.Tg(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=_.Tg(a)?a:null}}};var SR=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.ks;this.g=(a=_.Zr(_.Cc))?new a(this.m.getConfiguration()):null;this.h=new _.R("clpp.hlssmpte.ImageCueHandler");this.f=null;LR(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var TR=class extends _.ru{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.ek()){var b=a.getConfiguration();b=_.Ng(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Nc&&(b.patchMetadataTrack=!1);_.Ug(b.timestampOffset)||(b.timestampOffset=0);this.a=new SR(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",TR);
5
+ TR.Id="hlssmpte";_.ap(new class{create(){return new TR}});};f.call(g, window);
package/cl.htmlcue.js CHANGED
@@ -1,26 +1,26 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var zQ="Unsupported unit",AQ="clpp-text-plain",BQ="clpp-text-ttml",CQ="clpp.htmlcue.HtmlTextDisplayer",DQ="initial",EQ=function(a){return _.Bh(a,{Ze:(b,c)=>b.wc(c)})},FQ=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},GQ=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},HQ=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
2
- b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},JQ=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>IQ[c]);return a},LQ=function(a,b){KQ(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{KQ(a,c)})},KQ=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},MQ=function(a,b){return 0===a?"0":a+b},NQ=function(a,b){return 1>Math.abs(a-b)||a<b},OQ=function(a,b){return a<b&&1<Math.abs(a-b)},PQ=function(a,b){return a>b&&1<Math.abs(a-b)},QQ=
3
- function(a,b){return 1>Math.abs(a-b)||a>b},SQ=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new RQ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
- d-e)},TQ=function(a){return new RQ(a.left,a.f,a.top,a.a,a.height,a.width)},UQ=function(a,b){return b.some(c=>OQ(a.left,c.f)&&PQ(a.f,c.left)&&OQ(a.top,c.a)&&PQ(a.a,c.top))},VQ=function(a,b){return QQ(a.top,b.top)&&NQ(a.a,b.a)&&QQ(a.left,b.left)&&NQ(a.f,b.f)},WQ=function(a,b,c){switch(c){case "+x":return OQ(a.left,b.left);case "-x":return PQ(a.f,b.f);case "+y":return OQ(a.top,b.top);case "-y":return PQ(a.a,b.a);default:throw Error("Unknown axis");}},XQ=function(a){return a.f.writingMode===_.ls},YQ=
5
- function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return XQ(a)?b:c},ZQ=function(a){switch(a.f.writingMode){case _.ls:return"horizontal-tb";case _.eg:return _.eg;case _.gg:return _.gg;default:throw Error("Unknown writing mode");}},$Q=function(a){switch(a.f.positionAlign){case _.ie:return _.fe;case "auto":case _.ad:return _.ks;case _.je:return _.wf}return a.f.textAlign},aR=function(a,b){if(typeof a.f.position===_.t&&typeof a.f.size===
6
- _.t)switch(b){case _.ie:return a.f.position;case "auto":case _.ad:return a.f.position-a.f.size/2;case _.je:return a.f.position-a.f.size}return 0},bR=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.fe:case _.fe:return _.ie;case _.ks:return _.ad;case _.wf:case _.wf:return _.je}return a.f.positionAlign},eR=function(a,b,c){return(cR(a)||dR(a))&&_.Ug(c)?MQ(c,_.pf):cR(a)&&_.A(c)?MQ(0,_.pf):XQ(a)&&_.Ug(b)?MQ(b,"%"):DQ},fR=function(a,b,c){return XQ(a)&&_.Ug(c)?MQ(c,_.pf):(cR(a)||dR(a))&&_.Ug(b)?
7
- MQ(b,"%"):DQ},dR=function(a){return a.f.writingMode===_.gg},cR=function(a){return a.f.writingMode===_.eg},gR=function(a,b){if(a.j)switch(b.writingMode){case _.ls:return["-y"];case _.eg:return["+x"];case _.gg:return["-x"]}a=[];switch(b.writingMode){case _.ls:a=["+y","-y"];break;case _.eg:a=["+x","-x"];break;case _.gg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},hR=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=SQ(a.l.a)},iR=function(a,b){hR(a.g);a.l.unshift(b);
8
- for(const c of a.l)a.g.append(c)},jR=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.ss)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(zQ);},lR=function(a,b,c,d){const e=document.createElement(_.Pf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);kR(a,c,b);a.h.debug(`Created HTML style element #${b}.`);return e.sheet},mR=function(a,b){a=`.${a.j} .clpp-text-container`;
9
- const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},nR=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);
10
- return c},oR=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.o=[]}},kR=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.h.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},pR=function(a){a=_.Ng(a.htmlcue||{});_.A(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.A(a.enableResizeObserver)&&(a.enableResizeObserver=
11
- !0);return a},vR=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();if(b||a.J!==c&&a.m.getState()===_.Wn)if(a.J=c,c=qR(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,rR(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.bs(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.rg:g="clpp-text-vtt";
12
- break;case _.Wf:g=BQ;break;case _.js:g=AQ}g&&!f.classList.contains(g)&&_.so(f,g);f=SQ(c.a.a);if(0===f.width||0===f.height)c.h.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{KQ({fontSize:sR(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.rg;var h=d.payloadType===_.Wf;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new tR(d.region,
13
- {}),c.B.set(d.region.id,f),iR(c.a,f)));d=new uR(d,c.L,e);f?iR(f,d):iR(c.a,d)}}}}},wR=function(a){rR(a);a.J=null;a.o=null;a.f=[]},xR=function(a,b){return a.startTime<=b&&a.endTime>b},qR=function(a,b){var c=GQ(a.f,d=>xR(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&xR(a.f[d-1],b);)d--;for(;c+1<a.f.length&&xR(a.f[c+1],b);)c++;return{start:d,end:c}}},rR=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(BQ);
14
- b.classList.remove(AQ);a=a.a;hR(a.g);a.l=[]}},sR=function(a,b){const c=SQ(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.t&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},BR=class{parse(a){a={input:a};const b=_.uo(_.Gd),c=[];let d=b;for(var e;null!==(e=HQ(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);
15
- else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=yR[f];h?(h=_.uo(h),(f=zR[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||AR[g.localName]&&AR[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(JQ(e)));return b}},yR={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},zR={v:"voice",lang:"lang"},AR={rt:"ruby"},IQ={"\x26amp;":"\x26",
16
- "\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var RQ=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var CR=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var uR=class extends CR{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.g=!!this.f.backgroundImage;this.C=c}A(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.so(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.Wf){var c=_.uo(_.Gd);c.innerHTML=b.payload;b=c}else b.payloadType===
17
- _.rg?b=(new BR).parse(b.payload):(c=_.uo(_.Gd),c.textContent=b.payload,b=c);_.so(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.so(b,d);KQ({writingMode:ZQ(this)},b);var d=b;this.a.appendChild(d);_.so(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.so(this.a,`clpp-text-wrapper__${e}`);_.A(this.f.line)&&(this.f.lineInterpretation=_.ms,this.f.line=XQ(this)?-1:0);e=ZQ(this);KQ({writingMode:e,webkitWritingMode:e,direction:DQ,textAlign:$Q(this)},this.a);if(!this.f.region||
18
- !this.f.region.displayAlign){e=aR(this,bR(this));KQ({position:"absolute",left:eR(this,e,null),right:dR(this)&&_.A(null)?MQ(0,_.pf):DQ,top:fR(this,e,null),width:XQ(this)?MQ(this.f.size,"%"):DQ,height:cR(this)||dR(this)?MQ(this.f.size,"%"):DQ},this.a);b=this.f;a=XQ(this)?a.height:a.width;c=YQ(this);if(b.lineInterpretation===_.ms){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.ad:g-=f/2;break;case _.Ud:g-=f}f=Math.round(g/
19
- 100*a)}dR(this)&&(f=a-f-c);a=f;KQ({left:eR(this,e,a),right:dR(this)&&_.A(a)?MQ(0,_.pf):DQ,top:fR(this,e,a)},this.a)}LQ(this.C,d)}}o(){return _.uo(_.Gd)}};var DR=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=SQ(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.$d;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=SQ(a.a);var d=gR(this,a.f),e=YQ(a);const g=TQ(c);let h=null,k=0;for(const l of d){for(;WQ(c,this.a,l)||VQ(c,this.a)&&UQ(c,this.g);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||VQ(c,this.a))break a;
20
- d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=TQ(c),k=d);c=TQ(g)}c=h||g}KQ({top:MQ(c.top-this.a.top,_.pf),bottom:MQ(this.a.a-c.a,_.pf),left:MQ(c.left-this.a.left,_.pf),right:MQ(this.a.f-c.f,_.pf),height:MQ(c.height,_.pf),width:MQ(c.width,_.pf)},a.a)}b.style.visibility="visible";this.g.push(SQ(a.a))}};var ER=class extends CR{constructor(a,b,c){super(a,b,c);this.g=null;this.l=[]}init(){this.g=new DR(this);this.j=!0}o(){const a=_.uo(_.Gd);_.so(a,this.w);this.id&&(a.id=this.id);return a}};var tR=class extends ER{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.ss:b=b.width/100*a.width;break a;default:throw Error(zQ);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.ss)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(zQ);d=a.height;const e=jR(this,d,a.height);KQ(this.B,this.a);KQ({left:MQ(c,_.pf),top:MQ(e,_.pf),width:MQ(b,
21
- _.pf),height:MQ(d,_.pf)},this.a);this.f.writingMode&&KQ({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&KQ({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.so(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.ss:f=f.height/100*a.height;break a;case 2:f=f.height;c=new uR(new _.ps(0,1,"Lorem ipsum",_.js),{},{});b=c.a;this.a.appendChild(b);c.init(SQ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
- b=c;f*=b;break a;default:throw Error(zQ);}a=jR(this,f,a.height);KQ({top:MQ(a,_.pf),height:MQ(f,_.pf)},this.a);this.g=new DR(this,!0);this.j=!0}getId(){return this.f.id}};var FR=class{constructor(a,b){this.h=new _.R("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.g=b;this.o=[];this.a=lR(this,this.g,this.j);this.f=lR(this,this.g,this.j,!0);this.f.disabled=!0;this.h.debug(`Stylesheet ${this.g} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=mR(this,a);if(nR(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.h.debug(`Added CSS rule ${b}`)}catch(c){this.h.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.h.warn(`Stylesheet ${this.g} ignoring the CSS rule `+
23
- `because it's not safe: ${b}`)}}destroy(){const a=this;return _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],oR(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.h.debug(`Stylesheet ${a.g} has been destroyed.`))})}};var GR=class extends _.mu{constructor(a){super(a);this.h=new _.R(CQ);this.m=a;this.L=pR(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new FR(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new ER(null,"clpp-text-container",{});this.A=new _.du(a.getSurface(),this.T.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.h.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
24
- this.G=new _.Qj(()=>{vR(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=FQ(this.f,EQ(a));this.o=null;vR(this,!1)}}g(){null==this.j||vR(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(wR(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
25
- this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;vR(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.hb(.25),this.L.enableResizeObserver&&this.A.start(),vR(this,!0)):(this.G.stop(),this.A.stop(),wR(this)))}Oc(){return this.f}T(){vR(this,!0)}};_.z(CQ,GR);GR.prototype.setTextVisibility=GR.prototype.setTextVisibility;GR.prototype.isTextVisible=GR.prototype.isTextVisible;GR.prototype.remove=GR.prototype.remove;
26
- GR.prototype.destroy=GR.prototype.destroy;GR.prototype.append=GR.prototype.append;var HR=class{isSupported(a){return!!a.enableHtmlCue&&!_.gk()}create(a){return new GR(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Nt{f(){_.An(_.ae,new HR)}a(){_.yn.has(_.ae)&&(_.yn.delete(_.ae),_.zn.info("Removed factory: 'html'"))}id(){return _.Qf}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var BQ="Unsupported unit",CQ="clpp-text-plain",DQ="clpp-text-ttml",EQ="clpp.htmlcue.HtmlTextDisplayer",FQ="initial",GQ=function(a){return _.Bh(a,{Ze:(b,c)=>b.wc(c)})},HQ=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},IQ=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},JQ=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
2
+ b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},LQ=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>KQ[c]);return a},NQ=function(a,b){MQ(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{MQ(a,c)})},MQ=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},OQ=function(a,b){return 0===a?"0":a+b},PQ=function(a,b){return 1>Math.abs(a-b)||a<b},QQ=function(a,b){return a<b&&1<Math.abs(a-b)},RQ=function(a,b){return a>b&&1<Math.abs(a-b)},SQ=
3
+ function(a,b){return 1>Math.abs(a-b)||a>b},UQ=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new TQ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
4
+ d-e)},VQ=function(a){return new TQ(a.left,a.f,a.top,a.a,a.height,a.width)},WQ=function(a,b){return b.some(c=>QQ(a.left,c.f)&&RQ(a.f,c.left)&&QQ(a.top,c.a)&&RQ(a.a,c.top))},XQ=function(a,b){return SQ(a.top,b.top)&&PQ(a.a,b.a)&&SQ(a.left,b.left)&&PQ(a.f,b.f)},YQ=function(a,b,c){switch(c){case "+x":return QQ(a.left,b.left);case "-x":return RQ(a.f,b.f);case "+y":return QQ(a.top,b.top);case "-y":return RQ(a.a,b.a);default:throw Error("Unknown axis");}},ZQ=function(a){return a.f.writingMode===_.os},$Q=
5
+ function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return ZQ(a)?b:c},aR=function(a){switch(a.f.writingMode){case _.os:return"horizontal-tb";case _.eg:return _.eg;case _.fg:return _.fg;default:throw Error("Unknown writing mode");}},bR=function(a){switch(a.f.positionAlign){case _.he:return _.ee;case "auto":case _.$c:return _.ns;case _.ie:return _.vf}return a.f.textAlign},cR=function(a,b){if(typeof a.f.position===_.t&&typeof a.f.size===
6
+ _.t)switch(b){case _.he:return a.f.position;case "auto":case _.$c:return a.f.position-a.f.size/2;case _.ie:return a.f.position-a.f.size}return 0},dR=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.ee:case _.ee:return _.he;case _.ns:return _.$c;case _.vf:case _.vf:return _.ie}return a.f.positionAlign},gR=function(a,b,c){return(eR(a)||fR(a))&&_.Ug(c)?OQ(c,_.of):eR(a)&&_.A(c)?OQ(0,_.of):ZQ(a)&&_.Ug(b)?OQ(b,"%"):FQ},hR=function(a,b,c){return ZQ(a)&&_.Ug(c)?OQ(c,_.of):(eR(a)||fR(a))&&_.Ug(b)?
7
+ OQ(b,"%"):FQ},fR=function(a){return a.f.writingMode===_.fg},eR=function(a){return a.f.writingMode===_.eg},iR=function(a,b){if(a.j)switch(b.writingMode){case _.os:return["-y"];case _.eg:return["+x"];case _.fg:return["-x"]}a=[];switch(b.writingMode){case _.os:a=["+y","-y"];break;case _.eg:a=["+x","-x"];break;case _.fg:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},jR=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=UQ(a.l.a)},kR=function(a,b){jR(a.g);a.l.unshift(b);
8
+ for(const c of a.l)a.g.append(c)},lR=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.vs)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(BQ);},nR=function(a,b,c,d){const e=document.createElement(_.Of),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);mR(a,c,b);a.h.debug(`Created HTML style element #${b}.`);return e.sheet},oR=function(a,b){a=`.${a.j} .clpp-text-container`;
9
+ const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},pR=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);
10
+ return c},qR=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.o=[]}},mR=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.h.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},rR=function(a){a=_.Ng(a.htmlcue||{});_.A(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.A(a.enableResizeObserver)&&(a.enableResizeObserver=
11
+ !0);return a},xR=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition();if(b||a.J!==c&&a.m.getState()===_.Wn)if(a.J=c,c=sR(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,tR(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.es(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.rg:g="clpp-text-vtt";
12
+ break;case _.Vf:g=DQ;break;case _.ms:g=CQ}g&&!f.classList.contains(g)&&_.so(f,g);f=UQ(c.a.a);if(0===f.width||0===f.height)c.h.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{MQ({fontSize:uR(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.rg;var h=d.payloadType===_.Vf;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new vR(d.region,
13
+ {}),c.B.set(d.region.id,f),kR(c.a,f)));d=new wR(d,c.L,e);f?kR(f,d):kR(c.a,d)}}}}},yR=function(a){tR(a);a.J=null;a.o=null;a.f=[]},zR=function(a,b){return a.startTime<=b&&a.endTime>b},sR=function(a,b){var c=IQ(a.f,d=>zR(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&zR(a.f[d-1],b);)d--;for(;c+1<a.f.length&&zR(a.f[c+1],b);)c++;return{start:d,end:c}}},tR=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(DQ);
14
+ b.classList.remove(CQ);a=a.a;jR(a.g);a.l=[]}},uR=function(a,b){const c=UQ(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.t&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},DR=class{parse(a){a={input:a};const b=_.uo(_.Fd),c=[];let d=b;for(var e;null!==(e=JQ(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);
15
+ else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=AR[f];h?(h=_.uo(h),(f=BR[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||CR[g.localName]&&CR[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(LQ(e)));return b}},AR={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},BR={v:"voice",lang:"lang"},CR={rt:"ruby"},KQ={"\x26amp;":"\x26",
16
+ "\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var TQ=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var ER=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var wR=class extends ER{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.g=!!this.f.backgroundImage;this.C=c}A(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.so(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.Vf){var c=_.uo(_.Fd);c.innerHTML=b.payload;b=c}else b.payloadType===
17
+ _.rg?b=(new DR).parse(b.payload):(c=_.uo(_.Fd),c.textContent=b.payload,b=c);_.so(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.so(b,d);MQ({writingMode:aR(this)},b);var d=b;this.a.appendChild(d);_.so(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.so(this.a,`clpp-text-wrapper__${e}`);_.A(this.f.line)&&(this.f.lineInterpretation=_.ps,this.f.line=ZQ(this)?-1:0);e=aR(this);MQ({writingMode:e,webkitWritingMode:e,direction:FQ,textAlign:bR(this)},this.a);if(!this.f.region||
18
+ !this.f.region.displayAlign){e=cR(this,dR(this));MQ({position:"absolute",left:gR(this,e,null),right:fR(this)&&_.A(null)?OQ(0,_.of):FQ,top:hR(this,e,null),width:ZQ(this)?OQ(this.f.size,"%"):FQ,height:eR(this)||fR(this)?OQ(this.f.size,"%"):FQ},this.a);b=this.f;a=ZQ(this)?a.height:a.width;c=$Q(this);if(b.lineInterpretation===_.ps){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.$c:g-=f/2;break;case _.Td:g-=f}f=Math.round(g/
19
+ 100*a)}fR(this)&&(f=a-f-c);a=f;MQ({left:gR(this,e,a),right:fR(this)&&_.A(a)?OQ(0,_.of):FQ,top:hR(this,e,a)},this.a)}NQ(this.C,d)}}o(){return _.uo(_.Fd)}};var FR=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=UQ(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.Zd;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=UQ(a.a);var d=iR(this,a.f),e=$Q(a);const g=VQ(c);let h=null,k=0;for(const l of d){for(;YQ(c,this.a,l)||XQ(c,this.a)&&WQ(c,this.g);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||XQ(c,this.a))break a;
20
+ d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=VQ(c),k=d);c=VQ(g)}c=h||g}MQ({top:OQ(c.top-this.a.top,_.of),bottom:OQ(this.a.a-c.a,_.of),left:OQ(c.left-this.a.left,_.of),right:OQ(this.a.f-c.f,_.of),height:OQ(c.height,_.of),width:OQ(c.width,_.of)},a.a)}b.style.visibility="visible";this.g.push(UQ(a.a))}};var GR=class extends ER{constructor(a,b,c){super(a,b,c);this.g=null;this.l=[]}init(){this.g=new FR(this);this.j=!0}o(){const a=_.uo(_.Fd);_.so(a,this.w);this.id&&(a.id=this.id);return a}};var vR=class extends GR{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.vs:b=b.width/100*a.width;break a;default:throw Error(BQ);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.vs)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(BQ);d=a.height;const e=lR(this,d,a.height);MQ(this.B,this.a);MQ({left:OQ(c,_.of),top:OQ(e,_.of),width:OQ(b,
21
+ _.of),height:OQ(d,_.of)},this.a);this.f.writingMode&&MQ({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&MQ({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.so(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.vs:f=f.height/100*a.height;break a;case 2:f=f.height;c=new wR(new _.ss(0,1,"Lorem ipsum",_.ms),{},{});b=c.a;this.a.appendChild(b);c.init(UQ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
22
+ b=c;f*=b;break a;default:throw Error(BQ);}a=lR(this,f,a.height);MQ({top:OQ(a,_.of),height:OQ(f,_.of)},this.a);this.g=new FR(this,!0);this.j=!0}getId(){return this.f.id}};var HR=class{constructor(a,b){this.h=new _.R("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.g=b;this.o=[];this.a=nR(this,this.g,this.j);this.f=nR(this,this.g,this.j,!0);this.f.disabled=!0;this.h.debug(`Stylesheet ${this.g} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=oR(this,a);if(pR(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.h.debug(`Added CSS rule ${b}`)}catch(c){this.h.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.h.warn(`Stylesheet ${this.g} ignoring the CSS rule `+
23
+ `because it's not safe: ${b}`)}}destroy(){const a=this;return _.x(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],qR(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.h.debug(`Stylesheet ${a.g} has been destroyed.`))})}};var IR=class extends _.ou{constructor(a){super(a);this.h=new _.R(EQ);this.m=a;this.L=rR(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new HR(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new GR(null,"clpp-text-container",{});this.A=new _.fu(a.getSurface(),this.T.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.h.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
24
+ this.G=new _.Qj(()=>{xR(this)});this.B=new Map;this.o=null}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=HQ(this.f,GQ(a));this.o=null;xR(this,!1)}}g(){null==this.j||xR(this,!0)}destroy(){const a=this;return _.x(function*(){null!=a.j&&(yR(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,a.l=!1)})}remove(a,b){if(null==this.j)return!1;
25
+ this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;xR(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.hb(.25),this.L.enableResizeObserver&&this.A.start(),xR(this,!0)):(this.G.stop(),this.A.stop(),yR(this)))}Oc(){return this.f}T(){xR(this,!0)}};_.z(EQ,IR);IR.prototype.setTextVisibility=IR.prototype.setTextVisibility;IR.prototype.isTextVisible=IR.prototype.isTextVisible;IR.prototype.remove=IR.prototype.remove;
26
+ IR.prototype.destroy=IR.prototype.destroy;IR.prototype.append=IR.prototype.append;var JR=class{isSupported(a){return!!a.enableHtmlCue&&!_.gk()}create(a){return new IR(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Pt{f(){_.An(_.$d,new JR)}a(){_.yn.has(_.$d)&&(_.yn.delete(_.$d),_.zn.info("Removed factory: 'html'"))}id(){return _.Pf}});};f.call(g, window);