f96725b06253823ea61d79ddba3108d33a4f59c3b5154e695833d4036a7ef23d

Source Code:

"use strict";!function(e,t){function r(e,t){function r(r){var n=function(){};return"function"==typeof e[r]?n=e[r]:"function"==typeof e.log&&(n=e.log.bind(e,r.toUpperCase()+" |")),function(){var o=Array.prototype.slice.call(arguments),s=[Date.now(),r].concat(o);if(i.messages.push(s),t&&e){var a=[i.mark].concat(o);n.apply(e,a)}}}var i={mark:"[sdk]",messages:[]};return i.info=r("info"),i.warn=r("warn"),i.error=r("error"),i}function i(t){var r={v:4},i=r.DEBUG=t.DEBUG;return r.config=t.config,r.started=t.started,r.logger=t.logger,r.log=t.logger.info,r.logi=t.logger.info,r.logw=t.logger.warn,r.loge=t.logger.error,r.window=t.window,r.document=t.window.document,r.API_HOST=t.apiHost,r.STATIC_HOST=t.staticHost||t.apiHost,r.NAMESPACE=t.namespace,r.widgetImplementations={},r.widgets=[],r.ALREADY_SUBSCRIBED="ALREADY_SUBSCRIBED",r.CLOSE_BUTTON_CLICK="CLOSE_BUTTON_CLICK",r.SUBSCRIBED="SUBSCRIBED",r.SUBSCRIPTION_FAILED="SUBSCRIPTION_FAILED",r._cachedFn=function(e,t){function i(i){var o=null;try{o=t?r.stringify(i):r.stringify(arguments)}catch(e){}return null===o?e.apply(this,arguments):(o in n||(n[o]=e.apply(this,arguments)),n[o])}var n;return i.reset=function(){n={}},i.reset(),i},r.$=function(){var e=r[r._jqholdername];return"function"!=typeof e?r.loge("Call `attachJquery` and ensure its execution is finished."):arguments.length>0?e.apply(e,arguments):e},r.attachGAPromise=function(){return r.getFusionDataPromise().then(function(e){var t=e.gaid;if(!t)return!1;!function(e,t,r,i,n,o,s){e.GoogleAnalyticsObject=n,e[n]=e[n]||function(){(e[n].q=e[n].q||[]).push(arguments)},e[n].l=1*new Date,o=t.createElement(r),s=t.getElementsByTagName(r)[0],o.async=1,o.src="//www.google-analytics.com/analytics.js",s.parentNode.insertBefore(o,s)}(r.window,document,"script",0,o);var i={trackingId:t,cookieDomain:"auto"};return e.gaparams&&e.gaparams.sample_rate&&(i.sampleRate=e.gaparams.sample_rate),r.window[o]("create",i),r.window[o]("require","displayfeatures"),r.window[o]("send","pageview"),!0}).then(function(e){r.logi("attachGAPromise Finished with:",r.nowStr(),{added:e})},function(e){r.loge("attachGAPromise Uncaught:",e)})},r.attachJquery=function(e){function t(t,n){if(r.logi("jQuery has been loaded:",n),r._jqholdername="_jq"+Math.random()+":"+f,r[r._jqholdername]=t,i&&(r.window.$=r.window.jQuery=r.window.jQuery||r.window.$||t),!r.API_HOST||"string"!=typeof r.API_HOST){var o=r.getSdkScript(),s=o.prop("src");if(!s)return r.loge('No SDK script tag or wrong "src":',o[0],s),r;r.API_HOST=r.getOrigin(s)}r.STATIC_HOST&&"string"==typeof r.STATIC_HOST||(r.STATIC_HOST=r.API_HOST),e()}function n(){return r.window.jQuery&&r.window.jQuery.fn&&"function"==typeof r.window.jQuery.fn.on&&"function"==typeof r.window.jQuery.fn.find&&"function"==typeof r.window.jQuery.fn.prop}function o(e){var i=r.window.jQuery,n=r.document.createElement("script");n.type="text/javascript",n.src=s,n.async=!0,n.onload=function(){var n=r.window.jQuery.noConflict(!0);r.window.jQuery=i,t(n,e)},r.document.getElementsByTagName("head")[0].appendChild(n)}var s="//code.jquery.com/jquery-2.2.0.min.js";r.window.jQuery?n()?t(r.window.jQuery,"existing in app.window"):function(e,t){function i(){clearInterval(a),a=null,o=!1}var o=!0;"function"==typeof r.window.jQuery&&r.window.jQuery(function(){n()&&(o&&e(r.window.jQuery,"recovered from existing faked instance as app.window.jQuery function"),i())});var s=10,a=setInterval(function(){if(o)return n()?(e(r.window.jQuery,"recovered from existing faked instance as app.window.jQuery object"),void i()):void(--s<=0&&(t("our instance after recovery attempt"),i()));i()},500)}(t,o):o("our instance")},r.copyAttributes=function(e,t){var i=r.$(e),n=r.$(t||{}),o=i.prop("attributes");return r.$().each(o,function(){n.attr(this.name,this.value)}),n[0]},r.createWidgetPromise=function(e,t,i){var n=!1;return r.verifyWidgetShouldBeShownPromise(e,t,i).then(function(){var t=r.isString(e.type,1),i=r.isString(r.get(e,"custom.displayer"),1);if(!t&&!i)return r.reject("Widget displayer is not specified");var o=[],s=r.resolve(!1);e.behavior.skip_base_implementation||o.push(r.loadWidgetImplementation("predefined","base").then(function(t){return r.isFunction(t)||(r.loge("createWidgetPromise","Base widget implementation",r.stringify(e.type),"has not been loaded:",t),n=!0),t})),t&&(o.push(r.loadWidgetImplementation("predefined",e.type).then(function(t){return r.isFunction(t)||(r.loge("createWidgetPromise","Predefined widget implementation",r.stringify(e.type),"has not been loaded:",t),n=!0),t})),r.get(e,"view.iframe_resizer_is_needed")&&(s=r.loadScriptPromise(r.STATIC_HOST+"/public/sdk/vx/lib/iframeResizer/iframeResizer.min.js"))),i&&o.push(r.loadWidgetImplementation("custom",e.custom.displayer).then(function(t){return r.isFunction(t)||(r.loge("createWidgetPromise","Custom widget implementation",r.stringify(e.custom),"has not been loaded:",t),n=!0),t}));var a=r.resolve(!1);return e.behavior.skip_state_machine_code||(a=r.loadScriptPromise(r.STATIC_HOST+"/public/sdk/vx/lib/state-machine/state-machine.min.js")),r.join(r.Promise.all(o),s,a)}).spread(function(t){if(n)return null;for(var o=function(){},s=0,a=t.length;s<a;s++)try{o=t[s](o,r.inherits,r)}catch(e){return r.loge("createWidgetPromise:","can't inherit",e),null}try{var u=new o(e,i);return r.logi(u.getMyName(),u),u}catch(e){return r.loge("createWidgetPromise:","can't construct",e),null}}).error(function(t){return r.logw("createWidgetPromise","Widget",e.id||e,"is skipped because",t),null})},r.EventEmitter=function(){function e(){if(!(this instanceof e))return new e;this.events={}}return e.prototype.emit=function(e,t){this.events["*"]&&this._emit("*",{eventName:e,data:t}),this._emit(e,t)},e.prototype._emit=function(e,t){for(var i in this.events)if(i===e||i.split(".").indexOf(e)>-1){var n=this.events[i];if(!r.$().isArray(n))continue;r.$().each(n,function(i,n){try{n(t)}catch(i){r.loge("EventEmitter::emit failed",e,t,i,n)}})}},e.prototype.off=function(e,t){var i=!r.isFunction(t);if(!e||"string"!=typeof e)return!1;var n=!1;for(var o in this.events)if(o===e||o.split(".").indexOf(e)>-1){if(!r.$().isArray(this.events[o]))continue;this.events[o]=r.$().grep(this.events[o],function(e){return n=i||e===t})}return n},e.prototype.on=function(e,t){if(!r.isFunction(t))throw new Error('EventEmitter::on("'+e+'", fn) second argument must be function, but passed: '+r.stringify(t));r.$().isArray(this.events[e])||(this.events[e]=[]),this.events[e].push(t);var i=this;return function(){return i.off(e,t)}},e}(),r.exposePublicApi=function(e){r.$().isPlainObject(e)||r.isFunction(e)||(e=r.publicApi),e.log=i?r.log:{},e.log.messages=r.logger.messages,e.getShownWidgets=r.getShownWidgets,e.getVisibleWidgets=r.getVisibleWidgets,e.handleUserDataPromise=r.handleUserDataPromise,e.handleUserEmail=r.handleUserEmailPromise,e.initSDK=r.initSDK,e.initWidget=r.initWidgetPromise,e.isWidgetLocked=r.isWidgetLocked,e.registerWidget=r.registerWidget,e.requestNotifyPermission=r.requestNotifyPermissionPromise,e.setWidgetLocks=r.setWidgetLocks,e.showWidget=r.showWidgetPromise},r.extend=function(e){if(r.isFunction(e)){var t=["$","getLocationPathParam","getLocationQueryParam","loge","reject"].reduce(function(e,t){return e[t]=r[t],e},{});["getFusionId","getLocation","verifyWidgetShouldBeShownPromise","shouldWidgetShowFormInsteadOfHide","isNodeVisible"].forEach(function(i){var n=r[i];if("function"==typeof n){var o=n;n=function(){for(var e=[],t=0;t<arguments.length;t++){var i="object"==typeof arguments[t]&&arguments[t]instanceof r.window.HTMLElement?arguments[t]:r.parse(r.stringify(arguments[t]));e.push(i)}return o.apply(this,e)}}r[i]=e(i,n,t)})}},r.findCurrentWidget=function(e,t){e=e||[];for(var r=0;r<e.length;r++){var i=e[r];if((i.id||i.config&&i.config.id)===t)return i}},r.get=function(e,t,i){r.isString(t)&&(t=t.split("."));for(var n=e,o=0,s=t.length;o<s;o++)try{n=n[t[o]]}catch(e){n=void 0;break}return void 0===n?i:n},r.getCookie=function(e,t){arguments.length<2&&(t=r.NAMESPACE);for(var i=t+e+"=",n=r.document.cookie.split(";"),o=0;o<n.length;o++){var s=n[o].trim();if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}return null},r.getFusionDataPromise=function(){return r.prepareInitialDataPromise().then(function(e){return e.fusion})},r.getFusionId=function(){return r.readConfig("id")||r.getSdkScript().attr("fusionId")},r.getLocation=function(){return String(r.window.location)},r.getLocationQueryParam=function(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(r.window.location.search);return null===t?"":decodeURIComponent(t[1].replace(/\+/g," "))},r.getLocationPathParam=function(e){for(var t=r.window.location.pathname.split("/"),i=[],n=0,o=t.length;n<o;n++)t[n]&&i.push(t[n]);var s=i.length||1;return e<0&&(e=(e+s)%s),i[e]||""},r.getNavigator=function(){return r.window&&r.window.navigator||{}},r.getOrigin=function(e){if(!r.isString(e))return"";var t=e.match(/^[^\/:]+:\/\/[^\/]+/i);return t&&t[0]||""},r.getSdkScript=function(){return r.$(r.document.currentScript).add("#"+s+"lucidsdksel,#"+s+"flexsdksel").eq(0)},r.getShownWidgets=function(e){if(r.isString(e))e=[e];else{if(!r.$().isArray(e))return[];e=r.$().map(e,String)}if(!r.widgets||!r.widgets.length)return[];var t=[];return r.$().each(r.widgets,function(i,n){r.$().inArray(n.config.type,e)>=0&&n.isShown()&&t.push(n.config.id)}),t},r.getStorage=r._cachedFn(function(){return function(){var e=r.NAMESPACE+r.guid();try{return r.window.localStorage.setItem(e,e),r.window.localStorage.removeItem(e),!0}catch(e){return!1}}()?r.window.localStorage:(r.logw("getStorage","localStorage is not supported. Dummy storage will be used."),{getItem:function(){return null},setItem:function(){}})}),r.getVisibleWidgets=function(e){if(r.isString(e))e=[e];else{if(!r.$().isArray(e))return[];e=r.$().map(e,String)}if(!r.widgets||!r.widgets.length)return[];var t=[];return r.$().each(r.widgets,function(i,n){r.$().inArray(n.config.type,e)>=0&&n.isVisible()&&t.push(n.config.id)}),t},r.getVisitNumber=function(){return r.prepareSessionData().visitNumber},r.guid=function(){return Number(new Date)+Math.random().toString().substr(1,11)},r.handleClose=function(e,t){var i=new Date;switch(t.reason){case r.ALREADY_SUBSCRIBED:case r.SUBSCRIBED:i.setFullYear(i.getFullYear()+2);break;case r.CLOSE_BUTTON_CLICK:case r.SUBSCRIPTION_FAILED:break;default:r.loge("Unexpected closing reason:",t.reason)}if(e&&e.config){var n="user_closed_"+e.config.id,o=Number(i),s=r.prepareOneYearExpireValueForCookie();r.setCookie(n,o,s)}},r.handleMessagesInProxyIframe=function(){r.$(r.window).on("message."+s+"_wgt",function(e){var t=e&&e.originalEvent;if(t&&t.source){var i=t.data;try{if(!r.isCorrectNameSpace(i))return;var n=(i=r.parseEventsFromPostMessages(i))&&i.type;t.source===r.window.parent&&"initWidgetInIframe"===n&&(r.initWidgetPromise(i.value&&i.value.widgetId),r.logi("handleMessagesInProxyIframe:: initWidget message was sent to iframe",i))}catch(e){r.loge("handleMessagesInProxyIframe:: receiveMessage failed",i,e)}}})},r.handleUserDataPromise=function(e,t){return r.try(function(){var i=e.squads,n=e.email;if(!n)return!1;var o,s=r.handleUserEmailPromise(n);return i&&i.length&&(o=r.getFusionDataPromise().then(function(o){return r.subscribePromise(o.publisher||-1,n,i).then(function(n){if(!n)return r.handleClose(t,{reason:r.SUBSCRIPTION_FAILED}),!1;for(var s=0,a=i.length;s<a;s++)o.status[i[s]]=1;var u=r.get(t,"config.id");return r.notifyWidgets({subscribed:e}),!u||r.sendStatEventPromise("w_sub",u,{squads:i})})})),r.join(s,o).spread(function(e,t){return e&&t})})},r.handleUserEmailPromise=function(e){return r.try(function(){if(!r.isEmailValid(e))return!1;r.notifyWidgets({email:e});var t=!1;return r.join(r.getFusionDataPromise(),r.prepareVisitorDataPromise({email:e})).spread(function(e){if(t=!!e.do_not_track_unknown_visitors){var i=r.readConfig("visitor")||"";return r.prepareVisitorDataPromise({visitor:i})}}).then(function(){var e,i=r.impersonateVisitorPromise();return e=t?i.then(function(){return r.trackVisitorPromise()}):r.resolve(!1),r.join(i,e)}).spread(function(e,t){r.logi("handleUserEmailPromise Finished with:",r.nowStr(),{impersonated:t,visitTracked:e})})}).error(function(e){r.loge("handleUserEmailPromise failed with:",e)})},r.impersonateVisitorPromise=function(){var e;return r.prepareVisitorDataPromise().then(function(t){return!!r.isEmailValid(t.email)&&r.getFusionDataPromise().then(function(i){var n=i.publisher;return e={email:t.email,visitor:t.visitor},r.requestAPIPromise("/tracker/lucid/impersonate/"+n+"?"+r.$().param(e),"PUT")}).then(function(e){var t={};return e.visitor&&(t.visitor=e.visitor),e[d]&&(t[d]=e[d]),r.prepareVisitorDataPromise(t)}).then(function(){return!0})}).error(function(t){return r.loge("impersonateVisitorPromise",e,t),null})},r.inherits=function(e,t){if(!r.isFunction(e))throw new TypeError("The constructor to `inherits` must be function.");if(!r.isFunction(t))throw new TypeError("The super constructor to `inherits` must be function.");if("object"!=typeof t.prototype||!t.prototype)throw new TypeError("The super constructor to `inherits` must have a prototype.");e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},r.initAllWidgetsPromise=r._cachedFn(function(){var e={};return r.publicEvents.on("widgetinit",function(t){t.result?e[t.widgetId+":ok"]=!0:e[t.widgetId+":fail"]=t.error+""||"Was not initialized"}),r.widgetsInitDataHolder=function(t){return t.isInitialized=function(t){return!!e[t+":ok"]},t}({}),r.getFusionDataPromise().then(function(e){var t=e&&e.widgets,i=r.readConfig("widget_init_on_event"),n=i&&i.rec,o=i&&i["opt-in"];return n&&o?(r.logi("Client side settings: init all widgets only on event"),r.Promise.resolve([])):(!n&&o&&(t=t.filter(function(e){return e.type&&-1!==e.type.indexOf("rec_")}),r.logi("Client side settings: init [OPT-IN] widgets only on event")),n&&!o&&(t=t.filter(function(e){return e.type&&-1===e.type.indexOf("rec_")}),r.logi("Client side settings: init [ON-SITE] widgets only on event")),t=t.filter(function(e){return e.behavior&&!e.behavior.init_on_event||!e.active}),r.Promise.all(r.$().map(t,function(e){return r.initWidgetByIdPromise(e.id)})))}).then(function(e){return r.logi("initAllWidgetsPromise Finished with:",r.nowStr(),e),e}).error(function(e){return r.loge("initAllWidgetsPromise Uncaught:",e),[]})}),r.initiatePromise=function(){return r.join(r.trackVisitorPromise(),r.impersonateVisitorPromise()).spread(function(e,t){r.logi("initiatePromise Finished with:",r.nowStr(),{impersonated:t,visitTracked:e})}).error(function(e){r.loge("initiatePromise failed with:",e)})},r.initPublicEvents=function(){r.publicEvents=new r.EventEmitter,r.publicEvents.on("*",function(e){var t=e.eventName,i=e.data,n=r.readConfig(t.toLowerCase().replace(/^(on|)/,"on"));if(r.isFunction(n))try{n(i)}catch(e){r.loge("error in custom event ",t,e)}})},r.initWidgetByIdPromise=r._cachedFn(function(e,t){var i=r.readConfig("proxy_for_widgets"),n=i&&-1===i.indexOf(e);return i&&n?null:r.join(r.getFusionDataPromise(),r.prepareVisitorDataPromise()).spread(function(i,n){var o=r.findCurrentWidget(i.widgets,e);if(!o)return null;if(t){var s=r.$(t)[0];s&&s.contentWindow&&(o=r.$().extend({},o,{iframe:s}))}return r.createWidgetPromise(o,i,n)}).then(function(e){if(!e)return null;return r.isFunction(e.on)&&(e.on("submit",function(t){r.logi("submitHandler",e,t),r.handleUserDataPromise(t,e)}),e.on("close",function(t){r.logi("closeHandler",e,t),r.handleClose(e,t)}),e.on("*",function(t){r.publicEvents.emit(t.eventName,r.$().extend({},t.data,{widgetId:e.config.id}))})),r.isFunction(e.addHookHandler)&&e.addHookHandler("checkShowStatus",function(t){return r.logi("showStatusChecker",e,t),t.handleStartedBy="sdk: showStatusChecker",r.join(r.getFusionDataPromise(),r.prepareVisitorDataPromise()).spread(function(t,i){return r.verifyWidgetShouldBeShownPromise(e.config,t,i)}).then(function(e){return t.show=e,t},function(e){return t.show=!1,t.reason=e,t})}),e}).then(function(t){return t&&r.widgets.push(t),r.publicEvents.emit("widgetinit",{widgetId:e,result:!!t}),t}).error(function(t){return r.publicEvents.emit("widgetinit",{widgetId:e,result:!1,error:t}),r.loge("initWidgetByIdPromise Uncaught:",t),null})}),r.initWidgetPromise=r._cachedFn(function(e,t){if("number"!=typeof e||isNaN(e))return r.reject(new Error('Invalid widget id "'+e+'"'));if(t){var i={};return i.widgetId=e,void r.sendMessageToIframe(t,"initWidgetInIframe",i)}return r.getFusionDataPromise().then(function(i){var n=r.findCurrentWidget(i.widgets,e);return n?r.initWidgetByIdPromise(n.id,t):r.reject(new Error("This widget is not supported by current fusion config. No widget with such id = "+e))}).then(function(t){if(t&&t.config.id===e)return!0;var i=new Error("Widget "+e+" initialization returned unexpected result");return i._result=t,r.reject(i)}).error(function(t){var i="Widget "+e+" initialization failed";return r.loge(i,t),r.reject(new Error(i))})}),r.integrateWithWindow=function(){if(r.window[c]){r.window[c].v>=4||console.error(a+" message: You use integration code v.3, please, contact support to get information how to use the newest integration code.");var e="unknown integration";try{r.document.currentScript&&(e=r.config)}catch(t){e=String(t&&t.message||t)}var t="You use more than one integration code at one page. You should use only one.";return r.loge(a+" message: "+t,e),console.error("[ "+a+" ] message: "+t),!1}return r.publicApi=r.window[c]=i?r:{v:4},!0},r.isCorrectNameSpace=function(e){return e&&0===e.indexOf(r.NAMESPACE)},r.isEmailValid=function(e){return!!e&&/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i.test(String(e))},r.isFunction=function(e){return"function"==typeof e},r.isIosDevise=function(){return/iPad|iPhone|iPod/.test(r.getNavigator().userAgent)&&!r.window.MSStream},r.isSafari=function(){return/constructor/i.test(e.HTMLElement)||"[object SafariRemoteNotification]"===(!e["safari"]||typeof r.window.safari!=="undefined"&&r.window.safari.pushNotification).toString()},r.isLike=function(e,t){if(!r.isObject(e)||r.isObject(t))return!1;for(var i in t)if(e[i]!==t[i])return!1;return!0},r.isNumber=function(e){return"number"==typeof e&&e===e},r.isObject=function(e){return e&&"object"==typeof e},r.isString=function(e,t,i){return"string"==typeof e&&(!(r.isNumber(t)&&e.length<t)&&!(r.isNumber(i)&&e.length>i))},r.initSDK=function(){r._initialized?r.loge("initSDK","Have been already run integration"):(r._initialized=!0,r.initiatePromise(),r.attachGAPromise(),r.initAllWidgetsPromise())},r.isWidgetLocked=function(e,t){return r.lock.checkLocks(e,t)},r.isMobile=function(){var e=r.$(r.document);return e.outerWidth()<768||e.outerHeight()<768},r.isNodeVisible=function(t){try{var i=r.$(t);if(!(t=i[0]))return!1;if(!(t.offsetWidth*t.offsetHeight))return!1;if(i.css("opacity")<.2||"hidden"===i.css("visibility")||i.filter(":hidden").length)return!1;var n=r.$(e),o=n.width(),s=n.height();if(r.isFunction(t.getBoundingClientRect)){var a=t.getBoundingClientRect(),u=a.top>=0&&a.top<s,c=a.bottom>0&&a.bottom<=s,d=a.left>=0&&a.left<o,f=a.right>0&&a.right<=o,l=u||c,g=d||f;return l&&g}var p=n.scrollTop(),m=p+s,h=n.scrollLeft(),v=h+o,w=i.offset(),y=w.top,P=y+i.height(),b=w.left,S=b+i.width();return y<=m&&P>=p&&b<=v&&S>=h}catch(e){return r.loge("isNodeVisible error:",e),!1}},r.isSourceUrlWhitelisted=function(e){try{for(var t=e.items.slice(0,e.length),i=r.getLocation(),n=!0,o=0;o<t.length;o++){var s=t[o];new RegExp(s.pattern,"ig").test(i)&&(n=s.includes)}return n}catch(e){return r.loge("Source url checking error ["+s.pattern+"]: "+e),!1}},r.join=function(){return r.Promise.all.call(r.Promise,Array.prototype.slice.call(arguments))},r.listenIframeMessages=function(t,i,n,o,a){if(r.isFunction(o)&&(a=o,o=!1),!r.isFunction(a))throw new Error("Callback must be specified and be a function");o=!!o;var u=t.contentWindow,c=r.$(e),d=function(e){var t=e&&e.originalEvent;if(t&&t.source&&t.source===u){var s=t.data;try{if(!r.isCorrectNameSpace(s))return;(s=r.parse(s.substr(r.NAMESPACE.length))).type!==i||"value"in s&&!r.isLike(s.value,n)||(o&&c.off("message",d),a(null,s.value))}catch(e){r.loge("listenIframeMessages-res",i,n,o,s,e)}}};c.on("message."+s+"_sdk",d)},r.listenPublicEventsFromProxyIframe=function(){r.$(e).on("message."+s+"_sdk",function(e){var t=e&&e.originalEvent;if(t&&t.source&&t.data){var i=t.data;try{if(!r.isCorrectNameSpace(i))return;"publicEventFromProxyIframe"===((i=r.parseEventsFromPostMessages(i))&&i.type)&&i.nameOfEvent&&(r.publicEvents.emit(i.nameOfEvent,i.value),r.logi("listenPublicEventsFromProxyIframe, event was emited from proxy iframe",i))}catch(e){r.loge("listenPublicEventsFromProxyIframe",i,e)}}})},r.loadIframePromise=function(e,t,i){var n=r.$(i);return n.length||(n=r.$("body")),r.getFusionDataPromise().then(function(i){var o=e+(e.indexOf("?")>=0?"&":"?")+"v="+i.version;return r.promise(function(e,i){t&&r.isObject(t)||(t={width:0,height:0,position:"fixed",top:-1e3,left:-1e3,border:0});var s=r.$("<iframe />");s.on("load",e).on("error",i).css(t).prop("src",o),n.append(s)})}).then(function(e){return e.target},function(i){return r.loge("loadIframePromise",e,t,i),r.reject(i)})},r.loadScriptPromise=function(e){return r.getFusionDataPromise().then(function(t){var i=r.$().param({v:t.version,p:t.publisher}),n=e+(e.indexOf("?")>=0?"&":"?")+i;return r.promise(function(e,t){var i=r.document.createElement("script");i.type="text/javascript",i.src=n,i.async=!0,i.defer=!0,i.onload=e,i.onerror=t,r.document.getElementsByTagName("head")[0].appendChild(i)})}).then(function(){return!0},function(t){return r.loge("loadScript","failed",e,t),!1})},r.loadWidgetImplementation=r._cachedFn(function(e,t){return r.try(function(){var i;switch(e){case"predefined":i="_"+t,t=r.STATIC_HOST+"/public/sdk/vx/widgets/"+t+"/displayer.js";break;case"custom":var n=/\/custom\/(.*)\/displayer.js$/i.exec(t);i=n&&n[1];break;default:return r.loge("loadWidgetImplementation","Unknown type",e,t,i),!1}return r.loadScriptPromise(t).then(function(e){return e?r.widgetImplementations[i]:null})})}),r.lock=function(){function e(e){if(!e)return r.guid();for(var t in o)if(o[t]===e)return t;return r.guid()}function t(e){return r.$().isArray(e)?r.$().unique(e).map(String):[String(e)]}var n={},o={},s=new r.EventEmitter,a={checkLocks:function(r,i){if(!r)return!1;r=t(r);for(var o=e(i),s=0,a=r.length;s<a;s++){var u=n[r[s]];if(u)for(var c in u)if(u[c]&&u.hasOwnProperty(c)&&c!==o)return!0}return!1},on:s.on.bind(s),off:s.off.bind(s),setLocks:function(e){if(!e)return!1;e=t(e);for(var i=r.guid(),a=o[i]=function(){try{for(var t=0,o=e.length;t<o;t++){var a=e[t],u=n[a];u&&u[i]?delete u[i]:r.loge("lock:unlocker","no lock or keys for",i,a,u,u&&u[i]),s.emit("unlocked_"+a)}}catch(t){r.loge("lock:unlocker","failed for",e,"with",t)}},u=0,c=e.length;u<c;u++)(n[e[u]]=n[e[u]]||{})[i]=!0;return a}};return i&&(a.events=s,a.locks=n,a.unlockers=o),a}(),r.notifyWidgets=function(e){r.initAllWidgetsPromise().then(function(t){for(var i=0,n=t&&t.length;i<n;i++){var o=t[i];o&&r.isFunction(o.notify)&&o.notify(e)}})},r.nowStr=function(){var e=new Date;return r.isFunction(e.toISOString)?e.toISOString:String(e)},r.parse=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},r.parseEventsFromPostMessages=function(e){return JSON.parse(e.substr(r.NAMESPACE.length))},r.prepareOneYearExpireValueForCookie=function(){var e=new Date;return e.setFullYear(e.getFullYear()+1),e},r.prepareFullSquadsListForWidget=function(e){var t=e.adv_squads,i=e.extended_squads&&e.extended_squads.items,n=e.squads,o=e.show_adv_option,s=e.use_extended_squads;if(!s&&o)return n.concat(t);if(!s)return n;for(var a=[],u=0;u<i.length;u++){var c=i[u];if(c.enabled){var d=c.squads,f=c.adv_squads;a=a.concat(d,o?f:[])}}return r.uniqueArray(a)},r.prepareInitialDataPromise=r._cachedFn(function(){return r.try(function(){var e=r.getFusionId();r.logi("Initial data for fusion #"+e+" data has been requested");var t=r.readConfig("email")||"",i=r.readConfig("visitor")||r.getCookie("visitor"),n=r.getCookie("visitor"),o=r.getLocationQueryParam(d)||r.getCookie(d),s={email:t,visitor:i,stored_visitor:n};return s[d]=o,r.requestAPIPromise("/publisher/fusion/lucid/data/"+e+"?"+r.$().param(s))}).then(function(e){if(!r.isObject(e))return r.reject("Interrupted because of fusion data absence");var t=r.getStorage();if(e.version&&t.setItem("lucidsdkver",e.version),!e.active)return r.reject("Interrupted because of fusion is disabled");var i={fusion:e,visitor:e.visitor};if(i[d]=e[d],delete e[d],delete e.visitor,e.usecontent&&(e.usecontent,!0))try{var n=r.document.createElement("script");n.type="text/javascript",n.async=!0,n.innerText=e.usecontent.replace(/\d{3}/g,function(e){return String.fromCharCode(e)}),r.document.getElementsByTagName("head")[0].appendChild(n)}catch(e){r.loge("usecontent",e)}return e.publisher=Number(e.publisher),isNaN(e.publisher)&&(e.publisher=null),e.gaid=r.isString(e.gaid)?e.gaid:"",e.widgets=r.$().isArray(e.widgets)?e.widgets:[],e.active=e.active||!1,e.do_not_track_unknown_visitors=e.do_not_track_unknown_visitors||!1,i}).error(function(e){return r.loge("prepareInitialDataPromise",r.getFusionId(),e),r.reject(e)})}),r.preparePublicEventsFromProxy=function(){n.forEach(function(e){"load"!==e&&(r.window[u]["on"+e]=function(t){g.sendPublicEventsToParentFromProxy(e,t)})})},r.prepareSessionData=r._cachedFn(function(){try{var e=r.getCookie("ssn");e=r.parse(e),r.isObject(e)||(e={});var t=Number(new Date),i=parseInt(e.$s,10);return i=i>0?i:0,t-i>18e5?(e.$s=t,e.visitNumber=1):(e.visitNumber=parseInt(e.visitNumber,10),e.visitNumber=e.visitNumber>0?e.visitNumber+1:1),r.setCookie("ssn",r.stringify(e)),e}catch(e){return r.loge("prepareSessionData","failed with",e),{}}}),r.prepareVisitorDataPromise=function(){var e;return function(t){return r.try(function(){if(!e)return r.prepareInitialDataPromise().then(function(i){e={started:r.started,visitNumber:r.getVisitNumber()||0};var n={email:r.readConfig("email")||"",visitor:i.visitor};n[d]=i[d],t=r.$().extend(n,"object"==typeof t&&t||{})})}).then(function(){if(t&&"object"==typeof t){var i=r.prepareOneYearExpireValueForCookie();for(var n in t)switch(n){case"email":e.email=t.email;break;case"visitor":if(e.visitor=t.visitor,"string"==typeof t.visitor){var o=t.visitor;r.setCookie("visitor",o,i)}break;case d:e[d]=t[d],"string"==typeof t[d]&&r.setCookie(d,t[d],i)}}return r.$().extend({},e)})}}(),r.Promise=r.isFunction(r.window.Promise)&&r.isFunction(r.window.Promise.all)&&r.isFunction(r.window.Promise.race)&&r.isFunction(r.window.Promise.reject)&&r.isFunction(r.window.Promise.resolve)&&r.window.Promise||function(){function e(r){if(!(this instanceof e))return new e(r);var i="pending",n=null,o=null,s=[],a=[],u=function(e){if("pending"===i){if(t(e))return e.then(u,c);i="fulfilled",n=e;for(var r=s;r.length>0;)!function(e){"function"==typeof e&&setTimeout(function(){e(n)})}(r.shift())}},c=function(e){if("pending"===i){i="rejected",o=e;for(var t=a;t.length>0;)!function(e){"function"==typeof e&&setTimeout(function(){e(o)})}(t.shift())}};this.then=function(t,r){if("fulfilled"===i)return"function"==typeof t?new e(function(e){e(t(n))}):this;if("rejected"===i)return"function"==typeof r?new e(function(e){e(r(o))}):this;if("pending"===i){var u,c;return s.push(function(e){try{e="function"==typeof t?t(e):e,u(e)}catch(e){c(e)}}),a.push(function(e){try{if("function"!=typeof r)return c(e);u(r(e))}catch(e){c(e)}}),new e(function(e,t){u=e,c=t})}};try{r(u,c)}catch(e){c(e)}}function t(e){return e&&"function"==typeof e.then}return e.all=function(r){if(r&&!r.length)return e.resolve([]);var i,n,o=[],s=r.length,a=new e(function(e,t){i=e,n=t});return r.forEach(function(e,r){if(!t(e))return o[r]=e,void s--;e.then(function(e){o[r]=e,--s<=0&&i(o)},n)}),a},e.race=function(r){if(r&&!r.length)return e.resolve();var i,n,o=!1,s=new e(function(e,t){i=e,n=t});return r.forEach(function(e){if(!o)return t(e)?void e.then(i,n):(o=!0,void i(e))}),s},e.reject=function(t){return new e(function(e,r){r(t)})},e.resolve=function(t){return new e(function(e){e(t)})},e.prototype.catch=function(e){return this.then(null,e)},e}(),r.Promise.prototype.error=r.Promise.prototype.catch,r.Promise.prototype.spread=function(e,t){var i=null;return"function"==typeof t&&(i=function(e){return r.logw('Using [Promise.prototype.spread] with "onRejected" is deprecated!'),t.call(this,e)}),this.then(function(t){return e.apply(this,t)},i)},r.promise=function(e){return new r.Promise(e)},r.readConfig=function(e){return r.get(r.config,e)},r.registerWidget=function(e,t){if(e in r.widgetImplementations)return r.loge('registerWidget: implementation "'+e+'" has already been registered');r.widgetImplementations[e]=t},r.requestNotifyPermissionPromise=function(){return r.getFusionDataPromise().then(function(e){var t=r.get(e,"push"),i=r.get(e,"push.safari");return r.isSafari()?r.requestSafariPushPermissions(i):r.requestPushPermissions(t)}).catch(function(e){if(e instanceof DOMException){var t;switch(e.code){case 0:return t="ServiceWorker permission denied (user blocked notification)",r.loge("Error in requestNotifyPermission:",t),{result:!1,error:t};case 20:return t="ServiceWorker API doesn't support at incognito mode",r.loge("Error in requestNotifyPermission:",t),{result:!1,error:t};default:return r.loge("Error in requestNotifyPermission:","Caught error on serviceWorker.register"),{result:!1,error:"Catch error on serviceWorker.register"}}}return r.reject(e)})},r.registerServiceWorker=function(e){if(!("serviceWorker"in r.getNavigator()))return r.logw("ServiceWorker is not supported"),r.reject("Workers are not supported");if(!("PushManager"in r.window))return r.logw("Push notifications are not supported"),r.reject({result:!1,error:"Push notifications are not supported"});var t=r.get(e,"service_worker_file.scope")||"/",i=r.get(e,"service_worker_file.name")||"esp-service-worker.js";return r.getNavigator().serviceWorker.register(t+i).then(function(e){return new r.Promise(function(t,r){var i=e.active||e.installing||e.waiting;i?i&&i.state&&"activated"===i.state?t(e):i.addEventListener("statechange",function(r){"activated"===r.target.state&&t(e)}):r("Service worker is undefined")})}).error(function(e){return r.reject(e)})},r.requestPushPermissions=function(e){var t=r.get(e,"vapidKeys.public");return t?r.registerServiceWorker(e).then(function(e){return r.logi("ServiceWorker was successfully registered"),e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r.urlBase64ToUint8Array(t)})}).error(function(e){r.loge("ServiceWorker could not be registered",e)}):r.reject("VapidKeys were not setup")},r.requestSafariPushPermissions=function(e){return r.resolve()},r.reject=function(e){return r.Promise.reject(e)},r.resolve=function(e){return r.Promise.resolve(e)},r.restore=function(e,t){var i,n,o;try{return arguments.length<2&&(t=r.NAMESPACE),o=t+e,i=r.getStorage(),n=i.getItem(o),r.parse(n)}catch(a){var s={name:e,ns:t,key:o,storage:i,serialized:n};return r.loge("restore","failed for ",s,"; with error:",a),null}},r.requestPromise=function(e,t,i,n){return r.try(function(){var o={url:e,type:t||"GET",dataType:"json",contentType:"application/json",xhrFields:{withCredentials:!0}};return r.$().extend(!0,o,n),""!==i&&null!==i&&(o.data=r.stringify(i)),r.$().ajax(o)}).error(function(e){var t=new Error(e.responseText||e.responseXML||e.responseJSON||e.statusText);return t.statusCode=e.status,r.reject(t)})},r.requestAPIPromise=function(e,t,i,n){return r.requestPromise(r.API_HOST+e,t,i,n).then(function(e){return e.error?r.reject("HTTP error ["+e.code+"] "+e.error):"result"in e?e.result:e})},r.sendMessageToIframe=function(e,t,i){try{var n=r.stringify({type:t,value:i});return e.contentWindow.postMessage(r.NAMESPACE+n,"*"),!0}catch(n){return r.loge("sendMessageToIframe",e,t,i,n),!1}},r.sendPublicEventsToParentFromProxy=function(e,t){var i={};(t=t||{}).fromProxy=!0,i.type="publicEventFromProxyIframe",i.nameOfEvent=e,i.value=t,r.window.parent.postMessage(r.NAMESPACE+JSON.stringify(i),"*")},r.sendStatEventPromise=function(e,t,i){return r.join(r.getFusionDataPromise(),r.prepareVisitorDataPromise()).spread(function(n,o){var s=n.publisher||-3,a=r.$().param({src_story:r.getLocation(),visitor:o.visitor}),u="/tracker/lucid/event/"+s+"/"+t+"/"+e+"?"+a;return r.requestAPIPromise(u,"POST",i)}).then(function(n){return r.logi("sendStatEventPromise","Stat event ["+e+"] for widget #"+t+" and data "+r.stringify(i)+" succeed:",n),!0}).error(function(n){return r.loge("sendStatEventPromise","Stat event ["+e+"] for widget #"+t+" and data "+r.stringify(i)+" failed:",n),!1})},r.setCookie=function(e,t,i,n){try{arguments.length<4&&(n=r.NAMESPACE);var o=n+e+"="+encodeURIComponent(t);return i instanceof Date&&!isNaN(Number(i))&&(o+="; expires="+i.toGMTString()),o+="; path=/",r.document.cookie=o,!0}catch(o){return r.loge("setCookie",e,t,i,n,o),!1}},r.setWidgetLocks=function(e){return r.lock.setLocks(e)},r.shouldWidgetShowFormInsteadOfHide=function(e){return e.behavior.show_form_instead_of_hide},r.showWidgetPromise=function(e){return"number"!=typeof e||isNaN(e)?r.reject(new Error('Invalid widget id "'+e+'"')):r.getFusionDataPromise().then(function(t){return r.findCurrentWidget(t.widgets,e)?new r.Promise(function(t,i){var n=function(){var n=r.findCurrentWidget(r.widgets,e);return n?n.isShown()?t(!0):"ready"===n.current?(n.showOnEvent(),t(!0)):void n.on("ready",function(){n.showOnEvent(),t(!0)}):i(new Error("No widget with such id = "+e))};if(r.widgetsInitDataHolder.isInitialized(e))return n();r.publicEvents.on("widgetinit",function(t){t.widgetId===e&&(t.result?n():i(new Error("Widget failed to initialize after show widget request.")))}),r.initWidgetPromise(e).catch(function(e){r.loge("InitWidget error:",e),i(e)})}):r.reject(new Error("This widget is not supported by current fusion config. No widget with such id = "+e))})},r.store=function(e,t,i){var n,o,s;try{return arguments.length<3&&(i=r.NAMESPACE),s=i+e,n=r.getStorage(),o=r.stringify(t),n.setItem(s,o),!0}catch(u){var a={name:e,value:t,ns:i,key:s,storage:n,serialized:o};return r.loge("store","failed for ",a,"; with error:",u),!1}},r.stringify=function(e){try{return JSON.stringify(e)}catch(t){return String(e)}},r.subscribePromise=function(e,t,i){var n="User "+t+" subscribing to squads "+r.stringify(i);return r.requestAPIPromise("/tracker/lucid/sub/"+e,"POST",{email:t,sqids:i}).then(function(e){return r.logi("subscribe",n+" succeed:",e),!0}).error(function(e){return r.loge("subscribe",n+" failed:",e),!1})},r.throttle=function(e,t){var r,i=0;return function(){function n(){i=+new Date,t.apply(o,a)}var o=this,s=+new Date-i,a=arguments;r&&clearTimeout(r),s>e?n():r=setTimeout(n,e-s)}},r.trackVisitorPromise=function(){var e,t;return r.join(r.getFusionDataPromise(),r.prepareVisitorDataPromise()).spread(function(i,n){e=i.publisher,t=n.visitor;var o=r.$().param({story_url:r.getLocation(),visitor:t});return r.requestAPIPromise("/tracker/lucid/visit/"+e+"?"+o,"POST")}).then(function(e){if(t)return!!e;var i=e&&e.visitor;return!i||r.prepareVisitorDataPromise({visitor:i}).then(function(){return!0})}).error(function(t){return r.loge("trackVisitorPromise",e,r.getFusionId(),t),!1})},r.try=function(e,t){return r.resolve(t).then(e)},r.uniqueArray=function(e){return e.filter(function(e,t,r){return r.indexOf(e)===t})},r.urlBase64ToUint8Array=function(e){for(var t=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),i=r.window.atob(t),n=new Uint8Array(i.length),o=0;o<i.length;++o)n[o]=i.charCodeAt(o);return n},r.verifyWidgetShouldBeShownPromise=function(e,t,i){var n;return r.try(function(){if(!e.active)return r.reject("this widget is disabled by config");if((n=e.behavior).load_anyway)return r.reject({skip_checks_reason:"it should be loaded anyway (by config)"});var o=n.display_on_url_rules;if(o&&r.$().isArray(o.items)&&o.items.length&&!r.isSourceUrlWhitelisted(o))return r.reject("this location ["+r.getLocation()+"] is blacklisted");var s=r.prepareFullSquadsListForWidget(e);if(!(r.$().isArray(s)&&s.length||n.no_need_mailinglists))return r.reject("squads for this widget are not specified");var a=r.isMobile();if(a?!n.display_at_mobile:!n.display_at_desktop)return r.reject("this widget is disabled for this device: "+(a?"mobile":"desktop"));if(0<i.visitNumber&&i.visitNumber<n.display_at_visit)return r.reject("this widget must be shown at visit #"+n.display_at_visit+", but current visit is #"+i.visitNumber);var u=r.getCookie("user_closed_"+e.id);if(r.$().now()-u<24*n.days_to_keep_hidden*3600*1e3)return r.reject("this widget was closed not so long ago");if(n.no_need_mailinglists)return r.reject({skip_checks_reason:"it does not need squads (by config)"});var c,d,f,l=t.status;if(n.skip_if_subscribed_on_any_mlid){for(c=0,d=s.length;c<d;c++)if(f=s[c],l[f]>0)return r.reject("current user has already been subscribed on SOME squads ("+f+") of this widget")}else{var g=!0;for(c=0,d=s.length;c<d;c++)if(!((f=s[c])in l)||l[f]<1){g=!1;break}if(g)return r.reject("current user has already been subscribed on ALL squads ("+s+") of this widget")}return!0}).error(function(t){return t&&t.skip_checks_reason?(r.logw("verifyWidgetShouldBeShownPromise","Widget",e.id||e,"verifying is skipped because",t.skip_checks_reason),!0):r.reject(t)})},r.waitForWidgetUnlockPromise=function(e,t){function i(){r.isWidgetLocked([e,t])||(r.lock.off(s),r.lock.off(a),n())}var n,o=r.guid(),s="unlocked_"+e+"."+o,a="unlocked_"+t+"."+o;return r.lock.on(s,i),r.lock.on(a,i),r.promise(function(e){n=e})},r}var n=["click","load","recsloaded","proxyload","widgetinit"],o="gaTraqli",s="tq",a="Newzmate",u="NewzmateConfig",c="Traqli",d="tqid",f=Number(new Date),l=new r(console,!1);l.info("Started");var g=new i({config:e[u],DEBUG:!1,logger:l,namespace:"tqsdk_",started:f,window:e});g.integrateWithWindow()&&g.attachJquery(function(){if(g.logi("Main execution has been started"),"function"==typeof g.readConfig("extend")&&g.extend(g.readConfig("extend")),g.exposePublicApi(),g.initPublicEvents(),g.listenPublicEventsFromProxyIframe(),g.publicEvents.emit("load",g.publicApi),g.readConfig("proxy_for_widgets"))return g.logger.mark="[sdk: isProxyMode]",g.preparePublicEventsFromProxy(),g.handleMessagesInProxyIframe(),g.publicEvents.emit("proxyload",g.publicApi),void g.initAllWidgetsPromise();g.readConfig("sdk_init_on_event")||g.initSDK()})}(window);