@castlabs/prestoplay 6.6.1 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -110
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +418 -419
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +72 -72
  10. package/cjs/cl.externs.js +48 -42
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +68 -49
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +24 -23
  16. package/cjs/cl.mse.js +275 -261
  17. package/cjs/cl.muxdata.js +15 -12
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.smooth.js +71 -71
  22. package/cjs/cl.thumbnails.js +24 -24
  23. package/cjs/cl.tizen.js +71 -71
  24. package/cjs/cl.ttml.js +27 -27
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +19 -19
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +20 -20
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +88 -88
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +362 -365
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -67
  38. package/cl.externs.js +48 -42
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +58 -40
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +17 -16
  44. package/cl.mse.js +238 -228
  45. package/cl.muxdata.js +12 -8
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +10 -10
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -59
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -22
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +15 -15
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +15 -15
  58. package/package.json +1 -1
  59. package/typings.d.ts +147 -19
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 HI="clpp-freewheel",II="clpp.freewheel.AdsManagerFactory",JI="freewheel",KI=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""}},LI=function(a){const b=[];typeof a.networkId!==_.p&&b.push("networkId");typeof a.serverUrl!==_.ne&&b.push("serverUrl");typeof a.profileId!==_.ne&&b.push("profileId");typeof a.videoAssetId!==_.ne&&typeof a.videoAssetId!==_.p&&b.push("videoAssetId");
2
- if(b.length)throw new _.G(1,9,12001,{missingKeys:b.join(", ")});},MI=function(){return _.w(function*(){var a=new _.dq;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})},NI=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.l,_.ve,a.F.bind(a));a.g.on(a.l,_.ke,a.C.bind(a))},QI=function(a){return _.w(function*(){a.A.length?(OI(a),a.f=a.A.shift(),a.f.play()):(PI(a),yield a.l.a.play())})},PI=function(a){const b=a.l.Tb(JI).mc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},OI=function(a){const b=a.l.Tb(JI).mc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(HI),
4
- a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},RI=function(a){a.w.length?(OI(a),a.f=a.w.shift(),a.f.play()):PI(a)},SI=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 W(a.a,c,d)});a.l.trigger(new _.C(b,d))},TI=class extends _.jq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.lm(_.Qc,{id:HI}),this.f=_.lm(_.u,{"class":_.yc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
- !0),a.getSurface().hide(this.a);else a.onError(new _.G(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return JI}mc(){return this.a}pf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",TI);TI.prototype.getAdVideo=TI.prototype.pf;TI.prototype.getAdContainer=TI.prototype.mc;TI.Id=JI;TI.AD_CONTAINER_ID=HI;_.Sm(new class{create(){return new TI}});var W=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}mb(){return"FreeWheel AdManager SDK"}nb(){return tv.freewheel.SDK.version}sb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.ne?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
- 0}getSkipTimeOffset(){return 0}Xb(){return!1}Db(){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():""}pb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}ob(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}cb(){return 0}Oa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
- case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Oa()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Eb(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Fb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}rb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
- W.prototype.getWrapperCreativeIds=W.prototype.getWrapperCreativeIds;W.prototype.getWrapperAdSystems=W.prototype.getWrapperAdSystems;W.prototype.getWrapperAdIds=W.prototype.getWrapperAdIds;W.prototype.getSequenceLength=W.prototype.rb;W.prototype.getPositionInSequence=W.prototype.Fb;W.prototype.getPodTimeOffset=W.prototype.Eb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Oa;W.prototype.getMediaBitrate=W.prototype.cb;W.prototype.getMediaHeight=W.prototype.ob;
9
- W.prototype.getMediaWidth=W.prototype.pb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Db;W.prototype.isBumper=W.prototype.Xb;W.prototype.getSkipTimeOffset=W.prototype.getSkipTimeOffset;W.prototype.getDuration=W.prototype.getDuration;W.prototype.getTitle=W.prototype.getTitle;W.prototype.getAdvertiserName=W.prototype.getAdvertiserName;W.prototype.getAdSystem=W.prototype.getAdSystem;W.prototype.getApiFramework=W.prototype.getApiFramework;
10
- W.prototype.getCreativeId=W.prototype.getCreativeId;W.prototype.getId=W.prototype.getId;W.prototype.getTechnology=W.prototype.sb;W.prototype.getAdManagerVersion=W.prototype.nb;W.prototype.getAdManagerName=W.prototype.mb;var UI=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Gb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}eb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
- UI.prototype.hasPostroll=UI.prototype.eb;UI.prototype.hasPreroll=UI.prototype.Gb;UI.prototype.getCuePoints=UI.prototype.getCuePoints;var VI=class{constructor(a){this.B=new _.O("clpp.freewheel.AdsManager");this.l=a;this.g=new _.uo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Xk;this.h=null}load(){const a=this;return _.w(function*(){const b=a.l.getConfiguration().freewheel||{};try{LI(b)}catch(d){return a.l.onError(d),a.j.resolve(),a.j}a.o.setNetwork(b.networkId);a.o.setServer(b.serverUrl);a.a=a.o.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.ne&&typeof b.siteSectionId!==
12
- _.p||a.a.setSiteSection(b.siteSectionId);const c=yield MI();a.a.setVideoAsset(b.videoAssetId,a.l.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,KI(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Bd&&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);NI(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.w(function*(){yield QI(a)})}resume(){this.f&&this.f.resume()}pause(){this.f&&this.f.pause()}skip(){this.f&&this.f.skipCurrentAd()}getVolume(){return this.a?this.a.getAdVolume():1}setVolume(a){this.a&&this.a.setAdVolume(a)}getPosition(){return this.f?this.f.getPlayheadTime():-1}dispose(){const a=this;return _.w(function*(){a.g.release();
14
- a.h&&(a.h.stop(),a.h=null);PI(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.C(_.Ob,{adsTimeline:new UI(this.a)})),this.h=new _.bq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Tb(JI).f);else this.l.onError(new _.G(1,
15
- 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){SI(this,_.wb,a);this.h.start()}I(a){this.f=null;a=a.slot;SI(this,_.xb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:QI(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:PI(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:RI(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:SI(this,_.Kb,a);SI(this,
16
- _.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:SI(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:SI(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:SI(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:SI(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:SI(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:SI(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:SI(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:SI(this,
17
- _.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:SI(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:SI(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:SI(this,_.Hb,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.onError(new _.G(1,9,10003,{errorType:1},{fwCode:a[tv.freewheel.SDK.INFO_KEY_ERROR_CODE],fwInfo:a[tv.freewheel.SDK.INFO_KEY_ERROR_INFO],fwModule:a[tv.freewheel.SDK.INFO_KEY_ERROR_MODULE]}))}}F(){if(!this.f){var a=this.l.getPosition();if(this.f=this.m.find(b=>
18
- .5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();OI(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Sl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Rl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);RI(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- VI.prototype.getPosition=VI.prototype.getPosition;VI.prototype.setVolume=VI.prototype.setVolume;VI.prototype.getVolume=VI.prototype.getVolume;VI.prototype.skip=VI.prototype.skip;VI.prototype.pause=VI.prototype.pause;VI.prototype.resume=VI.prototype.resume;VI.prototype.start=VI.prototype.start;var WI=class{constructor(){this.a=new _.O(II)}name(){return II}da(a,b){return a.namespace()===_.Ac?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new VI(a)}};WI.prototype.create=WI.prototype.create;WI.prototype.isSupported=WI.prototype.da;WI.prototype.name=WI.prototype.name;_.im(new WI);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var eK="clpp-freewheel",fK="clpp.freewheel.AdsManagerFactory",gK="freewheel",hK=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""}},iK=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.me&&b.push("serverUrl");typeof a.profileId!==_.me&&b.push("profileId");typeof a.videoAssetId!==_.me&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},jK=function(){return _.y(function*(){var a=new _.Vp;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})},kK=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.l,_.ue,a.F.bind(a));a.g.on(a.l,_.je,a.C.bind(a))},nK=function(a){return _.y(function*(){a.A.length?(lK(a),a.f=a.A.shift(),a.f.play()):(mK(a),yield a.l.a.play())})},mK=function(a){const b=a.l.Ub(gK).qc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},lK=function(a){const b=a.l.Ub(gK).qc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(eK),
4
+ a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},oK=function(a){a.w.length?(lK(a),a.f=a.w.shift(),a.f.play()):mK(a)},pK=function(a,b,c){var d=null;a.a&&c&&(c.adInstance||c.slot)&&(c=(d=c.adInstance||null)?d.getSlot():c.slot,d={ad:new X(a.a,c,d)});a.l.trigger(new _.F(b,d))},qK=class extends _.aq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.am(_.Qc,{id:eK}),this.f=_.am(_.w,{"class":_.xc}),this.a.appendChild(this.f),a.getSurface().addElementToContainer(this.a,
5
+ !0),a.getSurface().hide(this.a);else a.onError(new _.H(1,9,12E3))}onPlayerWillDestroy(a){this.a&&(a.getSurface().removeElementFromContainer(this.a),this.f=this.a=null)}id(){return gK}qc(){return this.a}Bf(){return this.f}};_.A("clpp.freewheel.FreeWheelPlugin",qK);qK.prototype.getAdVideo=qK.prototype.Bf;qK.prototype.getAdContainer=qK.prototype.qc;qK.Id=gK;qK.AD_CONTAINER_ID=eK;_.Hm(new class{create(){return new qK}});var X=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}nb(){return"FreeWheel AdManager SDK"}ob(){return tv.freewheel.SDK.version}tb(){return 0}getId(){return this.a?this.a.getAdId():""}getCreativeId(){const a=(this.a||{})._creativeId;return typeof a===_.me?a:""}getApiFramework(){return this.a?this.a.getActiveCreativeRendition().getCreativeApi():""}getAdSystem(){return""}getAdvertiserName(){return""}getTitle(){return""}getDuration(){return this.a?this.a.getActiveCreativeRendition().getDuration():
6
+ 0}getSkipTimeOffset(){return 0}Yb(){return!1}Fb(){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():""}qb(){return this.a?this.a.getActiveCreativeRendition().getWidth():0}pb(){return this.a?this.a.getActiveCreativeRendition().getHeight():0}eb(){return 0}Qa(){switch(this.f.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;
7
+ case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return 2;default:return 1}}getPodIndex(){switch(this.Qa()){case 0:return 0;case 2:return-1}return this.g.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL).indexOf(this.f)+1}Gb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Hb(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}sb(){return this.f.getAdCount()}getWrapperAdIds(){return[]}getWrapperAdSystems(){return[]}getWrapperCreativeIds(){return[]}};
8
+ X.prototype.getWrapperCreativeIds=X.prototype.getWrapperCreativeIds;X.prototype.getWrapperAdSystems=X.prototype.getWrapperAdSystems;X.prototype.getWrapperAdIds=X.prototype.getWrapperAdIds;X.prototype.getSequenceLength=X.prototype.sb;X.prototype.getPositionInSequence=X.prototype.Hb;X.prototype.getPodTimeOffset=X.prototype.Gb;X.prototype.getPodIndex=X.prototype.getPodIndex;X.prototype.getPodType=X.prototype.Qa;X.prototype.getMediaBitrate=X.prototype.eb;X.prototype.getMediaHeight=X.prototype.pb;
9
+ X.prototype.getMediaWidth=X.prototype.qb;X.prototype.getMediaUrl=X.prototype.getMediaUrl;X.prototype.getClickThroughUrl=X.prototype.Fb;X.prototype.isBumper=X.prototype.Yb;X.prototype.getSkipTimeOffset=X.prototype.getSkipTimeOffset;X.prototype.getDuration=X.prototype.getDuration;X.prototype.getTitle=X.prototype.getTitle;X.prototype.getAdvertiserName=X.prototype.getAdvertiserName;X.prototype.getAdSystem=X.prototype.getAdSystem;X.prototype.getApiFramework=X.prototype.getApiFramework;
10
+ X.prototype.getCreativeId=X.prototype.getCreativeId;X.prototype.getId=X.prototype.getId;X.prototype.getTechnology=X.prototype.tb;X.prototype.getAdManagerVersion=X.prototype.ob;X.prototype.getAdManagerName=X.prototype.nb;var rK=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Ib(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ rK.prototype.hasPostroll=rK.prototype.fb;rK.prototype.hasPreroll=rK.prototype.Ib;rK.prototype.getCuePoints=rK.prototype.getCuePoints;var sK=class{constructor(a){this.B=new _.P("clpp.freewheel.AdsManager");this.l=a;this.g=new _.jo;this.o=new tv.freewheel.SDK.AdManager;this.f=this.a=null;this.A=[];this.m=[];this.w=[];this.j=new _.Mk;this.h=null}load(){const a=this;return _.y(function*(){const b=a.l.getConfiguration().freewheel||{};try{iK(b)}catch(d){return a.l.onError(d),a.j.resolve(),a.j}a.o.setNetwork(b.networkId);a.o.setServer(b.serverUrl);a.a=a.o.newContext();a.a.setProfile(b.profileId);typeof b.siteSectionId!==_.me&&typeof b.siteSectionId!==
12
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield jK();a.a.setVideoAsset(b.videoAssetId,a.l.getDuration(),void 0,void 0,c);if(Array.isArray(b.pods))for(const d of b.pods)a.a.addTemporalSlot(d.id,hK(d.type),d.position,d.slotProfile,d.cuepointSequence,d.maxDuration,d.minDuration,d.acceptContentType);b.keyValues&&typeof b.keyValues===_.Bd&&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);kK(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.y(function*(){yield nK(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 _.y(function*(){a.g.release();
14
+ a.h&&(a.h.stop(),a.h=null);mK(a);a.a&&(a.a.dispose(),a.a=null)})}H(a){if(a.success)this.A=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL),this.m=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL),this.w=this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL),this.l.trigger(new _.F(_.Nb,{adsTimeline:new rK(this.a)})),this.h=new _.Tp(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Ub(gK).f);else this.l.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){pK(this,_.wb,a);this.h.start()}I(a){this.f=null;a=a.slot;pK(this,_.xb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:nK(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:mK(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:oK(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:pK(this,_.Jb,a);pK(this,
16
+ _.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:pK(this,_.Kb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:pK(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:pK(this,_.Eb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:pK(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:pK(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:pK(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:pK(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:pK(this,
17
+ _.Hb,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:pK(this,_.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:pK(this,_.yb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:pK(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_ERROR:this.l.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.l.getPosition();if(this.f=this.m.find(b=>
18
+ .5>Math.abs(a-b.getTimePosition()))||null){const b=this.m.findIndex(c=>c===this.f);this.m.splice(b,1);this.l.pause();lK(this);this.f.play()}}}C(a){if((a=a.detail)&&this.a)switch(a.currentState){case _.Hl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PLAYING);break;case _.Gl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_PAUSED);break;case _.wl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_COMPLETED);oK(this);break;case _.El:case _.Dl:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ sK.prototype.getPosition=sK.prototype.getPosition;sK.prototype.setVolume=sK.prototype.setVolume;sK.prototype.getVolume=sK.prototype.getVolume;sK.prototype.skip=sK.prototype.skip;sK.prototype.pause=sK.prototype.pause;sK.prototype.resume=sK.prototype.resume;sK.prototype.start=sK.prototype.start;var tK=class{constructor(){this.a=new _.P(fK)}name(){return fK}da(a,b){return a.namespace()===_.zc?!1:window.tv&&tv.freewheel&&tv.freewheel.SDK?!(!b||!b.freewheel):(this.a.warn("FreeWheel SDK is not loaded."),!1)}create(a){return new sK(a)}};tK.prototype.create=tK.prototype.create;tK.prototype.isSupported=tK.prototype.da;tK.prototype.name=tK.prototype.name;_.Yl(new tK);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,40 +1,58 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mz="CLOSED-CAPTIONS",Nz="Could not parse MP4 segment start time.",Oz="EXT-X-BYTERANGE",Pz="EXT-X-DISCONTINUITY",Qz="EXT-X-DISCONTINUITY-SEQUENCE",Rz="EXT-X-ENDLIST",Sz="EXT-X-MAP",Tz="EXT-X-MEDIA-SEQUENCE",Uz="EXT-X-PART-INF",Vz="EXT-X-PLAYLIST-TYPE",Wz="EXT-X-PRELOAD-HINT",Xz="EXT-X-SERVER-CONTROL",Yz="EXT-X-STREAM-INF",Zz="EXT-X-TARGETDURATION",$z="EXTINF",aA="Guessing audio-only",bA="SAMPLE-AES-CTR",cA="SUBTITLES",dA="application/vnd.apple.mpegurl",eA=function(a,b){a=a.getAttribute(b);
2
- if(!a)throw new _.G(_.F,4,4023,b);return a.value},fA=function(a){if(1>a.a)throw _.xj();--a.a},gA=function(a,b){return a.filter(c=>c.name==b)},hA=function(a,b){return a.filter(c=>eA(c,"TYPE")===b)},iA=function(a,b){a=gA(a,b);return a.length?a[0]:null},jA=function(a,b){return _.wu([a],[b])[0]},nA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.yg(a.a++,h),kA.includes(h.name)?d.push(h):lA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===Wz&&"PART"===_.rg(h,
3
- "TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=jA(b,h.trim()),e.push(new mA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new mA(null,f,g));return{$:e,fa:d}},oA=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},pA=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.G(_.F,
4
- 4,4030);}oA(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}}oA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},qA=function(a,
5
- b){let c=null,d=0;try{(new _.Mj).M(_.wd,_.N).M(_.we,_.N).M(_.rd,_.N).X("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.M(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.eq.error("Unable to find timescale in init segment!"),new _.G(_.F,4,4030,Nz,c);let e=0,f=!1;try{(new _.Mj).M("moof",_.N).M("traf",_.N).X("tfdt",g=>{e=(0==g.version?_.M(g.reader):_.Cj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.G(_.F,4,4030,Nz,c);return e},rA=function(a){for(;a.getPosition()<
6
- a.wa()-1;){const b=a.getPosition();if(71===_.yj(a))return fA(a),b}return-1},sA=function(a){function b(){d.seek(e+188);f=_.yj(d);71!=f&&(d.seek(e+192),f=_.yj(d));71!=f&&(d.seek(e+204),f=_.yj(d));71!=f&&c();fA(d)}function c(){throw new _.G(_.F,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=rA(d);0>e&&(_.eq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.yj(d);71!=f&&c();a=_.zj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.yj(d)&
7
- 48)>>4;0!=a&&2!=a||c();3==a&&(a=_.yj(d),d.skip(a));if(1!=_.M(d)>>8){b();continue}d.skip(3);a=_.yj(d)>>6;0!=a&&1!=a||c();0==_.yj(d)&&c();a=_.yj(d);const g=_.zj(d),h=_.zj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},tA=function(a,b,c){return _.w(function*(){const d=b.f(),e=_.Qu(b.Ca(),b.Ta,b.Ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Qu(b.Ca(),b.Ta,b.Ja,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===g.code||c)throw g;
8
- a.f.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",e.uris[0]);try{return yield a.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.G(_.F,4,4030,"Failed to fetch the media segment.");}}})},uA=function(a,b,c,d,e,f){return _.w(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.dc||d===
9
- _.cc)return 0;if(d===_.bc){var g=yield tA(a,c,f);const h=_.H(g.data);return oA(h)?pA(h):sA(g.data)}if(d===_.Je||d===_.ec)return g=[tA(a,c,f)],b&&g.push(tA(a,b,!0)),g=yield Promise.all(g),qA(g[0].data,(g[1]||g[0]).data);if(d===_.Ie)return g=yield tA(a,c,f),sA(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.G(_.F,4,4030);})},vA=function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("PlayReady in HLS is only supported with [",
10
- c.join(", "),"], not",b),null;a=eA(a,_.mb);b=_.go(a);a=null;b=_.H(b.data);try{a=_.nu(_.Fk(b))}catch(d){a=b}return _.xu(_.Jc,[{initDataType:_.tc,initData:a}],"")},wA=function(a,b){return _.w(function*(){var c=_.bh([b],a.g.attemptParameters);c.type=1;c=yield a.R(c);let d="";try{d=_.Ig(c.data)}catch(e){throw new _.G(_.F,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},DA=function(a,b){return _.w(function*(){var c=xA(a,b,a.w,"");if(1===c.type){a.G.set(a.w,c);c=
11
- _.Qo(c.$[0].a)||"";c=null!=_.Po.video[c]?_.u:null!=_.Po.audio[c]?_.ac:null;var d="";c===_.u?d="avc1.42E01E":c===_.ac&&(d="mp4a.40.2");{c=a.aa;var e=a.w;d=a.g.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.wg(_.ka,"0"));k.push(new _.wg(_.mb,e));d.length&&k.push(new _.wg(_.ma,d));h.push(new _.xg(c.a++,Yz,k));c=new yA(e,0,h)}}c=yield zA(a,c.fa);if(!a.D)throw new _.G(_.F,7,7001);a.D.filterAllPeriods([c]);d=e=Infinity;for(var f of a.a.values())e=Math.min(e,f.Dd),f.type!==_.r&&(d=Math.min(d,f.duration));
12
- a.j===AA?a.h=new _.Bz(null,0,!0):(a.h=new _.Bz(0,a.S,!1),_.Uu(a.h,1));BA(a);if(a.j===AA){a.h.Lb(d);a.h.offset(-e);for(const h of a.a.values())h.segmentIndex.offset(-e),_.gv(h.segmentIndex,d)}else{a.V=a.F;a.j===CA&&(f=Math.max(d,a.h.Md),isNaN(a.g.availabilityWindowOverride)||(f=a.g.availabilityWindowOverride),a.h.Zb=f);f=0;for(var g of a.a.values())f=Math.max(f,g.Dd);for(g=0;95443.7176888889<=f;)g+=95443.7176888889,f-=95443.7176888889;if(g){a.f.debug("Offsetting live streams by",g,"to compensate for rollover");
13
- for(const h of a.a.values())95443.7176888889>h.Dd?(a.f.debug("Offset applied to",h.type),h.segmentIndex.offset(g)):a.f.debug("Offset NOT applied to",h.type)}}return{presentationTimeline:a.h,periods:[c],offlineSessionIds:[],minBufferTime:0}})},GA=function(a,b){return _.w(function*(){var c=new _.eg(b.Ue);if(a.g.hlsLowLatency){var d=c.a;if(b.$e){var e=b.segmentIndex;if(e=e.a[e.a.length-1]){var f=e.a,g=f.length-1;e={Bf:e.position,Hf:f&&0<f.length?g:null}}else e=null;const {Bf:l,Hf:m}=e;null!==l&&(d.add("_HLS_msn",
14
- l),null!==m&&d.add("_HLS_part",m))}e=d;_.pg(e);e.g&&_.hg(c,d)}const {response:h,text:k}=yield wA(a,c.toString());c=xA(a,k,h.uri,b.Jc);if(1!==c.type)throw new _.G(_.F,4,4017);d=yield EA(a,b.Jc,c,b.type,b.mimeType,b.codecs,b.keyInfo||null,b.ef);b.$=d;b.segmentIndex.replace(d);d=d[d.length-1];iA(c.fa,Rz)&&(FA(a,AA),a.h.Lb(d.endTime))})},xA=function(a,b,c,d){a:{a=a.aa;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.G(_.F,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||
15
- /^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.yg(0,h),kA.includes(e.name)){f=1;break}else e.name===Yz&&(g=!0)}h=f;f=[];g=!0;for(var k of _.yu(b)){let {Wc:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.yg(a.a++,e);if(HA.includes(e.name)){if(1!==h)throw new _.G(_.F,4,4017);k=b.splice(l,b.length-l);a=nA(a,c,k);c=new yA(c,h,f.concat(a.fa),a.$);break a}f.push(e);e.name===Yz&&(e.attributes.push(new _.wg(_.mb,n)),g=!0)}}c=new yA(c,h,f)}c.f=d;return c},EA=function(a,b,c,
16
- d,e,f,g,h){return _.w(function*(){var k=c.$;const l=IA(c,g);var m=(m=iA(c.fa,Tz))?Number(m.value):0;null===a.J&&(a.J=yield JA(a,b,l,k[0],m,g,e,f,d));const n=a.J;a.f.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=iA(c.fa,Qz);let t=q?Number(q.value):0;h.has(t)||h.set(t,m);if(!q)for(;h.has(t+1)&&h.get(t+1)<m;)t++;q=a.H.get(t)||0;const v=[];for(const E of _.yu(k)){var y=E.Wc;k=E.item;{var A=v[v.length-1];const D=0==y?n:A.endTime;y=m+y;iA(k.fa,Pz)&&(t++,h.set(t,y),q=yield KA(a,t,b,
17
- l,k,y,g,e,f,D,d));A=LA(a,A,k,y,D,q,g,d,c.a);k=iA(k.fa,$z);A&&(a.g.hlsLowLatency||k)&&v.push(A)}}a.U.push(v);BA(a);return v})},FA=function(a,b){a.j=b;if(a.h){b=a.h;var c=a.j===AA;b.j=c;b.m=c}a.j===AA&&a.o.stop()},zA=function(a,b){return _.w(function*(){var c=gA(b,"EXT-X-MEDIA"),d=gA(b,Yz),e=gA(b,"EXT-X-IMAGE-STREAM-INF");var f=new Map;for(var g of d){var h=_.rg(g,"AUDIO"),k=_.rg(g,"VIDEO"),l=_.rg(g,cA);const m=MA(a,g);if(l){const n=_.Fh(_.r,m);f.set(l,n);l=m.indexOf(n);-1<l&&m.splice(l,1)}h&&(l=NA(_.ac,
18
- m),f.set(h,l));k&&(h=NA(_.u,m),f.set(k,h))}a.B=f;yield OA(a,c);f=hA(c,Mz);for(const m of f)f=PA(m),g=eA(m,_.Ca),k=eA(m,"INSTREAM-ID"),a.I.get(g)||a.I.set(g,new Map),a.I.get(g).set(k,f);d=yield QA(a,d);c=yield RA(a,c);e=yield SA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},OA=function(a,b){return _.w(function*(){b=b.filter(d=>{const e=_.rg(d,_.mb)||"";return _.rg(d,"TYPE")!==cA&&""!==e});b.length&&(yield TA(a,b[0]));const c=b.slice(1).map(d=>TA(a,d));yield Promise.all(c)})},
19
- QA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=_.rg(f,"FRAME-RATE"),h=Number(eA(f,_.ka));var k=_.rg(f,_.Za);const [l,m]=k?k.split("x"):[null,null];return(k=yield UA(a,f,k,g))?VA(a,k.audio,k.video,h,l,m,g):[]});let d=0;var e=Infinity;for(let f=0;f<b.length;++f){const g=Number(eA(b[f],_.ka));g<e&&(e=g,d=f)}e=b.splice(d,1).pop();e=yield c(e);c=b.map(c);c=yield Promise.all(c);c.splice(d,0,e);return c.reduce(_.uu,[]).filter(_.dg)})},RA=function(a,b){return _.w(function*(){var c=
20
- hA(b,cA),d=c.map(f=>_.w(function*(){try{return yield TA(a,f)}catch(g){throw g;}}));d=yield Promise.all(d);for(const f of c){var e=eA(f,_.Ca);if(c=a.B.get(e))if(e=a.m.get(e))for(const g of e)g.codecs=c}return d.filter(f=>f)})},SA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return WA(a,d)}));return(yield Promise.all(c)).filter(d=>d)})},MA=function(a,b){var c=_.rg(b,_.ma,a.g.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
21
- _.Fu(e)[0],b.has(c)?a.f.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},NA=function(a,b){if(1===b.length)return b[0];a=_.Fh(a,b);if(null!=a)return a;throw new _.G(_.F,4,4025,{codecList:b});},TA=function(a,b){return _.w(function*(){const c=eA(b,_.Ca);var d="";let e=eA(b,"TYPE").toLowerCase();e===_.gu&&(e=_.r);e!==_.r&&c&&a.B.has(c)&&(d=a.B.get(c));const f=eA(b,_.mb);if(a.a.has(f))return a.a.get(f);const g=PA(b),h=_.rg(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),
22
- m=_.rg(b,"CHANNELS");d=yield XA(a,f,d,e,g,!!k&&!!l,h,e==_.ac?m?parseInt(m.split("/")[0],10):null:null,null);a.m.has(c)?a.m.get(c).push(d):a.m.set(c,[d]);if(a.a.has(f))return a.a.get(f);a.a.set(f,d);return d})},WA=function(a,b){return _.w(function*(){const c=eA(b,_.mb);if(a.a.has(c))return a.a.get(c);var d=_.rg(b,_.ma)||"jpg",e=PA(b);const f=_.rg(b,"NAME");d=yield XA(a,c,d,_.ed,e,!1,f,null,null);if(a.a.has(c))return a.a.get(c);if(e=_.rg(b,_.ka))d.bandwidth=Number(e);a.a.set(c,d);return d})},UA=function(a,
23
- b,c,d){return _.w(function*(){let e=MA(a,b);var f=_.rg(b,"AUDIO"),g=_.rg(b,"VIDEO"),h=f||g;h=h&&a.m.has(h)?a.m.get(h):[];f={audio:f?h:[],video:g?h:[]};a.f.debug("Guessing stream type for",b.toString());g=!1;const k=eA(b,_.mb);var l=f.audio.find(n=>n.Jc===k),m=_.Fh(_.u,e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.f.debug("Guessing multiplexed audio+video"),h=_.u,e=[e.join(",")]):f.audio.length&&l?(a.f.debug(aA),h=_.ac,g=!0):f.video.length?(a.f.debug(aA),h=_.ac):(a.f.debug("Guessing video-only"),
24
- h=_.u):(h=_.ac,a.f.debug(aA));l=null;g||(l=yield YA(a,b,e,h));if(l)f[l.type]=[l];else if(null===l)return a.f.debug("stream is null"),null;ZA(f);return f})},VA=function(a,b,c,d,e,f,g){c.forEach(l=>{l&&(l.width=Number(e)||void 0,l.height=Number(f)||void 0,l.frameRate=Number(g)||void 0)});b.length||(b=[null]);c.length||(c=[null]);const h=[];for(const l of b)for(const m of c){var k=l?l.drmInfos:null;const n=m?m.drmInfos:null;b=(m?m.Jc:"")+" - "+(l?l.Jc:"");let q;if(l&&m)if(k.length&&n.length?0<_.Hu(k,
25
- n).length:1)q=_.Hu(k,n);else{a.f.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else l?q=k:m&&(q=n);a.W.has(b)?a.f.debug("Skipping variant which only differs in text streams."):(k=$A(a,l,m,d,q),h.push(k),a.W.add(b))}return h},YA=function(a,b,c,d){return _.w(function*(){const e=eA(b,_.mb);if(a.a.has(e))return a.a.get(e);var f=_.rg(b,Mz),g=null;d==_.u&&f&&"NONE"!==f&&(g=a.I.get(f));f=NA(d,c);g=yield XA(a,e,f,d,_.ye,!1,null,null,g);if(a.a.has(e))return a.a.get(e);a.a.set(e,g);return g})},
26
- ZA=function(a){for(const b of a.audio.concat(a.video))a=b.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!==c),b.codecs=a.join(",")},$A=function(a,b,c,d,e){return{id:a.Z++,language:b?b.language:_.ye,primary:!!b&&b.primary||!!c&&c.primary,audio:b,video:c,bandwidth:d,drmInfos:e,allowedByApplication:!0,allowedByKeySystem:!0}},PA=function(a){a=_.rg(a,"LANGUAGE")||_.ye;return _.Nh(a)},XA=function(a,b,c,d,e,f,g,h,k){return _.w(function*(){let l=jA(a.w,b);var m=null;if(a.j===AA&&a.G.has(l)){var n=a.G.get(l);
27
- a.G.delete(l)}else{const {response:rb,text:pa}=yield wA(a,l);l=rb.uri;n=xA(a,pa,l,b)}if(1!==n.type)throw new _.G(_.F,4,4017);aB(a,n);const q=yield bB(a,d,c,n),t=[];n.$.forEach(rb=>{rb=gA(rb.fa,"EXT-X-KEY");t.push.apply(t,rb)});let v=!1;const y=[];let A=null;for(var E of t){var D=eA(E,"METHOD"),ha=_.rg(E,"KEYFORMAT","identity");"NONE"!==D&&("AES-128"===D?(m=_.rg(E,"IV",""),m={method:"AES-128",url:jA(a.w,eA(E,_.mb)),iv:m?_.gj((m||"0x").slice(2)):null},a.L=!0):(v=!0,(D=(D=cB[ha])?D(E,q):null)?(D.keyIds.length&&
28
- (A=D.keyIds[0]),y.push(D)):a.f.warn("Unsupported HLS KEYFORMAT",ha)))}if(v&&!y.length&&!a.L)throw new _.G(_.F,4,4026);E=new Map;ha=yield EA(a,b,n,d,q,c,m,E);D=ha[0].startTime;const gb=ha[ha.length-1].endTime,vf=gb-D,yb=new _.Cz(ha),wf=a.g.hlsLowLatency?_.zx:_.Yt,Ta=IA(n,m);let Hd=void 0;d==_.r&&(Hd=_.fu);n=(n=iA(n.fa,Xz))?"YES"===_.rg(n,"CAN-BLOCK-RELOAD"):!1;return{id:a.Z++,originalId:g,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:yb.f.bind(yb),getSegmentReference:yb.get.bind(yb),
29
- adjustSegmentDurations:yb.g.bind(yb),getDuration:yb.getDuration.bind(yb),segmentIndex:yb,segmentLookupStrategy:wf,initSegmentReference:Ta,mimeType:q,codecs:c,kind:Hd,encrypted:v,keyId:A,language:e,label:g,type:d,primary:f,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:void 0,width:void 0,height:void 0,bandwidth:void 0,roles:[],channelsCount:h,closedCaptions:k,keyInfo:m,$:ha,drmInfos:y,Jc:b,Ue:l,Dd:D,qg:gb,duration:vf,ef:E,$e:n}})},aB=function(a,b){var c=iA(b.fa,Vz),d=iA(b.fa,Rz);d=c&&"VOD"===
30
- c.value||d;c=c&&"EVENT"===c.value&&!d;c=!d&&!c;if(d)FA(a,AA);else{c?FA(a,CA):FA(a,dB);d=iA(b.fa,Zz);if(!d)throw new _.G(_.F,4,4024,{missingTag:Zz});d=Number(d.value);c=iA(b.fa,Uz);a.g.hlsLowLatency&&c?(d=Number(eA(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.C=Math.max(d,a.C),b=iA(b.fa,Xz),a.S=b?Number(eA(b,"PART-HOLD-BACK")):0):(a.C=Math.max(d,a.C),a.F=Math.min(d,a.F),a.S=3*a.C)}},bB=function(a,b,c,d){return _.w(function*(){var e=d.$[0];const f=e.a;e=(e=iA(e.fa,Sz))?eA(e,_.mb):null;return eB(a,b,c,f,
31
- e)})},IA=function(a,b){var c=gA(a.$[0].fa,Sz);if(!c.length)return null;if(1<a.$.map(f=>gA(f.fa,Sz)).reduce((f,g)=>f.concat(g),[]).length)throw new _.G(_.F,4,4020);c=c[0];var d=eA(c,_.mb);const e=jA(a.a,d);a=0;d=null;if(c=_.rg(c,"BYTERANGE"))a=c.split("@"),c=Number(a[0]),a=Number(a[1]),d=a+c-1;return new _.Az(()=>[e],a,d,b)},BA=function(a){a.h&&(a.U.forEach(b=>{_.Tu(a.h,b,0)}),a.U=[])},fB=function(a,b){var c=0;let d=null;b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ja+1,d=c+b-1);return[c,
32
- d]},hB=function(a,b,c,d,e,f,g){const h=[];for(const n of _.yu(b.f)){b=n.Wc;const q=n.item;{var k=0==b?a:h[h.length-1],l=0==b?d:k.endTime,m=Number(_.rg(q,"DURATION"));m=l+m;const t=_.rg(q,"BYTERANGE"),[v,y]=fB(k,t);k=_.rg(q,_.mb);const A=(k=jA(g,k))?[k]:[];l=new gB(c,l,m,()=>A,v,y,e,f,!1,null,null,null,null);if("YES"===_.rg(q,"INDEPENDENT")||0===b)l.g=!0;h.push(l)}}return h},LA=function(a,b,c,d,e,f,g,h,k){var l=c.fa,m=c.a;const n=m?[m]:[];m=iA(l,$z);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.jj(new Uint8Array(12),
33
- new Uint8Array([d>>24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,v=null;h===_.ed&&(t=iA(l,"EXT-X-TILES"),q="1x1",t&&(q=_.rg(t,"LAYOUT")||"1x1",v=(v=_.rg(t,"DURATION"))?Number(v):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.G(_.F,4,4024,{missingTag:$z});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=hB(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+Number(m.value.split(",")[0]),l=iA(l,Oz),[c,k]=fB(b,l?l.value:null)):a=h[h.length-1].endTime;return new gB(d,
34
- e,a,()=>n,c,k,f,g,!1,null,q,t,v,h)},JA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){const m=LA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.N&&!l){{var n=m.position;const q=a.a.get(b);n=q?(n=q.segmentIndex.get(n))?n.startTime:null:null}if(null!=n)return a.f.debug("Found segment start time in previous manifest"),n;a.f.debug("Unable to find segment start time in previous manifest!")}return uA(a.ca,c,m,g,h,a.L)})},KA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.H.has(b)?n=a.H.get(b):
35
- (n=(yield JA(a,c,d,e,f,g,h,k,m,!0))-l,a.f.debug("Discontinuity segment offset",n),a.H.set(b,n));return n})},eB=function(a,b,c,d,e){return _.w(function*(){const f=[d,e].filter(Boolean);var g=_.Ih(f,b,c);if(g)return g;g=_.bh([d],a.g.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.R(g)).headers["content-type"];if(!g)throw new _.G(_.F,4,4021,f.join(", "));return g.split(";")[0]})},yA=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.G(_.F,4,4043,"Media playlist must have at least one segment!");
36
- if(null==d[0].a)throw new _.G(_.F,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.f="";this.type=b;this.fa=c;this.$=1===b?d:null}},mA=class{constructor(a,b,c){c=void 0===c?[]:c;this.fa=b;this.a=a;this.f=c}},kA=[Qz,Rz,"EXT-X-I-FRAMES-ONLY",Tz,Uz,Vz,Xz,Zz],HA=[$z,Oz,"EXT-X-DATERANGE",Pz,"EXT-X-KEY",Sz,"EXT-X-PROGRAM-DATE-TIME"],lA=["EXT-X-PART",Wz],iB=class{constructor(){this.a=0}},jB=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.Zg()}}};var gB=class extends _.bv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,h,k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0}};var kB=class{constructor(){this.g=this.D=null;this.Z=1;this.S=0;this.m=new Map;this.W=new Set;this.a=new Map;this.h=null;this.w="";this.aa=new iB;this.V=0;this.K=new Map;this.o=new _.Th(()=>{this.vb()});this.j=AA;this.N=null;this.C=0;this.F=Infinity;this.A=new _.So;this.U=[];this.I=new Map;this.L=!1;this.B=new Map;this.J=null;this.f=new _.O("clpp.hls.HlsParser");this.G=new Map;this.H=new Map;this.ca=new jB(this.R.bind(this))}configure(a){this.g=a;this.ca.a=a}setCurrentVariant(a){const b=a.video?a.video.id:
37
- null;a=a.audio?a.audio.id:null;this.K.clear();for(const c of this.a.keys()){const d=this.a.get(c);d.id!==b&&d.id!==a||this.K.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.D=b;const {response:d,text:e}=yield wA(c,a);c.w=d.uri;const f=yield DA(c,e);c.N=f;const g=c.V;0<g&&c.o.ba(g);return f})}stop(){this.o&&(this.o.stop(),this.o=null);const a=[];this.A&&(a.push(this.A.destroy()),this.A=null);this.g=this.D=null;this.W.clear();this.a.clear();this.G.clear();this.N=null;this.m.clear();this.B.clear();
38
- return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.j!==AA){var b=[];a.J=null;var c=Array.from(a.a.values()),d=Array.from(a.K.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield GA(a,c[0]);for(d=1;d<c.length;d++)b.push(GA(a,c[d]));yield Promise.all(b)}})}onExpirationUpdated(){}vb(){const a=this;return _.w(function*(){a.f.debug(_.Rt);if(a.D)try{yield a.update(),a.o.ba(a.V)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.o.ba(.1))}})}R(a){if(!this.A)throw new _.G(_.F,7,7001);a=this.D.networkingEngine.fetch(a);
39
- _.ih(this.A,a);return a.P}},cB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Ie)throw new _.G(_.F,4,4041);return _.xu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":vA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":vA,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=eA(a,"METHOD");const c=["SAMPLE-AES",bA];if(!c.includes(b))return _.Jf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=eA(a,_.mb);b=_.go(b);
40
- b=_.H(b.data);b=_.xu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.rg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},AA="VOD",dB="EVENT",CA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Lp{constructor(){super()}f(){_.Kn.m3u8=kB;_.In[_.Pi]=kB;_.In[dA]=kB}a(){_.jv("m3u8");_.kv(_.Pi);_.kv(dA)}id(){return"hls"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var eA="CLOSED-CAPTIONS",fA="Could not parse MP4 segment start time.",gA="EXT-X-BYTERANGE",hA="EXT-X-DISCONTINUITY",iA="EXT-X-DISCONTINUITY-SEQUENCE",jA="EXT-X-ENDLIST",kA="EXT-X-KEY",lA="EXT-X-MAP",mA="EXT-X-MEDIA-SEQUENCE",nA="EXT-X-PART-INF",oA="EXT-X-PLAYLIST-TYPE",pA="EXT-X-PRELOAD-HINT",qA="EXT-X-SERVER-CONTROL",rA="EXT-X-STREAM-INF",sA="EXT-X-TARGETDURATION",tA="Failed to infer discontinuity number",uA="Guessing audio-only",vA="METHOD",wA="SAMPLE-AES-CTR",xA="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",
2
+ yA="application/vnd.apple.mpegurl",zA="sample",AA="whole-segment",BA=function(a,b){return _.pg(a,b,void 0,{required:!0})},CA=function(a){if(1>a.a)throw _.vj();--a.a},DA=function(a){if(null!==a&&void 0!==a)return Number(a)},EA=function(a,b){return a.filter(c=>c.name===b)},FA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=BA(d,"TYPE");return c.includes(d)})},GA=function(a,b){return a.some(c=>c.name===b)},HA=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,
3
+ 4,4024,{missingTag:b});return a},IA=function(a){var b=HA(a,"EXT-X-TILES");if(!b)return{we:1,Xe:1,durationPerTile:null};a=_.pg(b,"LAYOUT")||"1x1";b=(b=_.pg(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{we:c,Xe:d,durationPerTile:b}},JA=function(a,b){return _.uu([a],[b])[0]},KA=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)},
4
+ LA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of KA(c))b(d,c)})},MA=function(a){return a.type===_.p||a.type===_.w},NA=function(a){const b=HA(a,oA);if(HA(a,jA))return _.Rt;if(!b)return"LIVE";if(b.value===_.Rt)return _.Rt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);},OA=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.H(_.G,4,4044,"Byte range length must be positive.");
5
+ if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ta:d,ha:e}},PA=function(a,b){a=HA(a,gA);return OA(a?a.value:null,b)},QA=function(a){a=HA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||
6
+ null}},RA=function(a,b){b=void 0===b?{}:b;const c={Rc:!1,lf:!1,mf:null,Kf:null,Ke:null};a=HA(a,qA,{required:b.Oe});if(!a)return c;const d=e=>null==e?null:Number(e);c.Rc="YES"===_.pg(a,"CAN-BLOCK-RELOAD");c.lf="YES"===_.pg(a,"CAN-SKIP-DATERANGES");c.mf=d(_.pg(a,"CAN-SKIP-UNTIL"));c.Kf=d(_.pg(a,"HOLD-BACK"));c.Ke=d(_.pg(a,"PART-HOLD-BACK",void 0,{required:b.Oe}));return c},SA=function(a,b,c){c=void 0===c?!1:c;a=_.pg(a,"BYTERANGE");return OA(a,b,c)},UA=function(a,b){const c=PA(a.$,null);return new TA(0,
7
+ 0,0,()=>[a.a],c.ta,c.ha,0,b)},VA=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.$g(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},WA=function(a){let b=Infinity,c=Infinity;KA(a).filter(MA).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{$b:b,duration:c}},XA=function(a){return a.map(b=>{({duration:b}=WA(b));return b}).reduce((b,c)=>b+c,0)},YA=function(a,b,c){if(b===
8
+ _.Rt)return{delay:0,Oc:0};b=HA(a,nA);if(c&&b)return c=Number(BA(b,"PART-TARGET")),{Ke:a}=RA(a,{Oe:!0}),{delay:a,Oc:c};a=HA(a,sA,{required:!0});a=Number(a.value);return{delay:3*a,Oc:a}},ZA=function(a){const b=[];LA(a,c=>{b.push(c.Sf)});return{delay:Math.max(...b.map(c=>c.delay)),Oc:Math.min(...b.map(c=>c.Oc))}},$A=function(a){const b=new Map;a.forEach(c=>{var d=c.ea[0].groupId;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},aB=function(a){a=_.pg(a,"LANGUAGE")||_.xe;return _.rg(a)},
9
+ cB=function(a){a=a.audio.concat(a.video);for(const b of a)a=b.ea[0].codecs.split(",").filter(c=>"mp4a.40.34"!==c),bB(b,a)},gB=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.eh(a.a++,h),dB.includes(h.name)?d.push(h):eB.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===pA&&"PART"===_.pg(h,"TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=JA(b,h.trim()),e.push(new fB(h,f,g)),f=[],g=[])});0<g.length&&e.push(new fB(null,f,g));return{V:e,$:d}},hB=function(a){return 0>
10
+ a?[]:Array.from({length:a},(b,c)=>c)},iB=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},jB=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}iB(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],
11
+ 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}}iB(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},kB=function(a,b){let c=null,d=0;try{(new _.Lj).M(_.wd,_.Ej).M(_.ve,_.Ej).M(_.rd,_.Ej).Z("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,
12
+ !0)}catch(g){c=g}if(c||!d)throw _.Wp.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,fA,c);let e=0,f=!1;try{(new _.Lj).M("moof",_.Ej).M("traf",_.Ej).Z("tfdt",g=>{e=(0==g.version?_.N(g.reader):_.Aj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.G,4,4030,fA,c);return e},lB=function(a){for(;a.getPosition()<a.za()-1;){const b=a.getPosition();if(71===_.wj(a))return CA(a),b}return-1},mB=function(a){function b(){d.seek(e+188);f=_.wj(d);71!=f&&
13
+ (d.seek(e+192),f=_.wj(d));71!=f&&(d.seek(e+204),f=_.wj(d));71!=f&&c();CA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.qk(new DataView(a),!1);let e=0,f=0;e=lB(d);0>e&&(_.Wp.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.wj(d);71!=f&&c();a=_.xj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.wj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.wj(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.wj(d)>>6;0!=a&&1!=a||c();0==_.wj(d)&&
14
+ c();a=_.wj(d);const g=_.xj(d),h=_.xj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},pB=function(a){var b=BA(a,vA);if(!nB.includes(b))return oB.error("PlayReady in HLS is only supported with [",nB.join(", "),"], not",b),null;a=BA(a,_.lb);b=_.Vn(a);a=null;b=_.I(b.data);try{a=_.nu(_.Xu(b))}catch(c){a=b}return _.vu(_.Ic,[{initDataType:_.sc,initData:a}],"")},rB=function(a){if(0===a.length)return qB();if(a.some(c=>c.type===AA)||a.every(c=>c.type===_.Ad))return a[0];a=a.filter(c=>c.type===
15
+ zA);const b=Array.from((new Set(a.flatMap(c=>c.drmInfos))).values());return{keyInfo:null,keyId:a[a.length-1].keyId,type:zA,drmInfos:b}},uB=function(a){a=sB(a);if(a.some(b=>tB(b))&&1<a.length)throw new _.H(_.G,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");},tB=function(a){return EA(a.$,kA).some(b=>"AES-128"===_.pg(b,vA))},wB=function(a,b,c){return sB(a).map(d=>vB(d.$,b,c))},xB=function(a){return a.filter(b=>GA(b.$,kA)).length},sB=function(a){return a.filter(b=>
16
+ GA(b.$,kA))},vB=function(a,b,c){a=EA(a,kA);if(0===a.length)return null;var d=BA(a[0],vA);if(1===a.length){if("NONE"===d)return qB();if("AES-128"===d)return a=a[0],d=_.pg(a,"IV",""),{type:AA,keyInfo:{method:"AES-128",url:JA(b,BA(a,_.lb)),iv:d?_.Vg((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>BA(e,vA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===wA))throw yB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");
17
+ b=a.map(e=>{const f=_.pg(e,"KEYFORMAT","identity");{const g=zB[f]||null;e=g?g(e,c):null}e||yB.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.G,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||null,type:zA,drmInfos:b}},qB=function(){return{type:_.Ad,keyInfo:null,drmInfos:[],keyId:null}},AB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.jv(b.Fa(),b.ta,b.ta+2048-1,a.a.attemptParameters);e.type=2;
18
+ const f=_.jv(b.Fa(),b.ta,b.ha,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.f.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",e.uris[0]);try{return yield a.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.H(_.G,4,4030,"Failed to fetch the media segment.");
19
+ }}})},BB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.cc||d===_.bc)return 0;if(d===_.ac){var g=yield AB(a,c,f);const h=_.I(g.data);return iB(h)?jB(h):mB(g.data)}if(d===_.Je||d===_.dc)return g=[AB(a,c,f)],b&&g.push(AB(a,b,!0)),g=yield Promise.all(g),kB(g[0].data,(g[1]||g[0]).data);if(d===_.He)return g=yield AB(a,c,f),mB(g.data);if(!_.Eu(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},CB=function(a,
20
+ b){a=a.map(c=>c.ea[b]);return a.some(c=>null==c)?null:a},bB=function(a,b){a.ea.forEach(c=>{c.codecs=b.join(",")})},DB=function(a,b){a=a.ea.find(c=>{c=c.V;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.V.find(c=>c.position===b)||null},EB=function(a,b){a.ea.forEach(c=>{c.width=b})},FB=function(a,b){a.ea.forEach(c=>{c.height=b})},GB=function(a,b){a.ea.forEach(c=>{c.frameRate=b})},HB=function(a,b){a.ea.forEach(c=>{c.bandwidth=b})},IB=function(a,b){return a.ea.some(c=>c.id===
21
+ b)},JB=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},MB=function(a,b,c,d){var e=a[0].length();e=hB(e).map(f=>{const g=JB(a,f)||[],h=CB(b,f)||[],k=CB(c,f)||[];return KB({variants:g,textStreams:h,thumbStreams:k,Qf:d&&0===f})});LB(e);return e},OB=function(a){if(1===a.length)return a[0];const b=a[0],c=a.reduce((e,f)=>e+f.duration,0),d=new Map;a.forEach((e,f)=>{const g=KA(e);0<f&&NB(g,e.startTime);g.forEach(h=>{const k=h.ec;d.has(k)?d.get(k).push(h):d.set(k,[h])})});LA(b,e=>{var f=
22
+ d.get(e.ec);const g=f.flatMap(h=>h.V);f=f.map(h=>({keyInfo:h.keyInfo,type:h.re,drmInfos:h.drmInfos,keyId:h.keyId}));f=rB(f);e.keyInfo=f.keyInfo;e.re=f.type;e.encrypted=f.type===zA;e.drmInfos=f.drmInfos;e.keyId=f.keyId;e.V=g;e.segmentIndex.replace(g)});return Object.assign({},b,{duration:c,endTime:a[0].startTime+c})},KB=function(a){const b=a.variants,c=a.textStreams,d=a.thumbStreams;var e=a.Qf;a=[...b.flatMap(l=>[l.video,l.audio]),...c,...d].filter(Boolean);const f=a[0].$b;e=e?f:0;PB(a,e);const {Db:g,
23
+ cd:h,duration:k}=a[0];return{variants:b,textStreams:c,thumbStreams:d,startTime:0,id:`P${g}`,endTime:h,duration:k+e,Db:g}},LB=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:0;c.endTime=c.startTime+c.duration}},PB=function(a,b){NB(a,0);QB(a);0<b&&NB(a,b)},NB=function(a,b){a.forEach(c=>{const d=-c.$b+b;c.segmentIndex.offset(d);c.cd+=d;c.$b=b})},QB=function(a){const b=RB(a);a.forEach(c=>{_.fv(c.segmentIndex,b);c.duration=b;c.cd=c.$b+b})},RB=function(a){let b=Infinity;
24
+ a.filter(MA).forEach(c=>{b=Math.min(b,c.duration)});return b},SB=function(a,b){return _.y(function*(){var c=_.jh([b],a.f.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.Eg(c.data)}catch(e){throw new _.H(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},YB=function(a,b){return _.y(function*(){var c=TB(a,b,a.h,"");if(1===c.type){a.w.set(a.h,c);c=_.Fo(c.V[0].a)||"";c=null!=_.Eo.video[c]?_.w:null!=_.Eo.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":
25
+ c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.h;d=a.f.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.ch(_.ja,"0"));k.push(new _.ch(_.lb,e));d.length&&k.push(new _.ch(_.ka,d));h.push(new _.dh(c.a++,rA,k));c=new UB(e,0,h)}}d=c.$;c=EA(d,"EXT-X-MEDIA");e=EA(d,rA);d=EA(d,"EXT-X-IMAGE-STREAM-INF");c={tc:{gf:FA(c,["AUDIO",_.sb]),closedCaptions:FA(c,eA),kg:FA(c,"SUBTITLES")},Ze:e,Lf:d};c=yield VB(a,c);if(!a.D)throw new _.H(_.G,7,7001);d=ZA(c[0]);e=WB(a,d.delay,c);if(!XB(a)){a.H=d.Oc;d=0;for(var f of a.g.values())d=
26
+ Math.max(d,f.ea[0].$b);for(f=0;95443.7176888889<=d;)f+=95443.7176888889,d-=95443.7176888889;if(f){a.a.debug("Offsetting live streams by",f,"to compensate for rollover");for(var g of a.g.values())d=g.ea[0],95443.7176888889>d.$b?(a.a.debug("Offset applied to",d.type),d.segmentIndex.offset(f)):a.a.debug("Offset NOT applied to",d.type)}}g=XA(c);"LIVE"===a.m||"EVENT"===a.m?(g=Math.max(g,e.F),isNaN(a.f.availabilityWindowOverride)||(g=a.f.availabilityWindowOverride),e.j=g):a.m===_.Rt&&(e.f=g);g={presentationTimeline:e,
27
+ periods:c,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",g);return g})},cC=function(a,b,c,d){return _.y(function*(){var e=b.ea[0],f=ZB(a,e);const {response:g,text:h}=yield SB(a,f.toString());f=TB(a,h,g.uri,e.ec);$B(f,e.codecs,e.type);if(1!==f.type)throw new _.H(_.G,4,4017);const k=(yield aC(a,f,e.type,e.codecs)).flatMap(l=>l.V);e.V=k;e.segmentIndex.replace(k);_.nv(c,k,d);e=k[k.length-1];HA(f.$,jA)&&(bC(a,_.Rt),_.kv(c,!0),c.f=e.endTime)})},ZB=function(a,b){const c=new _.cg(b.ef);
28
+ if(a.f.hlsLowLatency){a=c.a;if(b.Rc){b=b.segmentIndex;if(b=b.a[b.a.length-1]){var d=b.a,e=d.length-1;b={Tf:b.position,Zf:d&&0<d.length?e:null}}else b=null;const {Tf:f,Zf:g}=b;null!==f&&(a.add("_HLS_msn",f),null!==g&&a.add("_HLS_part",g))}b=a;_.ng(b);b.g&&_.fg(c,a)}return c},TB=function(a,b,c,d){a:{a=a.K;b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.G,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.eh(0,h),
29
+ dB.includes(e.name)){f=1;break}else e.name===rA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.zu(b)){let {yd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.eh(a.a++,e);if(dC.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=gB(a,c,k);c=new UB(c,h,f.concat(a.$),a.V);break a}f.push(e);e.name===rA&&(e.attributes.push(new _.ch(_.lb,n)),g=!0)}}c=new UB(c,h,f)}c.a=d;eC(c);return c},$B=function(a,b,c){if(1===a.type&&(a=a.V.map(d=>d.a?d.a:d.f.map(e=>
30
+ _.pg(e,_.lb))||null).map(d=>_.Go(d,c,b)),1<(new Set(a)).size))throw new _.H(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},aC=function(a,b,c,d){return _.y(function*(){const e=b.a;var f=b.V;var g=void 0===g?0:g;var h=(h=HA(b.$,mA))?Number(h.value):g;g=[];a:{var k=a.g.get(b.a),l=!XB(a),m=HA(b.$,iA);if(m)var n=Number(m.value);else{k?(m=k.ea[k.ea.length-1].V,m=m[m.length-1].Db):m=0;if(l&&0<m)try{var q=HA(b.$,mA);if(!q)throw fC.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),
31
+ Error(tA);var t=Number(q.value),u=DB(k,t);if(!u)throw fC.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${t})`),Error(tA);n=u.Db;break a}catch(z){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}n=0}}!XB(a)&&uB(f);q=yield gC(a,b.f,e,f,h,c,d);t=h;if(0===f.length)f=[];else{u=[];h=[];for(var x of f)GA(x.$,hA)&&0<h.length&&(u.push(h),h=[]),h.push(x);u.push(h);
32
+ f=u}for(x=0;x<f.length;x++)u=f[x],q=yield hC(a,e,b.f,u,n+x,t,q,c,d,g[g.length-1]||null,f.length),g.push(q),q=q.endTime,t+=u.length;return g})},bC=function(a,b){a.m=b;XB(a)&&a.j.stop()},VB=function(a,b){return _.y(function*(){var c=b.tc.closedCaptions;var d=new Map;for(var e of c){c=aB(e);var f=BA(e,_.Ba),g=BA(e,"INSTREAM-ID");d.has(f)||d.set(f,new Map);d.get(f).set(g,c)}c=b.Ze;e=new Map;for(k of c){f=_.pg(k,"AUDIO");c=_.pg(k,_.sb);var h=_.pg(k,"SUBTITLES");g=iC(a,k);if(h){const l=_.Nh(_.v,g);e.set(h,
33
+ l);h=g.indexOf(l);-1<h&&g.splice(h,1)}f&&(h=jC(_.p,g),e.set(f,h));c&&(f=jC(_.w,g),e.set(c,f))}var k=e;e=yield kC(a,b.tc.gf,k);d=yield lC(a,b.Ze,e,d);k=yield mC(a,b.tc.kg,k);e=yield nC(a,b.Lf);k=MB(d,k,e,!XB(a));!XB(a)&&(k=[OB(k)]);a.D.filterAllPeriods(k);return k})},WB=function(a,b,c){let d=!0,e=null,f=0;XB(a)||(d=!1,e=0,f=b);const g=new _.Vz(e,f,!0);_.kv(g,d);LA(c,(h,k)=>{_.nv(g,h.V,k.startTime)});return g},kC=function(a,b,c){return _.y(function*(){var d=b.filter(f=>""!==(_.pg(f,_.lb)||""));if(0===
34
+ d.length)return new Map;let e=[oC(a,d[0],c)];yield e[0];e=e.concat(d.slice(1).map(f=>oC(a,f,c)));d=yield Promise.all(e);return $A(d)})},lC=function(a,b,c,d){return _.y(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(BA(f[k],_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield pC(a,h,c,d,e);f=f.map(k=>pC(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.su,[])})},mC=function(a,b,c){return Promise.all(b.map(d=>oC(a,d,c)))},
35
+ nC=function(a,b){return Promise.all(b.map(c=>qC(a,c)))},iC=function(a,b){var c=_.pg(b,_.ka,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.Ku(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},jC=function(a,b){if(1===b.length)return b[0];a=_.Nh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},oC=function(a,b,c){return _.y(function*(){const d=BA(b,_.lb);return rC(a,d,()=>_.y(function*(){const e=
36
+ BA(b,_.Ba);var f={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.v,"CLOSED-CAPTIONS":_.v}[BA(b,"TYPE").toUpperCase()];if(!f)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const g=c.get(e)||"",h=aB(b),k=_.pg(b,"NAME"),l=b.getAttribute("DEFAULT"),m=b.getAttribute("AUTOSELECT"),n=_.pg(b,"CHANNELS");return yield sC(a,{uri:d,codecs:g,type:f,language:h,primary:!!l&&!!m,name:k,channelsCount:f===_.p?n?parseInt(n.split("/")[0],10):null:null,groupId:e,closedCaptions:null,ee:null})}))})},qC=function(a,
37
+ b){return _.y(function*(){const c=BA(b,_.lb);return rC(a,c,()=>_.y(function*(){var d=_.pg(b,_.ka)||"jpg",e=aB(b);const f=_.pg(b,"NAME");d=yield sC(a,{uri:c,codecs:d,type:_.ed,language:e,name:f,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ee:null});(e=_.pg(b,_.ja))&&HB(d,Number(e));return d}))})},pC=function(a,b,c,d,e){return _.y(function*(){var f=Number(BA(b,_.ja));if(null!=b.getAttribute("FRAME-RATE")||null!=b.getAttribute(_.Ya)){var g=_.pg(b,"FRAME-RATE");var h=_.pg(b,_.Ya),[k,
38
+ l]=h?h.split("x"):[null,null];g={frameRate:DA(g),width:DA(k),height:DA(l)}}else g=null;if(h=yield tC(a,b,g,c,d)){g=h.video;h=h.audio;var m=0<h.length?h:[null];g=0<g.length?g:[null];h=[];for(const O of m)for(const pa of g)if(m=(pa?pa.ea[0].ec:"")+" - "+(O?O.ea[0].ec:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=O,t=pa,u=f;const pb=[],Nc=(t||q).length();for(let Qb=0;Qb<Nc;Qb++){var x=q?q.ea[Qb]||null:null,z=t?t.ea[Qb]||null:null,E=x,D=z;E=E&&D?
39
+ _.Cu(E.drmInfos,D.drmInfos)?_.Bu(E.drmInfos,D.drmInfos):null:E?E.drmInfos:D?D.drmInfos:null;if(!E){n=null;break a}D=u;x={id:n.I++,language:x?x.language:_.xe,primary:!!x&&x.primary||!!z&&z.primary,audio:x,video:z,bandwidth:D,drmInfos:E,allowedByApplication:!0,allowedByKeySystem:!0};pb.push(x)}n=new uC(pb)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(h.push(n),e.add(m))}f=h}else f=[];return f})},tC=function(a,b,c,d,e){return _.y(function*(){let f=iC(a,b);var g=_.pg(b,"AUDIO"),
40
+ h=_.pg(b,_.sb),k=g||h;k=k&&d.has(k)?d.get(k):[];g={audio:g?k:[],video:h?k:[]};a.a.debug("Guessing stream type for",b.toString());h=!1;const l=BA(b,_.lb);var m=g.audio.find(q=>q.ec===l);var n=_.Nh(_.w,f);n=c||n;1!==f.length||n?!k.length&&1<f.length?(a.a.debug("Guessing multiplexed audio+video"),m=_.w,f=[f.join(",")]):g.audio.length&&m?(a.a.debug(uA),m=_.p,h=!0):g.video.length?(a.a.debug(uA),m=_.p):(a.a.debug("Guessing video-only"),m=_.w):(m=_.p,a.a.debug(uA));n=null;h||(n=yield vC(a,b,f,m,e,c));if(null==
41
+ n)return null;g[m]=[n];m===_.p&&c&&k.forEach(q=>{EB(q,c.width);FB(q,c.height);GB(q,c.frameRate)});cB(g);return g})},vC=function(a,b,c,d,e,f){return _.y(function*(){const g=BA(b,_.lb);return rC(a,g,()=>_.y(function*(){var h=_.pg(b,eA);let k=null;d===_.w&&h&&"NONE"!==h&&(k=e.get(h));h=jC(d,c);return yield sC(a,{uri:g,codecs:h,type:d,closedCaptions:k,primary:!1,language:null,name:null,channelsCount:null,groupId:null,ee:f})}))})},rC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);
42
+ if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},sC=function(a,b){return _.y(function*(){const c=b.uri,d=b.codecs,e=b.type,f=b.language,g=b.groupId,h=b.primary,k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ee;let q=JA(a.h,c);if(XB(a)&&a.w.has(q)){var t=a.w.get(q);a.w.delete(q)}else{const {response:O,text:pa}=yield SB(a,q);q=O.uri;t=TB(a,pa,q,c);$B(t,d,e)}if(1!==t.type)throw new _.H(_.G,4,4017);var u=NA(t.$);bC(a,u);const x=YA(t.$,u,a.f.hlsLowLatency||!1);u=yield aC(a,t,e,
43
+ d);const z=a.f.hlsLowLatency?_.Wx:_.Yt;let E=void 0;e===_.v&&(E=_.fu);const {Rc:D}=RA(t.$);t=u.map(O=>{const pa=O.V,pb=O.sf,Nc=O.mimeType;O=O.Db;const Qb=pa[0].startTime,Qa=pa[pa.length-1].endTime,Ge=Qa-Qb,bb=new _.Wz(pa),qa=pa[0].initSegment||null;return{id:a.I++,originalId:k,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:bb.f.bind(bb),getSegmentReference:bb.get.bind(bb),adjustSegmentDurations:bb.g.bind(bb),getDuration:bb.getDuration.bind(bb),segmentIndex:bb,segmentLookupStrategy:z,
44
+ initSegmentReference:qa,mimeType:Nc,codecs:d,kind:E,re:pb.type,encrypted:pb.type===zA,keyId:pb.keyId,language:f||_.xe,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:n?n.frameRate:void 0,width:n?n.width:void 0,height:n?n.height:void 0,bandwidth:void 0,roles:[],channelsCount:l,closedCaptions:m,keyInfo:pb.keyInfo,V:pa,drmInfos:pb.drmInfos,Db:O,ec:c,ef:q,$b:Qb,cd:Qa,duration:Ge,Rc:D,groupId:g,Sf:x}});return new wC(t)})},eC=function(a){1===a.type&&a.V.forEach((b,c)=>{if(GA(b.$,
45
+ lA)&&!GA(b.$,hA)&&0<c)throw new _.H(_.G,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},xC=function(a,b,c){a=EA(a.$,lA);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=BA(a,_.lb),e=JA(b,d);b=SA(a,null,!0);return new _.Sz(()=>[e],b.ta,b.ha,c)},yC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.zu(b.f)){b=q.yd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.pg(t,"DURATION"));n=m+n;k=SA(t,k?
46
+ null:l.ha,k);l=_.pg(t,_.lb);const u=(l=JA(g,l))?[l]:[];m=new TA(c,m,n,()=>u,k.ta,k.ha,e,f,!1,null,null,null,null);if("YES"===_.pg(t,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},zC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.$;var q=c.a;const t=null!=q,u=q?[q]:[];if(!t&&!a.f.hlsLowLatency)return null;a=0;q={ta:0,ha:null};let x=null;t?({duration:c}=QA(n),a=e+c,q=PA(n,b?b.ha:null)):(b=yC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.ed?IA(n):null;d=new TA(d,e,a,()=>u,q.ta,q.ha,f,g,!1,null,h?
47
+ h.we:null,h?h.Xe:null,h?h.durationPerTile:null,x);d.Db=l;d.initSegment=m||void 0;return d},gC=function(a,b,c,d,e,f,g){return _.y(function*(){var h=d[0];if(null!=a.B)return a.B;const k=yield AC(a,f,g,h);var l=vB(h.$,a.h,k)||qB();const m=xC(h,b,l.keyInfo);l=VA(l.keyInfo,e);h=yield BC(a,c,m,h,e,l,k,g);a.a.debug(`Setting playlist start time to ${h}.`);return a.B=h})},hC=function(a,b,c,d,e,f,g,h,k,l,m){return _.y(function*(){var n=d[0],q=null==l;const t=yield AC(a,h,k,n);var u=a.h,x=l?l.Rf:null;var z=
48
+ 1===m;if(d.slice(1).some(tB))throw new _.H(_.G,4,4046,z?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");if(GA(d[0].$,kA)||null===x)if((x=vB(d[0].$,u,t))&&x.type===AA){if(1<xB(d))throw new _.H(_.G,4,4046,xA+`${z?"playlist":"discontinuity"}.`);z=[x]}else z=wB(d,u,t),z=0===z.length?
49
+ [qB()]:z;else if(u=wB(d,u,t),x.type===_.Ad||x.type===zA)z=[x,...u];else{if(0<xB(d))throw new _.H(_.G,4,4046,xA+`${z?"playlist":"discontinuity"}.`);z=[x]}u=z;z=u[u.length-1];u=rB(u);x=xC(n,c,u.keyInfo)||(l?l.Mf:null);var E=VA(u.keyInfo,f);n=q&&XB(a)?0:yield CC(a,e,b,x,n,f,E,t,k,g);q=[];for(E=0;E<d.length;E++){var D=d[E];const O=q[q.length-1]||null,pa=0===E?g:O.endTime,pb=f+E,Nc=VA(u.keyInfo,pb);(D=zC(a,O,D,pb,pa,n,Nc,h,c,e,x))&&q.push(D)}return{V:q,sf:u,Rf:z,mimeType:t,endTime:q[q.length-1].endTime,
50
+ Db:e,Mf:x}})},AC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=HA(d.$,lA);f=f?BA(f,_.lb):null;return DC(a,b,c,e,f)})},BC=function(a,b,c,d,e,f,g,h){return _.y(function*(){if(null==d.a)return 0;var k;k=(k=a.g.get(b))?(k=DB(k,e))?k.startTime:null:null;if(null!=k)return a.a.debug("Found segment start time in previous manifest"),k;a.a.debug("Unable to find segment start time in previous manifest!");k=UA(d,f);return BB(a.L,c,k,g,h,null!=f)})},XB=function(a){return a.m===_.Rt},CC=function(a,
51
+ b,c,d,e,f,g,h,k,l){return _.y(function*(){let m;a.G.has(b)?m=a.G.get(b):(m=(yield BC(a,c,d,e,f,g,h,k))-l,a.a.debug(`Segment #${f} has `+`timestamp offset ${m} s`),a.G.set(b,m));return m})},DC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Qh(f,b,c);if(g)return g;g=_.jh([d],a.f.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.F(g)).headers["content-type"];if(!g)throw new _.H(_.G,4,4021,f.join(", "));return g.split(";")[0]})},UB=class{constructor(a,b,c,d){if(1===
52
+ b){if(!d||0===d.length)throw new _.H(_.G,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.G,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.$=c;this.V=1===b?d:null}},fB=class{constructor(a,b,c){c=void 0===c?[]:c;this.$=b;this.a=a;this.f=c}},TA=class extends _.xv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:
53
+ m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0;this.Db=0}},dB=[iA,jA,"EXT-X-I-FRAMES-ONLY",mA,nA,oA,qA,sA],dC=["EXTINF",gA,"EXT-X-DATERANGE",hA,kA,lA,"EXT-X-PROGRAM-DATE-TIME"],eB=["EXT-X-PART",pA],EC=class{constructor(){this.a=0}},FC=class{constructor(){this.f=new Map;this.a=new Map}set(a,b){this.a.set(a,b);return b.then(c=>this.f.set(a,c)).catch(()=>{}).then(()=>this.a.delete(a))}has(a){return this.f.has(a)}get(a){return this.f.get(a)||null}values(){return Array.from(this.f.values())}clear(){this.a.clear();
54
+ this.f.clear()}},fC=new _.P("clpp.hls.DiscontinuityUtils");var zB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.He)throw new _.H(_.G,4,4041);if(BA(a,vA)===wA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.vu(_.Hc,[{initDataType:_.ge,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":pB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":pB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=BA(a,vA);if(!nB.includes(b))return oB.error("Widevine in HLS is only supported with [",
55
+ nB.join(", "),"], not",b),null;b=BA(a,_.lb);b=_.Vn(b);b=_.I(b.data);b=_.vu(_.Jc,[{initDataType:_.sc,initData:b}],"");if(a=_.pg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},nB=["SAMPLE-AES",wA],oB=new _.P("clpp.hls.DrmParser");var yB=new _.P("clpp.hls.EncryptionUtils");var GC=class{constructor(a){this.f=new _.P("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.gh()}}};var wC=class{constructor(a){this.ea=a}length(){return this.ea.length}};var uC=class{constructor(a){this.a=a}length(){return this.a.length}};var HC=class{constructor(){this.f=this.D=null;this.I=1;this.g=new FC;this.h="";this.K=new EC;this.H=0;this.A=new Map;this.j=new _.Yh(()=>{this.wb()});this.m=_.Rt;this.C=null;this.o=new _.Jo;this.B=null;this.a=new _.P("clpp.hls.HlsParser");this.w=new Map;this.G=new Map;this.L=new GC(this.F.bind(this));this.J=!1}configure(a){this.f=a;this.L.a=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.A.clear();for(const c of this.g.values())(null!=b&&IB(c,b)||null!=a&&IB(c,
56
+ a))&&this.A.set(c.ea[0].ec,c)}start(a,b){const c=this;return _.y(function*(){if(c.J)throw Error("start() may be called only once!");c.J=!0;c.D=b;const {response:d,text:e}=yield SB(c,a);c.h=d.uri;const f=yield YB(c,e);c.C=f;const g=c.H;0<g&&c.j.ca(g);return f})}stop(){this.j&&(this.j.stop(),this.j=null);const a=[];this.o&&(a.push(this.o.destroy()),this.o=null);this.g.clear();this.A.clear();this.f=this.D=null;this.w.clear();this.C=null;return Promise.all(a)}onExpirationUpdated(){}update(){const a=this;
57
+ return _.y(function*(){var b=a.C;if(!XB(a)&&b){var c=b.presentationTimeline;b=b.periods[0].startTime;var d=[];"LIVE"===a.m&&(a.B=null);var e=Array.from(a.g.values()),f=Array.from(a.A.values());e=a.f.hlsLowLatency&&0<f.length?f:e;yield cC(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(cC(a,e[f],c,b));yield Promise.all(d)}})}wb(){const a=this;return _.y(function*(){a.a.debug(_.Qt);if(a.D)try{yield a.update(),a.j.ca(a.H)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.j.ca(.1))}})}F(a){if(!this.o)throw new _.H(_.G,
58
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.qh(this.o,a);return a.P}};_.A("clpp.hls.HlsComponent",class extends _.Ap{constructor(){super()}f(){_.zn.m3u8=HC;_.xn[_.Ui]=HC;_.xn[yA]=HC}a(){_.Ev("m3u8");_.Fv(_.Ui);_.Fv(yA)}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 yI=function(a){a.a.one(a.l,_.nd,()=>xI(a))},xI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>zI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{zI(a,{track:d})});!AI(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),BI(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
- else a.f.warn("A video element is not available. Skipping.")},zI=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.dd,a.a.on(b,_.Nc,c=>CI(a,c)))},AI=function(a){return a.some(b=>b.kind===_.td)},BI=function(a,b){const c=a.l.getTrackManager(),d=c.la(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.qa(d);a.a.on(b.textTracks,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,f),c.qa(d))});c.qa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- CI=function(a,b){const c=DI(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new EI(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Mg(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},DI=function(a){return(a=a.l.getTrackManager().ma())&&a.language&&a.language.toLowerCase()},
4
- EI=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.pf(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=_.pf(a)?a:null}}};var FI=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;yI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var GI=class extends _.jq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.gi()){var b=a.getConfiguration();b=_.kf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.lc&&(b.patchMetadataTrack=!1);_.qf(b.timestampOffset)||(b.timestampOffset=0);this.a=new FI(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.w(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.x("clpp.hlssmpte.HlsSmptePlugin",GI);
5
- GI.Id="hlssmpte";_.Sm(new class{create(){return new GI}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var WJ=function(a){a.a.one(a.l,_.nd,()=>VJ(a))},VJ=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Mb,d=>XJ(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{XJ(a,{track:d})});!YJ(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),ZJ(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
2
+ else a.f.warn("A video element is not available. Skipping.")},XJ=function(a,b){b=b.track;b.kind===_.td&&(a.f.info("The metadata track has been added."),b.mode=_.dd,a.a.on(b,_.Mc,c=>$J(a,c)))},YJ=function(a){return a.some(b=>b.kind===_.td)},ZJ=function(a,b){const c=a.l.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.sa(d);a.a.on(b.textTracks,_.Mb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Mb,f),c.sa(d))});c.sa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
+ $J=function(a,b){const c=aK(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new bK(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Ig(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},aK=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
4
+ bK=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.pf(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=_.pf(a)?a:null}}};var cK=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.jo;this.h=(a=_.Xn[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.P("clpp.hlssmpte.ImageCueHandler");this.g=null;WJ(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var dK=class extends _.aq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.li()){var b=a.getConfiguration();b=_.kf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.hc&&(b.patchMetadataTrack=!1);_.qf(b.timestampOffset)||(b.timestampOffset=0);this.a=new cK(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.A("clpp.hlssmpte.HlsSmptePlugin",dK);
5
+ dK.Id="hlssmpte";_.Hm(new class{create(){return new dK}});};f.call(g, window);
package/cl.htmlcue.js CHANGED
@@ -1,25 +1,25 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qH="Unsupported unit",rH="clpp-text-plain",sH="clpp-text-ttml",tH="clpp.htmlcue.HtmlTextDisplayer",uH="initial",vH=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},wH=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},yH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>xH[c]);return a},AH=
2
- function(a,b){zH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{zH(a,c)})},zH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},BH=function(a,b){return 0===a?"0":a+b},CH=function(a,b){return 1>Math.abs(a-b)||a<b},DH=function(a,b){return a<b&&1<Math.abs(a-b)},EH=function(a,b){return a>b&&1<Math.abs(a-b)},FH=function(a,b){return 1>Math.abs(a-b)||a>b},HH=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||
3
- 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 GH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},IH=function(a){return new GH(a.f,a.g,a.h,a.a,a.height,a.width)},JH=function(a,b){return b.some(c=>DH(a.f,c.g)&&EH(a.g,c.f)&&DH(a.h,c.a)&&EH(a.a,c.h))},KH=function(a,b){return FH(a.h,
4
- b.h)&&CH(a.a,b.a)&&FH(a.f,b.f)&&CH(a.g,b.g)},LH=function(a,b,c){switch(c){case "+x":return DH(a.f,b.f);case "-x":return EH(a.g,b.g);case "+y":return DH(a.h,b.h);case "-y":return EH(a.a,b.a);default:throw Error("Unknown axis");}},MH=function(a){return a.f.writingMode===_.yo},NH=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 MH(a)?b:c},OH=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
5
- case _.He:return _.He;default:throw Error("Unknown writing mode");}},PH=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},QH=function(a,b){if(typeof a.f.position===_.p&&typeof a.f.size===_.p)switch(b){case _.ld:return a.f.position;case "auto":case _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},RH=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.ld;
6
- case _.xo:return _.uc;case _.de:case _.de:return _.md}return a.f.positionAlign},UH=function(a,b,c){return(SH(a)||TH(a))&&_.qf(c)?BH(c,_.Xd):SH(a)&&_.z(c)?BH(0,_.Xd):MH(a)&&_.qf(b)?BH(b,"%"):uH},VH=function(a,b,c){return MH(a)&&_.qf(c)?BH(c,_.Xd):(SH(a)||TH(a))&&_.qf(b)?BH(b,"%"):uH},TH=function(a){return a.f.writingMode===_.He},SH=function(a){return a.f.writingMode===_.Ge},WH=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.He:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
7
- ["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.He:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},XH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=HH(a.j.a)},YH=function(a,b){XH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},ZH=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Fo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(qH);},aI=function(a,b,c,d){const e=document.createElement(_.pe),
8
- f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);$H(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},bI=function(a,b){a=`.${a.j} .clpp-text-container`;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,
9
- a)},cI=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},dI=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},$H=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});
10
- d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},eI=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},kI=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Sl)if(a.I=c,c=fI(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,gI(a),c)){b={color:a.getFontColor()||void 0,
11
- backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.oo(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 _.Oe:g="clpp-text-vtt";break;case _.xe:g=sH;break;case _.wo:g=rH}g&&!f.classList.contains(g)&&_.mm(f,g);f=HH(c.a.a);if(0===f.width||0===f.height)c.L.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.");
12
- else{zH({fontSize:hI(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Oe;var h=d.payloadType===_.xe;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new iI(d.region,{}),c.A.set(d.region.id,f),YH(c.a,f)));d=new jI(d,c.K,e);f?YH(f,d):YH(c.a,d)}}}}},lI=function(a){gI(a);a.I=null;a.m=null;a.f=[]},mI=function(a,b){return a.startTime<=b&&a.endTime>b},fI=function(a,b){var c=vH(a.f,d=>mI(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
13
- c;for(;0<=d-1&&mI(a.f[d-1],b);)d--;for(;c+1<a.f.length&&mI(a.f[c+1],b);)c++;return{start:d,end:c}}},gI=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(sH);b.classList.remove(rH);a=a.a;XH(a.g);a.j=[]}},hI=function(a,b){const c=HH(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.p&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
14
- a)}px`},qI=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=wH(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=nI[f];h?(h=_.om(h),(f=oI[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||pI[g.localName]&&pI[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
15
- d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(yH(e)));return b}},nI={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},oI={v:"voice",lang:"lang"},pI={rt:"ruby"},xH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var GH=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var rI=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var jI=class extends rI{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.mm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.xe){var c=_.om(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
- _.Oe?b=(new qI).parse(b.payload):(c=_.om(_.Qc),c.textContent=b.payload,b=c);_.mm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.mm(b,d);zH({writingMode:OH(this)},b);var d=b;this.a.appendChild(d);_.mm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.mm(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=MH(this)?-1:0);e=OH(this);zH({writingMode:e,webkitWritingMode:e,direction:uH,textAlign:PH(this)},this.a);if(!this.f.region||
17
- !this.f.region.displayAlign){e=QH(this,RH(this));zH({position:"absolute",left:UH(this,e,null),right:TH(this)&&_.z(null)?BH(0,_.Xd):uH,top:VH(this,e,null),width:MH(this)?BH(this.f.size,"%"):uH,height:SH(this)||TH(this)?BH(this.f.size,"%"):uH},this.a);b=this.f;a=MH(this)?a.height:a.width;c=NH(this);if(b.lineInterpretation===_.zo){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 _.uc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
18
- 100*a)}TH(this)&&(f=a-f-c);a=f;zH({left:UH(this,e,a),right:TH(this)&&_.z(a)?BH(0,_.Xd):uH,top:VH(this,e,a)},this.a)}AH(this.B,d)}}m(){return _.om(_.Qc)}};var sI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=HH(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.dd;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=HH(a.a);var d=WH(this,a.f),e=NH(a);const g=IH(c);let h=null,k=0;for(const l of d){for(;LH(c,this.a,l)||KH(c,this.a)&&JH(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||KH(c,this.a))break a;
19
- d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=IH(c),k=d);c=IH(g)}c=h||g}zH({top:BH(c.h-this.a.h,_.Xd),bottom:BH(this.a.a-c.a,_.Xd),left:BH(c.f-this.a.f,_.Xd),right:BH(this.a.g-c.g,_.Xd),height:BH(c.height,_.Xd),width:BH(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(HH(a.a))}};var tI=class extends rI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new sI(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var iI=class extends tI{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 _.Fo:b=b.width/100*a.width;break a;default:throw Error(qH);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Fo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(qH);d=a.height;const e=ZH(this,d,a.height);zH(this.A,this.a);zH({left:BH(c,_.Xd),top:BH(e,_.Xd),width:BH(b,
20
- _.Xd),height:BH(d,_.Xd)},this.a);this.f.writingMode&&zH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&zH({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.mm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Fo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new jI(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(HH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
- b=c;f*=b;break a;default:throw Error(qH);}a=ZH(this,f,a.height);zH({top:BH(a,_.Xd),height:BH(f,_.Xd)},this.a);this.g=new sI(this,!0);this.h=!0}getId(){return this.f.id}};var uI=class{constructor(a,b){this.f=new _.O("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=aI(this,this.h,this.j);this.g=aI(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=bI(this,a);if(cI(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
22
- `because it's not safe: ${b}`)}}destroy(){const a=this;return _.w(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],dI(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var vI=class extends _.gq{constructor(a){super(a);this.L=new _.O(tH);this.l=a;this.K=eI(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new uI(a,"CLPP Subtitle Styles");this.a=new tI(null,"clpp-text-container",{});this.w=new _.bq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.L.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
23
- new _.Th(()=>{kI(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);b=this.f.findIndex(c=>c.startTime>=a[0].startTime);0===b?this.f=[]:0<b&&this.f.splice(0,b);for(const c of a)this.f.some(d=>d.payload!==c.payload?!1:d.startTime!==c.startTime?!1:d.endTime!==c.endTime?!1:!0)||this.f.push(c);this.m=null;kI(this,!1)}}g(){null==this.h||kI(this,!0)}destroy(){const a=
24
- this;return _.w(function*(){null!=a.h&&(lI(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;kI(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Ua(.25),this.K.enableResizeObserver&&this.w.start(),kI(this,!0)):(this.F.stop(),this.w.stop(),lI(this)))}U(){kI(this,!0)}};_.x(tH,vI);
25
- vI.prototype.setTextVisibility=vI.prototype.setTextVisibility;vI.prototype.isTextVisible=vI.prototype.isTextVisible;vI.prototype.remove=vI.prototype.remove;vI.prototype.destroy=vI.prototype.destroy;vI.prototype.append=vI.prototype.append;var wI=class{da(a){return!!a.enableHtmlCue&&!_.ii()}create(a){return new vI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Lp{f(){_.wl("html",new wI)}a(){}id(){return _.qe}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var OI="Unsupported unit",PI="clpp-text-plain",QI="clpp-text-ttml",RI="clpp.htmlcue.HtmlTextDisplayer",SI="initial",TI=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},UI=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},WI=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>VI[c]);return a},YI=
2
+ function(a,b){XI(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{XI(a,c)})},XI=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},ZI=function(a,b){return 0===a?"0":a+b},$I=function(a,b){return 1>Math.abs(a-b)||a<b},aJ=function(a,b){return a<b&&1<Math.abs(a-b)},bJ=function(a,b){return a>b&&1<Math.abs(a-b)},cJ=function(a,b){return 1>Math.abs(a-b)||a>b},eJ=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||
3
+ 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 dJ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},fJ=function(a){return new dJ(a.f,a.g,a.h,a.a,a.height,a.width)},gJ=function(a,b){return b.some(c=>aJ(a.f,c.g)&&bJ(a.g,c.f)&&aJ(a.h,c.a)&&bJ(a.a,c.h))},hJ=function(a,b){return cJ(a.h,
4
+ b.h)&&$I(a.a,b.a)&&cJ(a.f,b.f)&&$I(a.g,b.g)},iJ=function(a,b,c){switch(c){case "+x":return aJ(a.f,b.f);case "-x":return bJ(a.g,b.g);case "+y":return aJ(a.h,b.h);case "-y":return bJ(a.a,b.a);default:throw Error("Unknown axis");}},jJ=function(a){return a.f.writingMode===_.no},kJ=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 jJ(a)?b:c},lJ=function(a){switch(a.f.writingMode){case _.no:return"horizontal-tb";case _.Ee:return _.Ee;
5
+ case _.Fe:return _.Fe;default:throw Error("Unknown writing mode");}},mJ=function(a){switch(a.f.positionAlign){case _.ld:return _.hd;case "auto":case _.tc:return _.mo;case _.md:return _.ce}return a.f.textAlign},nJ=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.ld:return a.f.position;case "auto":case _.tc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},oJ=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.hd:case _.hd:return _.ld;
6
+ case _.mo:return _.tc;case _.ce:case _.ce:return _.md}return a.f.positionAlign},rJ=function(a,b,c){return(pJ(a)||qJ(a))&&_.qf(c)?ZI(c,_.Wd):pJ(a)&&_.B(c)?ZI(0,_.Wd):jJ(a)&&_.qf(b)?ZI(b,"%"):SI},sJ=function(a,b,c){return jJ(a)&&_.qf(c)?ZI(c,_.Wd):(pJ(a)||qJ(a))&&_.qf(b)?ZI(b,"%"):SI},qJ=function(a){return a.f.writingMode===_.Fe},pJ=function(a){return a.f.writingMode===_.Ee},tJ=function(a,b){if(a.h)switch(b.writingMode){case _.no:return["-y"];case _.Ee:return["+x"];case _.Fe:return["-x"]}a=[];switch(b.writingMode){case _.no:a=
7
+ ["+y","-y"];break;case _.Ee:a=["+x","-x"];break;case _.Fe:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},uJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=eJ(a.j.a)},vJ=function(a,b){uJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},wJ=function(a,b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.uo)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(OI);},yJ=function(a,b,c,d){const e=document.createElement(_.oe),
8
+ f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);xJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},zJ=function(a,b){a=`.${a.j} .clpp-text-container`;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,
9
+ a)},AJ=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},BJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},xJ=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});
10
+ d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},CJ=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},IJ=function(a,b){if((b||a.j)&&a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Hl)if(a.I=c,c=DJ(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,EJ(a),c)){b={color:a.getFontColor()||void 0,
11
+ backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.co(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 _.Oe:g="clpp-text-vtt";break;case _.we:g=QI;break;case _.lo:g=PI}g&&!f.classList.contains(g)&&_.bm(f,g);f=eJ(c.a.a);if(0===f.width||0===f.height)c.L.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.");
12
+ else{XI({fontSize:FJ(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Oe;var h=d.payloadType===_.we;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new GJ(d.region,{}),c.A.set(d.region.id,f),vJ(c.a,f)));d=new HJ(d,c.K,e);f?vJ(f,d):vJ(c.a,d)}}}}},JJ=function(a){EJ(a);a.I=null;a.m=null;a.f=[]},KJ=function(a,b){return a.startTime<=b&&a.endTime>b},DJ=function(a,b){var c=TI(a.f,d=>KJ(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=
13
+ c;for(;0<=d-1&&KJ(a.f[d-1],b);)d--;for(;c+1<a.f.length&&KJ(a.f[c+1],b);)c++;return{start:d,end:c}}},EJ=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(QI);b.classList.remove(PI);a=a.a;uJ(a.g);a.j=[]}},FJ=function(a,b){const c=eJ(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*
14
+ a)}px`},OJ=class{parse(a){a={input:a};const b=_.dm(_.Qc),c=[];let d=b;for(var e;null!==(e=UI(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=LJ[f];h?(h=_.dm(h),(f=MJ[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||NJ[g.localName]&&NJ[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),
15
+ d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(WI(e)));return b}},LJ={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},MJ={v:"voice",lang:"lang"},NJ={rt:"ruby"},VI={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var dJ=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var PJ=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var HJ=class extends PJ{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.bm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.we){var c=_.dm(_.Qc);c.innerHTML=b.payload;b=c}else b.payloadType===
16
+ _.Oe?b=(new OJ).parse(b.payload):(c=_.dm(_.Qc),c.textContent=b.payload,b=c);_.bm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.bm(b,d);XI({writingMode:lJ(this)},b);var d=b;this.a.appendChild(d);_.bm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.bm(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.oo,this.f.line=jJ(this)?-1:0);e=lJ(this);XI({writingMode:e,webkitWritingMode:e,direction:SI,textAlign:mJ(this)},this.a);if(!this.f.region||
17
+ !this.f.region.displayAlign){e=nJ(this,oJ(this));XI({position:"absolute",left:rJ(this,e,null),right:qJ(this)&&_.B(null)?ZI(0,_.Wd):SI,top:sJ(this,e,null),width:jJ(this)?ZI(this.f.size,"%"):SI,height:pJ(this)||qJ(this)?ZI(this.f.size,"%"):SI},this.a);b=this.f;a=jJ(this)?a.height:a.width;c=kJ(this);if(b.lineInterpretation===_.oo){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 _.tc:g-=f/2;break;case _.Yc:g-=f}f=Math.round(g/
18
+ 100*a)}qJ(this)&&(f=a-f-c);a=f;XI({left:rJ(this,e,a),right:qJ(this)&&_.B(a)?ZI(0,_.Wd):SI,top:sJ(this,e,a)},this.a)}YI(this.B,d)}}m(){return _.dm(_.Qc)}};var QJ=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=eJ(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.dd;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=eJ(a.a);var d=tJ(this,a.f),e=kJ(a);const g=fJ(c);let h=null,k=0;for(const l of d){for(;iJ(c,this.a,l)||hJ(c,this.a)&&gJ(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||hJ(c,this.a))break a;
19
+ d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=fJ(c),k=d);c=fJ(g)}c=h||g}XI({top:ZI(c.h-this.a.h,_.Wd),bottom:ZI(this.a.a-c.a,_.Wd),left:ZI(c.f-this.a.f,_.Wd),right:ZI(this.a.g-c.g,_.Wd),height:ZI(c.height,_.Wd),width:ZI(c.width,_.Wd)},a.a)}b.style.visibility="visible";this.g.push(eJ(a.a))}};var RJ=class extends PJ{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new QJ(this);this.h=!0}m(){const a=_.dm(_.Qc);_.bm(a,this.o);this.id&&(a.id=this.id);return a}};var GJ=class extends RJ{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 _.uo:b=b.width/100*a.width;break a;default:throw Error(OI);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.uo)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(OI);d=a.height;const e=wJ(this,d,a.height);XI(this.A,this.a);XI({left:ZI(c,_.Wd),top:ZI(e,_.Wd),width:ZI(b,
20
+ _.Wd),height:ZI(d,_.Wd)},this.a);this.f.writingMode&&XI({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&XI({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.bm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.uo:f=f.height/100*a.height;break a;case 2:f=f.height;c=new HJ(new _.ro(0,1,"Lorem ipsum",_.lo),{},{});b=c.a;this.a.appendChild(b);c.init(eJ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
+ b=c;f*=b;break a;default:throw Error(OI);}a=wJ(this,f,a.height);XI({top:ZI(a,_.Wd),height:ZI(f,_.Wd)},this.a);this.g=new QJ(this,!0);this.h=!0}getId(){return this.f.id}};var SJ=class{constructor(a,b){this.f=new _.P("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=yJ(this,this.h,this.j);this.g=yJ(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=zJ(this,a);if(AJ(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
22
+ `because it's not safe: ${b}`)}}destroy(){const a=this;return _.y(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],BJ(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var TJ=class extends _.Yp{constructor(a){super(a);this.L=new _.P(RI);this.l=a;this.K=CJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new SJ(a,"CLPP Subtitle Styles");this.a=new RJ(null,"clpp-text-container",{});this.w=new _.Tp(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.L.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
23
+ new _.Yh(()=>{IJ(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);b=this.f.findIndex(c=>c.startTime>=a[0].startTime);0===b?this.f=[]:0<b&&this.f.splice(0,b);for(const c of a)this.f.some(d=>d.payload!==c.payload?!1:d.startTime!==c.startTime?!1:d.endTime!==c.endTime?!1:!0)||this.f.push(c);this.m=null;IJ(this,!1)}}g(){null==this.h||IJ(this,!0)}destroy(){const a=
24
+ this;return _.y(function*(){null!=a.h&&(JJ(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;IJ(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Va(.25),this.K.enableResizeObserver&&this.w.start(),IJ(this,!0)):(this.F.stop(),this.w.stop(),JJ(this)))}U(){IJ(this,!0)}};_.A(RI,TJ);
25
+ TJ.prototype.setTextVisibility=TJ.prototype.setTextVisibility;TJ.prototype.isTextVisible=TJ.prototype.isTextVisible;TJ.prototype.remove=TJ.prototype.remove;TJ.prototype.destroy=TJ.prototype.destroy;TJ.prototype.append=TJ.prototype.append;var UJ=class{da(a){return!!a.enableHtmlCue&&!_.ni()}create(a){return new TJ(a)}};_.A("clpp.htmlcue.HtmlCueComponent",class extends _.Ap{f(){_.ll("html",new UJ)}a(){}id(){return _.pe}});};f.call(g, window);