@castlabs/prestoplay 6.17.0 → 6.18.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 (63) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +7 -7
  5. package/cjs/cl.cast.js +111 -111
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +566 -555
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +75 -74
  10. package/cjs/cl.externs.js +46 -46
  11. package/cjs/cl.freewheel.js +24 -24
  12. package/cjs/cl.hls.js +71 -69
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +29 -29
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +312 -312
  17. package/cjs/cl.muxdata.js +15 -15
  18. package/cjs/cl.onboard.js +3 -3
  19. package/cjs/cl.persistent.js +14 -14
  20. package/cjs/cl.playlist.js +6 -6
  21. package/cjs/cl.sessions.js +15 -15
  22. package/cjs/cl.simid.js +15 -15
  23. package/cjs/cl.smooth.js +72 -72
  24. package/cjs/cl.thumbnails.js +26 -26
  25. package/cjs/cl.tizen.js +69 -69
  26. package/cjs/cl.ttml.js +28 -28
  27. package/cjs/cl.verimatrix.js +5 -5
  28. package/cjs/cl.vimond.js +13 -13
  29. package/cjs/cl.vr.js +19 -19
  30. package/cjs/cl.vtt.js +14 -14
  31. package/cjs/cl.youbora.js +18 -18
  32. package/cl.adobe.js +3 -3
  33. package/cl.airplay.js +3 -3
  34. package/cl.broadpeak.js +5 -5
  35. package/cl.cast.js +87 -87
  36. package/cl.conviva.js +27 -27
  37. package/cl.core.js +449 -442
  38. package/cl.crypto.js +8 -8
  39. package/cl.dash.js +70 -69
  40. package/cl.externs.js +46 -46
  41. package/cl.freewheel.js +19 -19
  42. package/cl.hls.js +72 -72
  43. package/cl.hlssmpte.js +5 -5
  44. package/cl.htmlcue.js +26 -26
  45. package/cl.ima.js +17 -17
  46. package/cl.mse.js +274 -274
  47. package/cl.muxdata.js +13 -13
  48. package/cl.onboard.js +4 -4
  49. package/cl.persistent.js +10 -10
  50. package/cl.playlist.js +5 -5
  51. package/cl.sessions.js +10 -10
  52. package/cl.simid.js +13 -13
  53. package/cl.smooth.js +59 -59
  54. package/cl.thumbnails.js +19 -19
  55. package/cl.tizen.js +57 -57
  56. package/cl.ttml.js +22 -22
  57. package/cl.verimatrix.js +4 -4
  58. package/cl.vimond.js +8 -8
  59. package/cl.vr.js +15 -15
  60. package/cl.vtt.js +12 -12
  61. package/cl.youbora.js +14 -14
  62. package/package.json +2 -2
  63. package/typings.d.ts +40 -5
package/cl.muxdata.js CHANGED
@@ -1,13 +1,13 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var hz=function(a){switch(a.type){case 1:return ez;case 2:return fz;case 3:return gz}},jz=function(a){const b=Object.keys(a).find(c=>iz.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},lz=function(a){let b={debug:!0,data:kz(a)};a.f&&a.f.muxOptionsOverride&&_.Qg(a.f.muxOptionsOverride)&&(b=_.Mg(b,a.f.muxOptionsOverride));b=_.Mg(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.h.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
- a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.Hl(c.url);e.video_source_url=_.gj(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().ma(),
3
- c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.h.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.la())&&d.language&&(e.player_language_code=d.language)}return e}});a.h.debug("Mux SDK options",b);return b},mz=function(a){_.mh(a.a);a.j.ed(a.F);a.j.we(a.C)},kz=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.ra,player_software_name:_.ra,player_software_version:_.fa,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
- player_mux_plugin_version:_.fa};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},nz=function(a){a.a.on(a.m,_.Uf,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.Uf,b)});a.a.on(a.m,_.Re,()=>a.emit(_.Re));a.a.on(a.m,_.Nc,a.G.bind(a));a.a.on(a.m,_.Kf,a.I.bind(a));a.a.on(a.m,_.cg,()=>a.emit(_.Cf));a.a.on(a.m,_.bg,()=>a.emit(_.Bf));a.a.on(a.m,_.r,a.H.bind(a));a.a.on(a.m,_.cc,()=>a.emit("adbreakstart"));a.a.on(a.m,_.dc,()=>a.emit("adbreakend"));a.a.on(a.m,_.qc,()=>{a.emit("adplay");
5
- a.emit("adplaying")});a.a.on(a.m,_.mc,()=>a.emit("adpause"));a.a.on(a.m,_.oc,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.rc,()=>a.emit("adended"));a.a.on(a.m,_.hc,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.lc,()=>a.emit("admidpoint"));a.a.on(a.m,_.sc,()=>a.emit("adthirdquartile"));a.j.qc(a.F);a.j.Nd(a.C);a.a.on(a.m,_.r,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
- var d=new _.Hl(b.uris[b.uriIndex]);b={request_start:c,request_type:hz(b),request_hostname:d.a};a.h.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.Hl(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:hz(c),request_hostname:f.a,request_error:`${hz(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
- a.h.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},oz=function(a){return!_.A(a)&&typeof a.init===_.Yd&&typeof a.emit===_.Yd},ez="manifest",fz="media",gz="encryption",iz=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var pz=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.hs;this.h=b;this.A=this.l=this.g=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.J.bind(this);this.C=this.K.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.g){try{this.g=!0,this.w.init(this.B,lz(this))}catch(d){throw this.g=!1,mz(this),new _.H(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=kz(this),this.emit("videochange",
8
- a),this.l=!1);nz(this)}release(){this.h.debug("release()");this.l?this.h.debug(_.ja):(mz(this),this.l=!0,this.o=this.f=null)}destroy(){this.h.debug(_.Ed);this.A?this.h.debug(_.ia):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.H(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.h.debug(_.Ee);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Na())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.h.debug(_.Ie);
9
- switch(a.detail.currentState){case _.Un:this.m.getConfiguration().autoplay&&this.emit(_.Re);break;case _.Wn:this.emit(_.bf);break;case _.Vn:this.emit(_.Ne);break;case _.Ln:this.emit(_.Vd)}}H(a){this.h.debug(_.Fe);if(this.g&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.F){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
- this.emit(_.r,{player_error_code:a.code,player_error_message:b})}}J(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.Hl(b.uris[b.uriIndex]);a={request_start:g,request_type:hz(b),request_hostname:d.a,request_id:jz(e),request_bytes_loaded:f,request_response_start:h,
11
- request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.gj(d)};this.h.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}K(a){a.requestStartTimestamp=Date.now()}};var qz=class extends _.pu{constructor(){super();this.f=this.m=null;this.a=!1;this.h=new _.R("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new pz(a,this.h)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.Ng(c.muxdata);try{var d=[];typeof c===_.De&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.H(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.A(f.muxdata)&&typeof f.muxdata===_.De){const g=f.muxdata;d=oz(g.muxLib)?g.muxLib:window.mux;if(!oz(d)){this.h.warn("Mux SDK is not loaded. Will do nothing.");
12
- this.a=!1;const h=new _.H(1,9,9301);this.U(a,h)}}else this.h.warn("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,this.U(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&this.U(this.m,c),c;}}U(a,b){a.trigger(new _.E(_.r,{detail:b}))}};
13
- _.z("clpp.muxdata.MuxDataPlugin",qz);qz.prototype.emit=qz.prototype.emit;qz.Id="mux";_.Yo(new class{create(){return new qz}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var sz=function(a){switch(a.type){case 1:return pz;case 2:return qz;case 3:return rz}},uz=function(a){const b=Object.keys(a).find(c=>tz.includes(c.toLowerCase()));return void 0!==b?a[b]:void 0},wz=function(a){let b={debug:!0,data:vz(a)};a.f&&a.f.muxOptionsOverride&&_.Tg(a.f.muxOptionsOverride)&&(b=_.Pg(b,a.f.muxOptionsOverride));b=_.Pg(b,{getPlayheadTime:()=>1E3*a.m.getPosition(),getStateData:()=>{{a.g.debug("getStateData()");var c=a.m.getLoadedSource(),d=a.m.getTrackManager();const f=
2
+ a.m.getSurface();var e={player_is_paused:a.m.isPaused(),player_is_fullscreen:f.isFullscreen(),video_source_duration:1E3*a.m.getDuration(),player_autoplay_on:!!a.m.getConfiguration().autoplay};if(c){const k=new _.Kl(c.url);e.video_source_url=_.jj(k);e.video_source_mime_type=c.type;c.name&&(e.video_title=c.name)}if(c=f.getContainer())e.player_width=c.offsetWidth,e.player_height=c.offsetHeight;(c=a.m.getSurface().getMedia())?c={videoWidth:c.videoWidth,videoHeight:c.videoHeight}:(c=a.m.getTrackManager().oa(),
3
+ c={videoWidth:c.width,videoHeight:c.height});const {videoWidth:g,videoHeight:h}=c;a.g.debug(`Video dimensions: ${g}x${h}`);g&&h&&(e.video_source_height=g,e.video_source_width=h);(d=d.na())&&d.language&&(e.player_language_code=d.language)}return e}});a.g.debug("Mux SDK options",b);return b},xz=function(a){_.ph(a.a);a.j.gd(a.F);a.j.ye(a.C)},vz=function(a){const b={env_key:a.f.envKey,video_title:a.o&&a.o.name||"",player_name:_.ra,player_software_name:_.ra,player_software_version:_.fa,player_mux_plugin_name:"CastlabsPlayer built-in Mux Plugin",
4
+ player_mux_plugin_version:_.fa};(a=a.m.getConfiguration().viewerId)&&(b.viewer_user_id=a);return b},yz=function(a){a.a.on(a.m,_.Xf,()=>{const b={player_playhead_time:1E3*a.m.getPosition()};a.emit(_.Xf,b)});a.a.on(a.m,_.Te,()=>a.emit(_.Te));a.a.on(a.m,_.Nc,a.G.bind(a));a.a.on(a.m,_.Nf,a.I.bind(a));a.a.on(a.m,_.gg,()=>a.emit(_.Ff));a.a.on(a.m,_.fg,()=>a.emit(_.Ef));a.a.on(a.m,_.r,a.H.bind(a));a.a.on(a.m,_.cc,()=>a.emit("adbreakstart"));a.a.on(a.m,_.dc,()=>a.emit("adbreakend"));a.a.on(a.m,_.qc,()=>{a.emit("adplay");
5
+ a.emit("adplaying")});a.a.on(a.m,_.mc,()=>a.emit("adpause"));a.a.on(a.m,_.oc,()=>{a.emit("adplay");a.emit("adplaying")});a.a.on(a.m,_.rc,()=>a.emit("adended"));a.a.on(a.m,_.hc,()=>a.emit("adfirstquartile"));a.a.on(a.m,_.lc,()=>a.emit("admidpoint"));a.a.on(a.m,_.sc,()=>a.emit("adthirdquartile"));a.j.tc(a.F);a.j.Rd(a.C);a.a.on(a.m,_.r,b=>{if((b=b.detail)&&1===b.category){var c=b.data;c=c&&c.request;if(void 0!==c&&!0===(1===c.type||2===c.type||3===c.type))if(7001===b.code){b=c;c=b.requestStartTimestamp;
6
+ var d=new _.Kl(b.uris[b.uriIndex]);b={request_start:c,request_type:sz(b),request_hostname:d.a};a.g.debug("onRequestCanceled()","Track event: requestcanceled",b);a.emit("requestcanceled",b)}else{{d=c.requestStartTimestamp;const f=new _.Kl(c.uris[c.uriIndex]);var e=b.data;e=void 0===e?-1:void 0!==e.response?e.response.status:void 0!==e.status?e.status:-1;b={request_start:d,request_type:sz(c),request_hostname:f.a,request_error:`${sz(c)}${"LoadError"}`,request_error_code:e,request_error_text:b.toString()};
7
+ a.g.debug("onRequestFailed()","Track event: requestfailed",b);a.emit("requestfailed",b)}}}})},zz=function(a){return!_.A(a)&&typeof a.init===_.Yd&&typeof a.emit===_.Yd},pz="manifest",qz="media",rz="encryption",tz=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];var Az=class{constructor(a,b){this.m=a;this.o=this.f=null;this.B=("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6);this.a=new _.ts;this.g=b;this.A=this.l=this.h=!1;this.w=null;this.j=a.getNetworkEngine();this.F=this.J.bind(this);this.C=this.K.bind(this)}initialize(a,b,c){this.f=a;this.o=b;this.w=c;if(!this.h){try{this.h=!0,this.w.init(this.B,wz(this))}catch(d){throw this.h=!1,xz(this),new _.H(1,9,9302,null,d);}this.emit("playerready")}this.l&&!this.A&&(a=vz(this),this.emit("videochange",
8
+ a),this.l=!1);yz(this)}release(){this.g.debug("release()");this.l?this.g.debug(_.ja):(xz(this),this.l=!0,this.o=this.f=null)}destroy(){this.g.debug(_.Ed);this.A?this.g.debug(_.ia):(this.A=!0,this.emit("destroy"))}emit(a,b){if(null===this.w)throw new _.H(1,9,9301);this.w.emit(this.B,a,b)}G(a){this.g.debug(_.Ge);var b=a.detail;a=this.m.getTrackManager();b&&b.bandwidth&&(b=b.bandwidth,(a=a.Qa())&&a.bandwidth&&(b+=a.bandwidth),this.emit("renditionchange",{video_source_bitrate:b}))}I(a){this.g.debug(_.Ke);
9
+ switch(a.detail.currentState){case _.Xn:this.m.getConfiguration().autoplay&&this.emit(_.Te);break;case _.Zn:this.emit(_.df);break;case _.Yn:this.emit(_.Pe);break;case _.On:this.emit(_.Vd)}}H(a){this.g.debug(_.He);if(this.h&&(a=a.detail||null))if(10003===a.code)this.emit("aderror");else if(a.severity===_.F){var b=a.message||"Player error";if(1===a.category||6100===a.code||6007===a.code)b="Download error",6100===a.code?b="Certificate request error":6007===a.code&&(b="License request error"),b=`${b} castlabs-error-data:${JSON.stringify(a.data)}`;
10
+ this.emit(_.r,{player_error_code:a.code,player_error_message:b})}}J(a){var b=a.request;if(b=void 0!==b&&!0===(1===b.type||2===b.type||3===b.type))b=a.status,b=void 0!==b&&200<=b&&299>=b;if(b){{b=a.request;const e=a.headers,f=b.bytesLoaded,g=b.requestStartTimestamp;var c=b.startTime,d=b.endTime;const h=g+a.responseStartMs;a=g+a.timeMs;c=c&&d?d-c:void 0;d=new _.Kl(b.uris[b.uriIndex]);a={request_start:g,request_type:sz(b),request_hostname:d.a,request_id:uz(e),request_bytes_loaded:f,request_response_start:h,
11
+ request_response_end:a,request_response_headers:e,request_media_duration:c,request_url:_.jj(d)};this.g.debug("onRequestCompleted()","Track event: requestcompleted",a);this.emit("requestcompleted",a)}}}K(a){a.requestStartTimestamp=Date.now()}};var Bz=class extends _.Au{constructor(){super();this.f=this.m=null;this.a=!1;this.g=new _.R("clpp.muxdata")}onPlayerCreated(a){this.m=a;this.f=new Az(a,this.g)}onContentWillLoad(a,b){var c=a.getConfiguration();c=_.Qg(c.muxdata);try{var d=[];typeof c===_.Fe&&(c.envKey||d.push("envKey"));if(0<d.length)throw new _.H(1,9,9300,{missingKeys:d});{const f=a.getConfiguration();d=null;if(this.a=!_.A(f.muxdata)&&typeof f.muxdata===_.Fe){const g=f.muxdata;d=zz(g.muxLib)?g.muxLib:window.mux;if(!zz(d)){this.g.warn("Mux SDK is not loaded. Will do nothing.");
12
+ this.a=!1;const h=new _.H(1,9,9301);this.U(a,h)}}else this.g.warn("Mux plugin is loaded but not configured. Will do nothing.");var e=d}null!==e&&this.f.initialize(c,b,e)}catch(f){this.a=!1,this.U(a,f)}}onContentLoaded(){}onPlayerWillDestroy(){this.a&&(this.f.destroy(),this.m=this.f=null)}onPlayerWillRelease(){this.a&&this.f.release()}id(){return"mux"}emit(a,b){try{this.f.emit(a,b)}catch(c){throw null!==this.m&&this.U(this.m,c),c;}}U(a,b){a.trigger(new _.E(_.r,{detail:b}))}};
13
+ _.z("clpp.muxdata.MuxDataPlugin",Bz);Bz.prototype.emit=Bz.prototype.emit;Bz.Id="mux";_.dp(new class{create(){return new Bz}});};f.call(g, window);
package/cl.onboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var dz=function(a,b){let c=b.baseUrl;_.ti(c,"/")||(c+="/");const d=g=>g&&(_.si(g,"https://")||_.si(g,"http://")||_.si(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.Zs(a);a.Qa(_.zd,{licenseUrl:e,videoRobustness:[_.Fb,void 0],audioRobustness:[_.Eb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.Wl,licenseResponse:_.Xl}});a.Qa(_.vd,{licenseUrl:b,
2
- certificateUrl:b,modifiers:{licenseRequest:_.Zl,licenseResponse:_.$l,extractContentId:_.am,certificateRequest:_.bm}});a.Qa(_.xd,{licenseUrl:f,modifiers:{licenseRequest:_.Wl}});_.ll(a)};
3
- _.z("clpp.onboard.OnboardComponent",class extends _.Nt{constructor(){super();this.h=new _.R("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.kl[a];this.j.clear()}g(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.h.info(`Registering the DRMtoday Onboard environment, name='${b}'`),dz(b,a),this.j.add(b))}id(){return"onboard"}});
4
- _.z("clpp.onboard.register",dz);};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var oz=function(a,b){let c=b.baseUrl;_.wi(c,"/")||(c+="/");const d=g=>g&&(_.vi(g,"https://")||_.vi(g,"http://")||_.vi(g,"//"))?g:`${c}${g}`,e=d(b.widevineUrl||"widevine"),f=d(b.playreadyUrl||"playready");b=d(b.fairplayUrl||"fairplay");a=new _.kt(a);a.Ta(_.zd,{licenseUrl:e,videoRobustness:[_.Gb,void 0],audioRobustness:[_.Fb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:_.Zl,licenseResponse:_.$l}});a.Ta(_.vd,{licenseUrl:b,
2
+ certificateUrl:b,modifiers:{licenseRequest:_.bm,licenseResponse:_.cm,extractContentId:_.dm,certificateRequest:_.em}});a.Ta(_.xd,{licenseUrl:f,modifiers:{licenseRequest:_.Zl}});_.ol(a)};
3
+ _.z("clpp.onboard.OnboardComponent",class extends _.Yt{constructor(){super();this.g=new _.R("clpp.onboard");this.j=new Set}a(){for(const a of this.j)delete _.nl[a];this.j.clear()}h(a){a=a.getConfiguration().drm;var b;if(b=!(!a||!a.env))b=a&&a.customData,b=!(!b||!b.baseUrl);b&&(b=a.env,a=a.customData,a={baseUrl:a.baseUrl,widevineUrl:a.widevineUrl,playreadyUrl:a.playreadyUrl,fairplayUrl:a.fairplayUrl},this.g.info(`Registering the DRMtoday Onboard environment, name='${b}'`),oz(b,a),this.j.add(b))}id(){return"onboard"}});
4
+ _.z("clpp.onboard.register",oz);};f.call(g, window);
package/cl.persistent.js CHANGED
@@ -1,11 +1,11 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Oy="A persistent DRM session already exists for: ",Py="No DRM configuration.",Qy="clpp.persistent",Ry="clpp.persistent.SimpleSessionStorage",Sy=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},Uy=function(a,b){a.I=Ty;a.J=[];a.C=!0;return _.Ym(a,b)},Wy=function(a,b,c,d,e,f){a.I=Vy;const g=new Map,h=_.Im(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Ke,persistentState:_.uf,sessionTypes:[_.Pe],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,
2
- distinctiveIdentifierRequired:!1,persistentStateRequired:!0,audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.Xm(a,g)},Xy=function(a,b){return _.x(function*(){const c=yield _.on(a,b);if(c){var d=[],e=a.f.get(c);e&&a.A&&(e.ub=new _.an,d.push(e.ub));a.h.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.h.debug("Ignoring attempt to remove missing session",b)})},Yy=function(a){a=a.f.keys();a=Sy(a,b=>b.sessionId);return Array.from(a)},
3
- Zy=function(a,b){const c=_.nl(a),d=_.Tk({drm:a});d.drm=a;a=new _.fo({sb:b,onError:()=>{},pe:()=>{},oe:()=>{},onEvent:()=>{},getConfiguration:()=>d,yc:()=>null});a.g=c;return a},bz=function(a,b,c){return _.x(function*(){const d=$y;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)az.debug(Oy,e);else{var g=Zy(a,c);try{yield Uy(g,b);yield _.mn(g);yield _.pn(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.Kj(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:Yy(g),
4
- keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw az.error(`Error while persisting DRM session ${e}`),new _.H(1,6,6200,null,h);}finally{yield g.destroy()}}}}else az.debug(Py)})},Ty=1,Vy=2,cz=class{constructor(){this.h=new _.R(Ry)}store(a,b){return _.x(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Zy="A persistent DRM session already exists for: ",$y="No DRM configuration.",az="clpp.persistent",bz="clpp.persistent.SimpleSessionStorage",cz=function(a,b){const c=[];for(const d of a)c.push(b(d));return c},ez=function(a,b){a.I=dz;a.J=[];a.C=!0;return _.an(a,b)},gz=function(a,b,c,d,e,f){a.I=fz;const g=new Map,h=_.Lm(b);g.set(h,{audioCapabilities:e,videoCapabilities:f,distinctiveIdentifier:_.Me,persistentState:_.xf,sessionTypes:[_.Re],label:h,drmInfos:[{keySystem:b,licenseServerUri:c,
2
+ distinctiveIdentifierRequired:!1,persistentStateRequired:!0,audioRobustness:"",videoRobustness:"",serverCertificate:d,initData:null,keyIds:null}]});return _.$m(a,g)},hz=function(a,b){return _.x(function*(){const c=yield _.rn(a,b);if(c){var d=[],e=a.f.get(c);e&&a.A&&(e.xb=new _.dn,d.push(e.xb));a.g.debug("Attempting to remove session",b);d.push(c.remove());return Promise.all(d)}a.g.debug("Ignoring attempt to remove missing session",b)})},iz=function(a){a=a.f.keys();a=cz(a,b=>b.sessionId);return Array.from(a)},
3
+ jz=function(a,b){const c=_.ql(a),d=_.Wk({drm:a});d.drm=a;a=new _.io({vb:b,onError:()=>{},re:()=>{},qe:()=>{},onEvent:()=>{},getConfiguration:()=>d,Bc:()=>null});a.h=c;return a},mz=function(a,b,c){return _.x(function*(){const d=kz;if(a){var e=a.offlineId;if(0!==e.length){var f=yield d.get(e);if(f)lz.debug(Zy,e);else{var g=jz(a,c);try{yield ez(g,b);yield _.pn(g);yield _.sn(g);const h=g.getDrmInfo(),k=b.map(l=>({contentType:_.Nj(l.video.mimeType,l.video.codecs),robustness:h.videoRobustness}));f={sessionIds:iz(g),
4
+ keySystem:h.keySystem,licenseServerUri:h.licenseServerUri,serverCertificate:h.serverCertificate,audioCapabilities:[],videoCapabilities:k,drmConfig:a};yield d.store(e,f)}catch(h){throw lz.error(`Error while persisting DRM session ${e}`),new _.H(1,6,6200,null,h);}finally{yield g.destroy()}}}}else lz.debug($y)})},dz=1,fz=2,nz=class{constructor(){this.g=new _.R(bz)}store(a,b){return _.x(function*(){{var c=JSON.stringify(b.sessionIds);var d=b.serverCertificate?Array.from(b.serverCertificate):null;d=JSON.stringify(d);
5
5
  const e=JSON.stringify(b.audioCapabilities),f=JSON.stringify(b.videoCapabilities);c=JSON.stringify({sessionIds:c,keySystem:b.keySystem,licenseServerUri:encodeURIComponent(b.licenseServerUri),serverCertificate:d,audioCapabilities:e,videoCapabilities:f,drmConfig:JSON.stringify(b.drmConfig)})}window.localStorage.setItem(encodeURIComponent(a),btoa(c))})}get(a){const b=this;return _.x(function*(){const c=window.localStorage.getItem(encodeURIComponent(a));if(c)try{{const e=JSON.parse(atob(c)),f=JSON.parse(e.sessionIds),
6
- g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.h.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.x(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.x(function*(){window.localStorage.clear()})}getName(){return Ry}};_.z("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.A(a)||(_.Rg(a.store)||c.push("store"),_.Rg(a.get)||c.push("get"),_.Rg(a.delete)||c.push("delete"),_.Rg(a.clear)||c.push("clear"),_.Rg(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw az.warn("Invalid session storage implementation"),new _.H(1,6,6202,{missingMethods:b});$y=a});
7
- _.z("clpp.persistent.fetchLicense",function(a,b,...c){return _.x(function*(){var d=$y,e=(l,m)=>new _.H(1,6,6200,l,m);const f=_.Zn(a).shift();if(!f)throw e("No source specified.");if(!b)throw e(Py);var g=b.offlineId;if(typeof g!==_.Nf||!g.length)throw e("Missing offline id.");if(yield d.get(g))az.debug(Oy,g);else{var h=_.Tk();d=new _.Vo;g=[];for(var k of c){const l=new k;_.Wk(l.id())||(l.f(),_.Yk(l),g.push(l))}k=null;try{k=yield _.nr(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
- const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.H(_.F,4,4014));const m=_.lr(l.periods);yield bz(b,m,d)}catch(l){if(l instanceof _.H&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.Vk.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
- _.z("clpp.persistent.removeLicense",function(a){return _.x(function*(){var b=$y;if(_.Tg(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.Vo,c=Zy(e.drmConfig,d),yield Wy(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.mn(c),yield Promise.all(e.sessionIds.map(f=>_.x(function*(){yield Xy(c,f);az.debug("successfully removed session with id",f)}))),yield b.delete(a)):az.debug("No persistent DRM session found")}catch(e){throw az.error("Failed to remove session"),
10
- new _.H(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else az.warn("Invalid offlineId")})});var $y=new cz,az=new _.R(Qy);_.z("clpp.persistent.PersistentLicenseComponent",class extends _.Nt{constructor(){super();this.h=new _.R(Qy)}id(){return _.Oe}l(a,b){const c=this;return _.x(function*(){const d=a.getConfiguration().drm;if(d){c.h.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield bz(d,b,e),a.trigger(new _.E(_.Od,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.h.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.x(function*(){b.h.debug(`Getting EME session IDs for ${a}`);
11
- const c=$y;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.h.debug(`No offline session found for ${a}`);return[]}catch(d){return b.h.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
6
+ g=e.audioCapabilities||[],h=e.videoCapabilities||[],k=e.serverCertificate||[],l=e.drmConfig||{};var d={sessionIds:f,keySystem:e.keySystem,licenseServerUri:decodeURIComponent(e.licenseServerUri||""),serverCertificate:k?new Uint8Array(k):null,audioCapabilities:g,videoCapabilities:h,drmConfig:l}}return d}catch(e){b.g.warn(`Error while loading offline items for ${a} from storage: `,e)}return null})}delete(a){return _.x(function*(){window.localStorage.removeItem(encodeURIComponent(a))})}clear(){return _.x(function*(){window.localStorage.clear()})}getName(){return bz}};_.z("clpp.persistent.useStorage",function(a){{var b=["store","get","delete","clear","getName"];const c=[];_.A(a)||(_.Ug(a.store)||c.push("store"),_.Ug(a.get)||c.push("get"),_.Ug(a.delete)||c.push("delete"),_.Ug(a.clear)||c.push("clear"),_.Ug(a.getName)||c.push("getName"),b=c)}if(0<b.length)throw lz.warn("Invalid session storage implementation"),new _.H(1,6,6202,{missingMethods:b});kz=a});
7
+ _.z("clpp.persistent.fetchLicense",function(a,b,...c){return _.x(function*(){var d=kz,e=(l,m)=>new _.H(1,6,6200,l,m);const f=_.bo(a).shift();if(!f)throw e("No source specified.");if(!b)throw e($y);var g=b.offlineId;if(typeof g!==_.Qf||!g.length)throw e("Missing offline id.");if(yield d.get(g))lz.debug(Zy,g);else{var h=_.Wk();d=new _.ap;g=[];for(var k of c){const l=new k;_.Zk(l.id())||(l.f(),_.al(l),g.push(l))}k=null;try{k=yield _.yr(f.url,d,h.manifest.attemptParameters,f.type||null);k.configure(h.manifest);
8
+ const l=yield k.start(f.url,{configurationId:"",networkingEngine:d,filterAllPeriods:()=>{},filterNewPeriod:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}});if(!l.periods.length)throw e(null,new _.H(_.F,4,4014));const m=_.wr(l.periods);yield mz(b,m,d)}catch(l){if(l instanceof _.H&&6200===l.code)throw l;throw e(null,l);}finally{for(;g.length;)e=g.shift(),e.a(),_.Yk.delete(e.id());e=[];k&&e.push(k.stop());e.push(d.destroy());yield Promise.all(e)}}})});
9
+ _.z("clpp.persistent.removeLicense",function(a){return _.x(function*(){var b=kz;if(_.Wg(a)&&0!==a.length){var c=null,d=null;try{const e=yield b.get(a);e?(e.drmConfig.delayLicenseRequestUntilPlayed=!0,d=new _.ap,c=jz(e.drmConfig,d),yield gz(c,e.keySystem,e.licenseServerUri,e.serverCertificate,e.audioCapabilities,e.videoCapabilities),yield _.pn(c),yield Promise.all(e.sessionIds.map(f=>_.x(function*(){yield hz(c,f);lz.debug("successfully removed session with id",f)}))),yield b.delete(a)):lz.debug("No persistent DRM session found")}catch(e){throw lz.error("Failed to remove session"),
10
+ new _.H(1,6,6201,null,e);}finally{b=[],c&&b.push(c.destroy()),d&&b.push(d.destroy()),yield Promise.all(b)}}else lz.warn("Invalid offlineId")})});var kz=new nz,lz=new _.R(az);_.z("clpp.persistent.PersistentLicenseComponent",class extends _.Yt{constructor(){super();this.g=new _.R(az)}id(){return _.Qe}l(a,b){const c=this;return _.x(function*(){const d=a.getConfiguration().drm;if(d){c.g.debug(`Persisting DRM session ID: ${d.offlineId}`);var e=a.getNetworkEngine();try{yield mz(d,b,e),a.trigger(new _.E(_.Od,{offlineId:d.offlineId}))}catch(f){a.onError(f)}}else c.g.debug("No DRM configuration found for loaded source.")})}j(a){const b=this;return _.x(function*(){b.g.debug(`Getting EME session IDs for ${a}`);
11
+ const c=kz;try{const d=yield c.get(a);if(d)return d.sessionIds||[];b.g.debug(`No offline session found for ${a}`);return[]}catch(d){return b.g.warn("Error while loading session info from storage"),[]}})}});};f.call(g, window);
package/cl.playlist.js CHANGED
@@ -1,5 +1,5 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Ly=function(a,b){return 0<=b&&b<a.a.length},My=function(a){a.trigger(new _.E(_.df))},Ny=class extends _.Us{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.g=!1;this.j=this.ic.bind(this)}getPosition(){return this.f}Cg(){return this.a}Pc(){return 0<this.a.length&&Ly(this,this.f)?this.a[this.f]:null}Dg(){const a=this.f+1;return 0<
2
- this.a.length&&Ly(this,a)?this.a[a]:null}Ng(){return this.g}start(){this.g||(this.g=!0,this.m.on(_.Vd,this.j),this.wd(this.f,!0))}stop(){this.g=!1;this.m.off(_.Vd,this.j)}ic(){this.next()}next(){const a=this;return _.x(function*(){yield a.wd(Math.min(a.a.length-1,a.f+1))})}eh(){const a=this;return _.x(function*(){yield a.wd(Math.max(0,a.f-1))})}wd(a,b){b=void 0===b?!1:b;const c=this;return _.x(function*(){if(0<c.a.length&&Ly(c,a)&&(b||c.f!==a)){c.f=a;var d=c.Pc();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
- c.trigger(new _.E(_.cf,{item:d})))}})}append(a){this.a.push(a);My(this)}Mg(a,b){if(0<=b&&b<=this.a.length){const c=this.Pc();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));My(this)}}remove(a){if(0<this.a.length&&Ly(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);My(this)}}clear(){this.stop();this.f=0;this.a=[];this.g=!1;My(this)}};_.z("clpp.Playlist",Ny);Ny.prototype.clear=Ny.prototype.clear;Ny.prototype.remove=Ny.prototype.remove;Ny.prototype.insert=Ny.prototype.Mg;
4
- Ny.prototype.append=Ny.prototype.append;Ny.prototype.goTo=Ny.prototype.wd;Ny.prototype.previous=Ny.prototype.eh;Ny.prototype.next=Ny.prototype.next;Ny.prototype.onEnded=Ny.prototype.ic;Ny.prototype.stop=Ny.prototype.stop;Ny.prototype.start=Ny.prototype.start;Ny.prototype.isStarted=Ny.prototype.Ng;Ny.prototype.getUpcoming=Ny.prototype.Dg;Ny.prototype.getCurrent=Ny.prototype.Pc;Ny.prototype.getQueue=Ny.prototype.Cg;Ny.prototype.getPosition=Ny.prototype.getPosition;Ny.prototype.off=Ny.prototype.off;
5
- Ny.prototype.one=Ny.prototype.one;Ny.prototype.on=Ny.prototype.on;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Wy=function(a,b){return 0<=b&&b<a.a.length},Xy=function(a){a.trigger(new _.E(_.ff))},Yy=class extends _.ft{on(a,b,c){return super.on(a,b,c)}one(a,b,c){return super.one(a,b,c)}off(a,b){return super.off(a,b)}constructor(a,b){b=void 0===b?()=>Promise.resolve():b;super();this.m=a;this.l=b;this.f=0;this.a=[];this.h=!1;this.j=this.Wa.bind(this)}getPosition(){return this.f}Eg(){return this.a}Sc(){return 0<this.a.length&&Wy(this,this.f)?this.a[this.f]:null}Fg(){const a=this.f+1;return 0<
2
+ this.a.length&&Wy(this,a)?this.a[a]:null}Qg(){return this.h}start(){this.h||(this.h=!0,this.m.on(_.Vd,this.j),this.yd(this.f,!0))}stop(){this.h=!1;this.m.off(_.Vd,this.j)}Wa(){this.next()}next(){const a=this;return _.x(function*(){yield a.yd(Math.min(a.a.length-1,a.f+1))})}hh(){const a=this;return _.x(function*(){yield a.yd(Math.max(0,a.f-1))})}yd(a,b){b=void 0===b?!1:b;const c=this;return _.x(function*(){if(0<c.a.length&&Wy(c,a)&&(b||c.f!==a)){c.f=a;var d=c.Sc();d&&(yield c.l(d),yield c.m.load(d.configuration),
3
+ c.trigger(new _.E(_.ef,{item:d})))}})}append(a){this.a.push(a);Xy(this)}Og(a,b){if(0<=b&&b<=this.a.length){const c=this.Sc();this.a.splice(b,0,a);c&&(this.f=this.a.indexOf(c));Xy(this)}}remove(a){if(0<this.a.length&&Wy(this,a)){if(this.f===a)throw Error("Can't remove the current item");this.a.splice(a,1);Xy(this)}}clear(){this.stop();this.f=0;this.a=[];this.h=!1;Xy(this)}};_.z("clpp.Playlist",Yy);Yy.prototype.clear=Yy.prototype.clear;Yy.prototype.remove=Yy.prototype.remove;Yy.prototype.insert=Yy.prototype.Og;
4
+ Yy.prototype.append=Yy.prototype.append;Yy.prototype.goTo=Yy.prototype.yd;Yy.prototype.previous=Yy.prototype.hh;Yy.prototype.next=Yy.prototype.next;Yy.prototype.onEnded=Yy.prototype.Wa;Yy.prototype.stop=Yy.prototype.stop;Yy.prototype.start=Yy.prototype.start;Yy.prototype.isStarted=Yy.prototype.Qg;Yy.prototype.getUpcoming=Yy.prototype.Fg;Yy.prototype.getCurrent=Yy.prototype.Sc;Yy.prototype.getQueue=Yy.prototype.Eg;Yy.prototype.getPosition=Yy.prototype.getPosition;Yy.prototype.off=Yy.prototype.off;
5
+ Yy.prototype.one=Yy.prototype.one;Yy.prototype.on=Yy.prototype.on;};f.call(g, window);
package/cl.sessions.js CHANGED
@@ -1,10 +1,10 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Hx="apiUrl config is missing",Ix=function(a,b){a.j=a.j.filter(c=>c!==b)},Jx=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},Ox=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Nf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){Kx(a,b<<3|2);b=new Lx;for(let e=0;e<c.length;e++)d(b,c[e]);Mx(a,b.length());Nx(a,b.end())}else Kx(a,
2
- b<<3|0),d(a,c)},Mx=function(a,b){if(0<=b)Kx(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},Px=function(a,b,c){Ox(a,b,c,(d,e)=>{Mx(d,e)})},Kx=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},Rx=function(a,b,c){Ox(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=Jx(e);Qx(d,f,g)}}else{{const [f,g]=Jx(e);Qx(d,f,g)}}})},Sx=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Nf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
- 0;e<c.length;e++){Kx(a,b<<3|2);const f=new Lx;d(f,c[e]);Mx(a,f.length());Nx(a,f.end())}else Kx(a,b<<3|2),b=new Lx,d(b,c),Mx(a,b.length()),Nx(a,b.end())},Tx=function(a,b,c){Sx(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
- 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},Nx=function(a,b){a.a.push.apply(a.a,b)},Ux=function(a,b,c){Sx(a,b,c,(d,e)=>{Nx(d,e.a())})},Vx=function(a,b,c){Sx(a,b,c,(d,e)=>{Nx(d,e)})},Qx=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},Xx=function(a){const b=new Wx;b.g=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},ay=function(a){return _.x(function*(){if(!a.j&&!a.f){0===a.a.length&&Yx(a,new Zx);var b=()=>
5
- {};a.f=new Promise(c=>{b=c});try{const c=new $x;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:"POST",headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},dy=function(a,b,c,d,e,f,g){const h=new by;h.headers=[new cy("CL-BROWSER-NAME",b),new cy("CL-BROWSER-VERSION",
6
- c),new cy("CL-OS-FAMILY",d),new cy("CL-OS-VERSION",e),new cy("CL-SDK-NAME",f),new cy("CL-SDK-NAME",f),new cy("CL-SDK-VERSION",g)];Yx(a,h)},Yx=function(a,b){if(!a.j){var c=new ey(a.w);c.sessionId=a.A;{var d=Date.now();const e=new fy;e.g=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.g=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},gy=function(a){_.x(function*(){a.h.info("Destroy the session and stop sending events.");_.mh(a.f);a.a=!1;const b=a.m.getNetworkEngine();b.we(a.o);b.ed(a.j);Ix(b,a.j);
7
- a.g&&(yield a.g.dispose(),a.g=null)})},oy=function(a){switch(a){case _.Tn:return hy;case _.Un:return iy;case _.On:return jy;case _.Wn:return ky;case _.Vn:return ly;case _.Ln:return my;case _.Sn:return ny;default:return null}},py=function(a,b){a.h.debug("Sending event",b);Yx(a.g,b)},xy=function(a,b){switch(a){case 1:return qy;case 2:return b===_.w?ry:b===_.p?sy:b===_.G?ty:b===_.be?uy:vy;case 3:return wy;default:return vy}};var Lx=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var yy=class{constructor(a,b,c,d){this.downloadId=a;this.g=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new Lx;Ux(a,1,this.downloadId);Px(a,2,this.g);Ux(a,3,this.duration);Px(a,4,this.j);Ux(a,5,this.f);return a.end()}getId(){return 4}};var zy=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new Lx;Px(a,1,this.f);Ux(a,2,this.downloadId);Tx(a,3,this.url);Ux(a,4,this.headers);Tx(a,5,null);Ux(a,6,null);Ux(a,7,this.duration);Rx(a,8,this.size);return a.end()}getId(){return 2}};var Ay=class{constructor(a,b){this.g=a;this.f=b}a(){const a=new Lx;Px(a,1,this.g);Vx(a,2,this.f);return a.end()}};var By=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new Lx;Px(a,1,this.errorCode);Px(a,2,this.severity);Tx(a,3,this.message);Tx(a,4,this.f);Ux(a,5,this.cause);return a.end()}getId(){return 7}};var cy=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new Lx;Tx(a,1,this.key);Tx(a,2,this.value);return a.end()}};var Cy=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new Lx;Px(a,1,this.code);Px(a,2,this.severity);Ux(a,3,this.cause);return a.end()}getId(){return 12}};var Dy=class{constructor(){this.data=null}a(){const a=new Lx;Vx(a,1,this.data);return a.end()}};var Ey=class extends Dy{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var by=class{constructor(){this.headers=[]}a(){const a=new Lx;Ux(a,1,this.headers);return a.end()}getId(){return 1}};var Zx=class{constructor(){}a(){return(new Lx).end()}getId(){return 6}};var ey=class{constructor(a){this.j=a;this.f=this.g=this.time=this.sessionId=null}a(){const a=new Lx;Ux(a,1,this.j);Ux(a,2,this.sessionId);Ux(a,3,this.time);Rx(a,4,null);Tx(a,5,null);Px(a,6,this.g);Vx(a,7,this.f);return a.end()}};var $x=class{constructor(){this.f=null;this.events=[]}a(){const a=new Lx;Vx(a,1,this.f);Ux(a,2,this.events);return a.end()}};var fy=class{constructor(){this.f=this.g=null}a(){const a=new Lx;Rx(a,1,this.g);Px(a,2,this.f);return a.end()}};var Wx=class{constructor(){this.f=this.g=null}a(){const a=new Lx;Rx(a,1,this.g);Px(a,2,this.f);return a.end()}};var Fy=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new Ey;this.A=new Ey;this.a=[];this.g=setInterval(()=>ay(this),k);this.f=null;this.j=!1;dy(this,b,c,d,e,f,g)}dispose(){const a=this;return _.x(function*(){a.g&&(clearInterval(a.g),a.g=null);a.f&&(yield a.f);0<a.a.length&&(yield ay(a),a.a=[]);a.j=!0})}};var Gy=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new Lx;Px(a,1,this.previousState);Px(a,2,this.currentState);Px(a,3,this.reason);Ux(a,4,null);Ux(a,5,null);Ux(a,6,null);return a.end()}getId(){return 5}};var Ky=class extends _.pu{constructor(){super();this.m=null;this.a=this.l=!1;this.f=new _.hs;this.g=null;this.h=new _.R("clpp.sessions.SessionsPlugin");this.o=this.F.bind(this);this.j=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.De))||this.h.warn("Sessions plugin is loaded but not configured. Will do nothing.");if(this.l=b)b=a.getConfiguration().sessions,b.apiUrl?(this.h.debug(_.sa),this.h.info("Create a session and start sending events."),
8
- a=_.sk(),this.g=new Fy(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.fa,b.apiUrl),this.f.on(this.m,_.Kf,this.B.bind(this)),this.f.on(this.m,_.Cf,this.A.bind(this)),this.f.on(this.m,_.Bf,this.w.bind(this)),this.f.on(this.m,_.r,this.U.bind(this)),a=this.m.getNetworkEngine(),a.Nd(this.o),a.qc(this.j),a.j.push(this.j)):(this.h.warn(Hx),a.onError(new _.H(1,9,15E3,Hx)))}onPlayerWillRelease(){gy(this)}id(){return"sessions"}B(a){if(!this.a){a=a.detail;var b=a.currentState,
9
- c=new Gy;c.previousState=oy(a.previousState);c.currentState=oy(b);py(this,c)}}A(){if(!this.a){var a=new Gy;a.previousState=oy(this.m.getState());a.currentState=Hy;py(this,a);this.a=!0}}w(){if(this.a){var a=new Gy;a.previousState=Hy;a.currentState=oy(this.m.getState());py(this,a);this.a=!1}}U(a){a=a.detail;var b=new Cy;b=new By(new Ay(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.F?Iy:Jy;py(this,b)}F(a){const b=new Ey;a.downloadId=b;
10
- const c=new zy(xy(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new cy(d,a.headers[d]));py(this,c)}C(a){var b=a.request.downloadId;b?(b=new yy(b,a.data.byteLength,Xx(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new cy(c,a.headers[c])),py(this,b)):this.h.warn("Download ID is missing on download completed event.")}};_.Yo(new class{create(){return new Ky}});var Jy=1,Iy=2;var hy=0,iy=2,ny=3,Hy=5,jy=6,ky=8,ly=10,my=11;var qy=0,ry=1,sy=2,ty=3,uy=4,wy=5,vy=9;};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Sx="apiUrl config is missing",Tx=function(a,b){a.j=a.j.filter(c=>c!==b)},Ux=function(a){let b=0>a;a=Math.abs(a);let c=a>>>0;a=Math.floor((a-c)/4294967296);a>>>=0;b&&(a=~a>>>0,c=(~c>>>0)+1,4294967295<c&&(c=0,a++,4294967295<a&&(a=0)));return[c,a]},Zx=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Qf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c)){Vx(a,b<<3|2);b=new Wx;for(let e=0;e<c.length;e++)d(b,c[e]);Xx(a,b.length());Yx(a,b.end())}else Vx(a,
2
+ b<<3|0),d(a,c)},Xx=function(a,b){if(0<=b)Vx(a,b);else{for(let c=0;9>c;c++)a.a.push(b&127|128),b>>=7;a.a.push(1)}},$x=function(a,b,c){Zx(a,b,c,(d,e)=>{Xx(d,e)})},Vx=function(a,b){for(;127<b;)a.a.push(b&127|128),b>>>=7;a.a.push(b)},by=function(a,b,c){Zx(a,b,c,(d,e)=>{if(0<=e){{const [f,g]=Ux(e);ay(d,f,g)}}else{{const [f,g]=Ux(e);ay(d,f,g)}}})},cy=function(a,b,c,d){if(!(null===c||void 0===c||typeof c===_.t&&0===c||typeof c===_.Qf&&0===c.length||Array.isArray(c)&&0===c.length))if(Array.isArray(c))for(let e=
3
+ 0;e<c.length;e++){Vx(a,b<<3|2);const f=new Wx;d(f,c[e]);Xx(a,f.length());Yx(a,f.end())}else Vx(a,b<<3|2),b=new Wx,d(b,c),Xx(a,b.length()),Yx(a,b.end())},dy=function(a,b,c){cy(a,b,c,(d,e)=>{for(let f=0;f<e.length;f++){let g=e.charCodeAt(f);if(128>g)d.a.push(g);else if(2048>g)d.a.push(g>>6|192),d.a.push(g&63|128);else if(65536>g)if(55296<=g&&56319>=g&&f+1<e.length){let h=e.charCodeAt(f+1);56320<=h&&57343>=h&&(g=1024*(g-55296)+h-56320+65536,d.a.push(g>>18|240),d.a.push(g>>12&63|128),d.a.push(g>>6&63|
4
+ 128),d.a.push(g&63|128),f++)}else d.a.push(g>>12|224),d.a.push(g>>6&63|128),d.a.push(g&63|128)}})},Yx=function(a,b){a.a.push.apply(a.a,b)},ey=function(a,b,c){cy(a,b,c,(d,e)=>{Yx(d,e.a())})},fy=function(a,b,c){cy(a,b,c,(d,e)=>{Yx(d,e)})},ay=function(a,b,c){for(;0<c||127<b;)a.a.push(b&127|128),b=(b>>>7|c<<25)>>>0,c>>>=7;a.a.push(b)},hy=function(a){const b=new gy;b.h=Math.floor(a/1E3);b.f=a%1E3*1E6;return b},ly=function(a){return _.x(function*(){if(!a.j&&!a.f){0===a.a.length&&iy(a,new jy);var b=()=>
5
+ {};a.f=new Promise(c=>{b=c});try{const c=new ky;c.f=a.o;c.events.push(...a.a);const d=[...a.a],e=yield fetch(a.l,{method:_.ub,headers:{"Content-Type":"application/proto"},body:new Uint8Array(c.a())});if(e.ok)a.a=a.a.filter(f=>!d.includes(f));else throw Error("An error occurred while sending telemetry events to the API, "+`status='${e.status}' statusText='${e.statusText}'`);}finally{b(),a.f=null}}})},oy=function(a,b,c,d,e,f,g){const h=new my;h.headers=[new ny("CL-BROWSER-NAME",b),new ny("CL-BROWSER-VERSION",
6
+ c),new ny("CL-OS-FAMILY",d),new ny("CL-OS-VERSION",e),new ny("CL-SDK-NAME",f),new ny("CL-SDK-NAME",f),new ny("CL-SDK-VERSION",g)];iy(a,h)},iy=function(a,b){if(!a.j){var c=new py(a.w);c.sessionId=a.A;{var d=Date.now();const e=new qy;e.h=Math.floor(d/1E3);e.f=d%1E3*1E6;d=e}c.time=d;c.h=b.getId();c.f=new Uint8Array(b.a());a.a.push(c)}},ry=function(a){_.x(function*(){a.g.info("Destroy the session and stop sending events.");_.ph(a.f);a.a=!1;const b=a.m.getNetworkEngine();b.ye(a.o);b.gd(a.j);Tx(b,a.j);
7
+ a.h&&(yield a.h.dispose(),a.h=null)})},zy=function(a){switch(a){case _.Wn:return sy;case _.Xn:return ty;case _.Rn:return uy;case _.Zn:return vy;case _.Yn:return wy;case _.On:return xy;case _.Vn:return yy;default:return null}},Ay=function(a,b){a.g.debug("Sending event",b);iy(a.h,b)},Iy=function(a,b){switch(a){case 1:return By;case 2:return b===_.w?Cy:b===_.p?Dy:b===_.G?Ey:b===_.de?Fy:Gy;case 3:return Hy;default:return Gy}};var Wx=class{constructor(){this.a=[]}length(){return this.a.length}end(){const a=this.a;this.a=[];return a}};var Jy=class{constructor(a,b,c,d){this.downloadId=a;this.h=b;this.duration=c;this.j=d;this.f=[]}a(){const a=new Wx;ey(a,1,this.downloadId);$x(a,2,this.h);ey(a,3,this.duration);$x(a,4,this.j);ey(a,5,this.f);return a.end()}getId(){return 4}};var Ky=class{constructor(a,b){this.f=a;this.url=b;this.downloadId=null;this.headers=[];this.size=this.duration=null}a(){const a=new Wx;$x(a,1,this.f);ey(a,2,this.downloadId);dy(a,3,this.url);ey(a,4,this.headers);dy(a,5,null);ey(a,6,null);ey(a,7,this.duration);by(a,8,this.size);return a.end()}getId(){return 2}};var Ly=class{constructor(a,b){this.h=a;this.f=b}a(){const a=new Wx;$x(a,1,this.h);fy(a,2,this.f);return a.end()}};var My=class{constructor(a){this.cause=a;this.f=this.message=this.severity=this.errorCode=null}a(){const a=new Wx;$x(a,1,this.errorCode);$x(a,2,this.severity);dy(a,3,this.message);dy(a,4,this.f);ey(a,5,this.cause);return a.end()}getId(){return 7}};var ny=class{constructor(a,b){this.key=a;this.value=b}a(){const a=new Wx;dy(a,1,this.key);dy(a,2,this.value);return a.end()}};var Ny=class{constructor(){this.cause=this.severity=this.code=null}a(){const a=new Wx;$x(a,1,this.code);$x(a,2,this.severity);ey(a,3,this.cause);return a.end()}getId(){return 12}};var Oy=class{constructor(){this.data=null}a(){const a=new Wx;fy(a,1,this.data);return a.end()}};var Py=class extends Oy{constructor(){super();var a=new Uint8Array(16);crypto.getRandomValues(a);a[6]=a[6]&15|64;a[8]=a[8]&63|128;this.data=a}toString(){const a=[];for(let b=0;256>b;++b)a.push((b+256).toString(16).slice(1));return a[this.data[0]]+a[this.data[1]]+a[this.data[2]]+a[this.data[3]]+"-"+a[this.data[4]]+a[this.data[5]]+"-"+a[this.data[6]]+a[this.data[7]]+"-"+a[this.data[8]]+a[this.data[9]]+"-"+a[this.data[10]]+a[this.data[11]]+a[this.data[12]]+a[this.data[13]]+a[this.data[14]]+a[this.data[15]]}};var my=class{constructor(){this.headers=[]}a(){const a=new Wx;ey(a,1,this.headers);return a.end()}getId(){return 1}};var jy=class{constructor(){}a(){return(new Wx).end()}getId(){return 6}};var py=class{constructor(a){this.j=a;this.f=this.h=this.time=this.sessionId=null}a(){const a=new Wx;ey(a,1,this.j);ey(a,2,this.sessionId);ey(a,3,this.time);by(a,4,null);dy(a,5,null);$x(a,6,this.h);fy(a,7,this.f);return a.end()}};var ky=class{constructor(){this.f=null;this.events=[]}a(){const a=new Wx;fy(a,1,this.f);ey(a,2,this.events);return a.end()}};var qy=class{constructor(){this.f=this.h=null}a(){const a=new Wx;by(a,1,this.h);$x(a,2,this.f);return a.end()}};var gy=class{constructor(){this.f=this.h=null}a(){const a=new Wx;by(a,1,this.h);$x(a,2,this.f);return a.end()}};var Qy=class{constructor(a,b,c,d,e,f,g,h,k){k=void 0===k?2500:k;this.o=a;this.l=h;this.w=new Py;this.A=new Py;this.a=[];this.h=setInterval(()=>ly(this),k);this.f=null;this.j=!1;oy(this,b,c,d,e,f,g)}dispose(){const a=this;return _.x(function*(){a.h&&(clearInterval(a.h),a.h=null);a.f&&(yield a.f);0<a.a.length&&(yield ly(a),a.a=[]);a.j=!0})}};var Ry=class{constructor(){this.reason=this.currentState=this.previousState=null}a(){const a=new Wx;$x(a,1,this.previousState);$x(a,2,this.currentState);$x(a,3,this.reason);ey(a,4,null);ey(a,5,null);ey(a,6,null);return a.end()}getId(){return 5}};var Vy=class extends _.Au{constructor(){super();this.m=null;this.a=this.l=!1;this.f=new _.ts;this.h=null;this.g=new _.R("clpp.sessions.SessionsPlugin");this.o=this.F.bind(this);this.j=this.C.bind(this)}onPlayerCreated(a){this.m=a}onContentWillLoad(a){var b=a.getConfiguration().sessions;(b=!(!b||typeof b!==_.Fe))||this.g.warn("Sessions plugin is loaded but not configured. Will do nothing.");if(this.l=b)b=a.getConfiguration().sessions,b.apiUrl?(this.g.debug(_.sa),this.g.info("Create a session and start sending events."),
8
+ a=_.vk(),this.h=new Qy(new Uint8Array([]),a.browser,a.browserVersion.name,a.os,a.osVersion.name,"prestoplay-web",_.fa,b.apiUrl),this.f.on(this.m,_.Nf,this.B.bind(this)),this.f.on(this.m,_.Ff,this.A.bind(this)),this.f.on(this.m,_.Ef,this.w.bind(this)),this.f.on(this.m,_.r,this.U.bind(this)),a=this.m.getNetworkEngine(),a.Rd(this.o),a.tc(this.j),a.j.push(this.j)):(this.g.warn(Sx),a.onError(new _.H(1,9,15E3,Sx)))}onPlayerWillRelease(){ry(this)}id(){return"sessions"}B(a){if(!this.a){a=a.detail;var b=a.currentState,
9
+ c=new Ry;c.previousState=zy(a.previousState);c.currentState=zy(b);Ay(this,c)}}A(){if(!this.a){var a=new Ry;a.previousState=zy(this.m.getState());a.currentState=Sy;Ay(this,a);this.a=!0}}w(){if(this.a){var a=new Ry;a.previousState=Sy;a.currentState=zy(this.m.getState());Ay(this,a);this.a=!1}}U(a){a=a.detail;var b=new Ny;b=new My(new Ly(b.getId(),new Uint8Array(b.a())));b.errorCode=a.code;b.message=a.message;b.f=a.stack;b.severity=a.severity===_.F?Ty:Uy;Ay(this,b)}F(a){const b=new Py;a.downloadId=b;
10
+ const c=new Ky(Iy(a.type,a.contentType),a.uris[0]);c.downloadId=b;c.headers=Object.keys(a.headers).map(d=>new ny(d,a.headers[d]));Ay(this,c)}C(a){var b=a.request.downloadId;b?(b=new Jy(b,a.data.byteLength,hy(a.timeMs||0),a.status||-1),b.f=Object.keys(a.headers).map(c=>new ny(c,a.headers[c])),Ay(this,b)):this.g.warn("Download ID is missing on download completed event.")}};_.dp(new class{create(){return new Vy}});var Uy=1,Ty=2;var sy=0,ty=2,yy=3,Sy=5,uy=6,vy=8,wy=10,xy=11;var By=0,Cy=1,Dy=2,Ey=3,Fy=4,Hy=5,Gy=9;};f.call(g, window);
package/cl.simid.js CHANGED
@@ -1,13 +1,13 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var qx="No surface found. Can not attach frame!",rx="SIMID:Media:timeupdate",sx="Starting creative",tx=function(a,b,c){return{type:b,sessionId:a.g,messageId:a.l++,timestamp:Date.now(),args:c}},wx=function(a,b){return new Promise((c,d)=>{new ux(a.j,c,d,b);vx(a,b)})},xx=function(a){const b=tx(a,"SIMID:Player:startCreative",void 0);wx(a,b).then(()=>{var c=a.f;c.h.info(sx);c.m.trigger(new _.E(_.Ef));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.h.error("Error while starting creative",
2
- c)})},zx=function(a,b){_.x(function*(){a.g=b.sessionId;yx(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
- !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=tx(a,"SIMID:Player:init",d);var e=wx(a,f)}yield e;a.h.info("Player Init acknowledged");a.f.h.info("SIMID Player initialized")}catch(f){a.h.error("Error while initializing",f),a.f.h.error("Error while initializing SIMID player: ",f),a.unload()}})},yx=function(a,b){vx(a,tx(a,"resolve",{messageId:b.messageId,
4
- value:void 0}))},vx=function(a,b){a.g?(b.type!==rx&&a.h.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.h.warn(`WARNING: no session available to send message '${b.type}'`)},Ax=function(a,b,c){return new ResizeObserver(()=>{if(a.a.g){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
- e=tx(d,"SIMID:Player:resize",e);vx(d,e)}})},Bx=function(a,b){a.h.info("SIMID Session created");a.a=b},Cx=function(a){a.h.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
- "";a.g=!1;a.m.trigger(new _.E(_.Ff))},Dx=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},Ex=class{constructor(a){this.f=a;this.g="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";this.a.style.border=_.Ce;this.a.style.backgroundColor="transparent";this.a.style.transition="opacity .5s";this.a.style.transitionDelay=".5s";this.a.style.pointerEvents=
7
- _.Ce;this.a.style.overflow=_.$d;this.a.classList.add(_.ed);this.o=b=>{if(b.source===this.a.contentWindow&&(b=(b=b.data)?typeof b===_.Nf?JSON.parse(b):b:null))if(b.type)switch(this.h.info(`Received message [${b.messageId}] '${b.type}':`,b.args),b.type){case "createSession":zx(this,b);break;case "resolve":b=b.args;var c=this.j.get(b.messageId);c&&c.resolve(b);break;case "reject":b=b.args;(c=this.j.get(b.messageId))&&c.reject(b);break;case "SIMID:Creative:requestResize":c=this.f;var d=b.args;c.h.info("Creative requested resize",
8
- d);if(c.m&&c.m.getSurface()&&c.m.getSurface().getMedia()&&d.mediaDimensions){c.g?c.m.getSurface().getMedia().style.transition="":(c.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",c.g=!0);const e=Dx(c,d.mediaDimensions);c.m.getSurface().getMedia().style.left=e.left;c.m.getSurface().getMedia().style.top=e.top;c.m.getSurface().getMedia().style.width=e.width;c.m.getSurface().getMedia().style.height=e.height}d.creativeDimensions&&(d=Dx(c,d.creativeDimensions),c.a.a.style.left=
9
- d.left,c.a.a.style.top=d.top,c.a.a.style.width=d.width,c.a.a.style.height=d.height);yx(this,b)}else this.h.warn("WARNING: received message without 'type' property")};this.h=new _.R("clpp.simid.SimidPlayer");Bx(this.f,this)}load(a){window.addEventListener(_.ve,this.o);this.g="";this.l=0;const b=this.f.url();this.h.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.h.info("Attaching iFrame");a.appendChild(this.a)}unload(){Cx(this.f);this.g=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.ve,
10
- this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},ux=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.g=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.g.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.g.messageId);this.j(a)}};var Gx=class extends _.pu{constructor(){super();this.h=new _.R("clpp.simid.Plugin");this.g=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.h.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.g&&this.g.release();this.g=new Fx(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length)if(this.l=b.simid.creatives,this.h.info(`Setting up SIMID plugin for ${this.l.length} creatives`),
11
- b=this.m.getSurface()){this.h.info("Creating new session");this.a=new Ex(this.g);var c=b.getContainer();this.j=Ax(this,c,b);this.j.observe(c);a.on(_.Uf,this.w)}else this.h.warn(qx)}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(xx(this.a),this.o=!0,this.h.info(sx)),
12
- c&&(c=this.a,vx(c,tx(c,rx,{currentTime:a-b}))))):((a=this.m.getSurface())||this.h.warn(qx),a=a.getContainer(),this.f=b,this.o=!1,this.h.info("Loading session"),this.g.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.Uf,this.w),this.f&&(this.a.unload(),this.f=this.g.f=null))}},Fx=class{constructor(a){this.m=a;this.a=null;this.h=new _.R("clpp.simid.Loader");
13
- this.g=!1;this.f=null}release(){this.h.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.h.error("No player container found. Can not create SIMID init data"),new _.H(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.h.error("No player surface found. Can not create SIMID init data"),new _.H(1,10,10100,"No surface");return a}url(){return this.f?this.f.url:""}};_.Yo(new class{create(){return new Gx}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Bx="No surface found. Can not attach frame!",Cx="SIMID:Media:timeupdate",Dx="Starting creative",Ex=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),args:c}},Hx=function(a,b){return new Promise((c,d)=>{new Fx(a.j,c,d,b);Gx(a,b)})},Ix=function(a){const b=Ex(a,"SIMID:Player:startCreative",void 0);Hx(a,b).then(()=>{var c=a.f;c.g.info(Dx);c.m.trigger(new _.E(_.Hf));a.a.style.opacity="1"}).catch(c=>{a.unload();a.f.g.error("Error while starting creative",
2
+ c)})},Kx=function(a,b){_.x(function*(){a.h=b.sessionId;Jx(a,b);try{{var c=a.f;const f=c.getSurface(),g=c.getContainer();var d={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:c.m.isMuted()||
3
+ !1,volume:c.m.getVolume()||0,navigationSupport:"adHandles",closeButtonSupport:"adHandles",nonlinearDuration:c.f.duration},creativeData:{adParameters:c.f.adParameters||"",clickThruUri:"",clickThruUrl:""}}}{const f=Ex(a,"SIMID:Player:init",d);var e=Hx(a,f)}yield e;a.g.info("Player Init acknowledged");a.f.g.info("SIMID Player initialized")}catch(f){a.g.error("Error while initializing",f),a.f.g.error("Error while initializing SIMID player: ",f),a.unload()}})},Jx=function(a,b){Gx(a,Ex(a,"resolve",{messageId:b.messageId,
4
+ value:void 0}))},Gx=function(a,b){a.h?(b.type!==Cx&&a.g.info(`Posting message [${b.messageId}] '${b.type}':`,b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn(`WARNING: no session available to send message '${b.type}'`)},Lx=function(a,b,c){return new ResizeObserver(()=>{if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};
5
+ e=Ex(d,"SIMID:Player:resize",e);Gx(d,e)}})},Mx=function(a,b){a.g.info("SIMID Session created");a.a=b},Nx=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(()=>{a.m.getSurface().getMedia().style.transition=""},500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height=
6
+ "";a.h=!1;a.m.trigger(new _.E(_.If))},Ox=function(a,b){var c=a.getContainer();a=c.clientWidth;c=c.clientHeight;return{top:`${b.y/c*100}%`,left:`${b.x/a*100}%`,width:`${b.width/a*100}%`,height:`${b.height/c*100}%`}},Px=class{constructor(a){this.f=a;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";this.a.style.border=_.Ee;this.a.style.backgroundColor="transparent";this.a.style.transition="opacity .5s";this.a.style.transitionDelay=".5s";this.a.style.pointerEvents=
7
+ _.Ee;this.a.style.overflow=_.$d;this.a.classList.add(_.ed);this.o=b=>{if(b.source===this.a.contentWindow&&(b=(b=b.data)?typeof b===_.Qf?JSON.parse(b):b:null))if(b.type)switch(this.g.info(`Received message [${b.messageId}] '${b.type}':`,b.args),b.type){case "createSession":Kx(this,b);break;case "resolve":b=b.args;var c=this.j.get(b.messageId);c&&c.resolve(b);break;case "reject":b=b.args;(c=this.j.get(b.messageId))&&c.reject(b);break;case "SIMID:Creative:requestResize":c=this.f;var d=b.args;c.g.info("Creative requested resize",
8
+ d);if(c.m&&c.m.getSurface()&&c.m.getSurface().getMedia()&&d.mediaDimensions){c.h?c.m.getSurface().getMedia().style.transition="":(c.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",c.h=!0);const e=Ox(c,d.mediaDimensions);c.m.getSurface().getMedia().style.left=e.left;c.m.getSurface().getMedia().style.top=e.top;c.m.getSurface().getMedia().style.width=e.width;c.m.getSurface().getMedia().style.height=e.height}d.creativeDimensions&&(d=Ox(c,d.creativeDimensions),c.a.a.style.left=
9
+ d.left,c.a.a.style.top=d.top,c.a.a.style.width=d.width,c.a.a.style.height=d.height);Jx(this,b)}else this.g.warn("WARNING: received message without 'type' property")};this.g=new _.R("clpp.simid.SimidPlayer");Mx(this.f,this)}load(a){window.addEventListener(_.xe,this.o);this.h="";this.l=0;const b=this.f.url();this.g.info(`Loading "${b}" as src of iFrame`);this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)}unload(){Nx(this.f);this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.xe,
10
+ this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)}},Fx=class{constructor(a,b,c,d,e){e=void 0===e?-1:e;this.f=a;this.l=b;this.j=c;this.h=d;this.a=null;this.f.set(d.messageId,this);0<=e&&(this.a=setTimeout(()=>{this.resolve()},e))}resolve(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.l(a)}reject(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f.delete(this.h.messageId);this.j(a)}};var Rx=class extends _.Au{constructor(){super();this.g=new _.R("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.A.bind(this);this.f=null;this.o=!1}id(){return"simid"}onPlayerCreated(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new Qx(a)}onContentWillLoad(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length)if(this.l=b.simid.creatives,this.g.info(`Setting up SIMID plugin for ${this.l.length} creatives`),
11
+ b=this.m.getSurface()){this.g.info("Creating new session");this.a=new Px(this.h);var c=b.getContainer();this.j=Lx(this,c,b);this.j.observe(c);a.on(_.Xf,this.w)}else this.g.warn(Bx)}A(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b];const d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(Ix(this.a),this.o=!0,this.g.info(Dx)),
12
+ c&&(c=this.a,Gx(c,Ex(c,Cx,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(Bx),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)}onPlayerWillRelease(a){super.onPlayerWillRelease(a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.Xf,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))}},Qx=class{constructor(a){this.m=a;this.a=null;this.g=new _.R("clpp.simid.Loader");
13
+ this.h=!1;this.f=null}release(){this.g.info("Releasing loader")}getContainer(){const a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.H(1,10,10100,"No player container found");return a}getSurface(){const a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.H(1,10,10100,"No surface");return a}url(){return this.f?this.f.url:""}};_.dp(new class{create(){return new Rx}});};f.call(g, window);