@suprsend/web-sdk 1.3.2 → 1.4.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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see cdn_bundle.js.LICENSE.txt */
2
- !function(){"use strict";var t={147:function(t){t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.3.2","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 g=Object.getPrototypeOf,_=g&&g(g(E([])));_&&_!==e&&r.call(_,o)&&(y=_);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 g(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)||function(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}}(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 _(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,g=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),g=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<g.length;u+=16)s=p,l=d,f=v,h=y,p=n(p,d,v,y,g[u+0],7,3614090360),y=n(y,p,d,v,g[u+1],12,3905402710),v=n(v,y,p,d,g[u+2],17,606105819),d=n(d,v,y,p,g[u+3],22,3250441966),p=n(p,d,v,y,g[u+4],7,4118548399),y=n(y,p,d,v,g[u+5],12,1200080426),v=n(v,y,p,d,g[u+6],17,2821735955),d=n(d,v,y,p,g[u+7],22,4249261313),p=n(p,d,v,y,g[u+8],7,1770035416),y=n(y,p,d,v,g[u+9],12,2336552879),v=n(v,y,p,d,g[u+10],17,4294925233),d=n(d,v,y,p,g[u+11],22,2304563134),p=n(p,d,v,y,g[u+12],7,1804603682),y=n(y,p,d,v,g[u+13],12,4254626195),v=n(v,y,p,d,g[u+14],17,2792965006),p=o(p,d=n(d,v,y,p,g[u+15],22,1236535329),v,y,g[u+1],5,4129170786),y=o(y,p,d,v,g[u+6],9,3225465664),v=o(v,y,p,d,g[u+11],14,643717713),d=o(d,v,y,p,g[u+0],20,3921069994),p=o(p,d,v,y,g[u+5],5,3593408605),y=o(y,p,d,v,g[u+10],9,38016083),v=o(v,y,p,d,g[u+15],14,3634488961),d=o(d,v,y,p,g[u+4],20,3889429448),p=o(p,d,v,y,g[u+9],5,568446438),y=o(y,p,d,v,g[u+14],9,3275163606),v=o(v,y,p,d,g[u+3],14,4107603335),d=o(d,v,y,p,g[u+8],20,1163531501),p=o(p,d,v,y,g[u+13],5,2850285829),y=o(y,p,d,v,g[u+2],9,4243563512),v=o(v,y,p,d,g[u+7],14,1735328473),p=i(p,d=o(d,v,y,p,g[u+12],20,2368359562),v,y,g[u+5],4,4294588738),y=i(y,p,d,v,g[u+8],11,2272392833),v=i(v,y,p,d,g[u+11],16,1839030562),d=i(d,v,y,p,g[u+14],23,4259657740),p=i(p,d,v,y,g[u+1],4,2763975236),y=i(y,p,d,v,g[u+4],11,1272893353),v=i(v,y,p,d,g[u+7],16,4139469664),d=i(d,v,y,p,g[u+10],23,3200236656),p=i(p,d,v,y,g[u+13],4,681279174),y=i(y,p,d,v,g[u+0],11,3936430074),v=i(v,y,p,d,g[u+3],16,3572445317),d=i(d,v,y,p,g[u+6],23,76029189),p=i(p,d,v,y,g[u+9],4,3654602809),y=i(y,p,d,v,g[u+12],11,3873151461),v=i(v,y,p,d,g[u+15],16,530742520),p=a(p,d=i(d,v,y,p,g[u+2],23,3299628645),v,y,g[u+0],6,4096336452),y=a(y,p,d,v,g[u+7],10,1126891415),v=a(v,y,p,d,g[u+14],15,2878612391),d=a(d,v,y,p,g[u+5],21,4237533241),p=a(p,d,v,y,g[u+12],6,1700485571),y=a(y,p,d,v,g[u+3],10,2399980690),v=a(v,y,p,d,g[u+10],15,4293915773),d=a(d,v,y,p,g[u+1],21,2240044497),p=a(p,d,v,y,g[u+8],6,1873313359),y=a(y,p,d,v,g[u+15],10,4264355552),v=a(v,y,p,d,g[u+6],15,2734768916),d=a(d,v,y,p,g[u+13],21,1309151649),p=a(p,d,v,y,g[u+4],6,4149444226),y=a(y,p,d,v,g[u+11],10,3174756917),v=a(v,y,p,d,g[u+2],15,718787259),d=a(d,v,y,p,g[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(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=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,g(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,g(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 g=p.prototype=f.prototype=Object.create(d);function _(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(g,"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(g),t},t.awrap=function(t){return{__await:t}},_(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(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"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,e=navigator.userAgent,r=F(),n=A(s[r]);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(o){var i=e.match(o);if(i&&i.length>1)return i[1]}}}catch(t){n.e(t)}finally{n.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 g=p.prototype=f.prototype=Object.create(d);function _(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(g,"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(g),t},t.awrap=function(t){return{__await:t}},_(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(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"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 g=[];t.channels.forEach((function(t){t.preference===tt.OPT_OUT&&g.push(t.channel)}));var _={preference:t.preference,opt_out_channels:g};return this._debounced_update_category_preferences(o,o,_,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 g=p.prototype=f.prototype=Object.create(d);function _(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(g,"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(g),t},t.awrap=function(t){return{__await:t}},_(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(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"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,gt=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 _t=gt;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 g=p.prototype=f.prototype=Object.create(d);function _(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(g,"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(g),t},t.awrap=function(t){return{__await:t}},_(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(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"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 _t(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 _t(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}(),window.suprsend=n}();
2
+ !function(){"use strict";var t={147:function(t){t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.4.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":{"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 N(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 N(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)?N(t,e):void 0}}function N(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 I(t){if($())return localStorage.getItem(t)}function G(t,e){$()&&localStorage.setItem(t,e)}function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=I(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),G(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:$,get_local_storage_item:I,set_local_storage_item:G,remove_local_storage_item:function(t){$()&&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($()){var r=M(e,[]);null==r||r.push(t),G(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,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=B(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=B(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=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=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=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,Nt=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 $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 It(t){return It="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},It(t)}function Gt(){Gt=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"==It(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=$t(),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 Nt("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=Gt().mark((function r(){var n,o,a,u=arguments;return Gt().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}(),window.suprsend=n}();
@@ -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.2","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,e=navigator.userAgent,r=F(),n=A(s[r]);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(o){var i=e.match(o);if(i&&i.length>1)return i[1]}}}catch(t){n.e(t)}finally{n.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(){"use strict";var t={147:function(t){t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.4.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":{"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 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=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(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 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 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 N(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 N(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)?N(t,e):void 0}}function N(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 I(t){if($())return localStorage.getItem(t)}function G(t,e){$()&&localStorage.setItem(t,e)}function M(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=I(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 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),G(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:$,get_local_storage_item:I,set_local_storage_item:G,remove_local_storage_item:function(t){$()&&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($()){var r=M(e,[]);null==r||r.push(t),G(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 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"==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 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=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,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=B(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=B(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=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=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=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 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=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 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,Ct,Nt=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 It(t){return It="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},It(t)}function Gt(){Gt=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"==It(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 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=$t(),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 Nt("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=Gt().mark((function r(){var n,o,a,u=arguments;return Gt().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})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suprsend/web-sdk",
3
- "version": "1.3.2",
3
+ "version": "1.4.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": {
package/src/index.d.ts CHANGED
@@ -72,17 +72,21 @@ interface GetOverAllChannelPreferencesResponse extends PreferenceErrorData {
72
72
  interface Preferences {
73
73
  data: PreferenceData;
74
74
 
75
- get_preferences(args?: { tenant_id?: string }): Promise<PreferencesResponse>;
75
+ get_preferences(args?: {
76
+ tenant_id?: string;
77
+ show_opt_out_channels?: boolean;
78
+ }): Promise<PreferencesResponse>;
76
79
 
77
80
  get_categories(args?: {
78
81
  tenant_id?: string;
79
82
  limit?: number;
80
83
  offset?: number;
84
+ show_opt_out_channels?: boolean;
81
85
  }): Promise<GetCategoriesResponse>;
82
86
 
83
87
  get_category(
84
88
  category: string,
85
- args?: { tenant_id?: string }
89
+ args?: { tenant_id?: string; show_opt_out_channels?: boolean }
86
90
  ): Promise<Category>;
87
91
 
88
92
  get_overall_channel_preferences(): Promise<GetOverAllChannelPreferencesResponse>;
@@ -92,6 +96,7 @@ interface Preferences {
92
96
  preference: PreferenceOptions,
93
97
  args?: {
94
98
  tenant_id?: string;
99
+ show_opt_out_channels?: boolean;
95
100
  }
96
101
  ): PreferencesResponse;
97
102
 
@@ -101,6 +106,7 @@ interface Preferences {
101
106
  category: string,
102
107
  args?: {
103
108
  tenant_id?: string;
109
+ show_opt_out_channels?: boolean;
104
110
  }
105
111
  ): PreferencesResponse;
106
112
 
@@ -182,7 +182,10 @@ class Preferences {
182
182
  async get_preferences(args = {}) {
183
183
  let url_path = "full_preference";
184
184
  this._preference_args = args;
185
- let query_params = { tenant_id: args?.tenant_id };
185
+ let query_params = {
186
+ tenant_id: args?.tenant_id,
187
+ show_opt_out_channels: args?.show_opt_out_channels,
188
+ };
186
189
 
187
190
  const response = await this._get_request(url_path, query_params);
188
191
  if (!response?.error) {
@@ -195,6 +198,7 @@ class Preferences {
195
198
  let url_path = "category";
196
199
  const query_params = {
197
200
  tenant_id: args?.tenant_id,
201
+ show_opt_out_channels: args?.show_opt_out_channels,
198
202
  limit: args?.limit,
199
203
  offset: args?.offset,
200
204
  };
@@ -212,7 +216,10 @@ class Preferences {
212
216
  }
213
217
 
214
218
  let url_path = `category/${category}`;
215
- let query_params = { tenant_id: args?.tenant_id };
219
+ let query_params = {
220
+ tenant_id: args?.tenant_id,
221
+ show_opt_out_channels: args?.show_opt_out_channels,
222
+ };
216
223
 
217
224
  const response = await this._get_request(url_path, query_params);
218
225
  return response;
@@ -248,6 +255,7 @@ class Preferences {
248
255
 
249
256
  let category_data;
250
257
  let data_updated = false;
258
+ let show_opt_out_channels = args?.show_opt_out_channels;
251
259
 
252
260
  // optimistic update in local store
253
261
  for (let section of this.data.sections) {
@@ -295,7 +303,10 @@ class Preferences {
295
303
 
296
304
  const request_payload = {
297
305
  preference: category_data.preference,
298
- opt_out_channels,
306
+ opt_out_channels:
307
+ show_opt_out_channels && preference === PreferenceOptions.OPT_IN
308
+ ? null
309
+ : opt_out_channels,
299
310
  };
300
311
 
301
312
  this._debounced_update_category_preferences(
@@ -303,7 +314,10 @@ class Preferences {
303
314
  category,
304
315
  request_payload,
305
316
  category_data,
306
- { tenant_id: args?.tenant_id }
317
+ {
318
+ tenant_id: args?.tenant_id,
319
+ show_opt_out_channels: args?.show_opt_out_channels,
320
+ }
307
321
  );
308
322
 
309
323
  return this.data;
@@ -404,8 +418,15 @@ class Preferences {
404
418
  }
405
419
  });
406
420
 
421
+ const category_preference =
422
+ args?.show_opt_out_channels &&
423
+ category_data.preference === PreferenceOptions.OPT_OUT &&
424
+ preference === PreferenceOptions.OPT_IN
425
+ ? PreferenceOptions.OPT_IN
426
+ : category_data.preference;
427
+
407
428
  const request_payload = {
408
- preference: category_data.preference,
429
+ preference: category_preference,
409
430
  opt_out_channels,
410
431
  };
411
432
 
@@ -414,7 +435,10 @@ class Preferences {
414
435
  category,
415
436
  request_payload,
416
437
  category_data,
417
- { tenant_id: args?.tenant_id }
438
+ {
439
+ tenant_id: args?.tenant_id,
440
+ show_opt_out_channels: args?.show_opt_out_channels,
441
+ }
418
442
  );
419
443
 
420
444
  return this.data;
package/src/utils.js CHANGED
@@ -103,7 +103,11 @@ function browser() {
103
103
  function browser_version() {
104
104
  const userAgent = navigator.userAgent;
105
105
  const browser_name = browser();
106
- for (let regex_item of browser_version_useragent_map[browser_name]) {
106
+ const regexItems = browser_version_useragent_map[browser_name];
107
+
108
+ if (!regexItems || !browser_name) return "";
109
+
110
+ for (let regex_item of regexItems) {
107
111
  const regex = regex_item;
108
112
  if (regex) {
109
113
  const result = userAgent.match(regex);