(function(){var g={}; var _ = _ || {}
var f=function(window){var wA="No surface found. Can not attach frame!",xA="SIMID:Media:timeupdate",yA="Starting creative",DA=function(a,b){var c=this;this.f=a;this.w=b;this.h="";this.l=0;this.j=new Map;this.a=document.createElement("iframe");this.a.style.opacity="0";var d=this.w.style;d.className?this.a.classList.add(d.className):(this.a.style.border=_.Qe,this.a.style.backgroundColor="transparent",this.a.style.transition="opacity .5s",this.a.style.transitionDelay=".5s",this.a.style.pointerEvents=_.Qe,this.a.style.overflow=
_.qe);this.a.classList.add(_.md);this.o=function(e){if(e.source===c.a.contentWindow&&(e=(e=e.data)?typeof e===_.eg?JSON.parse(e):e:null))if(e.type)switch(c.g.info("Received message ["+e.messageId+"] '"+e.type+"':",e.args),e.type){case "createSession":zA(c,e);break;case "resolve":e=e.args;var f=c.j.get(e.messageId);f&&f.resolve(e);break;case "reject":e=e.args;(f=c.j.get(e.messageId))&&f.reject(e);break;case "SIMID:Creative:requestResize":f=c.f;var g=e.args;f.g.info("Creative requested resize",g);if(f.m&&
f.m.getSurface()&&f.m.getSurface().getMedia()&&g.mediaDimensions){f.h?f.m.getSurface().getMedia().style.transition="":(f.m.getSurface().getMedia().style.transition="left .5s, top .5s,width .5s, height .5s",f.h=!0);var h=AA(f,g.mediaDimensions);f.m.getSurface().getMedia().style.left=h.left;f.m.getSurface().getMedia().style.top=h.top;f.m.getSurface().getMedia().style.width=h.width;f.m.getSurface().getMedia().style.height=h.height}g.creativeDimensions&&(g=AA(f,g.creativeDimensions),f.a.a.style.left=
g.left,f.a.a.style.top=g.top,f.a.a.style.width=g.width,f.a.a.style.height=g.height);BA(c,e)}else c.g.warn("WARNING: received message without 'type' property")};this.g=new _.J("clpp.simid.SimidPlayer");CA(this.f,this)},GA=function(a){var b=EA(a,"SIMID:Player:startCreative",void 0);FA(a,b).then(function(){var c=a.f;c.g.info(yA);c.m.trigger(new _.K(_.Wf));a.a.style.opacity="1"})["catch"](function(c){a.unload();a.f.g.error("Error while starting creative",c)})},zA=function(a,b){var c;_.H(function(d){if(1==
d.a){a.h=b.sessionId;BA(a,b);_.C(d,2);var e=a.f;var f=e.getSurface(),g=e.getContainer();e={environmentData:{videoDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},creativeDimensions:{x:0,y:0,height:g.clientHeight,width:g.clientWidth},fullscreen:f.isFullscreen(),fullscreenAllowed:!0,variableDurationAllowed:!1,skippableState:"notSkippable",version:"1.1",skipoffset:"",siteUrl:window.location.toString(),appId:"",useragent:"",deviceId:"",muted:e.m.isMuted()||!1,volume:e.m.getVolume()||0,navigationSupport:"adHandles",
closeButtonSupport:"adHandles",nonlinearDuration:e.f.duration},creativeData:{adParameters:e.f.adParameters||"",clickThruUri:"",clickThruUrl:""}};e=EA(a,"SIMID:Player:init",e);e=FA(a,e);return _.x(d,e,4)}if(2!=d.a)return a.g.info("Player Init acknowledged"),a.f.g.info("SIMID Player initialized"),_.uh(d,0);c=_.E(d);a.g.error("Error while initializing",c);a.f.g.error("Error while initializing SIMID player: ",c);a.unload();_.y(d)})},EA=function(a,b,c){return{type:b,sessionId:a.h,messageId:a.l++,timestamp:Date.now(),
args:c}},HA=function(a,b){a.h?(b.type!==xA&&a.g.info("Posting message ["+b.messageId+"] '"+b.type+"':",b.args),a.a.contentWindow&&a.a.contentWindow.postMessage(JSON.stringify(b),"*")):a.g.warn("WARNING: no session available to send message '"+b.type+"'")},BA=function(a,b){HA(a,EA(a,"resolve",{messageId:b.messageId,value:void 0}))},FA=function(a,b){return new Promise(function(c,d){new IA(a.j,c,d,b);HA(a,b)})},IA=function(a,b,c,d){var e=this;var f=void 0===f?-1:f;this.f=a;this.l=b;this.j=c;this.h=d;
this.a=null;this.f.set(d.messageId,this);0<=f&&(this.a=setTimeout(function(){e.resolve()},f))},JA=function(){this.g=new _.J("clpp.simid.Plugin");this.h=this.a=this.m=null;this.l=[];this.j=null;this.w=this.Wk.bind(this);this.f=null;this.o=!1},KA=function(a,b,c){return new ResizeObserver(function(){if(a.a.h){var d=a.a,e={videoDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},creativeDimensions:{x:0,y:0,height:b.clientHeight,width:b.clientWidth},fullscreen:c.isFullscreen()};e=EA(d,"SIMID:Player:resize",
e);HA(d,e)}})},LA=function(a){this.m=a;this.a=null;this.g=new _.J("clpp.simid.Loader");this.h=!1;this.f=null},AA=function(a,b){var c=a.getContainer(),d=c.clientWidth;c=c.clientHeight;return{top:b.y/c*100+"%",left:b.x/d*100+"%",width:b.width/d*100+"%",height:b.height/c*100+"%"}},CA=function(a,b){a.g.info("SIMID Session created");a.a=b},MA=function(a){a.g.info("Stopping creative");a.m.getSurface().getMedia().style.transition=".5s";setTimeout(function(){a.m.getSurface().getMedia().style.transition=""},
500);a.m.getSurface().getMedia().style.left="";a.m.getSurface().getMedia().style.top="";a.m.getSurface().getMedia().style.width="";a.m.getSurface().getMedia().style.height="";a.a.a.style.left="";a.a.a.style.top="";a.a.a.style.width="";a.a.a.style.height="";a.h=!1;a.m.trigger(new _.K(_.Xf))},NA=function(){};
DA.prototype.load=function(a){window.addEventListener(_.Ie,this.o);this.h="";this.l=0;var b=this.f.url();this.g.info('Loading "'+b+'" as src of iFrame');this.a.src=b;this.g.info("Attaching iFrame");a.appendChild(this.a)};DA.prototype.unload=function(){MA(this.f);this.h=this.a.src="";this.l=0;this.a.style.opacity="0";window.removeEventListener(_.Ie,this.o);this.a.parentElement&&this.a.parentElement.removeChild(this.a)};
IA.prototype.resolve=function(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f["delete"](this.h.messageId);this.l(a)};IA.prototype.reject=function(a){null!==this.a&&(clearTimeout(this.a),this.a=null);this.f["delete"](this.h.messageId);this.j(a)};_.w(JA,_.bw);_.r=JA.prototype;_.r.id=function(){return"simid"};_.r.onPlayerCreated=function(a){this.g.info("New player created");this.a&&(this.a.unload(),this.a=null);this.m=a;this.h&&this.h.release();this.h=new LA(a)};
_.r.onContentWillLoad=function(a){var b=a.getConfiguration();if(b.simid&&b.simid.creatives&&0!==b.simid.creatives.length){this.l=b.simid.creatives;this.g.info("Setting up SIMID plugin for "+this.l.length+" creatives");var c=this.m.getSurface();c?(this.g.info("Creating new session"),this.a=new DA(this.h,b.simid),b=c.getContainer(),this.j=KA(this,b,c),this.j.observe(b),a.on(_.rg,this.w)):this.g.warn(wA)}};
_.r.Wk=function(){var a=this.m.getPosition();a:if(this.f&&a<this.f.startTime+this.f.duration)var b=this.f;else{for(b=0;b<this.l.length;b++){var c=this.l[b],d=c.startTime+c.duration;if(a>=c.startTime-(c.preload||5)&&a<d){b=c;break a}}b=null}b?b===this.f?(b=b.startTime,this.a&&(c=a>=b,!this.o&&c&&(GA(this.a),this.o=!0,this.g.info(yA)),c&&(c=this.a,HA(c,EA(c,xA,{currentTime:a-b}))))):((a=this.m.getSurface())||this.g.warn(wA),a=a.getContainer(),this.f=b,this.o=!1,this.g.info("Loading session"),this.h.f=
b,this.a.load(a)):this.f&&(this.a.unload(),this.f=null,this.o=!1)};_.r.onPlayerWillRelease=function(a){_.bw.prototype.onPlayerWillRelease.call(this,a);this.m.getSurface()&&(this.j&&(this.j.disconnect(),this.j=null),a.off(_.rg,this.w),this.f&&(this.a.unload(),this.f=this.h.f=null))};_.r=LA.prototype;_.r.release=function(){this.g.info("Releasing loader")};
_.r.getContainer=function(){var a=this.getSurface().getContainer();if(!a)throw this.g.error("No player container found. Can not create SIMID init data"),new _.N(1,10,10100,"No player container found");return a};_.r.getSurface=function(){var a=this.m.getSurface();if(!a)throw this.g.error("No player surface found. Can not create SIMID init data"),new _.N(1,10,10100,"No surface");return a};_.r.ii=function(){return this.a};_.r.url=function(){return this.f?this.f.url:""};NA.prototype.create=function(){return new JA};
_.Yt(new NA);};
if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
else{_=this.clpp._;(f.call(g,this));}
})();