webpackJsonpppg__name_([2],{106:function(e,t,n){"use strict";function r(e){return o(this,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),c.configureScope(function(t){t.setExtra("debug",!1),t.setTag("plugin","beacon"),t.setTag("version",e.version),t.setTag("project",e.projectId)}),[4,u.BeaconPluginStore.create(e)];case 1:return t=r.sent(),t.run(),[3,3];case 2:return n=r.sent(),c.captureException(n),[3,3];case 3:return[2]}})})}var o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(3),a=n(30),s=n(10),u=function(){function e(e,t,n,r){var o=this;this.apiURL=e,this.getData=t,this.endSession=this.startSession();var a=i.diffDates(n());switch((0===a||a>14400)&&window.addEventListener("load",function(){return setTimeout(function(){return o.send()},50)},!1),r){case"history":i.registerEventOnHistoryAPIChange(window.history),s.eventBus.on("pushstate",function(){return o.send()},!1);break;case"hash":window.addEventListener("hashchange",function(){return o.send()},!1);break;case"visibilitychange":window.addEventListener("visibilitychange",function(){if("visible"!==document.visibilityState)return this.send()});break;case"default":default:window.addEventListener("unload",function(){return o.send()},!1)}}return e.prototype.startSession=function(){var e=this,t=Date.now();return function(){return e.prepareToSendData({pageVisitTime:(Date.now()-t)/1e3,referrer:document.referrer,origin:location.href,url:location.href.replace(/^.*\/\/[^\/]+/,"")})}},e.prototype.prepareToSendData=function(e){return JSON.stringify(i.extend(e,this.getData()))},e.prototype.send=function(){var e=navigator.sendBeacon(this.apiURL+"/beacon",this.endSession());return s.eventBus.trigger("beacon",{result:e}),this.endSession=this.startSession(),e},r([a.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"startSession",null),r([a.log,o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",void 0)],e.prototype,"prepareToSendData",null),r([a.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"send",null),e}();t.Beacon=u},204:function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,i=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]-1)}),e.geoLocation=this.geoLocation,e},t.prototype.isBeaconInstanceRun=function(){return this.selectorInstance&&this.beaconInstance||!1},t.prototype.subscriberIdExists=function(){return this.subscriberId},t.prototype.internalBeaconRun=function(){var e=this;!1===this.isBeaconInstanceRun()&&this.subscriberIdExists()&&(this.selectorInstance=new c.Selector(this.options.beacon.selectors),this.beaconInstance=new u.Beacon(this.options.apiURL,function(){return e.getBeaconData()},function(){return e.getLastVisitTs()},this.options.beacon.strategy))},t.prototype.run=function(){var e=this;d.eventBus.on("tag",function(t){var n=t.state,r=t.tag,o=t.label;e.externalTags=l.filter(e.externalTags,function(e){return e.tag!==r}),e.externalTagsToDelete=l.filter(e.externalTagsToDelete,function(e){return e.tag!==r}),n?e.externalTags.push({tag:r,label:o||"default"}):e.externalTagsToDelete.push({tag:r,label:o||"default"})}),d.eventBus.on("geoLocation",function(t){e.geoLocation=t}),d.eventBus.on("subscriberActive",function(t){return a(e,void 0,void 0,function(){return s(this,function(e){try{this.subscriberId=t.subscriberId,this.internalBeaconRun()}catch(e){g.withScope(function(t){t.setExtra("debug",!1),g.captureException(e)})}return[2]})})}),this.internalBeaconRun()},o([p.Store.lsProperty({defaults:null}),i("design:type",String)],t.prototype,"subscriberId",void 0),o([p.Store.lsProperty({defaults:0}),i("design:type",Number)],t.prototype,"lastTs",void 0),o([p.Store.property({defaults:[]}),i("design:type",Array)],t.prototype,"externalTagsToDelete",void 0),o([p.Store.property({defaults:[]}),i("design:type",Array)],t.prototype,"externalTags",void 0),o([p.Store.property({}),i("design:type",Object)],t.prototype,"geoLocation",void 0),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",Number)],t.prototype,"getLastVisitTs",null),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",void 0)],t.prototype,"getBeaconData",null),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",void 0)],t.prototype,"isBeaconInstanceRun",null),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",void 0)],t.prototype,"subscriberIdExists",null),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",void 0)],t.prototype,"internalBeaconRun",null),o([p.log,i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",void 0)],t.prototype,"run",null),t}(p.Store);t.BeaconPluginStore=y},205:function(e,t,n){"use strict";var r=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(30),a=n(3),s=n(10),u=function(){function e(e){var t=this;this.tags={default:{}},this.data={},this.observers=[],this.globalBindedSelectors=[],this.bindSelectorEvents(e),s.eventBus.on("beacon",function(){t.resetState(),setTimeout(function(){return t.bindSelectorEvents(e)},100)},!1)}return e.prototype.resetState=function(){a.each(this.observers,function(e){return clearInterval(e)}),this.observers=[],this.globalBindedSelectors=[],this.tags={default:{}},this.data={}},e.prototype.getData=function(){return a.extend(this.data,this.prepareTags())},e.prototype.getDataForWizzard=function(){return a.extend(this.data,this.prepareTagsForWizzard())},e.prototype.prepareTags=function(){var e=(this.data.tags||"").split(";"),t=[];return a.map(this.tags,function(e,n){return a.map(e,function(e){return t.push({tag:e,label:n})})}),a.unifyTags(t.concat(e))},e.prototype.prepareTagsForWizzard=function(){return{tags:(this.data.tags||"").split(";").join("; ")}},e.prototype.getTagsForWizard=function(){var e={};return a.each(this.tags,function(t){return e=a.extend(e,t)}),e},e.prototype.getValueOfEl=function(e){return(e.textContent||e.value||"").trim().replace(/\r?\n|\r/g,"")},e.prototype.parseElementByType=function(e,t){if(!t)return"boolean"!==e.type&&null;var n=e.attribute?t.getAttribute(e.attribute):this.getValueOfEl(t);switch(e.type){case"boolean":return"click"===e.event||!!t;case"number":return"click"===e.event?1:parseFloat(n&&n.replace(/[^\d.,]/g,""));default:return n}},e.prototype.parseByType=function(e,t){switch(e.type){case"number":return Number(t);case"boolean":return Boolean(t);case"date":return new Date(t);default:return String(t)}},e.prototype.observeElement=function(e,t,n,r,o){var i=this;void 0===o&&(o=500);var a=setInterval(function(){if(e[t[n]]||0===e[t[n]]||""===e[t[n]]||null===e[t[n]])return window.clearInterval(a);e[t[n]]=i.parseElementByType(t,r)},o);this.observers.push(a)},e.prototype.observeJSVariable=function(e,t){var n=this;void 0===t&&(t=500);var r=setInterval(function(){if(n.data[e.name]||0===n.data[e.name]||""===n.data[e.name]||null===n.data[e.name])return window.clearInterval(r);var t=n.parseByType(e,a.get(window,e.selector));if("tag"===e.name){var o=n.getTagStoreByLabel(e.tagLabel);t&&"undefined"!==t&&(o[e.selector]=t)}else t&&"undefined"!==t&&(n.data[e.name]=t)},t);this.observers.push(r)},e.prototype.getTagStoreByLabel=function(e){return void 0===e&&(e="default"),this.tags[e]||(this.tags[e]={}),this.tags[e]},e.prototype.addEventBySelector=function(e,t){var n=this;switch(e.name){case"tag":return this.observeElement(this.getTagStoreByLabel(e.tagLabel),e,"selector",t);default:if("view"===e.event)return this.observeElement(this.data,e,"name",t);if("click"===e.event&&e.bindAll)return void this.globalBindedSelectors.push(e);if(this.data[e.name]=this.parseElementByType(e,null),!t)return;t.addEventListener(e.event,function(){n.data[e.name]=n.parseElementByType(e,t)})}},e.prototype.bindGlobalSelectors=function(){if(0!==this.globalBindedSelectors.length){var e=this;document.addEventListener("click",function(t){for(var n=a.unique(e.globalBindedSelectors),r=e.findElementParents(t),o=0,i=n;o-1?t.observeJSVariable(e):t.addEventBySelector(e,a.$(e.selector)))}),this.bindGlobalSelectors()},r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"resetState",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"getData",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"getDataForWizzard",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"prepareTags",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"prepareTagsForWizzard",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"getTagsForWizard",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",void 0)],e.prototype,"getValueOfEl",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",void 0)],e.prototype,"parseElementByType",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",void 0)],e.prototype,"parseByType",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object,Object,String,Object,Number]),o("design:returntype",void 0)],e.prototype,"observeElement",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object,Number]),o("design:returntype",void 0)],e.prototype,"observeJSVariable",null),r([i.log,o("design:type",Function),o("design:paramtypes",[String]),o("design:returntype",void 0)],e.prototype,"getTagStoreByLabel",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Object,Object]),o("design:returntype",void 0)],e.prototype,"addEventBySelector",null),r([i.log,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],e.prototype,"bindGlobalSelectors",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Event]),o("design:returntype",void 0)],e.prototype,"findElementParents",null),r([i.log,o("design:type",Function),o("design:paramtypes",[Array]),o("design:returntype",void 0)],e.prototype,"bindSelectorEvents",null),e}();t.Selector=u}}); //# sourceMappingURL=beacon.js.map