@castlabs/prestoplay 6.7.0 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cjs/cl.adobe.js +3 -3
  3. package/cjs/cl.airplay.js +3 -3
  4. package/cjs/cl.broadpeak.js +6 -6
  5. package/cjs/cl.cast.js +110 -110
  6. package/cjs/cl.conviva.js +33 -33
  7. package/cjs/cl.core.js +416 -417
  8. package/cjs/cl.crypto.js +9 -9
  9. package/cjs/cl.dash.js +72 -72
  10. package/cjs/cl.externs.js +26 -26
  11. package/cjs/cl.freewheel.js +23 -23
  12. package/cjs/cl.hls.js +67 -67
  13. package/cjs/cl.hlssmpte.js +6 -6
  14. package/cjs/cl.htmlcue.js +31 -31
  15. package/cjs/cl.ima.js +23 -23
  16. package/cjs/cl.mse.js +270 -259
  17. package/cjs/cl.muxdata.js +15 -11
  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.smooth.js +70 -70
  22. package/cjs/cl.thumbnails.js +24 -24
  23. package/cjs/cl.tizen.js +69 -69
  24. package/cjs/cl.ttml.js +27 -27
  25. package/cjs/cl.verimatrix.js +5 -5
  26. package/cjs/cl.vimond.js +13 -13
  27. package/cjs/cl.vr.js +19 -19
  28. package/cjs/cl.vtt.js +14 -14
  29. package/cjs/cl.youbora.js +18 -18
  30. package/cl.adobe.js +3 -3
  31. package/cl.airplay.js +3 -3
  32. package/cl.broadpeak.js +5 -5
  33. package/cl.cast.js +86 -86
  34. package/cl.conviva.js +27 -27
  35. package/cl.core.js +355 -360
  36. package/cl.crypto.js +8 -8
  37. package/cl.dash.js +66 -66
  38. package/cl.externs.js +26 -26
  39. package/cl.freewheel.js +19 -19
  40. package/cl.hls.js +58 -57
  41. package/cl.hlssmpte.js +5 -5
  42. package/cl.htmlcue.js +25 -25
  43. package/cl.ima.js +17 -17
  44. package/cl.mse.js +237 -227
  45. package/cl.muxdata.js +12 -9
  46. package/cl.onboard.js +4 -4
  47. package/cl.persistent.js +9 -9
  48. package/cl.playlist.js +5 -5
  49. package/cl.smooth.js +58 -58
  50. package/cl.thumbnails.js +17 -17
  51. package/cl.tizen.js +57 -57
  52. package/cl.ttml.js +22 -22
  53. package/cl.verimatrix.js +4 -4
  54. package/cl.vimond.js +8 -8
  55. package/cl.vr.js +15 -15
  56. package/cl.vtt.js +12 -12
  57. package/cl.youbora.js +14 -14
  58. package/package.json +1 -1
  59. package/typings.d.ts +47 -20
package/cl.tizen.js CHANGED
@@ -1,57 +1,57 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var CE="An unknown error occurred while trying to get volume",DE="Cannot get loading rendition due to platform limitations",EE="SecurityError",FE="The require privilege is: http://tizen.org/privilege/tv.audio",GE="|STARTBITRATE\x3d",HE=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},KE=function(a){return _.y(function*(){if(a.a!==_.Kc&&a.a!==_.Jc)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.Ic)throw new _.H(_.G,6,6012,`No license server given for ${a.a}`);try{a.a===_.Kc?yield IE(a):yield JE(a,b),a.o={keySystem:a.a,licenseServerUri:b.Ic,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Pd,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)});}})},ME=function(a,b){_.y(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=_.kh([b.serverurl&&""!==b.serverurl?b.serverurl:c.Ic],_.hh());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.wb.fetch(c).P;if(a.j){var g=_.I(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(LE,"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:_.za,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},IE=function(a){return _.y(function*(){try{webapis.avplay.setDrm(LE,"Initialize",""),webapis.avplay.setDrm(LE,
5
- "widevine_app_session",a.m.id),webapis.avplay.setDrm(LE,"widevine_data_type",a.m.type)}catch(b){throw b;}})},JE=function(a,b){return _.y(function*(){var c={};c[NE]=!b.Pd;c[OE]=b.Ic;""!==b.customData&&(c[PE]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(QE,"SetProperties",c)}catch(d){throw d;}})},SE=function(a,b){if(a.f!==b)if(a.f===_.Ol&&b!==_.Pl)a.g.debug(_.Pt+`${RE(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.Kl?(a.o=(new Date).getTime(),
6
- a.l.trigger(new _.F(_.nc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.Kl&&a.l.trigger(new _.F(_.jc,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.F(_.ke,{detail:b}));a.g.debug("State changed:",RE(a.j),"-\x3e",RE(a.f))}},RE=function(a){return Object.keys(_.Nl)[a]},VE=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case TE:c=_.Sl;break;case UE:c=_.Rl;break;default:a.l.isEnded()?c=_.Hl:a.g.debug("Inconsistent AVPlay playback state:",
7
- b)}SE(a,c)}},WE=function(a){return _.y(function*(){const b=a.l.getConfiguration();let c;(c=yield _.Hn(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},XE=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},YE=function(a){const b=document.createElement(_.w),c=new _.zy,d=new _.oy(()=>null),e=a.l.getTextDisplayer();return new _.Ay(b,c,e,d,a.l.getConfiguration())},ZE=function(a){const b=
8
- {rb:()=>a.l.getPosition(),Z:a.h,wb:a.l.getNetworkEngine(),Md:a.F.bind(a),Ld:a.C.bind(a),onError:a.T.bind(a),De:()=>{},onEvent:()=>{},He:a.G.bind(a),dd:()=>{},td:()=>new _.Ry,kd:()=>!1,Cc:null};return new _.tz(a.f,b)},$E=function(a){const b=a.l.getPosition();let c=null;for(const d of a.f.periods)d.startTime<=b&&(c=d);return c},aF=function(a){a.a.debug("getTextStreams()",a.f);if(a.f){var b=[],c=a.f.periods;a.a.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.a.debug(c[d].startTime,a.l.getPosition()),
9
- c[d].startTime<=a.l.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.yh(String(c++),_.J);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.iu;const f=new _.Gh(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},bF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){const b=_.rx(a.g,_.v);let c=null;if(b){a=aF(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},cF=function(a,b){a.a.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.f&&a.g)){a.setTextVisibility(!0);const c=$E(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)==d.id))?(a.w?(a.a.debug("Switching period defer text selection"),a.m=b):(_.Bx(a.g,b,!0,0),a.l.trigger(new _.F(_.Ri))),a.o=b.language):a.a.error(_.Ot,d.id)}},dF=function(a){const b=a.ia();b&&a.l.trigger(new _.F(_.hc,{detail:{width:b.width,height:b.height,
11
- bandwidth:b.bandwidth,rendition:b}}))},eF=function(a,b){a.l.trigger(new _.F(_.Me,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},fF=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.a.warn("Couldn't retrieve extra infos from stream."),c=null}return c},gF=function(a,b){a=a.g[_.L]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.sf(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||
12
- null},hF=function(a){const b=a.l.getConfiguration();var c=_.Zf(b.preferredAudioLanguage||[]);const d=a.g[_.K]||[];if(d.length){var e=null;c.some(g=>{e=_.Cu(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.a.debug("Setting audio track with preferred language:",e);a.sa(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},
13
- nF=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===iF),f=b.filter(l=>l.type===jF);const g=[];for(var h=0;h<f.length;h++){const l=fF(a,f[h].extra_info);if(l){var k=_.sg(l.language||_.ye);k=_.uh(k);k=c(g,k);k||(k=new _.yh(String(a.o++),_.K),g.push(k));k.renditions.push(kF(f[h].index,l,k))}else a.a.warn("Skipping audio stream with no extra info")}c=new _.yh(String(a.o++),_.L);for(f=0;f<
14
- e.length;f++)(h=fF(a,e[f].extra_info))?c.renditions.push(lF(e[f].index,h,c)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?aF(a.h):mF(a,b);d[_.L]=[c];d[_.K]=g;d[_.J]=e;return d},qF=function(a,b){if(b===_.J&&a.h)return bF(a.h);var c=oF(a.f)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.L&&(d=fF(a,c.extra_info),d=gF(a,{width:d.Width,height:d.Height}));b===_.K&&(c?(d=pF(a,c,_.K),a.j=d):d=a.j);b===_.J&&(c?(d=pF(a,c,_.J),a.m=d):d=a.m);return d},
15
- tF=function(a,b){if(b){const c=b.track.type.toUpperCase();rF(a.f,c,Number(b.id)).then(()=>{c===jF&&(a.j=b,a.l.trigger(new _.F(_.Qi)));c===sF&&(a.m=b,a.l.trigger(new _.F(_.Ri)))}).catch(()=>{a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},kF=function(a,b,c){const d=_.sg(b.language||_.ye);c.language=_.uh(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.ec;a=new _.Gh(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;
16
- return a},lF=function(a,b,c){c.mimeType=_.Ke;a=new _.Gh(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},uF=function(a,b,c){b=_.sg(b.track_lang||_.ye);c.mimeType="text/ttml";c.language=_.uh(b);c.kind=_.iu;return new _.Gh(String(a),c)},mF=function(a,b){b=b.filter(d=>d.type===sF);const c=[];for(let d=0;d<b.length;d++){const e=fF(a,b[d].extra_info);if(!e){a.a.warn("Skipping text stream with no extra info");
17
- continue}const f=new _.yh(String(a.o++),_.J);f.renditions.push(uF(b[d].index,e,f));c.push(f)}return c},pF=function(a,b,c){a=a.g[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},vF=function(a){return a.g&&a.f?a.f.lg:webapis.avplay.getTotalTrackInfo()},xF=function(a,b,c){a.a.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
- 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.f=wF(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(()=>{const e=a.f.ke;a.g=!1;a.f=null;return e===UE?a.pause():a.play()})}catch(d){return Promise.reject(d)}},yF=function(a,b){var c=a.l.getTextDisplayer();c&&c.setTextVisibility(b);c=a.l.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.a.debug("Could not set text track visibility",d)}},rF=function(a,b,c){b=b.toUpperCase();
19
- b===sF&&yF(a,!0);const d=a.j[b];d&&(d.fd.stop(),a.j[b]=null,a.a.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.a.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,he:0,fd:new _.Zh(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.he?(!a.w&&++k.he,k.fd.$(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),
20
- k&&k.fd.stop(),a.j[h]=null,f())}};g(b,c)})},oF=function(a){return a.g&&a.f?a.f.qf:webapis.avplay.getCurrentStreamInfo()},zF=function(a){return _.y(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.a.debug("Display resolution ratio: ",a.A)},b=>{a.a.debug("Could not load DISPLAY property");throw b;})})},BF=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(AF,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.O.bind(a),ondrmevent:a.J.bind(a),onerror:a.T.bind(a)})}catch(b){a.a.error(b)}},CF=function(a){const b=!!a.l.getTrackManager().Ea();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},DF=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,Bg:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
- GE+d)}catch(c){a.a.debug(c)}},EF=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+GE+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},FF=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case EE:a.a.warn("The application doesn't have the privilege to get the mute state.",FE);break;default:a.a.warn(CE,c)}}return!!b},wF=function(a){return{position:a.getPosition(),state:a.l.getState(),ke:a.getState(),playbackRate:a.getPlaybackRate(),
23
- isLive:a.isLive(),duration:a.getDuration(),isMuted:FF(a),volume:a.getVolume(),lg:vF(a),qf:oF(a)}},GF=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");HE(c,"load",d=>a(d));HE(c,_.$c,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},HF=function(a){return _.y(function*(){yield GF();const b=new Promise(c=>{(new _.Zh(c)).$(5)});if(!(yield Promise.race([zF(a).then(()=>!0),b.then(()=>!1)])))return a.a.debug("Took to long for the SDK to be ready"),
24
- Promise.reject("SDK Timeout")})},IF=function(a){return _.y(function*(){a.a.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.a.debug("AVPlay is ready!");CF(a);b()},d=>{a.a.debug("prepareAsync failed",d);c(d)})}catch(d){a.a.debug("Failed to prepare media player for playback"),c(d)}})})},JF=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case EE:a.a.warn("The application does not have the privilege to set mute.",FE);break;default:a.a.warn(CE,
25
- c)}}},OF=function(a,b,c){return _.y(function*(){a.m=_.Vl(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.a.debug(`Loading manifest URL: ${a.m[d].url}`);let f=b.startTime||void 0;a.g&&(a.trigger(new _.F(KF)),f=c.currentPosition);try{let g=a.m[d].url;if(a.m[d].type===_.Vb&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(EF(a,e.nextBandwidth),a.o=!1):(a.o||DF(a,e),
26
- a.o=!0);BF(a);if(b.drm&&b.drm.env){const h={onError:k=>a.l.onError(k),wb:a.l.getNetworkEngine()};a.h=new LF(b.drm,h);yield a.h.init()}else a.a.debug("No DRM configuration was provided. Assuming clear content");a.g||a.trigger(new _.F(MF));yield IF(a);a.g||a.trigger(new _.F(NF));f&&typeof f===_.r&&0<f&&a.seek(f).catch(h=>{a.a.debug("Couldn't set start position",h)});a.g||(b.volume&&a.setVolume(b.volume),b.muted&&JF(a,b.muted),b.autoplay&&a.l.play().catch(h=>{a.a.debug("Autoplay failed",h)}))}catch(g){throw a.a.debug("Error while attempting to load source."),
27
- g;}})},PF=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.a.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())},LF=class{constructor(a,
28
- b){this.h=a;this.o=null;this.a=_.Ad;this.m=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.O("clpp.tizen.DrmEngine")}init(){const a=this;return _.y(function*(){var b=_.mj[a.h.env]||null;if(!b)throw a.g.debug(_.sa,_.Xa+a.h.env+_.aa),new _.H(_.G,6,6015,`DRM environment '${a.h.env}' is missing.`);a.m={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=_.oj(b,a.h.customData);const d=b[_.Jc];d&&a.f.set(_.Jc,
29
- {Ic:d.licenseUrl||"",customData:c,Pd:!1});(b=b[_.Kc])&&a.f.set(_.Kc,{Ic:b.licenseUrl||"",customData:c,Pd:!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(_.Jc))a.a=_.Jc;else if(a.f.get(_.Kc))a.a=_.Kc;else throw new _.H(_.G,6,6001,"Configuration for the target system is missing.");yield KE(a);a.j=!0})}release(){const a=this;return _.y(function*(){a.j=!1;a.o=null;a.a=_.Ad;a.m=null;a.f=new Map})}getDrmInfo(){return this.o}},NE="DeleteLicenseAfterUse",
30
- OE="LicenseServer",PE="CustomData";var VF=class{constructor(a){this.l=a;this.a=this.l.a;this.f=_.Pl;this.j=_.xp;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.O("clpp.tizen.StateManager")}initialize(){this.a.on(KF,this.C,this);this.a.on(QF,this.B,this);this.a.on(RF,this.A,this);this.a.on(MF,this.H,this);this.a.on(NF,this.G,this);this.a.on(SF,this.F,this)}release(){SE(this,_.Pl);this.m=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(KF,this.C);this.a.off(QF,this.B);this.a.off(RF,this.A);this.a.off(MF,
31
- this.H);this.a.off(NF,this.G);this.a.off(SF,this.F);this.l=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;SE(this,_.Kl)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",RE(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.m){this.m=!0;var a=this.l.getConfiguration().autoplay;const b=this.a.getState()===TF;if(!a&&b){SE(this,_.Rl);return}}if(a=this.f!==_.Ql)a=this.a.getState(),a=a===
32
- TE||a===UE;a&&VE(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===UF?SE(this,_.Ql):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){SE(this,_.Hl)}getState(){return this.f}};var WF=class{constructor(){this.o=this.A=this.g=this.h=this.B=this.l=this.j=this.f=null;this.w=!0;this.m=null;this.a=new _.O("clpp.tizen.TextStreamer")}initialize(a){this.l=a}load(a){const b=this;return _.y(function*(){if(b.l)if(b.B=a,b.j=yield WE(b),b.j){var c={networkingEngine:b.l.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}};try{b.f=yield b.j.start(a.url,c)}catch(d){b.a.warn(d);try{b.f=yield b.j.start(a.url.replace("https://",
33
- "http://"),c)}catch(e){b.a.error(e),b.f=null}}if(b.f&&XE(b.f)){b.h=YE(b);try{yield b.h.H;b.g=ZE(b);const d=b.l.getConfiguration();b.g.j=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole}catch(d){b.a.debug("Could not setup media source..."),b.h=null,b.g=null,b.j=null,b.f=null}}}else b.a.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.a.debug("Text streamer is not initialized. Will not load()")})}F(a){this.a.debug(_.bu,a);this.w=!0;let b=_.ew(a.textStreams,
34
- this.o||"",this.A||"")[0]||null;this.m&&(a.textStreams.includes(this.m)&&(b=this.m),this.m=null);return{variant:null,text:b}}C(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.Bx(this.g,this.m,!0,0),this.m=null)}T(){this.a.debug("onError_")}G(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.y(function*(){if(a.g)try{a.g.start()}catch(b){a.a.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=
35
- this;return _.y(function*(){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null})}destroy(){const a=this;return _.y(function*(){a.j&&(yield a.j.stop(),a.j=null);a.g&&(yield a.g.destroy(),a.g=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var U=class extends _.P{constructor(){super();this.h=this.f=this.l=null;this.g={};this.a=new _.O("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.B=!1;this.o=1}C(a){var b=a.eventid;a=a.data;switch(b){case XF:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+fF(this,b[0].extra_info).Bit_rate,b=gF(this,{bandwidth:b}))&&(this.w=b,eF(this,b));break;case YF:dF(this);break;default:this.a.debug("Event type: "+
36
- b+" data: "+a)}}A(a){a.detail.currentState===_.Sl&&this.l.off(_.ke,this.A)}initialize(a){this.l=a;this.f=this.l.a;this.l.on(_.ke,b=>{this.B||(b=b.detail,b.currentState===_.Sl&&(this.a.debug("Current state",b.currentState),this.B=!0,hF(this)))});this.f.on(ZF,this.C,this)}release(){this.g={};this.h=this.w=this.m=this.j=null;this.B=!1;this.o=1}load(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.ke,this.A);this.l.on(_.ke,this.A,this);try{const a=vF(this.f);this.g=nF(this,a);
37
- const b=this.g[_.K]||[];b.length&&(this.j=b[0].renditions[0]||null);dF(this)}catch(a){this.a.debug("Could not load track manager")}}}destroy(){this.f.off(ZF,this.C);this.f=this.l=null}getVideoTracks(){return this.g[_.L]||[]}getAudioTracks(){return this.g[_.K]||[]}ja(){return this.g[_.J]||[]}ia(){return qF(this,_.L)}Da(){return qF(this,_.K)}Ea(){return qF(this,_.J)}Pa(){return this.w}bb(){this.a.info(DE);return null}cb(){this.a.info(DE);return null}Ga(){const a=this.ia();return a?a.track:null}na(){const a=
38
- this.Da();return a?a.track:null}oa(){const a=this.Ea();return a?a.track:null}Ua(a){null===a?(a=this.ia(),xF(this.f,a.bandwidth,null).then(()=>{dF(this)})):0<a.renditions.length&&this.Ta(a.renditions[0])}sa(a){a?tF(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ba(a){a?(a=a.renditions[0],this.h?cF(this.h,a.track):tF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,yF(this.f,!1),this.l.trigger(new _.F(_.Ri)))}Ta(a){const b=
39
- this.ia();this.f.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,eF(this,a),xF(this.f,b.bandwidth,a.bandwidth).then(()=>{dF(this)}).catch(c=>{const d=new _.H(_.G,7,7200,{tizenerror:c});this.a.debug("Error while switching video track",c);this.l.onError(d)})):this.a.debug("Trying to switch to already active rendition. Doing nothing...")}ib(a){tF(this,a)}jb(a){this.h?cF(this.h,a.track):tF(this,a)}addTextTrack(){}la(){return this.f.o}};U.prototype.isAbrEnabled=U.prototype.la;
40
- U.prototype.addTextTrack=U.prototype.addTextTrack;U.prototype.setTextRendition=U.prototype.jb;U.prototype.setAudioRendition=U.prototype.ib;U.prototype.setVideoRendition=U.prototype.Ta;U.prototype.setTextTrack=U.prototype.Ba;U.prototype.setAudioTrack=U.prototype.sa;U.prototype.setVideoTrack=U.prototype.Ua;U.prototype.getTextTrack=U.prototype.oa;U.prototype.getAudioTrack=U.prototype.na;U.prototype.getVideoTrack=U.prototype.Ga;U.prototype.getLoadingTextRendition=U.prototype.cb;
41
- U.prototype.getLoadingAudioRendition=U.prototype.bb;U.prototype.getLoadingVideoRendition=U.prototype.Pa;U.prototype.getTextRendition=U.prototype.Ea;U.prototype.getAudioRendition=U.prototype.Da;U.prototype.getVideoRendition=U.prototype.ia;U.prototype.getTextTracks=U.prototype.ja;U.prototype.getAudioTracks=U.prototype.getAudioTracks;U.prototype.getVideoTracks=U.prototype.getVideoTracks;var cG=class extends _.cp{constructor(a){super();this.l=a;this.h=null;this.a=new _.O("clpp.tizen.Middleware");this.C=1;this.B=!1;this.m=null;this.F=0;this.o=!0;this.g=!1;this.f=null;this.A=1;this.w=!1;this.j={}}I(){this.w=!0;this.g||this.trigger(new _.F(KF))}H(a){this.w=!0;this.trigger(new _.F(QF,{percent:a}))}G(){this.w=!1;this.trigger(new _.F(RF))}M(){this.trigger(new _.F(SF))}K(a,b){this.trigger(new _.F(ZF,{eventid:a,data:b}))}O(a,b,c,d,e){this.trigger(new _.F($F,{duration:a,text:b,subtitleType:c,
42
- attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.F(aG,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.Kc&&"Challenge"===b.name?ME(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))))}T(a){this.trigger(new _.F(bG,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(AF,f,this);e=setTimeout(()=>{this.off(AF,f);d("Timeout")},3E4)});if(a===UF)return(new Promise((c,
43
- d)=>{webapis.avplay.prepareAsync(()=>{CF(this);c(webapis.avplay.play())},e=>{this.trigger(new _.F(bG));d(e)})})).then(()=>b());if(a===UE||a===TF)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===TE?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===UE?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===TF||b===TE||b===UE){try{webapis.avplay.setSpeed(a),
44
- this.C=a}catch(c){return this.a.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.a.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.C}load(a,b){const c=this;return _.y(function*(){c.a.debug("configure()",b||"");try{yield HF(c),yield OF(c,a,b)}catch(d){throw new _.H(_.G,7,7003,null,d);}})}getState(){if(this.g&&this.f)return this.f.ke;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}}seek(a){const b=
45
- 1E3*a;return new Promise((c,d)=>{this.B=!0;this.l.trigger(new _.F(_.De));webapis.avplay.seekTo(b,()=>{this.B=!1;this.l.trigger(new _.F(_.Ce));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.T(JSON.stringify(a))}}getDuration(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.T(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.fd.stop()}this.j={};this.C=1;this.B=!1;this.f=this.m=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case EE:this.a.debug("The application does not have the privilege to get the volume.",FE);break;default:this.a.debug(CE,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.a.warn("Invalid value passed for setVolume.",
47
- "The passed value value should be in the range of 0 to 1.");break;case EE:this.a.warn("The application does not have the privilege to set the volume.",FE);break;default:this.a.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.g&&this.f)return this.f.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.T(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.a.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.F=
48
- a}getSourceIndex(){return this.F}getLoadedSource(){return this.m&&this.m[this.getSourceIndex()]}},UF="IDLE",TF="READY",TE="PLAYING",UE="PAUSED",iF=_.sb,jF="AUDIO",sF="TEXT",YF="PLAYER_MSG_RESOLUTION_CHANGED",XF="PLAYER_MSG_BITRATE_CHANGE",QE="PLAYREADY",LE="WIDEVINE_CDM";var gG=class extends _.cp{constructor(){super();this.a=new cG(this);this.f=new VF(this);this.configuration=this.B=_.aj();this.w=null;this.h=new _.O("clpp.tizen.Player");this.j=null;this.m=new U;this.C=new _.Pm;this.o=this.g=null;this.A=!1}H(){this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.F(_.Zc));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(_.ve,
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=_.Sg(d))&&this.o.append([new _.Co(b,c,d)],[])}G(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)}T(a){this.h.debug(`Error: TYPE: ${a.eventType}`);SE(this.f,_.Ol);a=new _.H(_.G,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.F(_.$c,{detail:a}))}init(a,
50
- b){this.configuration=this.B=b;this.w=a;this.a.on(SF,this.H,this);this.a.on(AF,this.F,this);this.a.on($F,this.I,this);this.a.on(aG,this.G,this);this.a.on(bG,this.T,this);this.a.on(RF,this.J,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();a=dG;dG+=1;a="__clpp_tizen_player_"+a;this.j=_.lm(_.Bd,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.Xe,_.cd,"position",
51
- _.id,"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}_.nm(a,d);PF(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}destroy(){const a=this;return _.y(function*(){yield a.release();a.a.off(SF,a.H);a.a.off(AF,a.F);a.a.off($F,a.I);a.a.off(aG,a.G);a.a.off(bG,a.T);a.a.off(RF,a.J);a.g&&(yield a.g.destroy(),a.g=null);a.j&&(a.j.parentElement.removeChild(a.j),
52
- a.j=null);a.m.destroy();a.f.destroy();a.m=null;a.f=null})}namespace(){return eG}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()===_.Hl?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(_.ma);return new _.bp}getTrackManager(){return this.m}unload(){return this.a.release().then(()=>{this.m.release()})}release(){const a=this;return _.y(function*(){a.g&&(yield a.g.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.m.release();a.f.release();a.A=!1})}load(a){const b=this;return _.y(function*(){_.dj(a)&&
54
- (b.configuration=_.cj(b.B,a));var c=_.xl(b.configuration,["html","native"]);b.o=c.create(b);c=_.Vl(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.g=new WF;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.m.load()})}play(){this.trigger(new _.F(_.Sd));PF(this);return this.a.play().then(()=>{VE(this.f)})}pause(){return this.a.pause().then(()=>{VE(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=
55
- new _.F(_.$c,{detail:a});a.severity===_.G&&(SE(this.f,_.Ol),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.Hl}isPaused(){return this.a.getState()===UE}isMuted(){return FF(this.a)}setMuted(a){JF(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 fG).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};gG.prototype.getTextDisplayer=gG.prototype.getTextDisplayer;gG.prototype.setNetworkEngine=gG.prototype.setNetworkEngine;gG.prototype.getNetworkEngine=gG.prototype.getNetworkEngine;
57
- var eG="clpp.tizen",dG=0,fG=class{a(){return eG}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Vb||a===_.Vi||a===_.$b)&&b){if(_.ci(2))return 2;if(_.ci(3)||_.ci(4)||_.ci(5)||_.ci(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}create(){return new gG}};_.z("clpp.tizen.TizenComponent",class extends _.Mp{constructor(){super();this.h=null}f(){this.h=new fG;_.Lf(this.h)}a(){if(this.h){var a=this.h.a();a&&_.Jf[a]&&(delete _.Jf[a],_.Kf.info("Removed Player factory: '"+a+"'"));this.h=null}}id(){return"tizen"}});var KF="onbufferingstart",QF="onbufferingprogress",RF="onbufferingcomplete",SF="onstreamcompleted",AF="oncurrentplaytime",ZF="onevent",$F="onsubtitlechange",aG="ondrmevent",bG="onerror",MF="preparingstart",NF="preparingend";};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var QE="An unknown error occurred while trying to get volume",RE="Cannot get loading rendition due to platform limitations",SE="SecurityError",TE="The require privilege is: http://tizen.org/privilege/tv.audio",UE="|STARTBITRATE\x3d",VE=function(a,b,c){const d=e=>{c.call(a,e);a.removeEventListener(b,d)};a.addEventListener(b,d)},YE=function(a){return _.y(function*(){if(a.a!==_.Jc&&a.a!==_.Ic)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.Ic)throw new _.H(_.G,6,6012,`No license server given for ${a.a}`);try{a.a===_.Jc?yield WE(a):yield XE(a,b),a.o={keySystem:a.a,licenseServerUri:b.Ic,distinctiveIdentifierRequired:!1,persistentStateRequired:b.Qd,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)});}})},$E=function(a,b){_.y(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=_.jh([b.serverurl&&""!==b.serverurl?b.serverurl:c.Ic],_.gh());c.type=3;c.body=e.buffer;c.method="POST";try{var f=yield a.D.vb.fetch(c).P;if(a.j){var g=_.I(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(ZE,"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:_.ya,url:h.data.url,status:h.data.status||NaN,response:h.data.response||"",headers:h.data.headers||{}},h),a.D.onError(g)}})},WE=function(a){return _.y(function*(){try{webapis.avplay.setDrm(ZE,"Initialize",""),webapis.avplay.setDrm(ZE,
5
+ "widevine_app_session",a.m.id),webapis.avplay.setDrm(ZE,"widevine_data_type",a.m.type)}catch(b){throw b;}})},XE=function(a,b){return _.y(function*(){var c={};c[aF]=!b.Qd;c[bF]=b.Ic;""!==b.customData&&(c[cF]=b.customData);c=JSON.stringify(c);a.g.debug("PlayReady properties: ",c);try{webapis.avplay.setDrm(dF,"SetProperties",c)}catch(d){throw d;}})},fF=function(a,b){if(a.f!==b)if(a.f===_.Dl&&b!==_.El)a.g.debug(_.Nt+`${eF(b)}`);else{var c=(new Date).getTime();a.j=a.f;a.f=b;a.f===_.zl?(a.o=(new Date).getTime(),
6
+ a.l.trigger(new _.F(_.jc,{detail:{bufferedTimeMS:-1,reason:a.h}}))):a.j===_.zl&&a.l.trigger(new _.F(_.ic,{detail:{bufferedTimeMS:c-a.o,reason:a.h}}));b={currentState:a.f,previousState:a.j,timeSinceLastStateChangeMS:c-a.w};a.w=c;a.l.trigger(new _.F(_.je,{detail:b}));a.g.debug("State changed:",eF(a.j),"-\x3e",eF(a.f))}},eF=function(a){return Object.keys(_.Cl)[a]},iF=function(a){if(a.m){var b=a.a.getState(),c=a.f;switch(b){case gF:c=_.Hl;break;case hF:c=_.Gl;break;default:a.l.isEnded()?c=_.wl:a.g.debug("Inconsistent AVPlay playback state:",
7
+ b)}fF(a,c)}},jF=function(a){return _.y(function*(){const b=a.l.getConfiguration();let c;(c=yield _.wn(a.B.url,a.l.getNetworkEngine(),b.manifest.attemptParameters,a.B.type||null))&&c.configure(b.manifest);return c})},kF=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},lF=function(a){const b=document.createElement(_.w),c=new _.Ny,d=new _.Cy(()=>null),e=a.l.getTextDisplayer();return new _.Oy(b,c,e,d,a.l.getConfiguration())},mF=function(a){const b=
8
+ {rb:()=>a.l.getPosition(),X:a.h,vb:a.l.getNetworkEngine(),Nd:a.F.bind(a),Md:a.C.bind(a),onError:a.T.bind(a),Ee:()=>{},onEvent:()=>{},Ie:a.G.bind(a),ed:()=>{},ud:()=>new _.ez,ld:()=>!1,Cc:null};return new _.Hz(a.f,b)},nF=function(a){const b=a.l.getPosition();let c=null;for(const d of a.f.periods)d.startTime<=b&&(c=d);return c},oF=function(a){a.a.debug("getTextStreams()",a.f);if(a.f){var b=[],c=a.f.periods;a.a.debug("getting text streams");for(var d=0;d<c.length;d++)if(a.a.debug(c[d].startTime,a.l.getPosition()),
9
+ c[d].startTime<=a.l.getPosition()){b=c[d].textStreams;break}a=b}else a=[];b=[];c=0;for(d=0;d<a.length;d++){const e=new _.xh(String(c++),_.J);e.mimeType=a[d].mimeType;e.language=a[d].language;e.roles=a[d].roles;e.kind=a[d].kind||_.gu;const f=new _.Fh(String(a[d].id),e);f.bandwidth=a[d].bandwidth||null;e.renditions.push(f);b.push(e)}return b},pF=function(a){if(a.h&&!a.h.getTextDisplayer().isTextVisible())return null;if(a.g){const b=_.Fx(a.g,_.v);let c=null;if(b){a=oF(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},qF=function(a,b){a.a.debug("Set active track",b);if(b&&(a.o=b.language,a.A=b.roles[0]||"",a.f&&a.g)){a.setTextVisibility(!0);const c=nF(a),d=b.renditions[0];(b=c.textStreams.find(e=>String(e.id)==d.id))?(a.w?(a.a.debug("Switching period defer text selection"),a.m=b):(_.Px(a.g,b,!0,0),a.l.trigger(new _.F(_.Qi))),a.o=b.language):a.a.error(_.Mt,d.id)}},rF=function(a){const b=a.ia();b&&a.l.trigger(new _.F(_.gc,{detail:{width:b.width,height:b.height,
11
+ bandwidth:b.bandwidth,rendition:b}}))},sF=function(a,b){a.l.trigger(new _.F(_.Le,{details:{width:b.width,height:b.height,bandwidth:b.bandwidth,track:b.track,abrSelection:a.f.o}}))},tF=function(a,b){let c=null;try{c=JSON.parse(b)}catch(d){a.a.warn("Couldn't retrieve extra infos from stream."),c=null}return c},uF=function(a,b){a=a.g[_.L]||[];const c=[];for(let d=0;d<a.length;d++)for(let e=0;e<a[d].renditions.length;e++)_.rf(a[d].renditions[e],b,Object.keys(b))&&c.push(a[d].renditions[e]);return c[0]||
12
+ null},vF=function(a){const b=a.l.getConfiguration();var c=_.Yf(b.preferredAudioLanguage||[]);const d=a.g[_.K]||[];if(d.length){var e=null;c.some(g=>{e=_.yu(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.a.debug("Setting audio track with preferred language:",e);a.sa(c)}else a.a.debug("Preferred language(s) not available")}else a.a.debug("Could not set preferred audio language")},
13
+ BF=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===wF),f=b.filter(l=>l.type===xF);const g=[];for(var h=0;h<f.length;h++){const l=tF(a,f[h].extra_info);if(l){var k=_.rg(l.language||_.xe);k=_.th(k);k=c(g,k);k||(k=new _.xh(String(a.o++),_.K),g.push(k));k.renditions.push(yF(f[h].index,l,k))}else a.a.warn("Skipping audio stream with no extra info")}c=new _.xh(String(a.o++),_.L);for(f=0;f<
14
+ e.length;f++)(h=tF(a,e[f].extra_info))?c.renditions.push(zF(e[f].index,h,c)):a.a.warn("Skipping video stream with no extra info");e=[];e=a.h?oF(a.h):AF(a,b);d[_.L]=[c];d[_.K]=g;d[_.J]=e;return d},EF=function(a,b){if(b===_.J&&a.h)return pF(a.h);var c=CF(a.f)||[];if(0===c.length)return null;c=c.filter(e=>e.type===b.toUpperCase())[0];var d=null;b===_.L&&(d=tF(a,c.extra_info),d=uF(a,{width:d.Width,height:d.Height}));b===_.K&&(c?(d=DF(a,c,_.K),a.j=d):d=a.j);b===_.J&&(c?(d=DF(a,c,_.J),a.m=d):d=a.m);return d},
15
+ HF=function(a,b){if(b){const c=b.track.type.toUpperCase();FF(a.f,c,Number(b.id)).then(()=>{c===xF&&(a.j=b,a.l.trigger(new _.F(_.Pi)));c===GF&&(a.m=b,a.l.trigger(new _.F(_.Qi)))}).catch(()=>{a.a.error("Could not select "+c+" track.")})}else a.a.debug("Must provide valid rendition")},yF=function(a,b,c){const d=_.rg(b.language||_.xe);c.language=_.th(d);c.channelsCount=b.channels?Number(b.channels):null;c.mimeType=_.dc;a=new _.Fh(String(a),c);a.track=c;a.codec=b.fourCC||null;a.bandwidth=b.bit_rate||null;
16
+ return a},zF=function(a,b,c){c.mimeType=_.Je;a=new _.Fh(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},IF=function(a,b,c){b=_.rg(b.track_lang||_.xe);c.mimeType="text/ttml";c.language=_.th(b);c.kind=_.gu;return new _.Fh(String(a),c)},AF=function(a,b){b=b.filter(d=>d.type===GF);const c=[];for(let d=0;d<b.length;d++){const e=tF(a,b[d].extra_info);if(!e){a.a.warn("Skipping text stream with no extra info");
17
+ continue}const f=new _.xh(String(a.o++),_.J);f.renditions.push(IF(b[d].index,e,f));c.push(f)}return c},DF=function(a,b,c){a=a.g[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},JF=function(a){return a.g&&a.f?a.f.lg:webapis.avplay.getTotalTrackInfo()},LF=function(a,b,c){a.a.debug("switchVideoTrack()");try{const d={estimatedBandwidth:parseInt(webapis.avplay.getStreamingProperty("CURRENT_BANDWITH"),
18
+ 10),currentBandwidth:b,nextBandwidth:c,currentPosition:a.getPosition()};a.f=KF(a);a.g=!0;webapis.avplay.stop();webapis.avplay.close();return a.load(a.l.getConfiguration(),d).then(()=>{const e=a.f.le;a.g=!1;a.f=null;return e===hF?a.pause():a.play()})}catch(d){return Promise.reject(d)}},MF=function(a,b){var c=a.l.getTextDisplayer();c&&c.setTextVisibility(b);c=a.l.g;try{c||webapis.avplay.setSilentSubtitle(!b)}catch(d){a.a.debug("Could not set text track visibility",d)}},FF=function(a,b,c){b=b.toUpperCase();
19
+ b===GF&&MF(a,!0);const d=a.j[b];d&&(d.hd.stop(),a.j[b]=null,a.a.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.a.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,je:0,hd:new _.Yh(()=>g(h,c,!0))}),(k=a.j[h])&&3>k.je?(!a.w&&++k.je,k.hd.ca(a.w?.5:.25)):(a.a.debug("Could not set track after multiple attempts.Giving up..."),
20
+ k&&k.hd.stop(),a.j[h]=null,f())}};g(b,c)})},CF=function(a){return a.g&&a.f?a.f.rf:webapis.avplay.getCurrentStreamInfo()},NF=function(a){return _.y(function*(){tizen.systeminfo.getPropertyValue("DISPLAY",b=>{a.A=b.resolutionWidth/1920;a.a.debug("Display resolution ratio: ",a.A)},b=>{a.a.debug("Could not load DISPLAY property");throw b;})})},PF=function(a){try{webapis.avplay.setListener({onbufferingstart:a.I.bind(a),onbufferingprogress:a.H.bind(a),onbufferingcomplete:a.G.bind(a),onstreamcompleted:a.L.bind(a),
21
+ oncurrentplaytime:b=>{a.trigger(new _.F(OF,{currentTime:b}))},onevent:a.K.bind(a),onsubtitlechange:a.N.bind(a),ondrmevent:a.J.bind(a),onerror:a.T.bind(a)})}catch(b){a.a.error(b)}},QF=function(a){const b=!!a.l.getTrackManager().Ea();try{webapis.avplay.setSilentSubtitle(!b)}catch(c){a.a.debug("Could not set AVPlay subtitle config",c)}},RF=function(a,b){try{const c=b.estimatedBandwidth||0,d=b.currentBandwidth||0;a.a.debug({estimatedBandwidth:c,Bg:d});0!==c&&0!==d&&c>=1.15*d&&webapis.avplay.setStreamingProperty("ADAPTIVE_INFO",
22
+ UE+d)}catch(c){a.a.debug(c)}},SF=function(a,b){try{webapis.avplay.setStreamingProperty("ADAPTIVE_INFO","|BITRATES\x3d"+b+UE+b)}catch(c){throw a.a.debug("Could not set fixed bandwidth",c),c;}},TF=function(a){let b=null;try{b=tizen.tvaudiocontrol.isMute()}catch(c){switch(c.name){case SE:a.a.warn("The application doesn't have the privilege to get the mute state.",TE);break;default:a.a.warn(QE,c)}}return!!b},KF=function(a){return{position:a.getPosition(),state:a.l.getState(),le:a.getState(),playbackRate:a.getPlaybackRate(),
23
+ isLive:a.isLive(),duration:a.getDuration(),isMuted:TF(a),volume:a.getVolume(),lg:JF(a),rf:CF(a)}},UF=function(){return new Promise((a,b)=>{if(window.webapis)a();else{const c=document.createElement("script");VE(c,"load",d=>a(d));VE(c,_.$c,d=>b(d));c.src="$WEBAPIS/webapis/webapis.js";document.querySelector("head").appendChild(c)}})},VF=function(a){return _.y(function*(){yield UF();const b=new Promise(c=>{(new _.Yh(c)).ca(5)});if(!(yield Promise.race([NF(a).then(()=>!0),b.then(()=>!1)])))return a.a.debug("Took to long for the SDK to be ready"),
24
+ Promise.reject("SDK Timeout")})},WF=function(a){return _.y(function*(){a.a.debug("avplay.prepare()");return new Promise((b,c)=>{try{webapis.avplay.prepareAsync(()=>{a.a.debug("AVPlay is ready!");QF(a);b()},d=>{a.a.debug("prepareAsync failed",d);c(d)})}catch(d){a.a.debug("Failed to prepare media player for playback"),c(d)}})})},XF=function(a,b){try{tizen.tvaudiocontrol.setMute(b)}catch(c){switch(c.name){case SE:a.a.warn("The application does not have the privilege to set mute.",TE);break;default:a.a.warn(QE,
25
+ c)}}},bG=function(a,b,c){return _.y(function*(){a.m=_.Kl(b);const d=a.F,e=c||{estimatedBandwidth:0,currentBandwidth:0,nextBandwidth:null,currentPosition:0};a.a.debug(`Loading manifest URL: ${a.m[d].url}`);let f=b.startTime||void 0;a.g&&(a.trigger(new _.F(YF)),f=c.currentPosition);try{let g=a.m[d].url;if(a.m[d].type===_.Ub&&!g.includes(".mpd")){const h=new URL(g);h.searchParams.append("cl-ext",".mpd");g=h.toString()}webapis.avplay.open(g);e.nextBandwidth?(SF(a,e.nextBandwidth),a.o=!1):(a.o||RF(a,e),
26
+ a.o=!0);PF(a);if(b.drm&&b.drm.env){const h={onError:k=>a.l.onError(k),vb:a.l.getNetworkEngine()};a.h=new ZF(b.drm,h);yield a.h.init()}else a.a.debug("No DRM configuration was provided. Assuming clear content");a.g||a.trigger(new _.F($F));yield WF(a);a.g||a.trigger(new _.F(aG));f&&typeof f===_.r&&0<f&&a.seek(f).catch(h=>{a.a.debug("Couldn't set start position",h)});a.g||(b.volume&&a.setVolume(b.volume),b.muted&&XF(a,b.muted),b.autoplay&&a.l.play().catch(h=>{a.a.debug("Autoplay failed",h)}))}catch(g){throw a.a.debug("Error while attempting to load source."),
27
+ g;}})},cG=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.a.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())},ZF=class{constructor(a,
28
+ b){this.h=a;this.o=null;this.a=_.Ad;this.m=null;this.j=!1;this.f=new Map;this.D=b;this.g=new _.P("clpp.tizen.DrmEngine")}init(){const a=this;return _.y(function*(){var b=_.lj[a.h.env]||null;if(!b)throw a.g.debug(_.ra,_.Wa+a.h.env+_.aa),new _.H(_.G,6,6015,`DRM environment '${a.h.env}' is missing.`);a.m={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=_.nj(b,a.h.customData);const d=b[_.Ic];d&&a.f.set(_.Ic,
29
+ {Ic:d.licenseUrl||"",customData:c,Qd:!1});(b=b[_.Jc])&&a.f.set(_.Jc,{Ic:b.licenseUrl||"",customData:c,Qd:!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(_.Ic))a.a=_.Ic;else if(a.f.get(_.Jc))a.a=_.Jc;else throw new _.H(_.G,6,6001,"Configuration for the target system is missing.");yield YE(a);a.j=!0})}release(){const a=this;return _.y(function*(){a.j=!1;a.o=null;a.a=_.Ad;a.m=null;a.f=new Map})}getDrmInfo(){return this.o}},aF="DeleteLicenseAfterUse",
30
+ bF="LicenseServer",cF="CustomData";var iG=class{constructor(a){this.l=a;this.a=this.l.a;this.f=_.El;this.j=_.np;this.w=(new Date).getTime();this.m=!1;this.o=-1;this.h=2;this.g=new _.P("clpp.tizen.StateManager")}initialize(){this.a.on(YF,this.C,this);this.a.on(dG,this.B,this);this.a.on(eG,this.A,this);this.a.on($F,this.H,this);this.a.on(aG,this.G,this);this.a.on(fG,this.F,this)}release(){fF(this,_.El);this.m=!1;this.o=-1;this.h=2}destroy(){this.release();this.a.off(YF,this.C);this.a.off(dG,this.B);this.a.off(eG,this.A);this.a.off($F,
31
+ this.H);this.a.off(aG,this.G);this.a.off(fG,this.F);this.l=this.a=null}C(){this.g.debug("Buffering start. Player state: ",this.a.getState());this.h=this.a.B?1:2;fF(this,_.zl)}B(a){this.g.debug("Buffering progress: "+a.percent+" %. Player state: ",eF(this.f))}A(){this.g.debug("Buffering complete. Player state: ",this.a.getState());if(!this.m){this.m=!0;var a=this.l.getConfiguration().autoplay;const b=this.a.getState()===gG;if(!a&&b){fF(this,_.Gl);return}}if(a=this.f!==_.Fl)a=this.a.getState(),a=a===
32
+ gF||a===hF;a&&iF(this)}H(){this.g.debug("Preparing starts. AVPlay State: ",this.a.getState());this.a.getState()===hG?fF(this,_.Fl):this.g.error("AVPlay prepares while state is not IDLE")}G(){this.g.debug("Preparing ends: AVPlay state:",this.a.getState())}F(){fF(this,_.wl)}getState(){return this.f}};var jG=class{constructor(){this.o=this.A=this.g=this.h=this.B=this.l=this.j=this.f=null;this.w=!0;this.m=null;this.a=new _.P("clpp.tizen.TextStreamer")}initialize(a){this.l=a}load(a){const b=this;return _.y(function*(){if(b.l)if(b.B=a,b.j=yield jF(b),b.j){var c={networkingEngine:b.l.getNetworkEngine(),filterNewPeriod:()=>{},filterAllPeriods:()=>{},onTimelineCueAdded:()=>{},onEvent:()=>{},onError:()=>{}};try{b.f=yield b.j.start(a.url,c)}catch(d){b.a.warn(d);try{b.f=yield b.j.start(a.url.replace("https://",
33
+ "http://"),c)}catch(e){b.a.error(e),b.f=null}}if(b.f&&kF(b.f)){b.h=lF(b);try{yield b.h.I;b.g=mF(b);const d=b.l.getConfiguration();b.g.j=d.streaming;b.o=d.preferredTextLanguage;b.A=d.preferredTextRole}catch(d){b.a.debug("Could not setup media source..."),b.h=null,b.g=null,b.j=null,b.f=null}}}else b.a.debug("Could not find manifest parser for source. Make sure parsers are registered.");else b.a.debug("Text streamer is not initialized. Will not load()")})}F(a){this.a.debug(_.$t,a);this.w=!0;let b=_.sw(a.textStreams,
34
+ this.o||"",this.A||"")[0]||null;this.m&&(a.textStreams.includes(this.m)&&(b=this.m),this.m=null);return{variant:null,text:b}}C(){this.a.debug("canSwitch_");this.w=!1;this.m&&(_.Px(this.g,this.m,!0,0),this.m=null)}T(){this.a.debug("onError_")}G(){this.j&&this.j.update&&this.j.update()}start(){const a=this;return _.y(function*(){if(a.g)try{a.g.start()}catch(b){a.a.error("Error while starting streaming engine",b)}})}setTextVisibility(a){this.a.debug("Set text visibility",a);this.h&&this.h.getTextDisplayer().setTextVisibility(a)}release(){const a=
35
+ this;return _.y(function*(){a.l=null;a.f=null;a.B=null;a.A=null;a.o=null;a.w=!0;a.m=null})}destroy(){const a=this;return _.y(function*(){a.j&&(yield a.j.stop(),a.j=null);a.g&&(yield a.g.destroy(),a.g=null,a.w=!0);a.h&&(yield a.h.destroy(),a.h=null)})}};var V=class extends _.Q{constructor(){super();this.h=this.f=this.l=null;this.g={};this.a=new _.P("clpp.tizen.TrackManager");this.w=this.m=this.j=null;this.B=!1;this.o=1}C(a){var b=a.eventid;a=a.data;switch(b){case kG:0<Object.keys(this.g).length||(this.a.debug("Loading track manager!"),this.load());b=webapis.avplay.getCurrentStreamInfo();0<b.length&&(b=+tF(this,b[0].extra_info).Bit_rate,b=uF(this,{bandwidth:b}))&&(this.w=b,sF(this,b));break;case lG:rF(this);break;default:this.a.debug("Event type: "+
36
+ b+" data: "+a)}}A(a){a.detail.currentState===_.Hl&&this.l.off(_.je,this.A)}initialize(a){this.l=a;this.f=this.l.a;this.l.on(_.je,b=>{this.B||(b=b.detail,b.currentState===_.Hl&&(this.a.debug("Current state",b.currentState),this.B=!0,vF(this)))});this.f.on(mG,this.C,this)}release(){this.g={};this.h=this.w=this.m=this.j=null;this.B=!1;this.o=1}load(){if(this.f&&!(0<Object.keys(this.g).length)){this.h=this.l.g;this.l.off(_.je,this.A);this.l.on(_.je,this.A,this);try{const a=JF(this.f);this.g=BF(this,a);
37
+ const b=this.g[_.K]||[];b.length&&(this.j=b[0].renditions[0]||null);rF(this)}catch(a){this.a.debug("Could not load track manager")}}}destroy(){this.f.off(mG,this.C);this.f=this.l=null}getVideoTracks(){return this.g[_.L]||[]}getAudioTracks(){return this.g[_.K]||[]}ja(){return this.g[_.J]||[]}ia(){return EF(this,_.L)}Da(){return EF(this,_.K)}Ea(){return EF(this,_.J)}Pa(){return this.w}bb(){this.a.info(RE);return null}cb(){this.a.info(RE);return null}Ga(){const a=this.ia();return a?a.track:null}na(){const a=
38
+ this.Da();return a?a.track:null}oa(){const a=this.Ea();return a?a.track:null}Ua(a){null===a?(a=this.ia(),LF(this.f,a.bandwidth,null).then(()=>{rF(this)})):0<a.renditions.length&&this.Ta(a.renditions[0])}sa(a){a?HF(this,a.renditions[0]):this.a.warn("Cannot disable audio tracks on this platform.","Consider muting audio instead...")}Ba(a){a?(a=a.renditions[0],this.h?qF(this.h,a.track):HF(this,a)):(this.a.debug("Disabling text tracks"),this.m=null,MF(this.f,!1),this.l.trigger(new _.F(_.Qi)))}Ta(a){const b=
39
+ this.ia();this.f.o||a.width!==b.width||a.height!==b.height||a.bandwidth!==b.bandwidth?(this.w=a,sF(this,a),LF(this.f,b.bandwidth,a.bandwidth).then(()=>{rF(this)}).catch(c=>{const d=new _.H(_.G,7,7200,{tizenerror:c});this.a.debug("Error while switching video track",c);this.l.onError(d)})):this.a.debug("Trying to switch to already active rendition. Doing nothing...")}ib(a){HF(this,a)}jb(a){this.h?qF(this.h,a.track):HF(this,a)}addTextTrack(){}la(){return this.f.o}};V.prototype.isAbrEnabled=V.prototype.la;
40
+ V.prototype.addTextTrack=V.prototype.addTextTrack;V.prototype.setTextRendition=V.prototype.jb;V.prototype.setAudioRendition=V.prototype.ib;V.prototype.setVideoRendition=V.prototype.Ta;V.prototype.setTextTrack=V.prototype.Ba;V.prototype.setAudioTrack=V.prototype.sa;V.prototype.setVideoTrack=V.prototype.Ua;V.prototype.getTextTrack=V.prototype.oa;V.prototype.getAudioTrack=V.prototype.na;V.prototype.getVideoTrack=V.prototype.Ga;V.prototype.getLoadingTextRendition=V.prototype.cb;
41
+ V.prototype.getLoadingAudioRendition=V.prototype.bb;V.prototype.getLoadingVideoRendition=V.prototype.Pa;V.prototype.getTextRendition=V.prototype.Ea;V.prototype.getAudioRendition=V.prototype.Da;V.prototype.getVideoRendition=V.prototype.ia;V.prototype.getTextTracks=V.prototype.ja;V.prototype.getAudioTracks=V.prototype.getAudioTracks;V.prototype.getVideoTracks=V.prototype.getVideoTracks;var qG=class extends _.To{constructor(a){super();this.l=a;this.h=null;this.a=new _.P("clpp.tizen.Middleware");this.C=1;this.B=!1;this.m=null;this.F=0;this.o=!0;this.g=!1;this.f=null;this.A=1;this.w=!1;this.j={}}I(){this.w=!0;this.g||this.trigger(new _.F(YF))}H(a){this.w=!0;this.trigger(new _.F(dG,{percent:a}))}G(){this.w=!1;this.trigger(new _.F(eG))}L(){this.trigger(new _.F(fG))}K(a,b){this.trigger(new _.F(mG,{eventid:a,data:b}))}N(a,b,c,d,e){this.trigger(new _.F(nG,{duration:a,text:b,subtitleType:c,
42
+ attriCount:d,attributes:e}))}J(a,b){this.trigger(new _.F(oG,{drmType:a,drmData:b}));this.h&&(a=this.h,a.j&&(a.a===_.Jc&&"Challenge"===b.name?$E(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))))}T(a){this.trigger(new _.F(pG,{eventType:a}))}play(){const a=this.getState(),b=()=>new Promise((c,d)=>{let e=null;const f=()=>{c();clearTimeout(e)};this.one(OF,f,this);e=setTimeout(()=>{this.off(OF,f);d("Timeout")},3E4)});if(a===hG)return(new Promise((c,
43
+ d)=>{webapis.avplay.prepareAsync(()=>{QF(this);c(webapis.avplay.play())},e=>{this.trigger(new _.F(pG));d(e)})})).then(()=>b());if(a===hF||a===gG)try{return webapis.avplay.play(),b()}catch(c){return Promise.reject(c)}return a===gF?Promise.resolve():Promise.reject("Player is in invalid state")}pause(){try{webapis.avplay.pause()}catch(a){Promise.reject(a)}return this.getState()===hF?Promise.resolve():Promise.reject()}setPlaybackRate(a){const b=this.getState();if(b===gG||b===gF||b===hF){try{webapis.avplay.setSpeed(a),
44
+ this.C=a}catch(c){return this.a.debug("Error while trying to set playback rate",c),this.setPlaybackRate(this.C)}return!0}this.a.debug("Cannot set playback rate; AVPlay is in inconsistent state: "+b);return!1}getPlaybackRate(){return this.C}load(a,b){const c=this;return _.y(function*(){c.a.debug("configure()",b||"");try{yield VF(c),yield bG(c,a,b)}catch(d){throw new _.H(_.G,7,7003,null,d);}})}getState(){if(this.g&&this.f)return this.f.le;try{return webapis.avplay.getState()}catch(a){this.T(JSON.stringify(a))}}seek(a){const b=
45
+ 1E3*a;return new Promise((c,d)=>{this.B=!0;this.l.trigger(new _.F(_.Ce));webapis.avplay.seekTo(b,()=>{this.B=!1;this.l.trigger(new _.F(_.Be));c()},()=>{this.B=!1;d()})})}getPosition(){if(this.g&&this.f)return this.f.position;try{return webapis.avplay.getCurrentTime()/1E3}catch(a){this.T(JSON.stringify(a))}}getDuration(){if(this.g&&this.f)return this.f.duration;try{return webapis.avplay.getDuration()/1E3}catch(a){this.T(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.hd.stop()}this.j={};this.C=1;this.B=!1;this.f=this.m=null;return a()}catch(c){return b(c)}})}getVolume(){let a=null;try{a=tizen.tvaudiocontrol.getVolume()}catch(b){switch(b.name){case SE:this.a.debug("The application does not have the privilege to get the volume.",TE);break;default:this.a.debug(QE,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.a.warn("Invalid value passed for setVolume.",
47
+ "The passed value value should be in the range of 0 to 1.");break;case SE:this.a.warn("The application does not have the privilege to set the volume.",TE);break;default:this.a.warn("An unknown error occurred while trying to set volume",b)}}}isLive(){if(this.g&&this.f)return this.f.isLive;try{return"1"===webapis.avplay.getStreamingProperty("IS_LIVE")}catch(a){this.T(JSON.stringify(a))}}stop(){try{webapis.avplay.stop()}catch(a){this.a.debug(a)}}getDrmInfo(){this.h&&this.h.getDrmInfo();return null}setSourceIndex(a){this.F=
48
+ a}getSourceIndex(){return this.F}getLoadedSource(){return this.m&&this.m[this.getSourceIndex()]}},hG="IDLE",gG="READY",gF="PLAYING",hF="PAUSED",wF=_.sb,xF="AUDIO",GF="TEXT",lG="PLAYER_MSG_RESOLUTION_CHANGED",kG="PLAYER_MSG_BITRATE_CHANGE",dF="PLAYREADY",ZE="WIDEVINE_CDM";var uG=class extends _.To{constructor(){super();this.a=new qG(this);this.f=new iG(this);this.configuration=this.B=_.$i();this.w=null;this.h=new _.P("clpp.tizen.Player");this.j=null;this.m=new V;this.C=new _.Em;this.o=this.g=null;this.A=!1}H(){this.h.debug("On Stream completed. Current time: ",this.getPosition());this.trigger(new _.F(_.Zc));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(_.ue,
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=_.Rg(d))&&this.o.append([new _.ro(b,c,d)],[])}G(a){this.h.debug("DRM event: "+a.drmType+", data: "+a.drmData)}J(){this.A||(this.h.debug("Initial buffering completed..."),this.A=!0)}T(a){this.h.debug(`Error: TYPE: ${a.eventType}`);fF(this.f,_.Dl);a=new _.H(_.G,7,7200,{tizenerror:a.eventType});this.a.release();this.trigger(new _.F(_.$c,{detail:a}))}init(a,
50
+ b){this.configuration=this.B=b;this.w=a;this.a.on(fG,this.H,this);this.a.on(OF,this.F,this);this.a.on(nG,this.I,this);this.a.on(oG,this.G,this);this.a.on(pG,this.T,this);this.a.on(eG,this.J,this);this.f.initialize();this.m.initialize(this);this.h.debug("Initializing player surface");this.w.hideMediaElement();a=rG;rG+=1;a="__clpp_tizen_player_"+a;this.j=_.am(_.Bd,{id:a,type:"application/avplayer"});this.w.addElementToContainer(this.j,!0);var c=this.w.getMedia();if(c){a=this.j;{b=[_.We,_.cd,"position",
51
+ _.hd,"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}_.cm(a,d);cG(this)}}getSurface(){return this.w}getConfiguration(){return this.configuration}destroy(){const a=this;return _.y(function*(){yield a.release();a.a.off(fG,a.H);a.a.off(OF,a.F);a.a.off(nG,a.I);a.a.off(oG,a.G);a.a.off(pG,a.T);a.a.off(eG,a.J);a.g&&(yield a.g.destroy(),a.g=null);a.j&&(a.j.parentElement.removeChild(a.j),
52
+ a.j=null);a.m.destroy();a.f.destroy();a.m=null;a.f=null})}namespace(){return sG}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()===_.wl?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(_.la);return new _.So}getTrackManager(){return this.m}unload(){return this.a.release().then(()=>{this.m.release()})}release(){const a=this;return _.y(function*(){a.g&&(yield a.g.release());a.o&&(yield a.o.destroy(),a.o=null);yield a.a.release();a.m.release();a.f.release();a.A=!1})}load(a){const b=this;return _.y(function*(){_.cj(a)&&
54
+ (b.configuration=_.bj(b.B,a));var c=_.ml(b.configuration,["html","native"]);b.o=c.create(b);c=_.Kl(b.configuration)[0];if(b.configuration.tizen&&b.configuration.tizen.sideStreamText){b.g=new jG;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.m.load()})}play(){this.trigger(new _.F(_.Rd));cG(this);return this.a.play().then(()=>{iF(this.f)})}pause(){return this.a.pause().then(()=>{iF(this.f)})}getState(){return this.f.getState()}getPeriods(){return[]}onError(a){const b=
55
+ new _.F(_.$c,{detail:a});a.severity===_.G&&(fF(this.f,_.Dl),this.a.release());this.trigger(b);b.defaultPrevented&&(b.a=!0)}getDrmInfo(){return this.a.getDrmInfo()}isEnded(){return this.f.getState()===_.wl}isPaused(){return this.a.getState()===hF}isMuted(){return TF(this.a)}setMuted(a){XF(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 tG).canPlay(a,b)}getTimelineCues(){return[]}getTextDisplayer(){return this.o}resetAbr(){}};uG.prototype.getTextDisplayer=uG.prototype.getTextDisplayer;uG.prototype.setNetworkEngine=uG.prototype.setNetworkEngine;uG.prototype.getNetworkEngine=uG.prototype.getNetworkEngine;
57
+ var sG="clpp.tizen",rG=0,tG=class{a(){return sG}canPlay(a){a=a.type;const b=!!window.webapis;if((a===_.Ub||a===_.Ui||a===_.Zb)&&b){if(_.bi(2))return 2;if(_.bi(3)||_.bi(4)||_.bi(5)||_.bi(6))return _.C("Use of clpp.tizen.TizenComponent is not recommended for Tizen version \x3e\x3d 3."),1}return 0}create(){return new uG}};_.A("clpp.tizen.TizenComponent",class extends _.Ap{constructor(){super();this.h=null}f(){this.h=new tG;_.Kf(this.h)}a(){if(this.h){var a=this.h.a();a&&_.If[a]&&(delete _.If[a],_.Jf.info("Removed Player factory: '"+a+"'"));this.h=null}}id(){return"tizen"}});var YF="onbufferingstart",dG="onbufferingprogress",eG="onbufferingcomplete",fG="onstreamcompleted",OF="oncurrentplaytime",mG="onevent",nG="onsubtitlechange",oG="ondrmevent",pG="onerror",$F="preparingstart",aG="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 zr='application/mp4; codecs\x3d"stpp.ttml"',Ar='application/mp4; codecs\x3d"stpp.ttml.im1i"',Br='application/mp4; codecs\x3d"stpp.ttml.im1t"',Cr="backgroundColor",Dr="direction",Er="displayAlign",Fr="region",Gr="textAlign",Hr="textDecoration",Ir="writingMode",Jr=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},Rr=function(a,b){var c=null;if(Kr.test(a)){{a=Kr.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 Lr.test(a)?c=Mr(Lr,a):Nr.test(a)?c=Mr(Nr,a):Or.test(a)?(a=Or.exec(a),c=Number(a[1])/b.frameRate):Pr.test(a)?(a=Pr.exec(a),c=Number(a[1])/b.a):Qr.test(a)&&(c=Mr(Qr,a));return c},Mr=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)},Sr=function(a){return a.split(":").pop()},Tr=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
- "$1em")},Vr=function(a,b){for(;Ur.test(a);){const c=Ur.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Wr=function(a,b,c){a=Jr(a,b,Gr);if(!a&&c&&(a=Jr(c,b,Gr),!a&&"rltb"===Jr(c,b,Ir)))return _.de;switch(a){case _.uc:return _.xo;case _.de:case _.Yc:return _.de;default:return _.id}},Xr=function(a,b,c){if(_.Og(a.o))return document.createTextNode(_.Sg(a.o||""));if(a.w)return _.lm("br");const d=_.lm("span");for(const e of a.f)_.mm(d,e);for(const e of a.h)d.appendChild(Xr(c.get(e),b,c));return d},
4
- $r=function(a,b,c,d){const e=Yr.exec(a);a=Zr.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},as=function(a,b){return typeof b===_.r&&0<b?_.Fo:Zr.test(a)?0:_.Fo},bs=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},cs=function(a,b){a=a.getAttribute("extent");return(a=Zr.exec(a))?Number(a[b]):null},es=function(a){a=a.getAttribute("cellResolution");return(a=ds.exec(a))?Number(a[2]):null},gs=function(){return`${"inline-"}${fs++}`},is=function(a){return hs.some(b=>
5
- b in a.attributes)},js=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...js(a,a.a.get(d).f),d);return c},ks=function(a){return a.m.map(b=>b.build(a.j,a.o,a.w,a.g,a.a,a.h,a.f)).filter(b=>null!=b)},ls=function(a){return Sr(a.g.nodeName)},os=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.j];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.h,f=[...k.f],
6
- g={},ms.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(Fr)&&(c=b.getAttribute(Fr));b.hasAttribute(_.pe)&&f.push(...b.getAttribute(_.pe).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Sr(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new ns(b,c,d,e,f,g);a.a.set(b,c);return c},ps=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,
7
- "0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},qs=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 rs=class extends qs{constructor(a,b,c){super(a,[],c);this.h=b||""}};var ss=class extends qs{constructor(a,b,c){super(a,b,c)}};var Kr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Lr=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Nr=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Or=/^(\d*(?:\.\d*)?)f$/,Pr=/^(\d*(?:\.\d*)?)t$/,Qr=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Yr=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Zr=/^(\d+)px (\d+)px$/,ds=/^(\d+) (\d+)$/,Ur=/(\d+)px/,ts=/^(\d+px|\d+em|\d*\.?\d+c)$/,hs=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
8
- "color",Cr,"opacity","padding","zIndex",Gr,Er,Ir,Dr,Hr,"textOutline"],ms=["begin",_.Yc];var us=class extends ss{constructor(a,b,c,d,e,f,g){super(a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]}build(a,b,c,d,e,f,g){let h=Rr(this.a.begin,b);b=Rr(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.lm(_.Qc);for(const k of this.h)c.appendChild(Xr(g.get(k),e,g));g=new _.Co(h,b,c.innerHTML.trim(),_.xe);g.cssClassList=[...this.f];g.textAlign=Wr(this,e,null);g.writingMode=_.yo;g.line=-1;g.lineInterpretation=_.zo;g.lineAlign=_.Ao;g.containerRows=bs(null,es(a),15);if(this.m&&(f=
9
- f.get(this.m))){g.region=f.build(a,e);g.textAlign=Wr(this,e,f);a:switch(Jr(f,e,Ir)){case "tb":case "tblr":a=_.Ge;break a;case "tbrl":a=_.Ie;break a;default:a=_.yo}g.writingMode=a;a:switch(Jr(f,e,Er)){case _.uc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(Jr(f,e,Er)){case _.uc:a=1;break a;default:a=_.zo}g.lineInterpretation=a;a:switch(Jr(f,e,Er)){case _.uc:e=_.uc;break a;default:e=_.Ao}g.lineAlign=e}this.j&&(d=d.get(this.j))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
- a.getAttribute("imagetype"),a=a.h.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var vs=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 ws=class extends ss{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.Ho;c.id=this.getId();const d=bs(a.h.containerWidth,cs(a,1),720);a=bs(a.h.containerHeight,cs(a,2),480);a:switch(Jr(this,b,Er)){case "after":var e="flex-start";break a;case _.uc:e=_.uc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(Jr(this,b,Ir)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.Gc}c.writingMode=e;e=this.getAttribute("extent")||Jr(this,b,"extent");c.width=$r(e,
11
- d,1,100);c.widthUnits=as(e,d);c.height=$r(e,a,2,100);c.heightUnits=as(e,a);b=this.getAttribute("origin")||Jr(this,b,"origin");c.viewportAnchorX=$r(b,d,1,0);c.viewportAnchorY=$r(b,a,2,0);c.viewportAnchorUnits=as(b,d);c.cssClassList=[...this.f];return c}};var xs=class extends qs{constructor(a,b){super("root-container",[],b);this.h=a}};var zs=class extends qs{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=es(a);c&&(b=bs(a.h.containerHeight,cs(a,2),480)/c);b=bs(a.h.fontSizeRadix,b,16);a=[];c=`::ttml .${this.g}, ::ttml .${this.g} * {`;for(const [g,h]of ys.entries())g in this.a&&(c+=`${h}:${Tr(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&&!ts.test(h)&&ts.test(k)&&ts.test(l)?(e=h,g=k):2===d.length&&!ts.test(h)&&ts.test(k)?(e=h,g=k):2===d.length&&ts.test(h)&&ts.test(k)&&(g=h);if(""!==g){g=Tr(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif","monospace").replace("monospaceSerif",
13
- "monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(Hr 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:"+Tr(this.a.padding),d+=
14
- ";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Tr(d),d=Vr(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=Tr(c);c=Vr(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}},ys=new Map([["color","color"],[Cr,"background-color"],
15
- [Dr,Dr],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var As=class{constructor(a){this.A=a;this.o=this.j=null;this.w=0;this.g=new Map;this.a=new Map;this.h=new Map;this.f=new Map;this.m=[]}},fs=0;var Ds=class{constructor(a){this.a=a.firstChild;this.f=new Set}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!Bs.has(Sr(a.nodeName))||Cs.has(Sr(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&&!Bs.has(Sr(a.nodeName))));const b=this.a;this.a=a;return b}},Bs=new Set(["tt","head","layout",_.td,_.ed,Fr,"styling",_.pe,"body",_.Qc,"p","span","br"]),
16
- Cs=new Set([_.pe,_.ed]);var ns=class{constructor(a,b,c,d,e,f){this.g=a;this.a=b;this.h=c;this.j=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var Es=class{constructor(){this.a=new Map}};var Fs=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.lf(this.a.ttml||{}),e=_.I(a,0,c[0]);e=_.Fg(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.ue)}catch(m){throw new _.H(_.G,2,2005,"Failed to parse TTML.");}d=new As(d);e=new Es;f=new Ds(f);b=b.periodStart;typeof b===_.r&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.I(a,b,h);k=_.Tg(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.g.set(m,
17
- new rs(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.a;)a=f.next(),a=os(e,a),c=d,b=a,"tt"===ls(b)&&(c.j=new xs(c.A,Object.assign({},b.attributes))),c=d,b=a,"tt"===ls(b)&&(c.o=new vs(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,ls(b)!==_.ed||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.g.set(g,new rs(g,b.g.textContent,b.attributes))),c=d,g=a,ls(g)===_.ed&&g.attributes.begin&&g.attributes.end?(b=`#${gs()}`,g=
18
- new rs(b,g.g.textContent,g.attributes),c.g.set(b,g),c=g):c=null,c&&(a.h=c.getId()),c=d,b=a,ls(b)===_.pe&&(g=b.getId()||gs(),h=new zs(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.h.get(b.a).f.push(g)),c=d,g=a,ls(g)!==_.pe&&is(g)?(b=gs(),g=new zs(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,ls(g)!==_.Qc||!g.attributes.extent&&!g.attributes.origin?c=null:(b=gs(),g=new ws(b,js(c,g.f),Object.assign({},g.attributes)),c.h.set(b,g),c=g),c&&(a.a=
19
- c.getId()),c=d,g=a,ls(g)!==Fr?c=null:(b=g.getId(),g=new ws(b,js(c,g.f),Object.assign({},g.attributes)),c.h.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.j,-1===["#text","span","br"].indexOf(ls(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=gs(),g=new us(b,"#text"===g.g.nodeName?g.g.textContent:null,"br"===ls(g),g.a,g.h,js(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.h.push(b),c=g):c=null),c&&a.j.push(c.getId()),c=d,g=a,"p"===ls(g)||g.h?(b=gs(),g=new us(b,null,!1,g.a,g.h,js(c,g.f),g.attributes),
20
- c.f.set(b,g),c.m.push(g),c=g):c=null,c&&a.j.push(c.getId());e=ks(d);f=[];for(l of d.a.values())f.push(...l.build(d.j));var l=f;return{cues:e,styles:l}}};var Gs=class{constructor(a){this.f=a}a(a){var b=new Fs(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=ps(d.startTime)+" --\x3e "+ps(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.id:e.push("align:left");break;case _.de:e.push("align:right");break;case _.xo:e.push("align:middle");break;case _.id:e.push("align:start");break;case _.de:e.push("align:end")}switch(c.writingMode){case _.Ge:e.push("vertical:lr");break;case _.Ie:e.push("vertical:rl")}c=
21
- e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Jg(b)}},Hs=class{probe(a,b){return a===_.Zb&&b===_.te}create(a){return new Gs(a)}};var Is=class{constructor(a){this.f=new Fs(a);this.a=new _.O("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Mj).L(_.wd,_.Fj).L(_.we,_.Fj).L(_.rd,_.Fj).L(_.vd,_.Fj).L(_.me,_.Fj).Y(_.oe,_.Gj).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 _.Mj).L("moof",_.Fj).L("traf",_.Fj).Y("subs",g=>{const h=_.N(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.yj(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
- _.N(g.reader):_.yj(g.reader);f.push(n);g.reader.skip(6)}}}).L(_.qd,_.Hj(g=>{c=!0;g=this.f.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.a.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.z("clpp.ttml.TtmlComponent",class extends _.Mp{constructor(){super();this.h=new Hs}f(){_.io[_.Zb]=Fs;_.io[_.Xb]=Is;_.io[zr]=Is;_.io[Br]=Is;_.io[Ar]=Is;_.Sh.push(this.h)}a(){_.jo(_.Zb);_.jo(_.Xb);_.jo(zr);_.jo(Br);_.jo(Ar);_.Uh(this.h)}id(){return _.re}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var pr='application/mp4; codecs\x3d"stpp.ttml"',qr='application/mp4; codecs\x3d"stpp.ttml.im1i"',rr='application/mp4; codecs\x3d"stpp.ttml.im1t"',sr="backgroundColor",tr="direction",ur="displayAlign",vr="region",wr="textAlign",xr="textDecoration",yr="writingMode",zr=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},Hr=function(a,b){var c=null;if(Ar.test(a)){{a=Ar.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 Br.test(a)?c=Cr(Br,a):Dr.test(a)?c=Cr(Dr,a):Er.test(a)?(a=Er.exec(a),c=Number(a[1])/b.frameRate):Fr.test(a)?(a=Fr.exec(a),c=Number(a[1])/b.a):Gr.test(a)&&(c=Cr(Gr,a));return c},Cr=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)},Ir=function(a){return a.split(":").pop()},Jr=function(a){return a.replace(/(\d*\.?\d+)c/g,
3
+ "$1em")},Lr=function(a,b){for(;Kr.test(a);){const c=Kr.exec(a)[0];a=a.replace(c,`${parseInt(c,10)/b}em`)}return a},Mr=function(a,b,c){a=zr(a,b,wr);if(!a&&c&&(a=zr(c,b,wr),!a&&"rltb"===zr(c,b,yr)))return _.ce;switch(a){case _.tc:return _.mo;case _.ce:case _.Yc:return _.ce;default:return _.hd}},Nr=function(a,b,c){if(_.Ng(a.o))return document.createTextNode(_.Rg(a.o||""));if(a.w)return _.am("br");const d=_.am("span");for(const e of a.f)_.bm(d,e);for(const e of a.h)d.appendChild(Nr(c.get(e),b,c));return d},
4
+ Qr=function(a,b,c,d){const e=Or.exec(a);a=Pr.exec(a);return typeof b===_.r&&0<b&&a?100*Number(a[c])/b:e?Number(e[c]):a?Number(a[c]):d},Rr=function(a,b){return typeof b===_.r&&0<b?_.uo:Pr.test(a)?0:_.uo},Sr=function(a,b,c){return typeof a===_.r?a:typeof b===_.r?b:c},Tr=function(a,b){a=a.getAttribute("extent");return(a=Pr.exec(a))?Number(a[b]):null},Vr=function(a){a=a.getAttribute("cellResolution");return(a=Ur.exec(a))?Number(a[2]):null},Xr=function(){return`${"inline-"}${Wr++}`},Zr=function(a){return Yr.some(b=>
5
+ b in a.attributes)},$r=function(a,b){if(0===b.length)return[];const c=[];for(const d of b)a.a.has(d)&&c.push(...$r(a,a.a.get(d).f),d);return c},as=function(a){return a.m.map(b=>b.build(a.j,a.o,a.w,a.g,a.a,a.h,a.f)).filter(b=>null!=b)},bs=function(a){return Ir(a.g.nodeName)},es=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.j];-1===["#text","span","br"].indexOf(b.nodeName)&&(c=k.a,d=k.h,f=[...k.f],
6
+ g={},cs.forEach(l=>{l in k.attributes&&(g[l]=k.attributes[l])}))}if(b.nodeType===b.ELEMENT_NODE){b.hasAttribute(vr)&&(c=b.getAttribute(vr));b.hasAttribute(_.oe)&&f.push(...b.getAttribute(_.oe).split(" "));d=Array.from(b.attributes).map(k=>k.name);for(const k of d)d=Ir(k),g[d]=b.getAttribute(k);d=g.backgroundImage}c=new ds(b,c,d,e,f,g);a.a.set(b,c);return c},fs=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,
7
+ "0")}.${String(Math.floor(1E3*a%1E3)).padStart(3,"0")}`},gs=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 hs=class extends gs{constructor(a,b,c){super(a,[],c);this.h=b||""}};var is=class extends gs{constructor(a,b,c){super(a,b,c)}};var Ar=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Br=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Dr=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d+)$/,Er=/^(\d*(?:\.\d*)?)f$/,Fr=/^(\d*(?:\.\d*)?)t$/,Gr=/^(?:(\d*(?:\.\d*)?)h)?(?:(\d*(?:\.\d*)?)m)?(?:(\d*(?:\.\d*)?)s)?(?:(\d*(?:\.\d*)?)ms)?$/,Or=/^(\d{1,2}(?:\.\d+)?|100(?:\.0+)?)% (\d{1,2}(?:\.\d+)?|100(?:\.0+)?)%$/,Pr=/^(\d+)px (\d+)px$/,Ur=/^(\d+) (\d+)$/,Kr=/(\d+)px/,js=/^(\d+px|\d+em|\d*\.?\d+c)$/,Yr=["fontStyle","fontSize","fontFamily","fontWeight","lineHeight",
8
+ "color",sr,"opacity","padding","zIndex",wr,ur,yr,tr,xr,"textOutline"],cs=["begin",_.Yc];var ks=class extends is{constructor(a,b,c,d,e,f,g){super(a,f,g);this.o=b;this.w=c;this.m=d;this.j=e;this.h=[]}build(a,b,c,d,e,f,g){let h=Hr(this.a.begin,b);b=Hr(this.a.end,b);if(null===h||null===b)return null;h+=c;b+=c;c=_.am(_.Qc);for(const k of this.h)c.appendChild(Nr(g.get(k),e,g));g=new _.ro(h,b,c.innerHTML.trim(),_.we);g.cssClassList=[...this.f];g.textAlign=Mr(this,e,null);g.writingMode=_.no;g.line=-1;g.lineInterpretation=_.oo;g.lineAlign=_.po;g.containerRows=Sr(null,Vr(a),15);if(this.m&&(f=
9
+ f.get(this.m))){g.region=f.build(a,e);g.textAlign=Mr(this,e,f);a:switch(zr(f,e,yr)){case "tb":case "tblr":a=_.Ee;break a;case "tbrl":a=_.Fe;break a;default:a=_.no}g.writingMode=a;a:switch(zr(f,e,ur)){case _.tc:a=50;break a;case "after":a=-1;break a;default:a=0}g.line=a;a:switch(zr(f,e,ur)){case _.tc:a=1;break a;default:a=_.oo}g.lineInterpretation=a;a:switch(zr(f,e,ur)){case _.tc:e=_.tc;break a;default:e=_.po}g.lineAlign=e}this.j&&(d=d.get(this.j))&&(a=d,d=a.getAttribute("encoding"),e=a.getAttribute("imageType")||
10
+ a.getAttribute("imagetype"),a=a.h.trim(),d="PNG"===e&&"Base64"===d&&0<a.length?`data:image/png;base64,${a}`:null,g.backgroundImage=d||"");return g}};var ls=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 ms=class extends is{constructor(a,b,c){super(a,b,c)}build(a,b){const c=new _.wo;c.id=this.getId();const d=Sr(a.h.containerWidth,Tr(a,1),720);a=Sr(a.h.containerHeight,Tr(a,2),480);a:switch(zr(this,b,ur)){case "after":var e="flex-start";break a;case _.tc:e=_.tc;break a;default:e="flex-end"}c.displayAlign=e;a:switch(zr(this,b,yr)){case "tb":case "tblr":e="row-reverse";break a;case "tbrl":e="row";break a;default:e=_.Fc}c.writingMode=e;e=this.getAttribute("extent")||zr(this,b,"extent");c.width=Qr(e,
11
+ d,1,100);c.widthUnits=Rr(e,d);c.height=Qr(e,a,2,100);c.heightUnits=Rr(e,a);b=this.getAttribute("origin")||zr(this,b,"origin");c.viewportAnchorX=Qr(b,d,1,0);c.viewportAnchorY=Qr(b,a,2,0);c.viewportAnchorUnits=Rr(b,d);c.cssClassList=[...this.f];return c}};var ns=class extends gs{constructor(a,b){super("root-container",[],b);this.h=a}};var ps=class extends gs{constructor(a,b,c){super(a,b,c)}build(a){var b=null;var c=Vr(a);c&&(b=Sr(a.h.containerHeight,Tr(a,2),480)/c);b=Sr(a.h.fontSizeRadix,b,16);a=[];c=`::ttml .${this.g}, ::ttml .${this.g} * {`;for(const [g,h]of os.entries())g in this.a&&(c+=`${h}:${Jr(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&&!js.test(h)&&js.test(k)&&js.test(l)?(e=h,g=k):2===d.length&&!js.test(h)&&js.test(k)?(e=h,g=k):2===d.length&&js.test(h)&&js.test(k)&&(g=h);if(""!==g){g=Jr(g);d="text-shadow:"+`0 0 ${g} ${e},`+`0 0 ${g} ${e},`+`0 0 ${g} ${e};`;break a}}d=""}c=c+d+("fontFamily"in this.a?`font-family:${this.a.fontFamily.replace("monospaceSansSerif","monospace").replace("monospaceSerif",
13
+ "monospace").replace("proportionalSansSerif","sans-serif").replace("proportionalSerif","sans-serif").replace("sansSerif","sans-serif").replace("default","sans-serif")};`:"");a:{if(xr 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:"+Jr(this.a.padding),d+=
14
+ ";"):d="";f=c=c+f+d;"lineHeight"in this.a?(c="",d=this.a.lineHeight,d=Jr(d),d=Lr(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=Jr(c);c=Lr(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}},os=new Map([["color","color"],[sr,"background-color"],
15
+ [tr,tr],["fontStyle","font-style"],["fontWeight","font-weight"],["opacity","opacity"],["zIndex","z-index"]]);var qs=class{constructor(a){this.A=a;this.o=this.j=null;this.w=0;this.g=new Map;this.a=new Map;this.h=new Map;this.f=new Map;this.m=[]}},Wr=0;var ts=class{constructor(a){this.a=a.firstChild;this.f=new Set}next(){if(!this.a)return null;let a=this.a;do this.f.add(a),a.nodeType!==Node.TEXT_NODE&&!rs.has(Ir(a.nodeName))||ss.has(Ir(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&&!rs.has(Ir(a.nodeName))));const b=this.a;this.a=a;return b}},rs=new Set(["tt","head","layout",_.td,_.ed,vr,"styling",_.oe,"body",_.Qc,"p","span","br"]),
16
+ ss=new Set([_.oe,_.ed]);var ds=class{constructor(a,b,c,d,e,f){this.g=a;this.a=b;this.h=c;this.j=d;this.f=e;this.attributes=f}getId(){return this.attributes.id}};var us=class{constructor(){this.a=new Map}};var vs=class{constructor(a){this.a=a;this.f=new DOMParser}parseInit(){}parseMedia(a,b,c){c&&c.length||(c=[a.byteLength]);var d=_.kf(this.a.ttml||{}),e=_.I(a,0,c[0]);e=_.Eg(e);if(""===e)return{cues:[],styles:[]};var f=null;try{f=this.f.parseFromString(e,_.te)}catch(m){throw new _.H(_.G,2,2005,"Failed to parse TTML.");}d=new qs(d);e=new us;f=new ts(f);b=b.periodStart;typeof b===_.r&&(d.w=b);b=c[0];for(var g=1;g<c.length;++g){var h=c[g],k=_.I(a,b,h);k=_.Sg(k);const m=`urn:mpeg:14496-30:subs:${g}`;d.g.set(m,
17
+ new hs(m,k,{imageType:"PNG",encoding:"Base64"}));b+=h}for(;f.a;)a=f.next(),a=es(e,a),c=d,b=a,"tt"===bs(b)&&(c.j=new ns(c.A,Object.assign({},b.attributes))),c=d,b=a,"tt"===bs(b)&&(c.o=new ls(b.attributes.frameRate,b.attributes.subFrameRate,b.attributes.frameRateMultiplier,b.attributes.tickRate)),c=d,b=a,bs(b)!==_.ed||b.attributes.begin||b.attributes.end||(g=`#${b.getId()}`,c.g.set(g,new hs(g,b.g.textContent,b.attributes))),c=d,g=a,bs(g)===_.ed&&g.attributes.begin&&g.attributes.end?(b=`#${Xr()}`,g=
18
+ new hs(b,g.g.textContent,g.attributes),c.g.set(b,g),c=g):c=null,c&&(a.h=c.getId()),c=d,b=a,bs(b)===_.oe&&(g=b.getId()||Xr(),h=new ps(g,b.f,Object.assign({},b.attributes)),c.a.set(g,h),b.a&&c.h.get(b.a).f.push(g)),c=d,g=a,bs(g)!==_.oe&&Zr(g)?(b=Xr(),g=new ps(b,[],Object.assign({},g.attributes)),c.a.set(b,g),c=g):c=null,c&&a.f.push(c.getId()),c=d,g=a,bs(g)!==_.Qc||!g.attributes.extent&&!g.attributes.origin?c=null:(b=Xr(),g=new ms(b,$r(c,g.f),Object.assign({},g.attributes)),c.h.set(b,g),c=g),c&&(a.a=
19
+ c.getId()),c=d,g=a,bs(g)!==vr?c=null:(b=g.getId(),g=new ms(b,$r(c,g.f),Object.assign({},g.attributes)),c.h.set(b,g),c=g),c&&(a.a=c.getId()),c=d,g=a,b=g.j,-1===["#text","span","br"].indexOf(bs(g))||0===b.length?c=null:(h=b[b.length-1],c.f.has(h)?(b=Xr(),g=new ks(b,"#text"===g.g.nodeName?g.g.textContent:null,"br"===bs(g),g.a,g.h,$r(c,g.f),g.attributes),c.f.set(b,g),(c=c.f.get(h))&&c.h.push(b),c=g):c=null),c&&a.j.push(c.getId()),c=d,g=a,"p"===bs(g)||g.h?(b=Xr(),g=new ks(b,null,!1,g.a,g.h,$r(c,g.f),g.attributes),
20
+ c.f.set(b,g),c.m.push(g),c=g):c=null,c&&a.j.push(c.getId());e=as(d);f=[];for(l of d.a.values())f.push(...l.build(d.j));var l=f;return{cues:e,styles:l}}};var ws=class{constructor(a){this.f=a}a(a){var b=new vs(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=fs(d.startTime)+" --\x3e "+fs(d.endTime);{var c=d;const e=[];switch(c.textAlign){case _.hd:e.push("align:left");break;case _.ce:e.push("align:right");break;case _.mo:e.push("align:middle");break;case _.hd:e.push("align:start");break;case _.ce:e.push("align:end")}switch(c.writingMode){case _.Ee:e.push("vertical:lr");break;case _.Fe:e.push("vertical:rl")}c=
21
+ e.length?" "+e.join(" "):""}b=a+(b+c+"\n");b+=d.payload+"\n\n"}return _.Ig(b)}},xs=class{probe(a,b){return a===_.Yb&&b===_.se}create(a){return new ws(a)}};var ys=class{constructor(a){this.f=new vs(a);this.a=new _.P("clpp.ttml.Mp4TtmlParser")}parseInit(a){let b=!1;(new _.Lj).M(_.wd,_.Ej).M(_.ve,_.Ej).M(_.rd,_.Ej).M(_.vd,_.Ej).M(_.le,_.Ej).Z(_.ne,_.Fj).M("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 _.Lj).M("moof",_.Ej).M("traf",_.Ej).Z("subs",g=>{const h=_.N(g.reader);for(let k=0;k<h;++k){g.reader.skip(4);const l=_.xj(g.reader);for(let m=0;m<l;++m){const n=1===g.version?
22
+ _.N(g.reader):_.xj(g.reader);f.push(n);g.reader.skip(6)}}}).M(_.qd,_.Gj(g=>{c=!0;g=this.f.parseMedia(g,b,f);d=d.concat(g.cues);e=e.concat(g.styles)})).parse(a);c||this.a.warn("Couldn't find the mdat box");return{cues:d,styles:e}}};_.A("clpp.ttml.TtmlComponent",class extends _.Ap{constructor(){super();this.h=new xs}f(){_.Xn[_.Yb]=vs;_.Xn[_.Wb]=ys;_.Xn[pr]=ys;_.Xn[rr]=ys;_.Xn[qr]=ys;_.Rh.push(this.h)}a(){_.Yn(_.Yb);_.Yn(_.Wb);_.Yn(pr);_.Yn(rr);_.Yn(qr);_.Th(this.h)}id(){return _.qe}});};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 or="VerimatrixVCAS",pr="clpp.verimatrix.Vcas",qr="clpp.verimatrix.VcasComponent",sr=function(a,b){return a.C===rr?(a=Object.assign({},{deviceId:_.Wg(_.Lg(a.A))},a.a&&{authenticator:_.Wg(_.Lg(a.a))}),b+_.Bh(a)):b},yr=class extends _.hp{constructor(a){super(or);const b={};b[tr]=tr;b[ur]=ur;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=rr,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
- vr}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=sr(this,g);this.o=sr(this,h);this.m=sr(this,k);this.j=l;this.G=m;this.F=n;this.f=new _.O(pr);_.Pg(this.w)?this.f.warn(_.vb):this.Ia(_.Kc,{licenseUrl:this.w,videoRobustness:[_.fb,void 0],audioRobustness:[_.eb,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.Pg(this.o)?this.f.warn(_.Va):this.Ia(_.Jc,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
- modifiers:{licenseRequest:this.h.bind(this)}});_.Pg(this.m)?this.f.warn(_.Ba):_.Pg(this.j)?this.f.warn(_.Aa):this.Ia(_.Ic,{licenseUrl:this.m,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===wr){a=this.B[ur];const c={};c[this.B[tr]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Lj(b);switch(this.F){case xr:a=_.Bh({r:a,Lg:this.G},!0)}return a}J(a,b){this.h(a,
4
- b);_.Qj(b)}K(a,b){_.Rj(b)}};_.z(pr,yr);yr.prototype.constructor=yr.prototype.constructor;yr.NAME=or;var rr="query-string",wr="http-header";yr.LicenseRequestVuidLocation={QUERY_STRING:rr,HTTP_HEADER:wr};var tr="DeviceId",ur="Authenticator";yr.LicenseRequestHttpHeader={DEVICE_ID_HEADER:tr,AUTHENTICATOR_HEADER:ur};var vr="keyid",xr="contentid-siteid";yr.FairPlayAssetIdStrategy={KEYID:vr,CONTENTID_SITEID:xr};_.z(qr,class extends _.Mp{constructor(){super();this.l=null;this.h=new _.O(qr)}f(a){this.l=a}a(){this.l=null}g(){var a=this.l.getConfiguration();if(a.drm&&a.drm.env===or){({customData:a}=a.drm);if(!a)throw new _.H(_.G,7,7100,_.Lc);a=new yr(a);this.h.info("Registering the Verimatrix VCAS Ultra environment");_.nj(a)}}release(){}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 er="VerimatrixVCAS",fr="clpp.verimatrix.Vcas",gr="clpp.verimatrix.VcasComponent",ir=function(a,b){return a.C===hr?(a=Object.assign({},{deviceId:_.Tg(_.Kg(a.A))},a.a&&{authenticator:_.Tg(_.Kg(a.a))}),b+_.Ah(a)):b},or=class extends _.Yo{constructor(a){super(er);const b={};b[jr]=jr;b[kr]=kr;const {deviceId:c,authenticator:d,licenseRequestVuidLocation:e=hr,httpHeaderNames:f=b,widevineLicenseUrl:g,playReadyLicenseUrl:h,fairPlayLicenseUrl:k,fairPlayCertificateUrl:l,fairPlaySiteId:m,fairPlayAssetIdStrategy:n=
2
+ lr}=a;this.A=c;this.a=d;this.C=e;this.B=f;this.w=ir(this,g);this.o=ir(this,h);this.m=ir(this,k);this.j=l;this.G=m;this.F=n;this.f=new _.P(fr);_.Og(this.w)?this.f.warn(_.ub):this.Ia(_.Jc,{licenseUrl:this.w,videoRobustness:[_.eb,void 0],audioRobustness:[_.db,void 0],persistentStateRequired:!1,distinctiveIdentifierRequired:!1,serverCertificate:null,modifiers:{licenseRequest:this.h.bind(this)}});_.Og(this.o)?this.f.warn(_.Ua):this.Ia(_.Ic,{licenseUrl:this.o,videoRobustness:["3000"],audioRobustness:["2000"],
3
+ modifiers:{licenseRequest:this.h.bind(this)}});_.Og(this.m)?this.f.warn(_.Aa):_.Og(this.j)?this.f.warn(_.za):this.Ia(_.Hc,{licenseUrl:this.m,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===mr){a=this.B[kr];const c={};c[this.B[jr]]=this.A;this.a&&(c[a]=this.a);Object.keys(c).forEach(d=>{b.headers[d]=c[d]})}}H(a,b){a=_.Kj(b);switch(this.F){case nr:a=_.Ah({r:a,Lg:this.G},!0)}return a}J(a,b){this.h(a,
4
+ b);_.Pj(b)}K(a,b){_.Qj(b)}};_.A(fr,or);or.prototype.constructor=or.prototype.constructor;or.NAME=er;var hr="query-string",mr="http-header";or.LicenseRequestVuidLocation={QUERY_STRING:hr,HTTP_HEADER:mr};var jr="DeviceId",kr="Authenticator";or.LicenseRequestHttpHeader={DEVICE_ID_HEADER:jr,AUTHENTICATOR_HEADER:kr};var lr="keyid",nr="contentid-siteid";or.FairPlayAssetIdStrategy={KEYID:lr,CONTENTID_SITEID:nr};_.A(gr,class extends _.Ap{constructor(){super();this.l=null;this.h=new _.P(gr)}f(a){this.l=a}a(){this.l=null}g(){var a=this.l.getConfiguration();if(a.drm&&a.drm.env===er){({customData:a}=a.drm);if(!a)throw new _.H(_.G,7,7100,_.Kc);a=new or(a);this.h.info("Registering the Verimatrix VCAS Ultra environment");_.mj(a)}}release(){}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 fr="Registering listeners",gr="clpp.vimond.VimondPlugin",hr=function(a,b){a.l.trigger(new _.F(_.Ne,{detail:b}))},ir=function(a,b,c){b&&(a.B=!0,a.h.stop());a.l.onError(new _.H(b?_.G:1,9,9201,c))},jr=function(a,b){const c=a.l.getState();if(1===b)return["str-start",_.Td];if(a.h)return[_.Yc,_.Od];if(c===_.Hl)return[_.Yc,null];if(c===_.Ol)return[_.$c,_.Od];b=_.Od;if(c===_.Kl||c===_.Sl||a.f)b=_.Td;return["period",b]},kr=class{constructor(a,b,c,d,e){this.K=a;this.M=b;this.O=c;this.l=d;this.F=
2
- e;this.f=new _.uo;this.m=!0;this.g=this.j=this.B=!1;this.C=null;this.h=new _.Zh(this.A.bind(this));this.a=new _.O("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.l&&this.f&&(this.a.debug(fr),this.f.on(this.l,_.ke,this.I.bind(this)),this.f.on(this.l,_.ve,this.J.bind(this)),this.f.on(this.l,_.xb,this.G.bind(this)),this.f.on(this.l,_.yb,this.H.bind(this)))}J(){this.g||(this.g=1<Math.abs(this.w-this.l.getPosition()));this.w=this.l.getPosition()}G(){this.a.debug("Ad break started");this.j=!0}H(){this.a.debug("Ad break stopped");
3
- this.j=!1}I(a){const b=this;return _.y(function*(){const c=a.detail,d=c.currentState;b.a.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.g?b.m&&d!==_.Sl||(b.g&&[_.Rl,_.Kl].includes(d)?b.a.debug("Seeking"):(b.g&&d===_.Sl&&(b.a.debug("Seeked"),b.g=!1),[_.Sl,_.Rl,_.Ol,_.Hl].includes(d)&&(b.C=d,yield b.A(),d===_.Hl&&b.h.stop()))):b.a.debug("Ignore transition"))})}A(){const a=this;return _.y(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.a.debug(`Last event was ${n-
4
- a.o} seconds ago`);a.o=n}a.h.stop();a.h.$(a.m?10:a.K);a.m=!1;try{{var b=a.F;b.f++;const q=_.kf(b.o);q.client.buildName=_.oa;q.client.buildVersion=_.da;var c=q.client;{const A=b.a.l.getDrmInfo();var d=A?A.keySystem:""}c.drm=d;q.client.pageUrl=document.location.href;q.client.streamUrl=b.a.l.getLoadedSource().url;q.client.userAgent=navigator.userAgent;q.client.videoFormat=b.a.l.getLoadedSource().type||"";var e=q.client;{const A=b.a.l.getLoadedSource();var f=((new _.Kj(A.url)).scheme||"").replace(":",
5
- "")}e.videoProtocol=f;const t=jr(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 u=q.progress.live;if(u){{var g=b.a;const A=g.l.getPresentationStartTime()||0,E=Math.floor(A+g.l.getPosition());var h=(new Date(1E3*E)).toISOString()}u.position=h;{var k=b.a;const A=k.l.getPosition(),E=k.l.getSeekRange().end;var l=30>Math.abs(E-A)}u.onLiveEdge=l;typeof u.liveResumePossible!==_.ic&&(u.liveResumePossible=!0)}q.progress.eventNumber=
6
- b.f;q.timestamp=(new Date).toISOString();b.h.debug("Fire an event");const x=_.kh(b.m);x.method="POST";x.contentType="application/json";x.headers.Authorization=`Bearer ${b.g}`;x.body=_.Lg(JSON.stringify(q));var m=b.j.fetch(x).P}const n=yield m;hr(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.a.debug("Unreachable service"),hr(a,b),ir(a,a.M,b)):1001===m?(a.a.debug("Generic service error"),hr(a,b),ir(a,a.O,b)):a.a.error(n.toString())}})}dispose(){this.a.debug(_.pb);_.Nf(this.f);this.h.stop()}};var lr=class{constructor(a,b,c,d,e){this.m=a;this.o=c;this.g=b;this.a=d;this.j=e;this.h=new _.O("clpp.vimond.VimondService");this.f=0}de(a){this.g=a}};var mr=class{constructor(a){this.l=a;this.a=new _.uo;this.g=new _.O("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.l&&this.a&&(this.g.debug(fr),this.a.on(this.l,_.$d,this.o.bind(this)),this.a.on(this.l,_.xb,this.j.bind(this)),this.a.on(this.l,_.yb,this.m.bind(this)))}getPosition(){return Math.floor(this.l.getPosition())}o(){this.h=!0}j(){this.f=!0}m(){this.f=!1}dispose(){this.g.debug(_.pb);_.Nf(this.a)}};var nr=class extends _.kq{constructor(){super();this.a=!1;this.h=new _.O(gr);this.j=this.g=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Bd)?a.namespace()===_.Ac&&(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!==_.ic&&(c=!0);var d=b.failOnError;typeof d!==_.ic&&(d=!0);this.f=new mr(a);this.g=new lr(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new kr(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"}de(a){this.a&&
8
- this.g&&this.g.de(a)}};_.z(gr,nr);nr.prototype.updateAuthToken=nr.prototype.de;nr.Id="vimond";_.Sm(new class{create(){return new nr}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Wq="Registering listeners",Xq="clpp.vimond.VimondPlugin",Yq=function(a,b){a.l.trigger(new _.F(_.Me,{detail:b}))},Zq=function(a,b,c){b&&(a.B=!0,a.h.stop());a.l.onError(new _.H(b?_.G:1,9,9201,c))},$q=function(a,b){const c=a.l.getState();if(1===b)return["str-start",_.Sd];if(a.h)return[_.Yc,_.Ld];if(c===_.wl)return[_.Yc,null];if(c===_.Dl)return[_.$c,_.Ld];b=_.Ld;if(c===_.zl||c===_.Hl||a.f)b=_.Sd;return["period",b]},ar=class{constructor(a,b,c,d,e){this.K=a;this.L=b;this.N=c;this.l=d;this.F=
2
+ e;this.f=new _.jo;this.m=!0;this.g=this.j=this.B=!1;this.C=null;this.h=new _.Yh(this.A.bind(this));this.a=new _.P("clpp.vimond.VimondDispatcher");this.o=this.w=0;this.l&&this.f&&(this.a.debug(Wq),this.f.on(this.l,_.je,this.I.bind(this)),this.f.on(this.l,_.ue,this.J.bind(this)),this.f.on(this.l,_.wb,this.G.bind(this)),this.f.on(this.l,_.xb,this.H.bind(this)))}J(){this.g||(this.g=1<Math.abs(this.w-this.l.getPosition()));this.w=this.l.getPosition()}G(){this.a.debug("Ad break started");this.j=!0}H(){this.a.debug("Ad break stopped");
3
+ this.j=!1}I(a){const b=this;return _.y(function*(){const c=a.detail,d=c.currentState;b.a.debug(`State changed, prev: ${c.previousState} curr: ${d}`);b.B||b.j||(d!==b.C||b.g?b.m&&d!==_.Hl||(b.g&&[_.Gl,_.zl].includes(d)?b.a.debug("Seeking"):(b.g&&d===_.Hl&&(b.a.debug("Seeked"),b.g=!1),[_.Hl,_.Gl,_.Dl,_.wl].includes(d)&&(b.C=d,yield b.A(),d===_.wl&&b.h.stop()))):b.a.debug("Ignore transition"))})}A(){const a=this;return _.y(function*(){{const n=Math.floor(Date.now()/1E3);0<a.o&&a.a.debug(`Last event was ${n-
4
+ a.o} seconds ago`);a.o=n}a.h.stop();a.h.ca(a.m?10:a.K);a.m=!1;try{{var b=a.F;b.f++;const q=_.jf(b.o);q.client.buildName=_.ma;q.client.buildVersion=_.da;var c=q.client;{const z=b.a.l.getDrmInfo();var d=z?z.keySystem:""}c.drm=d;q.client.pageUrl=document.location.href;q.client.streamUrl=b.a.l.getLoadedSource().url;q.client.userAgent=navigator.userAgent;q.client.videoFormat=b.a.l.getLoadedSource().type||"";var e=q.client;{const z=b.a.l.getLoadedSource();var f=((new _.Jj(z.url)).scheme||"").replace(":",
5
+ "")}e.videoProtocol=f;const t=$q(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 u=q.progress.live;if(u){{var g=b.a;const z=g.l.getPresentationStartTime()||0,E=Math.floor(z+g.l.getPosition());var h=(new Date(1E3*E)).toISOString()}u.position=h;{var k=b.a;const z=k.l.getPosition(),E=k.l.getSeekRange().end;var l=30>Math.abs(E-z)}u.onLiveEdge=l;typeof u.liveResumePossible!==_.hc&&(u.liveResumePossible=!0)}q.progress.eventNumber=
6
+ b.f;q.timestamp=(new Date).toISOString();b.h.debug("Fire an event");const x=_.jh(b.m);x.method="POST";x.contentType="application/json";x.headers.Authorization=`Bearer ${b.g}`;x.body=_.Kg(JSON.stringify(q));var m=b.j.fetch(x).P}const n=yield m;Yq(a,n)}catch(n){m=n.code,b=n.data,[1002,1003].includes(m)?(a.a.debug("Unreachable service"),Yq(a,b),Zq(a,a.L,b)):1001===m?(a.a.debug("Generic service error"),Yq(a,b),Zq(a,a.N,b)):a.a.error(n.toString())}})}dispose(){this.a.debug(_.ob);_.Mf(this.f);this.h.stop()}};var br=class{constructor(a,b,c,d,e){this.m=a;this.o=c;this.g=b;this.a=d;this.j=e;this.h=new _.P("clpp.vimond.VimondService");this.f=0}de(a){this.g=a}};var cr=class{constructor(a){this.l=a;this.a=new _.jo;this.g=new _.P("clpp.vimond.VimondAdapter");this.f=this.h=!1;this.l&&this.a&&(this.g.debug(Wq),this.a.on(this.l,_.Zd,this.o.bind(this)),this.a.on(this.l,_.wb,this.j.bind(this)),this.a.on(this.l,_.xb,this.m.bind(this)))}getPosition(){return Math.floor(this.l.getPosition())}o(){this.h=!0}j(){this.f=!0}m(){this.f=!1}dispose(){this.g.debug(_.ob);_.Mf(this.a)}};var dr=class extends _.aq{constructor(){super();this.a=!1;this.h=new _.P(Xq);this.j=this.g=this.f=null}onPlayerCreated(){}onContentWillLoad(a){var b=a.getConfiguration();(this.a=!_.B(b.vimond)&&typeof b.vimond===_.Bd)?a.namespace()===_.zc&&(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!==_.hc&&(c=!0);var d=b.failOnError;typeof d!==_.hc&&(d=!0);this.f=new cr(a);this.g=new br(b.playerEventRequest.uri,b.authToken,b.playerEventRequest.body,this.f,a.getNetworkEngine());this.j=new ar(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"}de(a){this.a&&
8
+ this.g&&this.g.de(a)}};_.A(Xq,dr);dr.prototype.updateAuthToken=dr.prototype.de;dr.Id="vimond";_.Hm(new class{create(){return new dr}});};f.call(g, window);
package/cl.vr.js CHANGED
@@ -1,15 +1,15 @@
1
- import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Mq="touchmove",Nq="touchstart",Pq=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new Oq(a/d*e,b/d*e,0/d*e,Math.cos(c))},Qq=function(a,b){const c=a.x,d=a.y,e=a.a;a=a.f;b.set(1-2*(d*d+e*e),2*(c*d-e*a),2*(c*e+d*a),0,2*(c*d+e*a),1-2*(c*c+e*e),2*(d*e-c*a),0,2*(c*e-d*a),2*(d*e+c*a),1-2*(c*c+d*d),0,0,0,0,1)},Rq=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},Sq=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},Tq=function(a,b,c){const d=b.x,e=b.y;
2
- b=b.a;const f=c.x,g=c.y;c=c.a;a.x=e*c-b*g;a.y=b*f-d*c;a.a=d*g-e*f;return a},Uq=function(a,b,c){b=b.a;c=c.a;const d=a.a;let e=0;do d[4*e]=b[4*e]*c[0]+b[4*e+1]*c[4]+b[4*e+2]*c[8]+b[4*e+3]*c[12],d[4*e+1]=b[4*e]*c[1]+b[4*e+1]*c[5]+b[4*e+2]*c[9]+b[4*e+3]*c[13],d[4*e+2]=b[4*e]*c[2]+b[4*e+1]*c[6]+b[4*e+2]*c[10]+b[4*e+3]*c[14],d[4*e+3]=b[4*e]*c[3]+b[4*e+1]*c[7]+b[4*e+2]*c[11]+b[4*e+3]*c[15];while(4>++e);return a},Wq=function(a){var b=new Vq(0,0,0),c=new Vq(0,0,1);const d=new Vq,e=new Vq,f=new Vq;a=a.a;var g=
3
- new Vq(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();Rq(f,1/g);c=Tq(d,c,f);g=c.length();Rq(c,1/g);Tq(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-Sq(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-Sq(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-Sq(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},Xq=function(a,b,c){b=a.a.createShader(b?a.a.FRAGMENT_SHADER:a.a.VERTEX_SHADER);a.a.shaderSource(b,c);a.a.compileShader(b);if(!a.a.getShaderParameter(b,a.a.COMPILE_STATUS))throw new _.H(1,9,9004,"Unable to compile GL shader: "+
4
- a.a.getShaderInfoLog(b));return b},Yq=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(Mq,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},Zq=function(a){const b=Pq(1,0,a.m*Math.PI/180);Qq(Pq(0,1,a.j*Math.PI/180),a.R);Qq(b,a.S);Wq(a.aa);Uq(a.da,a.R,a.aa);Uq(a.G,a.S,a.da)},Oq=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var Vq=class{constructor(a,b,c){this.x=a||0;this.y=b||0;this.a=c||0}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.a*this.a)}};var $q=class{constructor(){this.a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}set(a,b,c,d,e,f,g,h,k,l,m,n,q,t,u,x){const A=this.a;A[0]=a;A[4]=b;A[8]=c;A[12]=d;A[1]=e;A[5]=f;A[9]=g;A[13]=h;A[2]=k;A[6]=l;A[10]=m;A[14]=n;A[3]=q;A[7]=t;A[11]=u;A[15]=x;return this}};var ar=class{constructor(a){this.a=a;this.f=a.createProgram();this.j=Xq(this,!1,"uniform highp mat4 Mvpm;\nattribute highp vec4 aPosition;\nattribute highp vec2 aTexCoord;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_Position \x3d Mvpm * aPosition;\n oTexCoord \x3d aTexCoord;\n}\n");this.h=Xq(this,!0,"precision highp float;\nuniform sampler2D Texture0;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_FragColor \x3d texture2D(Texture0, oTexCoord);\n gl_FragColor.w \x3d 1.0;\n}\n");
5
- a.attachShader(this.f,this.j);a.attachShader(this.f,this.h);a.bindAttribLocation(this.f,0,"aPosition");a.bindAttribLocation(this.f,1,"aTexCoord");a.linkProgram(this.f);if(!a.getProgramParameter(this.f,a.LINK_STATUS))throw new _.H(1,9,9004,"Unable to initialize shader");a.useProgram(this.f);this.g=a.getUniformLocation(this.f,"Mvpm");a.uniform1i(a.getUniformLocation(this.f,"Texture0"),0);a.useProgram(null)}};var br=class{constructor(a){this.a=a;var b=[];let c,d;for(d=0;70>=d;d++){var e=3>=d?d/4/64:67<=d?(63+(d-66)/4)/64:(d-3)/64;var f=(e-.5)*Math.PI;const g=Math.cos(f);for(c=0;128>=c;c++){const h=c/128,k=(.5+h)*Math.PI*2;128===c?(b.push(b[645*d]),b.push(b[645*d+1]),b.push(b[645*d+2])):(b.push(100*Math.cos(k)*g),b.push(100*Math.sin(k)*g),b.push(100*Math.sin(f)));0===d||70===d?b.push(.5):b.push(1-h);b.push(1-e)}}e=[];for(c=0;128>c;c++)for(d=0;70>d;d++)f=5*(129*d+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+
6
- 4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]);this.g=e.length/5;this.f=a.createBuffer();b=new Float32Array(e);a.bindBuffer(a.ARRAY_BUFFER,this.f);a.bufferData(a.ARRAY_BUFFER,b,a.STATIC_DRAW)}};var cr=class{constructor(a,b){this.a=b;this.f=this.a.createTexture();b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,this.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.bindTexture(b.TEXTURE_2D,null)}};var dr={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},er=class extends _.kq{constructor(){super();this.o=this.w=this.K=this.I=this.C=this.X=this.G=this.f=this.a=this.l=null;this.h=new _.O("clpp.vr");this.H=70;this.W=1;this.O=this.M=!1;this.F=()=>{if(this.a&&this.f){this.f.viewport(0,0,this.a.width,this.a.height);{const a=this.K.a,b=Math.tan(.5*this.H*Math.PI/180);a[0]=1/(this.a.width/this.a.height*b);a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1/
7
- b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2E3/-1999.9;a[11]=200/-1999.9;a[12]=0;a[13]=0;a[14]=-1;a[15]=1}}};this.m=this.j=0;this.g={x:0,y:0};this.R=new $q;this.S=new $q;this.aa=new $q;this.da=new $q;this.A=this.ma.bind(this);this.B=this.Ka.bind(this);this.J=this.ga.bind(this)}onPlayerCreated(a){this.h.info("Player created");this.l=a}onContentWillLoad(a){const b=a.getConfiguration();if(b.vr&&b.vr.enable){{var c=b.vr,d=c.fieldOfView;const e=c.sensitivity,f=c.invertHorizontalControl;c=c.invertVerticalControl;
8
- if(void 0!==d&&_.rf(d))this.H=d;else throw new _.H(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.rf(e)&&0<e)this.W=e;else throw new _.H(1,7,7100,"sensitivity configuration must be a positive number");this.M=!!f;this.O=!!c}if(a=a.getSurface())if((d=a.getMedia())&&d.tagName.toLowerCase()===_.w){this.h.info("Initialize VR Surface");if(!this.a){this.a=document.createElement("canvas");this.a.style.width="100%";this.f=this.a.getContext("webgl",dr)||this.a.getContext("experimental-webgl",
9
- dr);if(!this.f)throw new _.H(1,9,9003,"Unable to create GL context");this.G=new $q;Wq(this.G);this.X=new br(this.f);this.C=new ar(this.f);this.I=new $q;this.K=new $q;this.o=this.w=null;this.a.addEventListener(_.ce,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(Nq,this.J,!1));this.F();this.U()}else this.h.info("No video element found, can not initialize VR plugin");else this.h.info("No surface found, can not initialize VR plugin")}}onPlayerWillRelease(){this.h.info("Releasing VR plugin resources");
10
- this.w&&cancelAnimationFrame(this.w);this.g.x=0;this.m=this.j=this.g.y=0;this.f&&(delete this.f,this.f=null);this.a&&(Yq(this),this.a.removeEventListener(_.ce,this.F),this.a.parentElement.removeChild(this.a),this.a.removeEventListener("mousedown",this.J,!1),delete this.a,this.a=null)}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.l=null})}id(){return"vr"}U(){if(this.l&&this.f){var a=this.l.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.U.bind(this));
11
- var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new cr(a,b));b.clearColor(0,0,0,1);b.clearDepth(1);b.clearStencil(0);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);b.depthMask(!0);b.clearColor(0,0,0,1);b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);if(this.o){var c=this.C;c.a.useProgram(c.f);{c=Uq(this.I,this.K,this.G).a;let d;d=c[1];c[1]=c[4];c[4]=d;d=c[2];c[2]=
12
- c[8];c[8]=d;d=c[6];c[6]=c[9];c[9]=d;d=c[3];c[3]=c[12];c[12]=d;d=c[7];c[7]=c[13];c[13]=d;d=c[11];c[11]=c[14];c[14]=d}b.uniformMatrix4fv(this.C.g,!1,this.I.a);c=this.o;c.a.activeTexture(c.a.TEXTURE0);c.a.bindTexture(c.a.TEXTURE_2D,c.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);a=this.X;a.a.bindBuffer(a.a.ARRAY_BUFFER,a.f);a.a.vertexAttribPointer(0,3,a.a.FLOAT,!1,20,0);a.a.vertexAttribPointer(1,2,a.a.FLOAT,!1,20,12);a.a.enableVertexAttribArray(0);a.a.enableVertexAttribArray(1);a.a.drawArrays(a.a.TRIANGLES,
13
- 0,a.g);a=this.o;a.a.bindTexture(a.a.TEXTURE_2D,null);this.C.a.useProgram(null)}}}}ga(a){this.h.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===Nq)a.type===Nq?a.touches[0]&&(this.g.x=a.touches[0].clientX,this.g.y=a.touches[0].clientY):(this.g.x=a.clientX,this.g.y=a.clientY),this.h.debug("Mouse Start coordinates:",this.g,a),this.a.addEventListener("mousemove",this.A,!1),this.a.addEventListener(Mq,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
- this.B,!1)}ma(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===Mq&&a.touches[0]&&(b=a.touches[0].clientX,c=a.touches[0].clientY);a=this.g.x-b;const d=this.g.y-c;this.g.x=b;this.g.y=c;b=this.W;const {hf:e,jf:f}={hf:a*b*(this.M?-1:1),jf:d*b*(this.O?-1:1)};this.j+=e;this.m+=f;Zq(this)}Ka(a){this.h.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();Yq(this)}Uf(a,b){this.m=b;this.j=a;Zq(this)}Cf(){return{x:this.j,y:this.m}}fg(a){this.H=a;this.F()}};
15
- _.z("clpp.vr.VrPlugin",er);er.prototype.setCameraFieldOfView=er.prototype.fg;er.prototype.getCameraCoordinates=er.prototype.Cf;er.prototype.moveCamera=er.prototype.Uf;er.Id="vr";_.Sm(new class{create(){return new er}});};f.call(g, window);
1
+ import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var Cq="touchmove",Dq="touchstart",Fq=function(a,b,c){c*=.5;const d=Math.sqrt(a*a+b*b),e=Math.sin(c);return new Eq(a/d*e,b/d*e,0/d*e,Math.cos(c))},Gq=function(a,b){const c=a.x,d=a.y,e=a.a;a=a.f;b.set(1-2*(d*d+e*e),2*(c*d-e*a),2*(c*e+d*a),0,2*(c*d+e*a),1-2*(c*c+e*e),2*(d*e-c*a),0,2*(c*e-d*a),2*(d*e+c*a),1-2*(c*c+d*d),0,0,0,0,1)},Hq=function(a,b){isFinite(b)?(a.x*=b,a.y*=b,a.a*=b):(a.x=0,a.y=0,a.a=0)},Iq=function(a,b){return a.x*b.x+a.y*b.y+a.a*b.a},Jq=function(a,b,c){const d=b.x,e=b.y;
2
+ b=b.a;const f=c.x,g=c.y;c=c.a;a.x=e*c-b*g;a.y=b*f-d*c;a.a=d*g-e*f;return a},Kq=function(a,b,c){b=b.a;c=c.a;const d=a.a;let e=0;do d[4*e]=b[4*e]*c[0]+b[4*e+1]*c[4]+b[4*e+2]*c[8]+b[4*e+3]*c[12],d[4*e+1]=b[4*e]*c[1]+b[4*e+1]*c[5]+b[4*e+2]*c[9]+b[4*e+3]*c[13],d[4*e+2]=b[4*e]*c[2]+b[4*e+1]*c[6]+b[4*e+2]*c[10]+b[4*e+3]*c[14],d[4*e+3]=b[4*e]*c[3]+b[4*e+1]*c[7]+b[4*e+2]*c[11]+b[4*e+3]*c[15];while(4>++e);return a},Mq=function(a){var b=new Lq(0,0,0),c=new Lq(0,0,1);const d=new Lq,e=new Lq,f=new Lq;a=a.a;var g=
3
+ new Lq(0,1,0);f.x=b.x-g.x;f.y=b.y-g.y;f.a=b.a-g.a;g=f.length();Hq(f,1/g);c=Jq(d,c,f);g=c.length();Hq(c,1/g);Jq(e,f,d);a[0]=d.x;a[1]=d.y;a[2]=d.a;a[3]=-Iq(d,b);a[4]=e.x;a[5]=e.y;a[6]=e.a;a[7]=-Iq(e,b);a[8]=f.x;a[9]=f.y;a[10]=f.a;a[11]=-Iq(f,b);a[12]=0;a[13]=0;a[14]=0;a[15]=1},Nq=function(a,b,c){b=a.a.createShader(b?a.a.FRAGMENT_SHADER:a.a.VERTEX_SHADER);a.a.shaderSource(b,c);a.a.compileShader(b);if(!a.a.getShaderParameter(b,a.a.COMPILE_STATUS))throw new _.H(1,9,9004,"Unable to compile GL shader: "+
4
+ a.a.getShaderInfoLog(b));return b},Oq=function(a){a.a&&(a.a.removeEventListener("mousemove",a.A,!1),a.a.removeEventListener(Cq,a.A,!1),a.a.removeEventListener("mouseup",a.B,!1),a.a.removeEventListener("touchend",a.B,!1))},Pq=function(a){const b=Fq(1,0,a.m*Math.PI/180);Gq(Fq(0,1,a.j*Math.PI/180),a.R);Gq(b,a.S);Mq(a.aa);Kq(a.ba,a.R,a.aa);Kq(a.G,a.S,a.ba)},Eq=class{constructor(a,b,c,d){this.x=a||0;this.y=b||0;this.a=c||0;this.f=d||1}};var Lq=class{constructor(a,b,c){this.x=a||0;this.y=b||0;this.a=c||0}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.a*this.a)}};var Qq=class{constructor(){this.a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}set(a,b,c,d,e,f,g,h,k,l,m,n,q,t,u,x){const z=this.a;z[0]=a;z[4]=b;z[8]=c;z[12]=d;z[1]=e;z[5]=f;z[9]=g;z[13]=h;z[2]=k;z[6]=l;z[10]=m;z[14]=n;z[3]=q;z[7]=t;z[11]=u;z[15]=x;return this}};var Rq=class{constructor(a){this.a=a;this.f=a.createProgram();this.j=Nq(this,!1,"uniform highp mat4 Mvpm;\nattribute highp vec4 aPosition;\nattribute highp vec2 aTexCoord;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_Position \x3d Mvpm * aPosition;\n oTexCoord \x3d aTexCoord;\n}\n");this.h=Nq(this,!0,"precision highp float;\nuniform sampler2D Texture0;\nvarying highp vec2 oTexCoord;\nvoid main()\n{\n gl_FragColor \x3d texture2D(Texture0, oTexCoord);\n gl_FragColor.w \x3d 1.0;\n}\n");
5
+ a.attachShader(this.f,this.j);a.attachShader(this.f,this.h);a.bindAttribLocation(this.f,0,"aPosition");a.bindAttribLocation(this.f,1,"aTexCoord");a.linkProgram(this.f);if(!a.getProgramParameter(this.f,a.LINK_STATUS))throw new _.H(1,9,9004,"Unable to initialize shader");a.useProgram(this.f);this.g=a.getUniformLocation(this.f,"Mvpm");a.uniform1i(a.getUniformLocation(this.f,"Texture0"),0);a.useProgram(null)}};var Sq=class{constructor(a){this.a=a;var b=[];let c,d;for(d=0;70>=d;d++){var e=3>=d?d/4/64:67<=d?(63+(d-66)/4)/64:(d-3)/64;var f=(e-.5)*Math.PI;const g=Math.cos(f);for(c=0;128>=c;c++){const h=c/128,k=(.5+h)*Math.PI*2;128===c?(b.push(b[645*d]),b.push(b[645*d+1]),b.push(b[645*d+2])):(b.push(100*Math.cos(k)*g),b.push(100*Math.sin(k)*g),b.push(100*Math.sin(f)));0===d||70===d?b.push(.5):b.push(1-h);b.push(1-e)}}e=[];for(c=0;128>c;c++)for(d=0;70>d;d++)f=5*(129*d+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+
6
+ 4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*d+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]),f=5*(129*(d+1)+c+1),e.push(b[f],b[f+1],b[f+2],b[f+3],b[f+4]);this.g=e.length/5;this.f=a.createBuffer();b=new Float32Array(e);a.bindBuffer(a.ARRAY_BUFFER,this.f);a.bufferData(a.ARRAY_BUFFER,b,a.STATIC_DRAW)}};var Tq=class{constructor(a,b){this.a=b;this.f=this.a.createTexture();b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,this.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.bindTexture(b.TEXTURE_2D,null)}};var Uq={alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,devicePixelRatio:1},Vq=class extends _.aq{constructor(){super();this.o=this.w=this.K=this.I=this.C=this.Y=this.G=this.f=this.a=this.l=null;this.h=new _.P("clpp.vr");this.H=70;this.W=1;this.N=this.L=!1;this.F=()=>{if(this.a&&this.f){this.f.viewport(0,0,this.a.width,this.a.height);{const a=this.K.a,b=Math.tan(.5*this.H*Math.PI/180);a[0]=1/(this.a.width/this.a.height*b);a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1/
7
+ b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2E3/-1999.9;a[11]=200/-1999.9;a[12]=0;a[13]=0;a[14]=-1;a[15]=1}}};this.m=this.j=0;this.g={x:0,y:0};this.R=new Qq;this.S=new Qq;this.aa=new Qq;this.ba=new Qq;this.A=this.ma.bind(this);this.B=this.Ka.bind(this);this.J=this.ga.bind(this)}onPlayerCreated(a){this.h.info("Player created");this.l=a}onContentWillLoad(a){const b=a.getConfiguration();if(b.vr&&b.vr.enable){{var c=b.vr,d=c.fieldOfView;const e=c.sensitivity,f=c.invertHorizontalControl;c=c.invertVerticalControl;
8
+ if(void 0!==d&&_.qf(d))this.H=d;else throw new _.H(1,7,7100,"fieldOfView configuration must be a number");if(void 0!==e&&_.qf(e)&&0<e)this.W=e;else throw new _.H(1,7,7100,"sensitivity configuration must be a positive number");this.L=!!f;this.N=!!c}if(a=a.getSurface())if((d=a.getMedia())&&d.tagName.toLowerCase()===_.w){this.h.info("Initialize VR Surface");if(!this.a){this.a=document.createElement("canvas");this.a.style.width="100%";this.f=this.a.getContext("webgl",Uq)||this.a.getContext("experimental-webgl",
9
+ Uq);if(!this.f)throw new _.H(1,9,9003,"Unable to create GL context");this.G=new Qq;Mq(this.G);this.Y=new Sq(this.f);this.C=new Rq(this.f);this.I=new Qq;this.K=new Qq;this.o=this.w=null;this.a.addEventListener(_.be,this.F)}a.addElementToContainer(this.a,!0,!0);a.hideMediaElement();b.vr.attachMouseListener&&(this.a.addEventListener("mousedown",this.J,!1),this.a.addEventListener(Dq,this.J,!1));this.F();this.U()}else this.h.info("No video element found, can not initialize VR plugin");else this.h.info("No surface found, can not initialize VR plugin")}}onPlayerWillRelease(){this.h.info("Releasing VR plugin resources");
10
+ this.w&&cancelAnimationFrame(this.w);this.g.x=0;this.m=this.j=this.g.y=0;this.f&&(delete this.f,this.f=null);this.a&&(Oq(this),this.a.removeEventListener(_.be,this.F),this.a.parentElement.removeChild(this.a),this.a.removeEventListener("mousedown",this.J,!1),delete this.a,this.a=null)}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.l=null})}id(){return"vr"}U(){if(this.l&&this.f){var a=this.l.getSurface();if(a&&(a=a.getMedia())&&a.tagName.toLowerCase()===_.w){this.w=requestAnimationFrame(this.U.bind(this));
11
+ var b=this.f;this.o||a.readyState!==a.HAVE_ENOUGH_DATA||(this.o=new Tq(a,b));b.clearColor(0,0,0,1);b.clearDepth(1);b.clearStencil(0);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);b.depthMask(!0);b.clearColor(0,0,0,1);b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);if(this.o){var c=this.C;c.a.useProgram(c.f);{c=Kq(this.I,this.K,this.G).a;let d;d=c[1];c[1]=c[4];c[4]=d;d=c[2];c[2]=
12
+ c[8];c[8]=d;d=c[6];c[6]=c[9];c[9]=d;d=c[3];c[3]=c[12];c[12]=d;d=c[7];c[7]=c[13];c[13]=d;d=c[11];c[11]=c[14];c[14]=d}b.uniformMatrix4fv(this.C.g,!1,this.I.a);c=this.o;c.a.activeTexture(c.a.TEXTURE0);c.a.bindTexture(c.a.TEXTURE_2D,c.f);b.texImage2D(b.TEXTURE_2D,0,b.RGB,b.RGB,b.UNSIGNED_BYTE,a);a=this.Y;a.a.bindBuffer(a.a.ARRAY_BUFFER,a.f);a.a.vertexAttribPointer(0,3,a.a.FLOAT,!1,20,0);a.a.vertexAttribPointer(1,2,a.a.FLOAT,!1,20,12);a.a.enableVertexAttribArray(0);a.a.enableVertexAttribArray(1);a.a.drawArrays(a.a.TRIANGLES,
13
+ 0,a.g);a=this.o;a.a.bindTexture(a.a.TEXTURE_2D,null);this.C.a.useProgram(null)}}}}ga(a){this.h.debug("Mouse Down. Enable VR mouse interaction");a.preventDefault();if(0===a.button||a.type===Dq)a.type===Dq?a.touches[0]&&(this.g.x=a.touches[0].clientX,this.g.y=a.touches[0].clientY):(this.g.x=a.clientX,this.g.y=a.clientY),this.h.debug("Mouse Start coordinates:",this.g,a),this.a.addEventListener("mousemove",this.A,!1),this.a.addEventListener(Cq,this.A,!1),this.a.addEventListener("mouseup",this.B,!1),this.a.addEventListener("touchend",
14
+ this.B,!1)}ma(a){a.preventDefault();var b=a.clientX;let c=a.clientY;a.type===Cq&&a.touches[0]&&(b=a.touches[0].clientX,c=a.touches[0].clientY);a=this.g.x-b;const d=this.g.y-c;this.g.x=b;this.g.y=c;b=this.W;const {jf:e,kf:f}={jf:a*b*(this.L?-1:1),kf:d*b*(this.N?-1:1)};this.j+=e;this.m+=f;Pq(this)}Ka(a){this.h.debug("Mouse Up. Removing mouse interaction listeners");a.preventDefault();Oq(this)}Vf(a,b){this.m=b;this.j=a;Pq(this)}Df(){return{x:this.j,y:this.m}}fg(a){this.H=a;this.F()}};
15
+ _.A("clpp.vr.VrPlugin",Vq);Vq.prototype.setCameraFieldOfView=Vq.prototype.fg;Vq.prototype.getCameraCoordinates=Vq.prototype.Df;Vq.prototype.moveCamera=Vq.prototype.Vf;Vq.Id="vr";_.Hm(new class{create(){return new Vq}});};f.call(g, window);