function t(t,e,n,r,o){for(e=e.split?e.split("."):e,r=0;r1;return a||(l?o(t,e):r(t)),l?document.cookie=t+"="+encodeURIComponent(e)+(i?"; expires="+new Date(+new Date+1e3*i).toUTCString()+(u?"; path="+u:"")+(c?"; domain="+c:"")+(s?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+t+"=")[1]||"").split(";")[0])}}var p=d();function d(){if(typeof p!==n)return p;p=!0;try{typeof localStorage!==n&&typeof JSON!==n||(p=!1),localStorage.setItem(n,n),localStorage.removeItem(n)}catch(t){p=!1}return p}var h="undefined"!=typeof window;function g(t){return"function"==typeof t}function y(t){return"string"==typeof t}function v(t){return void 0===t}function m(t){return"boolean"==typeof t}function b(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function w(t){var e=t;try{if("true"===(e=JSON.parse(t)))return!0;if("false"===e)return!1;if(b(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch(n){}if(null!==e&&""!==e)return e}var x=d(),S=l();function E(t,e){if(t){var n=I(e),o=!P(n),i=O(n)?w(localStorage.getItem(t)):void 0;if(o&&!v(i))return i;var a=k(n)?w(u(t)):void 0;if(o&&a)return a;var c=r(t);return o?c:{localStorage:i,cookie:a,global:c}}}function I(t){return t?"string"==typeof t?t:t.storage:"any"}function O(t){return x&&_(t,"localStorage")}function k(t){return S&&_(t,"cookie")}function P(t){return"*"===t||"all"===t}function _(t,e){return"any"===t||t===e||P(t)}var j={setItem:function(t,e,n){if(t&&!v(e)){var i={},a=I(n),s=JSON.stringify(e),l=!P(a);return O(a)&&(i.localStorage={location:"localStorage",current:e,previous:w(localStorage.getItem(t))},localStorage.setItem(t,s),l)?i.localStorage:k(a)&&(i.cookie={location:"cookie",current:e,previous:w(u(t))},c(t,s),l)?i.cookie:(i.global={location:"global",current:e,previous:r(t)},o(t,e),l?i.global:i)}},getItem:E,removeItem:function(t,e){if(t){var n=I(e),r=E(t,"*"),o={};return!v(r.localStorage)&&O(n)&&(localStorage.removeItem(t),o.localStorage=r.localStorage),!v(r.cookie)&&k(n)&&(s(t),o.cookie=r.cookie),!v(r.global)&&_(n,"global")&&(i(t),o.global=r.global),o}}};function N(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return null}}var A="undefined"!=typeof document;function T(t){return function(t){var e,n={},r=/([^&=]+)=?([^&]*)/g;for(;e=r.exec(t);){var o=N(e[1]),i=N(e[2]);"[]"===o.substring(o.length-2)?(n[o=o.substring(0,o.length-2)]||(n[o]=[])).push(i):n[o]=""===i||i}for(var a in n){var u=a.split("[");u.length>1&&(L(n,u.map((function(t){return t.replace(/[?[\]\\ ]/g,"")})),n[a]),delete n[a])}return n}(function(t){if(t){var e=t.match(/\?(.*)/);return e&&e[1]?e[1].split("#")[0]:""}return A&&window.location.search.substring(1)}(t))}function L(t,e,n){for(var r=e.length-1,o=0;o>4}return t}var M=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;P(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(n){Function("r","regeneratorRuntime = r")(e)}}));function F(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(s){return void n(s)}u.done?e(c):Promise.resolve(c).then(r,o)}var G=function(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){F(i,r,o,a,u,"next",t)}function u(t){F(i,r,o,a,u,"throw",t)}a(void 0)}))}};var $=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};function B(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}var J=function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;if(i)throw i;for(var r=!1,o={},u=0;u0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n.type===ft.setItemEnd){if(n.key===it)return J(J({},e),{anonymousId:n.value});if(n.key===at)return J(J({},e),{userId:n.value})}switch(n.type){case ft.identify:return Object.assign({},e,{userId:n.userId,traits:J(J({},e.traits),n.traits)});case ft.reset:return[at,it,ut].forEach((function(e){t.removeItem(e)})),Object.assign({},e,{userId:null,anonymousId:null,traits:{}});default:return e}}}function mt(t){return{userId:t.getItem(at),anonymousId:t.getItem(it),traits:t.getItem(ut)}}var bt=function(t){return"__TEMP__"+t};function wt(t){return function(e,n,o){var i=n.getState("user")[e];if(i)return i;if(o&&b(o)&&o[e])return o[e];var a=mt(t)[e];return a||(r(bt(e))||null)}}function xt(t){var e=t.storage,n=e.setItem,r=e.removeItem,o=e.getItem;return function(t){return function(e){return function(a){var u=a.userId,c=a.traits,s=a.options;if(a.type===ft.reset&&([at,ut,it].forEach((function(t){r(t)})),[rt,ot,"traits"].forEach((function(t){i(bt(t))}))),a.type===ft.identify){o(it)||n(it,z());var l=o(at),f=o(ut)||{};l&&l!==u&&t.dispatch({type:ft.userIdChanged,old:{userId:l,traits:f},new:{userId:u,traits:c},options:s}),u&&n(at,u),c&&n(ut,J(J({},f),c))}return e(a)}}}}var St={};function Et(t,e){St[t]&&g(St[t])&&(St[t](e),delete St[t])}function It(t,e,n){return new Promise((function(r,o){return e()?r(t):n<1?o(J(J({},t),{},{queue:!0})):(i=10,new Promise((function(t){return setTimeout(t,i)}))).then((function(i){return It(t,e,n-10).then(r,o)}));var i}))}function Ot(t,e,n){var r=e(),o=t.getState(),i=o.plugins,a=o.context,u=o.queue,c=o.user;if(!a.offline&&u&&u.actions&&u.actions.length){var s=u.actions.reduce((function(t,e,n){return i[e.plugin].loaded?(t.process.push(e),t.processIndex.push(n)):(t.requeue.push(e),t.requeueIndex.push(n)),t}),{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(s.processIndex&&s.processIndex.length){s.processIndex.forEach((function(e){var o=u.actions[e],a=o.plugin,s=o.payload.type,l=r[a][s];if(l&&g(l)){var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return[rt,ot].reduce((function(n,r){return t.hasOwnProperty(r)&&e[r]&&e[r]!==t[r]&&(n[r]=e[r]),n}),t)}(o.payload,c);l({payload:f,config:i[a].config,instance:n});var p="".concat(s,":").concat(a);t.dispatch(J(J({},f),{},{type:p,_:{called:p,from:"queueDrain"}}))}}));var l=u.actions.filter((function(t,e){return!~s.processIndex.indexOf(e)}));u.actions=l}}}function kt(t,e,n){return setInterval((function(){return Ot(t,e,n)}),3e3)}var Pt=function(t){if(Array.isArray(t))return t};var _t=function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(c){o=!0,i=c}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n};var jt=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var Nt=function(t,e){return Pt(t)||_t(t,e)||jt()};function At(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Object.keys(t).filter((function(t){var r=n.plugins||{};return m(r[t])?r[t]:!1!==r.all&&(!e[t]||!1!==e[t].enabled)})).map((function(e){return t[e]}))}var Tt=/Start$/,Lt=/^bootstrap/,zt=/^ready/;function Mt(t,e,n,r,o){return Dt.apply(this,arguments)}function Dt(){return(Dt=G(V.mark((function t(e,n,r,o,i){var a,u,c,s,l,f,p,d,h,y,v;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=g(n)?n():n,u=e.type,c=u.replace(Tt,""),!e._||!e._.called){t.next=5;break}return t.abrupt("return",e);case 5:return s=r.getState(),l=At(a,s.plugins,e.options),u===ft.initializeStart&&e.fromEnable&&(l=Object.keys(s.plugins).filter((function(t){var n=s.plugins[t];return e.plugins.includes(t)&&!n.initialized})).map((function(t){return a[t]}))),f=l.map((function(t){return t.name})),p=Gt(u,l),t.next=12,Ut({action:e,data:{exact:p.before,namespaced:p.beforeNS},state:s,allPlugins:a,allMatches:p,instance:r,store:o,EVENTS:i});case 12:if(!Bt(d=t.sent,f.length)){t.next=15;break}return t.abrupt("return",d);case 15:if(u!==c){t.next=19;break}h=d,t.next=22;break;case 19:return t.next=21,Ut({action:J(J({},d),{},{type:c}),data:{exact:p.during,namespaced:p.duringNS},state:s,allPlugins:a,allMatches:p,instance:r,store:o,EVENTS:i});case 21:h=t.sent;case 22:if(!u.match(Tt)){t.next=28;break}return y="".concat(c,"End"),t.next=26,Ut({action:J(J({},h),{},{type:y}),data:{exact:p.after,namespaced:p.afterNS},state:s,allPlugins:a,allMatches:p,instance:r,store:o,EVENTS:i});case 26:(v=t.sent).meta&&v.meta.hasCallback&&Et(v.meta.rid,{payload:v});case 28:return t.abrupt("return",d);case 29:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ut(t){return Ct.apply(this,arguments)}function Ct(){return(Ct=G(V.mark((function t(e){var n,r,o,i,a,u,c,s,l,f,p,d,h,y,v,m,w,x;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.data,r=e.action,o=e.instance,i=e.state,a=e.allPlugins,u=e.allMatches,c=e.store,s=e.EVENTS,l=i.plugins,f=i.context,p=r.type,d=p.match(Tt),h=n.exact.map((function(t){return t.pluginName})),d&&(h=u.during.map((function(t){return t.pluginName}))),y=Wt(o,h),v=n.exact.reduce((function(t,e){var n=e.pluginName,r=e.methodName,o=!1;return r.match(/^initialize/)||r.match(/^reset/)||(o=!l[n].loaded),f.offline&&r.match(/^(page|track|identify)/)&&(o=!0),t["".concat(n)]=o,t}),{}),t.next=10,n.exact.reduce(function(){var t=G(V.mark((function t(e,i,u){var c,s,f;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c=i.pluginName,t.next=3,e;case 3:if(s=t.sent,!n.namespaced||!n.namespaced[c]){t.next=11;break}return t.next=7,n.namespaced[c].reduce(function(){var t=G(V.mark((function t(e,n,r){var i,u,s,f;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=function(t,e,n){return function(r,o){var i=n||e;return J(J({},t),{},{abort:{reason:r,plugins:o||[e],caller:p,from:i}})}},t.next=3,e;case 3:if(i=t.sent,n.method&&g(n.method)){t.next=6;break}return t.abrupt("return",i);case 6:return Yt(n.methodName,n.pluginName),t.next=9,n.method({payload:i,instance:o,abort:u(i,c,n.pluginName),config:Rt(n.pluginName,l,a),plugins:l});case 9:return s=t.sent,f=b(s)?s:{},t.abrupt("return",Promise.resolve(J(J({},i),f)));case 12:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),Promise.resolve(r));case 7:f=t.sent,s[c]=f,t.next=12;break;case 11:s[c]=r;case 12:return t.abrupt("return",Promise.resolve(s));case 13:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),Promise.resolve({}));case 10:return m=t.sent,t.next=13,n.exact.reduce(function(){var t=G(V.mark((function t(e,r,i){var u,s,f,h,g,w,x,S,E,I,O,k;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=n.exact.length===i+1,s=r.pluginName,f=a[s],t.next=5,e;case 5:if(h=t.sent,g=m[s]?m[s]:{},d&&(g=h),!$t(g,s)){t.next=11;break}return qt({data:g,method:p,instance:o,pluginName:s,store:c}),t.abrupt("return",Promise.resolve(h));case 11:if(!$t(h,s)){t.next=14;break}return u&&qt({data:h,method:p,instance:o,store:c}),t.abrupt("return",Promise.resolve(h));case 14:if(!v.hasOwnProperty(s)||!0!==v[s]){t.next=17;break}return c.dispatch({type:"queue",plugin:s,payload:g,_:{called:"queue",from:"queueMechanism"}}),t.abrupt("return",Promise.resolve(h));case 17:return w=y(m[s],a[s]),t.next=20,f[p]({abort:w.abort,payload:g,instance:o,config:Rt(s,l,a),plugins:l});case 20:return x=t.sent,S=b(x)?x:{},E=J(J({},h),S),$t(I=m[s],s)?qt({data:I,method:p,instance:o,pluginName:s,store:c}):(O="".concat(p,":").concat(s),(O.match(/:/g)||[]).length<2&&!p.match(Lt)&&!p.match(zt)&&(k=d?E:g,o.dispatch(J(J({},k),{},{type:O,_:{called:O,from:"submethod"}})))),t.abrupt("return",Promise.resolve(E));case 26:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}(),Promise.resolve(r));case 13:if(w=t.sent,p.match(Tt)||p.match(/^registerPlugin/)||p.match(zt)||p.match(Lt)||p.match(/^params/)||p.match(/^userIdChanged/)){t.next=21;break}if(s.plugins.includes(p),!w._||w._.originalAction!==p){t.next=18;break}return t.abrupt("return",w);case 18:x=J(J({},w),{_:{originalAction:w.type,called:w.type,from:"engineEnd"}}),Bt(w,n.exact.length)&&!p.match(/End$/)&&(x=J(J({},x),{type:w.type+"Aborted"})),c.dispatch(x);case 21:return t.abrupt("return",w);case 22:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function qt(t){var e=t.data,n=t.method;t.instance;var r=t.pluginName,o=n+"Aborted"+(r?":"+r:"");t.store.dispatch(J(J({},e),{},{type:o,_:{called:o,from:"abort"}}))}function Rt(t,e,n){var r=e[t]||n[t];return r&&r.config?r.config:{}}function Vt(t,e){return e.reduce((function(e,n){return n[t]?e.concat({methodName:t,pluginName:n.name,method:n[t]}):e}),[])}function Ft(t,e){var n=function(t){return t.replace(Tt,"")}(t),r=e?":".concat(e):"";return["".concat(t).concat(r),"".concat(n).concat(r),"".concat(n,"End").concat(r)]}function Gt(t,e,n){var r=Ft(t).map((function(t){return Vt(t,e)}));return e.reduce((function(n,r){var o=r.name,i=Ft(t,o).map((function(t){return Vt(t,e)})),a=Nt(i,3),u=a[0],c=a[1],s=a[2];return u.length&&(n.beforeNS[o]=u),c.length&&(n.duringNS[o]=c),s.length&&(n.afterNS[o]=s),n}),{before:r[0],beforeNS:{},during:r[1],duringNS:{},after:r[2],afterNS:{}})}function $t(t,e){var n=t.abort;return!!n&&(!0===n||(Xt(n,e)||n&&Xt(n.plugins,e)))}function Bt(t,e){var n=t.abort;if(!n)return!1;if(!0===n||y(n))return!0;var r=n.plugins;return Jt(n)&&n.length===e||Jt(r)&&r.length===e}function Jt(t){return Array.isArray(t)}function Xt(t,e){return!(!t||!Jt(t))&&t.includes(e)}function Wt(t,e){return function(n,r,o){var i=r.config,a=r.name,u="".concat(a,".").concat(n.type);o&&(u=o.event);var c=n.type.match(Tt)?function(t,e,n,r,o){return function(i,a){var u=r?r.name:t,c=a&&Jt(a)?a:n;if(r&&(!(c=a&&Jt(a)?a:[t]).includes(t)||1!==c.length))throw new Error("Method ".concat(e," can only abort ").concat(t," plugin. ").concat(JSON.stringify(c)," input valid"));return J(J({},o),{},{abort:{reason:i,plugins:c,caller:e,_:u}})}}(a,u,e,o,n):function(t,e){return function(){throw new Error(t.type+" action not cancellable. Remove abort in "+e)}}(n,u);return{payload:Zt(n),instance:t,config:i||{},abort:c}}}function Yt(t,e){var n=Ht(t);if(n&&n.name===e){var r=Ht(n.method),o=r?"or "+r.method:"";throw new Error([e+" plugin is calling method "+t,"Plugins cant call self","Use ".concat(n.method," ").concat(o," in ").concat(e," plugin insteadof ").concat(t)].join("\n"))}}function Ht(t){var e=t.match(/(.*):(.*)/);return!!e&&{method:e[1],name:e[2]}}function Zt(t){return Object.keys(t).reduce((function(e,n){return"type"===n||(b(t[n])?e[n]=Object.assign({},t[n]):e[n]=t[n]),e}),{})}function Kt(t,e,n){var r={};return function(o){return function(i){return function(){var a=G(V.mark((function a(u){var c,s,l,f,p,d,h,g,y,v,m,b;return V.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(c=u.type,s=u.abort,l=u.plugins,f=u,!s){a.next=4;break}return a.abrupt("return",i(u));case 4:if(c===ft.enablePlugin&&o.dispatch({type:ft.initializeStart,plugins:l,disabled:[],fromEnable:!0,meta:u.meta}),c===ft.disablePlugin&&setTimeout((function(){return Et(u.meta.rid,{payload:u})}),0),c===ft.initializeEnd&&(p=e(),d=Object.keys(p),h=d.filter((function(t){return l.includes(t)})).map((function(t){return p[t]})),g=[],y=[],v=u.disabled,m=h.map((function(t){var e=t.loaded,n=t.name;return It(t,e,1e4).then((function(e){return r[n]||(o.dispatch({type:ft.pluginReadyType(n),name:n,events:Object.keys(t).filter((function(t){return!lt.includes(t)}))}),r[n]=!0),g=g.concat(n),t})).catch((function(t){if(t instanceof Error)throw new Error(t);return y=y.concat(t.name),t}))})),Promise.all(m).then((function(t){var e={plugins:g,failed:y,disabled:v};setTimeout((function(){d.length===m.length+v.length&&o.dispatch(J(J({},{type:ft.ready}),e))}),0)}))),c===ft.bootstrap){a.next=13;break}return/^ready:([^:]*)$/.test(c)&&setTimeout((function(){return Ot(o,e,t)}),0),a.next=11,Mt(u,e,t,o,n);case 11:return b=a.sent,a.abrupt("return",i(b));case 13:return a.abrupt("return",i(f));case 14:case"end":return a.stop()}}),a)})));return function(t){return a.apply(this,arguments)}}()}}}function Qt(t){return function(e){return function(e){return function(n){var r=n.type,o=n.key,i=n.value,a=n.options;if(r===ft.setItem||r===ft.removeItem){if(n.abort)return e(n);r===ft.setItem?t.setItem(o,i,a):t.removeItem(o,a)}return e(n)}}}}var te=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},ee=function t(){var e=this;te(this,t),$(this,"before",[]),$(this,"after",[]),$(this,"addMiddleware",(function(t,n){e[n]=e[n].concat(t)})),$(this,"removeMiddleware",(function(t,n){var r=e[n].findIndex((function(e){return e===t}));-1!==r&&(e[n]=[].concat(C(e[n].slice(0,r)),C(e[n].slice(r+1))))})),$(this,"dynamicMiddlewares",(function(t){return function(n){return function(r){return function(o){var i={getState:n.getState,dispatch:function(t){return n.dispatch(t)}},a=e[t].map((function(t){return t(i)}));return et.apply(void 0,C(a))(r)(o)}}}}))};function ne(t){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r={};if("initialize:aborted"===n.type)return e;if(/^registerPlugin:([^:]*)$/.test(n.type)){var o=re(n.type,"registerPlugin"),i=t()[o];if(!i||!o)return e;var a=n.enabled;return r[o]={enabled:a,initialized:!!a&&Boolean(!i.initialize),loaded:!!a&&Boolean(i.loaded()),config:i.config||{}},J(J({},e),r)}if(/^initialize:([^:]*)$/.test(n.type)){var u=re(n.type,ft.initialize),c=t()[u];return c&&u?(r[u]=J(J({},e[u]),{initialized:!0,loaded:Boolean(c.loaded())}),J(J({},e),r)):e}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=J(J({},e[n.name]),{loaded:!0}),J(J({},e),r);switch(n.type){case ft.disablePlugin:return J(J({},e),oe(n.plugins,!1,e));case ft.enablePlugin:return J(J({},e),oe(n.plugins,!0,e));default:return e}}}function re(t,e){return t.substring(e.length+1,t.length)}function oe(t,e,n){return t.reduce((function(t,r){return t[r]=J(J({},n[r]),{enabled:e}),t}),n)}function ie(t){try{return JSON.parse(JSON.stringify(t))}catch(e){}return t}var ae={last:{},history:[]};function ue(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ae,e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.event,o=e.properties,i=e.options,a=e.meta;switch(n){case ft.track:var u=ie(J(J({event:r,properties:o},Object.keys(i).length&&{options:i}),{},{meta:a}));return J(J({},t),{last:u,history:t.history.concat(u)});default:return t}}var ce={actions:[]};function se(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ce,e=arguments.length>1?arguments[1]:void 0,n=e.type,r=e.payload;switch(n){case"queue":var o;return o=r&&r.type&&r.type===ft.identify?[e].concat(t.actions):t.actions.concat(e),J(J({},t),{},{actions:o});case"dequeue":return[];default:return t}}var le=/#.*$/;function fe(t){var e=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);return"/"+(e&&e[3]?e[3].split("?")[0].replace(le,""):"")}function pe(t){var e=function(){if(h)for(var t,e=document.getElementsByTagName("link"),n=0;t=e[n];n++)if("canonical"===t.getAttribute("rel"))return t.getAttribute("href")}();return e?e.match(/\?/)?e:e+t:window.location.href.replace(le,"")}var de,he,ge,ye,ve=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!h)return t;var e=document,n=e.title,r=e.referrer,o=window,i=o.location,a=o.innerWidth,u=o.innerHeight,c=i.hash,s=i.search,l=pe(s),f={title:n,url:l,path:fe(l),hash:c,search:s,width:a,height:u};return r&&""!==r&&(f.referrer=r),J(J({},f),t)},me={last:{},history:[]};function be(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:me,e=arguments.length>1?arguments[1]:void 0,n=e.properties,r=e.options,o=e.meta;switch(e.type){case ft.page:var i=ie(J({properties:n,meta:o},Object.keys(r).length&&{options:r}));return J(J({},t),{last:i,history:t.history.concat(i)});default:return t}}de=function(){if(!h)return!1;var t=navigator.appVersion;return~t.indexOf("Win")?"Windows":~t.indexOf("Mac")?"MacOS":~t.indexOf("X11")?"UNIX":~t.indexOf("Linux")?"Linux":"Unknown OS"}(),he=h?document.referrer:null,ge=function(){if(A){var t=navigator,e=t.language,n=t.languages;return t.userLanguage||(n&&n.length?n[0]:e)}}(),ye=function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){}}();var we={initialized:!1,sessionId:z(),app:null,version:null,debug:!1,offline:!!h&&!navigator.onLine,os:{name:de},userAgent:h?navigator.userAgent:"node",library:{name:"analytics",version:"0.10.9"},timezone:ye,locale:ge,campaign:{},referrer:he};function xe(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:we,e=arguments.length>1?arguments[1]:void 0,n=t.initialized,r=e.type,o=e.campaign;switch(r){case ft.campaign:return J(J({},t),{campaign:o});case ft.offline:return J(J({},t),{offline:!0});case ft.online:return J(J({},t),{offline:!1});default:return n?t:J(J(J({},we),t),{initialized:!0})}}var Se=["plugins","reducers","storage"];function Ee(t){return Object.keys(t).reduce((function(e,n){return Se.includes(n)||(e[n]=t[n]),e}),{})}function Ie(t,e,n){if(h){var r=window[(n?"add":"remove")+"EventListener"];t.split(" ").forEach((function(t){r(t,e)}))}}function Oe(t){var e=Ie.bind(null,"online offline",(function(e){return Promise.resolve(!navigator.onLine).then(t)}));return e(!0),function(t){return e(!1)}}function ke(){var t="__analytics__";return o(t,[]),function(t){return function(n,r,o){var i=t(n,r,o),a=i.dispatch;return Object.assign(i,{dispatch:function(t){var n=t.action||t;return e.__analytics__.push(n),a(t)}})}}}function Pe(t){return function(){return et(et.apply(null,arguments),ke())}}function _e(t){return t?(e=t,Array.isArray(e)?t:[t]):[];var e}function je(t){for(var e,n=t||Array.prototype.slice.call(arguments),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=z();return e&&(St[r]=Ae(e,je(n))),J(J({},t),{},{rid:r,ts:Ne()},e?{hasCallback:!0}:{})}function Le(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.reducers||{},a=e.initialUser||{},u=(e.plugins||[]).reduce((function(t,e){if(g(e))return t.middlewares=t.middlewares.concat(e),t;if(e.NAMESPACE&&(e.name=e.NAMESPACE),!e.name)throw new Error("https://lytics.dev/errors/1");var n=e.EVENTS?Object.keys(e.EVENTS).map((function(t){return e.EVENTS[t]})):[],r=!(!1===e.enabled),o=!(e.config&&!1===e.config.enabled);t.pluginEnabled[e.name]=r&&o,delete e.enabled,e.methods&&(t.methods[e.name]=Object.keys(e.methods).reduce((function(t,n){return t[n]=at(e.methods[n]),t}),{}),delete e.methods);var i=Object.keys(e).concat(n),a=new Set(t.events.concat(i));if(t.events=Array.from(a),t.pluginsArray=t.pluginsArray.concat(e),t.plugins[e.name])throw new Error(e.name+"AlreadyLoaded");return t.plugins[e.name]=e,t.plugins[e.name].loaded||(t.plugins[e.name].loaded=function(){return!0}),t}),{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),c=e.storage?e.storage:{getItem:r,setItem:o,removeItem:i},s=wt(c),l=u.plugins,f=u.events.filter((function(t){return!lt.includes(t)})).sort(),p=new Set(f.concat(st).filter((function(t){return!lt.includes(t)}))),d=Array.from(p).sort(),v=function(){return l},m=new ee,w=m.addMiddleware,x=m.removeMiddleware,S=m.dynamicMiddlewares,E=function(){throw new Error("Abort disabled inListener")},I=T(),O=mt(c),k=J(J(J(J({},O),a),I.an_uid?{userId:I.an_uid}:{}),I.an_aid?{anonymousId:I.an_aid}:{});k.anonymousId||(k.anonymousId=z());var P,_,j,N=J({enable:function(t,e){return new Promise((function(n){W.dispatch({type:ft.enablePlugin,plugins:_e(t),_:{originalAction:ft.enablePlugin}},n,[e])}))},disable:function(t,e){return new Promise((function(n){W.dispatch({type:ft.disablePlugin,plugins:_e(t),_:{originalAction:ft.disablePlugin}},n,[e])}))}},u.methods),A={identify:(j=G(V.mark((function t(e,n,r,i){var a,u,c,l,f;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=y(e)?e:null,u=b(e)?e:n,c=r||{},l=A.user(),o(bt(rt),a),f=a||u.userId||s(rt,A,u),t.abrupt("return",new Promise((function(t){W.dispatch(J({type:ft.identifyStart,userId:f,traits:u||{},options:c,anonymousId:l.anonymousId},l.id&&l.id!==a&&{previousId:l.id}),t,[n,r,i])})));case 7:case"end":return t.stop()}}),t)}))),function(t,e,n,r){return j.apply(this,arguments)}),track:(_=G(V.mark((function t(e,n,r,o){var i,a,u;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((i=b(e)?e.event:e)&&y(i)){t.next=3;break}throw new Error("EventMissing");case 3:return a=b(e)?e:n||{},u=b(r)?r:{},t.abrupt("return",new Promise((function(t){W.dispatch({type:ft.trackStart,event:i,properties:a,options:u,userId:s(rt,A,n),anonymousId:s(ot,A,n)},t,[n,r,o])})));case 6:case"end":return t.stop()}}),t)}))),function(t,e,n,r){return _.apply(this,arguments)}),page:(P=G(V.mark((function t(e,n,r){var o,i;return V.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=b(e)?e:{},i=b(n)?n:{},t.abrupt("return",new Promise((function(t){W.dispatch({type:ft.pageStart,properties:ve(o),options:i,userId:s(rt,A,o),anonymousId:s(ot,A,o)},t,[e,n,r])})));case 3:case"end":return t.stop()}}),t)}))),function(t,e,n){return P.apply(this,arguments)}),user:function(e){if(e===rt||"id"===e)return s(rt,A);if(e===ot||"anonId"===e)return s(ot,A);var n=A.getState("user");return e?t(n,e):n},reset:function(t){return new Promise((function(e){W.dispatch({type:ft.resetStart},e,t)}))},ready:function(t){return A.on(ft.ready,t)},on:function(t,e){if(!t||!g(e))return!1;if(t===ft.bootstrap)throw new Error(".on disabled for "+t);var n=/Start$|Start:/;if("*"===t){var r=function(t){return function(t){return function(r){return r.type.match(n)&&e({payload:r,instance:A,plugins:l}),t(r)}}},o=function(t){return function(t){return function(r){return r.type.match(n)||e({payload:r,instance:A,plugins:l}),t(r)}}};return w(r,ze),w(o,Me),function(){x(r,ze),x(o,Me)}}var i=t.match(n)?ze:Me,a=function(n){return function(n){return function(r){return r.type===t&&e({payload:r,instance:A,plugins:l,abort:E}),n(r)}}};return w(a,i),function(){return x(a,i)}},once:function(t,e){if(!t||!g(e))return!1;if(t===ft.bootstrap)throw new Error(".once disabled for "+t);var n=A.on(t,(function(t){var r=t.payload;e({payload:r,instance:A,plugins:l,abort:E}),n()}));return n},getState:function(e){var n=W.getState();return e?t(n,e):Object.assign({},n)},dispatch:function(t){var e=y(t)?{type:t}:t;if(pt(e.type))throw new Error("reserved action "+e.type);var n=t._||{},r=J(J({},e),{},{_:J({originalAction:e.type},n)});W.dispatch(r)},enablePlugin:N.enable,disablePlugin:N.disable,plugins:N,storage:{getItem:c.getItem,setItem:function(t,e,n){W.dispatch({type:ft.setItemStart,key:t,value:e,options:n})},removeItem:function(t,e){W.dispatch({type:ft.removeItemStart,key:t,options:e})}},setAnonymousId:function(t,e){A.storage.setItem(it,t,e)},events:{all:d,core:st,plugins:f}},L=function(t){return function(t){return function(e){return e.meta||(e.meta=Te()),t(e)}}},M=u.middlewares.concat([L,S(ze),Kt(A,v,{all:d,plugins:f}),Qt(c),yt(A),xt(A),S(Me)]),D={context:xe,user:vt(c),page:be,track:ue,plugins:ne(v),queue:se},U=et,q=et;if(h&&e.debug){var F=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;F&&(U=F({trace:!0,traceLimit:25})),q=function(){return 0===arguments.length?ke():b(R(arguments[0]))?Pe():Pe().apply(null,arguments)}}var $=Ee(e),B=u.pluginsArray.reduce((function(t,e){var n=e.name,r=e.config,o=e.loaded,i=u.pluginEnabled[n];return t[n]={enabled:i,initialized:!!i&&Boolean(!e.initialize),loaded:Boolean(o()),config:r||{}},t}),{}),X={context:$,user:k,plugins:B},W=K(tt(J(J({},D),n)),X,q(U(nt.apply(void 0,C(M)))));function Y(t){return function(e,n,r){var o=Te(e.meta,n,_e(r)),i=J(J({},e),{meta:o});return t.apply(null,[i])}}W.dispatch=Y(W.dispatch);var H=Object.keys(l);W.dispatch({type:ft.bootstrap,plugins:H,config:$,params:I,user:k,initialUser:a,persistedUser:O});var Z=H.filter((function(t){return u.pluginEnabled[t]})),Q=H.filter((function(t){return!u.pluginEnabled[t]}));function at(t){return function(){for(var e=Array.prototype.slice.call(arguments),n=new Array(t.length),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e={storage:j};return Le(Ce(Ce({},e),t))}export default qe;export{qe as Analytics,ct as CONSTANTS,ft as EVENTS,qe as init};