HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/slfopp7cb1df/www/sitepacket.com/system/assets/js/push_notification/pusher/pusher.beams.min.js
var PusherPushNotifications=function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e){var t=function e(t,n){if("object"!=r(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,n);if("object"!=r(a))return a;throw TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e,"string");return"symbol"==r(t)?t:t+""}function i(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(u){return void r(u)}s.done?t(c):Promise.resolve(c).then(n,i)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,c,"next",e)}function c(e){a(o,n,i,s,c,"throw",e)}s(void 0)})}}function s(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function c(e,t,r){return t&&function e(t,r){for(var i=0;i<r.length;i++){var a=r[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,n(a.key),a)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var u,h,f,p,l,d={exports:{}},v={exports:{}},y=(l=function e(){if(p)return f;p=1;var t=(h||(h=1,function(e){var t=(u||(u=1,function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(v)),v.exports).default;function r(){e.exports=r=function e(){return i},e.exports.__esModule=!0,e.exports.default=e.exports;var n,i={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",h=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(l){p=function e(t,r,n){return t[r]=n}}function d(e,t,r,i){var a,o,c,u,h=Object.create((t&&t.prototype instanceof m?t:m).prototype);return s(h,"_invoke",{value:(a=e,o=r,c=new L(i||[]),u=y,function(e,t){if(u===g)throw Error("Generator is already running");if(u===w){if("throw"===e)throw t;return{value:n,done:!0}}for(c.method=e,c.arg=t;;){var r=c.delegate;if(r){var i=D(r,c);if(i){if(i===b)continue;return i}}if("next"===c.method)c.sent=c._sent=c.arg;else if("throw"===c.method){if(u===y)throw u=w,c.arg;c.dispatchException(c.arg)}else"return"===c.method&&c.abrupt("return",c.arg);u=g;var s=v(a,o,c);if("normal"===s.type){if(u=c.done?w:"suspendedYield",s.arg===b)continue;return{value:s.arg,done:c.done}}"throw"===s.type&&(u=w,c.method="throw",c.arg=s.arg)}})}),h}function v(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}i.wrap=d;var y="suspendedStart",g="executing",w="completed",b={};function m(){}function x(){}function S(){}var k={};p(k,u,function(){return this});var I=Object.getPrototypeOf,$=I&&I(I(O([])));$&&$!==a&&o.call($,u)&&(k=$);var _=S.prototype=m.prototype=Object.create(k);function P(e){["next","throw","return"].forEach(function(t){p(e,t,function(e){return this._invoke(t,e)})})}function E(e,r){var n;s(this,"_invoke",{value:function i(a,s){function c(){return new r(function(n,i){!function n(i,a,s,c){var u=v(e[i],e,a);if("throw"!==u.type){var h=u.arg,f=h.value;return f&&"object"==t(f)&&o.call(f,"__await")?r.resolve(f.__await).then(function(e){n("next",e,s,c)},function(e){n("throw",e,s,c)}):r.resolve(f).then(function(e){h.value=e,s(h)},function(e){return n("throw",e,s,c)})}c(u.arg)}(a,s,n,i)})}return n=n?n.then(c,c):c()}})}function D(e,t){var r=t.method,i=e.iterator[r];if(i===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=n,D(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=TypeError("The iterator does not provide a '"+r+"' method")),b;var a=v(i,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,b;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,b):o:(t.method="throw",t.arg=TypeError("iterator result is not an object"),t.delegate=null,b)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function t(){for(;++i<e.length;)if(o.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=n,t.done=!0,t};return a.next=a}}throw TypeError(t(e)+" is not iterable")}return x.prototype=S,s(_,"constructor",{value:S,configurable:!0}),s(S,"constructor",{value:x,configurable:!0}),x.displayName=p(S,f,"GeneratorFunction"),i.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===x||"GeneratorFunction"===(t.displayName||t.name))},i.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,f,"GeneratorFunction")),e.prototype=Object.create(_),e},i.awrap=function(e){return{__await:e}},P(E.prototype),p(E.prototype,h,function(){return this}),i.AsyncIterator=E,i.async=function(e,t,r,n,a){void 0===a&&(a=Promise);var o=new E(d(e,t,r,n),a);return i.isGeneratorFunction(t)?o:o.next().then(function(e){return e.done?e.value:o.next()})},P(_),p(_,f,"Generator"),p(_,u,function(){return this}),p(_,"toString",function(){return"[object Generator]"}),i.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},i.values=O,L.prototype={constructor:L,reset:function e(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=n)},stop:function e(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function e(t){if(this.done)throw t;var r=this;function i(e,i){return c.type="throw",c.arg=t,r.next=e,i&&(r.method="next",r.arg=n),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var s=this.tryEntries[a],c=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=o.call(s,"catchLoc"),h=o.call(s,"finallyLoc");if(u&&h){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!h)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function e(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=t,s.arg=r,a?(this.method="next",this.next=a.finallyLoc,b):this.complete(s)},complete:function e(t,r){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&&r&&(this.next=r),b},finish:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),b}},catch:function e(t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var a=i.arg;T(n)}return a}}throw Error("illegal catch attempt")},delegateYield:function e(t,r,i){return this.delegate={iterator:O(t),resultName:r,nextLoc:i},"next"===this.method&&(this.arg=n),b}},i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(d)),d.exports)();f=t;try{regeneratorRuntime=t}catch(r){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return f}())&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l;function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function w(e){var t,r=e.method,n=e.path,a=e.params,s=void 0===a?{}:a,c=e.body,u=void 0===c?null:c,h=e.headers,f=void 0===h?{}:h,p=e.credentials,l={method:r,headers:f,credentials:void 0===p?"same-origin":p};return!function e(t){for(var r in t)return!1;return!0}(s)&&(n+="?",n+=Object.entries(s).filter(function(e){return e[1]}).map(function(e){return e.map(function(e){return encodeURIComponent(e)}).join("=")}).join("&")),null!==u&&(l.body=JSON.stringify(u),l.headers=function e(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?g(Object(n),!0).forEach(function(e){i(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({"Content-Type":"application/json"},f)),fetch(n,l).then((t=o(y.mark(function e(t){return y.wrap(function e(r){for(;;)switch(r.prev=r.next){case 0:if(t.ok){r.next=3;break}return r.next=3,b(t);case 3:return r.prev=3,r.next=6,t.json();case 6:return r.abrupt("return",r.sent);case 9:return r.prev=9,r.t0=r.catch(3),r.abrupt("return",null);case 12:case"end":return r.stop()}},e,null,[[3,9]])})),function(e){return t.apply(this,arguments)}))}function b(e){return m.apply(this,arguments)}function m(){return(m=o(y.mark(function e(t){var r,n,i,a,o,s;return y.wrap(function e(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,t.json();case 3:a=void 0===(i=(n=c.sent).error)?"Unknown error":i,s=void 0===(o=n.description)?"No description":o,r="Unexpected status code ".concat(t.status,": ").concat(a,", ").concat(s),c.next=14;break;case 11:c.prev=11,c.t0=c.catch(0),r="Unexpected status code ".concat(t.status,": Cannot parse error response");case 14:throw Error(r);case 15:case"end":return c.stop()}},e,null,[[0,11]])}))).apply(this,arguments)}function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var k=function(){var e;function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.url,n=e.queryParams,i=e.headers,a=e.credentials;s(this,t),this.url=r,this.queryParams=n,this.headers=i,this.credentials=a}return c(t,[{key:"fetchToken",value:(e=o(y.mark(function e(t){var r,n,i,a;return y.wrap(function e(o){for(;;)switch(o.prev=o.next){case 0:return n=Object.entries(r=S({user_id:t},this.queryParams)).map(function(e){return e.map(encodeURIComponent).join("=")}).join("&"),i={method:"GET",path:"".concat(this.url,"?").concat(n),headers:this.headers,credentials:this.credentials},o.next=5,w(i);case 5:return a=o.sent,o.abrupt("return",a);case 7:case"end":return o.stop()}},e,this)})),function t(r){return e.apply(this,arguments)})}])}(),I=function(){var e,t;function r(e){s(this,r),this._instanceId=e,this._dbConn=null}return c(r,[{key:"_dbName",get:function e(){return"beams-".concat(this._instanceId)}},{key:"isConnected",get:function e(){return null!==this._dbConn}},{key:"connect",value:function e(){var t=this;return new Promise(function(e,r){var n=indexedDB.open(t._dbName);n.onsuccess=function(r){var n=r.target.result;t._dbConn=n,t._readState().then(function(e){return null===e?t.clear():Promise.resolve()}).then(e)},n.onupgradeneeded=function(e){e.target.result.createObjectStore("beams",{keyPath:"instance_id"})},n.onerror=function(e){r(Error("Database error: ".concat(e.target.error)))}})}},{key:"clear",value:function e(){return this._writeState({instance_id:this._instanceId,device_id:null,token:null,user_id:null})}},{key:"_readState",value:function e(){var t=this;if(!this.isConnected)throw Error("Cannot read value: DeviceStateStore not connected to IndexedDB");return new Promise(function(e,r){var n=t._dbConn.transaction("beams").objectStore("beams").get(t._instanceId);n.onsuccess=function(t){var r=t.target.result;r||e(null),e(r)},n.onerror=function(e){r(e.target.error)}})}},{key:"_readProperty",value:(e=o(y.mark(function e(t){var r;return y.wrap(function e(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this._readState();case 2:if(null!==(r=n.sent)){n.next=5;break}return n.abrupt("return",null);case 5:return n.abrupt("return",r[t]||null);case 6:case"end":return n.stop()}},e,this)})),function t(r){return e.apply(this,arguments)})},{key:"_writeState",value:function e(t){var r=this;if(!this.isConnected)throw Error("Cannot write value: DeviceStateStore not connected to IndexedDB");return new Promise(function(e,n){var i=r._dbConn.transaction("beams","readwrite").objectStore("beams").put(t);i.onsuccess=function(t){e()},i.onerror=function(e){n(e.target.error)}})}},{key:"_writeProperty",value:(t=o(y.mark(function e(t,r){var n;return y.wrap(function e(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._readState();case 2:return(n=i.sent)[t]=r,i.next=6,this._writeState(n);case 6:case"end":return i.stop()}},e,this)})),function e(r,n){return t.apply(this,arguments)})},{key:"getToken",value:function e(){return this._readProperty("token")}},{key:"setToken",value:function e(t){return this._writeProperty("token",t)}},{key:"getDeviceId",value:function e(){return this._readProperty("device_id")}},{key:"setDeviceId",value:function e(t){return this._writeProperty("device_id",t)}},{key:"getUserId",value:function e(){return this._readProperty("user_id")}},{key:"setUserId",value:function e(t){return this._writeProperty("user_id",t)}},{key:"getLastSeenSdkVersion",value:function e(){return this._readProperty("last_seen_sdk_version")}},{key:"setLastSeenSdkVersion",value:function e(t){return this._writeProperty("last_seen_sdk_version",t)}},{key:"getLastSeenUserAgent",value:function e(){return this._readProperty("last_seen_user_agent")}},{key:"setLastSeenUserAgent",value:function e(t){return this._writeProperty("last_seen_user_agent",t)}}])}(),$="2.1.0";function _(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function e(t,r){if(t){if("string"==typeof t)return P(t,r);var n=({}).toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?P(t,r):void 0}}(e))||t){r&&(e=r);var n=0,i=function e(){};return{s:i,n:function t(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function e(t){throw t},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function t(){r=r.call(e)},n:function e(){var t=r.next();return o=t.done,t},e:function e(t){s=!0,a=t},f:function e(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function D(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var R=RegExp("^(_|\\-|=|@|,|\\.|;|[A-Z]|[a-z]|[0-9])*$"),T="/index.php/pwa/service_worker?pusherBeamsWebSDKVersion=".concat($),L=Object.freeze({PERMISSION_PROMPT_REQUIRED:"PERMISSION_PROMPT_REQUIRED",PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS:"PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS",PERMISSION_GRANTED_REGISTERED_WITH_BEAMS:"PERMISSION_GRANTED_REGISTERED_WITH_BEAMS",PERMISSION_DENIED:"PERMISSION_DENIED"}),O=function(){var e,t,r,n,i,a,u,h,f,p,l,d,v,g,b,m,x,S,k,P,E,R;function T(e){if(s(this,T),!e)throw Error("Config object required");var t=e.instanceId,r=e.endpointOverride,n=e.serviceWorkerRegistration;if(void 0===t)throw Error("Instance ID is required");if("string"!=typeof t)throw Error("Instance ID must be a string");if(0===t.length)throw Error("Instance ID cannot be empty");if(!("indexedDB"in window))throw Error("Pusher Beams does not support this browser version (IndexedDB not supported)");if(!window.isSecureContext)throw Error("Pusher Beams relies on Service Workers, which only work in secure contexts. Check that your page is being served from localhost/over HTTPS");if(!("serviceWorker"in navigator))throw Error("Pusher Beams does not support this browser version (Service Workers not supported)");if(!("PushManager"in window))throw Error("Pusher Beams does not support this browser version (Web Push not supported)");this.instanceId=t,this._deviceId=null,this._token=null,this._userId=null,this._serviceWorkerRegistration=void 0===n?null:n,this._deviceStateStore=new I(t),this._endpoint=void 0===r?null:r,this._ready=this._init()}return c(T,[{key:"_init",value:(e=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:if(!(null!==this._deviceId)){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._deviceStateStore.connect();case 4:if(!this._serviceWorkerRegistration){t.next=9;break}return t.next=7,window.navigator.serviceWorker.ready;case 7:t.next=12;break;case 9:return t.next=11,M();case 11:this._serviceWorkerRegistration=t.sent;case 12:return t.next=14,this._detectSubscriptionChange();case 14:return t.next=16,this._deviceStateStore.getDeviceId();case 16:return this._deviceId=t.sent,t.next=19,this._deviceStateStore.getToken();case 19:return this._token=t.sent,t.next=22,this._deviceStateStore.getUserId();case 22:this._userId=t.sent;case 23:case"end":return t.stop()}},e,this)})),function t(){return e.apply(this,arguments)})},{key:"_resolveSDKState",value:(t=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._ready;case 2:return t.next=4,this._detectSubscriptionChange();case 4:case"end":return t.stop()}},e,this)})),function e(){return t.apply(this,arguments)})},{key:"_detectSubscriptionChange",value:(r=o(y.mark(function e(){var t,r,n;return y.wrap(function e(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._deviceStateStore.getToken();case 2:return t=i.sent,i.next=5,U(this._serviceWorkerRegistration);case 5:if(!(n=t!==(r=i.sent))){i.next=13;break}return i.next=10,this._deviceStateStore.clear();case 10:this._deviceId=null,this._token=null,this._userId=null;case 13:case"end":return i.stop()}},e,this)})),function e(){return r.apply(this,arguments)})},{key:"getDeviceId",value:(n=o(y.mark(function e(){var t=this;return y.wrap(function e(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._resolveSDKState();case 2:return r.abrupt("return",this._ready.then(function(){return t._deviceId}));case 3:case"end":return r.stop()}},e,this)})),function e(){return n.apply(this,arguments)})},{key:"getToken",value:(i=o(y.mark(function e(){var t=this;return y.wrap(function e(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._resolveSDKState();case 2:return r.abrupt("return",this._ready.then(function(){return t._token}));case 3:case"end":return r.stop()}},e,this)})),function e(){return i.apply(this,arguments)})},{key:"getUserId",value:(a=o(y.mark(function e(){var t=this;return y.wrap(function e(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._resolveSDKState();case 2:return r.abrupt("return",this._ready.then(function(){return t._userId}));case 3:case"end":return r.stop()}},e,this)})),function e(){return a.apply(this,arguments)})},{key:"_baseURL",get:function e(){return null!==this._endpoint?this._endpoint:"https://".concat(this.instanceId,".pushnotifications.pusher.com")}},{key:"_throwIfNotStarted",value:function e(t){if(!this._deviceId)throw Error("".concat(t,". SDK not registered with Beams. Did you call .start?"))}},{key:"start",value:(u=o(y.mark(function e(){var t,r,n,i;return y.wrap(function e(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._resolveSDKState();case 2:if(j()){a.next=4;break}return a.abrupt("return",this);case 4:if(!(null!==this._deviceId)){a.next=6;break}return a.abrupt("return",this);case 6:return a.next=8,this._getPublicKey();case 8:return r=(t=a.sent).vapidPublicKey,a.next=12,this._getPushToken(r);case 12:return n=a.sent,a.next=15,this._registerDevice(n);case 15:return i=a.sent,a.next=18,this._deviceStateStore.setToken(n);case 18:return a.next=20,this._deviceStateStore.setDeviceId(i);case 20:return a.next=22,this._deviceStateStore.setLastSeenSdkVersion($);case 22:return a.next=24,this._deviceStateStore.setLastSeenUserAgent(window.navigator.userAgent);case 24:return this._token=n,this._deviceId=i,a.abrupt("return",this);case 27:case"end":return a.stop()}},e,this)})),function e(){return u.apply(this,arguments)})},{key:"getRegistrationState",value:(h=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._resolveSDKState();case 2:if("denied"!==Notification.permission){t.next=4;break}return t.abrupt("return",L.PERMISSION_DENIED);case 4:if(!("granted"===Notification.permission&&null!==this._deviceId)){t.next=6;break}return t.abrupt("return",L.PERMISSION_GRANTED_REGISTERED_WITH_BEAMS);case 6:if(!("granted"===Notification.permission&&null===this._deviceId)){t.next=8;break}return t.abrupt("return",L.PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS);case 8:return t.abrupt("return",L.PERMISSION_PROMPT_REQUIRED);case 9:case"end":return t.stop()}},e,this)})),function e(){return h.apply(this,arguments)})},{key:"addDeviceInterest",value:(f=o(y.mark(function e(t){var r,n;return y.wrap(function e(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._resolveSDKState();case 2:return this._throwIfNotStarted("Could not add Device Interest"),N(t),n={method:"POST",path:r="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/interests/").concat(encodeURIComponent(t))},i.next=8,w(n);case 8:case"end":return i.stop()}},e,this)})),function e(t){return f.apply(this,arguments)})},{key:"removeDeviceInterest",value:(p=o(y.mark(function e(t){var r,n;return y.wrap(function e(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this._resolveSDKState();case 2:return this._throwIfNotStarted("Could not remove Device Interest"),N(t),n={method:"DELETE",path:r="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/interests/").concat(encodeURIComponent(t))},i.next=8,w(n);case 8:case"end":return i.stop()}},e,this)})),function e(t){return p.apply(this,arguments)})},{key:"getDeviceInterests",value:(l=o(y.mark(function e(){var t,r,n,i,a,o=arguments;return y.wrap(function e(s){for(;;)switch(s.prev=s.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:100,r=o.length>1&&void 0!==o[1]?o[1]:null,s.next=4,this._resolveSDKState();case 4:return this._throwIfNotStarted("Could not get Device Interests"),i={method:"GET",path:n="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/interests"),params:{limit:t,cursor:r}},s.next=9,w(i);case 9:return a=D({interests:(a=s.sent)&&a.interests||[]},a&&a.responseMetadata||{}),s.abrupt("return",a);case 12:case"end":return s.stop()}},e,this)})),function e(){return l.apply(this,arguments)})},{key:"setDeviceInterests",value:(d=o(y.mark(function e(t){var r,n,i,a,o,s;return y.wrap(function e(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._resolveSDKState();case 2:if(this._throwIfNotStarted("Could not set Device Interests"),null!=t){c.next=5;break}throw Error("interests argument is required");case 5:if(Array.isArray(t)){c.next=7;break}throw Error("interests argument must be an array");case 7:if(!(t.length>5e3)){c.next=9;break}throw Error("Number of interests (".concat(t.length,") exceeds maximum of ").concat(5e3));case 9:r=_(t);try{for(r.s();!(n=r.n()).done;)i=n.value,N(i)}catch(u){r.e(u)}finally{r.f()}return a=Array.from(new Set(t)),s={method:"PUT",path:o="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/interests"),body:{interests:a}},c.next=16,w(s);case 16:case"end":return c.stop()}},e,this)})),function e(t){return d.apply(this,arguments)})},{key:"clearDeviceInterests",value:(v=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._resolveSDKState();case 2:return this._throwIfNotStarted("Could not clear Device Interests"),t.next=5,this.setDeviceInterests([]);case 5:case"end":return t.stop()}},e,this)})),function e(){return v.apply(this,arguments)})},{key:"setUserId",value:(g=o(y.mark(function e(t,r){var n,i,a,o,s;return y.wrap(function e(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._resolveSDKState();case 2:if(j()){c.next=4;break}return c.abrupt("return");case 4:if(null!==this._deviceId){c.next=7;break}return n=Error(".start must be called before .setUserId"),c.abrupt("return",Promise.reject(n));case 7:if(!("string"!=typeof t)){c.next=9;break}throw Error("User ID must be a string (was ".concat(t,")"));case 9:if(""!==t){c.next=11;break}throw Error("User ID cannot be the empty string");case 11:if(!(null!==this._userId&&this._userId!==t)){c.next=13;break}throw Error("Changing the `userId` is not allowed.");case 13:return i="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/user"),c.next=16,r.fetchToken(t);case 16:return o=(a=c.sent).token,s={method:"PUT",path:i,headers:{Authorization:"Bearer ".concat(o)}},c.next=21,w(s);case 21:return this._userId=t,c.abrupt("return",this._deviceStateStore.setUserId(t));case 23:case"end":return c.stop()}},e,this)})),function e(t,r){return g.apply(this,arguments)})},{key:"stop",value:(b=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._resolveSDKState();case 2:if(j()){t.next=4;break}return t.abrupt("return");case 4:if(null!==this._deviceId){t.next=6;break}return t.abrupt("return");case 6:return t.next=8,this._deleteDevice();case 8:return t.next=10,this._deviceStateStore.clear();case 10:this._clearPushToken().catch(function(){}),this._deviceId=null,this._token=null,this._userId=null;case 14:case"end":return t.stop()}},e,this)})),function e(){return b.apply(this,arguments)})},{key:"clearAllState",value:(m=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:if(j()){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.stop();case 4:return t.next=6,this.start();case 6:case"end":return t.stop()}},e,this)})),function e(){return m.apply(this,arguments)})},{key:"_getPublicKey",value:(x=o(y.mark(function e(){var t,r;return y.wrap(function e(n){for(;;)switch(n.prev=n.next){case 0:return r={method:"GET",path:t="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/web-vapid-public-key")},n.abrupt("return",w(r));case 3:case"end":return n.stop()}},e,this)})),function e(){return x.apply(this,arguments)})},{key:"_getPushToken",value:(S=o(y.mark(function e(t){var r;return y.wrap(function e(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this._clearPushToken();case 3:return n.next=5,this._serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:C(t)});case 5:return r=n.sent,n.abrupt("return",btoa(JSON.stringify(r)));case 9:return n.prev=9,n.t0=n.catch(0),n.abrupt("return",Promise.reject(n.t0));case 12:case"end":return n.stop()}},e,this,[[0,9]])})),function e(t){return S.apply(this,arguments)})},{key:"_clearPushToken",value:(k=o(y.mark(function e(){return y.wrap(function e(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",navigator.serviceWorker.ready.then(function(e){return e.pushManager.getSubscription()}).then(function(e){e&&e.unsubscribe()}));case 1:case"end":return t.stop()}},e)})),function e(){return k.apply(this,arguments)})},{key:"_registerDevice",value:(P=o(y.mark(function e(t){var r,n,i,a;return y.wrap(function e(o){for(;;)switch(o.prev=o.next){case 0:return r="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web"),n={token:t,metadata:{sdkVersion:$}},i={method:"POST",path:r,body:n},o.next=5,w(i);case 5:return a=o.sent,o.abrupt("return",a.id);case 7:case"end":return o.stop()}},e,this)})),function e(t){return P.apply(this,arguments)})},{key:"_deleteDevice",value:(E=o(y.mark(function e(){var t,r;return y.wrap(function e(n){for(;;)switch(n.prev=n.next){case 0:return r={method:"DELETE",path:t="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(encodeURIComponent(this._deviceId))},n.next=4,w(r);case 4:case"end":return n.stop()}},e,this)})),function e(){return E.apply(this,arguments)})},{key:"_updateDeviceMetadata",value:(R=o(y.mark(function e(){var t,r,n,i,a,o;return y.wrap(function e(s){for(;;)switch(s.prev=s.next){case 0:return t=window.navigator.userAgent,s.next=3,this._deviceStateStore.getLastSeenUserAgent();case 3:return r=s.sent,s.next=6,this._deviceStateStore.getLastSeenSdkVersion();case 6:if(n=s.sent,!(t===r&&$===n)){s.next=9;break}return s.abrupt("return");case 9:return i="".concat(this._baseURL,"/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId),"/devices/web/").concat(this._deviceId,"/metadata"),a={sdkVersion:$},o={method:"PUT",path:i,body:a},s.next=14,w(o);case 14:return s.next=16,this._deviceStateStore.setLastSeenSdkVersion($);case 16:return s.next=18,this._deviceStateStore.setLastSeenUserAgent(t);case 18:case"end":return s.stop()}},e,this)})),function e(){return R.apply(this,arguments)})}])}(),N=function e(t){if(null==t)throw Error("Interest name is required");if("string"!=typeof t)throw Error("Interest ".concat(t," is not a string"));if(!R.test(t))throw Error('interest "'.concat(t,'" contains a forbidden character. ')+"Allowed characters are: ASCII upper/lower-case letters, numbers or one of _-=@,.;");if(t.length>164)throw Error("Interest is longer than the maximum of ".concat(164," chars"))};function M(){return A.apply(this,arguments)}function A(){return(A=o(y.mark(function e(){var t,r;return y.wrap(function e(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,fetch(T);case 2:if(!(200!==(r=(t=n.sent).status))){n.next=6;break}throw Error("Cannot start SDK, service worker missing: No file found at /service-worker.js");case 6:return window.navigator.serviceWorker.register(T,{updateViaCache:"none"}),n.abrupt("return",window.navigator.serviceWorker.ready);case 8:case"end":return n.stop()}},e)}))).apply(this,arguments)}function U(e){return e.pushManager.getSubscription().then(function(e){var t;return e?(t=e,btoa(JSON.stringify(t))):null})}function C(e){var r,n="=".repeat((4-e.length%4)%4),i=(e+n).replace(/-/g,"+").replace(/_/g,"/"),a=window.atob(i);return Uint8Array.from(((function e(r){if(Array.isArray(r))return t(r)})(r=a)||function e(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function e(r,n){if(r){if("string"==typeof r)return t(r,n);var i=({}).toString.call(r).slice(8,-1);return"Object"===i&&r.constructor&&(i=r.constructor.name),"Map"===i||"Set"===i?Array.from(r):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(r,n):void 0}}(r)||function e(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){return e.charCodeAt(0)}))}function j(){var e="Notification"in window,t="PushManager"in window,r="serviceWorker"in navigator;return!!e&&!!t&&!!r||(console.warn("Missing required Web Push APIs. Please upgrade your browser"),!1)}return e.Client=O,e.RegistrationState=L,e.TokenProvider=k,e}({});