@suprsend/web-sdk 1.4.0 → 1.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn_bundle.js +1 -1
- package/dist/cjs_bundle.js +1 -1
- package/package.json +2 -1
- package/src/encryption.js +2 -231
package/dist/cdn_bundle.js
CHANGED
|
@@ -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.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}();
|
|
2
|
+
!function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.0-beta.1","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":{"blueimp-md5":"^2.19.0","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].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},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(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="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},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);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"==v(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=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(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 _(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 g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(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 b(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)?b(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 b(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 w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return k.apply(this,arguments)}function k(){return k=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(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,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),k.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 S(){S=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(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 k(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,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:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(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 j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(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 P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(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 A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(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 $(t,e){if(t){if("string"==typeof t)return C(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)?C(t,e):void 0}}function C(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 I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(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 U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().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,x(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)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(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 J={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:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(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:z,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&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},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(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,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:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,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]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="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},B(t)}function K(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 V(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)?V(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 V(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 H(){H=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"==B(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 Q(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 X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(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 tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=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),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().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)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().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=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.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=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().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,x("",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=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().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,x(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=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().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=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().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=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().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=X(H().mark((function t(){var e;return H().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||![et.OPT_IN,et.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=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(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===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.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(![et.OPT_IN,et.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=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(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===et.OPT_IN&&(p.preference=et.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===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.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||![rt.ALL,rt.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===rt.REQUIRED,a=K(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&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(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 at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(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 ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(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 ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.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(!J.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=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.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=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.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=J.format_props({key:t,value:e,allow_special_tags:n});J.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?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.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&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="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},ft(t)}function ht(){ht=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"==ft(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 pt(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 dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(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 yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,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),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().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)})))),yt(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)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().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=dt(ht().mark((function t(e){return ht().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)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().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)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().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=J.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)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().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 lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=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}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="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},bt(t)}function wt(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 xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function kt(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&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(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 jt(t){var e="function"==typeof Map?new Map:void 0;return jt=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 Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?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&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){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 Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){Ot(r,t);var e=St(r);function r(t){var n;return kt(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(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 Mt(){Mt=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 Ft(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 Dt(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 Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(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 zt=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=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=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 Ct("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=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._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(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.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=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().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=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),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){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(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=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}(),window.suprsend=n}();
|
package/dist/cjs_bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see cjs_bundle.js.LICENSE.txt */
|
|
2
|
-
!function(){"use strict";var t={147:function(t){t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.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})}();
|
|
2
|
+
!function(){var t={560:function(t,e,r){var n;!function(o){"use strict";function i(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function a(t,e,r,n,o,a){return i((c=i(i(e,t),i(n,a)))<<(u=o)|c>>>32-u,r);var c,u}function c(t,e,r,n,o,i,c){return a(e&r|~e&n,t,e,o,i,c)}function u(t,e,r,n,o,i,c){return a(e&n|r&~n,t,e,o,i,c)}function s(t,e,r,n,o,i,c){return a(e^r^n,t,e,o,i,c)}function l(t,e,r,n,o,i,c){return a(r^(e|~n),t,e,o,i,c)}function f(t,e){var r,n,o,a,f;t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;var h=1732584193,p=-271733879,d=-1732584194,v=271733878;for(r=0;r<t.length;r+=16)n=h,o=p,a=d,f=v,h=c(h,p,d,v,t[r],7,-680876936),v=c(v,h,p,d,t[r+1],12,-389564586),d=c(d,v,h,p,t[r+2],17,606105819),p=c(p,d,v,h,t[r+3],22,-1044525330),h=c(h,p,d,v,t[r+4],7,-176418897),v=c(v,h,p,d,t[r+5],12,1200080426),d=c(d,v,h,p,t[r+6],17,-1473231341),p=c(p,d,v,h,t[r+7],22,-45705983),h=c(h,p,d,v,t[r+8],7,1770035416),v=c(v,h,p,d,t[r+9],12,-1958414417),d=c(d,v,h,p,t[r+10],17,-42063),p=c(p,d,v,h,t[r+11],22,-1990404162),h=c(h,p,d,v,t[r+12],7,1804603682),v=c(v,h,p,d,t[r+13],12,-40341101),d=c(d,v,h,p,t[r+14],17,-1502002290),h=u(h,p=c(p,d,v,h,t[r+15],22,1236535329),d,v,t[r+1],5,-165796510),v=u(v,h,p,d,t[r+6],9,-1069501632),d=u(d,v,h,p,t[r+11],14,643717713),p=u(p,d,v,h,t[r],20,-373897302),h=u(h,p,d,v,t[r+5],5,-701558691),v=u(v,h,p,d,t[r+10],9,38016083),d=u(d,v,h,p,t[r+15],14,-660478335),p=u(p,d,v,h,t[r+4],20,-405537848),h=u(h,p,d,v,t[r+9],5,568446438),v=u(v,h,p,d,t[r+14],9,-1019803690),d=u(d,v,h,p,t[r+3],14,-187363961),p=u(p,d,v,h,t[r+8],20,1163531501),h=u(h,p,d,v,t[r+13],5,-1444681467),v=u(v,h,p,d,t[r+2],9,-51403784),d=u(d,v,h,p,t[r+7],14,1735328473),h=s(h,p=u(p,d,v,h,t[r+12],20,-1926607734),d,v,t[r+5],4,-378558),v=s(v,h,p,d,t[r+8],11,-2022574463),d=s(d,v,h,p,t[r+11],16,1839030562),p=s(p,d,v,h,t[r+14],23,-35309556),h=s(h,p,d,v,t[r+1],4,-1530992060),v=s(v,h,p,d,t[r+4],11,1272893353),d=s(d,v,h,p,t[r+7],16,-155497632),p=s(p,d,v,h,t[r+10],23,-1094730640),h=s(h,p,d,v,t[r+13],4,681279174),v=s(v,h,p,d,t[r],11,-358537222),d=s(d,v,h,p,t[r+3],16,-722521979),p=s(p,d,v,h,t[r+6],23,76029189),h=s(h,p,d,v,t[r+9],4,-640364487),v=s(v,h,p,d,t[r+12],11,-421815835),d=s(d,v,h,p,t[r+15],16,530742520),h=l(h,p=s(p,d,v,h,t[r+2],23,-995338651),d,v,t[r],6,-198630844),v=l(v,h,p,d,t[r+7],10,1126891415),d=l(d,v,h,p,t[r+14],15,-1416354905),p=l(p,d,v,h,t[r+5],21,-57434055),h=l(h,p,d,v,t[r+12],6,1700485571),v=l(v,h,p,d,t[r+3],10,-1894986606),d=l(d,v,h,p,t[r+10],15,-1051523),p=l(p,d,v,h,t[r+1],21,-2054922799),h=l(h,p,d,v,t[r+8],6,1873313359),v=l(v,h,p,d,t[r+15],10,-30611744),d=l(d,v,h,p,t[r+6],15,-1560198380),p=l(p,d,v,h,t[r+13],21,1309151649),h=l(h,p,d,v,t[r+4],6,-145523070),v=l(v,h,p,d,t[r+11],10,-1120210379),d=l(d,v,h,p,t[r+2],15,718787259),p=l(p,d,v,h,t[r+9],21,-343485551),h=i(h,n),p=i(p,o),d=i(d,a),v=i(v,f);return[h,p,d,v]}function h(t){var e,r="",n=32*t.length;for(e=0;e<n;e+=8)r+=String.fromCharCode(t[e>>5]>>>e%32&255);return r}function p(t){var e,r=[];for(r[(t.length>>2)-1]=void 0,e=0;e<r.length;e+=1)r[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)r[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return r}function d(t){var e,r,n="0123456789abcdef",o="";for(r=0;r<t.length;r+=1)e=t.charCodeAt(r),o+=n.charAt(e>>>4&15)+n.charAt(15&e);return o}function v(t){return unescape(encodeURIComponent(t))}function y(t){return function(t){return h(f(p(t),8*t.length))}(v(t))}function _(t,e){return function(t,e){var r,n,o=p(t),i=[],a=[];for(i[15]=a[15]=void 0,o.length>16&&(o=f(o,8*t.length)),r=0;r<16;r+=1)i[r]=909522486^o[r],a[r]=1549556828^o[r];return n=f(i.concat(p(e)),512+8*e.length),h(f(a.concat(n),640))}(v(t),v(e))}function g(t,e,r){return e?r?_(e,t):d(_(e,t)):r?y(t):d(y(t))}void 0===(n=function(){return g}.call(e,r,e,t))||(t.exports=n)}()},147:function(t){"use strict";t.exports=JSON.parse('{"name":"@suprsend/web-sdk","version":"1.5.0-beta.1","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":{"blueimp-md5":"^2.19.0","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].call(i.exports,i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},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(){"use strict";r.r(n),r.d(n,{ChannelLevelPreferenceOptions:function(){return rt},PreferenceOptions:function(){return et},default:function(){return Wt},initialisedAt:function(){return $t}});var t="_suprsend_dist_id",e="_bulk_api_call",o="event/",i="_suprsend_super_props",a="_suprsend_device_id",c={app_launched:"$app_launched",user_login:"$user_login",user_logout:"$user_logout",purchase_made:"$purchase_made"},u={Edge:["Edge"],"Opera Mini":["Opera Mini"],"Opera Mobile":["Opera Mobi"],Opera:["Opera"],"Internet Explorer":["Trident","MSIE"],Chrome:["Chrome","CriOS"],Firefox:["Firefox"],Safari:["Safari"],Mozilla:["Mozilla"]},s={Edge:[/Edge\/([0-9]+(\.[0-9]+)?)/],"Opera Mini":[/Opera Mini\/([0-9]+(\.[0-9]+)?)/],"Opera Mobile":[/Version\/([0-9]+(\.[0-9]+)?)/],Opera:[/Version\/([0-9]+(\.[0-9]+)?)/],"Internet Explorer":["rv:"],Chrome:[/Chrome\/([0-9]+(\.[0-9]+)?)/,/CriOS\/([0-9]+(\.[0-9]+)?)/],Firefox:[/rv:([0-9]+(\.[0-9]+)?)/],Safari:[/Version\/([0-9]+(\.[0-9]+)?)/],Mozilla:[/rv:([0-9]+(\.[0-9]+)?)/]},l={"Chrome OS":"CrOS","Mac OS":"Macintosh",Windows:"Windows",iOS:"like Mac",Android:"Android",Linux:"Linux"},f={email:/\S+@\S+\.\S+/,mobile:/^\+[1-9]\d{1,14}$/};const h={api_url:"https://hub.suprsend.com",sdk_version:r(147).version,batch_size:20,flush_interval:3e3,service_worker_file:"serviceworker.js",sw_delay:5e3,preference_debounce:1e3};var p=r(560),d=r.n(p);function v(t){return v="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},v(t)}function y(){y=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),a=new S(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function f(){}function h(){}function p(){}var d={};c(d,o,(function(){return this}));var _=Object.getPrototypeOf,g=_&&_(_(E([])));g&&g!==e&&r.call(g,o)&&(d=g);var m=p.prototype=f.prototype=Object.create(d);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"==v(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,c(m,"constructor",p),c(p,"constructor",h),h.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(m),c(m,a,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function _(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 g(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){_(i,n,o,a,c,"next",t)}function c(t){_(i,n,o,a,c,"throw",t)}a(void 0)}))}}function m(t){return function(t){if(Array.isArray(t))return b(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 b(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)?b(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 b(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 w=function(t){return new Uint8Array(m(unescape(encodeURIComponent(t))).map((function(t){return t.charCodeAt(0)})))};function x(t,e,r){return O.apply(this,arguments)}function O(){return O=g(y().mark((function t(e,r,n){var i,a,c,u,s,l,f,p,v,_=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=_.length>3&&void 0!==_[3]?_[3]:"/".concat(o),window.crypto){t.next=3;break}return t.abrupt("return");case 3:return a=h.signing_key,c="application/json",u="",e&&(u=d()(e)),s="".concat(n,"\n").concat(u,"\n").concat(c,"\n").concat(r,"\n").concat(i),l=w(a),f=w(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,m(new Uint8Array(v)).map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",window.btoa(String.fromCharCode.apply(String,m(new Uint8Array(v)))));case 18:case"end":return t.stop()}}),t)}))),O.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 S(){S=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(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 O(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,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:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function E(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 j(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){P(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$(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 P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function T(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 A(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){T(i,n,o,a,c,"next",t)}function c(t){T(i,n,o,a,c,"throw",t)}a(void 0)}))}}function N(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=$(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 $(t,e){if(t){if("string"==typeof t)return C(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)?C(t,e):void 0}}function C(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 I(){var t=!0;try{window.localStorage}catch(e){t=!1}return t}function G(t){if(I())return localStorage.getItem(t)}function M(t,e){I()&&localStorage.setItem(t,e)}function F(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=G(t);return r?JSON.parse(r):e}function D(){var t=navigator.userAgent;for(var e in u){var r,n=N(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 U(t,e){return R.apply(this,arguments)}function R(){return R=A(S().mark((function t(e,r){var n,o,i,a,c,u=arguments;return S().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,x(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)}))),R.apply(this,arguments)}function q(){var t=F(e,[]);if(t.length){var r=t.slice(0,h.batch_size);U(o,r).then((function(t){if(!t.ok)throw new Error("Error in Fetch");var r=F(e,[]);r.splice(0,h.batch_size),M(e,JSON.stringify(r)),q()})).catch((function(){z(12e4)}))}else z()}function z(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.flush_interval;setTimeout((function(){q()}),t)}var W=function(t){var e;return t.startsWith("$")||(null==t||null===(e=t.toLowerCase())||void 0===e?void 0:e.startsWith("ss_"))};function Y(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 J={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:I,get_local_storage_item:G,set_local_storage_item:M,remove_local_storage_item:function(t){I()&&localStorage.removeItem(t)},get_parsed_local_store_data:F,browser:D,browser_version:function(){var t=navigator.userAgent,e=D(),r=s[e];if(!r||!e)return"";var n,o=N(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:z,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&&W(a)){console.log("SuprSend: key cannot start with $ or ss_");continue}e[String(a)]=r[a]}}else if(null!=n){if(!i&&W(String(r)))return void console.log("SuprSend: key cannot start with $ or ss_");e=P({},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(I()){var r=F(e,[]);null==r||r.push(t),M(e,JSON.stringify(r))}else U(o,t)},has_special_char:W,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:q,is_internal_event:function(t){return Object.values(c).includes(t)},api:U,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]=Y(t,e,j(j({},r),{},{leading:!0}))),n[c].apply(n,L(u))}}};function B(t){return B="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},B(t)}function K(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 V(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)?V(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 V(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 H(){H=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"==B(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 Q(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 X(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))}}function Z(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 tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var et={OPT_IN:"opt_in",OPT_OUT:"opt_out"},rt={ALL:"all",REQUIRED:"required"},nt=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),tt(this,"_update_category_preferences",X(H().mark((function t(){var e,r,o,i,a,c,u=arguments;return H().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)})))),tt(this,"_update_channel_preferences",X(H().mark((function t(){var e,r,o,i=arguments;return H().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=J.debounce_by_type(this._update_category_preferences,h.preference_debounce),this._debounced_update_channel_preferences=J.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=X(H().mark((function t(){var e,r,n,o,i,a,c,u,s,l,f,p=arguments;return H().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,x("",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=X(H().mark((function t(e,r,n){var o,i,a,c,u,s,l,f,p,d;return H().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,x(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=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().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=X(H().mark((function t(){var e,r,n,o,i=arguments;return H().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=X(H().mark((function t(){var e,r,n,o,i,a=arguments;return H().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=X(H().mark((function t(){var e;return H().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||![et.OPT_IN,et.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=K(this.data.sections);try{for(c.s();!(o=c.n()).done;){var u,s=o.value,l=!1,f=K(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===et.OPT_OUT&&p.push(t.channel)}));var d={preference:t.preference,opt_out_channels:a&&r===et.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(![et.OPT_IN,et.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=K(this.data.sections);try{for(u.s();!(a=u.n()).done;){var s,l=a.value,f=!1,h=K(l.subcategories);try{for(h.s();!(s=h.n()).done;){var p=s.value;if(p.category===o){t=p;var d,v=K(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===et.OPT_IN&&(p.preference=et.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===et.OPT_OUT&&_.push(t.channel)}));var g=null!=i&&i.show_opt_out_channels&&t.preference===et.OPT_OUT&&n===et.OPT_IN?et.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||![rt.ALL,rt.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===rt.REQUIRED,a=K(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&&Z(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const ot=nt;function it(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 at(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach((function(e){ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ct(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 ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var st=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ut(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 ot(this.instance,r)}var e,r;return e=t,r=[{key:"_call_indentity",value:function(t){J.batch_or_call(at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.epoch_milliseconds()},t))}},{key:"_call_flush_immediately",value:function(t){var e=this;J.api(o,at({env:h.env_key,distinct_id:this.instance.distinct_id,$insert_id:J.uuid(),$time:J.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(!J.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=J.format_props({key:t,value:e});J.is_empty(r)||this._call_indentity({$set:r})}},{key:"set_once",value:function(t,e){var r=J.format_props({key:t,value:e});J.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=J.format_props({key:t,value:e}),n=this._convert_to_number(r);J.is_empty(n)||this._call_indentity({$add:n})}},{key:"append",value:function(t,e){var r=this._allow_special_char_events(t),n=J.format_props({key:t,value:e,allow_special_tags:r});J.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=J.format_props({key:t,value:e,allow_special_tags:n});J.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?J.has_special_char(t)?console.log("SuprSend: key cannot start with $ or ss_"):e=[t]:Array.isArray(t)&&(e=[],t.forEach((function(t){J.has_special_char(String(t))||e.push(String(t))}))),J.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&&ct(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const lt=st;function ft(t){return ft="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},ft(t)}function ht(){ht=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"==ft(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 pt(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 dt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pt(i,n,o,a,c,"next",t)}function c(t){pt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function vt(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 yt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t,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),yt(this,"_check_push_support",(function(){return!(!("serviceWorker"in navigator)||!("PushManager"in window))})),yt(this,"_ask_notification_permission",dt(ht().mark((function t(){return ht().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)})))),yt(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)}))})),yt(this,"_get_subscription_without_wait",dt(ht().mark((function t(){var e;return ht().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=dt(ht().mark((function t(e){return ht().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)})))),yt(this,"_get_subscription",(function(){return navigator.serviceWorker.ready.then((function(t){return t.pushManager.getSubscription()})).then(function(){var t=dt(ht().mark((function t(e){return ht().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)}}())})),yt(this,"_subscribe_push",function(){var t=dt(ht().mark((function t(e){var n,o;return ht().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=J.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)}}()),yt(this,"register_push",(function(){r._check_push_support()?r._subscribe_with_delay():console.log("SuprSend: Web Push isn't supported")})),yt(this,"is_subscribed",dt(ht().mark((function t(){var e;return ht().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 lt(e)}var e,r;return e=t,(r=[{key:"_subscribe_with_delay",value:function(){var t=this,e=new Date-$t;e>=h.sw_delay?this._register_sw():(clearTimeout(_t),_t=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}}])&&vt(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();const mt=gt;function bt(t){return bt="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},bt(t)}function wt(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 xt(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ot(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&&Tt(t,e)}function St(t){var e=Pt();return function(){var r,n=At(t);if(e){var o=At(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Et(this,r)}}function Et(t,e){if(e&&("object"===bt(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 jt(t){var e="function"==typeof Map?new Map:void 0;return jt=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 Lt(t,arguments,At(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tt(n,t)},jt(t)}function Lt(t,e,r){return Lt=Pt()?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&&Tt(o,r.prototype),o},Lt.apply(null,arguments)}function Pt(){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 Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}var Nt,$t,Ct=function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendConfigurationError",n}return xt(r)}(function(t){kt(r,t);var e=St(r);function r(t){var n;return Ot(this,r),(n=e.call(this,t)).name="SuprsendError",n}return xt(r)}(jt(Error)));function It(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 Mt(){Mt=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"==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 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 Ft(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 Dt(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 Ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(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 zt=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=J.get_cookie(t);Nt||(Nt={},this._set_custom_config(o)),i||(i=J.uuid(),J.set_cookie(t,i)),Nt.distinct_id=i,this.emitter=It(),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),this.web_push.update_subscription(),e._set_env_properties(),$t||(J.bulk_call_api(),this.track(c.app_launched)),$t=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 Ct("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=J.get_parsed_local_store_data(i),r=Ut(Ut({},e),t),n={};for(var o in r)J.has_special_char(o)||(n[o]=r[o]);J.set_local_storage_item(i,JSON.stringify(n)),Nt.env_properties=Ut(Ut({},Nt.env_properties),n)}},{key:"identify",value:function(e){Nt._user_identified||(J.batch_or_call({env:h.env_key,event:"$identify",$insert_id:J.uuid(),$time:J.epoch_milliseconds(),properties:{$identified_id:e,$anon_id:Nt.distinct_id}}),J.set_cookie(t,e),Nt.distinct_id=e,Nt._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(J.is_internal_event(t)||!J.has_special_char(t)){var r=J.get_parsed_local_store_data(i),n=J.format_props({key:e}),o=Ut(Ut(Ut(Ut({},n),Nt.env_properties),r),{},{$current_url:window.location.href});J.batch_or_call({event:String(t),distinct_id:Nt.distinct_id,env:h.env_key,properties:o,$insert_id:J.uuid(),$time:J.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=Mt().mark((function r(){var n,o,a,u=arguments;return Mt().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=J.uuid(),J.set_cookie(t,a),Nt={distinct_id:a,_user_identified:!1},J.remove_local_storage_item(i),this.user=new lt(Nt,this.emitter),this.web_push=new mt(Nt),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){Ft(o,r,n,i,a,"next",t)}function a(t){Ft(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=J.get_local_storage_item(a);t||(t=J.uuid(),J.set_local_storage_item(a,t)),Nt.env_properties={$os:J.os(),$browser:J.browser(),$browser_version:J.browser_version(),$sdk_type:"Browser",$device_id:t,$sdk_version:h.sdk_version}}}],n&&qt(r.prototype,n),o&&qt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),e}();const Wt=new zt}();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
|
+
"version": "1.5.0-beta.1",
|
|
4
4
|
"description": "This is sdk used to integrate suprsend functionality in javascript applications",
|
|
5
5
|
"main": "dist/cjs_bundle.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"webpack-cli": "^4.8.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"blueimp-md5": "^2.19.0",
|
|
34
35
|
"mitt": "^3.0.0"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/src/encryption.js
CHANGED
|
@@ -1,235 +1,6 @@
|
|
|
1
1
|
import config from "./config";
|
|
2
2
|
import { constants } from "./constants";
|
|
3
|
-
|
|
4
|
-
var MD5 = function (string) {
|
|
5
|
-
function RotateLeft(lValue, iShiftBits) {
|
|
6
|
-
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function AddUnsigned(lX, lY) {
|
|
10
|
-
var lX4, lY4, lX8, lY8, lResult;
|
|
11
|
-
lX8 = lX & 0x80000000;
|
|
12
|
-
lY8 = lY & 0x80000000;
|
|
13
|
-
lX4 = lX & 0x40000000;
|
|
14
|
-
lY4 = lY & 0x40000000;
|
|
15
|
-
lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
|
|
16
|
-
if (lX4 & lY4) {
|
|
17
|
-
return lResult ^ 0x80000000 ^ lX8 ^ lY8;
|
|
18
|
-
}
|
|
19
|
-
if (lX4 | lY4) {
|
|
20
|
-
if (lResult & 0x40000000) {
|
|
21
|
-
return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
|
|
22
|
-
} else {
|
|
23
|
-
return lResult ^ 0x40000000 ^ lX8 ^ lY8;
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
return lResult ^ lX8 ^ lY8;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function F(x, y, z) {
|
|
31
|
-
return (x & y) | (~x & z);
|
|
32
|
-
}
|
|
33
|
-
function G(x, y, z) {
|
|
34
|
-
return (x & z) | (y & ~z);
|
|
35
|
-
}
|
|
36
|
-
function H(x, y, z) {
|
|
37
|
-
return x ^ y ^ z;
|
|
38
|
-
}
|
|
39
|
-
function I(x, y, z) {
|
|
40
|
-
return y ^ (x | ~z);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function FF(a, b, c, d, x, s, ac) {
|
|
44
|
-
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
|
|
45
|
-
return AddUnsigned(RotateLeft(a, s), b);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function GG(a, b, c, d, x, s, ac) {
|
|
49
|
-
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
|
|
50
|
-
return AddUnsigned(RotateLeft(a, s), b);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function HH(a, b, c, d, x, s, ac) {
|
|
54
|
-
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
|
|
55
|
-
return AddUnsigned(RotateLeft(a, s), b);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function II(a, b, c, d, x, s, ac) {
|
|
59
|
-
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
|
|
60
|
-
return AddUnsigned(RotateLeft(a, s), b);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function ConvertToWordArray(string) {
|
|
64
|
-
var lWordCount;
|
|
65
|
-
var lMessageLength = string.length;
|
|
66
|
-
var lNumberOfWords_temp1 = lMessageLength + 8;
|
|
67
|
-
var lNumberOfWords_temp2 =
|
|
68
|
-
(lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
|
|
69
|
-
var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
|
|
70
|
-
var lWordArray = Array(lNumberOfWords - 1);
|
|
71
|
-
var lBytePosition = 0;
|
|
72
|
-
var lByteCount = 0;
|
|
73
|
-
while (lByteCount < lMessageLength) {
|
|
74
|
-
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
|
|
75
|
-
lBytePosition = (lByteCount % 4) * 8;
|
|
76
|
-
lWordArray[lWordCount] =
|
|
77
|
-
lWordArray[lWordCount] |
|
|
78
|
-
(string.charCodeAt(lByteCount) << lBytePosition);
|
|
79
|
-
lByteCount++;
|
|
80
|
-
}
|
|
81
|
-
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
|
|
82
|
-
lBytePosition = (lByteCount % 4) * 8;
|
|
83
|
-
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
|
|
84
|
-
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
|
|
85
|
-
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
|
|
86
|
-
return lWordArray;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function WordToHex(lValue) {
|
|
90
|
-
var WordToHexValue = "",
|
|
91
|
-
WordToHexValue_temp = "",
|
|
92
|
-
lByte,
|
|
93
|
-
lCount;
|
|
94
|
-
for (lCount = 0; lCount <= 3; lCount++) {
|
|
95
|
-
lByte = (lValue >>> (lCount * 8)) & 255;
|
|
96
|
-
WordToHexValue_temp = "0" + lByte.toString(16);
|
|
97
|
-
WordToHexValue =
|
|
98
|
-
WordToHexValue +
|
|
99
|
-
WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
|
|
100
|
-
}
|
|
101
|
-
return WordToHexValue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function Utf8Encode(string) {
|
|
105
|
-
string = string.replace(/\r\n/g, "\n");
|
|
106
|
-
var utftext = "";
|
|
107
|
-
|
|
108
|
-
for (var n = 0; n < string.length; n++) {
|
|
109
|
-
var c = string.charCodeAt(n);
|
|
110
|
-
|
|
111
|
-
if (c < 128) {
|
|
112
|
-
utftext += String.fromCharCode(c);
|
|
113
|
-
} else if (c > 127 && c < 2048) {
|
|
114
|
-
utftext += String.fromCharCode((c >> 6) | 192);
|
|
115
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
116
|
-
} else {
|
|
117
|
-
utftext += String.fromCharCode((c >> 12) | 224);
|
|
118
|
-
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
119
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return utftext;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var x = Array();
|
|
127
|
-
var k, AA, BB, CC, DD, a, b, c, d;
|
|
128
|
-
var S11 = 7,
|
|
129
|
-
S12 = 12,
|
|
130
|
-
S13 = 17,
|
|
131
|
-
S14 = 22;
|
|
132
|
-
var S21 = 5,
|
|
133
|
-
S22 = 9,
|
|
134
|
-
S23 = 14,
|
|
135
|
-
S24 = 20;
|
|
136
|
-
var S31 = 4,
|
|
137
|
-
S32 = 11,
|
|
138
|
-
S33 = 16,
|
|
139
|
-
S34 = 23;
|
|
140
|
-
var S41 = 6,
|
|
141
|
-
S42 = 10,
|
|
142
|
-
S43 = 15,
|
|
143
|
-
S44 = 21;
|
|
144
|
-
|
|
145
|
-
string = Utf8Encode(string);
|
|
146
|
-
|
|
147
|
-
x = ConvertToWordArray(string);
|
|
148
|
-
|
|
149
|
-
a = 0x67452301;
|
|
150
|
-
b = 0xefcdab89;
|
|
151
|
-
c = 0x98badcfe;
|
|
152
|
-
d = 0x10325476;
|
|
153
|
-
|
|
154
|
-
for (k = 0; k < x.length; k += 16) {
|
|
155
|
-
AA = a;
|
|
156
|
-
BB = b;
|
|
157
|
-
CC = c;
|
|
158
|
-
DD = d;
|
|
159
|
-
a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
|
|
160
|
-
d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
|
|
161
|
-
c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
|
|
162
|
-
b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
|
|
163
|
-
a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
|
|
164
|
-
d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
|
|
165
|
-
c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
|
|
166
|
-
b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
|
|
167
|
-
a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
|
|
168
|
-
d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
|
|
169
|
-
c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
|
|
170
|
-
b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
|
|
171
|
-
a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
|
|
172
|
-
d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
|
|
173
|
-
c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
|
|
174
|
-
b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
|
|
175
|
-
a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
|
|
176
|
-
d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
|
|
177
|
-
c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
|
|
178
|
-
b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
|
|
179
|
-
a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
|
|
180
|
-
d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
|
|
181
|
-
c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
|
|
182
|
-
b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
|
|
183
|
-
a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
|
|
184
|
-
d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
|
|
185
|
-
c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
|
|
186
|
-
b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
|
|
187
|
-
a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
|
|
188
|
-
d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
|
|
189
|
-
c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
|
|
190
|
-
b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
|
|
191
|
-
a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
|
|
192
|
-
d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
|
|
193
|
-
c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
|
|
194
|
-
b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
|
|
195
|
-
a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
|
|
196
|
-
d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
|
|
197
|
-
c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
|
|
198
|
-
b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
|
|
199
|
-
a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
|
|
200
|
-
d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
|
|
201
|
-
c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
|
|
202
|
-
b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
|
|
203
|
-
a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
|
|
204
|
-
d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
|
|
205
|
-
c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
|
|
206
|
-
b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
|
|
207
|
-
a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
|
|
208
|
-
d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
|
|
209
|
-
c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
|
|
210
|
-
b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
|
|
211
|
-
a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
|
|
212
|
-
d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
|
|
213
|
-
c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
|
|
214
|
-
b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
|
|
215
|
-
a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
|
|
216
|
-
d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
|
|
217
|
-
c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
|
|
218
|
-
b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
|
|
219
|
-
a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
|
|
220
|
-
d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
|
|
221
|
-
c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
|
|
222
|
-
b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
|
|
223
|
-
a = AddUnsigned(a, AA);
|
|
224
|
-
b = AddUnsigned(b, BB);
|
|
225
|
-
c = AddUnsigned(c, CC);
|
|
226
|
-
d = AddUnsigned(d, DD);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);
|
|
230
|
-
|
|
231
|
-
return temp.toLowerCase();
|
|
232
|
-
};
|
|
3
|
+
import md5 from "blueimp-md5";
|
|
233
4
|
|
|
234
5
|
const getUtf8Bytes = (str) =>
|
|
235
6
|
new Uint8Array(
|
|
@@ -249,7 +20,7 @@ export default async function create_signature(
|
|
|
249
20
|
const content_type = "application/json";
|
|
250
21
|
let md5_str = "";
|
|
251
22
|
if (str) {
|
|
252
|
-
md5_str =
|
|
23
|
+
md5_str = md5(str);
|
|
253
24
|
}
|
|
254
25
|
const message = `${method}\n${md5_str}\n${content_type}\n${date}\n${route}`;
|
|
255
26
|
const keyBytes = getUtf8Bytes(key);
|