analytics-web3
Version:
Spock analytics SDK analytics-web3 is a js module to collect and log all the data and events of DApp for analytics.
1 lines • 80.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("analytics-web3",[],e):"object"==typeof exports?exports["analytics-web3"]=e():t["analytics-web3"]=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e);var n=function(t){return"".concat("spock","_").concat(t)},o={DEMOGRAPHICS:"demographics",ENGAGE:"engage",WEB2:"web2",WEB3:"web3"},i={DATA_POINTS:Object.values(o),DEBUG:!1,INACTIVITY_TIMEOUT:30,OPT_OUT:!1,TEST_ENV:!1,TEST_MODE:!1},a={ERROR:"[".concat(n("ERROR"),"] "),WARNING:"[".concat(n("WARNING"),"] "),INFO:"[".concat(n("INFO"),"] "),DEBUG:"[".concat(n("DEBUG"),"] "),VERBOSE:"[".concat(n("VERBOSE"),"] ")},c="Metamask",u="WalletConnect",s="Coinbase",l="Fortmatic",f="Portis",h="Other",d={SEND_TXN:n("sendTxn"),LEGACY_TXN_CALLBACK:n("legacyTxnCallback"),STORAGE_SET_ITEM:n("storageSetItem"),STORAGET_GET_ITEM:n("storageGetItem"),WALLET_CONNECTION:n("walletConnection")},p={COOKIES:{DISTINCT_ID:n("cache_distinctId"),SESSION:n("session"),OPT_OUT:n("opt_out")},LOCAL_STORAGE:{DEVICE_ID:n("device_Id")}},y={APP_VISIT:"app-visit",EXPIRE_OLD_SESSION:"expire-old-session",OUTBOUND:"outbound",PAGE_VIEW:"page-view",PAUSE_SESSION:"pause-session",REWIND_SESSION:"rewind-session",SESSION:"session",TRANSACTION:"transaction",WALLET_CONNECTION:"wallet-connect"},v=n("show_popup"),b=n("hide_popup"),m=n("button_click"),g=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function w(t){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function O(t){return!E(t,"undefined")}function E(t,e){return w(t)===e}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function k(t){return function(t){if(Array.isArray(t))return x(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function j(t){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,I(n.key),n)}}function T(t,e,r){return(e=I(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function I(t){var e=function(t,e){if("object"!==j(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===j(e)?e:String(e)}var _={connectedAccount:void 0,connectedChain:void 0,distinctId:void 0,flow:[],initialized:!1,ip:void 0,optOut:void 0,provider:void 0,sessionId:void 0,trackingQueue:[],txnReject:0,txnSubmit:0,userInfo:void 0,sessionDuration:function(){return 0}},C=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,r,n;return e=t,n=[{key:"dispatch",value:function(e){O(e)&&Object.keys(e).map((function(r){if(Object.keys(t.store).includes(r)){var n=e[r];t.store[r]="object"===j(n)?Array.isArray(n)?k(n):function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach((function(e){T(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},n):n}}))}}],(r=null)&&P(e.prototype,r),n&&P(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();T(C,"store",_);var L=C;function A(t,e){return t===y.TRANSACTION?{hash:null==e?void 0:e.hash,from:null==e?void 0:e.from,to:null==e?void 0:e.to,status:null==e?void 0:e.status}:e}function N(t,e,r){var n="expires="+function(t){return new Date(Date.now()+t).toUTCString()}(r);document.cookie=t+"="+e+"; "+n+"; path=/"}function R(t){var e,r=t+"=";return decodeURIComponent(document.cookie).split("; ").forEach((function(t){0===t.indexOf(r)&&(e=t.substring(r.length))})),e}function D(t){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==D(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===D(i)?i:String(i)),n)}var o,i}function G(t){if(O(t)){var e=t.split("/");return e.length>=3?e[2]:""}}var B=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,r,n;return e=t,n=[{key:"safeExecute",value:function(t){try{return t()}catch(t){return}}},{key:"stringify",value:function(e){return t.safeExecute((function(){return JSON.stringify(e)}))}},{key:"parse",value:function(e){return t.safeExecute((function(){return JSON.parse(e)}))}}],(r=null)&&M(e.prototype,r),n&&M(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function W(){return Math.floor((new Date).getTime()/1e3)}function F(t,e,r){O(t.addEventListener)?t.addEventListener(e,r,!1):t.attachEvent("on"+e,r)}function U(t,e){return O(t)?t:e}function V(t,e){return-1!==t.indexOf(e)}function K(t){return Object.entries(t).reduce((function(t,e){var r=e[1];return""!==(r=O(r)?r.toString():"").trim()&&(t[e[0]]=r),t}),{})}function z(t){return(z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function H(t,e,r){if(t&&"undefined"!=typeof console){arguments[2]&&"object"===z(arguments[2])&&(arguments[2]=B.stringify(arguments[2]));var n=arguments[3]?E(arguments[3],"object")?B.stringify(arguments[3]):arguments[3]:"",o=e+r+" "+n;switch(e){case a.ERROR:console.error(o);break;case a.WARNING:console.warn(o);break;case a.INFO:console.info(o);break;case a.VERBOSE:console.log(o);break;default:console.debug(o)}}}function q(t){return(q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function X(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Y(Object(r),!0).forEach((function(e){Q(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Q(t,e,r){return(e=et(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */$=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),c=new x(o||[]);return n(a,"_invoke",{value:O(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function d(){}function p(){}var y={};u(y,i,(function(){return this}));var v=Object.getPrototypeOf,b=v&&v(v(j([])));b&&b!==e&&r.call(b,i)&&(y=b);var m=p.prototype=h.prototype=Object.create(y);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;n(this,"_invoke",{value:function(n,i){function a(){return new e((function(o,a){!function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==q(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(n,i,o,a)}))}return o=o?o.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=j,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function J(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Z(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){J(i,n,o,a,c,"next",t)}function c(t){J(i,n,o,a,c,"throw",t)}a(void 0)}))}}function tt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,et(n.key),n)}}function et(t){var e=function(t,e){if("object"!==q(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===q(e)?e:String(e)}var rt=function(){function t(e){var r=e.appKey,n=e.log,o=e.testENV,i=e.testMode,a=e.store;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.log=n,this.testMode=i,this.endPoint=o?"https://ingest-dev.spockanalytics.xyz":"https://ingest.spockanalytics.xyz",this.store=a,this.appKey=r,this.headers={"Content-type":"application/json; charset=UTF-8"},this.post=this.post.bind(this)}var e,r,n,o,i,c;return e=t,(r=[{key:"sendFetch",value:(c=Z($().mark((function t(e,r){var n;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch(e,{method:"POST",headers:this.headers,body:r});case 3:return n=t.sent,t.next=6,n.json();case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(0),this.log(a.ERROR,"".concat(e," sendFetch"),null===t.t0||void 0===t.t0?void 0:t.t0.toString());case 11:case"end":return t.stop()}}),t,this,[[0,8]])}))),function(t,e){return c.apply(this,arguments)})},{key:"sendBeacon",value:(i=Z($().mark((function t(e,r){var n;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:try{navigator.sendBeacon&&(n=new Blob([r],{type:"text/plain"}),navigator.sendBeacon(e,n))}catch(t){this.log(a.ERROR,"".concat(e," sendBeacon"),null==t?void 0:t.toString())}case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"post",value:(o=Z($().mark((function t(e,r){var n,o,i,a;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.data,o=r.sendBeacon,!this.store.optOut){t.next=3;break}return t.abrupt("return");case 3:if(!(i=B.stringify(X({appKey:this.appKey},n)))){t.next=15;break}if(!this.testMode){t.next=7;break}return t.abrupt("return");case 7:if(a="".concat(this.endPoint,"/").concat(e),!o){t.next=13;break}return t.next=11,this.sendBeacon(a,i);case 11:t.next=15;break;case 13:return t.next=15,this.sendFetch(a,i);case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})}])&&tt(e.prototype,r),n&&tt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function nt(t){return(nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ot(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ot=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),c=new x(o||[]);return n(a,"_invoke",{value:O(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function d(){}function p(){}var y={};u(y,i,(function(){return this}));var v=Object.getPrototypeOf,b=v&&v(v(j([])));b&&b!==e&&r.call(b,i)&&(y=b);var m=p.prototype=h.prototype=Object.create(y);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;n(this,"_invoke",{value:function(n,i){function a(){return new e((function(o,a){!function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==nt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(n,i,o,a)}))}return o=o?o.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=j,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function it(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function at(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){it(i,n,o,a,c,"next",t)}function c(t){it(i,n,o,a,c,"throw",t)}a(void 0)}))}}function ct(t){return function(t){if(Array.isArray(t))return ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||lt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==nt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==nt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===nt(i)?i:String(i)),n)}var o,i}function st(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||lt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lt(t,e){if(t){if("string"==typeof t)return ft(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ft(t,e):void 0}}function ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var ht={display:"none",position:"fixed",borderRadius:"0",border:"none",zIndex:"2147483647"};function dt(t,e){for(var r=0,n=Object.entries(e);r<n.length;r++){var o=st(n[r],2),i=o[0],a=o[1];t.style[i]=a}}var pt=new(function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setUserDefinedOnClick=this.setUserDefinedOnClick.bind(this),this.store=L.store,this.dispatch=L.dispatch}var e,r,n,o,i;return e=t,(r=[{key:"init",value:function(t,e){var r,n=e?"https://spock-widget-56b11.web.app":"https://widget.spockanalytics.xyz";this.widgetEndpoint=n,this.iframe=((r=document.createElement("iframe")).src=n+"/?appKey=".concat(t),r.title="Spock Widget",r.id="spock-widget",r.dataset.spockIframeLabel=new URL(n).host,dt(r,ht),document.body.appendChild(r),r),F(window,"message",this.eventHandler.bind(this))}},{key:"addFlow",value:function(t,e){this.dispatch({flow:[].concat(ct(this.store.flow),[{event:t,properties:e}])})}},{key:"eventHandler",value:function(t){var e,r,n,o,i,a,c=t.origin,u=t.data;if(c===this.widgetEndpoint)switch(null==u?void 0:u.message){case v:this.show(null==u||null===(e=u.body)||void 0===e?void 0:e.styles),(null==u||null===(r=u.body)||void 0===r?void 0:r.campaignId)&&this.addFlow("show-popup",{campaignId:null==u||null===(n=u.body)||void 0===n?void 0:n.campaignId});break;case b:this.hide(),this.addFlow("hide-popup",{campaignId:null==u||null===(o=u.body)||void 0===o?void 0:o.campaignId});break;case m:var s;this.hide(),null!=u&&null!==(i=u.body)&&void 0!==i&&i.redirectUrl?window.location.href=null==u||null===(s=u.body)||void 0===s?void 0:s.redirectUrl:this.userDefinedClickMethod&&this.userDefinedClickMethod(null==u?void 0:u.body),this.addFlow("click-popup",{campaignId:null==u||null===(a=u.body)||void 0===a?void 0:a.campaignId})}}},{key:"documentLoaded",value:(i=at(ot().mark((function t(e){return ot().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("complete"==document.readyState){t.next=7;break}return t.next=3,new Promise((function(t){return setTimeout(t,5e3)}));case 3:if(t.t0=e<5,!t.t0){t.next=7;break}return t.next=7,this.documentLoaded(e+1);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"postMessage",value:(o=at(ot().mark((function t(e,r){return ot().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.iframe||!this.iframe.contentWindow){t.next=4;break}return t.next=3,this.documentLoaded(0);case 3:this.iframe.contentWindow.postMessage({message:e,body:r},this.widgetEndpoint);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"show",value:function(t){dt(this.iframe,t)}},{key:"hide",value:function(){this.iframe.style.display="none"}},{key:"setUserDefinedOnClick",value:function(t){this.userDefinedClickMethod=t}}])&&ut(e.prototype,r),n&&ut(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}());function yt(t){return(yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function vt(t){return function(t){if(Array.isArray(t))return bt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return bt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bt(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function mt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function gt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?mt(Object(r),!0).forEach((function(e){wt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function wt(t,e,r){return(e=Et(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ot(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function Et(t){var e=function(t,e){if("object"!==yt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===yt(e)?e:String(e)}var St=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.appKey=e.appKey,this.dataPoints=U(e.dataPoints,i.DATA_POINTS).concat("web3").reduce((function(t,e){return t[e]=!0,t}),{}),this.debug=U(e.debug,i.DEBUG),this.defaultOptOut=U(e.optOut,i.OPT_OUT),this.inActivityTimeout=U(e.inactivityTimeout,i.INACTIVITY_TIMEOUT),this.testENV=U(e.testENV,i.TEST_ENV),this.testMode=U(e.testMode,i.TEST_MODE),this.store=L.store,this.dispatch=L.dispatch,this.log=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return H.apply(void 0,[r.debug&&!r.store.optOut,t].concat(n))},this.request=new rt({appKey:this.appKey,log:this.log,testMode:this.testMode,testENV:this.testENV,store:this.store}),this.widgetController=pt}var e,r,c;return e=t,(r=[{key:"setConsetCookie",value:function(t,e,r){!this.store.optOut&&N(t,e,r)}},{key:"trackEvent",value:function(t){var e,r,i=t.event,c=t.properties,u=t.logMessage,s=t.sendBeacon,l=t.allowTrack,f=g.reduce((function(t,e){var r=function(t,e){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);if(null===r||r&&"string"!=typeof r[1]&&r[1].length)return"";var n=r[1];try{n=decodeURIComponent(n)}catch(t){}return n.replace(/\+/g," ")}(document.URL,e);return r&&(t[function(t){var e=t.split("_");return e[0]+e[1][0].toUpperCase()+e[1].slice(1)}(e)]=r),t}),{}),h=gt(gt({},this.store.userInfo),{},{currentUrl:window.location.href}),d=gt(gt({},h),f),v=gt(gt({},this.dataPoints[o.WEB2]?d:{}),{},{ip:this.dataPoints[o.DEMOGRAPHICS]?this.store.ip:void 0,chain:this.store.connectedChain,distinctId:this.store.distinctId,insertId:(r=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),e?r.substring(0,e):r),sessionId:this.store.sessionId,time:Date.now()/1e3,walletAddress:this.store.connectedAccount,dataPoints:Object.keys(this.dataPoints).sort()},null!=c?c:{});if(i===y.PAUSE_SESSION&&this.setConsetCookie(p.COOKIES.SESSION,B.stringify(gt(gt({},v),{},{ip:this.store.ip})),6048e5),[y.SESSION,y.PAUSE_SESSION].includes(i)||this.dispatch({flow:[].concat(vt(this.store.flow),[{event:i,properties:A(i,c)}])}),l&&(this.store.initialized?this.request.post("track/".concat(i),{data:v,sendBeacon:s}):this.dispatch({trackingQueue:[].concat(vt(this.store.trackingQueue),[{event:i,data:v}])})),this.dataPoints[o.ENGAGE]){var b=this.store,m=b.ip,w=b.flow,O=b.optOut,E=b.initialized,S=b.txnReject,k=b.txnSubmit,x=b.sessionDuration;this.widgetController.postMessage(n(i.replace(/-/g,"_")),gt(gt(gt({},v),d),{},{store:{duration:"function"==typeof x?x():0,flow:w,initialized:E,ip:m,optOut:O,txnReject:S,txnSubmit:k},browserProps:{innerWidth:window.innerWidth}}))}u&&this.log(a.INFO,u,v)}},{key:"processQueue",value:function(){var t=this;this.store.trackingQueue.forEach((function(e){var r=e.event,n=e.data;t.request.post("track/".concat(r),{data:n})})),this.dispatch({trackingQueue:[]})}}])&&Ot(e.prototype,r),c&&Ot(e,c),Object.defineProperty(e,"prototype",{writable:!1}),t}();function kt(t){return(kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function xt(t){return function(t){if(Array.isArray(t))return jt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return jt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jt(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(o=n.key,i=void 0,i=function(t,e){if("object"!==kt(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(o,"string"),"symbol"===kt(i)?i:String(i)),n)}var o,i}function Tt(t,e){return(Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function It(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=Lt(t);if(e){var o=Lt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return _t(this,r)}}function _t(t,e){if(e&&("object"===kt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Ct(t)}function Ct(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Lt(t){return(Lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var At=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}(u,t);var e,r,n,c=It(u);function u(t){var e,r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),(e=c.call(this,t)).inActivityTimeout=60*((r=e.inActivityTimeout)<2||r>30?i.INACTIVITY_TIMEOUT:r)*1e3,e.documentHidden=!1,e.storedDuration=0,e.inActivityCounter=0,e.sessionExpired=!1,e.hiddenTime=0,e.totalHiddenTime=0,e.hidden="hidden",e.dispatch({sessionDuration:e.sessionDuration.bind(Ct(e))}),e}return e=u,(r=[{key:"trackSession",value:function(){var t=this;this.beginSession(),this.inActivityInterval(),F(window,"beforeunload",this.pauseSession.bind(this)),F(window,d.WALLET_CONNECTION,(function(){t.endSession(),t.beginSession()})),this.visibilityEvents(),F(window,"mousemove",this.resetInActivity.bind(this)),F(window,"click",this.resetInActivity.bind(this)),F(window,"keydown",this.resetInActivity.bind(this)),F(window,"scroll",this.resetInActivity.bind(this))}},{key:"beginSession",value:function(){var t,e=R(p.COOKIES.SESSION);O(e)?this.rewindSession(e):(this.startTime=W(),this.dispatch({sessionId:(t=(new Date).getTime(),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)})))}),0===this.store.flow.length&&this.dispatch({flow:[{event:y.PAGE_VIEW,properties:{pathname:window.location.pathname,search:window.location.search}}]}),this.storedDuration=0,this.inActivityCounter=0,this.sessionExpired=!1,this.hiddenTime=0,this.totalHiddenTime=0,this.log(a.INFO,"Session started"))}},{key:"rewindSession",value:function(t){N(p.COOKIES.SESSION,"",-1);var e=B.parse(t),r=e.duration,n=e.flow,o=e.pauseTime,i=e.sessionId,a=e.timeout,c=e.txnReject,u=e.txnSubmit;W()-o>=a/1e3?(this.request.post("track/".concat(y.EXPIRE_OLD_SESSION),{data:e}),this.beginSession()):(this.startTime=o,this.dispatch({sessionId:i,txnReject:c,txnSubmit:u,flow:[].concat(xt(n),xt(this.store.flow))}),this.storedDuration=r,this.request.post("track/".concat(y.REWIND_SESSION),{data:{sessionId:i}}))}},{key:"pauseSession",value:function(){if(!this.sessionExpired){var t=this.sessionDuration(),e=this.store,r=e.connectedAccount,n=e.flow,o=e.sessionId,i=e.txnReject,a=e.txnSubmit,c={duration:t,flow:n,pauseTime:W(),sessionId:o,timeout:this.inActivityTimeout,txnReject:i,txnSubmit:a,walletConnected:Boolean(r)};this.trackEvent({event:y.PAUSE_SESSION,properties:c,logMessage:"Pause session",sendBeacon:!0,allowTrack:!0})}}},{key:"endSession",value:function(){var t=this.sessionDuration(),e=this.store,r=e.connectedAccount,n={duration:t,flow:e.flow,sessionId:e.sessionId,txnReject:e.txnReject,txnSubmit:e.txnSubmit,walletConnected:Boolean(r)};this.trackEvent({event:y.SESSION,properties:n,logMessage:"Session expired",allowTrack:this.dataPoints[o.WEB2]}),this.dispatch({flow:[],txnReject:0,txnSubmit:0})}},{key:"sessionDuration",value:function(){var t=this.storedDuration+(W()-this.startTime);return t-=this.totalHiddenTime}},{key:"resetInActivity",value:function(){this.sessionExpired&&this.beginSession(),this.inActivityCounter=0}},{key:"inActivityInterval",value:function(){var t=this;setInterval((function(){t.sessionExpired||(t.inActivityCounter+=6e4,t.inActivityCounter>=t.inActivityTimeout&&(t.sessionExpired=!0,t.endSession()))}),6e4)}},{key:"visibilityChange",value:function(){document[this.hidden]?this.hiddenTime=W():this.hiddenTime>0&&(this.totalHiddenTime+=W()-this.hiddenTime,this.hiddenTime=0)}},{key:"visibilityEvents",value:function(){F(window,"focus",this.visibilityChange.bind(this)),F(window,"blur",this.visibilityChange.bind(this)),F(window,"pageshow",this.visibilityChange.bind(this)),F(window,"pagehide",this.visibilityChange.bind(this)),"onfocusin"in document&&(F(window,"focusin",this.visibilityChange.bind(this)),F(window,"focusout",this.visibilityChange.bind(this))),this.hidden in document?F(document,"visibilitychange",this.visibilityChange.bind(this)):"mozHidden"in document?(this.hidden="mozHidden",F(document,"mozvisibilitychange",this.visibilityChange.bind(this))):"webkitHidden"in document?(this.hidden="webkitHidden",F(document,"webkitvisibilitychange",this.visibilityChange.bind(this))):"msHidden"in document&&(this.hidden="msHidden",F(document,"msvisibilitychange",this.visibilityChange.bind(this)))}}])&&Pt(e.prototype,r),n&&Pt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),u}(St);function Nt(t){return(Nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Rt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Rt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),c=new x(o||[]);return n(a,"_invoke",{value:O(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function d(){}function p(){}var y={};u(y,i,(function(){return this}));var v=Object.getPrototypeOf,b=v&&v(v(j([])));b&&b!==e&&r.call(b,i)&&(y=b);var m=p.prototype=h.prototype=Object.create(y);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var o;n(this,"_invoke",{value:function(n,i){function a(){return new e((function(o,a){!function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Nt(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(n,i,o,a)}))}return o=o?o.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function j(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return d.prototype=p,n(m,"constructor",{value:p,configurable:!0}),n(p,"constructor",{value:d,configurable:!0}),d.displayName=u(p,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=j,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(