@castlabs/prestoplay 6.13.0 → 6.14.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 +32 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -6
  5. package/cjs/cl.cast.js +83 -83
  6. package/cjs/cl.conviva.js +24 -24
  7. package/cjs/cl.core.js +431 -429
  8. package/cjs/cl.crypto.js +6 -6
  9. package/cjs/cl.dash.js +59 -59
  10. package/cjs/cl.externs.js +48 -40
  11. package/cjs/cl.freewheel.js +19 -19
  12. package/cjs/cl.hls.js +58 -57
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +17 -17
  15. package/cjs/cl.ima.js +18 -18
  16. package/cjs/cl.mse.js +269 -268
  17. package/cjs/cl.muxdata.js +15 -14
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +13 -13
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.simid.js +15 -15
  22. package/cjs/cl.smooth.js +33 -33
  23. package/cjs/cl.thumbnails.js +26 -26
  24. package/cjs/cl.tizen.js +53 -53
  25. package/cjs/cl.ttml.js +28 -28
  26. package/cjs/cl.verimatrix.js +5 -5
  27. package/cjs/cl.vimond.js +12 -12
  28. package/cjs/cl.vr.js +19 -19
  29. package/cjs/cl.vtt.js +14 -14
  30. package/cjs/cl.youbora.js +18 -18
  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 +87 -87
  35. package/cl.conviva.js +27 -27
  36. package/cl.core.js +424 -421
  37. package/cl.crypto.js +8 -8
  38. package/cl.dash.js +67 -67
  39. package/cl.externs.js +48 -40
  40. package/cl.freewheel.js +19 -19
  41. package/cl.hls.js +69 -69
  42. package/cl.hlssmpte.js +5 -5
  43. package/cl.htmlcue.js +26 -26
  44. package/cl.ima.js +17 -17
  45. package/cl.mse.js +221 -220
  46. package/cl.muxdata.js +13 -12
  47. package/cl.onboard.js +4 -4
  48. package/cl.persistent.js +10 -10
  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 +14 -14
  60. package/package.json +4 -4
  61. package/typings.d.ts +53 -17
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 Jv="Thumbnail URL is mandatory",Kv="Wrong gridSize format",Lv="clpp.thumbnails",Nv=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.ue&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Mv(a,0,e,!!f))},Promise.resolve())},Mv=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Ov(a,d).then(()=>a.a[b].load()).then(()=>Mv(a,e,c,d))},Ov=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.hn)c();else a.player.one(_.Lc,()=>{c()})})},
2
- Pv=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Vc.resolve()})},Sv=function(a,b){return Qv(a,b).then(c=>new Rv(c,b.time,b.duration))},Qv=function(a,b){return b.load().then(()=>{const c=_.J(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.di(c)})},Tv=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},Uv=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
- Vv=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Pc:c,Be:d,bf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Wv=function(a){return a.some(b=>0<b.thumbStreams.length)},dw=function(a){return a?a===Xv||a===Yv?new Zv:a===$v?new aw:a===bw?new cw:null:null},ew=function(a){if(!a)return null;a=new _.bl(a);return a.path.match(/.*\.vtt$/i)?$v:a.path.match(/.*\.bif$/i)?bw:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
- Xv:null};var fw=class{constructor(){this.log=new _.R(Lv);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.df,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Nv(this,b.preload)})}};var Rv=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.Qg=k;this.qg=l;this.rg=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(_.zd);a.style.width=c+_.af;a.style.height=d+_.af;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+_.af;a.style.backgroundPositionY="-"+b*d+_.af;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.Qg);this.x||(this.x=this.width*this.qg);this.y||(this.y=this.height*this.rg)};if(this.la.src&&this.la.complete)c(),a(this);else{var d=null,e=()=>{c();this.la.removeEventListener("load",e);this.la.removeEventListener(_.Nd,d);a(this)};
7
- d=f=>{this.la.removeEventListener("load",e);this.la.removeEventListener(_.Nd,d);b(new _.H(1,9,2014,"Failed to load thumbnail.",f))};this.la.addEventListener("load",e);this.la.addEventListener(_.Nd,d);this.la.src=this.src}}));return this.na}};_.z("clpp.thumbnails.Thumbnail",Rv);Rv.prototype.load=Rv.prototype.load;Rv.prototype.element=Rv.prototype.element;Rv.prototype.raw=Rv.prototype.raw;var Zv=class extends fw{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,Jv);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,Kv);}catch(c){throw this.log.error("Error during parsing gridSize",
8
- c),new _.H(1,9,7100,Kv);}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.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 Rv(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 gw=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Vc=new _.vm}load(){return this.Vc}},cw=class{constructor(){this.h=new _.R(Lv);this.a=new ArrayBuffer(0);this.f=[];this.g=new _.vm}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Jv);const c=b.url;b=_.ti(c);b.type=_.si;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,hw);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 gw(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");Pv(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 _.x(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 Sv(b,c);yield c.load();return c})}},hw=[137,66,73,70,13,10,26,10];var aw=class extends fw{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Jv);const c=b.url,d=_.ti(c);d.type=_.si;this.f=a.getNetworkEngine().fetch(d).P.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.Qh(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=Tv(g[0]);g=Tv(g[1])-l;this.a.push(new Rv(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 _.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 iw=class extends fw{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=Uv(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=Vv(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.Pc,l=Math.floor(k/h.Pc),f+=k*h.durationPerTile);g=new Rv(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
- h.Pc,h.Be,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&&!_.B(d=a.getSegmentReference(c++));){const e=Vv(d,a),f=d.La()[0],g=new Image;let h=d.startTime;for(let k=
17
- 0;k<e.Be;++k)for(let l=0;l<e.Pc;++l)this.a.push(new Rv(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Pc,e.Be,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var jw=class{constructor(){this.h=new _.R(Lv);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=ew(b.url||null));(this.a=dw(c))?(this.h.info("Loading thumbs configuration",b),this.m.one(_.ge,()=>{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(Wv(c)){this.a=new iw;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",jw);jw.prototype.get=jw.prototype.get;jw.Id="thumbnails";_.ro(new class{create(){return new jw}});
19
- var Xv="SINGLE",Yv="GRID",$v="WEBVTT",bw="BIF";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Kv="Thumbnail URL is mandatory",Lv="Wrong gridSize format",Mv="clpp.thumbnails",Ov=function(a,b){b.reduce((c,d)=>{let e=d,f=!1;typeof d===_.ve&&(e=d.step,f=d.preloadWhileBuffering);return c.then(()=>Nv(a,0,e,!!f))},Promise.resolve())},Nv=function(a,b,c,d){if(a.w||b>=a.a.length)return Promise.resolve();const e=b+c;return Pv(a,d).then(()=>a.a[b].load()).then(()=>Nv(a,e,c,d))},Pv=function(a,b){return new Promise(c=>{if(b||a.player.getState()!==_.jn)c();else a.player.one(_.Lc,()=>{c()})})},
2
+ Qv=function(a){const b=a.a.byteLength;a.f.forEach(c=>{c.offset+c.length<b&&c.Wc.resolve()})},Tv=function(a,b){return Rv(a,b).then(c=>new Sv(c,b.time,b.duration))},Rv=function(a,b){return b.load().then(()=>{const c=_.J(a.a,b.offset,b.length);return"data:image/jpeg;base64,"+_.ei(c)})},Uv=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},Vv=function(a,b){let c=null;for(const d of a)d.startTime<=b&&(c=d);return c},
3
+ Wv=function(a,b){const c=a.horizontalTiles||b.horizontalTiles||1,d=a.verticalTiles||b.verticalTiles||1,e=c*d;return{Qc:c,Ce:d,cf:e,durationPerTile:a.durationPerTile||b.durationPerTile||(a.endTime-a.startTime)/e}},Xv=function(a){return a.some(b=>0<b.thumbStreams.length)},ew=function(a){return a?a===Yv||a===Zv?new $v:a===aw?new bw:a===cw?new dw:null:null},fw=function(a){if(!a)return null;a=new _.dl(a);return a.path.match(/.*\.vtt$/i)?aw:a.path.match(/.*\.bif$/i)?cw:a.path.match(/.*\.(png|jpg|jpeg)$/i)?
4
+ Yv:null};var gw=class{constructor(){this.log=new _.R(Mv);this.player=null;this.a=[];this.w=!1}init(a,b){this.player=a;a.one(_.ef,()=>{this.w=!0});a.isLive()||this.l().then(()=>{b&&b.preload&&Ov(this,b.preload)})}};var Sv=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.ma=n;this.Zf=h;this.Sg=k;this.sg=l;this.tg=m;this.oa=null}raw(){return this.ma.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(_.zd);a.style.width=c+_.bf;a.style.height=d+_.bf;a.style.backgroundColor="#000";a.style.backgroundRepeat="no-repeat";a.style.backgroundImage=`url("${this.src}")`;a.style.backgroundSize=`${Math.ceil(c/this.width*(this.ma.naturalWidth||this.ma.width))}px ${Math.ceil(d/this.height*(this.ma.naturalHeight||this.ma.height))}px`;b=this.y/this.height;a.style.backgroundPositionX="-"+this.x/
6
+ this.width*c+_.bf;a.style.backgroundPositionY="-"+b*d+_.bf;return a}load(){this.oa||(this.oa=new Promise((a,b)=>{const c=()=>{this.width||(this.width=(this.ma.naturalWidth||this.ma.width)/this.Zf);this.height||(this.height=(this.ma.naturalHeight||this.ma.height)/this.Sg);this.x||(this.x=this.width*this.sg);this.y||(this.y=this.height*this.tg)};if(this.ma.src&&this.ma.complete)c(),a(this);else{var d=null,e=()=>{c();this.ma.removeEventListener("load",e);this.ma.removeEventListener(_.Nd,d);a(this)};
7
+ d=f=>{this.ma.removeEventListener("load",e);this.ma.removeEventListener(_.Nd,d);b(new _.H(1,9,2014,"Failed to load thumbnail.",f))};this.ma.addEventListener("load",e);this.ma.addEventListener(_.Nd,d);this.ma.src=this.src}}));return this.oa}};_.z("clpp.thumbnails.Thumbnail",Sv);Sv.prototype.load=Sv.prototype.load;Sv.prototype.element=Sv.prototype.element;Sv.prototype.raw=Sv.prototype.raw;var $v=class extends gw{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,Kv);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,Lv);}catch(c){throw this.log.error("Error during parsing gridSize",
8
+ c),new _.H(1,9,7100,Lv);}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 Sv(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 hw=class{constructor(a,b){this.time=a;this.duration=0;this.offset=b;this.length=0;this.Wc=new _.wm}load(){return this.Wc}},dw=class{constructor(){this.g=new _.R(Mv);this.a=new ArrayBuffer(0);this.f=[];this.h=new _.wm}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Kv);const c=b.url;b=_.ui(c);b.type=_.ti;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.g.info(`Appended ${e.byteLength} bytes.`+`Total data now ${f} bytes.`);f=this.a;d=_.J(f);h=String.fromCharCode.apply(null,iw);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 hw(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");Qv(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 Tv(b,c);yield c.load();return c})}},iw=[137,66,73,70,13,10,26,10];var bw=class extends gw{constructor(){super();this.f=null}init(a,b){if(!b||!b.url)throw new _.H(1,9,7100,Kv);const c=b.url,d=_.ui(c);d.type=_.ti;this.f=a.getNetworkEngine().fetch(d).P.then(e=>{e=e.data;if(!e)throw Error("No data in the response");e=_.Rh(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=Uv(g[0]);g=Uv(g[1])-l;this.a.push(new Sv(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 _.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 jw=class extends gw{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=Vv(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=Wv(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.cf+k]);else if((e=f.La())&&0<e.length){let l=g=0;f=f.startTime;1<h.cf&&(g=k%h.Qc,l=Math.floor(k/h.Qc),f+=k*h.durationPerTile);g=new Sv(e[0],f,h.durationPerTile,void 0,void 0,void 0,void 0,
16
+ h.Qc,h.Ce,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&&!_.B(d=a.getSegmentReference(c++));){const e=Wv(d,a),f=d.La()[0],g=new Image;let h=d.startTime;for(let k=
17
+ 0;k<e.Ce;++k)for(let l=0;l<e.Qc;++l)this.a.push(new Sv(f,h,e.durationPerTile,void 0,void 0,void 0,void 0,e.Qc,e.Ce,l,k,g)),h+=e.durationPerTile}}return Promise.resolve()}};var kw=class{constructor(){this.g=new _.R(Mv);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=fw(b.url||null));(this.a=ew(c))?(this.g.info("Loading thumbs configuration",b),this.m.one(_.he,()=>{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(Xv(c)){this.a=new jw;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",kw);kw.prototype.get=kw.prototype.get;kw.Id="thumbnails";_.so(new class{create(){return new kw}});
19
+ var Yv="SINGLE",Zv="GRID",aw="WEBVTT",cw="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 QI="An unknown error occurred while trying to get volume",RI="Cannot get loading rendition due to platform limitations",SI="SecurityError",TI="The require privilege is: http://tizen.org/privilege/tv.audio",UI="|STARTBITRATE\x3d",VI=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},YI=function(a){return _.x(function*(){if(a.a!==_.rd&&a.a!==_.pd)throw new _.H(_.G,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.Uc)throw new _.H(_.G,6,6012,`No license server given for ${a.a}`);try{a.a===_.rd?yield WI(a):yield XI(a,b),a.o={keySystem:a.a,licenseServerUri:b.Uc,distinctiveIdentifierRequired:!1,persistentStateRequired:b.me,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.h.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.G,6,6005,{message:JSON.stringify(c)});}})},$I=function(a,b){_.x(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=_.ti([b.serverurl&&""!==b.serverurl?b.serverurl:c.Uc],_.qi());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.Ab.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(ZI,"widevine_license_data",k)}catch(l){a.h.error("License response rejected by CDM");const m=new _.H(_.G,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.h.error("License request failed.",JSON.stringify(h)),g=new _.H(_.G,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)}})},WI=function(a){return _.x(function*(){try{webapis.avplay.setDrm(ZI,"Initialize",""),webapis.avplay.setDrm(ZI,
5
- "widevine_app_session",a.l.id),webapis.avplay.setDrm(ZI,"widevine_data_type",a.l.type)}catch(b){throw b;}})},XI=function(a,b){return _.x(function*(){var c={};c[aJ]=!b.me;c[bJ]=b.Uc;""!==b.customData&&(c[cJ]=b.customData);c=JSON.stringify(c);a.h.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(dJ,"SetProperties",c)}catch(d){throw d;}})},fJ=function(a,b){if(a.f!==b)if(a.f===_.mn&&b!==_.nn)a.h.debug(_.qx+`${eJ(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.hn?(a.o=(new Date).getTime(),
6
- a.m.trigger(new _.F(_.Mc,{detail:{bufferedTimeMS:-1,reason:a.g}}))):a.j===_.hn&&a.m.trigger(new _.F(_.Lc,{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 _.F(_.rf,{detail:b}));a.h.debug("State changed:",eJ(a.j),"-\x3e",eJ(a.f))}},eJ=function(a){return Object.keys(_.ln)[a]},iJ=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case gJ:c=_.qn;break;case hJ:c=_.pn;break;default:a.m.isEnded()?c=_.en:a.h.debug("Inconsistent AVPlay playback state:",
7
- b)}fJ(a,c)}},jJ=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.pq(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},kJ=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},lJ=function(a){const b=document.createElement(_.w),c=new _.sC,d=new _.hC(()=>null),e=a.m.getTextDisplayer();return new _.tC(b,c,e,d,a.m.getConfiguration())},mJ=function(a){const b=
8
- {wb:()=>a.m.getPosition(),Y:a.g,Ab:a.m.getNetworkEngine(),he:a.F.bind(a),ge:a.C.bind(a),onError:a.U.bind(a),gf:()=>{},onEvent:()=>{},kf:a.G.bind(a),yd:()=>{},Rd:()=>new _.xC,Hd:()=>!1,Lc:null};return new _.iD(a.a,b)},nJ=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},oJ=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 _.Ji(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.Ox;const f=new _.Ti(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},pJ=function(a){if(a.g&&!a.g.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.fB(a.f,_.u);let c=null;if(b){a=oJ(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},qJ=function(a,b){a.h.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.a&&a.f)){a.setTextVisibility(!0);const c=nJ(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):(_.oB(a.f,b,!0,0),a.m.trigger(new _.F(_.ck))),a.o=b.language):a.h.error(_.px,d.id)}},rJ=function(a){const b=a.ia();b&&a.m.trigger(new _.F(_.Jc,{detail:{width:b.width,height:b.height,
11
- bandwidth:b.bandwidth,rendition:b}}))},sJ=function(a,b){a.m.trigger(new _.F(_.Sf,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},tJ=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},uJ=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++)_.Cg(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||
12
- null},vJ=function(a){const b=a.m.getConfiguration();var c=_.dh(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.fy(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.sa(c)}else a.h.debug("Preferred language(s) not available")}else a.h.debug("Could not set preferred audio language")},
13
- BJ=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===wJ),f=b.filter(l=>l.type===xJ);const g=[];for(var h=0;h<f.length;h++){const l=tJ(a,f[h].extra_info);if(l){var k=_.Dh(l.language||_.Ef);k=_.Fi(k);k=c(g,k);k||(k=new _.Ji(String(a.o++),_.L),g.push(k));k.renditions.push(yJ(f[h].index,l,k))}else a.h.warn("Skipping audio stream with no extra info")}c=new _.Ji(String(a.o++),_.M);for(f=0;f<
14
- e.length;f++)(h=tJ(a,e[f].extra_info))?c.renditions.push(zJ(e[f].index,h,c)):a.h.warn("Skipping video stream with no extra info");e=[];e=a.g?oJ(a.g):AJ(a,b);d[_.M]=[c];d[_.L]=g;d[_.K]=e;return d},EJ=function(a,b){if(b===_.K&&a.g)return pJ(a.g);var c=CJ(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.M&&(d=tJ(a,c.extra_info),d=uJ(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=DJ(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=DJ(a,c,_.K),a.l=d):d=a.l);return d},
15
- HJ=function(a,b){if(b){const c=b.track.type.toUpperCase();FJ(a.a,c,Number(b.id)).then(()=>{c===xJ&&(a.j=b,a.m.trigger(new _.F(_.bk)));c===GJ&&(a.l=b,a.m.trigger(new _.F(_.ck)))}).catch(()=>{a.h.error("Could not select "+c+" track.")})}else a.h.debug("Must provide valid rendition")},yJ=function(a,b,c){const d=_.Dh(b.language||_.Ef);c.language=_.Fi(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Gc;a=new _.Ti(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
- b.bit_rate||null;return a},zJ=function(a,b,c){c.mimeType=_.Pf;a=new _.Ti(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},IJ=function(a,b,c){b=_.Dh(b.track_lang||_.Ef);c.mimeType="text/ttml";c.language=_.Fi(b);c.originalLanguage=b;c.kind=_.Ox;return new _.Ti(String(a),c)},AJ=function(a,b){b=b.filter(d=>d.type===GJ);const c=[];for(let d=0;d<b.length;d++){const e=tJ(a,b[d].extra_info);if(!e){a.h.warn("Skipping text stream with no extra info");
17
- continue}const f=new _.Ji(String(a.o++),_.K);f.renditions.push(IJ(b[d].index,e,f));c.push(f)}return c},DJ=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},JJ=function(a){return a.f&&a.a?a.a.ah:webapis.avplay.getTotalTrackInfo()},LJ=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=KJ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Ie;a.f=!1;a.a=null;return e===hJ?a.pause():a.play()})}catch(d){return Promise.reject(d)}},MJ=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)}},FJ=function(a,b,c){b=b.toUpperCase();
19
- b===GJ&&MJ(a,!0);const d=a.j[b];d&&(d.Cd.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,Fe:0,Cd:new _.lj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Fe?(!a.w&&++k.Fe,k.Cd.ca(a.w?.5:.25)):(a.h.debug("Could not set track after multiple attempts.Giving up..."),
20
- k&&k.Cd.stop(),a.j[h]=null,f())}};g(b,c)})},CJ=function(a){return a.f&&a.a?a.a.Zf:webapis.avplay.getCurrentStreamInfo()},NJ=function(a){return _.x(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;})})},PJ=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 _.F(OJ,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.U.bind(a)})}catch(b){a.h.error(b)}},QJ=function(a){const b=!!a.m.getTrackManager().Ka();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.h.debug("Could not set AVPlay subtitle config",c)}},RJ=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.h.debug({estimatedBandwidth:c,rh:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
- UI+d)}catch(c){a.h.debug(c)}},SJ=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+UI+b)}catch(c){throw a.h.debug("Could not set fixed bandwidth",c),c;}},TJ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case SI:a.h.warn("The application doesn't have the privilege to get the mute state.",TI);break;default:a.h.warn(QI,c)}}return!!b},KJ=function(a){return{position:a.getPosition(),state:a.m.getState(),Ie:a.getState(),playbackRate:a.getPlaybackRate(),
23
- isLive:a.isLive(),duration:a.getDuration(),isMuted:TJ(a),volume:a.getVolume(),ah:JJ(a),Zf:CJ(a)}},UJ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");VI(c,"load",d=>a(d));VI(c,_.Nd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},VJ=function(a){return _.x(function*(){yield UJ();const b=new Promise(c=>{(new _.lj(c)).ca(5)});if(!(yield Promise.race([NJ(a).then(()=>!0),b.then(()=>!1)])))return a.h.debug("Took to long for the SDK to be ready"),
24
- Promise.reject("SDK Timeout")})},WJ=function(a){return _.x(function*(){a.h.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.h.debug("AVPlay is ready!");QJ(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)}})})},XJ=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case SI:a.h.warn("The application does not have the privilege to set mute.",TI);break;default:a.h.warn(QI,
25
- c)}}},bK=function(a,b,c){return _.x(function*(){a.l=_.tn(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 _.F(YJ)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.sc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(SJ(a,e.nextBandwidth),a.o=!1):(a.o||RJ(a,e),
26
- a.o=!0);PJ(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Ab:a.m.getNetworkEngine()};a.g=new ZJ(b.drm,h);yield a.g.init()}else a.h.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.F($J));yield WJ(a);a.f||a.trigger(new _.F(aK));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&&XJ(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;}})},cK=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())},ZJ=class{constructor(a,
28
- b){this.g=a;this.o=null;this.a=_.te;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 _.x(function*(){var b=_.Fk[a.g.env]||null;if(!b)throw a.h.debug(_.sa,_.qb+a.g.env+_.aa),new _.H(_.G,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=_.Hk(b,a.g.customData);const d=b[_.pd];d&&a.f.set(_.pd,
29
- {Uc:d.licenseUrl||"",customData:c,me:!1});(b=b[_.rd])&&a.f.set(_.rd,{Uc:b.licenseUrl||"",customData:c,me:!1});if(0===a.f.size)throw new _.H(_.G,6,6E3);if((c=a.g.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.pd))a.a=_.pd;else if(a.f.get(_.rd))a.a=_.rd;else throw new _.H(_.G,6,6001,"Configuration for the target system is missing.");yield YI(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.te;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},aJ="DeleteLicenseAfterUse",
30
- bJ="LicenseServer",cJ="CustomData";var iK=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.nn;this.j=_.ps;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(YJ,this.C,this);this.a.on(dK,this.B,this);this.a.on(eK,this.A,this);this.a.on($J,this.H,this);this.a.on(aK,this.G,this);this.a.on(fK,this.F,this)}release(){fJ(this,_.nn);this.l=!1;this.o=-1;this.g=2}destroy(){this.release();this.a.off(YJ,this.C);this.a.off(dK,this.B);this.a.off(eK,this.A);this.a.off($J,
31
- this.H);this.a.off(aK,this.G);this.a.off(fK,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;fJ(this,_.hn)}B(a){this.h.debug("Buffering progress: "+a.percent+" %. Player state: ",eJ(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()===gK;if(!a&&b){fJ(this,_.pn);return}}if(a=this.f!==_.on)a=this.a.getState(),a=a===
32
- gJ||a===hJ;a&&iJ(this)}H(){this.h.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===hK?fJ(this,_.on):this.h.error("AVPlay prepares while state is not IDLE")}G(){this.h.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){fJ(this,_.en)}getState(){return this.f}};var jK=class{constructor(){this.o=this.A=this.f=this.g=this.B=this.m=this.j=this.a=null;this.w=!0;this.l=null;this.h=new _.R("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield jJ(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&&kJ(b.a)){b.g=lJ(b);try{yield b.g.I;b.f=mJ(b);const d=b.m.getConfiguration();b.f.g=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole}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()")})}F(a){this.h.debug(_.Hx,a);this.w=!0;let b=_.Pz(a.textStreams,
34
- this.o||"",this.A||"")[0]||null;this.l&&(a.textStreams.includes(this.l)&&(b=this.l),this.l=null);return{variant:null,text:b}}C(){this.h.debug("canSwitch_");this.w=!1;this.l&&(_.oB(this.f,this.l,!0,0),this.l=null)}U(){this.h.debug("onError_")}G(){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.h.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.h.debug("Set text visibility",a);this.g&&this.g.getTextDisplayer().setTextVisibility(a)}release(){const a=
35
- this;return _.x(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 _.x(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 kK:0<Object.keys(this.f).length||(this.h.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+tJ(this,b[0].extra_info).Bit_rate,b=uJ(this,{bandwidth:b}))&&(this.w=b,sJ(this,b));break;case lK:rJ(this);break;default:this.h.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.qn&&this.m.off(_.rf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.rf,b=>{this.B||(b=b.detail,b.currentState===_.qn&&(this.h.debug("Current state",b.currentState),this.B=!0,vJ(this)))});this.a.on(mK,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(_.rf,this.A);this.m.on(_.rf,this.A,this);try{const a=JJ(this.a);this.f=BJ(this,a);
37
- const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);rJ(this)}catch(a){this.h.debug("Could not load track manager")}}}destroy(){this.a.off(mK,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.M]||[]}getAudioTracks(){return this.f[_.L]||[]}ka(){return this.f[_.K]||[]}ia(){return EJ(this,_.M)}Ja(){return EJ(this,_.L)}Ka(){return EJ(this,_.K)}Ua(){return this.w}gb(){this.h.info(RI);return null}hb(){this.h.info(RI);return null}Ma(){const a=this.ia();return a?a.track:null}oa(){const a=
38
- this.Ja();return a?a.track:null}pa(){const a=this.Ka();return a?a.track:null}Za(a){null===a?(a=this.ia(),LJ(this.a,a.bandwidth,null).then(()=>{rJ(this)})):0<a.renditions.length&&this.Ya(a.renditions[0])}sa(a){a?HJ(this,a.renditions[0]):this.h.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Fa(a){a?(a=a.renditions[0],this.g?qJ(this.g,a.track):HJ(this,a)):(this.h.debug("Disabling text tracks"),this.l=null,MJ(this.a,!1),this.m.trigger(new _.F(_.ck)))}Ya(a){const b=
39
- this.ia();this.a.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,sJ(this,a),LJ(this.a,b.bandwidth,a.bandwidth).then(()=>{rJ(this)}).catch(c=>{const d=new _.H(_.G,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...")}mb(a){HJ(this,a)}nb(a){this.g?qJ(this.g,a.track):HJ(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.nb;W.prototype.setAudioRendition=W.prototype.mb;W.prototype.setVideoRendition=W.prototype.Ya;W.prototype.setTextTrack=W.prototype.Fa;W.prototype.setAudioTrack=W.prototype.sa;W.prototype.setVideoTrack=W.prototype.Za;W.prototype.getTextTrack=W.prototype.pa;W.prototype.getAudioTrack=W.prototype.oa;W.prototype.getVideoTrack=W.prototype.Ma;W.prototype.getLoadingTextRendition=W.prototype.hb;
41
- W.prototype.getLoadingAudioRendition=W.prototype.gb;W.prototype.getLoadingVideoRendition=W.prototype.Ua;W.prototype.getTextRendition=W.prototype.Ka;W.prototype.getAudioRendition=W.prototype.Ja;W.prototype.getVideoRendition=W.prototype.ia;W.prototype.getTextTracks=W.prototype.ka;W.prototype.getAudioTracks=W.prototype.getAudioTracks;W.prototype.getVideoTracks=W.prototype.getVideoTracks;var qK=class extends _.Vr{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 _.F(YJ))}H(a){this.w=!0;this.trigger(new _.F(dK,{percent:a}))}G(){this.w=!1;this.trigger(new _.F(eK))}M(){this.trigger(new _.F(fK))}K(a,b){this.trigger(new _.F(mK,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.F(nK,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.F(oK,{drmType:a,drmData:b}));this.g&&(a=this.g,a.j&&(a.a===_.rd&&"Challenge"===b.name?$I(a,b):"DrmError"===b.name&&(a.h.debug("DrmError event",b),b=new _.H(_.G,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}U(a){this.trigger(new _.F(pK,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(OJ,f,this);e=setTimeout(()=>{this.off(OJ,f);d("Timeout")},3E4)});if(a===hK)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{QJ(this);c(webapis.avplay.play())},e=>{this.trigger(new _.F(pK));d(e)})})).then(()=>b());if(a===hJ||a===gK)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===gJ?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===hJ?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===gK||b===gJ||b===hJ){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 _.x(function*(){c.h.debug("configure()",b||"");try{yield VJ(c),yield bK(c,a,b)}catch(d){throw new _.H(_.G,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Ie;try{return webapis.avplay.getState()}catch(a){this.U(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.F(_.Kf));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.F(_.Jf));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.U(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.U(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.Cd.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 SI:this.h.debug("The application does not have the privilege to get the volume.",TI);break;default:this.h.debug(QI,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 SI:this.h.warn("The application does not have the privilege to set the volume.",TI);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.U(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()]}},hK="IDLE",gK="READY",gJ="PLAYING",hJ="PAUSED",wJ=_.Mb,xJ="AUDIO",GJ="TEXT",lK="PLAYER_MSG_RESOLUTION_CHANGED",kK="PLAYER_MSG_BITRATE_CHANGE",dJ="PLAYREADY",ZI="WIDEVINE_CDM";var uK=class extends _.Vr{constructor(){super();this.a=new qK(this);this.f=new iK(this);this.configuration=this.B=_.mk();this.w=null;this.h=new _.R("clpp.tizen.Player");this.j=null;this.l=new W;this.C=new _.oo;this.o=this.g=null;this.A=!1}H(){this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.F(_.Md));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 _.F(_.Bf,
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=_.ci(d))&&this.o.append([new _.pr(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)}U(a){this.h.debug(`Error: TYPE: ${a.eventType}`);fJ(this.f,_.mn);a=new _.H(_.G,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.F(_.Nd,{detail:a}))}init(a,
50
- b){this.configuration=this.B=b;this.w=a;this.a.on(fK,this.H,this);this.a.on(OJ,this.F,this);this.a.on(nK,this.I,this);this.a.on(oK,this.G,this);this.a.on(pK,this.U,this);this.a.on(eK,this.J,this);this.f.initialize();this.l.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();a=rK;rK+=1;a="__clpp_tizen_player_"+a;this.j=_.Kn(_.ue,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.gg,_.Qd,"position",
51
- _.Xd,"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}_.Mn(a,d);cK(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}destroy(){const a=this;return _.x(function*(){yield a.release();a.a.off(fK,a.H);a.a.off(OJ,a.F);a.a.off(nK,a.I);a.a.off(oK,a.G);a.a.off(pK,a.U);a.a.off(eK,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 sK}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()===_.en?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 _.Ur}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{this.l.release()})}release(){const a=this;return _.x(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 _.x(function*(){_.pk(a)&&
54
- (b.configuration=_.ok(b.B,a));var c=_.Vm(b.configuration,[_.Sd,"native"]);b.o=c.create(b);c=_.tn(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.g=new jK;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 _.F(_.Ie));cK(this);return this.a.play().then(()=>{iJ(this.f)})}pause(){return this.a.pause().then(()=>{iJ(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=
55
- new _.F(_.Nd,{detail:a});a.severity===_.G&&(fJ(this.f,_.mn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.en}isPaused(){return this.a.getState()===hJ}isMuted(){return TJ(this.a)}setMuted(a){XJ(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 tK).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};uK.prototype.getTextDisplayer=uK.prototype.getTextDisplayer;uK.prototype.setNetworkEngine=uK.prototype.setNetworkEngine;uK.prototype.getNetworkEngine=uK.prototype.getNetworkEngine;
57
- var sK="clpp.tizen",rK=0,tK=class{a(){return sK}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.sc||a===_.gk||a===_.Bc)&&b){if(_.pj(2))return 2;if(_.pj(3)||_.pj(4)||_.pj(5)||_.pj(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}create(){return new uK}};_.z("clpp.tizen.TizenComponent",class extends _.Js{f(){_.Rg(new tK)}a(){var a=sK;a&&_.Pg[a]&&(delete _.Pg[a],_.Qg.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var YJ="onbufferingstart",dK="onbufferingprogress",eK="onbufferingcomplete",fK="onstreamcompleted",OJ="oncurrentplaytime",mK="onevent",nK="onsubtitlechange",oK="ondrmevent",pK="onerror",$J="preparingstart",aK="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 RI="An unknown error occurred while trying to get volume",SI="Cannot get loading rendition due to platform limitations",TI="SecurityError",UI="The require privilege is: http://tizen.org/privilege/tv.audio",VI="|STARTBITRATE\x3d",WI=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},ZI=function(a){return _.x(function*(){if(a.a!==_.rd&&a.a!==_.pd)throw new _.H(_.G,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(_.G,6,6012,`No license server given for ${a.a}`);try{a.a===_.rd?yield XI(a):yield YI(a,b),a.o={keySystem:a.a,licenseServerUri:b.Vc,distinctiveIdentifierRequired:!1,persistentStateRequired:b.me,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:[],keyIds:[],periodId:null}}catch(c){throw a.g.error(`Error while configuring CDM for ${a.a}`,c),new _.H(_.G,6,6005,{message:JSON.stringify(c)});}})},aJ=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=_.ui([b.serverurl&&""!==b.serverurl?b.serverurl:c.Vc],_.ri());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.Ab.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.g.debug("Widevine license params",
4
+ k);try{webapis.avplay.setDrm($I,"widevine_license_data",k)}catch(l){a.g.error("License response rejected by CDM");const m=new _.H(_.G,6,6008,{browserError:JSON.stringify(l)});a.D.onError(m)}}}catch(h){a.g.error("License request failed.",JSON.stringify(h)),g=new _.H(_.G,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)}})},XI=function(a){return _.x(function*(){try{webapis.avplay.setDrm($I,"Initialize",""),webapis.avplay.setDrm($I,
5
+ "widevine_app_session",a.l.id),webapis.avplay.setDrm($I,"widevine_data_type",a.l.type)}catch(b){throw b;}})},YI=function(a,b){return _.x(function*(){var c={};c[bJ]=!b.me;c[cJ]=b.Vc;""!==b.customData&&(c[dJ]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(eJ,"SetProperties",c)}catch(d){throw d;}})},gJ=function(a,b){if(a.f!==b)if(a.f===_.nn&&b!==_.on)a.g.debug(_.qx+`${fJ(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.jn?(a.o=(new Date).getTime(),
6
+ a.m.trigger(new _.F(_.Mc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.jn&&a.m.trigger(new _.F(_.Lc,{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 _.F(_.sf,{detail:b}));a.g.debug("State changed:",fJ(a.j),"-\x3e",fJ(a.f))}},fJ=function(a){return Object.keys(_.mn)[a]},jJ=function(a){if(a.l){var b=a.a.getState(),c=a.f;switch(b){case hJ:c=_.rn;break;case iJ:c=_.qn;break;default:a.m.isEnded()?c=_.fn:a.g.debug("Inconsistent AVPlay playback state:",
7
+ b)}gJ(a,c)}},kJ=function(a){return _.x(function*(){const b=a.m.getConfiguration();let c;(c=yield _.qq(a.B.url,a.m.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},lJ=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},mJ=function(a){const b=document.createElement(_.w),c=new _.sC,d=new _.hC(()=>null),e=a.m.getTextDisplayer();return new _.tC(b,c,e,d,a.m.getConfiguration())},nJ=function(a){const b=
8
+ {wb:()=>a.m.getPosition(),Y:a.h,Ab:a.m.getNetworkEngine(),he:a.G.bind(a),ge:a.F.bind(a),onError:a.U.bind(a),hf:()=>{},onEvent:()=>{},lf:a.H.bind(a),zd:()=>{},Sd:()=>new _.xC,Jd:()=>!1,Mc:null};return new _.iD(a.a,b)},oJ=function(a){const b=a.m.getPosition();let c=null;for(const d of a.a.periods)d.startTime<=b&&(c=d);return c},pJ=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,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 _.Ki(String(c++),_.K);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.Ox;const f=new _.Ui(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},qJ=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.f){const b=_.fB(a.f,_.u);let c=null;if(b){a=pJ(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},rJ=function(a,b){a.g.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.C=b.kind===_.Od,a.a&&a.f)){a.setTextVisibility(!0);const c=oJ(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):(_.oB(a.f,b,!0,0),a.m.trigger(new _.F(_.dk))),a.o=b.language):a.g.error(_.px,d.id)}},sJ=function(a){const b=a.ka();b&&a.m.trigger(new _.F(_.Jc,{detail:{width:b.width,
11
+ height:b.height,bandwidth:b.bandwidth,rendition:b}}))},tJ=function(a,b){a.m.trigger(new _.F(_.Tf,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.a.o}}))},uJ=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},vJ=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++)_.Dg(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);
12
+ return c[0]||null},wJ=function(a){const b=a.m.getConfiguration();var c=_.eh(b.preferredAudioLanguage||[]);const d=a.f[_.L]||[];if(d.length){var e=null;c.some(g=>{e=_.fy(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.ta(c)}else a.g.debug("Preferred language(s) not available")}else a.g.debug("Could not set preferred audio language")},
13
+ CJ=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===xJ),f=b.filter(l=>l.type===yJ);const g=[];for(var h=0;h<f.length;h++){const l=uJ(a,f[h].extra_info);if(l){var k=_.Eh(l.language||_.Ff);k=_.Gi(k);k=c(g,k);k||(k=new _.Ki(String(a.o++),_.L),g.push(k));k.renditions.push(zJ(f[h].index,l,k))}else a.g.warn("Skipping audio stream with no extra info")}c=new _.Ki(String(a.o++),_.M);for(f=0;f<
14
+ e.length;f++)(h=uJ(a,e[f].extra_info))?c.renditions.push(AJ(e[f].index,h,c)):a.g.warn("Skipping video stream with no extra info");e=[];e=a.h?pJ(a.h):BJ(a,b);d[_.M]=[c];d[_.L]=g;d[_.K]=e;return d},FJ=function(a,b){if(b===_.K&&a.h)return qJ(a.h);var c=DJ(a.a)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.M&&(d=uJ(a,c.extra_info),d=vJ(a,{width:d.Width,height:d.Height}));b===_.L&&(c?(d=EJ(a,c,_.L),a.j=d):d=a.j);b===_.K&&(c?(d=EJ(a,c,_.K),a.l=d):d=a.l);return d},
15
+ IJ=function(a,b){if(b){const c=b.track.type.toUpperCase();GJ(a.a,c,Number(b.id)).then(()=>{c===yJ&&(a.j=b,a.m.trigger(new _.F(_.ck)));c===HJ&&(a.l=b,a.m.trigger(new _.F(_.dk)))}).catch(()=>{a.g.error("Could not select "+c+" track.")})}else a.g.debug("Must provide valid rendition")},zJ=function(a,b,c){const d=_.Eh(b.language||_.Ff);c.language=_.Gi(d);c.originalLanguage=d;c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.Gc;a=new _.Ui(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=
16
+ b.bit_rate||null;return a},AJ=function(a,b,c){c.mimeType=_.Rf;a=new _.Ui(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},JJ=function(a,b,c){b=_.Eh(b.track_lang||_.Ff);c.mimeType="text/ttml";c.language=_.Gi(b);c.originalLanguage=b;c.kind=_.Ox;return new _.Ui(String(a),c)},BJ=function(a,b){b=b.filter(d=>d.type===HJ);const c=[];for(let d=0;d<b.length;d++){const e=uJ(a,b[d].extra_info);if(!e){a.g.warn("Skipping text stream with no extra info");
17
+ continue}const f=new _.Ki(String(a.o++),_.K);f.renditions.push(JJ(b[d].index,e,f));c.push(f)}return c},EJ=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},KJ=function(a){return a.f&&a.a?a.a.dh:webapis.avplay.getTotalTrackInfo()},MJ=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=LJ(a);a.f=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.m.getConfiguration(),d).then(()=>{const e=a.a.Je;a.f=!1;a.a=null;return e===iJ?a.pause():a.play()})}catch(d){return Promise.reject(d)}},NJ=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)}},GJ=function(a,b,c){b=b.toUpperCase();
19
+ b===HJ&&NJ(a,!0);const d=a.j[b];d&&(d.Dd.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,Ge:0,Dd:new _.mj(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.Ge?(!a.w&&++k.Ge,k.Dd.ca(a.w?.5:.25)):(a.g.debug("Could not set track after multiple attempts.Giving up..."),
20
+ k&&k.Dd.stop(),a.j[h]=null,f())}};g(b,c)})},DJ=function(a){return a.f&&a.a?a.a.ag:webapis.avplay.getCurrentStreamInfo()},OJ=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;})})},QJ=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 _.F(PJ,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.U.bind(a)})}catch(b){a.g.error(b)}},RJ=function(a){const b=!!a.m.getTrackManager().Da();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.g.debug("Could not set AVPlay subtitle config",c)}},SJ=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.g.debug({estimatedBandwidth:c,rh:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
+ VI+d)}catch(c){a.g.debug(c)}},TJ=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+VI+b)}catch(c){throw a.g.debug("Could not set fixed bandwidth",c),c;}},UJ=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case TI:a.g.warn("The application doesn't have the privilege to get the mute state.",UI);break;default:a.g.warn(RI,c)}}return!!b},LJ=function(a){return{position:a.getPosition(),state:a.m.getState(),Je:a.getState(),playbackRate:a.getPlaybackRate(),
23
+ isLive:a.isLive(),duration:a.getDuration(),isMuted:UJ(a),volume:a.getVolume(),dh:KJ(a),ag:DJ(a)}},VJ=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");WI(c,"load",d=>a(d));WI(c,_.Nd,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},WJ=function(a){return _.x(function*(){yield VJ();const b=new Promise(c=>{(new _.mj(c)).ca(5)});if(!(yield Promise.race([OJ(a).then(()=>!0),b.then(()=>!1)])))return a.g.debug("Took to long for the SDK to be ready"),
24
+ Promise.reject("SDK Timeout")})},XJ=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!");RJ(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)}})})},YJ=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case TI:a.g.warn("The application does not have the privilege to set mute.",UI);break;default:a.g.warn(RI,
25
+ c)}}},cK=function(a,b,c){return _.x(function*(){a.l=_.un(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 _.F(ZJ)),f=c.currentPosition);try{let g=a.l[d].url;if(a.l[d].type===_.sc&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(TJ(a,e.nextBandwidth),a.o=!1):(a.o||SJ(a,e),
26
+ a.o=!0);QJ(a);if(b.drm&&b.drm.env){const h={onError:k=>a.m.onError(k),Ab:a.m.getNetworkEngine()};a.h=new $J(b.drm,h);yield a.h.init()}else a.g.debug("No DRM configuration was provided. Assuming clear content");a.f||a.trigger(new _.F(aK));yield XJ(a);a.f||a.trigger(new _.F(bK));f&&typeof f===_.r&&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&&YJ(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;}})},dK=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())},$J=class{constructor(a,
28
+ b){this.h=a;this.o=null;this.a=_.ue;this.l=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.R("clpp.tizen.DrmEngine")}init(){const a=this;return _.x(function*(){var b=_.Gk[a.h.env]||null;if(!b)throw a.g.debug(_.sa,_.qb+a.h.env+_.aa),new _.H(_.G,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=_.Ik(b,a.h.customData);const d=b[_.pd];d&&a.f.set(_.pd,
29
+ {Vc:d.licenseUrl||"",customData:c,me:!1});(b=b[_.rd])&&a.f.set(_.rd,{Vc:b.licenseUrl||"",customData:c,me:!1});if(0===a.f.size)throw new _.H(_.G,6,6E3);if((c=a.h.preferredDrmSystem)&&a.f.get(c))a.a=c;else if(a.f.get(_.pd))a.a=_.pd;else if(a.f.get(_.rd))a.a=_.rd;else throw new _.H(_.G,6,6001,"Configuration for the target system is missing.");yield ZI(a);a.j=!0})}release(){const a=this;return _.x(function*(){a.j=!1;a.o=null;a.a=_.ue;a.l=null;a.f=new Map})}getDrmInfo(){return this.o}},bJ="DeleteLicenseAfterUse",
30
+ cJ="LicenseServer",dJ="CustomData";var jK=class{constructor(a){this.m=a;this.a=this.m.a;this.f=_.on;this.j=_.qs;this.w=(new Date).getTime();this.l=!1;this.o=-1;this.h=2;this.g=new _.R("clpp.tizen.StateManager")}initialize(){this.a.on(ZJ,this.C,this);this.a.on(eK,this.B,this);this.a.on(fK,this.A,this);this.a.on(aK,this.H,this);this.a.on(bK,this.G,this);this.a.on(gK,this.F,this)}release(){gJ(this,_.on);this.l=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(ZJ,this.C);this.a.off(eK,this.B);this.a.off(fK,this.A);this.a.off(aK,
31
+ this.H);this.a.off(bK,this.G);this.a.off(gK,this.F);this.m=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;gJ(this,_.jn)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",fJ(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()===hK;if(!a&&b){gJ(this,_.qn);return}}if(a=this.f!==_.pn)a=this.a.getState(),a=a===
32
+ hJ||a===iJ;a&&jJ(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===iK?gJ(this,_.pn):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){gJ(this,_.fn)}getState(){return this.f}};var kK=class{constructor(){this.o=this.A=this.f=this.h=this.B=this.m=this.j=this.a=null;this.C=!1;this.w=!0;this.l=null;this.g=new _.R("clpp.tizen.TextStreamer")}initialize(a){this.m=a}load(a){const b=this;return _.x(function*(){if(b.m)if(b.B=a,b.j=yield kJ(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.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&&lJ(b.a)){b.h=mJ(b);try{yield b.h.I;b.f=nJ(b);const d=b.m.getConfiguration();b.f.h=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole;b.C=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(_.Hx,
34
+ a);this.w=!0;let b=_.Pz(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.g.debug("canSwitch_");this.w=!1;this.l&&(_.oB(this.f,this.l,!0,0),this.l=null)}U(){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.B=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 W=class extends _.S{constructor(){super();this.h=this.a=this.m=null;this.f={};this.g=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 lK:0<Object.keys(this.f).length||(this.g.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+uJ(this,b[0].extra_info).Bit_rate,b=vJ(this,{bandwidth:b}))&&(this.w=b,tJ(this,b));break;case mK:sJ(this);break;default:this.g.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.rn&&this.m.off(_.sf,this.A)}initialize(a){this.m=a;this.a=this.m.a;this.m.on(_.sf,b=>{this.B||(b=b.detail,b.currentState===_.rn&&(this.g.debug("Current state",b.currentState),this.B=!0,wJ(this)))});this.a.on(nK,this.C,this)}release(){this.f={};this.h=this.w=this.l=this.j=null;this.B=!1;this.o=1}load(){if(this.a&&!(0<Object.keys(this.f).length)){this.h=this.m.h;this.m.off(_.sf,this.A);this.m.on(_.sf,this.A,this);try{const a=KJ(this.a);this.f=CJ(this,a);
37
+ const b=this.f[_.L]||[];b.length&&(this.j=b[0].renditions[0]||null);sJ(this)}catch(a){this.g.debug("Could not load track manager")}}}destroy(){this.a.off(nK,this.C);this.a=this.m=null}getVideoTracks(){return this.f[_.M]||[]}getAudioTracks(){return this.f[_.L]||[]}ga(){return this.f[_.K]||[]}ka(){return FJ(this,_.M)}Ka(){return FJ(this,_.L)}Da(){return FJ(this,_.K)}Va(){return this.w}ib(){this.g.info(SI);return null}jb(){this.g.info(SI);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(),MJ(this.a,a.bandwidth,null).then(()=>{sJ(this)})):0<a.renditions.length&&this.Ra(a.renditions[0])}ta(a){a?IJ(this,a.renditions[0]):this.g.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ha(a){a?(a=a.renditions[0],this.h?rJ(this.h,a.track):IJ(this,a)):(this.g.debug("Disabling text tracks"),this.l=null,NJ(this.a,!1),this.m.trigger(new _.F(_.dk)))}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,tJ(this,a),MJ(this.a,b.bandwidth,a.bandwidth).then(()=>{sJ(this)}).catch(c=>{const d=new _.H(_.G,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...")}Za(a){IJ(this,a)}$a(a){this.h?rJ(this.h,a.track):IJ(this,a)}addTextTrack(){}na(){return this.a.o}};W.prototype.isAbrEnabled=W.prototype.na;
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.jb;
41
+ W.prototype.getLoadingAudioRendition=W.prototype.ib;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 rK=class extends _.Wr{constructor(a){super();this.m=a;this.h=null;this.g=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 _.F(ZJ))}H(a){this.w=!0;this.trigger(new _.F(eK,{percent:a}))}G(){this.w=!1;this.trigger(new _.F(fK))}M(){this.trigger(new _.F(gK))}K(a,b){this.trigger(new _.F(nK,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.F(oK,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.F(pK,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.rd&&"Challenge"===b.name?aJ(a,b):"DrmError"===b.name&&(a.g.debug("DrmError event",b),b=new _.H(_.G,6,6005,{message:JSON.stringify(b)}),a.D.onError(b))))}U(a){this.trigger(new _.F(qK,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(PJ,f,this);e=setTimeout(()=>{this.off(PJ,f);d("Timeout")},3E4)});if(a===iK)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{RJ(this);c(webapis.avplay.play())},e=>{this.trigger(new _.F(qK));d(e)})})).then(()=>b());if(a===iJ||a===hK)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===hJ?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===iJ?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===hK||b===hJ||b===iJ){try{webapis.avplay.setSpeed(a),
44
+ this.C=a}catch(c){return this.g.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.g.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.C}load(a,b){const c=this;return _.x(function*(){c.g.debug("configure()",b||"");try{yield WJ(c),yield cK(c,a,b)}catch(d){throw new _.H(_.G,7,7003,null,d);}})}getState(){if(this.f&&this.a)return this.a.Je;try{return webapis.avplay.getState()}catch(a){this.U(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.B=!0;this.m.trigger(new _.F(_.Lf));webapis.avplay.seekTo(b,()=>{this.B=!1;this.m.trigger(new _.F(_.Kf));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.f&&this.a)return this.a.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.U(JSON.stringify(a))}}getDuration(){if(this.f&&this.a)return this.a.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.U(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.Dd.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 TI:this.g.debug("The application does not have the privilege to get the volume.",UI);break;default:this.g.debug(RI,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 TI:this.g.warn("The application does not have the privilege to set the volume.",UI);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.U(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()]}},iK="IDLE",hK="READY",hJ="PLAYING",iJ="PAUSED",xJ=_.Nb,yJ="AUDIO",HJ="TEXT",mK="PLAYER_MSG_RESOLUTION_CHANGED",lK="PLAYER_MSG_BITRATE_CHANGE",eJ="PLAYREADY",$I="WIDEVINE_CDM";var vK=class extends _.Wr{constructor(){super();this.a=new rK(this);this.f=new jK(this);this.configuration=this.B=_.nk();this.w=null;this.g=new _.R("clpp.tizen.Player");this.j=null;this.l=new W;this.C=new _.po;this.o=this.h=null;this.A=!1}H(){this.g.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.F(_.Md));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 _.F(_.Cf,
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=_.di(d))&&this.o.append([new _.qr(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)}U(a){this.g.debug(`Error: TYPE: ${a.eventType}`);gJ(this.f,_.nn);a=new _.H(_.G,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.F(_.Nd,{detail:a}))}init(a,
50
+ b){this.configuration=this.B=b;this.w=a;this.a.on(gK,this.H,this);this.a.on(PJ,this.F,this);this.a.on(oK,this.I,this);this.a.on(pK,this.G,this);this.a.on(qK,this.U,this);this.a.on(fK,this.J,this);this.f.initialize();this.l.initialize(this);this.g.debug("Initializing player surface");this.w.hideMediaElement();a=sK;sK+=1;a="__clpp_tizen_player_"+a;this.j=_.Ln(_.ve,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.hg,_.Rd,"position",
51
+ _.Zd,"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}_.Nn(a,d);dK(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}destroy(){const a=this;return _.x(function*(){yield a.release();a.a.off(gK,a.H);a.a.off(PJ,a.F);a.a.off(oK,a.I);a.a.off(pK,a.G);a.a.off(qK,a.U);a.a.off(fK,a.J);a.h&&(yield a.h.destroy(),a.h=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 tK}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()===_.fn?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.g.warn(_.oa);return new _.Vr}getTrackManager(){return this.l}unload(){return this.a.release().then(()=>{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*(){_.qk(a)&&
54
+ (b.configuration=_.pk(b.B,a));var c=_.Wm(b.configuration,[_.Td,"native"]);b.o=c.create(b);c=_.un(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.h=new kK;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),d;}b.l.load()})}play(){this.trigger(new _.F(_.Je));dK(this);return this.a.play().then(()=>{jJ(this.f)})}pause(){return this.a.pause().then(()=>{jJ(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=
55
+ new _.F(_.Nd,{detail:a});a.severity===_.G&&(gJ(this.f,_.nn),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.fn}isPaused(){return this.a.getState()===iJ}isMuted(){return UJ(this.a)}setMuted(a){YJ(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 uK).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};vK.prototype.getTextDisplayer=vK.prototype.getTextDisplayer;vK.prototype.setNetworkEngine=vK.prototype.setNetworkEngine;vK.prototype.getNetworkEngine=vK.prototype.getNetworkEngine;
57
+ var tK="clpp.tizen",sK=0,uK=class{a(){return tK}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.sc||a===_.hk||a===_.Bc)&&b){if(_.qj(2))return 2;if(_.qj(3)||_.qj(4)||_.qj(5)||_.qj(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}create(){return new vK}};_.z("clpp.tizen.TizenComponent",class extends _.Ks{f(){_.Sg(new uK)}a(){var a=tK;a&&_.Qg[a]&&(delete _.Qg[a],_.Rg.info("Removed Player factory: '"+a+"'"))}id(){return"tizen"}});var ZJ="onbufferingstart",eK="onbufferingprogress",fK="onbufferingcomplete",gK="onstreamcompleted",PJ="oncurrentplaytime",nK="onevent",oK="onsubtitlechange",pK="ondrmevent",qK="onerror",aK="preparingstart",bK="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 yu='application/mp4; codecs\x3d"stpp.ttml"',zu='application/mp4; codecs\x3d"stpp.ttml.im1i"',Au='application/mp4; codecs\x3d"stpp.ttml.im1t"',Bu="backgroundColor",Cu="direction",Du="displayAlign",Eu="region",Fu="textAlign",Gu="textDecoration",Hu="writingMode",Iu=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},Qu=function(a,b){var c=null;if(Ju.test(a)){{a=Ju.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 Ku.test(a)?c=Lu(Ku,a):Mu.test(a)?c=Lu(Mu,a):Nu.test(a)?(a=Nu.exec(a),c=Number(a[1])/b.frameRate):Ou.test(a)?(a=Ou.exec(a),c=Number(a[1])/b.a):Pu.test(a)&&(c=Lu(Pu,a));return c},Lu=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)},Ru=function(a){return a.split(":").pop()},Su=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},Uu=function(a,b){for(;Tu.test(a);){const c=Tu.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Vu=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Wu=function(a,b,c){a=Iu(a,b,Fu);if(!a&&c&&(a=Iu(c,b,Fu),!a&&"rltb"===Iu(c,b,Hu)))return _.hf;switch(a){case _.Tc:return _.kr;case _.hf:case _.Ld:return _.hf;default:return _.Xd}},Xu=function(a,b,c){if(_.Zh(a.w))return document.createTextNode(_.ci(a.w||""));if(a.A)return _.Kn("br");const d=_.Kn("span");for(const e of a.f)_.Ln(d,
4
- e);for(const e of a.j)d.appendChild(Xu(c.get(e),b,c));return d},$u=function(a,b,c,d){const e=Yu.exec(a);a=Zu.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?_.sr:Zu.test(a)?0:_.sr},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=Zu.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 Ru(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(Eu)&&(c=b.getAttribute(Eu));b.hasAttribute(_.wf)&&f.push(...b.getAttribute(_.wf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Ru(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 Ju=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ku=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Mu=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Nu=/^(\d*(?:\.\d*)?)f$/,Ou=/^(\d*(?:\.\d*)?)t$/,Pu=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Yu=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Zu=/^(\d+)px (\d+)px$/,dv=/^(\d+) (\d+)$/,Tu=/(\d+)px/,sv=/^(\d+px|\d+em|\d*\.?\d+c)$/,hv=[Bu,"color",Cu,Du,"fontFamily","fontSize","fontStyle","fontWeight",
8
- "lineHeight","opacity","padding",Fu,Gu,"textOutline",Hu,"zIndex"],lv=["begin",_.Ld];var uv=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=Qu(this.a.begin,b);b=Qu(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Kn(_.zd);for(const k of this.j)c.appendChild(Xu(g.get(k),e,g));g=new _.pr(h,b,c.innerHTML.trim(),_.Df);g.cssClassList=[...this.f];g.textAlign=Wu(this,e,null);g.writingMode=_.lr;g.line=-1;g.lineInterpretation=_.mr;g.lineAlign=_.nr;g.containerRows=bv(null,ev(a),15);if(this.o&&(f=
9
- f.get(this.o))){g.region=f.build(a,e);g.textAlign=Wu(this,e,f);a:switch(Iu(f,e,Hu)){case "tb":case "tblr":a=_.Mf;break a;case "tbrl":a=_.Nf;break a;default:a=_.lr}g.writingMode=a;a:switch(Iu(f,e,Du)){case _.Tc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Iu(f,e,Du)){case _.Tc:a=1;break a;default:a=_.mr}g.lineInterpretation=a;a:switch(Iu(f,e,Du)){case _.Tc:e=_.Tc;break a;default:e=_.nr}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 vv=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 wv=class extends rv{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.ur;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(Iu(this,b,Du)){case "after":var e="flex-start";break a;case _.Tc:e=_.Tc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Iu(this,b,Hu)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.ld}c.writingMode=e;e=this.getAttribute("extent")||Iu(this,b,"extent");c.width=$u(e,
11
- d,1,100);c.widthUnits=av(e,d);c.height=$u(e,a,2,100);c.heightUnits=av(e,a);b=this.getAttribute("origin")||Iu(this,b,"origin");c.viewportAnchorX=$u(b,d,1,0);c.viewportAnchorY=$u(b,a,2,0);c.viewportAnchorUnits=av(b,d);c.cssClassList=[...this.f];return c}};var xv=class extends pv{constructor(a,b){super("root-container",[],b);this.j=a}};var zv=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 yv.entries())g in this.a&&(c+=`${h}:${Su(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=Su(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=Vu(this.a.textShadow),d=Su(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(Gu 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
- Su(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Su(d),d=Uu(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=Su(c);c=Uu(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}},yv=new Map([[Bu,"background-color"],
15
- ["color","color"],[Cu,Cu],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Av=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=[]}Nc(){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 Dv=class{constructor(a){this.a=a.firstChild;this.f=new Set}zc(){return!!this.a}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Bv.has(Ru(a.nodeName))||Cv.has(Ru(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&&!Bv.has(Ru(a.nodeName))));const b=this.a;this.a=a;return b}},Bv=new Set(["tt","head","layout",_.me,_.Td,Eu,"styling",_.wf,"body",
16
- _.zd,"p","span","br"]),Cv=new Set([_.wf,_.Td]);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 Ev=class{constructor(){this.a=new Map}};var Fv=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.ug(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.Qh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Af)}catch(m){throw new _.H(_.G,2,2005,"Failed to parse TTML.");}d=new Av(d);e=new Ev;f=new Dv(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=_.di(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.zc();)a=f.next(),a=nv(e,a),c=d,b=a,"tt"===kv(b)&&(c.l=new xv(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===kv(b)&&(c.w=new vv(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,kv(b)!==_.Td||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)===_.Td&&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)===_.wf&&(g=b.getId()||gv(),h=new zv(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)!==_.wf&&iv(g)?(b=gv(),g=new zv(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)!==_.zd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=gv(),g=new wv(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)!==Eu?c=null:(b=g.getId(),g=new wv(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 uv(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 uv(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.Nc();f=[];for(l of d.a.values())f.push(...l.build(d.l));var l=f;return{cues:e,styles:l}}};var Gv=class{constructor(a){this.f=a}a(a){var b=new Fv(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 _.Xd:e.push("align:left");break;case _.hf:e.push("align:right");break;case _.kr:e.push("align:middle");break;case _.Xd:e.push("align:start");break;case _.hf:e.push("align:end")}switch(c.writingMode){case _.Mf:e.push("vertical:lr");break;case _.Nf:e.push("vertical:rl")}c=
21
- e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Uh(b)}},Hv=class{probe(a,b){return a===_.Ac&&b===_.zf}create(a){return new Gv(a)}};var Iv=class{constructor(a){this.a=new Fv(a);this.h=new _.R("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.el).L(_.pe,_.Xk).L(_.Cf,_.Xk).L(_.ke,_.Xk).L(_.oe,_.Xk).L(_.tf,_.Xk).$(_.vf,_.Yk).L("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.G,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.el).L("moof",_.Xk).L("traf",_.Xk).$("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.Qk(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.P(g.reader):_.Qk(g.reader);f.push(n);g.reader.skip(6)}}}).L(_.je,_.Zk(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}}};_.z("clpp.ttml.TtmlComponent",class extends _.Js{constructor(){super();this.j=new Hv}f(){_.Wq[_.Ac]=Fv;_.Wq[_.vc]=Iv;_.Wq[yu]=Iv;_.Wq[Au]=Iv;_.Wq[zu]=Iv;_.ej.push(this.j)}a(){_.Xq(_.Ac);_.Xq(_.vc);_.Xq(yu);_.Xq(Au);_.Xq(zu);_.gj(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 zu='application/mp4; codecs\x3d"stpp.ttml"',Au='application/mp4; codecs\x3d"stpp.ttml.im1i"',Bu='application/mp4; codecs\x3d"stpp.ttml.im1t"',Cu="backgroundColor",Du="direction",Eu="displayAlign",Fu="region",Gu="textAlign",Hu="textDecoration",Iu="writingMode",Ju=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},Ru=function(a,b){var c=null;if(Ku.test(a)){{a=Ku.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 Lu.test(a)?c=Mu(Lu,a):Nu.test(a)?c=Mu(Nu,a):Ou.test(a)?(a=Ou.exec(a),c=Number(a[1])/b.frameRate):Pu.test(a)?(a=Pu.exec(a),c=Number(a[1])/b.a):Qu.test(a)&&(c=Mu(Qu,a));return c},Mu=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)},Su=function(a){return a.split(":").pop()},Tu=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},Vu=function(a,b){for(;Uu.test(a);){const c=Uu.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Wu=function(a){return a?a.replace(/(\d*\.?\d+)%/g,(b,c)=>`${c/100}em`):""},Xu=function(a,b,c){a=Ju(a,b,Gu);if(!a&&c&&(a=Ju(c,b,Gu),!a&&"rltb"===Ju(c,b,Iu)))return _.jf;switch(a){case _.Tc:return _.lr;case _.jf:case _.Ld:return _.jf;default:return _.Zd}},Yu=function(a,b,c){if(_.$h(a.w))return document.createTextNode(_.di(a.w||""));if(a.A)return _.Ln("br");const d=_.Ln("span");for(const e of a.f)_.Mn(d,
4
+ e);for(const e of a.j)d.appendChild(Yu(c.get(e),b,c));return d},av=function(a,b,c,d){const e=Zu.exec(a);a=$u.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},bv=function(a,b){return typeof b===_.r&&0<b?_.tr:$u.test(a)?0:_.tr},cv=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},dv=function(a,b){a=a.getAttribute("extent");return(a=$u.exec(a))?Number(a[b]):null},fv=function(a){a=a.getAttribute("cellResolution");return(a=ev.exec(a))?Number(a[2]):null},
5
+ hv=function(){return`${"inline-"}${gv++}`},jv=function(a){return iv.some(b=>b in a.attributes)},kv=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...kv(a,a.a.get(d).f),d);return c},lv=function(a){return Su(a.h.nodeName)},ov=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={},mv.forEach(l=>
6
+ {l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Fu)&&(c=b.getAttribute(Fu));b.hasAttribute(_.xf)&&f.push(...b.getAttribute(_.xf).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Su(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new nv(b,c,d,e,f,g);a.a.set(b,c);return c},pv=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")}`},qv=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 rv=class extends qv{constructor(a,b,c){super(a,[],c);this.j=b||""}};var sv=class extends qv{constructor(a,b,c){super(a,b,c)}};var Ku=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Lu=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Nu=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Ou=/^(\d*(?:\.\d*)?)f$/,Pu=/^(\d*(?:\.\d*)?)t$/,Qu=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Zu=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,$u=/^(\d+)px (\d+)px$/,ev=/^(\d+) (\d+)$/,Uu=/(\d+)px/,uv=/^(\d+px|\d+em|\d*\.?\d+c)$/,iv=[Cu,"color",Du,Eu,"fontFamily","fontSize","fontStyle","fontWeight",
8
+ "lineHeight","opacity","padding",Gu,Hu,"textOutline",Iu,"zIndex"],mv=["begin",_.Ld];var vv=class extends sv{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=Ru(this.a.begin,b);b=Ru(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.Ln(_.zd);for(const k of this.j)c.appendChild(Yu(g.get(k),e,g));g=new _.qr(h,b,c.innerHTML.trim(),_.Ef);g.cssClassList=[...this.f];g.textAlign=Xu(this,e,null);g.writingMode=_.mr;g.line=-1;g.lineInterpretation=_.nr;g.lineAlign=_.or;g.containerRows=cv(null,fv(a),15);if(this.o&&(f=
9
+ f.get(this.o))){g.region=f.build(a,e);g.textAlign=Xu(this,e,f);a:switch(Ju(f,e,Iu)){case "tb":case "tblr":a=_.Nf;break a;case "tbrl":a=_.Of;break a;default:a=_.mr}g.writingMode=a;a:switch(Ju(f,e,Eu)){case _.Tc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Ju(f,e,Eu)){case _.Tc:a=1;break a;default:a=_.nr}g.lineInterpretation=a;a:switch(Ju(f,e,Eu)){case _.Tc:e=_.Tc;break a;default:e=_.or}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 wv=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 xv=class extends sv{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.vr;c.id=this.getId();const d=cv(a.j.containerWidth,dv(a,1),720);a=cv(a.j.containerHeight,dv(a,2),480);a:switch(Ju(this,b,Eu)){case "after":var e="flex-start";break a;case _.Tc:e=_.Tc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Ju(this,b,Iu)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.ld}c.writingMode=e;e=this.getAttribute("extent")||Ju(this,b,"extent");c.width=av(e,
11
+ d,1,100);c.widthUnits=bv(e,d);c.height=av(e,a,2,100);c.heightUnits=bv(e,a);b=this.getAttribute("origin")||Ju(this,b,"origin");c.viewportAnchorX=av(b,d,1,0);c.viewportAnchorY=av(b,a,2,0);c.viewportAnchorUnits=bv(b,d);c.cssClassList=[...this.f];return c}};var yv=class extends qv{constructor(a,b){super("root-container",[],b);this.j=a}};var Av=class extends qv{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=fv(a);c&&(b=cv(a.j.containerHeight,dv(a,2),480)/c);b=cv(a.j.fontSizeRadix,b,16);a=[];c=`::ttml .${this.h}, ::ttml .${this.h} * {`;for(const [g,h]of zv.entries())g in this.a&&(c+=`${h}:${Tu(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&&!uv.test(h)&&uv.test(k)&&uv.test(l)?(e=h,g=k):2===d.length&&!uv.test(h)&&uv.test(k)?(e=h,g=k):2===d.length&&uv.test(h)&&uv.test(k)&&(g=h);if(""!==g){g=Tu(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=Wu(this.a.textShadow),d=Tu(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(Hu 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
+ Tu(this.a.padding),d+=";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Tu(d),d=Vu(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=Tu(c);c=Vu(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}},zv=new Map([[Cu,"background-color"],
15
+ ["color","color"],[Du,Du],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var Bv=class{constructor(a){this.B=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=[]}Oc(){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)}},gv=0;var Ev=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&&!Cv.has(Su(a.nodeName))||Dv.has(Su(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&&!Cv.has(Su(a.nodeName))));const b=this.a;this.a=a;return b}},Cv=new Set(["tt","head","layout",_.ne,_.Ud,Fu,"styling",_.xf,"body",
16
+ _.zd,"p","span","br"]),Dv=new Set([_.xf,_.Ud]);var nv=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 Fv=class{constructor(){this.a=new Map}};var Gv=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.vg(this.a.ttml||{}),e=_.J(a,0,c[0]);e=_.Rh(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.Bf)}catch(m){throw new _.H(_.G,2,2005,"Failed to parse TTML.");}d=new Bv(d);e=new Fv;f=new Ev(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=_.ei(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.h.set(m,
17
+ new rv(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.Ac();)a=f.next(),a=ov(e,a),c=d,b=a,"tt"===lv(b)&&(c.l=new yv(c.B,Object.assign({},b.attributes))),c=d,b=a,"tt"===lv(b)&&(c.w=new wv(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,lv(b)!==_.Ud||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.h.set(g,new rv(g,b.h.textContent,b.attributes))),c=d,g=a,lv(g)===_.Ud&&g.attributes.begin&&g.attributes.end?(b=`#${hv()}`,
18
+ g=new rv(b,g.h.textContent,g.attributes),c.h.set(b,g),c=g):c=null,c&&(a.j=c.getId()),c=d,b=a,lv(b)===_.xf&&(g=b.getId()||hv(),h=new Av(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,lv(g)!==_.xf&&jv(g)?(b=hv(),g=new Av(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,lv(g)!==_.zd||!g.attributes.extent&&!g.attributes.origin?c=null:(b=hv(),g=new xv(b,kv(c,g.f),Object.assign({},g.attributes)),c.j.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,lv(g)!==Fu?c=null:(b=g.getId(),g=new xv(b,kv(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(lv(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=hv(),g=new vv(b,"#text"===g.h.nodeName?g.h.textContent:null,"br"===lv(g),g.a,g.j,kv(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"===lv(g)||g.j?(b=hv(),g=new vv(b,null,!1,g.a,g.j,kv(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 Hv=class{constructor(a){this.f=a}a(a){var b=new Gv(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=pv(d.startTime)+" --\x3e "+pv(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.Zd:e.push("align:left");break;case _.jf:e.push("align:right");break;case _.lr:e.push("align:middle");break;case _.Zd:e.push("align:start");break;case _.jf:e.push("align:end")}switch(c.writingMode){case _.Nf:e.push("vertical:lr");break;case _.Of:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Vh(b)}},Iv=class{probe(a,b){return a===_.xc&&b===_.Af}create(a){return new Hv(a)}};var Jv=class{constructor(a){this.a=new Gv(a);this.g=new _.R("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.fl).L(_.qe,_.Yk).L(_.Df,_.Yk).L(_.le,_.Yk).L(_.pe,_.Yk).L(_.uf,_.Yk).$(_.wf,_.Zk).L("stpp",c=>{b=!0;c.parser.stop()}).parse(a);if(!b)throw new _.H(_.G,2,2007);}parseMedia(a,b){let c=!1,d=[],e=[];const f=[];(new _.fl).L("moof",_.Yk).L("traf",_.Yk).$("subs",g=>{const h=_.P(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.Rk(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
+ _.P(g.reader):_.Rk(g.reader);f.push(n);g.reader.skip(6)}}}).L(_.ke,_.$k(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 _.Ks{constructor(){super();this.j=new Iv}f(){_.Xq[_.xc]=Gv;_.Xq[_.vc]=Jv;_.Xq[zu]=Jv;_.Xq[Bu]=Jv;_.Xq[Au]=Jv;_.fj.push(this.j)}a(){_.Yq(_.xc);_.Yq(_.vc);_.Yq(zu);_.Yq(Bu);_.Yq(Au);_.hj(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 nu="VerimatrixVCAS",ou="clpp.verimatrix.Vcas",pu="clpp.verimatrix.VcasComponent",ru=function(a,b){return a.C===qu?(a=Object.assign({},{deviceId:_.ei(_.Wh(a.A))},a.a&&{authenticator:_.ei(_.Wh(a.a))}),b+_.Mi(a)):b},xu=class extends _.$r{constructor(a){super(nu);const b={};b[su]=su;b[tu]=tu;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=qu,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- uu}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=ru(this,g);this.o=ru(this,h);this.l=ru(this,k);this.j=l;this.G=m;this.F=n;this.h=new _.R(ou);_.$h(this.w)?this.h.warn(_.Qb):this.Na(_.rd,{licenseUrl:this.w,videoRobustness:[_.zb,void 0],audioRobustness:[_.yb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.g.bind(this)}});_.$h(this.o)?this.h.warn(_.nb):this.Na(_.pd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.g.bind(this)}});_.$h(this.l)?this.h.warn(_.Ra):_.$h(this.j)?this.h.warn(_.Qa):this.Na(_.nd,{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===vu){a=this.B[tu];const c={};c[this.B[su]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.dl(b);switch(this.F){case wu:a=_.Mi({r:a,Ch:this.G},!0)}return a}J(a,b){this.g(a,
4
- b);_.il(b)}K(a,b){_.jl(b)}};_.z(ou,xu);xu.prototype.constructor=xu.prototype.constructor;xu.NAME=nu;var qu="query-string",vu="http-header";xu.LicenseRequestVuidLocation={QUERY_STRING:qu,HTTP_HEADER:vu};var su="DeviceId",tu="Authenticator";xu.LicenseRequestHttpHeader={DEVICE_ID_HEADER:su,AUTHENTICATOR_HEADER:tu};var uu="keyid",wu="contentid-siteid";xu.FairPlayAssetIdStrategy={KEYID:uu,CONTENTID_SITEID:wu};_.z(pu,class extends _.Js{constructor(){super();this.h=new _.R(pu)}a(){delete _.Fk.VerimatrixVCAS}g(a){a=a.getConfiguration();if(a.drm&&a.drm.env===nu){({customData:a}=a.drm);if(!a)throw new _.H(_.G,7,7100,_.td);a=new xu(a);this.h.info("Registering the Verimatrix VCAS Ultra environment");_.Gk(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 ou="VerimatrixVCAS",pu="clpp.verimatrix.Vcas",qu="clpp.verimatrix.VcasComponent",su=function(a,b){return a.C===ru?(a=Object.assign({},{deviceId:_.fi(_.Xh(a.A))},a.a&&{authenticator:_.fi(_.Xh(a.a))}),b+_.Ni(a)):b},yu=class extends _.as{constructor(a){super(ou);const b={};b[tu]=tu;b[uu]=uu;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=ru,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ vu}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=su(this,g);this.o=su(this,h);this.l=su(this,k);this.j=l;this.G=m;this.F=n;this.g=new _.R(pu);_.ai(this.w)?this.g.warn(_.Qb):this.Ma(_.rd,{licenseUrl:this.w,videoRobustness:[_.zb,void 0],audioRobustness:[_.yb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.ai(this.o)?this.g.warn(_.nb):this.Ma(_.pd,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.ai(this.l)?this.g.warn(_.Ra):_.ai(this.j)?this.g.warn(_.Qa):this.Ma(_.nd,{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.C===wu){a=this.B[uu];const c={};c[this.B[tu]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.el(b);switch(this.F){case xu:a=_.Ni({r:a,Ch:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.jl(b)}K(a,b){_.kl(b)}};_.z(pu,yu);yu.prototype.constructor=yu.prototype.constructor;yu.NAME=ou;var ru="query-string",wu="http-header";yu.LicenseRequestVuidLocation={QUERY_STRING:ru,HTTP_HEADER:wu};var tu="DeviceId",uu="Authenticator";yu.LicenseRequestHttpHeader={DEVICE_ID_HEADER:tu,AUTHENTICATOR_HEADER:uu};var vu="keyid",xu="contentid-siteid";yu.FairPlayAssetIdStrategy={KEYID:vu,CONTENTID_SITEID:xu};_.z(qu,class extends _.Ks{constructor(){super();this.g=new _.R(qu)}a(){delete _.Gk.VerimatrixVCAS}h(a){a=a.getConfiguration();if(a.drm&&a.drm.env===ou){({customData:a}=a.drm);if(!a)throw new _.H(_.G,7,7100,_.td);a=new yu(a);this.g.info("Registering the Verimatrix VCAS Ultra environment");_.Hk(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 eu="Registering listeners",fu="clpp.vimond.VimondPlugin",gu=function(a,b){a.m.trigger(new _.F(_.Tf,{detail:b}))},hu=function(a,b,c){b&&(a.B=!0,a.g.stop());a.m.onError(new _.H(b?_.G:1,9,9201,c))},iu=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.Pe];if(a.g)return[_.Ld,_.Ee];if(c===_.en)return[_.Ld,null];if(c===_.mn)return[_.Nd,_.Ee];b=_.Ee;if(c===_.hn||c===_.qn||a.f)b=_.Pe;return["period",b]},ju=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 _.hr;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.g=new _.lj(this.A.bind(this));this.h=new _.R("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.h.debug(eu),this.a.on(this.m,_.rf,this.I.bind(this)),this.a.on(this.m,_.Bf,this.J.bind(this)),this.a.on(this.m,_.Wb,this.G.bind(this)),this.a.on(this.m,_.Xb,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 _.x(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!==_.qn||(b.f&&[_.pn,_.hn].includes(d)?b.h.debug("Seeking"):(b.f&&d===_.qn&&(b.h.debug("Seeked"),b.f=!1),[_.qn,_.pn,_.mn,_.en].includes(d)&&(b.C=d,yield b.A(),d===_.en&&b.g.stop()))):b.h.debug("Ignore transition"))})}A(){const a=this;return _.x(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=_.tg(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 _.bl(A.url)).scheme||"").replace(":",
5
- "")}e.videoProtocol=f;const t=iu(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!==_.Kc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
- b.f;q.timestamp=(new Date).toISOString();b.h.debug("Fire an event");const y=_.ti(b.l);y.method="POST";y.contentType="application/json";y.headers.Authorization=`Bearer ${b.g}`;y.body=_.Wh(JSON.stringify(q));var m=b.j.fetch(y).P}const n=yield m;gu(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.h.debug("Unreachable service"),gu(a,b),hu(a,a.M,b)):1001===m?(a.h.debug("Generic service error"),gu(a,b),hu(a,a.N,b)):a.h.error(n.toString())}})}dispose(){this.h.debug(_.Jb);_.Tg(this.a);this.g.stop()}};var ku=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}Ae(a){this.g=a}};var lu=class{constructor(a){this.m=a;this.a=new _.hr;this.h=new _.R("clpp.vimond.VimondAdapter");this.f=this.g=!1;this.m&&this.a&&(this.h.debug(eu),this.a.on(this.m,_.df,this.o.bind(this)),this.a.on(this.m,_.Wb,this.j.bind(this)),this.a.on(this.m,_.Xb,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(_.Jb);_.Tg(this.a)}};var mu=class extends _.jt{constructor(){super();this.a=!1;this.h=new _.R(fu);this.j=this.g=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.ue)?a.namespace()===_.dd&&(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!==_.Kc&&(c=!0);var d=b.failOnError;typeof d!==_.Kc&&(d=!0);this.f=new lu(a);this.g=new ku(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new ju(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"}Ae(a){this.a&&
8
- this.g&&this.g.Ae(a)}};_.z(fu,mu);mu.prototype.updateAuthToken=mu.prototype.Ae;mu.Id="vimond";_.ro(new class{create(){return new mu}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var fu="Registering listeners",gu="clpp.vimond.VimondPlugin",hu=function(a,b){a.m.trigger(new _.F(_.Yf,{detail:b}))},iu=function(a,b,c){b&&(a.B=!0,a.h.stop());a.m.onError(new _.H(b?_.G:1,9,9201,c))},ju=function(a,b){const c=a.m.getState();if(1===b)return["str-start",_.Qe];if(a.h)return[_.Ld,_.Fe];if(c===_.fn)return[_.Ld,null];if(c===_.nn)return[_.Nd,_.Fe];b=_.Fe;if(c===_.jn||c===_.rn||a.f)b=_.Qe;return["period",b]},ku=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 _.ir;this.l=!0;this.f=this.j=this.B=!1;this.C=null;this.h=new _.mj(this.A.bind(this));this.g=new _.R("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.m&&this.a&&(this.g.debug(fu),this.a.on(this.m,_.sf,this.I.bind(this)),this.a.on(this.m,_.Cf,this.J.bind(this)),this.a.on(this.m,_.Wb,this.G.bind(this)),this.a.on(this.m,_.Xb,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.B||b.j||(d!==b.C||b.f?b.l&&d!==_.rn||(b.f&&[_.qn,_.jn].includes(d)?b.g.debug("Seeking"):(b.f&&d===_.rn&&(b.g.debug("Seeked"),b.f=!1),[_.rn,_.qn,_.nn,_.fn].includes(d)&&(b.C=d,yield b.A(),d===_.fn&&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.ca(a.l?10:a.K);a.l=!1;try{{var b=a.F;b.f++;const q=_.ug(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 _.dl(A.url)).scheme||"").replace(":",
5
+ "")}e.videoProtocol=f;const t=ju(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!==_.Kc&&(v.liveResumePossible=!0)}q.progress.eventNumber=
6
+ b.f;q.timestamp=(new Date).toISOString();b.g.debug("Fire an event");const y=_.ui(b.l);y.method="POST";y.contentType="application/json";y.headers.Authorization=`Bearer ${b.h}`;y.body=_.Xh(JSON.stringify(q));var m=b.j.fetch(y).P}const n=yield m;hu(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.g.debug("Unreachable service"),hu(a,b),iu(a,a.M,b)):1001===m?(a.g.debug("Generic service error"),hu(a,b),iu(a,a.N,b)):a.g.error(n.toString())}})}dispose(){this.g.debug(_.Jb);_.Ug(this.a);this.h.stop()}};var lu=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 _.R("clpp.vimond.VimondService");this.f=0}Be(a){this.h=a}};var mu=class{constructor(a){this.m=a;this.a=new _.ir;this.g=new _.R("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.m&&this.a&&(this.g.debug(fu),this.a.on(this.m,_.ef,this.o.bind(this)),this.a.on(this.m,_.Wb,this.j.bind(this)),this.a.on(this.m,_.Xb,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(_.Jb);_.Ug(this.a)}};var nu=class extends _.kt{constructor(){super();this.a=!1;this.g=new _.R(gu);this.j=this.h=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.ve)?a.namespace()===_.dd&&(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!==_.Kc&&(c=!0);var d=b.failOnError;typeof d!==_.Kc&&(d=!0);this.f=new mu(a);this.h=new lu(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new ku(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"}Be(a){this.a&&
8
+ this.h&&this.h.Be(a)}};_.z(gu,nu);nu.prototype.updateAuthToken=nu.prototype.Be;nu.Id="vimond";_.so(new class{create(){return new nu}});};f.call(g, window);