@castlabs/prestoplay 6.6.1-beta.2 → 6.7.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 +20 -0
  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 +403 -403
  8. package/cjs/cl.crypto.js +10 -10
  9. package/cjs/cl.dash.js +71 -71
  10. package/cjs/cl.externs.js +47 -41
  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 +263 -260
  17. package/cjs/cl.muxdata.js +11 -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 +70 -69
  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 +13 -13
  28. package/cjs/cl.vtt.js +11 -11
  29. package/cjs/cl.youbora.js +19 -19
  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 +345 -343
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +67 -67
  38. package/cl.externs.js +47 -41
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +57 -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 +227 -227
  45. package/cl.muxdata.js +9 -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 -58
  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 +14 -14
  58. package/package.json +1 -1
  59. package/typings.d.ts +118 -12
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 FI="clpp-freewheel",GI="clpp.freewheel.AdsManagerFactory",HI="freewheel",II=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""}},JI=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(", ")});},KI=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})},LI=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))},OI=function(a){return _.w(function*(){a.A.length?(MI(a),a.f=a.A.shift(),a.f.play()):(NI(a),yield a.l.a.play())})},NI=function(a){const b=a.l.Tb(HI).mc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},MI=function(a){const b=a.l.Tb(HI).mc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(FI),
4
- a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},PI=function(a){a.w.length?(MI(a),a.f=a.w.shift(),a.f.play()):NI(a)},QI=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))},RI=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:FI}),this.f=_.lm(_.v,{"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 HI}mc(){return this.a}qf(){return this.f}};_.x("clpp.freewheel.FreeWheelPlugin",RI);RI.prototype.getAdVideo=RI.prototype.qf;RI.prototype.getAdContainer=RI.prototype.mc;RI.Id=HI;RI.AD_CONTAINER_ID=FI;_.Sm(new class{create(){return new RI}});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}Cb(){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}Db(){switch(this.Oa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Eb(){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.Eb;W.prototype.getPodTimeOffset=W.prototype.Db;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.Cb;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 SI=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()}})}Fb(){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
- SI.prototype.hasPostroll=SI.prototype.eb;SI.prototype.hasPreroll=SI.prototype.Fb;SI.prototype.getCuePoints=SI.prototype.getCuePoints;var TI=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{JI(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 KI();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,II(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);LI(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.w(function*(){yield OI(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);NI(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 SI(this.a)})),this.h=new _.bq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Tb(HI).f);else this.l.onError(new _.G(1,
15
- 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){QI(this,_.xb,a);this.h.start()}I(a){this.f=null;a=a.slot;QI(this,_.yb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:OI(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:NI(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:PI(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:QI(this,_.Kb,a);QI(this,
16
- _.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:QI(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:QI(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:QI(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:QI(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:QI(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:QI(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:QI(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:QI(this,
17
- _.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:QI(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:QI(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:QI(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();MI(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);PI(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
- TI.prototype.getPosition=TI.prototype.getPosition;TI.prototype.setVolume=TI.prototype.setVolume;TI.prototype.getVolume=TI.prototype.getVolume;TI.prototype.skip=TI.prototype.skip;TI.prototype.pause=TI.prototype.pause;TI.prototype.resume=TI.prototype.resume;TI.prototype.start=TI.prototype.start;var UI=class{constructor(){this.a=new _.O(GI)}name(){return GI}aa(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 TI(a)}};UI.prototype.create=UI.prototype.create;UI.prototype.isSupported=UI.prototype.aa;UI.prototype.name=UI.prototype.name;_.im(new UI);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var RJ="clpp-freewheel",SJ="clpp.freewheel.AdsManagerFactory",TJ="freewheel",UJ=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""}},VJ=function(a){const b=[];typeof a.networkId!==_.r&&b.push("networkId");typeof a.serverUrl!==_.ne&&b.push("serverUrl");typeof a.profileId!==_.ne&&b.push("profileId");typeof a.videoAssetId!==_.ne&&typeof a.videoAssetId!==_.r&&b.push("videoAssetId");
2
+ if(b.length)throw new _.H(1,9,12001,{missingKeys:b.join(", ")});},WJ=function(){return _.y(function*(){var a=new _.eq;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})},XJ=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))},$J=function(a){return _.y(function*(){a.A.length?(YJ(a),a.f=a.A.shift(),a.f.play()):(ZJ(a),yield a.l.a.play())})},ZJ=function(a){const b=a.l.Vb(TJ).qc();b&&a.l.getSurface().hide(b);a.l.getSurface().showMediaElement()},YJ=function(a){const b=a.l.Vb(TJ).qc();b&&(a.l.getSurface().show(b),a.l.getSurface().hideMediaElement(),a.a.registerVideoDisplayBase(RJ),
4
+ a.l.isMuted()?a.setVolume(0):a.setVolume(a.l.getVolume()||1))},aK=function(a){a.w.length?(YJ(a),a.f=a.w.shift(),a.f.play()):ZJ(a)},bK=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 _.F(b,d))},cK=class extends _.kq{constructor(){super();this.f=this.a=null}onPlayerCreated(a){if(window.tv&&tv.freewheel&&tv.freewheel.SDK)this.a=_.lm(_.Qc,{id:RJ}),this.f=_.lm(_.w,{"class":_.yc}),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 TJ}qc(){return this.a}Af(){return this.f}};_.z("clpp.freewheel.FreeWheelPlugin",cK);cK.prototype.getAdVideo=cK.prototype.Af;cK.prototype.getAdContainer=cK.prototype.qc;cK.Id=TJ;cK.AD_CONTAINER_ID=RJ;_.Sm(new class{create(){return new cK}});var W=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===_.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}Zb(){return!1}Gb(){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}Hb(){switch(this.Qa()){case 0:return 0;case 2:return-1;default:return this.f.getTimePosition()}}Ib(){return this.a?this.f.getAdInstances().indexOf(this.a)+1:1}sb(){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.sb;W.prototype.getPositionInSequence=W.prototype.Ib;W.prototype.getPodTimeOffset=W.prototype.Hb;W.prototype.getPodIndex=W.prototype.getPodIndex;W.prototype.getPodType=W.prototype.Qa;W.prototype.getMediaBitrate=W.prototype.eb;W.prototype.getMediaHeight=W.prototype.pb;
9
+ W.prototype.getMediaWidth=W.prototype.qb;W.prototype.getMediaUrl=W.prototype.getMediaUrl;W.prototype.getClickThroughUrl=W.prototype.Gb;W.prototype.isBumper=W.prototype.Zb;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.tb;W.prototype.getAdManagerVersion=W.prototype.ob;W.prototype.getAdManagerName=W.prototype.nb;var dK=class{constructor(a){this.a=a}getCuePoints(){return this.a.getTemporalSlots().map(a=>{switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:return 0;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:return-1;default:return a.getTimePosition()}})}Jb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL).length}fb(){return 0<this.a.getSlotsByTimePositionClass(tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL).length}};
11
+ dK.prototype.hasPostroll=dK.prototype.fb;dK.prototype.hasPreroll=dK.prototype.Jb;dK.prototype.getCuePoints=dK.prototype.getCuePoints;var eK=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 _.y(function*(){const b=a.l.getConfiguration().freewheel||{};try{VJ(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
+ _.r||a.a.setSiteSection(b.siteSectionId);const c=yield WJ();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,UJ(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);XJ(a);a.a.submitRequest();return a.j})}start(){const a=this;return _.y(function*(){yield $J(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);ZJ(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(_.Ob,{adsTimeline:new dK(this.a)})),this.h=new _.cq(this.l.getSurface(),(b,c)=>this.a.resize(b,c),this.l.Vb(TJ).f);else this.l.onError(new _.H(1,
15
+ 9,10003,{errorType:0},void 0));this.j.resolve()}J(a){bK(this,_.xb,a);this.h.start()}I(a){this.f=null;a=a.slot;bK(this,_.yb);this.h.stop();if(a)switch(a.getTimePositionClass()){case tv.freewheel.SDK.TIME_POSITION_CLASS_PREROLL:$J(this);break;case tv.freewheel.SDK.TIME_POSITION_CLASS_MIDROLL:ZJ(this);this.l.play();break;case tv.freewheel.SDK.TIME_POSITION_CLASS_POSTROLL:aK(this)}}G(a){const b=a.subType;this.B.debug("ad event",b);switch(b){case tv.freewheel.SDK.EVENT_AD_IMPRESSION:bK(this,_.Kb,a);bK(this,
16
+ _.Db,a);break;case tv.freewheel.SDK.EVENT_AD_IMPRESSION_END:bK(this,_.Lb,a);break;case tv.freewheel.SDK.EVENT_AD_FIRST_QUARTILE:bK(this,_.Cb,a);break;case tv.freewheel.SDK.EVENT_AD_MIDPOINT:bK(this,_.Fb,a);break;case tv.freewheel.SDK.EVENT_AD_THIRD_QUARTILE:bK(this,_.Mb,a);break;case tv.freewheel.SDK.EVENT_AD_COMPLETE:bK(this,_.Bb,a);break;case tv.freewheel.SDK.EVENT_AD_CLICK:bK(this,_.Ab,a);break;case tv.freewheel.SDK.EVENT_AD_PAUSE:bK(this,_.Gb,a);break;case tv.freewheel.SDK.EVENT_AD_RESUME:bK(this,
17
+ _.Ib,a);break;case tv.freewheel.SDK.EVENT_AD_SKIPPED:bK(this,_.Jb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_START:bK(this,_.zb,a);break;case tv.freewheel.SDK.EVENT_AD_BUFFERING_END:bK(this,_.Hb,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();YJ(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);aK(this);break;case _.Pl:case _.Ol:this.a.setVideoState(tv.freewheel.SDK.VIDEO_STATE_STOPPED)}}};
19
+ eK.prototype.getPosition=eK.prototype.getPosition;eK.prototype.setVolume=eK.prototype.setVolume;eK.prototype.getVolume=eK.prototype.getVolume;eK.prototype.skip=eK.prototype.skip;eK.prototype.pause=eK.prototype.pause;eK.prototype.resume=eK.prototype.resume;eK.prototype.start=eK.prototype.start;var fK=class{constructor(){this.a=new _.O(SJ)}name(){return SJ}ba(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 eK(a)}};fK.prototype.create=fK.prototype.create;fK.prototype.isSupported=fK.prototype.ba;fK.prototype.name=fK.prototype.name;_.im(new fK);};f.call(g, window);
package/cl.hls.js CHANGED
@@ -1,40 +1,57 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Lz="CLOSED-CAPTIONS",Mz="Could not parse MP4 segment start time.",Nz="EXT-X-BYTERANGE",Oz="EXT-X-DISCONTINUITY",Pz="EXT-X-DISCONTINUITY-SEQUENCE",Qz="EXT-X-ENDLIST",Rz="EXT-X-MAP",Sz="EXT-X-MEDIA-SEQUENCE",Tz="EXT-X-PART-INF",Uz="EXT-X-PLAYLIST-TYPE",Vz="EXT-X-PRELOAD-HINT",Wz="EXT-X-SERVER-CONTROL",Xz="EXT-X-STREAM-INF",Yz="EXT-X-TARGETDURATION",Zz="EXTINF",$z="Guessing audio-only",aA="SAMPLE-AES-CTR",bA="SUBTITLES",cA="application/vnd.apple.mpegurl",dA=function(a,b){a=a.getAttribute(b);
2
- if(!a)throw new _.G(_.F,4,4023,b);return a.value},eA=function(a){if(1>a.a)throw _.xj();--a.a},fA=function(a,b){return a.filter(c=>c.name==b)},gA=function(a,b){return a.filter(c=>dA(c,"TYPE")===b)},hA=function(a,b){a=fA(a,b);return a.length?a[0]:null},iA=function(a,b){return _.wu([a],[b])[0]},jA=function(a,b){return _.yg(a.a++,b)},nA=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=jA(a,h),kA.includes(h.name)?d.push(h):lA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):
3
- h.name===Vz&&"PART"===_.rg(h,"TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=iA(b,h.trim()),e.push(new mA(h,f,g)),f=[],g=[])});g.length&&e.push(new mA(null,f,g));return e},qA=function(a,b,c){const d=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(d[0]))throw new _.G(_.F,4,4015);b=0;let e=!0;for(var f of d)if(f=f.trim(),!f.length||/^#(?!EXT)/m.test(f)||e)e=!1;else{var g=jA(a,f);--a.a;if(kA.includes(g.name)){b=1;break}else g.name===Xz&&(e=!0)}f=[];e=!0;for(var h of _.yu(d)){let {Vc:k,
4
- item:l,next:m}=h;l=l.trim();if(!l.length||/^#(?!EXT)/m.test(l)||e)e=!1;else{g=jA(a,l);if(oA.includes(g.name)){if(1!==b)throw new _.G(_.F,4,4017);h=d.splice(k,d.length-k);a=nA(a,c,h,f);return new pA(c,b,f,a)}f.push(g);g.name===Xz&&(g.attributes.push(new _.wg(_.mb,m)),e=!0)}}return new pA(c,b,f)},rA=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},sA=function(a){function b(h,k,l){let m="";for(;k<
5
- 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,4030);}rA(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]<<
6
- 22|a[5]<<14|a[6]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}rA(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},tA=function(a,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,{message:Mz,af:c&&c.message?c.message:null},c);let e=0,f=!1;try{(new _.Mj).M("moof",_.N).M("traf",
7
- _.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,{message:Mz,af:c&&c.message?c.message:null},c);return e},uA=function(a){for(;a.getPosition()<a.wa()-1;){const b=a.getPosition();if(71===_.yj(a))return eA(a),b}return-1},vA=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();eA(d)}function c(){throw new _.G(_.F,4,4030);}const d=new _.vk(new DataView(a),
8
- !1);let e=0,f=0;e=uA(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)&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}},wA=function(a){var b=dA(a,"METHOD");const c=
9
- ["SAMPLE-AES",aA];if(!c.includes(b))return _.Jf("PlayReady in HLS is only supported with [",c.join(", "),"], not",b),null;a=dA(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}],"")},yA=function(a,b){return _.w(function*(){var c=_.bh([b],a.g.attemptParameters);c.type=1;c=yield xA(a,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}})},
10
- DA=function(a,b){return _.w(function*(){var c=qA(a.L,b,a.A);if(1===c.type){a.G.set(a.A,c);c=_.Qo(c.ca[0].a)||"";c=null!=_.Po.video[c]?_.v:null!=_.Po.audio[c]?_.ac:null;var d="";c===_.v?d="avc1.42E01E":c===_.ac&&(d="mp4a.40.2");{c=a.L;var e=a.A;d=a.g.hlsDefaultCodecs||d;var f=[];const h=[];h.push(new _.wg(_.ka,"0"));h.push(new _.wg(_.mb,e));d.length&&h.push(new _.wg(_.ma,d));f.push(new _.xg(c.a++,Xz,h));c=new pA(e,0,f)}}c=yield zA(a,c.qa);if(!a.D)throw new _.G(_.F,7,7001);a.D.filterAllPeriods([c]);
11
- d=Infinity;e=0;f=Infinity;for(var g of a.a.values())d=Math.min(d,g.Dd),e=Math.max(e,g.Dd),g.stream.type!=_.r&&(f=Math.min(f,g.duration));a.j!=AA?(a.h=new _.Az(0,a.S,!1),_.Uu(a.h,1)):a.h=new _.Az(null,0,!0);BA(a);if(a.j!=AA){a.V=a.F;a.j===CA&&(g=Math.max(f,a.h.Md),isNaN(a.g.availabilityWindowOverride)||(g=a.g.availabilityWindowOverride),a.h.Zb=g);for(g=0;95443.7176888889<=e;)g+=95443.7176888889,e-=95443.7176888889;if(g){a.f.debug("Offsetting live streams by",g,"to compensate for rollover");for(const h of a.a.values())95443.7176888889>
12
- h.Dd?(a.f.debug("Offset applied to",h.stream.type),h.segmentIndex.offset(g)):a.f.debug("Offset NOT applied to",h.stream.type)}}else{a.h.Kb(f);a.h.offset(-d);for(const h of a.a.values())h.segmentIndex.offset(-d),_.gv(h.segmentIndex,f)}a.I={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]){const l=e.a,m=l.length-1;e={Cf:e.position,
13
- If:l&&0<l.length?m:null}}else e=null;const {Cf:h,If:k}=e;null!==h&&(d.add("_HLS_msn",h),null!==k&&d.add("_HLS_part",k))}e=d;_.pg(e);e.g&&_.hg(c,d)}const {response:f,text:g}=yield yA(a,c.toString());c=qA(a.L,g,f.uri);if(1!==c.type)throw new _.G(_.F,4,4017);d=b.stream;e=yield EA(a,b.bd,c,d.type,d.mimeType,d.codecs,d.keyInfo||null,b.ff);d.ca=e;b.segmentIndex.replace(e);d=e[e.length-1];hA(c.qa,Qz)&&(FA(a,AA),a.h.Kb(d.endTime))})},EA=function(a,b,c,d,e,f,g,h){return _.w(function*(){var k=c.ca;const l=
14
- HA(c,g);var m=(m=hA(c.qa,Sz))?Number(m.value):0;null===a.N&&(a.N=yield IA(a,b,l,k[0],m,g,e,f,d));const n=a.N;a.f.debug("First segment",k[0].a.split("/").pop(),"starts at",n);var q=hA(c.qa,Pz);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.J.get(t)||0;const u=[];for(const E of _.yu(k)){var y=E.Vc;k=E.item;{var A=u[u.length-1];const D=0==y?n:A.endTime;y=m+y;hA(k.qa,Oz)&&(t++,h.set(t,y),q=yield JA(a,t,b,l,k,y,g,e,f,D,d));A=KA(a,A,k,y,D,q,g,d,c.a);k=hA(k.qa,
15
- Zz);A&&(a.g.hlsLowLatency||k)&&u.push(A)}}a.U.push(u);BA(a);return u})},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.w.stop()},zA=function(a,b){return _.w(function*(){var c=fA(b,"EXT-X-MEDIA"),d=fA(b,Xz),e=fA(b,"EXT-X-IMAGE-STREAM-INF");for(var f of d){var g=_.rg(f,"AUDIO"),h=_.rg(f,"VIDEO"),k=_.rg(f,bA);const l=LA(a,f);if(k){const m=_.Fh(_.r,l);a.m.set(k,m);k=l.indexOf(m);-1<k&&l.splice(k,1)}g&&(k=MA(_.ac,l),a.m.set(g,k));h&&(g=MA(_.v,l),a.m.set(h,g))}yield NA(a,c);f=
16
- gA(c,Lz);for(const l of f)f=OA(l),h=dA(l,_.Ca),g=dA(l,"INSTREAM-ID"),a.K.get(h)||a.K.set(h,new Map),a.K.get(h).set(g,f);d=yield PA(a,d);c=yield QA(a,c);e=yield RA(a,e);return{startTime:0,variants:d,textStreams:c,thumbStreams:e}})},NA=function(a,b){return _.w(function*(){b=b.filter(d=>{const e=_.rg(d,_.mb)||"";return _.rg(d,"TYPE")!==bA&&""!==e});b.length&&(yield SA(a,b[0]));const c=b.slice(1).map(d=>SA(a,d));yield Promise.all(c)})},PA=function(a,b){return _.w(function*(){var c=f=>_.w(function*(){const g=
17
- _.rg(f,"FRAME-RATE"),h=Number(dA(f,_.ka));var k=_.rg(f,_.Za);const [l,m]=k?k.split("x"):[null,null];return(k=yield TA(a,f,k,g))?UA(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(dA(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)})},QA=function(a,b){return _.w(function*(){var c=gA(b,bA),d=c.map(f=>_.w(function*(){try{return(yield SA(a,f)).stream}catch(g){throw g;
18
- }}));d=yield Promise.all(d);for(const f of c){var e=dA(f,_.Ca);if(c=a.m.get(e))if(e=a.o.get(e))for(const g of e)g.stream.codecs=c}return d.filter(f=>f)})},RA=function(a,b){return _.w(function*(){const c=b.map(d=>_.w(function*(){return(yield VA(a,d)).stream}));return(yield Promise.all(c)).filter(d=>d)})},LA=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=_.Fu(e)[0],b.has(c)?a.f.debug("Ignoring duplicate codec"):
19
- (d.push(e),b.add(c));return d},MA=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});},SA=function(a,b){return _.w(function*(){const c=dA(b,_.Ca);var d="";let e=dA(b,"TYPE").toLowerCase();e==_.gu&&(e=_.r);e!==_.r&&c&&a.m.has(c)&&(d=a.m.get(c));const f=dA(b,_.mb);if(a.a.has(f))return a.a.get(f);const g=OA(b),h=_.rg(b,"NAME"),k=b.getAttribute("DEFAULT"),l=b.getAttribute("AUTOSELECT"),m=_.rg(b,"CHANNELS");d=yield WA(a,f,d,e,g,!!k&&!!l,h,e==
20
- _.ac?m?parseInt(m.split("/")[0],10):null:null,null);if(null==d)return null;a.o.has(c)?a.o.get(c).push(d):a.o.set(c,[d]);if(a.a.has(f))return a.a.get(f);a.a.set(f,d);return d})},VA=function(a,b){return _.w(function*(){const c=dA(b,_.mb);if(a.a.has(c))return a.a.get(c);var d=_.rg(b,_.ma)||"jpg",e=OA(b);const f=_.rg(b,"NAME");d=yield WA(a,c,d,_.ed,e,!1,f,null,null);if(null===d)return null;if(a.a.has(c))return a.a.get(c);if(e=_.rg(b,_.ka))d.stream.bandwidth=Number(e);a.a.set(c,d);return d})},TA=function(a,
21
- b,c,d){return _.w(function*(){let e=LA(a,b);var f=_.rg(b,"AUDIO"),g=_.rg(b,"VIDEO"),h=f||g;h=h&&a.o.has(h)?a.o.get(h):[];f={audio:f?h:[],video:g?h:[]};a.f.debug("Guessing stream type for",b.toString());g=!1;const k=dA(b,_.mb),l=f.audio.find(q=>q.bd===k);var m=_.Fh(_.v,e);m=c||d||m;1!==e.length||m?!h.length&&1<e.length?(a.f.debug("Guessing multiplexed audio+video"),h=_.v,e=[e.join(",")]):f.audio.length&&l?(a.f.debug($z),h=_.ac,g=!0):f.video.length?(a.f.debug($z),h=_.ac):(a.f.debug("Guessing video-only"),
22
- h=_.v):(h=_.ac,a.f.debug($z));let n;g||(n=yield XA(a,b,e,h));if(n)f[n.stream.type]=[n];else if(null===n)return a.f.debug("streamInfo is null"),null;YA(f);return f})},UA=function(a,b,c,d,e,f,g){c.forEach(l=>{if(l=l.stream)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.stream:null;const n=m?m.stream:null,q=l?l.drmInfos:null,t=m?m.drmInfos:null;b=(m?m.bd:"")+" - "+(l?
23
- l.bd:"");let u;if(k&&n)if(q.length&&t.length?0<_.Hu(q,t).length:1)u=_.Hu(q,t);else{a.f.warn("Incompatible DRM info in HLS variant. Skipping.");continue}else k?u=q:n&&(u=t);a.W.has(b)?a.f.debug("Skipping variant which only differs in text streams."):(k=ZA(a,k,n,d,u),h.push(k),a.W.add(b))}return h},XA=function(a,b,c,d){return _.w(function*(){const e=dA(b,_.mb);if(a.a.has(e))return a.a.get(e);var f=_.rg(b,Lz),g=null;d==_.v&&f&&"NONE"!=f&&(g=a.K.get(f));f=MA(d,c);g=yield WA(a,e,f,d,_.ye,!1,null,null,
24
- g);if(null==g)return null;if(a.a.has(e))return a.a.get(e);a.a.set(e,g);return g})},YA=function(a){for(const b of a.audio.concat(a.video))a=b.stream.codecs.split(","),a=a.filter(c=>"mp4a.40.34"!=c),b.stream.codecs=a.join(",")},ZA=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}},OA=function(a){a=_.rg(a,"LANGUAGE")||_.ye;return _.Nh(a)},WA=function(a,b,c,d,e,f,g,
25
- h,k){return _.w(function*(){let l=iA(a.A,b);var m=null;if(a.j==AA&&a.G.has(l)){var n=a.G.get(l);a.G.delete(l)}else{const {response:rb,text:pa}=yield yA(a,l);l=rb.uri;n=qA(a.L,pa,l)}if(1!==n.type)throw new _.G(_.F,4,4017);$A(a,n);const q=yield aB(a,d,c,n),t=[];n.ca.forEach(rb=>{rb=fA(rb.qa,"EXT-X-KEY");t.push.apply(t,rb)});let u=!1;const y=[];let A=null;for(var E of t){var D=dA(E,"METHOD"),ha=_.rg(E,"KEYFORMAT","identity");"NONE"!=D&&("AES-128"==D?(m=_.rg(E,"IV",""),m={method:"AES-128",url:iA(a.A,
26
- dA(E,_.mb)),iv:m?_.gj((m||"0x").slice(2)):null},a.H=!0):(u=!0,(D=(D=bB[ha])?D(E,q):null)?(D.keyIds.length&&(A=D.keyIds[0]),y.push(D)):a.f.warn("Unsupported HLS KEYFORMAT",ha)))}if(u&&!y.length&&!a.H)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,uf=gb-D,sb=new _.Bz(ha),vf=a.g.hlsLowLatency?_.yx:_.Yt,Ta=HA(n,m);let Hd=void 0;d==_.r&&(Hd=_.fu);n=(n=hA(n.qa,Wz))?"YES"===_.rg(n,"CAN-BLOCK-RELOAD"):!1;return{stream:{id:a.Z++,originalId:g,
27
- createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:sb.f.bind(sb),getSegmentReference:sb.get.bind(sb),adjustSegmentDurations:sb.g.bind(sb),getDuration:sb.getDuration.bind(sb),segmentIndex:sb,segmentLookupStrategy:vf,initSegmentReference:Ta,mimeType:q,codecs:c,kind:Hd,encrypted:u,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,ca:ha},
28
- segmentIndex:sb,drmInfos:y,bd:b,Ue:l,Dd:D,rg:gb,duration:uf,ff:E,$e:n}})},$A=function(a,b){var c=hA(b.qa,Uz),d=hA(b.qa,Qz);d=c&&"VOD"==c.value||d;c=c&&"EVENT"==c.value&&!d;c=!d&&!c;if(d)FA(a,AA);else{c?FA(a,CA):FA(a,cB);d=hA(b.qa,Yz);if(!d)throw new _.G(_.F,4,4024,{missingTag:Yz});d=Number(d.value);c=hA(b.qa,Tz);a.g.hlsLowLatency&&c?(d=Number(dA(c,"PART-TARGET")),a.F=Math.min(d,a.F),a.C=Math.max(d,a.C),b=hA(b.qa,Wz),a.S=b?Number(dA(b,"PART-HOLD-BACK")):0):(a.C=Math.max(d,a.C),a.F=Math.min(d,a.F),
29
- a.S=3*a.C)}},aB=function(a,b,c,d){return _.w(function*(){var e=d.ca[0];const f=e.a;e=(e=hA(e.qa,Rz))?dA(e,_.mb):null;return dB(a,b,c,f,e)})},HA=function(a,b){var c=fA(a.qa,Rz);if(!c.length)return null;if(1<c.length)throw new _.G(_.F,4,4020);c=c[0];var d=dA(c,_.mb);const e=iA(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 _.zz(()=>[e],a,d,b)},BA=function(a){a.h&&(a.U.forEach(b=>{_.Tu(a.h,b,0)}),a.U=[])},eB=function(a,b){var c=0;let d=null;
30
- b&&(c=b.split("@"),b=Number(c[0]),c=c[1]?Number(c[1]):a.Ia+1,d=c+b-1);return[c,d]},fB=function(a,b,c,d,e,f,g){const h=[];for(const n of _.yu(b.f)){b=n.Vc;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"),[u,y]=eB(k,t);k=_.rg(q,_.mb);const A=(k=iA(g,k))?[k]:[];l=new _.bv(c,l,m,()=>A,u,y,e,f,!1,null,null,null,null);if("YES"===_.rg(q,"INDEPENDENT")||0===b)l.g=!0;h.push(l)}}return h},KA=function(a,b,c,d,e,f,g,h,k){var l=c.qa,m=
31
- c.a;const n=m?[m]:[];m=hA(l,Zz);(g=g?Object.assign({},g):null)&&!g.iv&&(g.iv=_.jj(new Uint8Array(12),new Uint8Array([d>>24&255,d>>16&255,d>>8&255,d&255])));var q=null,t=null,u=null;h===_.ed&&(t=hA(l,"EXT-X-TILES"),q="1x1",t&&(q=_.rg(t,"LAYOUT")||"1x1",u=(u=_.rg(t,"DURATION"))?Number(u):null),[q,t]=q.split("x").map(y=>parseInt(y,10)));if(0===c.f.length&&!m)throw new _.G(_.F,4,4024,{missingTag:Zz});h=null;if(0<c.f.length)if(a.g.hlsLowLatency)h=fB(b,c,d,e,f,g,k);else return null;c=a=0;k=null;m?(a=e+
32
- Number(m.value.split(",")[0]),l=hA(l,Nz),[c,k]=eB(b,l?l.value:null)):a=h[h.length-1].endTime;return new _.bv(d,e,a,()=>n,c,k,f,g,!1,null,q,t,u,h)},IA=function(a,b,c,d,e,f,g,h,k,l){return _.w(function*(){var m=KA(a,null,d,e,0,0,f,k,"");if(!m)return 0;if(a.I&&!l){var n=a.a.get(b).segmentIndex.get(m.position);if(n)return a.f.debug("Found segment start time in previous manifest"),n.startTime;a.f.debug("Unable to find segment start time in previous manifest!")}a.f.debug("Fetching segment to find start time");
33
- if("audio/mpeg"==g)return 0;if(g==_.bc)return m=yield gB(a,m),n=_.H(m.data),rA(n)?sA(n):vA(m.data);if(g==_.Je||g==_.ec)return m=[gB(a,m)],c&&m.push(gB(a,c)),m=yield Promise.all(m),tA(m[0].data,(m[1]||m[0]).data);if(g==_.Ie)return m=yield gB(a,m),vA(m.data);if(g===_.dc||g===_.cc||!MediaSource.isTypeSupported(`${g.split("/")[0]||""}/mp4;codecs="${h}"`))return 0;throw new _.G(_.F,4,4030);})},JA=function(a,b,c,d,e,f,g,h,k,l,m){return _.w(function*(){let n;a.J.has(b)?n=a.J.get(b):(n=(yield IA(a,c,d,e,
34
- f,g,h,k,m,!0))-l,a.f.debug("Discontinuity segment offset",n),a.J.set(b,n));return n})},xA=function(a,b){if(!a.B)throw new _.G(_.F,7,7001);b=a.D.networkingEngine.fetch(b);_.ih(a.B,b);return b.P},gB=function(a,b){return _.w(function*(){const c=b.f(),d=_.Qu(b.Ja(),b.Ta,b.Ta+2048-1,a.g.attemptParameters);d.type=2;const e=_.Qu(b.Ja(),b.Ta,b.Ia,a.g.attemptParameters);e.type=2;c&&(e.keyInfo=c);try{return yield xA(a,a.H?e:d)}catch(f){if(7001==f.code||a.H)throw f;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 preflights.",
35
- d.uris[0]);return yield xA(a,e)}})},dB=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 xA(a,g)).headers["content-type"];if(!g)throw new _.G(_.F,4,4021,f.join(", "));return g.split(";")[0]})},pA=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!");if(null==d[0].a)throw new _.G(_.F,4,4043,"Media playlist must have at least one full segment!");
36
- }this.a=a;this.type=b;this.qa=c;this.ca=1===b?d:null}},mA=class{constructor(a,b,c){c=void 0===c?[]:c;this.qa=b;this.a=a;this.f=c}},kA=[Yz,Sz,Pz,Uz,Rz,"EXT-X-I-FRAMES-ONLY",Qz,Wz,Tz],oA=[Zz,Nz,Oz,"EXT-X-PROGRAM-DATE-TIME","EXT-X-KEY","EXT-X-DATERANGE"],lA=["EXT-X-PART",Vz],hB=class{constructor(){this.a=0}},iB=class{constructor(){this.g=this.D=null;this.Z=1;this.S=0;this.o=new Map;this.W=new Set;this.a=new Map;this.h=null;this.A="";this.L=new hB;this.V=0;this.R=new Map;this.w=new _.Th(()=>{this.vb()});
37
- this.j=AA;this.I=null;this.C=0;this.F=Infinity;this.B=new _.So;this.U=[];this.K=new Map;this.H=!1;this.m=new Map;this.N=null;this.f=new _.O("clpp.hls.HlsParser");this.G=new Map;this.J=new Map}configure(a){this.g=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.R.clear();for(const c of this.a.keys()){const d=this.a.get(c);!d.stream||d.stream.id!==b&&d.stream.id!==a||this.R.set(c,d)}}start(a,b){const c=this;return _.w(function*(){c.D=b;const {response:d,text:e}=
38
- yield yA(c,a);c.A=d.uri;yield DA(c,e);const f=c.V;0<f&&c.w.$(f);return c.I})}stop(){this.w&&(this.w.stop(),this.w=null);const a=[];this.B&&(a.push(this.B.destroy()),this.B=null);this.g=this.D=null;this.W.clear();this.a.clear();this.G.clear();this.I=null;this.o.clear();this.m.clear();return Promise.all(a)}update(){const a=this;return _.w(function*(){if(a.j!=AA){var b=[];a.N=null;var c=Array.from(a.a.values()),d=Array.from(a.R.values());c=a.g.hlsLowLatency&&0<d.length?d:c;yield GA(a,c[0]);for(d=1;d<
39
- 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.w.$(a.V)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.w.$(.1))}})}},bB={"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":wA,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":wA,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=
40
- dA(a,"METHOD");const c=["SAMPLE-AES",aA];if(!c.includes(b))return _.Jf("Widevine in HLS is only supported with [",c.join(", "),"], not",b),null;b=dA(a,_.mb);b=_.go(b);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",cB="EVENT",CA="LIVE";_.x("clpp.hls.HlsComponent",class extends _.Lp{constructor(){super()}f(){_.Kn.m3u8=iB;_.In[_.Pi]=iB;_.In[cA]=iB}a(){_.jv("m3u8");_.kv(_.Pi);_.kv(cA)}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 Rz="CLOSED-CAPTIONS",Sz="Could not parse MP4 segment start time.",Tz="EXT-X-BYTERANGE",Uz="EXT-X-DISCONTINUITY",Vz="EXT-X-DISCONTINUITY-SEQUENCE",Wz="EXT-X-ENDLIST",Xz="EXT-X-KEY",Yz="EXT-X-MAP",Zz="EXT-X-MEDIA-SEQUENCE",$z="EXT-X-PART-INF",aA="EXT-X-PLAYLIST-TYPE",bA="EXT-X-PRELOAD-HINT",cA="EXT-X-SERVER-CONTROL",dA="EXT-X-STREAM-INF",eA="EXT-X-TARGETDURATION",fA="Failed to infer discontinuity number",gA="Guessing audio-only",hA="METHOD",iA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 in combination with another EXT-X-KEY tag, which is not supported.",
2
+ jA="Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist , which is not supported.",kA="SAMPLE-AES-CTR",lA="application/vnd.apple.mpegurl",mA="sample",nA="whole-segment",oA=function(a,b){return _.qg(a,b,void 0,{required:!0})},pA=function(a){if(1>a.a)throw _.wj();--a.a},qA=function(a){if(null!==a&&void 0!==a)return Number(a)},rA=function(a,b){return a.filter(c=>c.name===b)},sA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=
3
+ oA(d,"TYPE");return c.includes(d)})},tA=function(a,b){return a.some(c=>c.name===b)},uA=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,4,4024,{missingTag:b});return a},vA=function(a){var b=uA(a,"EXT-X-TILES");if(!b)return{ve:1,Ve:1,durationPerTile:null};a=_.qg(b,"LAYOUT")||"1x1";b=(b=_.qg(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{ve:c,Ve:d,durationPerTile:b}},wA=function(a,b){return _.yu([a],[b])[0]},xA=
4
+ 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)},yA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of xA(c))b(d,c)})},zA=function(a){return a.type===_.p||a.type===_.w},AA=function(a){const b=uA(a,aA);if(uA(a,Wz))return _.Tt;if(!b)return"LIVE";if(b.value===_.Tt)return _.Tt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);
5
+ },BA=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.");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}},
6
+ CA=function(a,b){a=uA(a,Tz);return BA(a?a.value:null,b)},DA=function(a){a=uA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},EA=function(a,b){b=void 0===b?{}:b;const c={Qc:!1,kf:!1,lf:null,Jf:null,Je:null};a=uA(a,cA,{required:b.Me});if(!a)return c;const d=e=>null==e?null:Number(e);c.Qc="YES"===_.qg(a,"CAN-BLOCK-RELOAD");c.kf="YES"===_.qg(a,"CAN-SKIP-DATERANGES");c.lf=d(_.qg(a,"CAN-SKIP-UNTIL"));c.Jf=d(_.qg(a,"HOLD-BACK"));c.Je=d(_.qg(a,"PART-HOLD-BACK",void 0,
7
+ {required:b.Me}));return c},FA=function(a,b,c){c=void 0===c?!1:c;a=_.qg(a,"BYTERANGE");return BA(a,b,c)},HA=function(a,b){const c=CA(a.ca,null);return new GA(0,0,0,()=>[a.a],c.ta,c.ha,0,b)},IA=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.ah(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},JA=function(a){let b=Infinity,c=Infinity;xA(a).filter(zA).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,
8
+ d);c=Math.min(c,e)});return{ub:b,duration:c}},KA=function(a){return a.map(b=>{({duration:b}=JA(b));return b}).reduce((b,c)=>b+c,0)},LA=function(a,b,c){if(b===_.Tt)return{delay:0,Oc:0};b=uA(a,$z);if(c&&b)return c=Number(oA(b,"PART-TARGET")),{Je:a}=EA(a,{Me:!0}),{delay:a,Oc:c};a=uA(a,eA,{required:!0});a=Number(a.value);return{delay:3*a,Oc:a}},MA=function(a){const b=[];yA(a,c=>{b.push(c.Rf)});return{delay:Math.max(...b.map(c=>c.delay)),Oc:Math.min(...b.map(c=>c.Oc))}},NA=function(a){const b=new Map;
9
+ 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},OA=function(a){a=_.qg(a,"LANGUAGE")||_.ye;return _.sg(a)},QA=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),PA(b,a)},UA=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.fh(a.a++,h),RA.includes(h.name)?d.push(h):SA.includes(h.name)?"EXT-X-PART"===h.name?g.push(h):h.name===bA&&"PART"===_.qg(h,"TYPE")&&
10
+ g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=wA(b,h.trim()),e.push(new TA(h,f,g)),f=[],g=[])});0<g.length&&e.push(new TA(null,f,g));return{V:e,ca:d}},VA=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},WA=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},XA=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]<<
11
+ 21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}WA(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}}WA(a,e)||d();
12
+ e+=10;e+=f}while(e<a.byteLength);return d()},YA=function(a,b){let c=null,d=0;try{(new _.Mj).L(_.wd,_.Fj).L(_.we,_.Fj).L(_.rd,_.Fj).Y("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.N(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.fq.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,Sz,c);let e=0,f=!1;try{(new _.Mj).L("moof",_.Fj).L("traf",_.Fj).Y("tfdt",g=>{e=(0==g.version?_.N(g.reader):_.Bj(g.reader))/d;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||
13
+ !f)throw new _.H(_.G,4,4030,Sz,c);return e},ZA=function(a){for(;a.getPosition()<a.za()-1;){const b=a.getPosition();if(71===_.xj(a))return pA(a),b}return-1},$A=function(a){function b(){d.seek(e+188);f=_.xj(d);71!=f&&(d.seek(e+192),f=_.xj(d));71!=f&&(d.seek(e+204),f=_.xj(d));71!=f&&c();pA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.vk(new DataView(a),!1);let e=0,f=0;e=ZA(d);0>e&&(_.fq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.xj(d);71!=f&&
14
+ c();a=_.yj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.xj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.xj(d),d.skip(a));if(1!=_.N(d)>>8){b();continue}d.skip(3);a=_.xj(d)>>6;0!=a&&1!=a||c();0==_.xj(d)&&c();a=_.xj(d);const g=_.yj(d),h=_.yj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},cB=function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("PlayReady in HLS is only supported with [",aB.join(", "),"], not",b),null;a=oA(a,_.mb);b=_.go(a);a=null;b=_.I(b.data);
15
+ try{a=_.pu(_.Ck(b))}catch(c){a=b}return _.zu(_.Jc,[{initDataType:_.tc,initData:a}],"")},hB=function(a,b,c,d){if(null===d){if(a.slice(1).some(dB))throw new _.H(_.G,4,4046,jA);if((d=eB(a[0].ca,b,c))&&d.type===nA){if(0<fB(a.slice(1)).length)throw new _.H(_.G,4,4046,iA);return[d]}a=fB(a).map(e=>eB(e.ca,b,c));return 0===a.length?[gB()]:a}if(a.some(dB))throw new _.H(_.G,4,4046,jA);if(d.type===nA){if(0<fB(a).length)throw new _.H(_.G,4,4046,iA);return[d]}d=d.type===mA?[d]:[];a=fB(a).map(e=>eB(e.ca,b,c));
16
+ return d.concat(a)},iB=function(a){if(0===a.length)return gB();if(a.some(c=>c.type===nA)||a.every(c=>c.type===_.Ad))return a[0];a=a.filter(c=>c.type===mA);const b=Array.from((new Set(a.flatMap(c=>c.drmInfos))).values());return{keyInfo:null,keyId:a[a.length-1].keyId,type:mA,drmInfos:b}},dB=function(a){return rA(a.ca,Xz).some(b=>"AES-128"===_.qg(b,hA))},fB=function(a){return a.filter(b=>tA(b.ca,Xz))},eB=function(a,b,c){a=rA(a,Xz);if(0===a.length)return null;var d=oA(a[0],hA);if(1===a.length){if("NONE"===
17
+ d)return gB();if("AES-128"===d)return a=a[0],d=_.qg(a,"IV",""),{type:nA,keyInfo:{method:"AES-128",url:wA(b,oA(a,_.mb)),iv:d?_.Yg((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=a.map(e=>oA(e,hA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===kA))throw jB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.qg(e,"KEYFORMAT","identity");{const g=kB[f]||null;e=g?g(e,c):null}e||jB.warn("Unsupported HLS KEYFORMAT",
18
+ 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:mA,drmInfos:b}},gB=function(){return{type:_.Ad,keyInfo:null,drmInfos:[],keyId:null}},lB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.Tu(b.Fa(),b.ta,b.ta+2048-1,a.a.attemptParameters);e.type=2;const f=_.Tu(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===
19
+ 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.");}}})},mB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===
20
+ d||d===_.dc||d===_.cc)return 0;if(d===_.bc){var g=yield lB(a,c,f);const h=_.I(g.data);return WA(h)?XA(h):$A(g.data)}if(d===_.Ke||d===_.ec)return g=[lB(a,c,f)],b&&g.push(lB(a,b,!0)),g=yield Promise.all(g),YA(g[0].data,(g[1]||g[0]).data);if(d===_.Je)return g=yield lB(a,c,f),$A(g.data);if(!MediaSource.isTypeSupported(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},nB=function(a,b){a=a.map(c=>c.ea[b]);return a.some(c=>null==c)?null:a},PA=function(a,b){a.ea.forEach(c=>
21
+ {c.codecs=b.join(",")})},oB=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},pB=function(a,b){a.ea.forEach(c=>{c.width=b})},qB=function(a,b){a.ea.forEach(c=>{c.height=b})},rB=function(a,b){a.ea.forEach(c=>{c.frameRate=b})},sB=function(a,b){a.ea.forEach(c=>{c.bandwidth=b})},tB=function(a,b){return a.ea.some(c=>c.id===b)},uB=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},xB=function(a,
22
+ b,c,d){var e=a[0].length();e=VA(e).map(f=>{const g=uB(a,f)||[],h=nB(b,f)||[],k=nB(c,f)||[];return vB({variants:g,textStreams:h,thumbStreams:k,Pf:d&&0===f})});wB(e);return e},zB=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=xA(e);0<f&&yB(g,e.startTime);g.forEach(h=>{const k=h.ec;d.has(k)?d.get(k).push(h):d.set(k,[h])})});yA(b,e=>{var f=d.get(e.ec);const g=f.flatMap(h=>h.V);f=f.map(h=>({keyInfo:h.keyInfo,type:h.qe,drmInfos:h.drmInfos,
23
+ keyId:h.keyId}));f=iB(f);e.keyInfo=f.keyInfo;e.qe=f.type;e.encrypted=f.type===mA;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})},vB=function(a){const b=a.variants,c=a.textStreams,d=a.thumbStreams;var e=a.Pf;a=[...b.flatMap(l=>[l.video,l.audio]),...c,...d].filter(Boolean);const f=a[0].ub;e=e?f:0;AB(a,e);const {Eb:g,bd:h,duration:k}=a[0];return{variants:b,textStreams:c,thumbStreams:d,startTime:0,id:`P${g}`,endTime:h,
24
+ duration:k+e,Eb:g}},wB=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}},AB=function(a,b){yB(a,0);BB(a);0<b&&yB(a,b)},yB=function(a,b){a.forEach(c=>{const d=-c.ub+b;c.segmentIndex.offset(d);c.bd+=d;c.ub=b})},BB=function(a){const b=CB(a);a.forEach(c=>{_.kv(c.segmentIndex,b);c.duration=b;c.bd=c.ub+b})},CB=function(a){let b=Infinity;a.filter(zA).forEach(c=>{b=Math.min(b,c.duration)});return b},DB=function(a,b){return _.y(function*(){var c=
25
+ _.kh([b],a.f.attemptParameters);c.type=1;c=yield a.F(c);let d="";try{d=_.Fg(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}})},KB=function(a,b){return _.y(function*(){var c=EB(a,b,a.h,"");if(1===c.type){a.w.set(a.h,c);c=_.Qo(c.V[0].a)||"";c=null!=_.Po.video[c]?_.w:null!=_.Po.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.K;var e=a.h;d=a.f.hlsDefaultCodecs||d;const h=[],k=[];k.push(new _.dh(_.ja,
26
+ "0"));k.push(new _.dh(_.mb,e));d.length&&k.push(new _.dh(_.la,d));h.push(new _.eh(c.a++,dA,k));c=new FB(e,0,h)}}d=c.ca;c=rA(d,"EXT-X-MEDIA");e=rA(d,dA);d=rA(d,"EXT-X-IMAGE-STREAM-INF");c={tc:{ff:sA(c,["AUDIO",_.sb]),closedCaptions:sA(c,Rz),kg:sA(c,"SUBTITLES")},Xe:e,Kf:d};c=yield GB(a,c);if(!a.D)throw new _.H(_.G,7,7001);d=MA(c[0]);e=HB(a,d.delay,c);if(!IB(a)){a.H=d.Oc;d=0;for(var f of a.g.values())d=Math.max(d,f.ea[0].ub);for(f=0;95443.7176888889<=d;)f+=95443.7176888889,d-=95443.7176888889;if(f){a.a.debug("Offsetting live streams by",
27
+ f,"to compensate for rollover");for(var g of a.g.values())d=g.ea[0],95443.7176888889>d.ub?(a.a.debug("Offset applied to",d.type),d.segmentIndex.offset(f)):a.a.debug("Offset NOT applied to",d.type)}}g=KA(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===_.Tt&&JB(e,g,c);g={presentationTimeline:e,periods:c,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",g);return g})},PB=function(a,b,c,d){return _.y(function*(){var e=
28
+ b.ea[0],f=LB(a,e);const {response:g,text:h}=yield DB(a,f.toString());f=EB(a,h,g.uri,e.ec);MB(f,e.codecs,e.type);if(1!==f.type)throw new _.H(_.G,4,4017);const k=(yield NB(a,f,e.type,e.codecs)).flatMap(l=>l.V);e.V=k;e.segmentIndex.replace(k);_.Xu(c,k,d);e=k[k.length-1];uA(f.ca,Wz)&&(OB(a,_.Tt),_.Uu(c,!0),c.f=e.endTime)})},LB=function(a,b){const c=new _.dg(b.cf);if(a.f.hlsLowLatency){a=c.a;if(b.Qc){b=b.segmentIndex;if(b=b.a[b.a.length-1]){var d=b.a,e=d.length-1;b={Sf:b.position,Yf:d&&0<d.length?e:null}}else b=
29
+ null;const {Sf:f,Yf:g}=b;null!==f&&(a.add("_HLS_msn",f),null!==g&&a.add("_HLS_part",g))}b=a;_.og(b);b.g&&_.gg(c,a)}return c},EB=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=_.fh(0,h),RA.includes(e.name)){f=1;break}else e.name===dA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.Du(b)){let {xd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||
30
+ g)g=!1;else{e=m;e=_.fh(a.a++,e);if(QB.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=UA(a,c,k);c=new FB(c,h,f.concat(a.ca),a.V);break a}f.push(e);e.name===dA&&(e.attributes.push(new _.dh(_.mb,n)),g=!0)}}c=new FB(c,h,f)}c.a=d;RB(c);return c},MB=function(a,b,c){if(1===a.type&&(a=a.V.map(d=>d.a?d.a:d.f.map(e=>_.qg(e,_.mb))||null).map(d=>_.Ro(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.");
31
+ },NB=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=uA(b.ca,Zz))?Number(h.value):g;g=[];a:{var k=a.g.get(b.a),l=!IB(a),m=uA(b.ca,Vz);if(m)var n=Number(m.value);else{k?(m=k.ea[k.ea.length-1].V,m=m[m.length-1].Eb):m=0;if(l&&0<m)try{var q=uA(b.ca,Zz);if(!q)throw SB.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(fA);var t=Number(q.value),u=oB(k,t);if(!u)throw SB.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+
32
+ ` (segment position = ${t})`),Error(fA);n=u.Eb;break a}catch(A){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}n=0}}q=yield TB(a,b.f,e,f,h,c,d);t=h;if(0===f.length)f=[];else{u=[];h=[];for(var x of f)tA(x.ca,Uz)&&0<h.length&&(u.push(h),h=[]),h.push(x);u.push(h);f=u}for(x=0;x<f.length;x++)u=f[x],q=yield UB(a,e,b.f,u,n+x,t,q,c,d,g[g.length-1]||null),g.push(q),q=q.endTime,t+=u.length;return g})},OB=function(a,b){a.m=b;IB(a)&&a.j.stop()},GB=
33
+ function(a,b){return _.y(function*(){var c=b.tc.closedCaptions;var d=new Map;for(var e of c){c=OA(e);var f=oA(e,_.Ca),g=oA(e,"INSTREAM-ID");d.has(f)||d.set(f,new Map);d.get(f).set(g,c)}c=b.Xe;e=new Map;for(k of c){f=_.qg(k,"AUDIO");c=_.qg(k,_.sb);var h=_.qg(k,"SUBTITLES");g=VB(a,k);if(h){const l=_.Oh(_.v,g);e.set(h,l);h=g.indexOf(l);-1<h&&g.splice(h,1)}f&&(h=WB(_.p,g),e.set(f,h));c&&(f=WB(_.w,g),e.set(c,f))}var k=e;e=yield XB(a,b.tc.ff,k);d=yield YB(a,b.Xe,e,d);k=yield ZB(a,b.tc.kg,k);e=yield $B(a,
34
+ b.Kf);k=xB(d,k,e,!IB(a));k=[zB(k)];a.D.filterAllPeriods(k);return k})},HB=function(a,b,c){let d=!0,e=null,f=0;IB(a)||(d=!1,e=0,f=b);const g=new _.Gz(e,f,!0);_.Uu(g,d);yA(c,(h,k)=>{_.Xu(g,h.V,k.startTime)});return g},XB=function(a,b,c){return _.y(function*(){var d=b.filter(f=>""!==(_.qg(f,_.mb)||""));if(0===d.length)return new Map;let e=[aC(a,d[0],c)];yield e[0];e=e.concat(d.slice(1).map(f=>aC(a,f,c)));d=yield Promise.all(e);return NA(d)})},YB=function(a,b,c,d){return _.y(function*(){const e=new Set;
35
+ var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(oA(f[k],_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield bC(a,h,c,d,e);f=f.map(k=>bC(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.wu,[])})},ZB=function(a,b,c){return Promise.all(b.map(d=>aC(a,d,c)))},$B=function(a,b){return Promise.all(b.map(c=>cC(a,c)))},VB=function(a,b){var c=_.qg(b,_.la,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=
36
+ _.Ju(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},WB=function(a,b){if(1===b.length)return b[0];a=_.Oh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},aC=function(a,b,c){return _.y(function*(){const d=oA(b,_.mb);return dC(a,d,()=>_.y(function*(){const e=oA(b,_.Ca);var f={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.v,"CLOSED-CAPTIONS":_.v}[oA(b,"TYPE").toUpperCase()];if(!f)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const g=
37
+ c.get(e)||"",h=OA(b),k=_.qg(b,"NAME"),l=b.getAttribute("DEFAULT"),m=b.getAttribute("AUTOSELECT"),n=_.qg(b,"CHANNELS");return yield eC(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})}))})},cC=function(a,b){return _.y(function*(){const c=oA(b,_.mb);return dC(a,c,()=>_.y(function*(){var d=_.qg(b,_.la)||"jpg",e=OA(b);const f=_.qg(b,"NAME");d=yield eC(a,{uri:c,codecs:d,type:_.ed,language:e,
38
+ name:f,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ee:null});(e=_.qg(b,_.ja))&&sB(d,Number(e));return d}))})},bC=function(a,b,c,d,e){return _.y(function*(){var f=Number(oA(b,_.ja));if(null!=b.getAttribute("FRAME-RATE")||null!=b.getAttribute(_.Za)){var g=_.qg(b,"FRAME-RATE");var h=_.qg(b,_.Za),[k,l]=h?h.split("x"):[null,null];g={frameRate:qA(g),width:qA(k),height:qA(l)}}else g=null;if(h=yield fC(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=[];
39
+ for(const X of m)for(const na of g)if(m=(na?na.ea[0].ec:"")+" - "+(X?X.ea[0].ec:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=X,t=na,u=f;const tb=[],Jd=(t||q).length();for(let Pb=0;Pb<Jd;Pb++){var x=q?q.ea[Pb]||null:null,A=t?t.ea[Pb]||null:null,E=x,D=A;E=E&&D?_.Gu(E.drmInfos,D.drmInfos)?_.Fu(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:_.ye,primary:!!x&&x.primary||!!A&&
40
+ A.primary,audio:x,video:A,bandwidth:D,drmInfos:E,allowedByApplication:!0,allowedByKeySystem:!0};tb.push(x)}n=new gC(tb)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(h.push(n),e.add(m))}f=h}else f=[];return f})},fC=function(a,b,c,d,e){return _.y(function*(){let f=VB(a,b);var g=_.qg(b,"AUDIO"),h=_.qg(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=oA(b,_.mb);var m=g.audio.find(q=>q.ec===l);
41
+ var n=_.Oh(_.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(gA),m=_.p,h=!0):g.video.length?(a.a.debug(gA),m=_.p):(a.a.debug("Guessing video-only"),m=_.w):(m=_.p,a.a.debug(gA));n=null;h||(n=yield hC(a,b,f,m,e,c));if(null==n)return null;g[m]=[n];m===_.p&&c&&k.forEach(q=>{pB(q,c.width);qB(q,c.height);rB(q,c.frameRate)});QA(g);return g})},hC=function(a,b,c,d,e,f){return _.y(function*(){const g=oA(b,_.mb);
42
+ return dC(a,g,()=>_.y(function*(){var h=_.qg(b,Rz);let k=null;d===_.w&&h&&"NONE"!==h&&(k=e.get(h));h=WB(d,c);return yield eC(a,{uri:g,codecs:h,type:d,closedCaptions:k,primary:!1,language:null,name:null,channelsCount:null,groupId:null,ee:f})}))})},dC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},eC=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,
43
+ k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ee;let q=wA(a.h,c);if(IB(a)&&a.w.has(q)){var t=a.w.get(q);a.w.delete(q)}else{const {response:X,text:na}=yield DB(a,q);q=X.uri;t=EB(a,na,q,c);MB(t,d,e)}if(1!==t.type)throw new _.H(_.G,4,4017);var u=AA(t.ca);OB(a,u);const x=LA(t.ca,u,a.f.hlsLowLatency||!1);u=yield NB(a,t,e,d);const A=a.f.hlsLowLatency?_.Ex:_.$t;let E=void 0;e===_.v&&(E=_.hu);const {Qc:D}=EA(t.ca);t=u.map(X=>{const na=X.V,tb=X.rf,Jd=X.mimeType;X=X.Eb;const Pb=na[0].startTime,Qa=na[na.length-
44
+ 1].endTime,Fe=Qa-Pb,bb=new _.Hz(na),qa=na[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:A,initSegmentReference:qa,mimeType:Jd,codecs:d,kind:E,qe:tb.type,encrypted:tb.type===mA,keyId:tb.keyId,language:f||_.ye,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,
45
+ 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:tb.keyInfo,V:na,drmInfos:tb.drmInfos,Eb:X,ec:c,cf:q,ub:Pb,bd:Qa,duration:Fe,Qc:D,groupId:g,Rf:x}});return new iC(t)})},RB=function(a){1===a.type&&a.V.slice(1).forEach(b=>{if(tA(b.ca,Yz))throw new _.H(_.G,4,4045,"Media playlist contains one or more EXT-X-MAP tags that are not located at the beginning of the playlist. This is valid, but not yet supported.");
46
+ })},jC=function(a,b,c){a=rA(a.ca,Yz);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=oA(a,_.mb),e=wA(b,d);b=FA(a,null,!0);return new _.Ez(()=>[e],b.ta,b.ha,c)},kC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.Du(b.f)){b=q.xd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.qg(t,"DURATION"));n=m+n;k=FA(t,k?null:l.ha,k);l=_.qg(t,_.mb);const u=(l=wA(g,l))?[l]:[];m=new GA(c,m,n,()=>u,k.ta,k.ha,e,f,!1,null,null,null,null);if("YES"===_.qg(t,"INDEPENDENT")||
47
+ 0===b)m.g=!0;h.push(m)}}return h},lC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ca;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}=DA(n),a=e+c,q=CA(n,b?b.ha:null)):(b=kC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.ed?vA(n):null;d=new GA(d,e,a,()=>u,q.ta,q.ha,f,g,!1,null,h?h.ve:null,h?h.Ve:null,h?h.durationPerTile:null,x);d.Eb=l;d.initSegment=m||void 0;return d},TB=function(a,b,c,d,e,f,g){return _.y(function*(){var h=
48
+ d[0];if(null!=a.B)return a.B;const k=yield mC(a,f,g,h);var l=hB([h],a.h,k,null)[0];const m=jC(h,b,l.keyInfo);l=IA(l.keyInfo,e);h=yield nC(a,c,m,h,e,l,k,g);a.a.debug(`Setting playlist start time to ${h}.`);return a.B=h})},UB=function(a,b,c,d,e,f,g,h,k,l){return _.y(function*(){var m=d[0],n=null==l;const q=yield mC(a,h,k,m);var t=hB(d,a.h,q,l?l.Qf:null);const u=t[t.length-1];t=iB(t);const x=jC(m,c,t.keyInfo)||(l?l.Lf:null);var A=IA(t.keyInfo,f);m=n&&IB(a)?0:yield oC(a,e,b,x,m,f,A,q,k,g);n=[];for(A=
49
+ 0;A<d.length;A++){var E=d[A];const D=n[n.length-1]||null,X=0===A?g:D.endTime,na=f+A,tb=IA(t.keyInfo,na);(E=lC(a,D,E,na,X,m,tb,h,c,e,x))&&n.push(E)}return{V:n,rf:t,Qf:u,mimeType:q,endTime:n[n.length-1].endTime,Eb:e,Lf:x}})},mC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=uA(d.ca,Yz);f=f?oA(f,_.mb):null;return pC(a,b,c,e,f)})},nC=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=oB(k,e))?k.startTime:null:null;if(null!=k)return a.a.debug("Found segment start time in previous manifest"),
50
+ k;a.a.debug("Unable to find segment start time in previous manifest!");k=HA(d,f);return mB(a.M,c,k,g,h,null!=f)})},IB=function(a){return a.m===_.Tt},oC=function(a,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 nC(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})},pC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Rh(f,b,c);if(g)return g;g=_.kh([d],a.f.attemptParameters);g.method=
51
+ "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]})},JB=function(a,b,c){a.f=b;b=c[0];const d=JA(b);a.offset(-d.ub);yA(b,e=>{e.segmentIndex.offset(-d.ub);_.kv(e.segmentIndex,d.duration)})},FB=class{constructor(a,b,c,d){if(1===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=
52
+ a;this.a="";this.type=b;this.ca=c;this.V=1===b?d:null}},TA=class{constructor(a,b,c){c=void 0===c?[]:c;this.ca=b;this.a=a;this.f=c}},GA=class extends _.fv{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:q,t);this.initSegment=void 0;this.Eb=0}},RA=[Vz,Wz,"EXT-X-I-FRAMES-ONLY",Zz,$z,aA,cA,eA],QB=["EXTINF",Tz,"EXT-X-DATERANGE",Uz,Xz,Yz,"EXT-X-PROGRAM-DATE-TIME"],SA=["EXT-X-PART",
53
+ bA],qC=class{constructor(){this.a=0}},rC=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();this.f.clear()}},SB=new _.O("clpp.hls.DiscontinuityUtils");var kB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Je)throw new _.H(_.G,4,4041);if(oA(a,hA)===kA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.zu(_.Ic,[{initDataType:_.he,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":cB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":cB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=oA(a,hA);if(!aB.includes(b))return bB.error("Widevine in HLS is only supported with [",
54
+ aB.join(", "),"], not",b),null;b=oA(a,_.mb);b=_.go(b);b=_.I(b.data);b=_.zu(_.Kc,[{initDataType:_.tc,initData:b}],"");if(a=_.qg(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},aB=["SAMPLE-AES",kA],bB=new _.O("clpp.hls.DrmParser");var jB=new _.O("clpp.hls.EncryptionUtils");var sC=class{constructor(a){this.f=new _.O("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.hh()}}};var iC=class{constructor(a){this.ea=a}length(){return this.ea.length}};var gC=class{constructor(a){this.a=a}length(){return this.a.length}};var tC=class{constructor(){this.f=this.D=null;this.I=1;this.g=new rC;this.h="";this.K=new qC;this.H=0;this.A=new Map;this.j=new _.Zh(()=>{this.xb()});this.m=_.Tt;this.C=null;this.o=new _.Uo;this.B=null;this.a=new _.O("clpp.hls.HlsParser");this.w=new Map;this.G=new Map;this.M=new sC(this.F.bind(this));this.J=!1}configure(a){this.f=a;this.M.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&&tB(c,b)||null!=a&&tB(c,
55
+ 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 DB(c,a);c.h=d.uri;const f=yield KB(c,e);c.C=f;const g=c.H;0<g&&c.j.$(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;
56
+ return _.y(function*(){var b=a.C;if(!IB(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 PB(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(PB(a,e[f],c,b));yield Promise.all(d)}})}xb(){const a=this;return _.y(function*(){a.a.debug(_.St);if(a.D)try{yield a.update(),a.j.$(a.H)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.j.$(.1))}})}F(a){if(!this.o)throw new _.H(_.G,
57
+ 7,7001);a=this.D.networkingEngine.fetch(a);_.rh(this.o,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Mp{constructor(){super()}f(){_.Kn.m3u8=tC;_.In[_.Vi]=tC;_.In[lA]=tC}a(){_.nv("m3u8");_.ov(_.Vi);_.ov(lA)}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 wI=function(a){a.a.one(a.l,_.nd,()=>vI(a))},vI=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>xI(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{xI(a,{track:d})});!yI(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."),zI(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.")},xI=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=>AI(a,c)))},yI=function(a){return a.some(b=>b.kind===_.td)},zI=function(a,b){const c=a.l.getTrackManager(),d=c.ka(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.pa(d);a.a.on(b.textTracks,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,f),c.pa(d))});c.pa(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
3
- AI=function(a,b){const c=BI(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 CI(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)}}})},BI=function(a){return(a=a.l.getTrackManager().la())&&a.language&&a.language.toLowerCase()},
4
- CI=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 DI=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;wI(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var EI=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 DI(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",EI);
5
- EI.Id="hlssmpte";_.Sm(new class{create(){return new EI}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var IJ=function(a){a.a.one(a.l,_.nd,()=>HJ(a))},HJ=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Nb,d=>JJ(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.td).forEach(d=>{JJ(a,{track:d})});!KJ(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."),LJ(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.")},JJ=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=>MJ(a,c)))},KJ=function(a){return a.some(b=>b.kind===_.td)},LJ=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,_.Nb,g=>{g.track.kind===_.td&&(a.a.off(b.textTracks,_.Nb,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
+ MJ=function(a,b){const c=NJ(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 OJ(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Jg(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)}}})},NJ=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
4
+ OJ=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(_.qf(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=_.qf(a)?a:null}}};var PJ=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.uo;this.h=(a=_.io[_.Zb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.O("clpp.hlssmpte.ImageCueHandler");this.g=null;IJ(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var QJ=class extends _.kq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.mi()){var b=a.getConfiguration();b=_.lf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.ic&&(b.patchMetadataTrack=!1);_.rf(b.timestampOffset)||(b.timestampOffset=0);this.a=new PJ(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",QJ);
5
+ QJ.Id="hlssmpte";_.Sm(new class{create(){return new QJ}});};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 oH="Unsupported unit",pH="clpp-text-plain",qH="clpp-text-ttml",rH="clpp.htmlcue.HtmlTextDisplayer",sH="initial",tH=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},uH=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},wH=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>vH[c]);return a},yH=
2
- function(a,b){xH(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{xH(a,c)})},xH=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},zH=function(a,b){return 0===a?"0":a+b},AH=function(a,b){return 1>Math.abs(a-b)||a<b},BH=function(a,b){return a<b&&1<Math.abs(a-b)},CH=function(a,b){return a>b&&1<Math.abs(a-b)},DH=function(a,b){return 1>Math.abs(a-b)||a>b},FH=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 EH(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},GH=function(a){return new EH(a.f,a.g,a.h,a.a,a.height,a.width)},HH=function(a,b){return b.some(c=>BH(a.f,c.g)&&CH(a.g,c.f)&&BH(a.h,c.a)&&CH(a.a,c.h))},IH=function(a,b){return DH(a.h,
4
- b.h)&&AH(a.a,b.a)&&DH(a.f,b.f)&&AH(a.g,b.g)},JH=function(a,b,c){switch(c){case "+x":return BH(a.f,b.f);case "-x":return CH(a.g,b.g);case "+y":return BH(a.h,b.h);case "-y":return CH(a.a,b.a);default:throw Error("Unknown axis");}},KH=function(a){return a.f.writingMode===_.yo},LH=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 KH(a)?b:c},MH=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");}},NH=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},OH=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},PH=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},SH=function(a,b,c){return(QH(a)||RH(a))&&_.qf(c)?zH(c,_.Xd):QH(a)&&_.z(c)?zH(0,_.Xd):KH(a)&&_.qf(b)?zH(b,"%"):sH},TH=function(a,b,c){return KH(a)&&_.qf(c)?zH(c,_.Xd):(QH(a)||RH(a))&&_.qf(b)?zH(b,"%"):sH},RH=function(a){return a.f.writingMode===_.He},QH=function(a){return a.f.writingMode===_.Ge},UH=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},VH=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=FH(a.j.a)},WH=function(a,b){VH(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},XH=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(oH);},ZH=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);YH(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},$H=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)},aI=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},bI=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},YH=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())},cI=function(a){a=_.kf(a.getConfiguration().htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},iI=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=dI(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,eI(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=qH;break;case _.wo:g=pH}g&&!f.classList.contains(g)&&_.mm(f,g);f=FH(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{xH({fontSize:fI(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 gI(d.region,{}),c.A.set(d.region.id,f),WH(c.a,f)));d=new hI(d,c.K,e);f?WH(f,d):WH(c.a,d)}}}}},jI=function(a){eI(a);a.I=null;a.m=null;a.f=[]},kI=function(a,b){return a.startTime<=b&&a.endTime>b},dI=function(a,b){var c=tH(a.f,d=>kI(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&&kI(a.f[d-1],b);)d--;for(;c+1<a.f.length&&kI(a.f[c+1],b);)c++;return{start:d,end:c}}},eI=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(qH);b.classList.remove(pH);a=a.a;VH(a.g);a.j=[]}},fI=function(a,b){const c=FH(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`},oI=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=uH(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=lI[f];h?(h=_.om(h),(f=mI[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||nI[g.localName]&&nI[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(wH(e)));return b}},lI={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},mI={v:"voice",lang:"lang"},nI={rt:"ruby"},vH={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var EH=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 pI=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 hI=class extends pI{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 oI).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);xH({writingMode:MH(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=KH(this)?-1:0);e=MH(this);xH({writingMode:e,webkitWritingMode:e,direction:sH,textAlign:NH(this)},this.a);if(!this.f.region||
17
- !this.f.region.displayAlign){e=OH(this,PH(this));xH({position:"absolute",left:SH(this,e,null),right:RH(this)&&_.z(null)?zH(0,_.Xd):sH,top:TH(this,e,null),width:KH(this)?zH(this.f.size,"%"):sH,height:QH(this)||RH(this)?zH(this.f.size,"%"):sH},this.a);b=this.f;a=KH(this)?a.height:a.width;c=LH(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)}RH(this)&&(f=a-f-c);a=f;xH({left:SH(this,e,a),right:RH(this)&&_.z(a)?zH(0,_.Xd):sH,top:TH(this,e,a)},this.a)}yH(this.B,d)}}m(){return _.om(_.Qc)}};var qI=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=FH(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=FH(a.a);var d=UH(this,a.f),e=LH(a);const g=GH(c);let h=null,k=0;for(const l of d){for(;JH(c,this.a,l)||IH(c,this.a)&&HH(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||IH(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=GH(c),k=d);c=GH(g)}c=h||g}xH({top:zH(c.h-this.a.h,_.Xd),bottom:zH(this.a.a-c.a,_.Xd),left:zH(c.f-this.a.f,_.Xd),right:zH(this.a.g-c.g,_.Xd),height:zH(c.height,_.Xd),width:zH(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(FH(a.a))}};var rI=class extends pI{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new qI(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var gI=class extends rI{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(oH);}}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(oH);d=a.height;const e=XH(this,d,a.height);xH(this.A,this.a);xH({left:zH(c,_.Xd),top:zH(e,_.Xd),width:zH(b,
20
- _.Xd),height:zH(d,_.Xd)},this.a);this.f.writingMode&&xH({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&xH({"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 hI(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(FH(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
- b=c;f*=b;break a;default:throw Error(oH);}a=XH(this,f,a.height);xH({top:zH(a,_.Xd),height:zH(f,_.Xd)},this.a);this.g=new qI(this,!0);this.h=!0}getId(){return this.f.id}};var sI=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=ZH(this,this.h,this.j);this.g=ZH(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=$H(this,a);if(aI(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=[],bI(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 tI=class extends _.gq{constructor(a){super(a);this.L=new _.O(rH);this.l=a;this.K=cI(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new sI(a,"CLPP Subtitle Styles");this.a=new rI(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(()=>{iI(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;iI(this,!1)}}g(){null==this.h||iI(this,!0)}destroy(){const a=
24
- this;return _.w(function*(){null!=a.h&&(jI(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;iI(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(),iI(this,!0)):(this.F.stop(),this.w.stop(),jI(this)))}U(){iI(this,!0)}};_.x(rH,tI);
25
- tI.prototype.setTextVisibility=tI.prototype.setTextVisibility;tI.prototype.isTextVisible=tI.prototype.isTextVisible;tI.prototype.remove=tI.prototype.remove;tI.prototype.destroy=tI.prototype.destroy;tI.prototype.append=tI.prototype.append;var uI=class{aa(a){return!!a.enableHtmlCue&&!_.ii()}create(a){return new tI(a)}};_.x("clpp.htmlcue.HtmlCueComponent",class extends _.Lp{f(){_.wl("html",new uI)}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 AI="Unsupported unit",BI="clpp-text-plain",CI="clpp-text-ttml",DI="clpp.htmlcue.HtmlTextDisplayer",EI="initial",FI=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},GI=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},II=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>HI[c]);return a},KI=
2
+ function(a,b){JI(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{JI(a,c)})},JI=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},LI=function(a,b){return 0===a?"0":a+b},MI=function(a,b){return 1>Math.abs(a-b)||a<b},NI=function(a,b){return a<b&&1<Math.abs(a-b)},OI=function(a,b){return a>b&&1<Math.abs(a-b)},PI=function(a,b){return 1>Math.abs(a-b)||a>b},RI=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 QI(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-d-e)},SI=function(a){return new QI(a.f,a.g,a.h,a.a,a.height,a.width)},TI=function(a,b){return b.some(c=>NI(a.f,c.g)&&OI(a.g,c.f)&&NI(a.h,c.a)&&OI(a.a,c.h))},UI=function(a,b){return PI(a.h,
4
+ b.h)&&MI(a.a,b.a)&&PI(a.f,b.f)&&MI(a.g,b.g)},VI=function(a,b,c){switch(c){case "+x":return NI(a.f,b.f);case "-x":return OI(a.g,b.g);case "+y":return NI(a.h,b.h);case "-y":return OI(a.a,b.a);default:throw Error("Unknown axis");}},WI=function(a){return a.f.writingMode===_.yo},XI=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 WI(a)?b:c},YI=function(a){switch(a.f.writingMode){case _.yo:return"horizontal-tb";case _.Ge:return _.Ge;
5
+ case _.Ie:return _.Ie;default:throw Error("Unknown writing mode");}},ZI=function(a){switch(a.f.positionAlign){case _.ld:return _.id;case "auto":case _.uc:return _.xo;case _.md:return _.de}return a.f.textAlign},$I=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 _.uc:return a.f.position-a.f.size/2;case _.md:return a.f.position-a.f.size}return 0},aJ=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},dJ=function(a,b,c){return(bJ(a)||cJ(a))&&_.rf(c)?LI(c,_.Xd):bJ(a)&&_.B(c)?LI(0,_.Xd):WI(a)&&_.rf(b)?LI(b,"%"):EI},eJ=function(a,b,c){return WI(a)&&_.rf(c)?LI(c,_.Xd):(bJ(a)||cJ(a))&&_.rf(b)?LI(b,"%"):EI},cJ=function(a){return a.f.writingMode===_.Ie},bJ=function(a){return a.f.writingMode===_.Ge},fJ=function(a,b){if(a.h)switch(b.writingMode){case _.yo:return["-y"];case _.Ge:return["+x"];case _.Ie:return["-x"]}a=[];switch(b.writingMode){case _.yo:a=
7
+ ["+y","-y"];break;case _.Ge:a=["+x","-x"];break;case _.Ie:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},gJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=RI(a.j.a)},hJ=function(a,b){gJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},iJ=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(AI);},kJ=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);jJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},lJ=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)},mJ=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},nJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);a.m=[]}},jJ=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())},oJ=function(a){a=_.lf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},uJ=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=pJ(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,qJ(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 _.Pe:g="clpp-text-vtt";break;case _.xe:g=CI;break;case _.wo:g=BI}g&&!f.classList.contains(g)&&_.mm(f,g);f=RI(c.a.a);if(0===f.width||0===f.height)c.M.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{JI({fontSize:rJ(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Pe;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 sJ(d.region,{}),c.A.set(d.region.id,f),hJ(c.a,f)));d=new tJ(d,c.K,e);f?hJ(f,d):hJ(c.a,d)}}}}},vJ=function(a){qJ(a);a.I=null;a.m=null;a.f=[]},wJ=function(a,b){return a.startTime<=b&&a.endTime>b},pJ=function(a,b){var c=FI(a.f,d=>wJ(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&&wJ(a.f[d-1],b);)d--;for(;c+1<a.f.length&&wJ(a.f[c+1],b);)c++;return{start:d,end:c}}},qJ=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(CI);b.classList.remove(BI);a=a.a;gJ(a.g);a.j=[]}},rJ=function(a,b){const c=RI(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`},AJ=class{parse(a){a={input:a};const b=_.om(_.Qc),c=[];let d=b;for(var e;null!==(e=GI(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=xJ[f];h?(h=_.om(h),(f=yJ[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||zJ[g.localName]&&zJ[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(II(e)));return b}},xJ={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},yJ={v:"voice",lang:"lang"},zJ={rt:"ruby"},HI={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var QI=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 BJ=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 tJ=class extends BJ{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
+ _.Pe?b=(new AJ).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);JI({writingMode:YI(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}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.zo,this.f.line=WI(this)?-1:0);e=YI(this);JI({writingMode:e,webkitWritingMode:e,direction:EI,textAlign:ZI(this)},this.a);if(!this.f.region||
17
+ !this.f.region.displayAlign){e=$I(this,aJ(this));JI({position:"absolute",left:dJ(this,e,null),right:cJ(this)&&_.B(null)?LI(0,_.Xd):EI,top:eJ(this,e,null),width:WI(this)?LI(this.f.size,"%"):EI,height:bJ(this)||cJ(this)?LI(this.f.size,"%"):EI},this.a);b=this.f;a=WI(this)?a.height:a.width;c=XI(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)}cJ(this)&&(f=a-f-c);a=f;JI({left:dJ(this,e,a),right:cJ(this)&&_.B(a)?LI(0,_.Xd):EI,top:eJ(this,e,a)},this.a)}KI(this.B,d)}}m(){return _.om(_.Qc)}};var CJ=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=RI(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=RI(a.a);var d=fJ(this,a.f),e=XI(a);const g=SI(c);let h=null,k=0;for(const l of d){for(;VI(c,this.a,l)||UI(c,this.a)&&TI(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||UI(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=SI(c),k=d);c=SI(g)}c=h||g}JI({top:LI(c.h-this.a.h,_.Xd),bottom:LI(this.a.a-c.a,_.Xd),left:LI(c.f-this.a.f,_.Xd),right:LI(this.a.g-c.g,_.Xd),height:LI(c.height,_.Xd),width:LI(c.width,_.Xd)},a.a)}b.style.visibility="visible";this.g.push(RI(a.a))}};var DJ=class extends BJ{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new CJ(this);this.h=!0}m(){const a=_.om(_.Qc);_.mm(a,this.o);this.id&&(a.id=this.id);return a}};var sJ=class extends DJ{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(AI);}}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(AI);d=a.height;const e=iJ(this,d,a.height);JI(this.A,this.a);JI({left:LI(c,_.Xd),top:LI(e,_.Xd),width:LI(b,
20
+ _.Xd),height:LI(d,_.Xd)},this.a);this.f.writingMode&&JI({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&JI({"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 tJ(new _.Co(0,1,"Lorem ipsum",_.wo),{},{});b=c.a;this.a.appendChild(b);c.init(RI(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
21
+ b=c;f*=b;break a;default:throw Error(AI);}a=iJ(this,f,a.height);JI({top:LI(a,_.Xd),height:LI(f,_.Xd)},this.a);this.g=new CJ(this,!0);this.h=!0}getId(){return this.f.id}};var EJ=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=kJ(this,this.h,this.j);this.g=kJ(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=lJ(this,a);if(mJ(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=[],nJ(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 FJ=class extends _.hq{constructor(a){super(a);this.M=new _.O(DI);this.l=a;this.K=oJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new EJ(a,"CLPP Subtitle Styles");this.a=new DJ(null,"clpp-text-container",{});this.w=new _.cq(a.getSurface(),this.U.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.M.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
23
+ new _.Zh(()=>{uJ(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;uJ(this,!1)}}g(){null==this.h||uJ(this,!0)}destroy(){const a=
24
+ this;return _.y(function*(){null!=a.h&&(vJ(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;uJ(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(),uJ(this,!0)):(this.F.stop(),this.w.stop(),vJ(this)))}U(){uJ(this,!0)}};_.z(DI,FJ);
25
+ FJ.prototype.setTextVisibility=FJ.prototype.setTextVisibility;FJ.prototype.isTextVisible=FJ.prototype.isTextVisible;FJ.prototype.remove=FJ.prototype.remove;FJ.prototype.destroy=FJ.prototype.destroy;FJ.prototype.append=FJ.prototype.append;var GJ=class{ba(a){return!!a.enableHtmlCue&&!_.oi()}create(a){return new FJ(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Mp{f(){_.wl("html",new GJ)}a(){}id(){return _.qe}});};f.call(g, window);