@suprsend/web-sdk 1.3.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn_bundle.js +1 -1
- package/dist/cdn_bundle.js.LICENSE.txt +10 -0
- package/dist/cjs_bundle.js +1 -1
- package/dist/cjs_bundle.js.LICENSE.txt +10 -0
- package/package.json +2 -1
- package/src/encryption.js +2 -231
- package/src/index.d.ts +8 -2
- package/src/preferences.js +30 -6
package/dist/cjs_bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see cjs_bundle.js.LICENSE.txt */
|
|
2
|
-
!function(){"use strict";var t={147:function(t){t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.3.3","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return et},PreferenceOptions:function(){return tt},default:function(){return zt},initialisedAt:function(){return Ct}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};function p(t){return p="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},p(t)}function d(){d=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function v(){}var y={};c(y,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(y=g);var m=v.prototype=f.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==p(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function k(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 O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=v,c(m,"constructor",v),c(v,"constructor",h),h.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,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(O),!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,l):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),l},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),O(r),l}},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;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function v(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 y(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){v(i,n,o,a,c,"next",t)}function c(t){v(i,n,o,a,c,"throw",t)}a(void 0)}))}}function _(t){return function(t){if(Array.isArray(t))return g(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){if("string"==typeof t)return g(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)?g(t,e):void 0}}(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 g(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 m=function(t){function e(t,e){return t<<e|t>>>32-e}function r(t,e){var r,n,o,i,a;return o=2147483648&t,i=2147483648&e,a=(1073741823&t)+(1073741823&e),(r=1073741824&t)&(n=1073741824&e)?2147483648^a^o^i:r|n?1073741824&a?3221225472^a^o^i:1073741824^a^o^i:a^o^i}function n(t,n,o,i,a,c,u){return t=r(t,r(r(function(t,e,r){return t&e|~t&r}(n,o,i),a),u)),r(e(t,c),n)}function o(t,n,o,i,a,c,u){return t=r(t,r(r(function(t,e,r){return t&r|e&~r}(n,o,i),a),u)),r(e(t,c),n)}function i(t,n,o,i,a,c,u){return t=r(t,r(r(function(t,e,r){return t^e^r}(n,o,i),a),u)),r(e(t,c),n)}function a(t,n,o,i,a,c,u){return t=r(t,r(r(function(t,e,r){return e^(t|~r)}(n,o,i),a),u)),r(e(t,c),n)}function c(t){var e,r="",n="";for(e=0;e<=3;e++)r+=(n="0"+(t>>>8*e&255).toString(16)).substr(n.length-2,2);return r}var u,s,l,f,h,p,d,v,y,_=Array();for(t=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e+=String.fromCharCode(n):n>127&&n<2048?(e+=String.fromCharCode(n>>6|192),e+=String.fromCharCode(63&n|128)):(e+=String.fromCharCode(n>>12|224),e+=String.fromCharCode(n>>6&63|128),e+=String.fromCharCode(63&n|128))}return e}(t),_=function(t){for(var e,r=t.length,n=r+8,o=16*((n-n%64)/64+1),i=Array(o-1),a=0,c=0;c<r;)a=c%4*8,i[e=(c-c%4)/4]=i[e]|t.charCodeAt(c)<<a,c++;return a=c%4*8,i[e=(c-c%4)/4]=i[e]|128<<a,i[o-2]=r<<3,i[o-1]=r>>>29,i}(t),p=1732584193,d=4023233417,v=2562383102,y=271733878,u=0;u<_.length;u+=16)s=p,l=d,f=v,h=y,p=n(p,d,v,y,_[u+0],7,3614090360),y=n(y,p,d,v,_[u+1],12,3905402710),v=n(v,y,p,d,_[u+2],17,606105819),d=n(d,v,y,p,_[u+3],22,3250441966),p=n(p,d,v,y,_[u+4],7,4118548399),y=n(y,p,d,v,_[u+5],12,1200080426),v=n(v,y,p,d,_[u+6],17,2821735955),d=n(d,v,y,p,_[u+7],22,4249261313),p=n(p,d,v,y,_[u+8],7,1770035416),y=n(y,p,d,v,_[u+9],12,2336552879),v=n(v,y,p,d,_[u+10],17,4294925233),d=n(d,v,y,p,_[u+11],22,2304563134),p=n(p,d,v,y,_[u+12],7,1804603682),y=n(y,p,d,v,_[u+13],12,4254626195),v=n(v,y,p,d,_[u+14],17,2792965006),p=o(p,d=n(d,v,y,p,_[u+15],22,1236535329),v,y,_[u+1],5,4129170786),y=o(y,p,d,v,_[u+6],9,3225465664),v=o(v,y,p,d,_[u+11],14,643717713),d=o(d,v,y,p,_[u+0],20,3921069994),p=o(p,d,v,y,_[u+5],5,3593408605),y=o(y,p,d,v,_[u+10],9,38016083),v=o(v,y,p,d,_[u+15],14,3634488961),d=o(d,v,y,p,_[u+4],20,3889429448),p=o(p,d,v,y,_[u+9],5,568446438),y=o(y,p,d,v,_[u+14],9,3275163606),v=o(v,y,p,d,_[u+3],14,4107603335),d=o(d,v,y,p,_[u+8],20,1163531501),p=o(p,d,v,y,_[u+13],5,2850285829),y=o(y,p,d,v,_[u+2],9,4243563512),v=o(v,y,p,d,_[u+7],14,1735328473),p=i(p,d=o(d,v,y,p,_[u+12],20,2368359562),v,y,_[u+5],4,4294588738),y=i(y,p,d,v,_[u+8],11,2272392833),v=i(v,y,p,d,_[u+11],16,1839030562),d=i(d,v,y,p,_[u+14],23,4259657740),p=i(p,d,v,y,_[u+1],4,2763975236),y=i(y,p,d,v,_[u+4],11,1272893353),v=i(v,y,p,d,_[u+7],16,4139469664),d=i(d,v,y,p,_[u+10],23,3200236656),p=i(p,d,v,y,_[u+13],4,681279174),y=i(y,p,d,v,_[u+0],11,3936430074),v=i(v,y,p,d,_[u+3],16,3572445317),d=i(d,v,y,p,_[u+6],23,76029189),p=i(p,d,v,y,_[u+9],4,3654602809),y=i(y,p,d,v,_[u+12],11,3873151461),v=i(v,y,p,d,_[u+15],16,530742520),p=a(p,d=i(d,v,y,p,_[u+2],23,3299628645),v,y,_[u+0],6,4096336452),y=a(y,p,d,v,_[u+7],10,1126891415),v=a(v,y,p,d,_[u+14],15,2878612391),d=a(d,v,y,p,_[u+5],21,4237533241),p=a(p,d,v,y,_[u+12],6,1700485571),y=a(y,p,d,v,_[u+3],10,2399980690),v=a(v,y,p,d,_[u+10],15,4293915773),d=a(d,v,y,p,_[u+1],21,2240044497),p=a(p,d,v,y,_[u+8],6,1873313359),y=a(y,p,d,v,_[u+15],10,4264355552),v=a(v,y,p,d,_[u+6],15,2734768916),d=a(d,v,y,p,_[u+13],21,1309151649),p=a(p,d,v,y,_[u+4],6,4149444226),y=a(y,p,d,v,_[u+11],10,3174756917),v=a(v,y,p,d,_[u+2],15,718787259),d=a(d,v,y,p,_[u+9],21,3951481745),p=r(p,s),d=r(d,l),v=r(v,f),y=r(y,h);return(c(p)+c(d)+c(v)+c(y)).toLowerCase()},b=function(t){return new Uint8Array(_(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function w(t,e,r){return x.apply(this,arguments)}function x(){return x=y(d().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,y=arguments;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=y.length>3&&void 0!==y[3]?y[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=m(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=b(a),f=b(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return p=t.sent,t.next=15,crypto.subtle.sign("HMAC",p,f);case 15:return v=t.sent,_(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,_(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),x.apply(this,arguments)}function k(t){return k="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},k(t)}function O(){O=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==k(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}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 E(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){L(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}function j(t){return function(t){if(Array.isArray(t))return $(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||C(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 L(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(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 T(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){P(i,n,o,a,c,"next",t)}function c(t){P(i,n,o,a,c,"throw",t)}a(void 0)}))}}function A(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=C(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function C(t,e){if(t){if("string"==typeof t)return $(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)?$(t,e):void 0}}function $(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 N(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(N())return localStorage.getItem(t)}function I(t,e){N()&&localStorage.setItem(t,e)}function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function F(){var t=navigator.userAgent;for(var e in u){var r,n=A(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function D(t,e){return U.apply(this,arguments)}function U(){return U=T(O().mark((function t(e,r){var n,o,i,a,c,u=arguments;return O().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,w(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),U.apply(this,arguments)}function R(){var t=M(e,[]);if(t.length){var r=t.slice(0,h.batch_size);D(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=M(e,[]);r.splice(0,h.batch_size),I(e,JSON.stringify(r)),R()})).catch((function(){q(12e4)}))}else q()}function q(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){R()}),t)}var z=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function W(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const Y={uuid:function(){var t=(new Date).getTime();return"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)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:N,get_local_storage_item:G,set_local_storage_item:I,remove_local_storage_item:function(t){N()&&localStorage.removeItem(t)},get_parsed_local_store_data:M,browser:F,browser_version:function(){var t=navigator.userAgent,e=F(),r=s[e];if(!r||!e)return"";var n,o=A(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:q,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&z(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&z(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=L({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if(N()){var r=M(e,[]);null==r||r.push(t),I(e,JSON.stringify(r))}else D(o,t)},has_special_char:z,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:R,is_internal_event:function(t){return Object.values(c).includes(t)},api:D,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=W(t,e,E(E({},r),{},{leading:!0}))),n[c].apply(n,j(u))}}};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},J(t)}function B(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return K(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)?K(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function K(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 V(){V=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==J(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function H(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 Q(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){H(i,n,o,a,c,"next",t)}function c(t){H(i,n,o,a,c,"throw",t)}a(void 0)}))}}function X(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,n.key,n)}}function Z(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var tt={OPT_IN:"opt_in",OPT_OUT:"opt_out"},et={ALL:"all",REQUIRED:"required"},rt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Z(this,"_update_category_preferences",Q(V().mark((function t(){var e,r,o,i,a,c,u=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),Z(this,"_update_channel_preferences",Q(V().mark((function t(){var e,r,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=Y.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=Y.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=Q(V().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,w("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=Q(V().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,w(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=Q(V().mark((function t(){var e,r,n,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=Q(V().mark((function t(){var e,r,n,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=Q(V().mark((function t(){var e,r,n,o,i,a=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=Q(V().mark((function t(){var e;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![tt.OPT_IN,tt.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=B(this.data.sections);try{for(a.s();!(o=a.n()).done;){var c,u=o.value,s=!1,l=B(u.subcategories);try{for(l.s();!(c=l.n()).done;){var f=c.value;if(f.category===e){if(t=f,!f.is_editable)return{error:!0,message:"Category preference is not editable"};if(f.preference!==r){f.preference=r,i=!0,s=!0;break}}}}catch(t){l.e(t)}finally{l.f()}if(s)break}}catch(t){a.e(t)}finally{a.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var h=[];t.channels.forEach((function(t){t.preference===tt.OPT_OUT&&h.push(t.channel)}));var p={preference:t.preference,opt_out_channels:h};return this._debounced_update_category_preferences(e,e,p,t,{tenant_id:null==n?void 0:n.tenant_id}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![tt.OPT_IN,tt.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=B(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=B(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=B(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===tt.OPT_IN&&(p.preference=tt.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===tt.OPT_OUT&&_.push(t.channel)}));var g={preference:t.preference,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,g,t,{tenant_id:null==i?void 0:i.tenant_id}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![et.ALL,et.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===et.REQUIRED,a=B(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&X(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const nt=rt;function ot(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 it(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ot(Object(r),!0).forEach((function(e){ct(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ot(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function at(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,n.key,n)}}function ct(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ut=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ct(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new nt(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){Y.batch_or_call(it({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:Y.uuid(),$time:Y.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;Y.api(o,it({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:Y.uuid(),$time:Y.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!Y.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=Y.format_props({key:t,value:e});Y.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=Y.format_props({key:t,value:e});Y.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=Y.format_props({key:t,value:e}),n=this._convert_to_number(r);Y.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=Y.format_props({key:t,value:e,allow_special_tags:r});Y.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=Y.format_props({key:t,value:e,allow_special_tags:n});Y.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?Y.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){Y.has_special_char(String(t))||e.push(String(t))}))),Y.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&at(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const st=ut;function lt(t){return lt="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},lt(t)}function ft(){ft=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==lt(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ht(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 pt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ht(i,n,o,a,c,"next",t)}function c(t){ht(i,n,o,a,c,"throw",t)}a(void 0)}))}}function dt(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,n.key,n)}}function vt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var yt,_t=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),vt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),vt(this,"_ask_notification_permission",pt(ft().mark((function t(){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),vt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),vt(this,"_get_subscription_without_wait",pt(ft().mark((function t(){var e;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=pt(ft().mark((function t(e){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),vt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=pt(ft().mark((function t(e){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),vt(this,"_subscribe_push",function(){var t=pt(ft().mark((function t(e){var n,o;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=Y.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),vt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),vt(this,"is_subscribed",pt(ft().mark((function t(){var e;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new st(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-Ct;e>=h.sw_delay?this._register_sw():(clearTimeout(yt),yt=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&dt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const gt=_t;function mt(t){return mt="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},mt(t)}function bt(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,n.key,n)}}function wt(t,e,r){return e&&bt(t.prototype,e),r&&bt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function xt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kt(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&&Pt(t,e)}function Ot(t){var e=Lt();return function(){var r,n=Tt(t);if(e){var o=Tt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return St(this,r)}}function St(t,e){if(e&&("object"===mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Et(t){var e="function"==typeof Map?new Map:void 0;return Et=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return jt(t,arguments,Tt(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Pt(n,t)},Et(t)}function jt(t,e,r){return jt=Lt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Pt(o,r.prototype),o},jt.apply(null,arguments)}function Lt(){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}}function Pt(t,e){return Pt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Pt(t,e)}function Tt(t){return Tt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Tt(t)}var At,Ct,$t=function(t){kt(r,t);var e=Ot(r);function r(t){var n;return xt(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return wt(r)}(function(t){kt(r,t);var e=Ot(r);function r(t){var n;return xt(this,r),(n=e.call(this,t)).name="SuprsendError",n}return wt(r)}(Et(Error)));function Nt(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Gt(t){return Gt="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},Gt(t)}function It(){It=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new k(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Gt(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,k.prototype={constructor:k,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Mt(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 Ft(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 Dt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ft(Object(r),!0).forEach((function(e){Ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ft(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rt(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,n.key,n)}}var qt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=Y.get_cookie(t);At||(At={},this._set_custom_config(o)),i||(i=Y.uuid(),Y.set_cookie(t,i)),At.distinct_id=i,this.emitter=Nt(),this.user=new st(At,this.emitter),this.web_push=new gt(At),this.web_push.update_subscription(),e._set_env_properties(),Ct||(Y.bulk_call_api(),this.track(c.app_launched)),Ct=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new $t("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Y.get_parsed_local_store_data(i),r=Dt(Dt({},e),t),n={};for(var o in r)Y.has_special_char(o)||(n[o]=r[o]);Y.set_local_storage_item(i,JSON.stringify(n)),At.env_properties=Dt(Dt({},At.env_properties),n)}},{key:"identify",value:function(e){At._user_identified||(Y.batch_or_call({env:h.env_key,event:"$identify",$insert_id:Y.uuid(),$time:Y.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:At.distinct_id}}),Y.set_cookie(t,e),At.distinct_id=e,At._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(Y.is_internal_event(t)||!Y.has_special_char(t)){var r=Y.get_parsed_local_store_data(i),n=Y.format_props({key:e}),o=Dt(Dt(Dt(Dt({},n),At.env_properties),r),{},{$current_url:window.location.href});Y.batch_or_call({event:String(t),distinct_id:At.distinct_id,env:h.env_key,properties:o,$insert_id:Y.uuid(),$time:Y.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=It().mark((function r(){var n,o,a,u=arguments;return It().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=Y.uuid(),Y.set_cookie(t,a),At={distinct_id:a,_user_identified:!1},Y.remove_local_storage_item(i),this.user=new st(At,this.emitter),this.web_push=new gt(At),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Mt(o,r,n,i,a,"next",t)}function a(t){Mt(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=Y.get_local_storage_item(a);t||(t=Y.uuid(),Y.set_local_storage_item(a,t)),At.env_properties={$os:Y.os(),$browser:Y.browser(),$browser_version:Y.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&Rt(r.prototype,n),o&&Rt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const zt=new qt}();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})}();
|
|
2
|
+
!function(){var t={495:function(t,e,r){var n;!function(){"use strict";var e="input is invalid type",o="object"==typeof window,i=o?window:{};i.JS_MD5_NO_WINDOW&&(o=!1);var a=!o&&"object"==typeof self,c=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;c?i=r.g:a&&(i=self);var u,s=!i.JS_MD5_NO_COMMON_JS&&t.exports,l=r.amdO,f=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,h="0123456789abcdef".split(""),p=[128,32768,8388608,-2147483648],d=[0,8,16,24],v=["hex","array","digest","buffer","arrayBuffer","base64"],y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),_=[];if(f){var g=new ArrayBuffer(68);u=new Uint8Array(g),_=new Uint32Array(g)}var m=Array.isArray;!i.JS_MD5_NO_NODE_JS&&m||(m=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var b=ArrayBuffer.isView;!f||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&b||(b=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var w=function(t){var r=typeof t;if("string"===r)return[t,!0];if("object"!==r||null===t)throw new Error(e);if(f&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!m(t)&&!b(t))throw new Error(e);return[t,!1]},x=function(t){return function(e){return new k(!0).update(e)[t]()}},O=function(t){return function(e,r){return new S(e,!0).update(r)[t]()}};function k(t){if(t)_[0]=_[16]=_[1]=_[2]=_[3]=_[4]=_[5]=_[6]=_[7]=_[8]=_[9]=_[10]=_[11]=_[12]=_[13]=_[14]=_[15]=0,this.blocks=_,this.buffer8=u;else if(f){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function S(t,e){var r,n=w(t);if(t=n[0],n[1]){var o,i=[],a=t.length,c=0;for(r=0;r<a;++r)(o=t.charCodeAt(r))<128?i[c++]=o:o<2048?(i[c++]=192|o>>>6,i[c++]=128|63&o):o<55296||o>=57344?(i[c++]=224|o>>>12,i[c++]=128|o>>>6&63,i[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++r)),i[c++]=240|o>>>18,i[c++]=128|o>>>12&63,i[c++]=128|o>>>6&63,i[c++]=128|63&o);t=i}t.length>64&&(t=new k(!0).update(t).array());var u=[],s=[];for(r=0;r<64;++r){var l=t[r]||0;u[r]=92^l,s[r]=54^l}k.call(this,e),this.update(s),this.oKeyPad=u,this.inner=!0,this.sharedMemory=e}k.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var e=w(t);t=e[0];for(var r,n,o=e[1],i=0,a=t.length,c=this.blocks,u=this.buffer8;i<a;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),o)if(f)for(n=this.start;i<a&&n<64;++i)(r=t.charCodeAt(i))<128?u[n++]=r:r<2048?(u[n++]=192|r>>>6,u[n++]=128|63&r):r<55296||r>=57344?(u[n++]=224|r>>>12,u[n++]=128|r>>>6&63,u[n++]=128|63&r):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++i)),u[n++]=240|r>>>18,u[n++]=128|r>>>12&63,u[n++]=128|r>>>6&63,u[n++]=128|63&r);else for(n=this.start;i<a&&n<64;++i)(r=t.charCodeAt(i))<128?c[n>>>2]|=r<<d[3&n++]:r<2048?(c[n>>>2]|=(192|r>>>6)<<d[3&n++],c[n>>>2]|=(128|63&r)<<d[3&n++]):r<55296||r>=57344?(c[n>>>2]|=(224|r>>>12)<<d[3&n++],c[n>>>2]|=(128|r>>>6&63)<<d[3&n++],c[n>>>2]|=(128|63&r)<<d[3&n++]):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++i)),c[n>>>2]|=(240|r>>>18)<<d[3&n++],c[n>>>2]|=(128|r>>>12&63)<<d[3&n++],c[n>>>2]|=(128|r>>>6&63)<<d[3&n++],c[n>>>2]|=(128|63&r)<<d[3&n++]);else if(f)for(n=this.start;i<a&&n<64;++i)u[n++]=t[i];else for(n=this.start;i<a&&n<64;++i)c[n>>>2]|=t[i]<<d[3&n++];this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},k.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[e>>>2]|=p[3&e],e>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},k.prototype.hash=function(){var t,e,r,n,o,i,a=this.blocks;this.first?e=((e=((t=((t=a[0]-680876937)<<7|t>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&t)+a[1]-117830708)<<12|n>>>20)+t<<0)&(-271733879^t))+a[2]-1126478375)<<17|r>>>15)+n<<0)&(n^t))+a[3]-1316259209)<<22|e>>>10)+r<<0:(t=this.h0,e=this.h1,r=this.h2,e=((e+=((t=((t+=((n=this.h3)^e&(r^n))+a[0]-680876936)<<7|t>>>25)+e<<0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[1]-389564586)<<12|n>>>20)+t<<0)&(t^e))+a[2]+606105819)<<17|r>>>15)+n<<0)&(n^t))+a[3]-1044525330)<<22|e>>>10)+r<<0),e=((e+=((t=((t+=(n^e&(r^n))+a[4]-176418897)<<7|t>>>25)+e<<0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[5]+1200080426)<<12|n>>>20)+t<<0)&(t^e))+a[6]-1473231341)<<17|r>>>15)+n<<0)&(n^t))+a[7]-45705983)<<22|e>>>10)+r<<0,e=((e+=((t=((t+=(n^e&(r^n))+a[8]+1770035416)<<7|t>>>25)+e<<0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[9]-1958414417)<<12|n>>>20)+t<<0)&(t^e))+a[10]-42063)<<17|r>>>15)+n<<0)&(n^t))+a[11]-1990404162)<<22|e>>>10)+r<<0,e=((e+=((t=((t+=(n^e&(r^n))+a[12]+1804603682)<<7|t>>>25)+e<<0)^(r=((r+=(e^(n=((n+=(r^t&(e^r))+a[13]-40341101)<<12|n>>>20)+t<<0)&(t^e))+a[14]-1502002290)<<17|r>>>15)+n<<0)&(n^t))+a[15]+1236535329)<<22|e>>>10)+r<<0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[1]-165796510)<<5|t>>>27)+e<<0)^e))+a[6]-1069501632)<<9|n>>>23)+t<<0)^t&((r=((r+=(t^e&(n^t))+a[11]+643717713)<<14|r>>>18)+n<<0)^n))+a[0]-373897302)<<20|e>>>12)+r<<0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[5]-701558691)<<5|t>>>27)+e<<0)^e))+a[10]+38016083)<<9|n>>>23)+t<<0)^t&((r=((r+=(t^e&(n^t))+a[15]-660478335)<<14|r>>>18)+n<<0)^n))+a[4]-405537848)<<20|e>>>12)+r<<0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[9]+568446438)<<5|t>>>27)+e<<0)^e))+a[14]-1019803690)<<9|n>>>23)+t<<0)^t&((r=((r+=(t^e&(n^t))+a[3]-187363961)<<14|r>>>18)+n<<0)^n))+a[8]+1163531501)<<20|e>>>12)+r<<0,e=((e+=((n=((n+=(e^r&((t=((t+=(r^n&(e^r))+a[13]-1444681467)<<5|t>>>27)+e<<0)^e))+a[2]-51403784)<<9|n>>>23)+t<<0)^t&((r=((r+=(t^e&(n^t))+a[7]+1735328473)<<14|r>>>18)+n<<0)^n))+a[12]-1926607734)<<20|e>>>12)+r<<0,e=((e+=((i=(n=((n+=((o=e^r)^(t=((t+=(o^n)+a[5]-378558)<<4|t>>>28)+e<<0))+a[8]-2022574463)<<11|n>>>21)+t<<0)^t)^(r=((r+=(i^e)+a[11]+1839030562)<<16|r>>>16)+n<<0))+a[14]-35309556)<<23|e>>>9)+r<<0,e=((e+=((i=(n=((n+=((o=e^r)^(t=((t+=(o^n)+a[1]-1530992060)<<4|t>>>28)+e<<0))+a[4]+1272893353)<<11|n>>>21)+t<<0)^t)^(r=((r+=(i^e)+a[7]-155497632)<<16|r>>>16)+n<<0))+a[10]-1094730640)<<23|e>>>9)+r<<0,e=((e+=((i=(n=((n+=((o=e^r)^(t=((t+=(o^n)+a[13]+681279174)<<4|t>>>28)+e<<0))+a[0]-358537222)<<11|n>>>21)+t<<0)^t)^(r=((r+=(i^e)+a[3]-722521979)<<16|r>>>16)+n<<0))+a[6]+76029189)<<23|e>>>9)+r<<0,e=((e+=((i=(n=((n+=((o=e^r)^(t=((t+=(o^n)+a[9]-640364487)<<4|t>>>28)+e<<0))+a[12]-421815835)<<11|n>>>21)+t<<0)^t)^(r=((r+=(i^e)+a[15]+530742520)<<16|r>>>16)+n<<0))+a[2]-995338651)<<23|e>>>9)+r<<0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[0]-198630844)<<6|t>>>26)+e<<0)|~r))+a[7]+1126891415)<<10|n>>>22)+t<<0)^((r=((r+=(t^(n|~e))+a[14]-1416354905)<<15|r>>>17)+n<<0)|~t))+a[5]-57434055)<<21|e>>>11)+r<<0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[12]+1700485571)<<6|t>>>26)+e<<0)|~r))+a[3]-1894986606)<<10|n>>>22)+t<<0)^((r=((r+=(t^(n|~e))+a[10]-1051523)<<15|r>>>17)+n<<0)|~t))+a[1]-2054922799)<<21|e>>>11)+r<<0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[8]+1873313359)<<6|t>>>26)+e<<0)|~r))+a[15]-30611744)<<10|n>>>22)+t<<0)^((r=((r+=(t^(n|~e))+a[6]-1560198380)<<15|r>>>17)+n<<0)|~t))+a[13]+1309151649)<<21|e>>>11)+r<<0,e=((e+=((n=((n+=(e^((t=((t+=(r^(e|~n))+a[4]-145523070)<<6|t>>>26)+e<<0)|~r))+a[11]-1120210379)<<10|n>>>22)+t<<0)^((r=((r+=(t^(n|~e))+a[2]+718787259)<<15|r>>>17)+n<<0)|~t))+a[9]-343485551)<<21|e>>>11)+r<<0,this.first?(this.h0=t+1732584193<<0,this.h1=e-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},k.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,n=this.h3;return h[t>>>4&15]+h[15&t]+h[t>>>12&15]+h[t>>>8&15]+h[t>>>20&15]+h[t>>>16&15]+h[t>>>28&15]+h[t>>>24&15]+h[e>>>4&15]+h[15&e]+h[e>>>12&15]+h[e>>>8&15]+h[e>>>20&15]+h[e>>>16&15]+h[e>>>28&15]+h[e>>>24&15]+h[r>>>4&15]+h[15&r]+h[r>>>12&15]+h[r>>>8&15]+h[r>>>20&15]+h[r>>>16&15]+h[r>>>28&15]+h[r>>>24&15]+h[n>>>4&15]+h[15&n]+h[n>>>12&15]+h[n>>>8&15]+h[n>>>20&15]+h[n>>>16&15]+h[n>>>28&15]+h[n>>>24&15]},k.prototype.toString=k.prototype.hex,k.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,r=this.h2,n=this.h3;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255,255&n,n>>>8&255,n>>>16&255,n>>>24&255]},k.prototype.array=k.prototype.digest,k.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),e=new Uint32Array(t);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,t},k.prototype.buffer=k.prototype.arrayBuffer,k.prototype.base64=function(){for(var t,e,r,n="",o=this.array(),i=0;i<15;)t=o[i++],e=o[i++],r=o[i++],n+=y[t>>>2]+y[63&(t<<4|e>>>4)]+y[63&(e<<2|r>>>6)]+y[63&r];return t=o[i],n+(y[t>>>2]+y[t<<4&63]+"==")},S.prototype=new k,S.prototype.finalize=function(){if(k.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();k.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),k.prototype.finalize.call(this)}};var E=function(){var t=x("hex");c&&(t=function(t){var n,o=r(381),a=r(424).Buffer;return n=a.from&&!i.JS_MD5_NO_BUFFER_FROM?a.from:function(t){return new a(t)},function(r){if("string"==typeof r)return o.createHash("md5").update(r,"utf8").digest("hex");if(null==r)throw new Error(e);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),m(r)||b(r)||r.constructor===a?o.createHash("md5").update(n(r)).digest("hex"):t(r)}}(t)),t.create=function(){return new k},t.update=function(e){return t.create().update(e)};for(var n=0;n<v.length;++n){var o=v[n];t[o]=x(o)}return t}();E.md5=E,E.md5.hmac=function(){var t=O("hex");t.create=function(t){return new S(t)},t.update=function(e,r){return t.create(e).update(r)};for(var e=0;e<v.length;++e){var r=v[e];t[r]=O(r)}return t}(),s?t.exports=E:(i.md5=E,l&&(void 0===(n=function(){return E}.call(E,r,E,t))||(t.exports=n)))}()},424:function(){},381:function(){},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.0","description":"This is sdk used to integrate suprsend functionality in javascript applications","main":"dist/cjs_bundle.js","scripts":{"test":"echo \\"Error: no test specified\\" && exit 1","build":"rm -rf dist && webpack --env module_type=commonjs --env filename=cjs_bundle.js && webpack --env module_type=window --env filename=cdn_bundle.js","publish_sdk":"npm run build && npm publish"},"keywords":["suprsend","suprsend-browser","suprsend-browser-sdk"],"author":"Sivaram Katta","license":"MIT","repository":{"type":"git","url":"https://github.com/suprsend/suprsend-browser.git"},"types":"src/index.d.ts","publishConfig":{"access":"public"},"devDependencies":{"@babel/core":"^7.18.5","@babel/preset-env":"^7.18.2","babel-loader":"^8.2.5","webpack":"^5.76.0","webpack-cli":"^4.8.0"},"dependencies":{"js-md5":"^0.8.3","mitt":"^3.0.0"}}')}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.amdO={},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};!function(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return et},PreferenceOptions:function(){return tt},default:function(){return zt},initialisedAt:function(){return Nt}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(495);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},d(t)}function v(){v=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var y={};c(y,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(y=g);var m=p.prototype=f.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==d(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function O(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 S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,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,l):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),l},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),l}},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:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function y(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 _(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){y(i,n,o,a,c,"next",t)}function c(t){y(i,n,o,a,c,"throw",t)}a(void 0)}))}}function g(t){return function(t){if(Array.isArray(t))return m(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){if("string"==typeof t)return m(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)?m(t,e):void 0}}(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 m(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 b=function(t){return new Uint8Array(g(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function w(t,e,r){return x.apply(this,arguments)}function x(){return x=_(v().mark((function t(e,r,n){var i,a,c,u,s,l,f,d,y,_=arguments;return v().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=(0,p.md5)(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=b(a),f=b(s),t.next=12,crypto.subtle.importKey("raw",l,{name:"HMAC",hash:"SHA-256"},!0,["sign"]);case 12:return d=t.sent,t.next=15,crypto.subtle.sign("HMAC",d,f);case 15:return y=t.sent,g(new Uint8Array(y)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,g(new Uint8Array(y)))));case 18:case"end":return t.stop()}}),t)}))),x.apply(this,arguments)}function O(t){return O="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},O(t)}function k(){k=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(E([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==O(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}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 E(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){L(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}function j(t){return function(t){if(Array.isArray(t))return M(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||N(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 L(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(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 T(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){P(i,n,o,a,c,"next",t)}function c(t){P(i,n,o,a,c,"throw",t)}a(void 0)}))}}function A(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=N(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function N(t,e){if(t){if("string"==typeof t)return M(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)?M(t,e):void 0}}function M(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 $(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function C(t){if($())return localStorage.getItem(t)}function I(t,e){$()&&localStorage.setItem(t,e)}function G(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=C(t);return r?JSON.parse(r):e}function F(){var t=navigator.userAgent;for(var e in u){var r,n=A(u[e]);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t.indexOf(o)>=0)return e}}catch(t){n.e(t)}finally{n.f()}}return""}function D(t,e){return U.apply(this,arguments)}function U(){return U=T(k().mark((function t(e,r){var n,o,i,a,c,u=arguments;return k().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=u.length>2&&void 0!==u[2]?u[2]:"POST",o=(new Date).toGMTString(),i=JSON.stringify(r),t.next=5,w(i,o,"POST");case 5:return a=t.sent,c=a?"".concat(h.env_key,":").concat(a):h.env_key,t.abrupt("return",fetch("".concat(h.api_url,"/").concat(e),{method:n,body:i,headers:{"Content-Type":"application/json",Authorization:c,"x-amz-date":o}}));case 8:case"end":return t.stop()}}),t)}))),U.apply(this,arguments)}function B(){var t=G(e,[]);if(t.length){var r=t.slice(0,h.batch_size);D(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=G(e,[]);r.splice(0,h.batch_size),I(e,JSON.stringify(r)),B()})).catch((function(){R(12e4)}))}else R()}function R(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){B()}),t)}var z=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function J(t,e){var r,n=this;return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];return r&&clearTimeout(r),r=setTimeout((function(){t.apply(n,i)}),e)}}const q={uuid:function(){var t=(new Date).getTime();return"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)}))},epoch_milliseconds:function(){return Math.round(Date.now())},cookie_enabled:function(){return navigator.cookieEnabled},set_cookie:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:365,n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/"},get_cookie:function(t){for(var e=t+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},remove_cookie:function(t){document.cookie=t+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"},local_storage_enabled:$,get_local_storage_item:C,set_local_storage_item:I,remove_local_storage_item:function(t){$()&&localStorage.removeItem(t)},get_parsed_local_store_data:G,browser:F,browser_version:function(){var t=navigator.userAgent,e=F(),r=s[e];if(!r||!e)return"";var n,o=A(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(i){var a=t.match(i);if(a&&a.length>1)return a[1]}}}catch(t){o.e(t)}finally{o.f()}return""},os:function(){var t=navigator.userAgent;for(var e in l)if(t.indexOf(l[e])>=0)return e;return""},schedule_flush:R,format_props:function(t){var e,r=t.key,n=t.value,o=t.allow_special_tags,i=void 0!==o&&o;if(r instanceof Object){for(var a in e={},r)if(void 0!==r[a]){if(!i&&z(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&z(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=L({},String(r),n)}return e},urlB64ToUint8Array:function(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),r=window.atob(e),n=new Uint8Array(r.length),o=0;o<r.length;++o)n[o]=r.charCodeAt(o);return n},batch_or_call:function(t){if($()){var r=G(e,[]);null==r||r.push(t),I(e,JSON.stringify(r))}else D(o,t)},has_special_char:z,is_empty:function(t){return Array.isArray(t)?0===t.length:t instanceof Object?0===Object.keys(t).length:["",null,void 0].includes(t)},bulk_call_api:B,is_internal_event:function(t){return Object.values(c).includes(t)},api:D,debounce_by_type:function(t,e,r){var n={};return function(){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=i[0],u=i.slice(1);return"function"==typeof n[c]||(n[c]=J(t,e,E(E({},r),{},{leading:!0}))),n[c].apply(n,j(u))}}};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},W(t)}function Y(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return K(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)?K(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function K(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 V(){V=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==W(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function H(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 Q(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){H(i,n,o,a,c,"next",t)}function c(t){H(i,n,o,a,c,"throw",t)}a(void 0)}))}}function X(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,n.key,n)}}function Z(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var tt={OPT_IN:"opt_in",OPT_OUT:"opt_out"},et={ALL:"all",REQUIRED:"required"},rt=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Z(this,"_update_category_preferences",Q(V().mark((function t(){var e,r,o,i,a,c,u=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:"",r=u.length>1&&void 0!==u[1]?u[1]:{},o=u.length>2?u[2]:void 0,i=u.length>3&&void 0!==u[3]?u[3]:{},a="category/".concat(e),t.next=7,n._update_request(r,a,i);case 7:return null!=(c=t.sent)&&c.error?n._emitter.emit("preferences_error",c):(Object.assign(o,c),n._emitter.emit("preferences_updated",n.data)),t.abrupt("return",c);case 10:case"end":return t.stop()}}),t)})))),Z(this,"_update_channel_preferences",Q(V().mark((function t(){var e,r,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="channel_preference",t.next=4,n._update_request(e,r);case 4:if(null==(o=t.sent)||!o.error){t.next=9;break}n._emitter.emit("preferences_error",o),t.next=12;break;case 9:return t.next=11,n.get_preferences(n._preference_args);case 11:n._emitter.emit("preferences_updated",n.data);case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))),this.ss_instance=e,this._preference_data,this._preference_args,this._emitter=r,this._debounced_update_category_preferences=q.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=q.debounce_by_type(this._update_channel_preferences,h.preference_debounce)}var e,r,n,o,i,a,c,u;return e=t,r=[{key:"_validate_query_params",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};for(var r in t)t[r]&&(e[r]=t[r]);return e}},{key:"_get_request",value:(u=Q(V().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n="/v1/subscriber/".concat(this.ss_instance.distinct_id),o=this._validate_query_params(r),i=new URLSearchParams(o).toString(),a=i?"".concat(n,"/").concat(e,"/?").concat(i):"".concat(n,"/").concat(e),c=(new Date).toGMTString(),t.next=9,w("",c,"GET",a);case 9:return u=t.sent,s=u?"".concat(h.env_key,":").concat(u):h.env_key,t.prev=11,t.next=14,fetch("".concat(h.api_url).concat(a),{headers:{"Content-Type":"application/json",Authorization:s,"x-amz-date":c}});case 14:if(!(l=t.sent).ok){t.next=18;break}return f=l.json(),t.abrupt("return",f);case 18:return t.abrupt("return",{error:!0,api_error:!0,status_code:l.status,message:l.statusText,error_obj:null});case 21:return t.prev=21,t.t0=t.catch(11),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 24:case"end":return t.stop()}}),t,this,[[11,21]])}))),function(){return u.apply(this,arguments)})},{key:"_update_request",value:(c=Q(V().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o="/v1/subscriber/".concat(this.ss_instance.distinct_id),i=this._validate_query_params(n),a=new URLSearchParams(i).toString(),c=a?"".concat(o,"/").concat(r,"/?").concat(a):"".concat(o,"/").concat(r),u=(new Date).toGMTString(),s=JSON.stringify(e),t.next=8,w(s,u,"POST",c);case 8:return l=t.sent,f=l?"".concat(h.env_key,":").concat(l):h.env_key,t.prev=10,t.next=13,fetch("".concat(h.api_url).concat(c),{method:"POST",body:s,headers:{"Content-Type":"application/json",Authorization:f,"x-amz-date":u}});case 13:if(!(p=t.sent).ok){t.next=17;break}return d=p.json(),t.abrupt("return",d);case 17:return t.abrupt("return",{error:!0,api_error:!0,status_code:p.status,message:p.statusText,error_obj:null});case 20:return t.prev=20,t.t0=t.catch(10),t.abrupt("return",{error:!0,api_error:!1,status_code:null,message:t.t0.message,error_obj:t.t0});case 23:case"end":return t.stop()}}),t,this,[[10,20]])}))),function(t,e,r){return c.apply(this,arguments)})},{key:"data",get:function(){return this._preference_data},set:function(t){this._preference_data=t}},{key:"get_preferences",value:(a=Q(V().mark((function t(){var e,r,n,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="full_preference",this._preference_args=e,n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels},t.next=6,this._get_request(r,n);case 6:return null!=(o=t.sent)&&o.error||(this.data=o),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"get_categories",value:(i=Q(V().mark((function t(){var e,r,n,o,i=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},r="category",n={tenant_id:null==e?void 0:e.tenant_id,show_opt_out_channels:null==e?void 0:e.show_opt_out_channels,limit:null==e?void 0:e.limit,offset:null==e?void 0:e.offset},t.next=5,this._get_request(r,n);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"get_category",value:(o=Q(V().mark((function t(){var e,r,n,o,i,a=arguments;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=a.length>0&&void 0!==a[0]?a[0]:"",r=a.length>1&&void 0!==a[1]?a[1]:{},e){t.next=4;break}return t.abrupt("return",{error:!0,message:"Category parameter is missing"});case 4:return n="category/".concat(e),o={tenant_id:null==r?void 0:r.tenant_id,show_opt_out_channels:null==r?void 0:r.show_opt_out_channels},t.next=8,this._get_request(n,o);case 8:return i=t.sent,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get_overall_channel_preferences",value:(n=Q(V().mark((function t(){var e;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this._get_request("channel_preference");case 3:return e=t.sent,t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"update_category_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||![tt.OPT_IN,tt.OPT_OUT].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Category parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var o,i=!1,a=null==n?void 0:n.show_opt_out_channels,c=Y(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=Y(s.subcategories);try{for(f.s();!(u=f.n()).done;){var h=u.value;if(h.category===e){if(t=h,!h.is_editable)return{error:!0,message:"Category preference is not editable"};if(h.preference!==r){h.preference=r,i=!0,l=!0;break}}}}catch(t){f.e(t)}finally{f.f()}if(l)break}}catch(t){c.e(t)}finally{c.f()}if(!t)return{error:!0,message:"Category is not found"};if(!i)return this.data;var p=[];t.channels.forEach((function(t){t.preference===tt.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===tt.OPT_IN?null:p};return this._debounced_update_category_preferences(e,e,d,t,{tenant_id:null==n?void 0:n.tenant_id,show_opt_out_channels:null==n?void 0:n.show_opt_out_channels}),this.data}},{key:"update_channel_preference_in_category",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!r||!o)return{error:!0,message:r?"Category parameter is missing":"Channel parameter is missing"};if(![tt.OPT_IN,tt.OPT_OUT].includes(n))return{error:!0,message:"Preference parameter is invalid"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var a,c=!1,u=Y(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=Y(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=Y(p.channels);try{for(v.s();!(d=v.n()).done;){var y=d.value;if(y.channel===r){if(e=y,!y.is_editable)return{error:!0,message:"Channel preference is not editable"};if(y.preference!==n){y.preference=n,n===tt.OPT_IN&&(p.preference=tt.OPT_IN),c=!0,f=!0;break}}}}catch(t){v.e(t)}finally{v.f()}}if(f)break}}catch(t){h.e(t)}finally{h.f()}if(f)break}}catch(t){u.e(t)}finally{u.f()}if(!t)return{error:!0,message:"Category not found"};if(!e)return{error:!0,message:"Category's Channel not found"};if(!c)return this.data;var _=[];t.channels.forEach((function(t){t.preference===tt.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===tt.OPT_OUT&&n===tt.OPT_IN?tt.OPT_IN:t.preference,m={preference:g,opt_out_channels:_};return this._debounced_update_category_preferences(o,o,m,t,{tenant_id:null==i?void 0:i.tenant_id,show_opt_out_channels:null==i?void 0:i.show_opt_out_channels}),this.data}},{key:"update_overall_channel_preference",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!e||![et.ALL,et.REQUIRED].includes(r))return{error:!0,message:e?"Preference parameter is invalid":"Channel parameter is missing"};if(!this.data)return{error:!0,message:"Call get_preferences method before performing action"};var n,o=!1,i=r===et.REQUIRED,a=Y(this.data.channel_preferences);try{for(a.s();!(n=a.n()).done;){var c=n.value;if(c.channel===e&&(t=c,c.is_restricted!==i)){c.is_restricted=i,o=!0;break}}}catch(t){a.e(t)}finally{a.f()}return t?o?(this._debounced_update_channel_preferences(t.channel,{channel_preferences:[t]}),this.data):this.data:{error:!0,message:"Channel data not found"}}}],r&&X(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const nt=rt;function ot(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 it(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ot(Object(r),!0).forEach((function(e){ct(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ot(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function at(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,n.key,n)}}function ct(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ut=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ct(this,"_allow_special_char_events",(function(t){return"$email"===t||"$whatsapp"===t||"$sms"===t||(null==t?void 0:t.$webpush)})),this.instance=e,this.preferences=new nt(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){q.batch_or_call(it({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:q.uuid(),$time:q.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;q.api(o,it({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:q.uuid(),$time:q.epoch_milliseconds()},t)).then((function(t){if(!t.ok)throw new Error("Error in Fetch")})).catch((function(){e._call_indentity(t)}))}},{key:"_convert_to_number",value:function(t){if(!q.is_empty(t))for(var e in t){var r=Number(t[e]);r?t[e]=r:delete t[e]}return t}},{key:"_validate_email_and_send",value:function(t,e){f.email.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Email ID")}},{key:"_validate_mobile_and_send",value:function(t,e){try{f.mobile.test(e)?this.append(t,e):console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}catch(t){console.log("SuprSend: Provide valid Mobile number as per E.164 standard")}}},{key:"set",value:function(t,e){var r=q.format_props({key:t,value:e});q.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=q.format_props({key:t,value:e});q.is_empty(r)||this._call_indentity({$set_once:r})}},{key:"increment",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=q.format_props({key:t,value:e}),n=this._convert_to_number(r);q.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=q.format_props({key:t,value:e,allow_special_tags:r});q.is_empty(n)||this._call_indentity({$append:n})}},{key:"remove",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._allow_special_char_events(t),o=q.format_props({key:t,value:e,allow_special_tags:n});q.is_empty(o)||(null!=r&&r.flush_immediately?this._call_flush_immediately({$remove:o}):this._call_indentity({$remove:o}))}},{key:"unset",value:function(t){var e;"string"==typeof t?q.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){q.has_special_char(String(t))||e.push(String(t))}))),q.is_empty(e)||this._call_indentity({$unset:e})}},{key:"add_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_email_and_send("$email",t)}},{key:"remove_email",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$email",t)}},{key:"add_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$sms",t)}},{key:"remove_sms",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$sms",t)}},{key:"add_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this._validate_mobile_and_send("$whatsapp",t)}},{key:"remove_whatsapp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove("$whatsapp",t)}},{key:"add_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.append({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"})}},{key:"remove_webpush",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.remove({$webpush:r,$device_id:null===(t=this.instance)||void 0===t||null===(e=t.env_properties)||void 0===e?void 0:e.$device_id,$pushvendor:"vapid"},null,{flush_immediately:!0})}}],r&&at(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const st=ut;function lt(t){return lt="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},lt(t)}function ft(){ft=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==lt(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ht(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 pt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ht(i,n,o,a,c,"next",t)}function c(t){ht(i,n,o,a,c,"throw",t)}a(void 0)}))}}function dt(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,n.key,n)}}function vt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var yt,_t=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),vt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),vt(this,"_ask_notification_permission",pt(ft().mark((function t(){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Notification.requestPermission();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))),vt(this,"_register_sw",(function(){return navigator.serviceWorker.register("/".concat(h.service_worker_file)).then((function(t){r._subscribe_push(t)})).catch((function(t){console.error("SuprSend: Unable to register service worker.",t)}))})),vt(this,"_get_subscription_without_wait",pt(ft().mark((function t(){var e;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.serviceWorker.getRegistration();case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.abrupt("return",e.pushManager.getSubscription().then(function(){var t=pt(ft().mark((function t(e){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 6:case"end":return t.stop()}}),t)})))),vt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=pt(ft().mark((function t(e){return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())})),vt(this,"_subscribe_push",function(){var t=pt(ft().mark((function t(e){var n,o;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._ask_notification_permission();case 2:if("granted"!==t.sent){t.next=18;break}return t.next=6,r._get_subscription();case 6:if(t.sent){t.next=18;break}if(h.vapid_key){t.next=11;break}return console.log("SuprSend: Provide vapid key while calling init"),t.abrupt("return");case 11:return n=q.urlB64ToUint8Array(h.vapid_key),t.next=14,e.pushManager.subscribe({applicationServerKey:n,userVisibleOnly:!0});case 14:o=t.sent,r.user.add_webpush(o),t.next=18;break;case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),vt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),vt(this,"is_subscribed",pt(ft().mark((function t(){var e;return ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r._get_subscription_without_wait();case 2:return e=t.sent,t.abrupt("return",!!e);case 4:case"end":return t.stop()}}),t)})))),this.instance=e,this.user=new st(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-Nt;e>=h.sw_delay?this._register_sw():(clearTimeout(yt),yt=setTimeout((function(){t._register_sw()}),h.sw_delay-e))}},{key:"update_subscription",value:function(){var t,e,r=this;null===(t=navigator)||void 0===t||null===(e=t.serviceWorker)||void 0===e||e.ready.then((function(t){return t.pushManager.getSubscription()})).then((function(t){t&&r.user.add_webpush(t)}))}},{key:"notification_permission",value:function(){return Notification.permission}}])&&dt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const gt=_t;function mt(t){return mt="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},mt(t)}function bt(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,n.key,n)}}function wt(t,e,r){return e&&bt(t.prototype,e),r&&bt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function xt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(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&&Pt(t,e)}function kt(t){var e=Lt();return function(){var r,n=Tt(t);if(e){var o=Tt(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return St(this,r)}}function St(t,e){if(e&&("object"===mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Et(t){var e="function"==typeof Map?new Map:void 0;return Et=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return jt(t,arguments,Tt(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Pt(n,t)},Et(t)}function jt(t,e,r){return jt=Lt()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Pt(o,r.prototype),o},jt.apply(null,arguments)}function Lt(){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}}function Pt(t,e){return Pt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Pt(t,e)}function Tt(t){return Tt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Tt(t)}var At,Nt,Mt=function(t){Ot(r,t);var e=kt(r);function r(t){var n;return xt(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return wt(r)}(function(t){Ot(r,t);var e=kt(r);function r(t){var n;return xt(this,r),(n=e.call(this,t)).name="SuprsendError",n}return wt(r)}(Et(Error)));function $t(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map((function(t){t(r)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,r)}))}}}function Ct(t){return Ct="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},Ct(t)}function It(){It=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new O(n||[]);return i._invoke=function(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{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)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=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var _=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==Ct(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){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function w(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 x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return h.prototype=p,c(_,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},g(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(_),c(_,a,"Generator"),c(_,o,(function(){return this})),c(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,O.prototype={constructor:O,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(x),!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,l):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),l},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),x(r),l}},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;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function Gt(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 Ft(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 Dt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ft(Object(r),!0).forEach((function(e){Ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ft(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bt(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,n.key,n)}}var Rt=function(){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e)}var r,n,o,u,s;return r=e,n=[{key:"init",value:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.env=r,o.signing_key=n;var i=q.get_cookie(t);At||(At={},this._set_custom_config(o)),i||(i=q.uuid(),q.set_cookie(t,i)),At.distinct_id=i,this.emitter=$t(),this.user=new st(At,this.emitter),this.web_push=new gt(At),this.web_push.update_subscription(),e._set_env_properties(),Nt||(q.bulk_call_api(),this.track(c.app_launched)),Nt=new Date}},{key:"_set_custom_config_property",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e)h[t]=e;else if(r)throw new Mt("Mandatory Key Missing: ".concat(t))}},{key:"_set_custom_config",value:function(t){this._set_custom_config_property("env_key",t.env,!0),this._set_custom_config_property("signing_key",t.signing_key,!0),this._set_custom_config_property("api_url",null==t?void 0:t.api_url),this._set_custom_config_property("vapid_key",null==t?void 0:t.vapid_key),this._set_custom_config_property("service_worker_file",null==t?void 0:t.sw_file_name)}},{key:"set_super_properties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=q.get_parsed_local_store_data(i),r=Dt(Dt({},e),t),n={};for(var o in r)q.has_special_char(o)||(n[o]=r[o]);q.set_local_storage_item(i,JSON.stringify(n)),At.env_properties=Dt(Dt({},At.env_properties),n)}},{key:"identify",value:function(e){At._user_identified||(q.batch_or_call({env:h.env_key,event:"$identify",$insert_id:q.uuid(),$time:q.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:At.distinct_id}}),q.set_cookie(t,e),At.distinct_id=e,At._user_identified=!0,this.web_push.update_subscription(),this.track(c.user_login))}},{key:"track",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==t)if(q.is_internal_event(t)||!q.has_special_char(t)){var r=q.get_parsed_local_store_data(i),n=q.format_props({key:e}),o=Dt(Dt(Dt(Dt({},n),At.env_properties),r),{},{$current_url:window.location.href});q.batch_or_call({event:String(t),distinct_id:At.distinct_id,env:h.env_key,properties:o,$insert_id:q.uuid(),$time:q.epoch_milliseconds()})}else console.log("SuprSend: key cannot start with $ or ss_")}},{key:"purchase_made",value:function(t){this.track(c.purchase_made,t)}},{key:"reset",value:(u=It().mark((function r(){var n,o,a,u=arguments;return It().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(null==(n=u.length>0&&void 0!==u[0]?u[0]:{unsubscribe_push:!0})||!n.unsubscribe_push){r.next=6;break}return r.next=4,this.web_push._get_subscription_without_wait();case 4:(o=r.sent)&&this.user.remove_webpush(o);case 6:this.track(c.user_logout),a=q.uuid(),q.set_cookie(t,a),At={distinct_id:a,_user_identified:!1},q.remove_local_storage_item(i),this.user=new st(At,this.emitter),this.web_push=new gt(At),e._set_env_properties();case 14:case"end":return r.stop()}}),r,this)})),s=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=u.apply(t,e);function i(t){Gt(o,r,n,i,a,"next",t)}function a(t){Gt(o,r,n,i,a,"throw",t)}i(void 0)}))},function(){return s.apply(this,arguments)})}],o=[{key:"_set_env_properties",value:function(){var t=q.get_local_storage_item(a);t||(t=q.uuid(),q.set_local_storage_item(a,t)),At.env_properties={$os:q.os(),$browser:q.browser(),$browser_version:q.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&Bt(r.prototype,n),o&&Bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const zt=new Rt}();var o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})}();
|
|
@@ -1 +1,11 @@
|
|
|
1
1
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* [js-md5]{@link https://github.com/emn178/js-md5}
|
|
5
|
+
*
|
|
6
|
+
* @namespace md5
|
|
7
|
+
* @version 0.8.3
|
|
8
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
9
|
+
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
10
|
+
* @license MIT
|
|
11
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suprsend/web-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "This is sdk used to integrate suprsend functionality in javascript applications",
|
|
5
5
|
"main": "dist/cjs_bundle.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"webpack-cli": "^4.8.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"js-md5": "^0.8.3",
|
|
34
35
|
"mitt": "^3.0.0"
|
|
35
36
|
}
|
|
36
37
|
}
|