@castlabs/prestoplay 6.14.1 → 6.16.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 (61) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +114 -112
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +553 -538
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +74 -73
  10. package/cjs/cl.externs.js +193 -58
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +69 -69
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -29
  15. package/cjs/cl.ima.js +24 -24
  16. package/cjs/cl.mse.js +368 -264
  17. package/cjs/cl.muxdata.js +15 -15
  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.simid.js +15 -15
  22. package/cjs/cl.smooth.js +72 -71
  23. package/cjs/cl.thumbnails.js +26 -26
  24. package/cjs/cl.tizen.js +71 -71
  25. package/cjs/cl.ttml.js +28 -28
  26. package/cjs/cl.verimatrix.js +5 -5
  27. package/cjs/cl.vimond.js +13 -13
  28. package/cjs/cl.vr.js +19 -19
  29. package/cjs/cl.vtt.js +14 -14
  30. package/cjs/cl.youbora.js +20 -20
  31. package/cl.adobe.js +3 -3
  32. package/cl.airplay.js +3 -3
  33. package/cl.broadpeak.js +5 -5
  34. package/cl.cast.js +89 -88
  35. package/cl.conviva.js +27 -27
  36. package/cl.core.js +455 -443
  37. package/cl.crypto.js +9 -9
  38. package/cl.dash.js +70 -68
  39. package/cl.externs.js +189 -58
  40. package/cl.freewheel.js +19 -19
  41. package/cl.hls.js +71 -71
  42. package/cl.hlssmpte.js +5 -5
  43. package/cl.htmlcue.js +26 -26
  44. package/cl.ima.js +17 -17
  45. package/cl.mse.js +318 -236
  46. package/cl.muxdata.js +13 -13
  47. package/cl.onboard.js +4 -4
  48. package/cl.persistent.js +11 -11
  49. package/cl.playlist.js +5 -5
  50. package/cl.simid.js +13 -13
  51. package/cl.smooth.js +59 -59
  52. package/cl.thumbnails.js +19 -19
  53. package/cl.tizen.js +57 -57
  54. package/cl.ttml.js +22 -22
  55. package/cl.verimatrix.js +4 -4
  56. package/cl.vimond.js +8 -8
  57. package/cl.vr.js +15 -15
  58. package/cl.vtt.js +12 -12
  59. package/cl.youbora.js +15 -15
  60. package/package.json +1 -1
  61. package/typings.d.ts +393 -57
package/cl.thumbnails.js CHANGED
@@ -1,19 +1,19 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var hw="Thumbnail URL is mandatory",iw="Wrong gridSize format",jw="clpp.thumbnails",lw=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.ye&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>kw(a,0,e,!!f))},Promise.resolve())},kw=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return mw(a,d).then(()=>a.a[b].load()).then(()=>kw(a,e,c,d))},mw=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.xn)c();else a.player.one(_.Nc,()=>{c()})})},
2
- nw=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Wc.resolve()})},qw=function(a,b){return ow(a,b).then(c=>new pw(c,b.time,b.duration))},ow=function(a,b){return b.load().then(()=>{const c=_.J(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.ji(c)})},rw=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},sw=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
- tw=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Qc:c,Ae:d,bf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},uw=function(a){return a.some(b=>0<b.thumbStreams.length)},Cw=function(a){return a?a===vw||a===ww?new xw:a===yw?new zw:a===Aw?new Bw:null:null},Dw=function(a){if(!a)return null;a=new _.ql(a);return a.path.match(/.*\.vtt$/i)?yw:a.path.match(/.*\.bif$/i)?Aw:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
- vw:null};var Ew=class{constructor(){this.log=new _.R(jw);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.hf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&lw(this,b.preload)})}};var pw=class{constructor(a,b,c,d,e,f,g,h,k,l,m,n){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;k=void 0===k?1:k;l=void 0===l?0:l;m=void 0===m?0:m;n=void 0===n?new Image:n;this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.la=n;this.Xf=h;this.Pg=k;this.pg=l;this.qg=m;this.na=null}raw(){return this.la.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==
5
- a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Bd);a.style.width=c+_.ef;a.style.height=d+_.ef;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.la.naturalWidth||this.la.width))}px ${Math.ceil(d/this.height*(this.la.naturalHeight||this.la.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/
6
- this.width*c+_.ef;a.style.backgroundPositionY="-"+b*d+_.ef;return a}load(){this.na||(this.na=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.la.naturalWidth||this.la.width)/this.Xf);this.height||(this.height=(this.la.naturalHeight||this.la.height)/this.Pg);this.x||(this.x=this.width*this.pg);this.y||(this.y=this.height*this.qg)};if(this.la.src&&this.la.complete)c(),a(this);else{var d=null,e=()=>{c();this.la.removeEventListener("load",e);this.la.removeEventListener(_.Qd,d);a(this)};
7
- d=f=>{this.la.removeEventListener("load",e);this.la.removeEventListener(_.Qd,d);b(new _.H(1,9,2014,"Failed to load thumbnail.",f))};this.la.addEventListener("load",e);this.la.addEventListener(_.Qd,d);this.la.src=this.src}}));return this.na}};_.x("clpp.thumbnails.Thumbnail",pw);pw.prototype.load=pw.prototype.load;pw.prototype.element=pw.prototype.element;pw.prototype.raw=pw.prototype.raw;var xw=class extends Ew{constructor(){super();this.f=null;this.o=this.g=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,hw);if("GRID"===b.mode&&!b.gridSize)throw new _.H(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.H(1,9,7100,"Duration is mandatory");this.f=b;this.j=this.f.duration;if(this.f.gridSize)try{const c=this.f.gridSize.split(/x/).map(d=>parseInt(d,10)).filter(d=>0<d);if(2===c.length)this.g=c[0],this.o=c[1];else throw new _.H(1,9,7100,iw);}catch(c){throw this.log.error("Error during parsing gridSize",
8
- c),new _.H(1,9,7100,iw);}super.init(a,b)}get(a){const b=this;return _.w(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.H(1,9,2014,`Position is out of range: ${a}`);c=Math.floor(a/b.f.duration);const d=b.a[c];if(!d)throw new _.H(1,9,2014,"No thumbnail found for position "+a+" at index "+c);yield d.load();return d})}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getDuration();const b=this.g*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";
9
- for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new pw(e,this.j*(d*b+g),this.j,0,0,0,0,this.g,this.o,g%this.g,Math.floor(g/this.g),f))}return Promise.resolve()}};var Fw=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Wc=new _.Km}load(){return this.Wc}},Bw=class{constructor(){this.h=new _.R(jw);this.a=new ArrayBuffer(0);this.f=[];this.g=new _.Km}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,hw);const c=b.url;b=_.zi(c);b.type=_.yi;a.getNetworkEngine().fetch(b).P.then(d=>{var e=d.data;d=_.J(this.a);e=_.J(e);var f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g),k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
10
- d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.h.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.J(f);h=String.fromCharCode.apply(null,Gw);k=Array.prototype.slice.call(d,0,8);d=64;e=0;g=!1;if(h===String.fromCharCode.apply(null,k))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!g;){e+=1;k=f;h=new DataView(this.a,d);g=h.getUint32(0,!0);k=g*k/1E3;h=h.getUint32(4,!0);h=new Fw(k,h);if(k=this.f.length)k=this.f[k-1],k.length=
11
- h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.g.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");nw(this)}).catch(d=>{this.h.error(`[BIF] Error while loading thumbnails '
12
- + 'URL: ${c}`,d);a.onError(new _.H(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.H(1,9,2014,`Position is out of range: ${a}`);yield b.g;var c=b.f.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.H(1,9,2014,`No thumbnail found for position: ${a}`);c=yield qw(b,c);yield c.load();return c})}},Gw=[137,66,73,70,13,10,26,10];var zw=class extends Ew{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,hw);const c=b.url,d=_.zi(c);d.type=_.yi;this.f=a.getNetworkEngine().fetch(d).P.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.Wh(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],q=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,
13
- l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=rw(g[0]);g=rw(g[1])-l;this.a.push(new pw(f,l,g,h,n,q,k,0,0))}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.H(1,9,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){const b=this;return _.w(function*(){if(0>a)throw new _.H(1,9,2014,`Position is out of range: ${a}`);yield b.f;const c=b.a.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.H(1,9,2014,`No thumbnail found for position: ${a}`);
14
- yield c.load();return c})}l(){return this.f}};var Hw=class extends Ew{get(a){const b=this;return _.w(function*(){function c(){return new _.H(1,9,2014,`No thumbnail found for position: ${a}`)}if(0>a)throw b.log.error("Position must be greater than 0 but is "+a),new _.H(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=sw(d,a);if(!d)throw b.log.error("Could not find period for specified position",a),c();var e=d.thumbStreams.sort(b.f)[0];if(!e)throw b.log.error("Could not find thumb stream for specified position",a),c();d=
15
- e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=tw(f,e),k=Math.floor((a-f.startTime)/h.durationPerTile);var g;if(0<b.a.length)f=e.findSegmentPosition(0),null!==f&&(g=b.a[(d-f)*h.bf+k]);else if((e=f.La())&&0<e.length){let l=g=0;f=f.startTime;1<h.bf&&(g=k%h.Qc,l=Math.floor(k/h.Qc),f+=k*h.durationPerTile);g=new pw(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
- h.Qc,h.Ae,g,l)}if(g)return yield g.load(),g}b.log.error("segment reference for specified segment index does not exist",d);throw c();})}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.z(d=a.getSegmentReference(c++));){const e=tw(d,a),f=d.La()[0],g=new Image;let h=d.startTime;for(let k=
17
- 0;k<e.Ae;++k)for(let l=0;l<e.Qc;++l)this.a.push(new pw(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Qc,e.Ae,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var Iw=class{constructor(){this.h=new _.R(jw);this.a=this.m=null}onPlayerCreated(a){this.m=a}onPlayerWillDestroy(){this.m=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){const b=a.getConfiguration().thumbnails;if(b)if(!1===b.enabled)this.h.info("Thumbnails disabled.");else{var c=b.mode||null;c||(c=Dw(b.url||null));(this.a=Cw(c))?(this.h.info("Loading thumbs configuration",b),this.m.one(_.le,()=>{this.h.info("Initialize thumbnails provider");try{this.a.init(a,b)}catch(d){this.m.onError(d)}})):
18
- this.h.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(uw(c)){this.a=new Hw;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.H(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.x("clpp.thumbnails.ThumbnailsPlugin",Iw);Iw.prototype.get=Iw.prototype.get;Iw.Id="thumbnails";_.Ho(new class{create(){return new Iw}});
19
- var vw="SINGLE",ww="GRID",yw="WEBVTT",Aw="BIF";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Iw="Thumbnail URL is mandatory",Jw="Wrong gridSize format",Kw="clpp.thumbnails",Mw=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.Ce&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Lw(a,0,e,!!f))},Promise.resolve())},Lw=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Nw(a,d).then(()=>a.a[b].load()).then(()=>Lw(a,e,c,d))},Nw=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.Mn)c();else a.player.one(_.Pc,()=>{c()})})},
2
+ Ow=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.nd.resolve()})},Rw=function(a,b){return Pw(a,b).then(c=>new Qw(c,b.time,b.duration))},Pw=function(a,b){return b.load().then(()=>{const c=_.J(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.yi(c)})},Sw=function(a){a=a.split(/\.|:/).map(parseFloat);let b=0,c;const d={3:.001,2:1,1:60,0:3600};for(c=a.length-1;0<=c;c--)b+=a[c]*d[c];return b},Tw=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
+ Uw=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{dd:c,Re:d,Ef:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Vw=function(a){return a.some(b=>0<b.thumbStreams.length)},cx=function(a){return a?a===Ww||a===Xw?new Yw:a===Zw?new $w:a===ax?new bx:null:null},dx=function(a){if(!a)return null;a=new _.Fl(a);return a.path.match(/.*\.vtt$/i)?Zw:a.path.match(/.*\.bif$/i)?ax:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
+ Ww:null};var ex=class{constructor(){this.log=new _.S(Kw);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.rf,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Mw(this,b.preload)})}};var Qw=class{constructor(a,b,c,d,e,f,g,h,k,l,m,n){d=void 0===d?0:d;e=void 0===e?0:e;f=void 0===f?0:f;g=void 0===g?0:g;h=void 0===h?1:h;k=void 0===k?1:k;l=void 0===l?0:l;m=void 0===m?0:m;n=void 0===n?new Image:n;this.time=b;this.src=a;this.duration=c;this.x=d;this.y=e;this.width=f;this.height=g;this.ta=n;this.mg=h;this.hh=k;this.Kg=l;this.Lg=m;this.oe=null}raw(){return this.ta.cloneNode(!1)}element(a,b){let c=this.width,d=this.height;const e=this.width/this.height;void 0!==a&&void 0===b&&(b=0);null!==
5
+ a&&void 0!==a&&(c=a);null!==b&&void 0!==b&&(d=b);c||(c=Math.ceil(d*e));d||(d=Math.ceil(c/e));a=document.createElement(_.Fd);a.style.width=c+_.of;a.style.height=d+_.of;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.ta.naturalWidth||this.ta.width))}px ${Math.ceil(d/this.height*(this.ta.naturalHeight||this.ta.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/
6
+ this.width*c+_.of;a.style.backgroundPositionY="-"+b*d+_.of;return a}load(){this.oe||(this.oe=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.ta.naturalWidth||this.ta.width)/this.mg);this.height||(this.height=(this.ta.naturalHeight||this.ta.height)/this.hh);this.x||(this.x=this.width*this.Kg);this.y||(this.y=this.height*this.Lg)};if(this.ta.src&&this.ta.complete)c(),a(this);else{var d=null,e=()=>{c();this.ta.removeEventListener("load",e);this.ta.removeEventListener(_.q,d);a(this)};d=
7
+ f=>{this.ta.removeEventListener("load",e);this.ta.removeEventListener(_.q,d);b(new _.H(1,9,2014,"Failed to load thumbnail.",f))};this.ta.addEventListener("load",e);this.ta.addEventListener(_.q,d);this.ta.src=this.src}}));return this.oe}};_.z("clpp.thumbnails.Thumbnail",Qw);Qw.prototype.load=Qw.prototype.load;Qw.prototype.element=Qw.prototype.element;Qw.prototype.raw=Qw.prototype.raw;var Yw=class extends ex{constructor(){super();this.f=null;this.o=this.h=1;this.j=0}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Iw);if("GRID"===b.mode&&!b.gridSize)throw new _.H(1,9,7100,"Grid size is mandatory for GRID mode");if(!b.duration)throw new _.H(1,9,7100,"Duration is mandatory");this.f=b;this.j=this.f.duration;if(this.f.gridSize)try{const c=this.f.gridSize.split(/x/).map(d=>parseInt(d,10)).filter(d=>0<d);if(2===c.length)this.h=c[0],this.o=c[1];else throw new _.H(1,9,7100,Jw);}catch(c){throw this.log.error("Error during parsing gridSize",
8
+ c),new _.H(1,9,7100,Jw);}super.init(a,b)}get(a){const b=this;return _.x(function*(){var c=b.player.getDuration();if(0>a||a>c)throw new _.H(1,9,2014,`Position is out of range: ${a}`);c=Math.floor(a/b.f.duration);const d=b.a[c];if(!d)throw new _.H(1,9,2014,"No thumbnail found for position "+a+" at index "+c);yield d.load();return d})}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getDuration();const b=this.h*this.o;a=Math.ceil(Math.ceil(a/this.j)/b);const c=this.f.templateKey||"$index$";
9
+ for(let d=0;d<a;d++){const e=this.f.url.replace(c,String(d+1)),f=new Image;for(let g=0;g<b;g++)this.a.push(new Qw(e,this.j*(d*b+g),this.j,0,0,0,0,this.h,this.o,g%this.h,Math.floor(g/this.h),f))}return Promise.resolve()}};var fx=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.nd=new _.Zm}load(){return this.nd}},bx=class{constructor(){this.g=new _.S(Kw);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.Zm}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Iw);const c=b.url;b=_.Oi(c);b.type=_.Ni;a.getNetworkEngine().fetch(b).O.then(d=>{var e=d.data;d=_.J(this.a);e=_.J(e);var f=d.byteLength+e.byteLength,g=new ArrayBuffer(f),h=new DataView(g),k=0;for(let l=0,m=d.byteLength;l<m;l++)h.setUint8(k,
10
+ d[l]),k+=1;for(let l=0,m=e.byteLength;l<m;l++)h.setUint8(k,e[l]),k+=1;this.a=g;this.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.J(f);h=String.fromCharCode.apply(null,gx);k=Array.prototype.slice.call(d,0,8);d=64;e=0;g=!1;if(h===String.fromCharCode.apply(null,k))for(f=new DataView(f,16,20),f=f.getUint32(0,!0),0===f&&(f=1E3);!g;){e+=1;k=f;h=new DataView(this.a,d);g=h.getUint32(0,!0);k=g*k/1E3;h=h.getUint32(4,!0);h=new fx(k,h);if(k=this.f.length)k=this.f[k-1],k.length=
11
+ h.offset-k.offset,k.duration=h.time-k.time;this.f.push(h);d+=8;(g=4294967295===g)&&this.h.resolve();if(1E5<e)throw Error("There was a problem during reading BIF entries");}else throw Error("The file is not a valid BIF format");Ow(this)}).catch(d=>{this.g.error(`[BIF] Error while loading thumbnails '
12
+ + 'URL: ${c}`,d);a.onError(new _.H(1,9,2013,"Error while loading and parsing BIF thumbnails.",d))})}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.H(1,9,2014,`Position is out of range: ${a}`);yield b.h;var c=b.f.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.H(1,9,2014,`No thumbnail found for position: ${a}`);c=yield Rw(b,c);yield c.load();return c})}},gx=[137,66,73,70,13,10,26,10];var $w=class extends ex{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Iw);const c=b.url,d=_.Oi(c);d.type=_.Ni;this.f=a.getNetworkEngine().fetch(d).O.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.ki(e).split(/\n/);for(let m=0;m<e.length;m++){var f=e[m],g=f.split(" --\x3e ");if(2===g.length){f=e[++m];var h=f.indexOf("\x3d");var k=h=0>h?[]:f.substr(h+1).split(/,/).map(parseFloat);h=k[0];const n=k[1],r=k[2];k=k[3];var l=f.indexOf("#");f=0>l?f:f.substr(0,
13
+ l);f.match(/^http|^\/\//)||(f=c.substr(0,c.lastIndexOf("/"))+"/"+f);l=Sw(g[0]);g=Sw(g[1])-l;this.a.push(new Qw(f,l,g,h,n,r,k,0,0))}}}).catch(e=>{this.log.error("[VTT] Error while loading thumbnails "+`URL: ${c}`,e);a.onError(new _.H(1,9,2013,"Error while loading VTT thumbnails.",e))});super.init(a,b)}get(a){const b=this;return _.x(function*(){if(0>a)throw new _.H(1,9,2014,`Position is out of range: ${a}`);yield b.f;const c=b.a.find(d=>a>=d.time&&a<d.time+d.duration);if(!c)throw new _.H(1,9,2014,`No thumbnail found for position: ${a}`);
14
+ yield c.load();return c})}l(){return this.f}};var hx=class extends ex{get(a){const b=this;return _.x(function*(){function c(){return new _.H(1,9,2014,`No thumbnail found for position: ${a}`)}if(0>a)throw b.log.error("Position must be greater than 0 but is "+a),new _.H(1,9,2014,`Position is out of range: ${a}`);var d=b.player.getPeriods();d=Tw(d,a);if(!d)throw b.log.error("Could not find period for specified position",a),c();var e=d.thumbStreams.sort(b.f)[0];if(!e)throw b.log.error("Could not find thumb stream for specified position",a),c();d=
15
+ e.findSegmentPosition(a-d.startTime);if(null===d||void 0===d)throw b.log.error("Could not find segment index for specified position",a),c();var f=e.getSegmentReference(d);if(f){const h=Uw(f,e),k=Math.floor((a-f.startTime)/h.durationPerTile);var g;if(0<b.a.length)f=e.findSegmentPosition(0),null!==f&&(g=b.a[(d-f)*h.Ef+k]);else if((e=f.Qa())&&0<e.length){let l=g=0;f=f.startTime;1<h.Ef&&(g=k%h.dd,l=Math.floor(k/h.dd),f+=k*h.durationPerTile);g=new Qw(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
+ h.dd,h.Re,g,l)}if(g)return yield g.load(),g}b.log.error("segment reference for specified segment index does not exist",d);throw c();})}f(a,b){return void 0!==a.bandwidth&&void 0!==b.bandwidth?a.bandwidth-b.bandwidth:0}l(){if(0<this.a.length)return Promise.resolve();var a=this.player.getPeriods();for(const b of a)if(a=b.thumbStreams.sort(this.f)[0]){let c=a.findSegmentPosition(0),d;for(;null!==c&&!_.A(d=a.getSegmentReference(c++));){const e=Uw(d,a),f=d.Qa()[0],g=new Image;let h=d.startTime;for(let k=
17
+ 0;k<e.Re;++k)for(let l=0;l<e.dd;++l)this.a.push(new Qw(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.dd,e.Re,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var ix=class{constructor(){this.g=new _.S(Kw);this.a=this.m=null}onPlayerCreated(a){this.m=a}onPlayerWillDestroy(){this.m=null}onPlayerWillRelease(){this.a=null}onContentWillLoad(a){const b=a.getConfiguration().thumbnails;if(b)if(!1===b.enabled)this.g.info("Thumbnails disabled.");else{var c=b.mode||null;c||(c=dx(b.url||null));(this.a=cx(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.le,()=>{this.g.info("Initialize thumbnails provider");try{this.a.init(a,b)}catch(d){this.m.onError(d)}})):
18
+ this.g.warn("Unknown thumbnail mode",c)}else this.a=null}onContentLoaded(a){if(!this.a){var b=a.getConfiguration();b=b&&b.thumbnails;if(!b||void 0===b.enabled||b.enabled){var c=a.getPeriods();if(Vw(c)){this.a=new hx;try{this.a.init(a,b)}catch(d){this.m.onError(d)}}}}}get(a){return this.a?this.a.get(a):Promise.reject(new _.H(1,9,2014,"Thumbnail format is not supported"))}id(){return"thumbnails"}};_.z("clpp.thumbnails.ThumbnailsPlugin",ix);ix.prototype.get=ix.prototype.get;ix.Id="thumbnails";_.Wo(new class{create(){return new ix}});
19
+ var Ww="SINGLE",Xw="GRID",Zw="WEBVTT",ax="BIF";};f.call(g, window);
package/cl.tizen.js CHANGED
@@ -1,57 +1,57 @@
1
- import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var oJ="An unknown error occurred while trying to get volume",pJ="Cannot get loading rendition due to platform limitations",qJ="SecurityError",rJ="The require privilege is: http://tizen.org/privilege/tv.audio",sJ="|STARTBITRATE\x3d",tJ=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},wJ=function(a){return _.w(function*(){if(a.a!==_.ud&&a.a!==_.sd)throw new _.H(_.F,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
- const b=a.f.get(a.a);if(!b.Vc)throw new _.H(_.F,6,6012,`No license server given for ${a.a}`);try{a.a===_.ud?yield uJ(a):yield vJ(a,b),a.o={keySystem:a.a,licenseServerUri:b.Vc,distinctiveIdentifierRequired:!1,persistentStateRequired:b.le,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.h.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.F,6,6005,{message:JSON.stringify(c)});}})},yJ=function(a,b){_.w(function*(){var c=a.f.get(a.a);
3
- a.h.debug("DRM Challenge data: ",b.challenge);const d=atob(b.challenge);var e=new Uint8Array(d.length);for(let h=0;h<d.length;++h)e[h]=d.charCodeAt(h);c=_.zi([b.serverurl&&""!==b.serverurl?b.serverurl:c.Vc],_.wi());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.mb.fetch(c).P;if(a.j){var g=_.J(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.h.debug("Widevine license params",
4
- k);try{webapis.avplay.setDrm(xJ,"widevine_license_data",k)}catch(l){a.h.error("License response rejected by CDM");const m=new _.H(_.F,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.h.error("License request failed.",JSON.stringify(h)),g=new _.H(_.F,6,6007,{message:_.Pa,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},uJ=function(a){return _.w(function*(){try{webapis.avplay.setDrm(xJ,"Initialize",""),webapis.avplay.setDrm(xJ,
5
- "widevine_app_session",a.l.id),webapis.avplay.setDrm(xJ,"widevine_data_type",a.l.type)}catch(b){throw b;}})},vJ=function(a,b){return _.w(function*(){var c={};c[zJ]=!b.le;c[AJ]=b.Vc;""!==b.customData&&(c[BJ]=b.customData);c=JSON.stringify(c);a.h.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(CJ,"SetProperties",c)}catch(d){throw d;}})},EJ=function(a,b){if(a.f!==b)if(a.f===_.Bn&&b!==_.Cn)a.h.debug(_.Ox+`${DJ(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.xn?(a.o=(new Date).getTime(),
6
- a.m.trigger(new _.C(_.Oc,{detail:{bufferedTimeMS:-1,reason:a.g}}))):a.j===_.xn&&a.m.trigger(new _.C(_.Nc,{detail:{bufferedTimeMS:c-a.o,reason:a.g}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.C(_.vf,{detail:b}));a.h.debug("State changed:",DJ(a.j),"-\x3e",DJ(a.f))}},DJ=function(a){return Object.keys(_.An)[a]},HJ=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case FJ:c=_.Fn;break;case GJ:c=_.En;break;default:a.m.isEnded()?c=_.un:a.h.debug("Inconsistent AVPlay playback state:",
7
- b)}EJ(a,c)}},IJ=function(a){return _.w(function*(){const b=a.m.getConfiguration();let c;(c=yield _.Kq(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},JJ=function(a){if(!a)return!1;a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},KJ=function(a){const b=document.createElement(_.u),c=new _.OC,d=new _.DC(()=>null),e=a.m.getTextDisplayer();return new _.PC(b,c,e,d,a.m.getConfiguration())},LJ=function(a){const b=
8
- {xb:()=>a.m.getPosition(),Y:a.g,mb:a.m.getNetworkEngine(),ge:a.G.bind(a),fe:a.F.bind(a),onError:a.T.bind(a),gf:()=>{},onEvent:()=>{},kf:a.H.bind(a),wd:()=>{},Pd:()=>new _.TC,Fd:()=>!1,Mc:null};return new _.ED(a.a,b)},MJ=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},NJ=function(a){a.h.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.h.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.h.debug(c[d].startTime,a.m.getPosition()),
9
- c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.Pi(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.ly;const f=new _.Zi(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},OJ=function(a){if(a.g&&!a.g.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.BB(a.f,_.G);let c=null;if(b){a=NJ(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===
10
- String(b.id)){c=a[d].renditions[0];break}}return c}return null},PJ=function(a,b){a.h.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Rd,a.a&&a.f)){a.setTextVisibility(!0);const c=MJ(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)==d.id))?(a.w?(a.h.debug("Switching period defer text selection"),a.l=b):(_.KB(a.f,b,!0,0),a.m.trigger(new _.C(_.qk))),a.o=b.language):a.h.error(_.Nx,d.id)}},QJ=function(a){const b=a.ka();b&&a.m.trigger(new _.C(_.Lc,{detail:{width:b.width,
11
- height:b.height,bandwidth:b.bandwidth,rendition:b}}))},RJ=function(a,b){a.m.trigger(new _.C(_.$f,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},SJ=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.h.warn("Couldn't retrieve extra infos from stream."),c=null}return c},TJ=function(a,b){a=a.f[_.M]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.Gg(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);
12
- return c[0]||null},UJ=function(a){const b=a.m.getConfiguration();var c=_.hh(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.Dy(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.h.debug("Setting audio track with preferred language:",e);a.ta(c)}else a.h.debug("Preferred language(s) not available")}else a.h.debug("Could not set preferred audio language")},
13
- $J=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};const d={};if(0>=b.length)return d;var e=b.filter(l=>l.type===VJ),f=b.filter(l=>l.type===WJ);const g=[];for(var h=0;h<f.length;h++){const l=SJ(a,f[h].extra_info);if(l){var k=_.Jh(l.language||_.If);k=_.Li(k);k=c(g,k);k||(k=new _.Pi(String(a.o++),_.L),g.push(k));k.renditions.push(XJ(f[h].index,l,k))}else a.h.warn("Skipping audio stream with no extra info")}c=new _.Pi(String(a.o++),_.M);for(f=0;f<
14
- e.length;f++)(h=SJ(a,e[f].extra_info))?c.renditions.push(YJ(e[f].index,h,c)):a.h.warn("Skipping video stream with no extra info");e=[];e=a.g?NJ(a.g):ZJ(a,b);d[_.M]=[c];d[_.L]=g;d[_.K]=e;return d},cK=function(a,b){if(b===_.K&&a.g)return OJ(a.g);var c=aK(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.M&&(d=SJ(a,c.extra_info),d=TJ(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=bK(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=bK(a,c,_.K),a.l=d):d=a.l);return d},
15
- fK=function(a,b){if(b){const c=b.track.type.toUpperCase();dK(a.a,c,Number(b.id)).then(()=>{c===WJ&&(a.j=b,a.m.trigger(new _.C(_.pk)));c===eK&&(a.l=b,a.m.trigger(new _.C(_.qk)))}).catch(()=>{a.h.error("Could not select "+c+" track.")})}else a.h.debug("Must provide valid rendition")},XJ=function(a,b,c){const d=_.Jh(b.language||_.If);c.language=_.Li(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Hc;a=new _.Zi(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
- b.bit_rate||null;return a},YJ=function(a,b,c){c.mimeType=_.Yf;a=new _.Zi(String(a),c);a.track=c;a.width=b.Width||null;a.height=b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},gK=function(a,b,c){b=_.Jh(b.track_lang||_.If);c.mimeType="text/ttml";c.language=_.Li(b);c.originalLanguage=b;c.kind=_.ly;return new _.Zi(String(a),c)},ZJ=function(a,b){b=b.filter(d=>d.type===eK);const c=[];for(let d=0;d<b.length;d++){const e=SJ(a,b[d].extra_info);if(!e){a.h.warn("Skipping text stream with no extra info");
17
- continue}const f=new _.Pi(String(a.o++),_.K);f.renditions.push(gK(b[d].index,e,f));c.push(f)}return c},bK=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},hK=function(a){return a.f&&a.a?a.a.$g:webapis.avplay.getTotalTrackInfo()},jK=function(a,b,c){a.h.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
- 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=iK(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.He;a.f=!1;a.a=null;return e===GJ?a.pause():a.play()})}catch(d){return Promise.reject(d)}},kK=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.h.debug("Could not set text track visibility",d)}},dK=function(a,b,c){b=b.toUpperCase();
19
- b===eK&&kK(a,!0);const d=a.j[b];d&&(d.zd.stop(),a.j[b]=null,a.h.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.h.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,Ee:0,zd:new _.zj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Ee?(!a.w&&++k.Ee,k.zd.ca(a.w?.5:.25)):(a.h.debug("Could not set track after multiple attempts.Giving up..."),
20
- k&&k.zd.stop(),a.j[h]=null,f())}};g(b,c)})},aK=function(a){return a.f&&a.a?a.a.Zf:webapis.avplay.getCurrentStreamInfo()},lK=function(a){return _.w(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.h.debug("Display resolution ratio: ",a.A)},b=>{a.h.debug("Could not load DISPLAY property");throw b;})})},nK=function(a){try{webapis.avplay.setListener({onbufferingstart:a.I.bind(a),onbufferingprogress:a.H.bind(a),onbufferingcomplete:a.G.bind(a),onstreamcompleted:a.M.bind(a),
21
- oncurrentplaytime:b=>{a.trigger(new _.C(mK,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.O.bind(a),ondrmevent:a.J.bind(a),onerror:a.T.bind(a)})}catch(b){a.h.error(b)}},oK=function(a){const b=!!a.m.getTrackManager().Da();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.h.debug("Could not set AVPlay subtitle config",c)}},pK=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.h.debug({estimatedBandwidth:c,qh:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
- sJ+d)}catch(c){a.h.debug(c)}},qK=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+sJ+b)}catch(c){throw a.h.debug("Could not set fixed bandwidth",c),c;}},rK=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case qJ:a.h.warn("The application doesn't have the privilege to get the mute state.",rJ);break;default:a.h.warn(oJ,c)}}return!!b},iK=function(a){return{position:a.getPosition(),state:a.m.getState(),He:a.getState(),playbackRate:a.getPlaybackRate(),
23
- isLive:a.isLive(),duration:a.getDuration(),isMuted:rK(a),volume:a.getVolume(),$g:hK(a),Zf:aK(a)}},sK=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");tJ(c,"load",d=>a(d));tJ(c,_.Qd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},tK=function(a){return _.w(function*(){yield sK();const b=new Promise(c=>{(new _.zj(c)).ca(5)});if(!(yield Promise.race([lK(a).then(()=>!0),b.then(()=>!1)])))return a.h.debug("Took to long for the SDK to be ready"),
24
- Promise.reject("SDK Timeout")})},uK=function(a){return _.w(function*(){a.h.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.h.debug("AVPlay is ready!");oK(a);b()},d=>{a.h.debug("prepareAsync failed",d);c(d)})}catch(d){a.h.debug("Failed to prepare media player for playback"),c(d)}})})},vK=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case qJ:a.h.warn("The application does not have the privilege to set mute.",rJ);break;default:a.h.warn(oJ,
25
- c)}}},AK=function(a,b,c){return _.w(function*(){a.l=_.In(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.h.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.C(wK)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.tc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(qK(a,e.nextBandwidth),a.o=!1):(a.o||pK(a,e),
26
- a.o=!0);nK(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),mb:a.m.getNetworkEngine()};a.g=new xK(b.drm,h);yield a.g.init()}else a.h.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.C(yK));yield uK(a);a.f||a.trigger(new _.C(zK));f&&typeof f===_.r&&0<f&&a.seek(f).catch(h=>{a.h.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&vK(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.h.debug("Autoplay failed",h)}))}catch(g){throw a.h.debug("Error while attempting to load source."),
27
- g;}})},BK=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.h.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.h.debug("Could not apply dimension. Player state "+a.a.getState())},xK=class{constructor(a,
28
- b){this.g=a;this.o=null;this.a=_.xe;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.h=new _.R("clpp.tizen.DrmEngine")}init(){const a=this;return _.w(function*(){var b=_.Tk[a.g.env]||null;if(!b)throw a.h.debug(_.sa,_.sb+a.g.env+_.aa),new _.H(_.F,6,6015,`DRM environment '${a.g.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.g.customData||{}).length?btoa(JSON.stringify(a.g.customData)):"";b=_.Vk(b,a.g.customData);const d=b[_.sd];d&&a.f.set(_.sd,
29
- {Vc:d.licenseUrl||"",customData:c,le:!1});(b=b[_.ud])&&a.f.set(_.ud,{Vc:b.licenseUrl||"",customData:c,le:!1});if(0===a.f.size)throw new _.H(_.F,6,6E3);if((c=a.g.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.sd))a.a=_.sd;else if(a.f.get(_.ud))a.a=_.ud;else throw new _.H(_.F,6,6001,"Configuration for the target system is missing.");yield wJ(a);a.j=!0})}release(){const a=this;return _.w(function*(){a.j=!1;a.o=null;a.a=_.xe;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},zJ="DeleteLicenseAfterUse",
30
- AJ="LicenseServer",BJ="CustomData";var HK=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Cn;this.j=_.Ls;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.g=2;this.h=new _.R("clpp.tizen.StateManager")}initialize(){this.a.on(wK,this.C,this);this.a.on(CK,this.B,this);this.a.on(DK,this.A,this);this.a.on(yK,this.H,this);this.a.on(zK,this.G,this);this.a.on(EK,this.F,this)}release(){EJ(this,_.Cn);this.l=!1;this.o=-1;this.g=2}destroy(){this.release();this.a.off(wK,this.C);this.a.off(CK,this.B);this.a.off(DK,this.A);this.a.off(yK,
31
- this.H);this.a.off(zK,this.G);this.a.off(EK,this.F);this.m=this.a=null}C(){this.h.debug("Buffering start. Player state: ",this.a.getState());this.g=this.a.B?1:2;EJ(this,_.xn)}B(a){this.h.debug("Buffering progress: "+a.percent+" %. Player state: ",DJ(this.f))}A(){this.h.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===FK;if(!a&&b){EJ(this,_.En);return}}if(a=this.f!==_.Dn)a=this.a.getState(),a=a===
32
- FJ||a===GJ;a&&HJ(this)}H(){this.h.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===GK?EJ(this,_.Dn):this.h.error("AVPlay prepares while state is not IDLE")}G(){this.h.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){EJ(this,_.un)}getState(){return this.f}};var IK=class{constructor(){this.o=this.A=this.f=this.g=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.h=new _.R("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.w(function*(){if(b.m)if(b.B=a,b.j=yield IJ(b),b.j){var c={networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.h.warn(d);try{b.a=yield b.j.start(a.url.replace("https://",
33
- "http://"),c)}catch(e){b.h.error(e),b.a=null}}if(b.a&&JJ(b.a)){b.g=KJ(b);try{yield b.g.I;b.f=LJ(b);const d=b.m.getConfiguration();b.f.g=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=d.preferForcedSubtitles}catch(d){b.h.debug("Could not setup media source..."),b.g=null,b.f=null,b.j=null,b.a=null}}}else b.h.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.h.debug("Text streamer is not initialized. Will not load()")})}G(a){this.h.debug(_.ey,
34
- a);this.w=!0;let b=_.lA(a.textStreams,this.o||"",this.A||"",this.C)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{variant:null,text:b}}F(){this.h.debug("canSwitch_");this.w=!1;this.l&&(_.KB(this.f,this.l,!0,0),this.l=null)}T(){this.h.debug("onError_")}H(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.w(function*(){if(a.f)try{a.f.start()}catch(b){a.h.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.h.debug("Set text visibility",
35
- a);this.g&&this.g.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.w(function*(){a.m=null;a.a=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.w(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.g&&(yield a.g.destroy(),a.g=null)})}};var W=class extends _.S{constructor(){super();this.g=this.a=this.m=null;this.f={};this.h=new _.R("clpp.tizen.TrackManager");this.w=this.l=this.j=null;this.B=!1;this.o=1}C(a){var b=a.eventid;a=a.data;switch(b){case JK:0<Object.keys(this.f).length||(this.h.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+SJ(this,b[0].extra_info).Bit_rate,b=TJ(this,{bandwidth:b}))&&(this.w=b,RJ(this,b));break;case KK:QJ(this);break;default:this.h.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.Fn&&this.m.off(_.vf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.vf,b=>{this.B||(b=b.detail,b.currentState===_.Fn&&(this.h.debug("Current state",b.currentState),this.B=!0,UJ(this)))});this.a.on(LK,this.C,this)}release(){this.f={};this.g=this.w=this.l=this.j=null;this.B=!1;this.o=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.g=this.m.g;this.m.off(_.vf,this.A);this.m.on(_.vf,this.A,this);try{const a=hK(this.a);this.f=$J(this,a);
37
- const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);QJ(this)}catch(a){this.h.debug("Could not load track manager")}}}destroy(){this.a.off(LK,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.M]||[]}getAudioTracks(){return this.f[_.L]||[]}ga(){return this.f[_.K]||[]}ka(){return cK(this,_.M)}Ka(){return cK(this,_.L)}Da(){return cK(this,_.K)}Va(){return this.w}hb(){this.h.info(pJ);return null}ib(){this.h.info(pJ);return null}Ea(){const a=this.ka();return a?a.track:null}ja(){const a=
38
- this.Ka();return a?a.track:null}qa(){const a=this.Da();return a?a.track:null}ab(a){null===a?(a=this.ka(),jK(this.a,a.bandwidth,null).then(()=>{QJ(this)})):0<a.renditions.length&&this.Ra(a.renditions[0])}ta(a){a?fK(this,a.renditions[0]):this.h.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ha(a){a?(a=a.renditions[0],this.g?PJ(this.g,a.track):fK(this,a)):(this.h.debug("Disabling text tracks"),this.l=null,kK(this.a,!1),this.m.trigger(new _.C(_.qk)))}Ra(a){const b=
39
- this.ka();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,RJ(this,a),jK(this.a,b.bandwidth,a.bandwidth).then(()=>{QJ(this)}).catch(c=>{const d=new _.H(_.F,7,7200,{tizenerror:c});this.h.debug("Error while switching video track",c);this.m.onError(d)})):this.h.debug("Trying to switch to already active rendition. Doing nothing...")}Za(a){fK(this,a)}$a(a){this.g?PJ(this.g,a.track):fK(this,a)}addTextTrack(){}ma(){return this.a.o}};W.prototype.isAbrEnabled=W.prototype.ma;
40
- W.prototype.addTextTrack=W.prototype.addTextTrack;W.prototype.setTextRendition=W.prototype.$a;W.prototype.setAudioRendition=W.prototype.Za;W.prototype.setVideoRendition=W.prototype.Ra;W.prototype.setTextTrack=W.prototype.Ha;W.prototype.setAudioTrack=W.prototype.ta;W.prototype.setVideoTrack=W.prototype.ab;W.prototype.getTextTrack=W.prototype.qa;W.prototype.getAudioTrack=W.prototype.ja;W.prototype.getVideoTrack=W.prototype.Ea;W.prototype.getLoadingTextRendition=W.prototype.ib;
41
- W.prototype.getLoadingAudioRendition=W.prototype.hb;W.prototype.getLoadingVideoRendition=W.prototype.Va;W.prototype.getTextRendition=W.prototype.Da;W.prototype.getAudioRendition=W.prototype.Ka;W.prototype.getVideoRendition=W.prototype.ka;W.prototype.getTextTracks=W.prototype.ga;W.prototype.getAudioTracks=W.prototype.getAudioTracks;W.prototype.getVideoTracks=W.prototype.getVideoTracks;var PK=class extends _.qs{constructor(a){super();this.m=a;this.g=null;this.h=new _.R("clpp.tizen.Middleware");this.C=1;this.B=!1;this.l=null;this.F=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}I(){this.w=!0;this.f||this.trigger(new _.C(wK))}H(a){this.w=!0;this.trigger(new _.C(CK,{percent:a}))}G(){this.w=!1;this.trigger(new _.C(DK))}M(){this.trigger(new _.C(EK))}K(a,b){this.trigger(new _.C(LK,{eventid:a,data:b}))}O(a,b,c,d,e){this.trigger(new _.C(MK,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.C(NK,{drmType:a,drmData:b}));this.g&&(a=this.g,a.j&&(a.a===_.ud&&"Challenge"===b.name?yJ(a,b):"DrmError"===b.name&&(a.h.debug("DrmError event",b),b=new _.H(_.F,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}T(a){this.trigger(new _.C(OK,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(mK,f,this);e=setTimeout(()=>{this.off(mK,f);d("Timeout")},3E4)});if(a===GK)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{oK(this);c(webapis.avplay.play())},e=>{this.trigger(new _.C(OK));d(e)})})).then(()=>b());if(a===GJ||a===FK)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===FJ?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===GJ?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===FK||b===FJ||b===GJ){try{webapis.avplay.setSpeed(a),
44
- this.C=a}catch(c){return this.h.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.h.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.C}load(a,b){const c=this;return _.w(function*(){c.h.debug("configure()",b||"");try{yield tK(c),yield AK(c,a,b)}catch(d){throw new _.H(_.F,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.He;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.C(_.Pf));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.C(_.Of));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.T(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.T(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.g&&(this.g.release(),
46
- this.g=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.zd.stop()}this.j={};this.C=1;this.B=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case qJ:this.h.debug("The application does not have the privilege to get the volume.",rJ);break;default:this.h.debug(oJ,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.h.warn("Invalid value passed for setVolume.",
47
- "The passed value value should be in the range of 0 to 1.");break;case qJ:this.h.warn("The application does not have the privilege to set the volume.",rJ);break;default:this.h.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.T(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.h.debug(a)}}getDrmInfo(){this.g&&this.g.getDrmInfo();return null}setSourceIndex(a){this.F=
48
- a}getSourceIndex(){return this.F}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},GK="IDLE",FK="READY",FJ="PLAYING",GJ="PAUSED",VJ=_.Ob,WJ="AUDIO",eK="TEXT",KK="PLAYER_MSG_RESOLUTION_CHANGED",JK="PLAYER_MSG_BITRATE_CHANGE",CJ="PLAYREADY",xJ="WIDEVINE_CDM";var TK=class extends _.qs{constructor(){super();this.a=new PK(this);this.f=new HK(this);this.configuration=this.B=_.Ak();this.w=null;this.h=new _.R("clpp.tizen.Player");this.j=null;this.l=new W;this.C=new _.Eo;this.o=this.g=null;this.A=!1}H(){this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.C(_.Pd));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.h.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.C(_.Ff,
49
- {currentTime:a.currentTime/1E3}))}I(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.h.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.ii(d))&&this.o.append([new _.Mr(b,c,d)],[])}G(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)}T(a){this.h.debug(`Error: TYPE: ${a.eventType}`);EJ(this.f,_.Bn);a=new _.H(_.F,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.C(_.Qd,{detail:a}))}init(a,
50
- b){this.configuration=this.B=b;this.w=a;this.a.on(EK,this.H,this);this.a.on(mK,this.F,this);this.a.on(MK,this.I,this);this.a.on(NK,this.G,this);this.a.on(OK,this.T,this);this.a.on(DK,this.J,this);this.f.initialize();this.l.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();a=QK;QK+=1;a="__clpp_tizen_player_"+a;this.j=_.$n(_.ye,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.kg,_.Ud,"position",
51
- _.ee,"top"];const e={};c=null!==c.parentElement?window.getComputedStyle(c,null):c.style;if(!b||0===b.length)for(d in b||(b=[]),c)b.push(d);for(const f of b)e[f]=c[f];var d=e}_.bo(a,d);BK(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}destroy(){const a=this;return _.w(function*(){yield a.release();a.a.off(EK,a.H);a.a.off(mK,a.F);a.a.off(MK,a.I);a.a.off(NK,a.G);a.a.off(OK,a.T);a.a.off(DK,a.J);a.g&&(yield a.g.destroy(),a.g=null);a.j&&(a.j.parentElement.removeChild(a.j),
52
- a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return RK}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===_.un?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.r&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,
53
- end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.r?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.a.getDuration()}getBufferInfo(){this.h.warn(_.oa);return new _.ps}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.w(function*(){a.g&&(yield a.g.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.w(function*(){b.configuration=
54
- _.Ck(b.B,a);var c=_.kn(b.configuration,[_.Wd,"native"]);b.o=c.create(b);c=_.In(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.g=new IK;b.g.initialize(b);try{yield b.g.load(c),b.g.start()}catch(d){b.h.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),d;}b.l.load()})}play(){this.trigger(new _.C(_.Me));BK(this);return this.a.play().then(()=>{HJ(this.f)})}pause(){return this.a.pause().then(()=>{HJ(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=
55
- new _.C(_.Qd,{detail:a});a.severity===_.F&&(EJ(this.f,_.Bn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.un}isPaused(){return this.a.getState()===GJ}isMuted(){return rK(this.a)}setMuted(a){vK(this.a,a)}getNetworkEngine(){return this.C}setNetworkEngine(a){this.C=a}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,
56
- b){return(new SK).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};TK.prototype.getTextDisplayer=TK.prototype.getTextDisplayer;TK.prototype.setNetworkEngine=TK.prototype.setNetworkEngine;TK.prototype.getNetworkEngine=TK.prototype.getNetworkEngine;
57
- var RK="clpp.tizen",QK=0,SK=class{a(){return RK}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.tc||a===_.uk||a===_.zc)&&b){if(_.Dj(2))return 2;if(_.Dj(3)||_.Dj(4)||_.Dj(5)||_.Dj(6))return _.B("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}create(){return new TK}};_.x("clpp.tizen.TizenComponent",class extends _.ht{f(){_.Vg(new SK)}a(){var a=RK;a&&_.Tg[a]&&(delete _.Tg[a],_.Ug.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var wK="onbufferingstart",CK="onbufferingprogress",DK="onbufferingcomplete",EK="onstreamcompleted",mK="oncurrentplaytime",LK="onevent",MK="onsubtitlechange",NK="ondrmevent",OK="onerror",yK="preparingstart",zK="preparingend";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var gO="An unknown error occurred while trying to get volume",hO="Cannot get loading rendition due to platform limitations",iO="SecurityError",jO="The require privilege is: http://tizen.org/privilege/tv.audio",kO="|STARTBITRATE\x3d",lO=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},oO=function(a){return _.x(function*(){if(a.a!==_.yd&&a.a!==_.wd)throw new _.H(_.E,6,6001,`The key system ${a.a} is not supported by `+"the player or the platform");
2
+ const b=a.f.get(a.a);if(!b.md)throw new _.H(_.E,6,6012,`No license server given for ${a.a}`);try{a.a===_.yd?yield mO(a):yield nO(a,b),a.o={keySystem:a.a,licenseServerUri:b.md,distinctiveIdentifierRequired:!1,persistentStateRequired:b.ze,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.E,6,6005,{message:JSON.stringify(c)});}})},qO=function(a,b){_.x(function*(){var c=a.f.get(a.a);
3
+ a.g.debug("DRM Challenge data: ",b.challenge);const d=atob(b.challenge);var e=new Uint8Array(d.length);for(let h=0;h<d.length;++h)e[h]=d.charCodeAt(h);c=_.Oi([b.serverurl&&""!==b.serverurl?b.serverurl:c.md],_.Li());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.B.Za.fetch(c).O;if(a.j){var g=_.J(f.data);const h=g.byteLength;e="";for(f=0;f<h;f++)e+=String.fromCharCode(g[f]);const k=`${b.session_id}PARAM_START_POSITION`+`${btoa(e)}PARAM_START_POSITION`;a.g.debug("Widevine license params",
4
+ k);try{webapis.avplay.setDrm(pO,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.H(_.E,6,6008,{browserError:JSON.stringify(l)});a.B.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.H(_.E,6,6007,{message:_.Ra,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.B.onError(g)}})},mO=function(a){return _.x(function*(){try{webapis.avplay.setDrm(pO,"Initialize",""),webapis.avplay.setDrm(pO,
5
+ "widevine_app_session",a.l.id),webapis.avplay.setDrm(pO,"widevine_data_type",a.l.type)}catch(b){throw b;}})},nO=function(a,b){return _.x(function*(){var c={};c[rO]=!b.ze;c[sO]=b.md;""!==b.customData&&(c[tO]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(uO,"SetProperties",c)}catch(d){throw d;}})},wO=function(a,b){if(a.f!==b)if(a.f===_.Qn&&b!==_.Rn)a.g.debug(_.iz+`${vO(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Mn?(a.o=(new Date).getTime(),
6
+ a.m.trigger(new _.D(_.Tc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.Mn&&a.m.trigger(new _.D(_.Pc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.m.trigger(new _.D(_.Jf,{detail:b}));a.g.debug("State changed:",vO(a.j),"-\x3e",vO(a.f))}},vO=function(a){return Object.keys(_.Pn)[a]},zO=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case xO:c=_.Un;break;case yO:c=_.Tn;break;default:a.m.isEnded()?c=_.Jn:a.g.debug("Inconsistent AVPlay playback state:",
7
+ b)}wO(a,c)}},AO=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.hr(a.C.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.C.type||null))&&c.configure(b.manifest);return c})},BO=function(a){if(!a)return!1;a=a.periods;let b=!1;for(let c=0;c<a.length;c++)b=b||0<a[c].textStreams.length;return b},CO=function(a){const b=document.createElement(_.w),c=new _.TH,d=new _.ZG(()=>null),e=a.m.getTextDisplayer();return new _.VH(b,c,e,d,a.m.getConfiguration())},DO=function(a){const b=
8
+ {configuration:{},sa:()=>a.m.getPosition(),P:a.h,Za:a.m.getNetworkEngine(),Oc:a.G.bind(a),Nc:a.F.bind(a),onError:a.W.bind(a),Pd:()=>{},onEvent:()=>{},Rd:a.H.bind(a),Pc:()=>{},Gc:()=>new _.yH,Ac:()=>!1,ub:null};return new _.rI(a.a,b)},EO=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},FO=function(a){a.g.debug("getTextStreams()",a.a);if(a.a){var b=[],c=a.a.periods;a.g.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.g.debug(c[d].startTime,
9
+ a.m.getPosition()),c[d].startTime<=a.m.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.dj(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.eB;const f=new _.lj(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},GO=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=a.f.J();let c=null;if(b){a=FO(a);for(let d=0;d<a.length;d++)if(a[d].renditions[0].id===
10
+ String(b.id)){c=a[d].renditions[0];break}}return c}return null},HO=function(a,b){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.D=b.kind===_.Vd,a.a&&a.f)){a.setTextVisibility(!0);const c=EO(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)===d.id))?(a.w?(a.g.debug("Switching period defer text selection"),a.l=b):(a.f.H(b),a.m.trigger(new _.D(_.Gk))),a.o=b.language):a.g.error(_.gz,d.id)}},IO=function(a){const b=a.oa();b&&a.m.trigger(new _.D(_.Nc,{detail:{width:b.width,
11
+ height:b.height,bandwidth:b.bandwidth,rendition:b}}))},JO=function(a,b){a.m.trigger(new _.D(_.ig,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},KO=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.g.warn("Couldn't retrieve extra infos from stream."),c=null}return c},LO=function(a,b){a=a.f[_.M]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.Ug(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);
12
+ return c[0]||null},MO=function(a){const b=a.m.getConfiguration();var c=_.wh(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.IB(g,d.map(h=>h.language));return!!e});if(e){var f=d.filter(g=>g.language===e);c=f[0];1<f.length&&b.preferredAudioRole&&(f=f.filter(g=>0<=g.roles.indexOf(b.preferredAudioRole)),0<f.length&&(c=f[0]));a.g.debug("Setting audio track with preferred language:",e);a.Da(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},
13
+ SO=function(a,b){var c=(l,m)=>{for(let n=0;n<l.length;n++)if(l[n].language===m)return l[n];return null};const d={};if(0>=b.length)return d;var e=b.filter(l=>l.type===NO),f=b.filter(l=>l.type===OO);const g=[];for(var h=0;h<f.length;h++){const l=KO(a,f[h].extra_info);if(l){var k=_.Yh(l.language||_.Wf);k=_.$i(k);k=c(g,k);k||(k=new _.dj(String(a.o++),_.L),g.push(k));k.renditions.push(PO(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.dj(String(a.o++),_.M);for(f=0;f<
14
+ e.length;f++)(h=KO(a,e[f].extra_info))?c.renditions.push(QO(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.h?FO(a.h):RO(a,b);d[_.M]=[c];d[_.L]=g;d[_.K]=e;return d},VO=function(a,b){if(b===_.K&&a.h)return GO(a.h);var c=TO(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.M&&(d=KO(a,c.extra_info),d=LO(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=UO(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=UO(a,c,_.K),a.l=d):d=a.l);return d},
15
+ YO=function(a,b){if(b){const c=b.track.type.toUpperCase();WO(a.a,c,Number(b.id)).then(()=>{c===OO&&(a.j=b,a.m.trigger(new _.D(_.Fk)));c===XO&&(a.l=b,a.m.trigger(new _.D(_.Gk)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},PO=function(a,b,c){const d=_.Yh(b.language||_.Wf);c.language=_.$i(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Ic;a=new _.lj(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
+ b.bit_rate||null;return a},QO=function(a,b,c){c.mimeType=_.gg;a=new _.lj(String(a),c);a.track=c;a.width=b.Width||null;a.height=b.Height||null;a.bandwidth=b.Bit_rate?Number(b.Bit_rate):null;a.codec=b.fourCC||null;return a},ZO=function(a,b,c){b=_.Yh(b.track_lang||_.Wf);c.mimeType="text/ttml";c.language=_.$i(b);c.originalLanguage=b;c.kind=_.eB;return new _.lj(String(a),c)},RO=function(a,b){b=b.filter(d=>d.type===XO);const c=[];for(let d=0;d<b.length;d++){const e=KO(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");
17
+ continue}const f=new _.dj(String(a.o++),_.K);f.renditions.push(ZO(b[d].index,e,f));c.push(f)}return c},UO=function(a,b,c){a=a.f[c]||[];b=String(b.index);c=null;for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)if(a[d].renditions[e].id===b){c=a[d].renditions[e];break}return c},$O=function(a){return a.f&&a.a?a.a.th:webapis.avplay.getTotalTrackInfo()},bP=function(a,b,c){a.g.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
+ 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.a=aP(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.hf;a.f=!1;a.a=null;return e===yO?a.pause():a.play()})}catch(d){return Promise.reject(d)}},cP=function(a,b){var c=a.m.getTextDisplayer();c&&c.setTextVisibility(b);c=a.m.h;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.g.debug("Could not set text track visibility",d)}},WO=function(a,b,c){b=b.toUpperCase();
19
+ b===XO&&cP(a,!0);const d=a.j[b];d&&(d.Vd.stop(),a.j[b]=null,a.g.debug(`Cancelled pending track switch for ${b}`));return new Promise((e,f)=>{const g=(h,k,l)=>{l=void 0===l?!1:l;try{webapis.avplay.setSelectTrack(h,k),a.j[h]=null,e()}catch(m){a.g.debug(`Could not set ${h} track. Trying again...`+`AVPlay state: ${a.getState()}, `+`buffering: ${a.w}`,m),!1===l&&(a.j[h]={type:h,index:k,ef:0,Vd:new _.Pj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.ef?(!a.w&&++k.ef,k.Vd.ia(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),
20
+ k&&k.Vd.stop(),a.j[h]=null,f())}};g(b,c)})},TO=function(a){return a.f&&a.a?a.a.og:webapis.avplay.getCurrentStreamInfo()},dP=function(a){return _.x(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.g.debug("Display resolution ratio: ",a.A)},b=>{a.g.debug("Could not load DISPLAY property");throw b;})})},fP=function(a){try{webapis.avplay.setListener({onbufferingstart:a.I.bind(a),onbufferingprogress:a.H.bind(a),onbufferingcomplete:a.G.bind(a),onstreamcompleted:a.M.bind(a),
21
+ oncurrentplaytime:b=>{a.trigger(new _.D(eP,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.W.bind(a)})}catch(b){a.g.error(b)}},gP=function(a){const b=!!a.m.getTrackManager().Pa();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},hP=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,Ih:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
+ kO+d)}catch(c){a.g.debug(c)}},iP=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+kO+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},jP=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case iO:a.g.warn("The application doesn't have the privilege to get the mute state.",jO);break;default:a.g.warn(gO,c)}}return!!b},aP=function(a){return{position:a.getPosition(),state:a.m.getState(),hf:a.getState(),playbackRate:a.getPlaybackRate(),
23
+ isLive:a.isLive(),duration:a.getDuration(),isMuted:jP(a),volume:a.getVolume(),th:$O(a),og:TO(a)}},kP=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");lO(c,"load",d=>a(d));lO(c,_.q,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},lP=function(a){return _.x(function*(){yield kP();const b=new Promise(c=>{(new _.Pj(c)).ia(5)});if(!(yield Promise.race([dP(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),
24
+ Promise.reject("SDK Timeout")})},mP=function(a){return _.x(function*(){a.g.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.g.debug("AVPlay is ready!");gP(a);b()},d=>{a.g.debug("prepareAsync failed",d);c(d)})}catch(d){a.g.debug("Failed to prepare media player for playback"),c(d)}})})},nP=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case iO:a.g.warn("The application does not have the privilege to set mute.",jO);break;default:a.g.warn(gO,
25
+ c)}}},sP=function(a,b,c){return _.x(function*(){a.l=_.Xn(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.g.debug(`Loading manifest URL: ${a.l[d].url}`);let f=b.startTime||void 0;a.f&&(a.trigger(new _.D(oP)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.yc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(iP(a,e.nextBandwidth),a.o=!1):(a.o||hP(a,e),
26
+ a.o=!0);fP(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Za:a.m.getNetworkEngine()};a.h=new pP(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.D(qP));yield mP(a);a.f||a.trigger(new _.D(rP));f&&typeof f===_.t&&0<f&&a.seek(f).catch(h=>{a.g.debug("Couldn't set start position",h)});a.f||(b.volume&&a.setVolume(b.volume),b.muted&&nP(a,b.muted),b.autoplay&&a.m.play().catch(h=>{a.g.debug("Autoplay failed",h)}))}catch(g){throw a.g.debug("Error while attempting to load source."),
27
+ g;}})},tP=function(a){if("NONE"!==a.a.getState()){var b=a.j.getBoundingClientRect();{a=a.a;const c=Math.floor(b.left*a.A),d=Math.floor(b.top*a.A),e=Math.floor(b.width*a.A);b=Math.floor(b.height*a.A);a.g.debug("Setting display area to","x:",c,"y:",d,"width:",e,"height:",b);webapis.avplay.setDisplayRect(c,d,e,b);0===c&&0===d&&1920===e&&1080===b&&webapis.avplay.setDisplayMethod("PLAYER_DISPLAY_MODE_LETTER_BOX")}}else a.g.debug("Could not apply dimension. Player state "+a.a.getState())},pP=class{constructor(a,
28
+ b){this.h=a;this.o=null;this.a=_.Be;this.l=null;this.j=!1;this.f=new Map;this.B=b;this.g=new _.S("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.jl[a.h.env]||null;if(!b)throw a.g.debug(_.ua,_.xb+a.h.env+_.aa),new _.H(_.E,6,6015,`DRM environment '${a.h.env}' is missing.`);a.l={id:String(Math.floor(1E4*Math.random())),type:"MPEG-DASH"};var c=Object.keys(a.h.customData||{}).length?btoa(JSON.stringify(a.h.customData)):"";b=_.ll(b,a.h.customData);const d=b[_.wd];d&&a.f.set(_.wd,
29
+ {md:d.licenseUrl||"",customData:c,ze:!1});(b=b[_.yd])&&a.f.set(_.yd,{md:b.licenseUrl||"",customData:c,ze:!1});if(0===a.f.size)throw new _.H(_.E,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.wd))a.a=_.wd;else if(a.f.get(_.yd))a.a=_.yd;else throw new _.H(_.E,6,6001,"Configuration for the target system is missing.");yield oO(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.Be;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},rO="DeleteLicenseAfterUse",
30
+ sO="LicenseServer",tO="CustomData";var zP=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.Rn;this.j=_.it;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.S("clpp.tizen.StateManager")}initialize(){this.a.on(oP,this.D,this);this.a.on(uP,this.C,this);this.a.on(vP,this.A,this);this.a.on(qP,this.H,this);this.a.on(rP,this.G,this);this.a.on(wP,this.F,this)}release(){wO(this,_.Rn);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(oP,this.D);this.a.off(uP,this.C);this.a.off(vP,this.A);this.a.off(qP,
31
+ this.H);this.a.off(rP,this.G);this.a.off(wP,this.F);this.m=this.a=null}D(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.C?1:2;wO(this,_.Mn)}C(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",vO(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.l){this.l=!0;var a=this.m.getConfiguration().autoplay;const b=this.a.getState()===xP;if(!a&&b){wO(this,_.Tn);return}}if(a=this.f!==_.Sn)a=this.a.getState(),a=a===
32
+ xO||a===yO;a&&zO(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===yP?wO(this,_.Sn):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){wO(this,_.Jn)}getState(){return this.f}};var AP=class{constructor(){this.o=this.A=this.f=this.h=this.C=this.m=this.j=this.a=null;this.D=!1;this.w=!0;this.l=null;this.g=new _.S("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.C=a,b.j=yield AO(b),b.j){var c={configurationId:"",networkingEngine:b.m.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}};try{b.a=yield b.j.start(a.url,c)}catch(d){b.g.warn(d);try{b.a=yield b.j.start(a.url.replace("https://",
33
+ "http://"),c)}catch(e){b.g.error(e),b.a=null}}if(b.a&&BO(b.a)){b.h=CO(b);try{yield b.h.open();b.f=DO(b);const d=b.m.getConfiguration();b.f.X(d.streaming);b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.D=d.preferForcedSubtitles}catch(d){b.g.debug("Could not setup media source..."),b.h=null,b.f=null,b.j=null,b.a=null}}}else b.g.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.g.debug("Text streamer is not initialized. Will not load()")})}G(a){this.g.debug(_.JA,
34
+ a);this.w=!0;let b=_.UD(a.textStreams,this.o||"",this.A||"",this.D)[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{variant:null,text:b}}F(){this.g.debug("canSwitch_");this.w=!1;this.l&&(this.f.H(this.l),this.l=null)}W(){this.g.debug("onError_")}H(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.x(function*(){if(a.f)try{a.f.start()}catch(b){a.g.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.g.debug("Set text visibility",
35
+ a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=this;return _.x(function*(){a.m=null;a.a=null;a.C=null;a.A=null;a.o=null;a.w=!0;a.l=null})}destroy(){const a=this;return _.x(function*(){a.j&&(yield a.j.stop(),a.j=null);a.f&&(yield a.f.destroy(),a.f=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var EP=class extends _.T{constructor(){super();this.h=this.a=this.m=null;this.f={};this.g=new _.S("clpp.tizen.TrackManager");this.w=this.l=this.j=null;this.C=!1;this.o=1}D(a){var b=a.eventid;a=a.data;switch(b){case BP:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+KO(this,b[0].extra_info).Bit_rate,b=LO(this,{bandwidth:b}))&&(this.w=b,JO(this,b));break;case CP:IO(this);break;default:this.g.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.Un&&this.m.off(_.Jf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.Jf,b=>{this.C||(b=b.detail,b.currentState===_.Un&&(this.g.debug("Current state",b.currentState),this.C=!0,MO(this)))});this.a.on(DP,this.D,this)}release(){this.f={};this.h=this.w=this.l=this.j=null;this.C=!1;this.o=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.h=this.m.h;this.m.off(_.Jf,this.A);this.m.on(_.Jf,this.A,this);try{const a=$O(this.a);this.f=SO(this,a);
37
+ const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);IO(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(DP,this.D);this.a=this.m=null}getVideoTracks(){return this.f[_.M]||[]}getAudioTracks(){return this.f[_.L]||[]}ma(){return this.f[_.K]||[]}oa(){return VO(this,_.M)}Xa(){return VO(this,_.L)}Pa(){return VO(this,_.K)}kb(){return this.w}wb(){this.g.info(hO);return null}xb(){this.g.info(hO);return null}Ra(){const a=this.oa();return a?a.track:null}na(){const a=
38
+ this.Xa();return a?a.track:null}za(){const a=this.Pa();return a?a.track:null}sb(a){null===a?(a=this.oa(),bP(this.a,a.bandwidth,null).then(()=>{IO(this)})):0<a.renditions.length&&this.gb(a.renditions[0])}Da(a){a?YO(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ta(a){a?(a=a.renditions[0],this.h?HO(this.h,a.track):YO(this,a)):(this.g.debug("Disabling text tracks"),this.l=null,cP(this.a,!1),this.m.trigger(new _.D(_.Gk)))}gb(a){const b=
39
+ this.oa();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,JO(this,a),bP(this.a,b.bandwidth,a.bandwidth).then(()=>{IO(this)}).catch(c=>{const d=new _.H(_.E,7,7200,{tizenerror:c});this.g.debug("Error while switching video track",c);this.m.onError(d)})):this.g.debug("Trying to switch to already active rendition. Doing nothing...")}qb(a){YO(this,a)}rb(a){this.h?HO(this.h,a.track):YO(this,a)}addTextTrack(){}ua(){return this.a.o}};EP.prototype.isAbrEnabled=EP.prototype.ua;
40
+ EP.prototype.addTextTrack=EP.prototype.addTextTrack;EP.prototype.setTextRendition=EP.prototype.rb;EP.prototype.setAudioRendition=EP.prototype.qb;EP.prototype.setVideoRendition=EP.prototype.gb;EP.prototype.setTextTrack=EP.prototype.Ta;EP.prototype.setAudioTrack=EP.prototype.Da;EP.prototype.setVideoTrack=EP.prototype.sb;EP.prototype.getTextTrack=EP.prototype.za;EP.prototype.getAudioTrack=EP.prototype.na;EP.prototype.getVideoTrack=EP.prototype.Ra;EP.prototype.getLoadingTextRendition=EP.prototype.xb;
41
+ EP.prototype.getLoadingAudioRendition=EP.prototype.wb;EP.prototype.getLoadingVideoRendition=EP.prototype.kb;EP.prototype.getTextRendition=EP.prototype.Pa;EP.prototype.getAudioRendition=EP.prototype.Xa;EP.prototype.getVideoRendition=EP.prototype.oa;EP.prototype.getTextTracks=EP.prototype.ma;EP.prototype.getAudioTracks=EP.prototype.getAudioTracks;EP.prototype.getVideoTracks=EP.prototype.getVideoTracks;var IP=class extends _.Os{constructor(a){super();this.m=a;this.h=null;this.g=new _.S("clpp.tizen.Middleware");this.D=1;this.C=!1;this.l=null;this.F=0;this.o=!0;this.f=!1;this.a=null;this.A=1;this.w=!1;this.j={}}I(){this.w=!0;this.f||this.trigger(new _.D(oP))}H(a){this.w=!0;this.trigger(new _.D(uP,{percent:a}))}G(){this.w=!1;this.trigger(new _.D(vP))}M(){this.trigger(new _.D(wP))}K(a,b){this.trigger(new _.D(DP,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.D(FP,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.D(GP,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.yd&&"Challenge"===b.name?qO(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.H(_.E,6,6005,{message:JSON.stringify(b)}),a.B.onError(b))))}W(a){this.trigger(new _.D(HP,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(eP,f,this);e=setTimeout(()=>{this.off(eP,f);d("Timeout")},3E4)});if(a===yP)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{gP(this);c(webapis.avplay.play())},e=>{this.trigger(new _.D(HP));d(e)})})).then(()=>b());if(a===yO||a===xP)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===xO?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===yO?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===xP||b===xO||b===yO){try{webapis.avplay.setSpeed(a),
44
+ this.D=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.D)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.D}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield lP(c),yield sP(c,a,b)}catch(d){throw new _.H(_.E,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.hf;try{return webapis.avplay.getState()}catch(a){this.W(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.C=!0;this.m.trigger(new _.D(_.bg));webapis.avplay.seekTo(b,()=>{this.C=!1;this.m.trigger(new _.D(_.ag));c()},()=>{this.C=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.W(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.W(JSON.stringify(a))}}release(){return new Promise((a,b)=>{try{this.h&&(this.h.release(),
46
+ this.h=null);webapis.avplay.stop();webapis.avplay.close();for(const c in this.j){const d=this.j[c];d&&d.Vd.stop()}this.j={};this.D=1;this.C=!1;this.a=this.l=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case iO:this.g.debug("The application does not have the privilege to get the volume.",jO);break;default:this.g.debug(gO,b)}}return a}setVolume(a){try{tizen.tvaudiocontrol.setVolume(Math.max(0,Math.min(100*a,100)))}catch(b){switch(b.name){case "InvalidValueError":this.g.warn("Invalid value passed for setVolume.",
47
+ "The passed value value should be in the range of 0 to 1.");break;case iO:this.g.warn("The application does not have the privilege to set the volume.",jO);break;default:this.g.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.f&&this.a)return this.a.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.W(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.g.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.F=
48
+ a}getSourceIndex(){return this.F}getLoadedSource(){return this.l&&this.l[this.getSourceIndex()]}},yP="IDLE",xP="READY",xO="PLAYING",yO="PAUSED",NO=_.Rb,OO="AUDIO",XO="TEXT",CP="PLAYER_MSG_RESOLUTION_CHANGED",BP="PLAYER_MSG_BITRATE_CHANGE",uO="PLAYREADY",pO="WIDEVINE_CDM";var MP=class extends _.Os{constructor(){super();this.a=new IP(this);this.f=new zP(this);this.configuration=this.C=_.Qk();this.w=null;this.g=new _.S("clpp.tizen.Player");this.j=null;this.l=new EP;this.D=new _.To;this.o=this.h=null;this.A=!1}H(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.D(_.Ud));this.configuration.loop?this.seek(this.configuration.startTime||0).catch(()=>{this.g.debug("Could not loop playback")}):this.a.stop()}F(a){this.trigger(new _.D(_.Tf,
49
+ {currentTime:a.currentTime/1E3}))}I(a){const b=this.a.getPosition(),c=b+a.duration/1E3;let d=a.text||"";this.g.debug("Got subtitles: ",d,"start:",b,"end:",c,a);(d=_.xi(d))&&this.o.append([new _.js(b,c,d)],[])}G(a){this.g.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.g.debug("Initial buffering completed..."),this.A=!0)}W(a){this.g.debug(`Error: TYPE: ${a.eventType}`);wO(this.f,_.Qn);a=new _.H(_.E,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.D(_.q,{detail:a}))}init(a,
50
+ b){this.configuration=this.C=b;this.w=a;this.a.on(wP,this.H,this);this.a.on(eP,this.F,this);this.a.on(FP,this.I,this);this.a.on(GP,this.G,this);this.a.on(HP,this.W,this);this.a.on(vP,this.J,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=JP;JP+=1;a="__clpp_tizen_player_"+a;this.j=_.po(_.Ce,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.yg,_.Yd,"position",
51
+ _.ee,"top"];const e={};c=null!==c.parentElement?window.getComputedStyle(c,null):c.style;if(!b||0===b.length)for(d in b||(b=[]),c)b.push(d);for(const f of b)e[f]=c[f];var d=e}_.ro(a,d);tP(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}getTimeline(){return null}setupPlaylist(){return Promise.reject(_.pb)}appendLoad(){return Promise.reject(_.pb)}seekWith(){return Promise.reject(_.pb)}destroy(){const a=this;return _.x(function*(){yield a.release();a.a.off(wP,a.H);a.a.off(eP,
52
+ a.F);a.a.off(FP,a.I);a.a.off(GP,a.G);a.a.off(HP,a.W);a.a.off(vP,a.J);a.h&&(yield a.h.destroy(),a.h=null);a.j&&(a.j.parentElement.removeChild(a.j),a.j=null);a.l.destroy();a.f.destroy();a.l=null;a.f=null})}namespace(){return KP}getPlaybackRate(){return this.a.getPlaybackRate()}setDrmCustomDataModifier(){}setCdnErrorCallback(){}detach(){}setPlaybackRate(a){this.a.setPlaybackRate(a)}getPosition(){return this.getMediaPosition()}getMediaPosition(){return 0<(this.configuration.startTime||0)&&!this.A?0:this.f.getState()===
53
+ _.Jn?this.getDuration():this.a.getPosition()||0}seek(a){return typeof a===_.t&&0<=a?(this.isLive()||(a=Math.min(a,this.getDuration())),this.a.seek(a)):Promise.reject()}getPresentationStartTime(){return null}getSeekRange(){return{start:0,end:0}}getVolume(){const a=this.a.getVolume();return typeof a===_.t?a/100:null}setVolume(a){this.a.setVolume(a)}getDuration(){return this.getMediaDuration()}getMediaDuration(){return this.a.getDuration()}getBufferInfo(){this.g.warn(_.qa);return new _.Ns}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>
54
+ {this.l.release()})}release(){const a=this;return _.x(function*(){a.h&&(yield a.h.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.l.release();a.f.release();a.A=!1})}load(a){const b=this;return _.x(function*(){b.configuration=_.Sk(b.C,a);var c=_.zn(b.configuration,[_.$d,"native"]);b.o=c.create(b);c=_.Xn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=new AP;b.h.initialize(b);try{yield b.h.load(c),b.h.start()}catch(d){b.g.error(d)}}try{yield b.a.load(b.configuration)}catch(d){throw b.onError(d),
55
+ d;}b.l.load()})}play(){this.trigger(new _.D(_.Qe));tP(this);return this.a.play().then(()=>{zO(this.f)})}pause(){return this.a.pause().then(()=>{zO(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=new _.D(_.q,{detail:a});a.severity===_.E&&(wO(this.f,_.Qn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.Jn}isPaused(){return this.a.getState()===yO}isMuted(){return jP(this.a)}setMuted(a){nP(this.a,
56
+ a)}getNetworkEngine(){return this.D}setNetworkEngine(a){this.D=a}isLive(){return this.a.isLive()}getStats(){return null}setSourceIndex(a){this.a.setSourceIndex(a)}getSourceIndex(){return this.a.getSourceIndex()}getLoadedSource(){return this.a.getLoadedSource()}canPlay(a,b){return(new LP).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};MP.prototype.getTextDisplayer=MP.prototype.getTextDisplayer;MP.prototype.setNetworkEngine=MP.prototype.setNetworkEngine;
57
+ MP.prototype.getNetworkEngine=MP.prototype.getNetworkEngine;var KP="clpp.tizen",JP=0,LP=class{a(){return KP}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.yc||a===_.Kk||a===_.Dc)&&b){if(_.Tj(2))return 2;if(_.Tj(3)||_.Tj(4)||_.Tj(5)||_.Tj(6))return _.B("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}f(a){return a===_.na}create(){return new MP}};_.z("clpp.tizen.TizenComponent",class extends _.Gt{f(){_.ih(new LP)}a(){var a=KP;a&&_.gh[a]&&(delete _.gh[a],_.hh.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var oP="onbufferingstart",uP="onbufferingprogress",vP="onbufferingcomplete",wP="onstreamcompleted",eP="oncurrentplaytime",DP="onevent",FP="onsubtitlechange",GP="ondrmevent",HP="onerror",qP="preparingstart",rP="preparingend";};f.call(g, window);
package/cl.ttml.js CHANGED
@@ -1,22 +1,22 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Xu='application/mp4; codecs\x3d"stpp.ttml"',Yu='application/mp4; codecs\x3d"stpp.ttml.im1i"',Zu='application/mp4; codecs\x3d"stpp.ttml.im1t"',$u="backgroundColor",av="direction",bv="displayAlign",cv="region",dv="textAlign",ev="textDecoration",fv="writingMode",gv=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(c in e.a)return e.getAttribute(c)}return null},ov=function(a,b){var c=null;if(hv.test(a)){{a=hv.exec(a);c=Number(a[1]);const d=Number(a[2]);let e=
2
- Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else iv.test(a)?c=jv(iv,a):kv.test(a)?c=jv(kv,a):lv.test(a)?(a=lv.exec(a),c=Number(a[1])/b.frameRate):mv.test(a)?(a=mv.exec(a),c=Number(a[1])/b.a):nv.test(a)&&(c=jv(nv,a));return c},jv=function(a,b){a=a.exec(b);return null==a||""===a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},pv=function(a){return a.split(":").pop()},qv=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},sv=function(a,b){for(;rv.test(a);){const c=rv.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},uv=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},vv=function(a,b,c){a=gv(a,b,dv);if(!a&&c&&(a=gv(c,b,dv),!a&&"rltb"===gv(c,b,fv)))return _.mf;switch(a){case _.Vc:return _.Hr;case _.mf:case _.Od:return _.mf;default:return _.ee}},wv=function(a,b,c){if(_.ei(a.w))return document.createTextNode(_.ii(a.w||""));if(a.A)return _.$n("br");const d=_.$n("span");for(const e of a.f)_.ao(d,
4
- e);for(const e of a.j)d.appendChild(wv(c.get(e),b,c));return d},zv=function(a,b,c,d){const e=xv.exec(a);a=yv.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Av=function(a,b){return typeof b===_.r&&0<b?_.Pr:yv.test(a)?0:_.Pr},Bv=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},Cv=function(a,b){a=a.getAttribute("extent");return(a=yv.exec(a))?Number(a[b]):null},Ev=function(a){a=a.getAttribute("cellResolution");return(a=Dv.exec(a))?Number(a[2]):null},
5
- Gv=function(){return`${"inline-"}${Fv++}`},Iv=function(a){return Hv.some(b=>b in a.attributes)},Jv=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...Jv(a,a.a.get(d).f),d);return c},Kv=function(a){return pv(a.g.nodeName)},Nv=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},Lv.forEach(l=>
6
- {l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(cv)&&(c=b.getAttribute(cv));b.hasAttribute(_.Af)&&f.push(...b.getAttribute(_.Af).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=pv(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new Mv(b,c,d,e,f,g);a.a.set(b,c);return c},Ov=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*
7
- a%1E3)).padStart(3,"0")}`},Pv=class{constructor(a,b,c){this.g=a;this.f=b;this.a=c}getId(){return this.g}getAttribute(a){return this.a[a]}};var Qv=class extends Pv{constructor(a,b,c){super(a,[],c);this.j=b||""}};var Rv=class extends Pv{constructor(a,b,c){super(a,b,c)}};var hv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,iv=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,kv=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,lv=/^(\d*(?:\.\d*)?)f$/,mv=/^(\d*(?:\.\d*)?)t$/,nv=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,xv=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,yv=/^(\d+)px (\d+)px$/,Dv=/^(\d+) (\d+)$/,rv=/(\d+)px/,Sv=/^(\d+px|\d+em|\d*\.?\d+c)$/,Hv=[$u,"color",av,bv,"fontFamily","fontSize","fontStyle","fontWeight",
8
- "lineHeight","opacity","padding",dv,ev,"textOutline",fv,"zIndex"],Lv=["begin",_.Od];var Tv=class extends Rv{constructor(a,b,c,d,e,f,g){super(a,f,g);this.w=b;this.A=c;this.o=d;this.l=e;this.j=[]}build(a,b,c,d,e,f,g){let h=ov(this.a.begin,b);b=ov(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.$n(_.Bd);for(const k of this.j)c.appendChild(wv(g.get(k),e,g));g=new _.Mr(h,b,c.innerHTML.trim(),_.Hf);g.cssClassList=[...this.f];g.textAlign=vv(this,e,null);g.writingMode=_.Ir;g.line=-1;g.lineInterpretation=_.Jr;g.lineAlign=_.Kr;g.containerRows=Bv(null,Ev(a),15);if(this.o&&(f=
9
- f.get(this.o))){g.region=f.build(a,e);g.textAlign=vv(this,e,f);a:switch(gv(f,e,fv)){case "tb":case "tblr":a=_.Vf;break a;case "tbrl":a=_.Wf;break a;default:a=_.Ir}g.writingMode=a;a:switch(gv(f,e,bv)){case _.Vc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(gv(f,e,bv)){case _.Vc:a=1;break a;default:a=_.Jr}g.lineInterpretation=a;a:switch(gv(f,e,bv)){case _.Vc:e=_.Vc;break a;default:e=_.Kr}g.lineAlign=e}this.l&&(d=d.get(this.l))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
- a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var Uv=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0===this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=Number(a[1])/Number(a[2]))}};var Vv=class extends Rv{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Rr;c.id=this.getId();const d=Bv(a.j.containerWidth,Cv(a,1),720);a=Bv(a.j.containerHeight,Cv(a,2),480);a:switch(gv(this,b,bv)){case "after":var e="flex-start";break a;case _.Vc:e=_.Vc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(gv(this,b,fv)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.nd}c.writingMode=e;e=this.getAttribute("extent")||gv(this,b,"extent");c.width=zv(e,
11
- d,1,100);c.widthUnits=Av(e,d);c.height=zv(e,a,2,100);c.heightUnits=Av(e,a);b=this.getAttribute("origin")||gv(this,b,"origin");c.viewportAnchorX=zv(b,d,1,0);c.viewportAnchorY=zv(b,a,2,0);c.viewportAnchorUnits=Av(b,d);c.cssClassList=[...this.f];return c}};var Wv=class extends Pv{constructor(a,b){super("root-container",[],b);this.j=a}};var Yv=class extends Pv{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=Ev(a);c&&(b=Bv(a.j.containerHeight,Cv(a,2),480)/c);b=Bv(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.g}, ::ttml .${this.g} * {`;for(const [g,h]of Xv.entries())g in this.a&&(c+=`${h}:${qv(this.a[g])};`);a:{if("unicodeBidi"in this.a){var d=this.a.unicodeBidi;var e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d=`unicode-bidi:${e};`;break a}}d=""}c+=d;a:{if("textOutline"in
12
- this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!Sv.test(h)&&Sv.test(k)&&Sv.test(l)?(e=h,g=k):2===d.length&&!Sv.test(h)&&Sv.test(k)?(e=h,g=k):2===d.length&&Sv.test(h)&&Sv.test(k)&&(g=h);if(""!==g){g=qv(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c+=d;"textShadow"in this.a?(d=uv(this.a.textShadow),d=qv(d),d=`text-shadow:${d};`):d="";c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif",
13
- "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(ev in this.a){d=this.a.textDecoration.split(" ");e=[];for(f of d)switch(f){case "underline":case "overline":e.push(f);break;case "lineThrough":e.push("line-through")}if(0<e.length){var f=`text-decoration:${e.join(" ")};`;break a}}f=""}"padding"in this.a?(d="border: solid transparent;border-width:"+
14
- qv(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=qv(d),d=sv(d,b),c+="line-height:",c+=d,c+=";"):c="";a.push(f+c+"}");a:{if("fontSize"in this.a&&(f=this.a.fontSize.split(" "),c=null,1===f.length&&(c=f[0]),2===f.length&&(c=f[1]),c)){c=c.trim();c=qv(c);c=sv(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.g} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.g} {`,f+=b,f+="}",a.push(f));return a}},Xv=new Map([[$u,"background-color"],
15
- ["color","color"],[av,av],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Zv=class{constructor(a){this.B=a;this.w=this.l=null;this.A=0;this.g=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}Oc(){return this.o.map(a=>a.build(this.l,this.w,this.A,this.g,this.a,this.j,this.f)).filter(a=>null!=a)}},Fv=0;var bw=class{constructor(a){this.a=a.firstChild;this.f=new Set}Ac(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!$v.has(pv(a.nodeName))||aw.has(pv(a.nodeName))||!a.firstChild||this.f.has(a.firstChild)?a.nextSibling?a=a.nextSibling:a=a.parentNode:a=a.firstChild;while(a&&(this.f.has(a)||a.nodeType!==Node.TEXT_NODE&&!$v.has(pv(a.nodeName))));const b=this.a;this.a=a;return b}},$v=new Set(["tt","head","layout",_.re,_.Yd,cv,"styling",_.Af,"body",
16
- _.Bd,"p","span","br"]),aw=new Set([_.Af,_.Yd]);var Mv=class{constructor(a,b,c,d,e,f){this.g=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var cw=class{constructor(){this.a=new Map}};var dw=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.yg(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.Wh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Ef)}catch(m){throw new _.H(_.F,2,2005,"Failed to parse TTML.");}d=new Zv(d);e=new cw;f=new bw(f);b=b.periodStart;typeof b===_.r&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.J(a,b,h);k=_.ji(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.g.set(m,
17
- new Qv(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Ac();)a=f.next(),a=Nv(e,a),c=d,b=a,"tt"===Kv(b)&&(c.l=new Wv(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===Kv(b)&&(c.w=new Uv(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,Kv(b)!==_.Yd||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.g.set(g,new Qv(g,b.g.textContent,b.attributes))),c=d,g=a,Kv(g)===_.Yd&&g.attributes.begin&&g.attributes.end?(b=`#${Gv()}`,
18
- g=new Qv(b,g.g.textContent,g.attributes),c.g.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,Kv(b)===_.Af&&(g=b.getId()||Gv(),h=new Yv(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.j.get(b.a).f.push(g)),c=d,g=a,Kv(g)!==_.Af&&Iv(g)?(b=Gv(),g=new Yv(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,Kv(g)!==_.Bd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=Gv(),g=new Vv(b,Jv(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
- c.getId()),c=d,g=a,Kv(g)!==cv?c=null:(b=g.getId(),g=new Vv(b,Jv(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===["#text","span","br"].indexOf(Kv(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=Gv(),g=new Tv(b,"#text"===g.g.nodeName?g.g.textContent:null,"br"===Kv(g),g.a,g.j,Jv(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.j.push(b),c=g):c=null),c&&a.l.push(c.getId()),c=d,g=a,"p"===Kv(g)||g.j?(b=Gv(),g=new Tv(b,null,!1,g.a,g.j,Jv(c,g.f),g.attributes),
20
- c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=d.Oc();f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var ew=class{constructor(a){this.f=a}a(a){var b=new dw(this.f);({cues:a}=b.parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}));b="WEBVTT\n\n";for(const d of a){a=b;b=Ov(d.startTime)+" --\x3e "+Ov(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ee:e.push("align:left");break;case _.mf:e.push("align:right");break;case _.Hr:e.push("align:middle");break;case _.ee:e.push("align:start");break;case _.mf:e.push("align:end")}switch(c.writingMode){case _.Vf:e.push("vertical:lr");break;case _.Wf:e.push("vertical:rl")}c=
21
- e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.$h(b)}},fw=class{probe(a,b){return a===_.yc&&b===_.Df}create(a){return new ew(a)}};var gw=class{constructor(a){this.a=new dw(a);this.h=new _.R("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.sl).L(_.ue,_.ll).L(_.Gf,_.ll).L(_.pe,_.ll).L(_.te,_.ll).L(_.xf,_.ll).$(_.zf,_.ml).L("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.F,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.sl).L("moof",_.ll).L("traf",_.ll).$("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.el(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.P(g.reader):_.el(g.reader);f.push(n);g.reader.skip(6)}}}).L(_.oe,_.nl(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.h.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.x("clpp.ttml.TtmlComponent",class extends _.ht{constructor(){super();this.j=new fw}f(){_.rr(_.yc,dw);_.rr(_.vc,gw);_.rr(Xu,gw);_.rr(Zu,gw);_.rr(Yu,gw);_.kj.push(this.j)}a(){_.tr(_.yc);_.tr(_.vc);_.tr(Xu);_.tr(Zu);_.tr(Yu);_.mj(this.j)}id(){return"subtitles-ttml"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var yv='application/mp4; codecs\x3d"stpp.ttml"',zv='application/mp4; codecs\x3d"stpp.ttml.im1i"',Av='application/mp4; codecs\x3d"stpp.ttml.im1t"',Bv="backgroundColor",Cv="direction",Dv="displayAlign",Ev="region",Fv="textAlign",Gv="textDecoration",Hv="writingMode",Iv=function(a,b,c){a=a.f;for(let d=a.length-1;0<=d;d--){const e=b.get(a[d]);if(c in e.a)return e.getAttribute(c)}return null},Qv=function(a,b){var c=null;if(Jv.test(a)){{a=Jv.exec(a);c=Number(a[1]);const d=Number(a[2]);let e=
2
+ Number(a[3]),f=Number(a[4]);f+=(Number(a[5])||0)/b.f;e+=f/b.frameRate;c=e+60*d+3600*c}}else Kv.test(a)?c=Lv(Kv,a):Mv.test(a)?c=Lv(Mv,a):Nv.test(a)?(a=Nv.exec(a),c=Number(a[1])/b.frameRate):Ov.test(a)?(a=Ov.exec(a),c=Number(a[1])/b.a):Pv.test(a)&&(c=Lv(Pv,a));return c},Lv=function(a,b){a=a.exec(b);return null==a||""===a[0]?null:(Number(a[4])||0)/1E3+(Number(a[3])||0)+60*(Number(a[2])||0)+3600*(Number(a[1])||0)},Rv=function(a){return a.split(":").pop()},Sv=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},Uv=function(a,b){for(;Tv.test(a);){const c=Tv.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Vv=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Wv=function(a,b,c){a=Iv(a,b,Fv);if(!a&&c&&(a=Iv(c,b,Fv),!a&&"rltb"===Iv(c,b,Hv)))return _.vf;switch(a){case _.$c:return _.cs;case _.vf:case _.Td:return _.vf;default:return _.ee}},Xv=function(a,b,c){if(_.ti(a.w))return document.createTextNode(_.xi(a.w||""));if(a.A)return _.po("br");const d=_.po("span");for(const e of a.f)_.qo(d,
4
+ e);for(const e of a.j)d.appendChild(Xv(c.get(e),b,c));return d},$v=function(a,b,c,d){const e=Yv.exec(a);a=Zv.exec(a);return typeof b===_.t&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},aw=function(a,b){return typeof b===_.t&&0<b?_.ms:Zv.test(a)?0:_.ms},bw=function(a,b,c){return typeof a===_.t?a:typeof b===_.t?b:c},cw=function(a,b){a=a.getAttribute("extent");return(a=Zv.exec(a))?Number(a[b]):null},ew=function(a){a=a.getAttribute("cellResolution");return(a=dw.exec(a))?Number(a[2]):null},
5
+ gw=function(){return`${"inline-"}${fw++}`},iw=function(a){return hw.some(b=>b in a.attributes)},jw=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...jw(a,a.a.get(d).f),d);return c},kw=function(a){return Rv(a.h.nodeName)},nw=function(a,b){if(a.a.has(b))return a.a.get(b);var c=null,d=null;let e=[],f=[],g={};const h=b.parentNode;if(h&&a.a.has(h)){const k=a.a.get(h);e=[...k.l];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.j,f=[...k.f],g={},lw.forEach(l=>
6
+ {l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Ev)&&(c=b.getAttribute(Ev));b.hasAttribute(_.Of)&&f.push(...b.getAttribute(_.Of).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Rv(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new mw(b,c,d,e,f,g);a.a.set(b,c);return c},ow=function(a){return`${String(Math.floor(a/3600)).padStart(2,"0")}:${String(Math.floor(a/60%60)).padStart(2,"0")}:${String(Math.floor(a%60)).padStart(2,"0")}.${String(Math.floor(1E3*
7
+ a%1E3)).padStart(3,"0")}`},pw=class{constructor(a,b,c){this.h=a;this.f=b;this.a=c}getId(){return this.h}getAttribute(a){return this.a[a]}};var qw=class extends pw{constructor(a,b,c){super(a,[],c);this.j=b||""}};var rw=class extends pw{constructor(a,b,c){super(a,b,c)}};var Jv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Kv=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Mv=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Nv=/^(\d*(?:\.\d*)?)f$/,Ov=/^(\d*(?:\.\d*)?)t$/,Pv=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Yv=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Zv=/^(\d+)px (\d+)px$/,dw=/^(\d+) (\d+)$/,Tv=/(\d+)px/,sw=/^(\d+px|\d+em|\d*\.?\d+c)$/,hw=[Bv,"color",Cv,Dv,"fontFamily","fontSize","fontStyle","fontWeight",
8
+ "lineHeight","opacity","padding",Fv,Gv,"textOutline",Hv,"zIndex"],lw=["begin",_.Td];var tw=class extends rw{constructor(a,b,c,d,e,f,g){super(a,f,g);this.w=b;this.A=c;this.o=d;this.l=e;this.j=[]}build(a,b,c,d,e,f,g){let h=Qv(this.a.begin,b);b=Qv(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.po(_.Fd);for(const k of this.j)c.appendChild(Xv(g.get(k),e,g));g=new _.js(h,b,c.innerHTML.trim(),_.Vf);g.cssClassList=[...this.f];g.textAlign=Wv(this,e,null);g.writingMode=_.ds;g.line=-1;g.lineInterpretation=_.es;g.lineAlign=_.hs;g.containerRows=bw(null,ew(a),15);if(this.o&&(f=
9
+ f.get(this.o))){g.region=f.build(a,e);g.textAlign=Wv(this,e,f);a:switch(Iv(f,e,Hv)){case "tb":case "tblr":a=_.dg;break a;case "tbrl":a=_.eg;break a;default:a=_.ds}g.writingMode=a;a:switch(Iv(f,e,Dv)){case _.$c:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Iv(f,e,Dv)){case _.$c:a=1;break a;default:a=_.es}g.lineInterpretation=a;a:switch(Iv(f,e,Dv)){case _.$c:e=_.$c;break a;default:e=_.hs}g.lineAlign=e}this.l&&(d=d.get(this.l))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
+ a.getAttribute("imagetype"),a=a.j.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var uw=class{constructor(a,b,c,d){this.frameRate=Number(a)||30;this.f=Number(b)||1;this.a=Number(d);0===this.a&&(this.a=a?this.frameRate*this.f:1);c&&(a=/^(\d+) (\d+)$/g.exec(c))&&(this.frameRate*=Number(a[1])/Number(a[2]))}};var vw=class extends rw{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.os;c.id=this.getId();const d=bw(a.j.containerWidth,cw(a,1),720);a=bw(a.j.containerHeight,cw(a,2),480);a:switch(Iv(this,b,Dv)){case "after":var e="flex-start";break a;case _.$c:e=_.$c;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Iv(this,b,Hv)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.sd}c.writingMode=e;e=this.getAttribute("extent")||Iv(this,b,"extent");c.width=$v(e,
11
+ d,1,100);c.widthUnits=aw(e,d);c.height=$v(e,a,2,100);c.heightUnits=aw(e,a);b=this.getAttribute("origin")||Iv(this,b,"origin");c.viewportAnchorX=$v(b,d,1,0);c.viewportAnchorY=$v(b,a,2,0);c.viewportAnchorUnits=aw(b,d);c.cssClassList=[...this.f];return c}};var ww=class extends pw{constructor(a,b){super("root-container",[],b);this.j=a}};var yw=class extends pw{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=ew(a);c&&(b=bw(a.j.containerHeight,cw(a,2),480)/c);b=bw(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of xw.entries())g in this.a&&(c+=`${h}:${Sv(this.a[g])};`);a:{if("unicodeBidi"in this.a){var d=this.a.unicodeBidi;var e="";switch(d){case "normal":case "embed":e=d;break;case "bidiOverride":e="bidi-override"}if(0<e.length){d=`unicode-bidi:${e};`;break a}}d=""}c+=d;a:{if("textOutline"in
12
+ this.a){d=this.a.textOutline.split(" ");e="black";let g=".4em";const h=d[0]&&d[0].trim(),k=d[1]&&d[1].trim(),l=d[2]&&d[2].trim();3===d.length&&!sw.test(h)&&sw.test(k)&&sw.test(l)?(e=h,g=k):2===d.length&&!sw.test(h)&&sw.test(k)?(e=h,g=k):2===d.length&&sw.test(h)&&sw.test(k)&&(g=h);if(""!==g){g=Sv(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c+=d;"textShadow"in this.a?(d=Vv(this.a.textShadow),d=Sv(d),d=`text-shadow:${d};`):d="";c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif",
13
+ "monospace").replace("monospaceSerif","monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(Gv in this.a){d=this.a.textDecoration.split(" ");e=[];for(f of d)switch(f){case "underline":case "overline":e.push(f);break;case "lineThrough":e.push("line-through")}if(0<e.length){var f=`text-decoration:${e.join(" ")};`;break a}}f=""}"padding"in this.a?(d="border: solid transparent;border-width:"+
14
+ Sv(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Sv(d),d=Uv(d,b),c+="line-height:",c+=d,c+=";"):c="";a.push(f+c+"}");a:{if("fontSize"in this.a&&(f=this.a.fontSize.split(" "),c=null,1===f.length&&(c=f[0]),2===f.length&&(c=f[1]),c)){c=c.trim();c=Sv(c);c=Uv(c,b);b=`font-size:${c};`;break a}b=null}b&&(f=`::ttml .${this.h} .clpp-text-wrapper {`,f+=b,f+="}",a.push(f),f=`::ttml .clpp-text-wrapper__${this.h} {`,f+=b,f+="}",a.push(f));return a}},xw=new Map([[Bv,"background-color"],
15
+ ["color","color"],[Cv,Cv],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var zw=class{constructor(a){this.C=a;this.w=this.l=null;this.A=0;this.h=new Map;this.a=new Map;this.j=new Map;this.f=new Map;this.o=[]}Zc(){return this.o.map(a=>a.build(this.l,this.w,this.A,this.h,this.a,this.j,this.f)).filter(a=>null!=a)}},fw=0;var Cw=class{constructor(a){this.a=a.firstChild;this.f=new Set}Jc(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Aw.has(Rv(a.nodeName))||Bw.has(Rv(a.nodeName))||!a.firstChild||this.f.has(a.firstChild)?a.nextSibling?a=a.nextSibling:a=a.parentNode:a=a.firstChild;while(a&&(this.f.has(a)||a.nodeType!==Node.TEXT_NODE&&!Aw.has(Rv(a.nodeName))));const b=this.a;this.a=a;return b}},Aw=new Set(["tt","head","layout",_.ve,_.ae,Ev,"styling",_.Of,"body",
16
+ _.Fd,"p","span","br"]),Bw=new Set([_.Of,_.ae]);var mw=class{constructor(a,b,c,d,e,f){this.h=a;this.a=b;this.j=c;this.l=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var Dw=class{constructor(){this.a=new Map}};var Ew=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.Mg(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.ki(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Sf)}catch(m){throw new _.H(_.E,2,2005,"Failed to parse TTML.");}d=new zw(d);e=new Dw;f=new Cw(f);b=b.periodStart;typeof b===_.t&&(d.A=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.J(a,b,h);k=_.yi(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
+ new qw(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Jc();)a=f.next(),a=nw(e,a),c=d,b=a,"tt"===kw(b)&&(c.l=new ww(c.C,Object.assign({},b.attributes))),c=d,b=a,"tt"===kw(b)&&(c.w=new uw(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,kw(b)!==_.ae||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new qw(g,b.h.textContent,b.attributes))),c=d,g=a,kw(g)===_.ae&&g.attributes.begin&&g.attributes.end?(b=`#${gw()}`,
18
+ g=new qw(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,kw(b)===_.Of&&(g=b.getId()||gw(),h=new yw(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.j.get(b.a).f.push(g)),c=d,g=a,kw(g)!==_.Of&&iw(g)?(b=gw(),g=new yw(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,kw(g)!==_.Fd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=gw(),g=new vw(b,jw(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,kw(g)!==Ev?c=null:(b=g.getId(),g=new vw(b,jw(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.l,-1===["#text","span","br"].indexOf(kw(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=gw(),g=new tw(b,"#text"===g.h.nodeName?g.h.textContent:null,"br"===kw(g),g.a,g.j,jw(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.j.push(b),c=g):c=null),c&&a.l.push(c.getId()),c=d,g=a,"p"===kw(g)||g.j?(b=gw(),g=new tw(b,null,!1,g.a,g.j,jw(c,g.f),g.attributes),
20
+ c.f.set(b,g),c.o.push(g),c=g):c=null,c&&a.l.push(c.getId());e=d.Zc();f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Fw=class{constructor(a){this.f=a}a(a){var b=new Ew(this.f);({cues:a}=b.parseMedia(a,{periodStart:0,segmentStart:null,segmentEnd:0}));b="WEBVTT\n\n";for(const d of a){a=b;b=ow(d.startTime)+" --\x3e "+ow(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.ee:e.push("align:left");break;case _.vf:e.push("align:right");break;case _.cs:e.push("align:middle");break;case _.ee:e.push("align:start");break;case _.vf:e.push("align:end")}switch(c.writingMode){case _.dg:e.push("vertical:lr");break;case _.eg:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.oi(b)}},Gw=class{probe(a,b){return a===_.Cc&&b===_.Rf}create(a){return new Fw(a)}};var Hw=class{constructor(a){this.a=new Ew(a);this.g=new _.S("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Hl).L(_.ye,_.Q).L(_.Uf,_.Q).L(_.qe,_.Q).L(_.xe,_.Q).L(_.Lf,_.Q).ba(_.Nf,_.Bl).L("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.E,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.Hl).L("moof",_.Q).L("traf",_.Q).ba("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.ul(g.reader);for(let m=0;m<l;++m){const n=1===g.version?_.P(g.reader):
22
+ _.ul(g.reader);f.push(n);g.reader.skip(6)}}}).L(_.pe,_.Cl(g=>{c=!0;g=this.a.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.g.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.z("clpp.ttml.TtmlComponent",class extends _.Gt{constructor(){super();this.j=new Gw}f(){_.Nr(_.Cc,Ew);_.Nr(_.Ac,Hw);_.Nr(yv,Hw);_.Nr(Av,Hw);_.Nr(zv,Hw);_.zj.push(this.j)}a(){_.Pr(_.Cc);_.Pr(_.Ac);_.Pr(yv);_.Pr(Av);_.Pr(zv);_.Bj(this.j)}id(){return"subtitles-ttml"}});};f.call(g, window);
package/cl.verimatrix.js CHANGED
@@ -1,4 +1,4 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mu="VerimatrixVCAS",Nu="clpp.verimatrix.Vcas",Ou="clpp.verimatrix.VcasComponent",Qu=function(a,b){return a.C===Pu?(a=Object.assign({},{deviceId:_.ki(_.bi(a.A))},a.a&&{authenticator:_.ki(_.bi(a.a))}),b+_.Si(a)):b},Wu=class extends _.vs{constructor(a){super(Mu);const b={};b[Ru]=Ru;b[Su]=Su;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=Pu,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- Tu}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=Qu(this,g);this.o=Qu(this,h);this.l=Qu(this,k);this.j=l;this.G=m;this.F=n;this.h=new _.R(Nu);_.fi(this.w)?this.h.warn(_.Rb):this.Ma(_.ud,{licenseUrl:this.w,videoRobustness:[_.Ab,void 0],audioRobustness:[_.zb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.g.bind(this)}});_.fi(this.o)?this.h.warn(_.pb):this.Ma(_.sd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.g.bind(this)}});_.fi(this.l)?this.h.warn(_.Ra):_.fi(this.j)?this.h.warn(_.Qa):this.Ma(_.pd,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}g(a,b){if(this.C===Uu){a=this.B[Su];const c={};c[this.B[Ru]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.rl(b);switch(this.F){case Vu:a=_.Si({r:a,Bh:this.G},!0)}return a}J(a,b){this.g(a,
4
- b);_.wl(b)}K(a,b){_.xl(b)}};_.x(Nu,Wu);Wu.prototype.constructor=Wu.prototype.constructor;Wu.NAME=Mu;var Pu="query-string",Uu="http-header";Wu.LicenseRequestVuidLocation={QUERY_STRING:Pu,HTTP_HEADER:Uu};var Ru="DeviceId",Su="Authenticator";Wu.LicenseRequestHttpHeader={DEVICE_ID_HEADER:Ru,AUTHENTICATOR_HEADER:Su};var Tu="keyid",Vu="contentid-siteid";Wu.FairPlayAssetIdStrategy={KEYID:Tu,CONTENTID_SITEID:Vu};_.x(Ou,class extends _.ht{constructor(){super();this.h=new _.R(Ou)}a(){delete _.Tk.VerimatrixVCAS}g(a){a=a.getConfiguration();if(a.drm&&a.drm.env===Mu){({customData:a}=a.drm);if(!a)throw new _.H(_.F,7,7100,_.vd);a=new Wu(a);this.h.info("Registering the Verimatrix VCAS Ultra environment");_.Uk(a)}}id(){return"verimatrix-vcas"}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var mv="VerimatrixVCAS",nv="clpp.verimatrix.Vcas",ov="clpp.verimatrix.VcasComponent",qv=function(a,b){return a.D===pv?(a=Object.assign({},{deviceId:_.zi(_.qi(a.A))},a.a&&{authenticator:_.zi(_.qi(a.a))}),b+_.gj(a)):b},xv=class extends _.Ts{constructor(a){super(mv);const b={};b[rv]=rv;b[sv]=sv;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=pv,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ uv}=a;this.A=c;this.a=d;this.D=e;this.C=f;this.w=qv(this,g);this.o=qv(this,h);this.l=qv(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.S(nv);_.ui(this.w)?this.g.warn(_.Vb):this.bb(_.yd,{licenseUrl:this.w,videoRobustness:[_.Eb,void 0],audioRobustness:[_.Db,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.ui(this.o)?this.g.warn(_.tb):this.bb(_.wd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.ui(this.l)?this.g.warn(_.Ta):_.ui(this.j)?this.g.warn(_.Sa):this.bb(_.ud,{licenseUrl:this.l,certificateUrl:this.j,modifiers:{licenseRequest:this.J.bind(this),licenseResponse:this.K.bind(this),extractContentId:this.H.bind(this)}})}h(a,b){if(this.D===vv){a=this.C[sv];const c={};c[this.C[rv]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Gl(b);switch(this.F){case wv:a=_.gj({r:a,Th:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.Ll(b)}K(a,b){_.Ml(b)}};_.z(nv,xv);xv.prototype.constructor=xv.prototype.constructor;xv.NAME=mv;var pv="query-string",vv="http-header";xv.LicenseRequestVuidLocation={QUERY_STRING:pv,HTTP_HEADER:vv};var rv="DeviceId",sv="Authenticator";xv.LicenseRequestHttpHeader={DEVICE_ID_HEADER:rv,AUTHENTICATOR_HEADER:sv};var uv="keyid",wv="contentid-siteid";xv.FairPlayAssetIdStrategy={KEYID:uv,CONTENTID_SITEID:wv};_.z(ov,class extends _.Gt{constructor(){super();this.g=new _.S(ov)}a(){delete _.jl.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===mv){({customData:a}=a.drm);if(!a)throw new _.H(_.E,7,7100,_.zd);a=new xv(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.kl(a)}}id(){return"verimatrix-vcas"}});};f.call(g, window);
package/cl.vimond.js CHANGED
@@ -1,8 +1,8 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Du="Registering listeners",Eu="clpp.vimond.VimondPlugin",Fu=function(a,b){a.m.trigger(new _.C(_.ag,{detail:b}))},Gu=function(a,b,c){b&&(a.B=!0,a.g.stop());a.m.onError(new _.H(b?_.F:1,9,9201,c))},Hu=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.Te];if(a.g)return[_.Od,_.Ie];if(c===_.un)return[_.Od,null];if(c===_.Bn)return[_.Qd,_.Ie];b=_.Ie;if(c===_.xn||c===_.Fn||a.f)b=_.Te;return["period",b]},Iu=class{constructor(a,b,c,d,e){this.K=a;this.M=b;this.O=c;this.m=d;this.F=
2
- e;this.a=new _.Er;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.g=new _.zj(this.A.bind(this));this.h=new _.R("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.h.debug(Du),this.a.on(this.m,_.vf,this.I.bind(this)),this.a.on(this.m,_.Ff,this.J.bind(this)),this.a.on(this.m,_.Xb,this.G.bind(this)),this.a.on(this.m,_.Zb,this.H.bind(this)))}J(){this.f||(this.f=1<Math.abs(this.w-this.m.getPosition()));this.w=this.m.getPosition()}G(){this.h.debug("Ad break started");this.j=!0}H(){this.h.debug("Ad break stopped");
3
- this.j=!1}I(a){const b=this;return _.w(function*(){const c=a.detail,d=c.currentState;b.h.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.f?b.l&&d!==_.Fn||(b.f&&[_.En,_.xn].includes(d)?b.h.debug("Seeking"):(b.f&&d===_.Fn&&(b.h.debug("Seeked"),b.f=!1),[_.Fn,_.En,_.Bn,_.un].includes(d)&&(b.C=d,yield b.A(),d===_.un&&b.g.stop()))):b.h.debug("Ignore transition"))})}A(){const a=this;return _.w(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.h.debug(`Last event was ${n-
4
- a.o} seconds ago`);a.o=n}a.g.stop();a.g.ca(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const q=_.xg(b.o);q.client.buildName=_.pa;q.client.buildVersion=_.da;var c=q.client;{const A=b.a.m.getDrmInfo();var d=A?A.keySystem:""}c.drm=d;q.client.pageUrl=document.location.href;q.client.streamUrl=b.a.m.getLoadedSource().url;q.client.userAgent=navigator.userAgent;q.client.videoFormat=b.a.m.getLoadedSource().type||"";var e=q.client;{const A=b.a.m.getLoadedSource();var f=((new _.ql(A.url)).scheme||"").replace(":",
5
- "")}e.videoProtocol=f;const t=Hu(b.a,b.f);q.client.playerEvent=t[0]||"";q.client.playerState=t[1]||"";q.progress.vod&&(q.progress.vod.position=b.a.getPosition());const v=q.progress.live;if(v){{var g=b.a;const A=g.m.getPresentationStartTime()||0,D=Math.floor(A+g.m.getPosition());var h=(new Date(1E3*D)).toISOString()}v.position=h;{var k=b.a;const A=k.m.getPosition(),D=k.m.getSeekRange().end;var l=30>Math.abs(D-A)}v.onLiveEdge=l;typeof v.liveResumePossible!==_.Mc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
- b.f;q.timestamp=(new Date).toISOString();b.h.debug("Fire an event");const y=_.zi(b.l);y.method="POST";y.contentType="application/json";y.headers.Authorization=`Bearer ${b.g}`;y.body=_.bi(JSON.stringify(q));var m=b.j.fetch(y).P}const n=yield m;Fu(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.h.debug("Unreachable service"),Fu(a,b),Gu(a,a.M,b)):1001===m?(a.h.debug("Generic service error"),Fu(a,b),Gu(a,a.O,b)):a.h.error(n.toString())}})}dispose(){this.h.debug(_.Kb);_.Xg(this.a);this.g.stop()}};var Ju=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.g=b;this.a=d;this.j=e;this.h=new _.R("clpp.vimond.VimondService");this.f=0}ze(a){this.g=a}};var Ku=class{constructor(a){this.m=a;this.a=new _.Er;this.h=new _.R("clpp.vimond.VimondAdapter");this.f=this.g=!1;this.m&&this.a&&(this.h.debug(Du),this.a.on(this.m,_.hf,this.o.bind(this)),this.a.on(this.m,_.Xb,this.j.bind(this)),this.a.on(this.m,_.Zb,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.g=!0}j(){this.f=!0}l(){this.f=!1}dispose(){this.h.debug(_.Kb);_.Xg(this.a)}};var Lu=class extends _.It{constructor(){super();this.a=!1;this.h=new _.R(Eu);this.j=this.g=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.z(b.vimond)&&typeof b.vimond===_.ye)?a.namespace()===_.fd&&(this.a=!1,this.h.info("Vimond does not report when casting.")):this.h.warn("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.h.warn(`${c} key is missing`);
7
- a.onError(new _.H(1,9,9200));return}this.h.debug("Configuration is valid");c=b.failIfUnreachable;typeof c!==_.Mc&&(c=!0);var d=b.failOnError;typeof d!==_.Mc&&(d=!0);this.f=new Ku(a);this.g=new Ju(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new Iu(b.playerEventRequest.eventInterval,c,d,a,this.g)}}onPlayerWillRelease(){this.a&&(this.f&&this.f.dispose(),this.j&&this.j.dispose(),this.j=this.g=this.f=null)}onPlayerWillDestroy(){}id(){return"vimond"}ze(a){this.a&&
8
- this.g&&this.g.ze(a)}};_.x(Eu,Lu);Lu.prototype.updateAuthToken=Lu.prototype.ze;Lu.Id="vimond";_.Ho(new class{create(){return new Lu}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dv="Registering listeners",ev="clpp.vimond.VimondPlugin",fv=function(a,b){a.m.trigger(new _.D(_.jg,{detail:b}))},gv=function(a,b,c){b&&(a.C=!0,a.h.stop());a.m.onError(new _.H(b?_.E:1,9,9201,c))},hv=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.af];if(a.h)return[_.Td,_.Me];if(c===_.Jn)return[_.Td,null];if(c===_.Qn)return[_.q,_.Me];b=_.Me;if(c===_.Mn||c===_.Un||a.f)b=_.af;return["period",b]},iv=class{constructor(a,b,c,d,e){this.K=a;this.M=b;this.N=c;this.m=d;this.F=
2
+ e;this.a=new _.$r;this.l=!0;this.f=this.j=this.C=!1;this.D=null;this.h=new _.Pj(this.A.bind(this));this.g=new _.S("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(dv),this.a.on(this.m,_.Jf,this.I.bind(this)),this.a.on(this.m,_.Tf,this.J.bind(this)),this.a.on(this.m,_.bc,this.G.bind(this)),this.a.on(this.m,_.cc,this.H.bind(this)))}J(){this.f||(this.f=1<Math.abs(this.w-this.m.getPosition()));this.w=this.m.getPosition()}G(){this.g.debug("Ad break started");this.j=!0}H(){this.g.debug("Ad break stopped");
3
+ this.j=!1}I(a){const b=this;return _.x(function*(){const c=a.detail,d=c.currentState;b.g.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.C||b.j||(d!==b.D||b.f?b.l&&d!==_.Un||(b.f&&[_.Tn,_.Mn].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.Un&&(b.g.debug("Seeked"),b.f=!1),[_.Un,_.Tn,_.Qn,_.Jn].includes(d)&&(b.D=d,yield b.A(),d===_.Jn&&b.h.stop()))):b.g.debug("Ignore transition"))})}A(){const a=this;return _.x(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.g.debug(`Last event was ${n-
4
+ a.o} seconds ago`);a.o=n}a.h.stop();a.h.ia(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const r=_.Lg(b.o);r.client.buildName=_.ra;r.client.buildVersion=_.fa;var c=r.client;{const C=b.a.m.getDrmInfo();var d=C?C.keySystem:""}c.drm=d;r.client.pageUrl=document.location.href;r.client.streamUrl=b.a.m.getLoadedSource().url;r.client.userAgent=navigator.userAgent;r.client.videoFormat=b.a.m.getLoadedSource().type||"";var e=r.client;{const C=b.a.m.getLoadedSource();var f=((new _.Fl(C.url)).scheme||"").replace(":",
5
+ "")}e.videoProtocol=f;const v=hv(b.a,b.f);r.client.playerEvent=v[0]||"";r.client.playerState=v[1]||"";r.progress.vod&&(r.progress.vod.position=b.a.getPosition());const u=r.progress.live;if(u){{var g=b.a;const C=g.m.getPresentationStartTime()||0,F=Math.floor(C+g.m.getPosition());var h=(new Date(1E3*F)).toISOString()}u.position=h;{var k=b.a;const C=k.m.getPosition(),F=k.m.getSeekRange().end;var l=30>Math.abs(F-C)}u.onLiveEdge=l;typeof u.liveResumePossible!==_.Oc&&(u.liveResumePossible=!0)}r.progress.eventNumber=
6
+ b.f;r.timestamp=(new Date).toISOString();b.g.debug("Fire an event");const y=_.Oi(b.l);y.method="POST";y.contentType="application/json";y.headers.Authorization=`Bearer ${b.h}`;y.body=_.qi(JSON.stringify(r));var m=b.j.fetch(y).O}const n=yield m;fv(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.g.debug("Unreachable service"),fv(a,b),gv(a,a.M,b)):1001===m?(a.g.debug("Generic service error"),fv(a,b),gv(a,a.N,b)):a.g.error(n.toString())}})}dispose(){this.g.debug(_.Ob);_.lh(this.a);this.h.stop()}};var jv=class{constructor(a,b,c,d,e){this.l=a;this.o=c;this.h=b;this.a=d;this.j=e;this.g=new _.S("clpp.vimond.VimondService");this.f=0}Qe(a){this.h=a}};var kv=class{constructor(a){this.m=a;this.a=new _.$r;this.g=new _.S("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(dv),this.a.on(this.m,_.rf,this.o.bind(this)),this.a.on(this.m,_.bc,this.j.bind(this)),this.a.on(this.m,_.cc,this.l.bind(this)))}getPosition(){return Math.floor(this.m.getPosition())}o(){this.h=!0}j(){this.f=!0}l(){this.f=!1}dispose(){this.g.debug(_.Ob);_.lh(this.a)}};var lv=class extends _.iu{constructor(){super();this.a=!1;this.g=new _.S(ev);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.A(b.vimond)&&typeof b.vimond===_.Ce)?a.namespace()===_.jd&&(this.a=!1,this.g.info("Vimond does not report when casting.")):this.g.warn("Vimond plugin is loaded but not configured. Will do nothing.");if(this.a){b=a.getConfiguration().vimond;for(var c of["authToken","playerEventRequest"])if(!b[c]){this.g.warn(`${c} key is missing`);
7
+ a.onError(new _.H(1,9,9200));return}this.g.debug("Configuration is valid");c=b.failIfUnreachable;typeof c!==_.Oc&&(c=!0);var d=b.failOnError;typeof d!==_.Oc&&(d=!0);this.f=new kv(a);this.h=new jv(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new iv(b.playerEventRequest.eventInterval,c,d,a,this.h)}}onPlayerWillRelease(){this.a&&(this.f&&this.f.dispose(),this.j&&this.j.dispose(),this.j=this.h=this.f=null)}onPlayerWillDestroy(){}id(){return"vimond"}Qe(a){this.a&&
8
+ this.h&&this.h.Qe(a)}};_.z(ev,lv);lv.prototype.updateAuthToken=lv.prototype.Qe;lv.Id="vimond";_.Wo(new class{create(){return new lv}});};f.call(g, window);