window.ppd_wnd=function(t){new class extends Createclck{constructor(t){super(t),this._options=t,this._mainPadding=40,this._outerWidth=this._options.width+2*this._mainPadding,this._outerHeight=this._options.height+2*this._mainPadding,this._extraWidth=0,this._extraHeight=0,this.function_helper=new FunctionsHelper}show(){document.body.appendChild(this._createStyles());var t=this._createOverlay();this._createMainDiv(),this._div.appendChild(t);var e=this;this._options.bannerShowDelay?setTimeout(function(){e._show()},1e3*this._options.bannerShowDelay):e._show(),super.show()}_show(){document.body.appendChild(this._parent),setTimeout(this.checkContentLoaded.bind(this),3e3),this._trackImpression()}checkContentLoaded(){!this._clicked&&this._div_content&&this._div_content.offsetWidth<=20&&this._div_content.offsetHeight<=20&&this.switchToClickUnder()}switchToClickUnder(){this._removePopunder(),super.init(document)}_createStyles(){try{var t=document.createElement("style"),e='.v_adTopClass{padding: 5px;background-color: #4898ED;text-decoration: none;margin: 3px;position: relative;overflow: hidden; color: white;}.v_adTopClass:hover{background-color: #0066CC;text-decoration: underline;}.v_closeBtn{color:#999}.v_closeBtn:hover{color:#000}.v_closeBtn:after{content:"X"}';return this._options.toolbar&&(e+='img[src="//static.traffic.ru/images/handler/label.png"] {transform: scale(0) !important;}a.csgwrp67ovjl3xsm {transform: scale(0) !important;}'),t.innerHTML=e,t}catch(t){var i=document.createElement("div");return i.style.cssText="display:none;",i}}_createOverlay(){return this._div_overlay=document.createElement("div"),this._div_overlay.style.cssText="display:flex;justify-content:center;align-items:center;opacity: 0;position:relative;",this._div_overlay_inner=document.createElement("div"),this._div_overlay_inner.style.cssText="background-color: #fff;max-height:calc(100vh - 80px);max-width: calc(100vw - 80px);padding: 40px;position:relative;box-shadow: 0 0 10px rgba(0,0,0,0.5);box-sizing: initial;",this._div_content=document.createElement("div"),this._div_content.style.cssText="position: absolute;",this._div_shadow=document.createElement("div"),this._div_shadow.style.cssText="position:absolute; top:0;left:0;bottom:0;right:0;border-radius: 30px;opacity:0.5;background-color: #afafaf;cursor:pointer;",this._div_shadow.setAttribute&&this._div_shadow.setAttribute("PndrClCl","1"),super.init(this._div_shadow),this._div_overlay_inner.appendChild(this._createCloseButton()),this._div_overlay_inner.appendChild(this._div_content),this._div_overlay.appendChild(this._div_shadow),this._div_overlay.appendChild(this._div_overlay_inner),this._createBlocks(this._div_content),this._div_overlay}_createMainDiv(){switch(this._parent=null,this._div=document.createElement("div"),Math.ceil(10*Math.random())){case 1:this._parent=document.createElement("form");break;case 2:this._parent=document.createElement("div");break;case 3:this._parent=document.createElement("p"),this._parent.style.cssText="margin:0;padding:0;";break;default:this._parent=document.createElement("span")}return this._parent.appendChild(this._div),this._div.style.cssText="position: fixed; top:0;bottom:0;left:0;right:0;display:flex;justify-content:center;align-items:center;z-index:2147483638;",this._div.setAttribute&&this._div.setAttribute("PndrClCl","1"),this._div}_processSize(t=!1){var e=this;function i(){e._div_overlay.style.width="100%",e._div_overlay.style.height="100%"}function o(){e._div_overlay.style.width=e._div_content.offsetWidth+80+300+"px",e._div_overlay.style.height=e._div_content.offsetHeight+80+300+"px"}var n={w:e._div_content.offsetWidth,h:e._div_content.offsetHeight};if(t)var s=setInterval(function(){e._div_content.offsetWidth>20&&e._div_content.offsetHeight>20&&(e._div_overlay_inner.style.width=e._div_content.offsetWidth+"px",e._div_overlay_inner.style.height=e._div_content.offsetHeight+"px",e._div_overlay.style.opacity="1",n.w!=e._div_content.offsetWidth&&n.h!=e._div_content.offsetHeight&&(e._options.popUnderInfo.shadow?i():e._options.popUnderInfo.shadowHalf&&o(),e._div_content.style.position="relative",e._div_content.style.maxWidth="calc(100vw - 80px)",e._div_content.style.maxHeight="calc(100vh - 80px)",e._div_content.style.overflow="hidden",clearInterval(s),clearTimeout(r),n={w:e._div_content.offsetWidth,h:e._div_content.offsetHeight}))},50);var r=setTimeout(function(){e._div_overlay.style.opacity="1",e._options.popUnderInfo.shadow?i():e._options.popUnderInfo.shadowHalf&&o()},500)}_checkClose(){var t=this;void 0!==this.generator.cookieGet("c"+this._options.impId)?this._clicked||this._close():setTimeout(function(){t._checkClose()},10)}_createCloseButton(){var t,e=document.createElement("a");switch(e.setAttribute&&e.setAttribute("PndrClCl","1"),super.init(e),this._options.popUnderInfo.closePosition){case 1:t="left:10px;top:10px;";break;case 3:t="right:10px;bottom:10px;";break;case 4:t="left:10px;bottom:10px;";break;case 2:default:t="right:10px;top:10px;"}return e.style.cssText="position: absolute;font-size:20px;line-height:20px;height:20px;cursor:pointer;font-weight:bold;text-decoration: none;"+t,this._options.popUnderInfo.closeDelay&&(e.style.cssText+="display:none;",setTimeout(function(){this.generator.style(e,"display:block;")},1e3*this._options.popUnderInfo.closeDelay)),e.className="v_closeBtn",e}_removePopunder(){this._parent&&this._parent.parentNode&&this._parent.parentNode.removeChild(this._parent)}_close(){this._clicked=!0,this.generator.cookieSet("c"+this._options.impId,"1"),this._removePopunder()}_createBlocks(t){console.log("CreateBlocks"),this.function_helper.xhrJsonRequest(this._options.popUnderInfo.bannerXhr,e=>{if(console.log("rows",e),e&&e[0]&&e[0].options){e[0].options.width&&e[0].options.height?(this._div_overlay_inner.style.width=`${e[0].options.width}px`,this._div_overlay_inner.style.height=`${e[0].options.height}px`,this._processSize(!1)):this._processSize(!0);var i=PndrDisplayFile.get(e[0].options,{});e[0].options.trackImp&&((new Image).src=e[0].options.trackImp),t.appendChild(i.main),e[0].options&&e[0].options.bannerInfo&&"vinstant"===e[0].options.bannerInfo.type&&setTimeout(function(){i.afterLoad&&i.afterLoad()},1),e[0].options.impressionUrl&&((new Image).src=e[0].options.impressionUrl)}else{const e=document.createElement("script");e.src=this._options.popUnderInfo.tpl,t.appendChild(e),this._processSize(!0)}})}}(t).show()};