1/*! jQuery Migrate v3.4.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */ 2"undefined"==typeof jQuery.migrateMute&&(jQuery.migrateMute=!0),function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e,window)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery"),window):t(jQuery,window)}(function(s,n){"use strict";function e(e){return 0<=function(e,t){for(var r=/^(\d+)\.(\d+)\.(\d+)/,n=r.exec(e)||[],o=r.exec(t)||[],a=1;a<=3;a++){if(+o[a]<+n[a])return 1;if(+n[a]<+o[a])return-1}return 0}(s.fn.jquery,e)}s.migrateVersion="3.4.1";var t=Object.create(null);s.migrateDisablePatches=function(){for(var e=0;e<arguments.length;e++)t[arguments[e]]=!0},s.migrateEnablePatches=function(){for(var e=0;e<arguments.length;e++)delete t[arguments[e]]},s.migrateIsPatchEnabled=function(e){return!t[e]},n.console&&n.console.log&&(s&&e("3.0.0")&&!e("5.0.0")||n.console.log("JQMIGRATE: jQuery 3.x-4.x REQUIRED"),s.migrateWarnings&&n.console.log("JQMIGRATE: Migrate plugin loaded multiple times"),n.console.log("JQMIGRATE: Migrate is installed"+(s.migrateMute?"":" with logging active")+", version "+s.migrateVersion));var o={};function u(e,t){var r=n.console;!s.migrateIsPatchEnabled(e)||s.migrateDeduplicateWarnings&&o[t]||(o[t]=!0,s.migrateWarnings.push(t+" ["+e+"]"),r&&r.warn&&!s.migrateMute&&(r.warn("JQMIGRATE: "+t),s.migrateTrace&&r.trace&&r.trace()))}function r(e,t,r,n,o){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return u(n,o),r},set:function(e){u(n,o),r=e}})}function a(e,t,r,n,o){var a=e[t];e[t]=function(){return o&&u(n,o),(s.migrateIsPatchEnabled(n)?r:a||s.noop).apply(this,arguments)}}function c(e,t,r,n,o){if(!o)throw new Error("No warning message provided");return a(e,t,r,n,o),0}function i(e,t,r,n){return a(e,t,r,n),0}s.migrateDeduplicateWarnings=!0,s.migrateWarnings=[],void 0===s.migrateTrace&&(s.migrateTrace=!0),s.migrateReset=function(){o={},s.migrateWarnings.length=0},"BackCompat"===n.document.compatMode&&u("quirks","jQuery is not compatible with Quirks Mode");var d,l,p,f={},m=s.fn.init,y=s.find,h=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,g=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,v=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;for(d in i(s.fn,"init",function(e){var t=Array.prototype.slice.call(arguments);return s.migrateIsPatchEnabled("selector-empty-id")&&"string"==typeof e&&"#"===e&&(u("selector-empty-id","jQuery( '#' ) is not a valid selector"),t[0]=[]),m.apply(this,t)},"selector-empty-id"),s.fn.init.prototype=s.fn,i(s,"find",function(t){var r=Array.prototype.slice.call(arguments);if("string"==typeof t&&h.test(t))try{n.document.querySelector(t)}catch(e){t=t.replace(g,function(e,t,r,n){return"["+t+r+'"'+n+'"]'});try{n.document.querySelector(t),u("selector-hash","Attribute selector with '#' must be quoted: "+r[0]),r[0]=t}catch(e){u("selector-hash","Attribute selector with '#' was not fixed: "+r[0])}}return y.apply(this,r)},"selector-hash"),y)Object.prototype.hasOwnProperty.call(y,d)&&(s.find[d]=y[d]);c(s.fn,"size",function(){return this.length},"size","jQuery.fn.size() is deprecated and removed; use the .length property"),c(s,"parseJSON",function(){return JSON.parse.apply(null,arguments)},"parseJSON","jQuery.parseJSON is deprecated; use JSON.parse"),c(s,"holdReady",s.holdReady,"holdReady","jQuery.holdReady is deprecated"),c(s,"unique",s.uniqueSort,"unique","jQuery.unique is deprecated; use jQuery.uniqueSort"),r(s.expr,"filters",s.expr.pseudos,"expr-pre-pseudos","jQuery.expr.filters is deprecated; use jQuery.expr.pseudos"),r(s.expr,":",s.expr.pseudos,"expr-pre-pseudos","jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos"),e("3.1.1")&&c(s,"trim",function(e){return null==e?"":(e+"").replace(v,"$1")},"trim","jQuery.trim is deprecated; use String.prototype.trim"),e("3.2.0")&&(c(s,"nodeName",function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},"nodeName","jQuery.nodeName is deprecated"),c(s,"isArray",Array.isArray,"isArray","jQuery.isArray is deprecated; use Array.isArray")),e("3.3.0")&&(c(s,"isNumeric",function(e){var t=typeof e;return("number"==t||"string"==t)&&!isNaN(e-parseFloat(e))},"isNumeric","jQuery.isNumeric() is deprecated"),s.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){f["[object "+t+"]"]=t.toLowerCase()}),c(s,"type",function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?f[Object.prototype.toString.call(e)]||"object":typeof e},"type","jQuery.type is deprecated"),c(s,"isFunction",function(e){return"function"==typeof e},"isFunction","jQuery.isFunction() is deprecated"),c(s,"isWindow",function(e){return null!=e&&e===e.window}
2,"isWindow","jQuery.isWindow() is deprecated")),s.ajax&&(l=s.ajax,p=/(=)\?(?=&|$)|\?\?/,i(s,"ajax",function(){var e=l.apply(this,arguments);return e.promise&&(c(e,"success",e.done,"jqXHR-methods","jQXHR.success is deprecated and removed"),c(e,"error",e.fail,"jqXHR-methods","jQXHR.error is deprecated and removed"),c(e,"complete",e.always,"jqXHR-methods","jQXHR.complete is deprecated and removed")),e},"jqXHR-methods"),e("4.0.0")||s.ajaxPrefilter("+json",function(e){!1!==e.jsonp&&(p.test(e.url)||"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&p.test(e.data))&&u("jsonp-promotion","JSON-to-JSONP auto-promotion is deprecated")}));var j=s.fn.removeAttr,b=s.fn.toggleClass,w=/\S+/g;function x(e){return e.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()})}i(s.fn,"removeAttr",function(e){var r=this,n=!1;return s.each(e.match(w),function(e,t){s.expr.match.bool.test(t)&&r.each(function(){if(!1!==s(this).prop(t))return!(n=!0)}),n&&(u("removeAttr-bool","jQuery.fn.removeAttr no longer sets boolean properties: "+t),r.prop(t,!1))}),j.apply(this,arguments)},"removeAttr-bool"),i(s.fn,"toggleClass",function(t){return void 0!==t&&"boolean"!=typeof t?b.apply(this,arguments):(u("toggleClass-bool","jQuery.fn.toggleClass( boolean ) is deprecated"),this.each(function(){var e=this.getAttribute&&this.getAttribute("class")||"";e&&s.data(this,"__className__",e),this.setAttribute&&this.setAttribute("class",!e&&!1!==t&&s.data(this,"__className__")||"")}))},"toggleClass-bool");var Q,A,R=!1,C=/^[a-z]/,N=/^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;s.swap&&s.each(["height","width","reliableMarginRight"],function(e,t){var r=s.cssHooks[t]&&s.cssHooks[t].get;r&&(s.cssHooks[t].get=function(){var e;return R=!0,e=r.apply(this,arguments),R=!1,e})}),i(s,"swap",function(e,t,r,n){var o,a,i={};for(a in R||u("swap","jQuery.swap() is undocumented and deprecated"),t)i[a]=e.style[a],e.style[a]=t[a];for(a in o=r.apply(e,n||[]),t)e.style[a]=i[a];return o},"swap"),e("3.4.0")&&"undefined"!=typeof Proxy&&(s.cssProps=new Proxy(s.cssProps||{},{set:function(){return u("cssProps","jQuery.cssProps is deprecated"),Reflect.set.apply(this,arguments)}})),e("4.0.0")?(A={animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},"undefined"!=typeof Proxy?s.cssNumber=new Proxy(A,{get:function(){return u("css-number","jQuery.cssNumber is deprecated"),Reflect.get.apply(this,arguments)},set:function(){return u("css-number","jQuery.cssNumber is deprecated"),Reflect.set.apply(this,arguments)}}):s.cssNumber=A):A=s.cssNumber,Q=s.fn.css,i(s.fn,"css",function(e,t){var r,n,o=this;return e&&"object"==typeof e&&!Array.isArray(e)?(s.each(e,function(e,t){s.fn.css.call(o,e,t)}),this):("number"==typeof t&&(r=x(e),n=r,C.test(n)&&N.test(n[0].toUpperCase()+n.slice(1))||A[r]||u("css-number",'Number-typed values are deprecated for jQuery.fn.css( "'+e+'", value )')),Q.apply(this,arguments))},"css-number");var S,P,k,H,E=s.data;i(s,"data",function(e,t,r){var n,o,a;if(t&&"object"==typeof t&&2===arguments.length){for(a in n=s.hasData(e)&&E.call(this,e),o={},t)a!==x(a)?(u("data-camelCase","jQuery.data() always sets/gets camelCased names: "+a),n[a]=t[a]):o[a]=t[a];return E.call(this,e,o),t}return t&&"string"==typeof t&&t!==x(t)&&(n=s.hasData(e)&&E.call(this,e))&&t in n?(u("data-camelCase","jQuery.data() always sets/gets camelCased names: "+t),2<arguments.length&&(n[t]=r),n[t]):E.apply(this,arguments)},"data-camelCase"),s.fx&&(k=s.Tween.prototype.run,H=function(e){return e},i(s.Tween.prototype,"run",function(){1<s.easing[this.easing].length&&(u("easing-one-arg","'jQuery.easing."+this.easing.toString()+"' should use only one argument"),s.easing[this.easing]=H),k.apply(this,arguments)},"easing-one-arg"),S=s.fx.interval,P="jQuery.fx.interval is deprecated",n.requestAnimationFrame&&Object.defineProperty(s.fx,"interval",{configurable:!0,enumerable:!0,get:function(){return n.document.hidden||u("fx-interval",P),s.migrateIsPatchEnabled("fx-interval")&&void 0===S?13:S},set:function(e){u("fx-interval",P),S=e}}));var M=s.fn.load,q=s.event.add,O=s.event.fix;s.event.props=[],s.event.fixHooks={}
2,r(s.event.props,"concat",s.event.props.concat,"event-old-patch","jQuery.event.props.concat() is deprecated and removed"),i(s.event,"fix",function(e){var t,r=e.type,n=this.fixHooks[r],o=s.event.props;if(o.length){u("event-old-patch","jQuery.event.props are deprecated and removed: "+o.join());while(o.length)s.event.addProp(o.pop())}if(n&&!n._migrated_&&(n._migrated_=!0,u("event-old-patch","jQuery.event.fixHooks are deprecated and removed: "+r),(o=n.props)&&o.length))while(o.length)s.event.addProp(o.pop());return t=O.call(this,e),n&&n.filter?n.filter(t,e):t},"event-old-patch"),i(s.event,"add",function(e,t){return e===n&&"load"===t&&"complete"===n.document.readyState&&u("load-after-event","jQuery(window).on('load'...) called after load event occurred"),q.apply(this,arguments)},"load-after-event"),s.each(["load","unload","error"],function(e,t){i(s.fn,t,function(){var e=Array.prototype.slice.call(arguments,0);return"load"===t&&"string"==typeof e[0]?M.apply(this,e):(u("shorthand-removed-v3","jQuery.fn."+t+"() is deprecated"),e.splice(0,0,t),arguments.length?this.on.apply(this,e):(this.triggerHandler.apply(this,e),this))},"shorthand-removed-v3")}),s.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,r){c(s.fn,r,function(e,t){return 0<arguments.length?this.on(r,null,e,t):this.trigger(r)},"shorthand-deprecated-v3","jQuery.fn."+r+"() event shorthand is deprecated")}),s(function(){s(n.document).triggerHandler("ready")}),s.event.special.ready={setup:function(){this===n.document&&u("ready-event","'ready' event is deprecated")}},c(s.fn,"bind",function(e,t,r){return this.on(e,null,t,r)},"pre-on-methods","jQuery.fn.bind() is deprecated"),c(s.fn,"unbind",function(e,t){return this.off(e,null,t)},"pre-on-methods","jQuery.fn.unbind() is deprecated"),c(s.fn,"delegate",function(e,t,r,n){return this.on(t,e,r,n)},"pre-on-methods","jQuery.fn.delegate() is deprecated"),c(s.fn,"undelegate",function(e,t,r){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",r)},"pre-on-methods","jQuery.fn.undelegate() is deprecated"),c(s.fn,"hover",function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)},"pre-on-methods","jQuery.fn.hover() is deprecated");function T(e){var t=n.document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body&&t.body.innerHTML}var F=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi;s.UNSAFE_restoreLegacyHtmlPrefilter=function(){s.migrateEnablePatches("self-closed-tags")},i(s,"htmlPrefilter",function(e){var t,r;return(r=(t=e).replace(F,"<$1></$2>"))!==t&&T(t)!==T(r)&&u("self-closed-tags","HTML tags must be properly nested and closed: "+t),e.replace(F,"<$1></$2>")},"self-closed-tags"),s.migrateDisablePatches("self-closed-tags");var D,W,_,I=s.fn.offset;return i(s.fn,"offset",function(){var e=this[0];return!e||e.nodeType&&e.getBoundingClientRect?I.apply(this,arguments):(u("offset-valid-elem","jQuery.fn.offset() requires a valid DOM element"),arguments.length?this:void 0)},"offset-valid-elem"),s.ajax&&(D=s.param,i(s,"param",function(e,t){var r=s.ajaxSettings&&s.ajaxSettings.traditional;return void 0===t&&r&&(u("param-ajax-traditional","jQuery.param() no longer uses jQuery.ajaxSettings.traditional"),t=r),D.call(this,e,t)},"param-ajax-traditional")),c(s.fn,"andSelf",s.fn.addBack,"andSelf","jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()"),s.Deferred&&(W=s.Deferred,_=[["resolve","done",s.Callbacks("once memory"),s.Callbacks("once memory"),"resolved"],["reject","fail",s.Callbacks("once memory"),s.Callbacks("once memory"),"rejected"],["notify","progress",s.Callbacks("memory"),s.Callbacks("memory")]],i(s,"Deferred",function(e){var a=W(),i=a.promise();function t(){var o=arguments;return s.Deferred(function(n){s.each(_,function(e,t){var r="function"==typeof o[e]&&o[e];a[t[1]](function(){var e=r&&r.apply(this,arguments);e&&"function"==typeof e.promise?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[t[0]+"With"](this===i?n.promise():this,r?[e]:arguments)})}),o=null}).promise()}return c(a,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),c(i,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),e&&e.call(a,a),a},"deferred-pipe"),s.Deferred.exceptionHook=W.exceptionHook),s}); 3; 4jQuery(document).ready(function() { 5jQuery('.listing-section .listing-tabs .elementor-widget-container .elementor-tabs').css('margin','auto').css('max-width','1440px').css('width','90%'); 6});; 7jQuery(document).ready(function() { 8jQuery('.listing-section .listing-tabs .elementor-widget-container .elementor-tabs .elementor-tabs-wrapper').css('display','block'); 9});; 10const lazyloadRunObserver = () => {
11 const lazyloadBackgrounds = document.querySelectorAll( `.e-con.e-parent:not(.e-lazyloaded)` ); 12 const lazyloadBackgroundObserver = new IntersectionObserver( ( entries ) => { 13 entries.forEach( ( entry ) => { 14 if ( entry.isIntersecting ) { 15 let lazyloadBackground = entry.target; 16 if( lazyloadBackground ) { 17 lazyloadBackground.classList.add( 'e-lazyloaded' ); 18 } 19 lazyloadBackgroundObserver.unobserve( entry.target ); 20 } 21 }); 22 }, { rootMargin: '200px 0px 200px 0px' } ); 23 lazyloadBackgrounds.forEach( ( lazyloadBackground ) => { 24 lazyloadBackgroundObserver.observe( lazyloadBackground ); 25 } ); 26 }; 27 const events = [ 28 'DOMContentLoaded', 29 'elementor/lazyload/observe', 30 ]; 31 events.forEach( ( event ) => { 32 document.addEventListener( event, lazyloadRunObserver ); 33 } );; 34var PusherPushNotifications = (function (exports) { 35 'use strict'; 36 37 function _arrayWithoutHoles(arr) { 38 if (Array.isArray(arr)) { 39 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { 40 arr2[i] = arr[i]; 41 } 42 43 return arr2; 44 } 45 } 46 47 var arrayWithoutHoles = _arrayWithoutHoles; 48 49 function _iterableToArray(iter) { 50 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); 51 } 52 53 var iterableToArray = _iterableToArray; 54 55 function _nonIterableSpread() { 56 throw new TypeError("Invalid attempt to spread non-iterable instance"); 57 } 58 59 var nonIterableSpread = _nonIterableSpread; 60 61 function _toConsumableArray(arr) { 62 return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread(); 63 } 64 65 var toConsumableArray = _toConsumableArray; 66 67 function createCommonjsModule(fn, module) { 68 return module = { exports: {} }, fn(module, module.exports), module.exports; 69 } 70 71 var runtime_1 = createCommonjsModule(function (module) { 72 /** 73 * Copyright (c) 2014-present, Facebook, Inc. 74 * 75 * This source code is licensed under the MIT license found in the 76 * LICENSE file in the root directory of this source tree. 77 */ 78 79 var runtime = (function (exports) { 80 81 var Op = Object.prototype; 82 var hasOwn = Op.hasOwnProperty; 83 var undefined$1; // More compressible than void 0. 84 var $Symbol = typeof Symbol === "function" ? Symbol : {}; 85 var iteratorSymbol = $Symbol.iterator || "@@iterator"; 86 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; 87 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; 88 89 function wrap(innerFn, outerFn, self, tryLocsList) { 90 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. 91 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; 92 var generator = Object.create(protoGenerator.prototype); 93 var context = new Context(tryLocsList || []); 94 95 // The ._invoke method unifies the implementations of the .next, 96 // .throw, and .return methods. 97 generator._invoke = makeInvokeMethod(innerFn, self, context); 98 99 return generator; 100 } 101 exports.wrap = wrap; 102 103 // Try/catch helper to minimize deoptimizations. Returns a completion 104 // record like context.tryEntries[i].completion. This interface could 105 // have been (and was previously) designed to take a closure to be 106 // invoked without arguments, but in all the cases we care about we 107 // already have an existing method we want to call, so there's no need 108 // to create a new function object. We can even get away with assuming 109 // the method takes exactly one argument, since that happens to be true 110 // in every case, so we don't have to touch the arguments object. The 111 // only additional allocation required is the completion record, which 112 // has a stable shape and so hopefully should be cheap to allocate. 113 function tryCatch(fn, obj, arg) { 114 try { 115 return { type: "normal", arg: fn.call(obj, arg) }; 116 } catch (err) { 117 return { type: "throw", arg: err }; 118 } 119 } 120 121 var GenStateSuspendedStart = "suspendedStart"; 122 var GenStateSuspendedYield = "suspendedYield"; 123 var GenStateExecuting = "executing"; 124 var GenStateCompleted = "completed"; 125 126 // Returning this object from the innerFn has the same effect as 127 // breaking out of the dispatch switch statement. 128 var ContinueSentinel = {}; 129 130 // Dummy constructor functions that we use as the .constructor and 131 // .constructor.prototype properties for functions that return Generator 132 // objects. For full spec compliance, you may wish to configure your 133 // minifier not to mangle the names of these two functions. 134 function Generator() {} 135 function GeneratorFunction() {} 136 function GeneratorFunctionPrototype() {} 137 138 // This is a polyfill for %IteratorPrototype% for environments that 139 // don't natively support it. 140 var IteratorPrototype = {}; 141 IteratorPrototype[iteratorSymbol] = function () { 142 return this; 143 }; 144 145 var getProto = Object.getPrototypeOf; 146 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); 147 if (NativeIteratorPrototype && 148 NativeIteratorPrototype !== Op && 149 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { 150 // This environment has a native %IteratorPrototype%; use it instead 151 // of the polyfill. 152 IteratorPrototype = NativeIteratorPrototype; 153 } 154 155 var Gp = GeneratorFunctionPrototype.prototype = 156 Generator.prototype = Object.create(IteratorPrototype); 157 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; 158 GeneratorFunctionPrototype.constructor = GeneratorFunction; 159 GeneratorFunctionPrototype[toStringTagSymbol] = 160 GeneratorFunction.displayName = "GeneratorFunction"; 161 162 // Helper for defining the .next, .throw, and .return methods of the 163 // Iterator interface in terms of a single ._invoke method. 164 function defineIteratorMethods(prototype) { 165 ["next", "throw", "return"].forEach(function(method) { 166 prototype[method] = function(arg) { 167 return this._invoke(method, arg); 168 }; 169 }); 170 } 171 172 exports.isGeneratorFunction = function(genFun) { 173 var ctor = typeof genFun === "function" && genFun.constructor; 174 return ctor 175 ? ctor === GeneratorFunction || 176 // For the native GeneratorFunction constructor, the best we can 177 // do is to check its .name property. 178 (ctor.displayName || ctor.name) === "GeneratorFunction" 179 : false;
vendor: 17,297 bytes, lines 180-705
180 }; 181 182 exports.mark = function(genFun) { 183 if (Object.setPrototypeOf) { 184 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); 185 } else { 186 genFun.__proto__ = GeneratorFunctionPrototype; 187 if (!(toStringTagSymbol in genFun)) { 188 genFun[toStringTagSymbol] = "GeneratorFunction"; 189 } 190 } 191 genFun.prototype = Object.create(Gp); 192 return genFun; 193 }; 194 195 // Within the body of any async function, `await x` is transformed to 196 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test 197 // `hasOwn.call(value, "__await")` to determine if the yielded value is 198 // meant to be awaited. 199 exports.awrap = function(arg) { 200 return { __await: arg }; 201 }; 202 203 function AsyncIterator(generator) { 204 function invoke(method, arg, resolve, reject) { 205 var record = tryCatch(generator[method], generator, arg); 206 if (record.type === "throw") { 207 reject(record.arg); 208 } else { 209 var result = record.arg; 210 var value = result.value; 211 if (value && 212 typeof value === "object" && 213 hasOwn.call(value, "__await")) { 214 return Promise.resolve(value.__await).then(function(value) { 215 invoke("next", value, resolve, reject); 216 }, function(err) { 217 invoke("throw", err, resolve, reject); 218 }); 219 } 220 221 return Promise.resolve(value).then(function(unwrapped) { 222 // When a yielded Promise is resolved, its final value becomes 223 // the .value of the Promise<{value,done}> result for the 224 // current iteration. 225 result.value = unwrapped; 226 resolve(result); 227 }, function(error) { 228 // If a rejected Promise was yielded, throw the rejection back 229 // into the async generator function so it can be handled there. 230 return invoke("throw", error, resolve, reject); 231 }); 232 } 233 } 234 235 var previousPromise; 236 237 function enqueue(method, arg) { 238 function callInvokeWithMethodAndArg() { 239 return new Promise(function(resolve, reject) { 240 invoke(method, arg, resolve, reject); 241 }); 242 } 243 244 return previousPromise = 245 // If enqueue has been called before, then we want to wait until 246 // all previous Promises have been resolved before calling invoke, 247 // so that results are always delivered in the correct order. If 248 // enqueue has not been called before, then it is important to 249 // call invoke immediately, without waiting on a callback to fire, 250 // so that the async generator function has the opportunity to do 251 // any necessary setup in a predictable way. This predictability 252 // is why the Promise constructor synchronously invokes its 253 // executor callback, and why async functions synchronously 254 // execute code before the first await. Since we implement simple 255 // async functions in terms of async generators, it is especially 256 // important to get this right, even though it requires care. 257 previousPromise ? previousPromise.then( 258 callInvokeWithMethodAndArg, 259 // Avoid propagating failures to Promises returned by later 260 // invocations of the iterator. 261 callInvokeWithMethodAndArg 262 ) : callInvokeWithMethodAndArg(); 263 } 264 265 // Define the unified helper method that is used to implement .next, 266 // .throw, and .return (see defineIteratorMethods). 267 this._invoke = enqueue; 268 } 269 270 defineIteratorMethods(AsyncIterator.prototype); 271 AsyncIterator.prototype[asyncIteratorSymbol] = function () { 272 return this; 273 }; 274 exports.AsyncIterator = AsyncIterator; 275 276 // Note that simple async functions are implemented on top of 277 // AsyncIterator objects; they just return a Promise for the value of 278 // the final result produced by the iterator. 279 exports.async = function(innerFn, outerFn, self, tryLocsList) { 280 var iter = new AsyncIterator( 281 wrap(innerFn, outerFn, self, tryLocsList) 282 ); 283 284 return exports.isGeneratorFunction(outerFn) 285 ? iter // If outerFn is a generator, return the full iterator. 286 : iter.next().then(function(result) { 287 return result.done ? result.value : iter.next(); 288 }); 289 }; 290 291 function makeInvokeMethod(innerFn, self, context) { 292 var state = GenStateSuspendedStart; 293 294 return function invoke(method, arg) { 295 if (state === GenStateExecuting) { 296 throw new Error("Generator is already running"); 297 } 298 299 if (state === GenStateCompleted) { 300 if (method === "throw") { 301 throw arg; 302 } 303 304 // Be forgiving, per 25.3.3.3.3 of the spec: 305 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 306 return doneResult(); 307 } 308 309 context.method = method; 310 context.arg = arg; 311 312 while (true) { 313 var delegate = context.delegate; 314 if (delegate) { 315 var delegateResult = maybeInvokeDelegate(delegate, context); 316 if (delegateResult) { 317 if (delegateResult === ContinueSentinel) continue; 318 return delegateResult; 319 } 320 } 321 322 if (context.method === "next") { 323 // Setting context._sent for legacy support of Babel's 324 // function.sent implementation. 325 context.sent = context._sent = context.arg; 326 327 } else if (context.method === "throw") { 328 if (state === GenStateSuspendedStart) { 329 state = GenStateCompleted; 330 throw context.arg; 331 } 332 333 context.dispatchException(context.arg); 334 335 } else if (context.method === "return") { 336 context.abrupt("return", context.arg); 337 } 338 339 state = GenStateExecuting; 340 341 var record = tryCatch(innerFn, self, context); 342 if (record.type === "normal") { 343 // If an exception is thrown from innerFn, we leave state === 344 // GenStateExecuting and loop back for another invocation. 345 state = context.done 346 ? GenStateCompleted 347 : GenStateSuspendedYield; 348 349 if (record.arg === ContinueSentinel) { 350 continue; 351 } 352 353 return { 354 value: record.arg, 355 done: context.done 356 }; 357 358 } else if (record.type === "throw") { 359 state = GenStateCompleted; 360 // Dispatch the exception by looping back around to the 361 // context.dispatchException(context.arg) call above. 362 context.method = "throw"; 363 context.arg = record.arg; 364 } 365 } 366 }; 367 } 368 369 // Call delegate.iterator[context.method](context.arg) and handle the 370 // result, either by returning a { value, done } result from the 371 // delegate iterator, or by modifying context.method and context.arg, 372 // setting context.delegate to null, and returning the ContinueSentinel. 373 function maybeInvokeDelegate(delegate, context) { 374 var method = delegate.iterator[context.method]; 375 if (method === undefined$1) { 376 // A .throw or .return when the delegate iterator has no .throw 377 // method always terminates the yield* loop. 378 context.delegate = null; 379 380 if (context.method === "throw") { 381 // Note: ["return"] must be used for ES3 parsing compatibility. 382 if (delegate.iterator["return"]) { 383 // If the delegate iterator has a return method, give it a 384 // chance to clean up. 385 context.method = "return"; 386 context.arg = undefined$1; 387 maybeInvokeDelegate(delegate, context); 388 389 if (context.method === "throw") { 390 // If maybeInvokeDelegate(context) changed context.method from 391 // "return" to "throw", let that override the TypeError below. 392 return ContinueSentinel; 393 } 394 } 395 396 context.method = "throw"; 397 context.arg = new TypeError( 398 "The iterator does not provide a 'throw' method"); 399 } 400 401 return ContinueSentinel; 402 } 403 404 var record = tryCatch(method, delegate.iterator, context.arg); 405 406 if (record.type === "throw") { 407 context.method = "throw"; 408 context.arg = record.arg; 409 context.delegate = null; 410 return ContinueSentinel; 411 } 412 413 var info = record.arg; 414 415 if (! info) { 416 context.method = "throw"; 417 context.arg = new TypeError("iterator result is not an object"); 418 context.delegate = null; 419 return ContinueSentinel; 420 } 421 422 if (info.done) { 423 // Assign the result of the finished delegate to the temporary 424 // variable specified by delegate.resultName (see delegateYield). 425 context[delegate.resultName] = info.value; 426 427 // Resume execution at the desired location (see delegateYield). 428 context.next = delegate.nextLoc; 429 430 // If context.method was "throw" but the delegate handled the 431 // exception, let the outer generator proceed normally. If 432 // context.method was "next", forget context.arg since it has been 433 // "consumed" by the delegate iterator. If context.method was 434 // "return", allow the original .return call to continue in the 435 // outer generator. 436 if (context.method !== "return") { 437 context.method = "next"; 438 context.arg = undefined$1; 439 } 440 441 } else { 442 // Re-yield the result returned by the delegate method. 443 return info; 444 } 445 446 // The delegate iterator is finished, so forget it and continue with 447 // the outer generator. 448 context.delegate = null; 449 return ContinueSentinel; 450 } 451 452 // Define Generator.prototype.{next,throw,return} in terms of the 453 // unified ._invoke helper method. 454 defineIteratorMethods(Gp); 455 456 Gp[toStringTagSymbol] = "Generator"; 457 458 // A Generator should always return itself as the iterator object when the 459 // @@iterator function is called on it. Some browsers' implementations of the 460 // iterator prototype chain incorrectly implement this, causing the Generator 461 // object to not be returned from this call. This ensures that doesn't happen. 462 // See https://github.com/facebook/regenerator/issues/274 for more details. 463 Gp[iteratorSymbol] = function() { 464 return this; 465 }; 466 467 Gp.toString = function() { 468 return "[object Generator]"; 469 }; 470 471 function pushTryEntry(locs) { 472 var entry = { tryLoc: locs[0] }; 473 474 if (1 in locs) { 475 entry.catchLoc = locs[1]; 476 } 477 478 if (2 in locs) { 479 entry.finallyLoc = locs[2]; 480 entry.afterLoc = locs[3]; 481 } 482 483 this.tryEntries.push(entry); 484 } 485 486 function resetTryEntry(entry) { 487 var record = entry.completion || {}; 488 record.type = "normal"; 489 delete record.arg; 490 entry.completion = record; 491 } 492 493 function Context(tryLocsList) { 494 // The root entry object (effectively a try statement without a catch 495 // or a finally block) gives us a place to store values thrown from 496 // locations where there is no enclosing try statement. 497 this.tryEntries = [{ tryLoc: "root" }]; 498 tryLocsList.forEach(pushTryEntry, this); 499 this.reset(true); 500 } 501 502 exports.keys = function(object) { 503 var keys = []; 504 for (var key in object) { 505 keys.push(key); 506 } 507 keys.reverse(); 508 509 // Rather than returning an object with a next method, we keep 510 // things simple and return the next function itself. 511 return function next() { 512 while (keys.length) { 513 var key = keys.pop(); 514 if (key in object) { 515 next.value = key; 516 next.done = false; 517 return next; 518 } 519 } 520 521 // To avoid creating an additional object, we just hang the .value 522 // and .done properties off the next function object itself. This 523 // also ensures that the minifier will not anonymize the function. 524 next.done = true; 525 return next; 526 }; 527 }; 528 529 function values(iterable) { 530 if (iterable) { 531 var iteratorMethod = iterable[iteratorSymbol]; 532 if (iteratorMethod) { 533 return iteratorMethod.call(iterable); 534 } 535 536 if (typeof iterable.next === "function") { 537 return iterable; 538 } 539 540 if (!isNaN(iterable.length)) { 541 var i = -1, next = function next() { 542 while (++i < iterable.length) { 543 if (hasOwn.call(iterable, i)) { 544 next.value = iterable[i]; 545 next.done = false; 546 return next; 547 } 548 } 549 550 next.value = undefined$1; 551 next.done = true; 552 553 return next; 554 }; 555 556 return next.next = next; 557 } 558 } 559 560 // Return an iterator with no values. 561 return { next: doneResult }; 562 } 563 exports.values = values; 564 565 function doneResult() { 566 return { value: undefined$1, done: true }; 567 } 568 569 Context.prototype = { 570 constructor: Context, 571 572 reset: function(skipTempReset) { 573 this.prev = 0; 574 this.next = 0; 575 // Resetting context._sent for legacy support of Babel's 576 // function.sent implementation. 577 this.sent = this._sent = undefined$1; 578 this.done = false; 579 this.delegate = null; 580 581 this.method = "next"; 582 this.arg = undefined$1; 583 584 this.tryEntries.forEach(resetTryEntry); 585 586 if (!skipTempReset) { 587 for (var name in this) { 588 // Not sure about the optimal order of these conditions: 589 if (name.charAt(0) === "t" && 590 hasOwn.call(this, name) && 591 !isNaN(+name.slice(1))) { 592 this[name] = undefined$1; 593 } 594 } 595 } 596 }, 597 598 stop: function() { 599 this.done = true; 600 601 var rootEntry = this.tryEntries[0]; 602 var rootRecord = rootEntry.completion; 603 if (rootRecord.type === "throw") { 604 throw rootRecord.arg; 605 } 606 607 return this.rval; 608 }, 609 610 dispatchException: function(exception) { 611 if (this.done) { 612 throw exception; 613 } 614 615 var context = this; 616 function handle(loc, caught) { 617 record.type = "throw"; 618 record.arg = exception; 619 context.next = loc; 620 621 if (caught) { 622 // If the dispatched exception was caught by a catch block, 623 // then let that catch block handle the exception normally. 624 context.method = "next"; 625 context.arg = undefined$1; 626 } 627 628 return !! caught; 629 } 630 631 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 632 var entry = this.tryEntries[i]; 633 var record = entry.completion; 634 635 if (entry.tryLoc === "root") { 636 // Exception thrown outside of any try block that could handle 637 // it, so set the completion value of the entire function to 638 // throw the exception. 639 return handle("end"); 640 } 641 642 if (entry.tryLoc <= this.prev) { 643 var hasCatch = hasOwn.call(entry, "catchLoc"); 644 var hasFinally = hasOwn.call(entry, "finallyLoc"); 645 646 if (hasCatch && hasFinally) { 647 if (this.prev < entry.catchLoc) { 648 return handle(entry.catchLoc, true); 649 } else if (this.prev < entry.finallyLoc) { 650 return handle(entry.finallyLoc); 651 } 652 653 } else if (hasCatch) { 654 if (this.prev < entry.catchLoc) { 655 return handle(entry.catchLoc, true); 656 } 657 658 } else if (hasFinally) { 659 if (this.prev < entry.finallyLoc) { 660 return handle(entry.finallyLoc); 661 } 662 663 } else { 664 throw new Error("try statement without catch or finally"); 665 } 666 } 667 } 668 }, 669 670 abrupt: function(type, arg) { 671 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 672 var entry = this.tryEntries[i]; 673 if (entry.tryLoc <= this.prev && 674 hasOwn.call(entry, "finallyLoc") && 675 this.prev < entry.finallyLoc) { 676 var finallyEntry = entry; 677 break; 678 } 679 } 680 681 if (finallyEntry && 682 (type === "break" || 683 type === "continue") && 684 finallyEntry.tryLoc <= arg && 685 arg <= finallyEntry.finallyLoc) { 686 // Ignore the finally entry if control is not jumping to a 687 // location outside the try/catch block. 688 finallyEntry = null; 689 } 690 691 var record = finallyEntry ? finallyEntry.completion : {}; 692 record.type = type; 693 record.arg = arg; 694 695 if (finallyEntry) { 696 this.method = "next"; 697 this.next = finallyEntry.finallyLoc; 698 return ContinueSentinel; 699 } 700 701 return this.complete(record); 702 }, 703 704 complete: function(record, afterLoc) { 705 if (record.type === "throw") {
706 throw record.arg; 707 } 708 709 if (record.type === "break" || 710 record.type === "continue") { 711 this.next = record.arg; 712 } else if (record.type === "return") { 713 this.rval = this.arg = record.arg; 714 this.method = "return"; 715 this.next = "end"; 716 } else if (record.type === "normal" && afterLoc) { 717 this.next = afterLoc; 718 } 719 720 return ContinueSentinel; 721 }, 722 723 finish: function(finallyLoc) { 724 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 725 var entry = this.tryEntries[i]; 726 if (entry.finallyLoc === finallyLoc) { 727 this.complete(entry.completion, entry.afterLoc); 728 resetTryEntry(entry); 729 return ContinueSentinel; 730 } 731 } 732 }, 733 734 "catch": function(tryLoc) { 735 for (var i = this.tryEntries.length - 1; i >= 0; --i) { 736 var entry = this.tryEntries[i]; 737 if (entry.tryLoc === tryLoc) { 738 var record = entry.completion; 739 if (record.type === "throw") { 740 var thrown = record.arg; 741 resetTryEntry(entry); 742 } 743 return thrown; 744 } 745 } 746 747 // The context.catch method must only be called with a location 748 // argument that corresponds to a known catch block. 749 throw new Error("illegal catch attempt"); 750 }, 751 752 delegateYield: function(iterable, resultName, nextLoc) { 753 this.delegate = { 754 iterator: values(iterable), 755 resultName: resultName, 756 nextLoc: nextLoc 757 }; 758 759 if (this.method === "next") { 760 // Deliberately forget the last sent value so that we don't 761 // accidentally pass it on to the delegate. 762 this.arg = undefined$1; 763 } 764 765 return ContinueSentinel; 766 } 767 }; 768 769 // Regardless of whether this script is executing as a CommonJS module 770 // or not, return the runtime object so that we can declare the variable 771 // regeneratorRuntime in the outer scope, which allows this module to be 772 // injected easily by `bin/regenerator --include-runtime script.js`. 773 return exports; 774 775 }( 776 // If this script is executing as a CommonJS module, use module.exports 777 // as the regeneratorRuntime namespace. Otherwise create a new empty 778 // object. Either way, the resulting object will be used to initialize 779 // the regeneratorRuntime variable at the top of this file. 780 module.exports 781 )); 782 783 try { 784 regeneratorRuntime = runtime; 785 } catch (accidentalStrictMode) { 786 // This module should not be running in strict mode, so the above 787 // assignment should always work unless something is misconfigured. Just 788 // in case runtime.js accidentally runs in strict mode, we can escape 789 // strict mode using a global Function call. This could conceivably fail 790 // if a Content Security Policy forbids using Function, but in that case 791 // the proper solution is to fix the accidental strict mode problem. If 792 // you've misconfigured your bundler to force strict mode and applied a 793 // CSP to forbid Function, and you're not willing to fix either of those 794 // problems, please detail your unique predicament in a GitHub issue. 795 Function("r", "regeneratorRuntime = r")(runtime); 796 } 797 }); 798 799 var regenerator = runtime_1; 800 801 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 802 try { 803 var info = gen[key](arg); 804 var value = info.value; 805 } catch (error) { 806 reject(error); 807 return; 808 } 809 810 if (info.done) { 811 resolve(value); 812 } else { 813 Promise.resolve(value).then(_next, _throw); 814 } 815 } 816 817 function _asyncToGenerator(fn) { 818 return function () { 819 var self = this, 820 args = arguments; 821 return new Promise(function (resolve, reject) { 822 var gen = fn.apply(self, args); 823 824 function _next(value) { 825 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 826 } 827 828 function _throw(err) { 829 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 830 } 831 832 _next(undefined); 833 }); 834 }; 835 } 836 837 var asyncToGenerator = _asyncToGenerator; 838 839 function _classCallCheck(instance, Constructor) { 840 if (!(instance instanceof Constructor)) { 841 throw new TypeError("Cannot call a class as a function"); 842 } 843 } 844 845 var classCallCheck = _classCallCheck; 846 847 function _defineProperties(target, props) { 848 for (var i = 0; i < props.length; i++) { 849 var descriptor = props[i]; 850 descriptor.enumerable = descriptor.enumerable || false; 851 descriptor.configurable = true; 852 if ("value" in descriptor) descriptor.writable = true; 853 Object.defineProperty(target, descriptor.key, descriptor); 854 } 855 } 856 857 function _createClass(Constructor, protoProps, staticProps) { 858 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 859 if (staticProps) _defineProperties(Constructor, staticProps); 860 return Constructor; 861 } 862 863 var createClass = _createClass; 864 865 function _defineProperty(obj, key, value) { 866 if (key in obj) { 867 Object.defineProperty(obj, key, { 868 value: value, 869 enumerable: true, 870 configurable: true, 871 writable: true 872 }); 873 } else { 874 obj[key] = value; 875 } 876 877 return obj; 878 } 879 880 var defineProperty = _defineProperty; 881 882 function _objectSpread(target) { 883 for (var i = 1; i < arguments.length; i++) { 884 var source = arguments[i] != null ? arguments[i] : {}; 885 var ownKeys = Object.keys(source); 886 887 if (typeof Object.getOwnPropertySymbols === 'function') { 888 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { 889 return Object.getOwnPropertyDescriptor(source, sym).enumerable; 890 })); 891 } 892 893 ownKeys.forEach(function (key) { 894 defineProperty(target, key, source[key]); 895 }); 896 } 897 898 return target; 899 } 900 901 var objectSpread = _objectSpread; 902 903 function doRequest(_ref) { 904 var method = _ref.method, 905 path = _ref.path, 906 _ref$body = _ref.body, 907 body = _ref$body === void 0 ? null : _ref$body, 908 _ref$headers = _ref.headers, 909 headers = _ref$headers === void 0 ? {}
909 : _ref$headers; 910 var options = { 911 method: method, 912 headers: headers 913 }; 914 915 if (body !== null) { 916 options.body = JSON.stringify(body); 917 options.headers = objectSpread({ 918 'Content-Type': 'application/json' 919 }, headers); 920 } 921 922 return fetch(path, options).then( 923 /*#__PURE__*/ 924 function () { 925 var _ref2 = asyncToGenerator( 926 /*#__PURE__*/ 927 regenerator.mark(function _callee(response) { 928 return regenerator.wrap(function _callee$(_context) { 929 while (1) { 930 switch (_context.prev = _context.next) { 931 case 0: 932 if (response.ok) { 933 _context.next = 3; 934 break; 935 } 936 937 _context.next = 3; 938 return handleError(response); 939 940 case 3: 941 _context.prev = 3; 942 _context.next = 6; 943 return response.json(); 944 945 case 6: 946 return _context.abrupt("return", _context.sent); 947 948 case 9: 949 _context.prev = 9; 950 _context.t0 = _context["catch"](3); 951 return _context.abrupt("return", null); 952 953 case 12: 954 case "end": 955 return _context.stop(); 956 } 957 } 958 }, _callee, null, [[3, 9]]); 959 })); 960 961 return function (_x) { 962 return _ref2.apply(this, arguments); 963 }; 964 }()); 965 } 966 967 function handleError(_x2) { 968 return _handleError.apply(this, arguments); 969 } 970 971 function _handleError() { 972 _handleError = asyncToGenerator( 973 /*#__PURE__*/ 974 regenerator.mark(function _callee2(response) { 975 var errorMessage, _ref3, _ref3$error, error, _ref3$description, description; 976 977 return regenerator.wrap(function _callee2$(_context2) { 978 while (1) { 979 switch (_context2.prev = _context2.next) { 980 case 0: 981 _context2.prev = 0; 982 _context2.next = 3; 983 return response.json(); 984 985 case 3: 986 _ref3 = _context2.sent; 987 _ref3$error = _ref3.error; 988 error = _ref3$error === void 0 ? 'Unknown error' : _ref3$error; 989 _ref3$description = _ref3.description; 990 description = _ref3$description === void 0 ? 'No description' : _ref3$description; 991 errorMessage = "Unexpected status code ".concat(response.status, ": ").concat(error, ", ").concat(description); 992 _context2.next = 14; 993 break; 994 995 case 11: 996 _context2.prev = 11; 997 _context2.t0 = _context2["catch"](0); 998 errorMessage = "Unexpected status code ".concat(response.status, ": Cannot parse error response"); 999 1000 case 14: 1001 throw new Error(errorMessage); 1002 1003 case 15: 1004 case "end": 1005 return _context2.stop(); 1006 } 1007 } 1008 }, _callee2, null, [[0, 11]]); 1009 })); 1010 return _handleError.apply(this, arguments); 1011 } 1012 1013 var TokenProvider = 1014 /*#__PURE__*/ 1015 function () { 1016 function TokenProvider() { 1017 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 1018 url = _ref.url, 1019 queryParams = _ref.queryParams, 1020 headers = _ref.headers; 1021 1022 classCallCheck(this, TokenProvider); 1023 1024 this.url = url; 1025 this.queryParams = queryParams; 1026 this.headers = headers; 1027 } 1028 1029 createClass(TokenProvider, [{ 1030 key: "fetchToken", 1031 value: function () { 1032 var _fetchToken = asyncToGenerator( 1033 /*#__PURE__*/ 1034 regenerator.mark(function _callee(userId) { 1035 var queryParams, encodedParams, options, response; 1036 return regenerator.wrap(function _callee$(_context) { 1037 while (1) { 1038 switch (_context.prev = _context.next) { 1039 case 0: 1040 queryParams = objectSpread({ 1041 user_id: userId 1042 }, this.queryParams); 1043 encodedParams = Object.entries(queryParams).map(function (kv) { 1044 return kv.map(encodeURIComponent).join('='); 1045 }).join('&'); 1046 options = { 1047 method: 'GET', 1048 path: "".concat(this.url, "?").concat(encodedParams), 1049 headers: this.headers 1050 }; 1051 _context.next = 5; 1052 return doRequest(options); 1053 1054 case 5: 1055 response = _context.sent; 1056 return _context.abrupt("return", response); 1057 1058 case 7: 1059 case "end": 1060 return _context.stop(); 1061 } 1062 } 1063 }, _callee, this); 1064 })); 1065 1066 function fetchToken(_x) { 1067 return _fetchToken.apply(this, arguments); 1068 } 1069 1070 return fetchToken; 1071 }() 1072 }]); 1073 1074 return TokenProvider; 1075 }(); 1076 1077 var DeviceStateStore = 1078 /*#__PURE__*/ 1079 function () { 1080 function DeviceStateStore(instanceId) { 1081 classCallCheck(this, DeviceStateStore); 1082 1083 this._instanceId = instanceId; 1084 this._dbConn = null; 1085 } 1086 1087 createClass(DeviceStateStore, [{ 1088 key: "connect", 1089 value: function connect() { 1090 var _this = this; 1091 1092 return new Promise(function (resolve, reject) { 1093 var request = indexedDB.open(_this._dbName); 1094 1095 request.onsuccess = function (event) { 1096 var db = event.target.result; 1097 _this._dbConn = db; 1098 1099 _this._readState().then(function (state) { 1100 return state === null ? _this.clear() : Promise.resolve(); 1101 }).then(resolve); 1102 }; 1103
1104 request.onupgradeneeded = function (event) { 1105 var db = event.target.result; 1106 db.createObjectStore('beams', { 1107 keyPath: 'instance_id' 1108 }); 1109 }; 1110 1111 request.onerror = function (event) { 1112 var error = new Error("Database error: ".concat(event.target.error)); 1113 reject(error); 1114 }; 1115 }); 1116 } 1117 }, { 1118 key: "clear", 1119 value: function clear() { 1120 return this._writeState({ 1121 instance_id: this._instanceId, 1122 device_id: null, 1123 token: null, 1124 user_id: null 1125 }); 1126 } 1127 }, { 1128 key: "_readState", 1129 value: function _readState() { 1130 var _this2 = this; 1131 1132 if (!this.isConnected) { 1133 throw new Error('Cannot read value: DeviceStateStore not connected to IndexedDB'); 1134 } 1135 1136 return new Promise(function (resolve, reject) { 1137 var request = _this2._dbConn.transaction('beams').objectStore('beams').get(_this2._instanceId); 1138 1139 request.onsuccess = function (event) { 1140 var state = event.target.result; 1141 1142 if (!state) { 1143 resolve(null); 1144 } 1145 1146 resolve(state); 1147 }; 1148 1149 request.onerror = function (event) { 1150 reject(event.target.error); 1151 }; 1152 }); 1153 } 1154 }, { 1155 key: "_readProperty", 1156 value: function () { 1157 var _readProperty2 = asyncToGenerator( 1158 /*#__PURE__*/ 1159 regenerator.mark(function _callee(name) { 1160 var state; 1161 return regenerator.wrap(function _callee$(_context) { 1162 while (1) { 1163 switch (_context.prev = _context.next) { 1164 case 0: 1165 _context.next = 2; 1166 return this._readState(); 1167 1168 case 2: 1169 state = _context.sent; 1170 1171 if (!(state === null)) { 1172 _context.next = 5; 1173 break; 1174 } 1175 1176 return _context.abrupt("return", null); 1177 1178 case 5: 1179 return _context.abrupt("return", state[name] || null); 1180 1181 case 6: 1182 case "end": 1183 return _context.stop(); 1184 } 1185 } 1186 }, _callee, this); 1187 })); 1188 1189 function _readProperty(_x) { 1190 return _readProperty2.apply(this, arguments); 1191 } 1192 1193 return _readProperty; 1194 }() 1195 }, { 1196 key: "_writeState", 1197 value: function _writeState(state) { 1198 var _this3 = this; 1199 1200 if (!this.isConnected) { 1201 throw new Error('Cannot write value: DeviceStateStore not connected to IndexedDB'); 1202 } 1203 1204 return new Promise(function (resolve, reject) { 1205 var request = _this3._dbConn.transaction('beams', 'readwrite').objectStore('beams').put(state); 1206 1207 request.onsuccess = function (_) { 1208 resolve(); 1209 }; 1210 1211 request.onerror = function (event) { 1212 reject(event.target.error); 1213 }; 1214 }); 1215 } 1216 }, { 1217 key: "_writeProperty", 1218 value: function () { 1219 var _writeProperty2 = asyncToGenerator( 1220 /*#__PURE__*/ 1221 regenerator.mark(function _callee2(name, value) { 1222 var state; 1223 return regenerator.wrap(function _callee2$(_context2) { 1224 while (1) { 1225 switch (_context2.prev = _context2.next) { 1226 case 0: 1227 _context2.next = 2; 1228 return this._readState(); 1229 1230 case 2: 1231 state = _context2.sent; 1232 state[name] = value; 1233 _context2.next = 6; 1234 return this._writeState(state); 1235 1236 case 6: 1237 case "end": 1238 return _context2.stop(); 1239 } 1240 } 1241 }, _callee2, this); 1242 })); 1243 1244 function _writeProperty(_x2, _x3) { 1245 return _writeProperty2.apply(this, arguments); 1246 } 1247 1248 return _writeProperty; 1249 }() 1250 }, { 1251 key: "getToken", 1252 value: function getToken() { 1253 return this._readProperty('token'); 1254 } 1255 }, {
1256 key: "setToken", 1257 value: function setToken(token) { 1258 return this._writeProperty('token', token); 1259 } 1260 }, { 1261 key: "getDeviceId", 1262 value: function getDeviceId() { 1263 return this._readProperty('device_id'); 1264 } 1265 }, { 1266 key: "setDeviceId", 1267 value: function setDeviceId(deviceId) { 1268 return this._writeProperty('device_id', deviceId); 1269 } 1270 }, { 1271 key: "getUserId", 1272 value: function getUserId() { 1273 return this._readProperty('user_id'); 1274 } 1275 }, { 1276 key: "setUserId", 1277 value: function setUserId(userId) { 1278 return this._writeProperty('user_id', userId); 1279 } 1280 }, { 1281 key: "getLastSeenSdkVersion", 1282 value: function getLastSeenSdkVersion() { 1283 return this._readProperty('last_seen_sdk_version'); 1284 } 1285 }, { 1286 key: "setLastSeenSdkVersion", 1287 value: function setLastSeenSdkVersion(sdkVersion) { 1288 return this._writeProperty('last_seen_sdk_version', sdkVersion); 1289 } 1290 }, { 1291 key: "getLastSeenUserAgent", 1292 value: function getLastSeenUserAgent() { 1293 return this._readProperty('last_seen_user_agent'); 1294 } 1295 }, { 1296 key: "setLastSeenUserAgent", 1297 value: function setLastSeenUserAgent(userAgent) { 1298 return this._writeProperty('last_seen_user_agent', userAgent); 1299 } 1300 }, { 1301 key: "_dbName", 1302 get: function get() { 1303 return "beams-".concat(this._instanceId); 1304 } 1305 }, { 1306 key: "isConnected", 1307 get: function get() { 1308 return this._dbConn !== null; 1309 } 1310 }]); 1311 1312 return DeviceStateStore; 1313 }(); 1314 1315 var version = "1.0.3"; 1316 1317 var INTERESTS_REGEX = new RegExp('^(_|\\-|=|@|,|\\.|;|[A-Z]|[a-z]|[0-9])*$'); 1318 var MAX_INTEREST_LENGTH = 164; 1319 var MAX_INTERESTS_NUM = 5000; 1320 var SERVICE_WORKER_URL = "/service-worker.js?pusherBeamsWebSDKVersion=".concat(version); 1321 var RegistrationState = Object.freeze({ 1322 PERMISSION_PROMPT_REQUIRED: 'PERMISSION_PROMPT_REQUIRED', 1323 PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS: 'PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS', 1324 PERMISSION_GRANTED_REGISTERED_WITH_BEAMS: 'PERMISSION_GRANTED_REGISTERED_WITH_BEAMS', 1325 PERMISSION_DENIED: 'PERMISSION_DENIED' 1326 }); 1327 var Client = 1328 /*#__PURE__*/ 1329 function () { 1330 function Client(config) { 1331 classCallCheck(this, Client); 1332 1333 if (!config) { 1334 throw new Error('Config object required'); 1335 } 1336 1337 var instanceId = config.instanceId, 1338 _config$endpointOverr = config.endpointOverride, 1339 endpointOverride = _config$endpointOverr === void 0 ? null : _config$endpointOverr, 1340 _config$serviceWorker = config.serviceWorkerRegistration, 1341 serviceWorkerRegistration = _config$serviceWorker === void 0 ? null : _config$serviceWorker; 1342 1343 if (instanceId === undefined) { 1344 throw new Error('Instance ID is required'); 1345 } 1346 1347 if (typeof instanceId !== 'string') { 1348 throw new Error('Instance ID must be a string'); 1349 } 1350 1351 if (instanceId.length === 0) { 1352 throw new Error('Instance ID cannot be empty'); 1353 } 1354 1355 if (!('indexedDB' in window)) { 1356 throw new Error('Pusher Beams does not support this browser version (IndexedDB not supported)'); 1357 } 1358 1359 if (!window.isSecureContext) { 1360 throw new Error('Pusher Beams relies on Service Workers, which only work in secure contexts. Check that your page is being served from localhost/over HTTPS'); 1361 } 1362 1363 if (!('serviceWorker' in navigator)) { 1364 throw new Error('Pusher Beams does not support this browser version (Service Workers not supported)'); 1365 } 1366 1367 if (!('PushManager' in window)) { 1368 throw new Error('Pusher Beams does not support this browser version (Web Push not supported)'); 1369 } 1370 1371 if (serviceWorkerRegistration) { 1372 var serviceWorkerScope = serviceWorkerRegistration.scope; 1373 var currentURL = window.location.href; 1374 var scopeMatchesCurrentPage = currentURL.startsWith(serviceWorkerScope); 1375 1376 if (!scopeMatchesCurrentPage) { 1377 throw new Error("Could not initialize Pusher web push: current page not in serviceWorkerRegistration scope (".concat(serviceWorker
1377Scope, ")")); 1378 } 1379 } 1380 1381 this.instanceId = instanceId; 1382 this._deviceId = null; 1383 this._token = null; 1384 this._userId = null; 1385 this._serviceWorkerRegistration = serviceWorkerRegistration; 1386 this._deviceStateStore = new DeviceStateStore(instanceId); 1387 this._endpoint = endpointOverride; // Internal only 1388 1389 this._ready = this._init(); 1390 } 1391 1392 createClass(Client, [{ 1393 key: "_init", 1394 value: function () { 1395 var _init2 = asyncToGenerator( 1396 /*#__PURE__*/ 1397 regenerator.mark(function _callee() { 1398 return regenerator.wrap(function _callee$(_context) { 1399 while (1) { 1400 switch (_context.prev = _context.next) { 1401 case 0: 1402 if (!(this._deviceId !== null)) { 1403 _context.next = 2; 1404 break; 1405 } 1406 1407 return _context.abrupt("return"); 1408 1409 case 2: 1410 _context.next = 4; 1411 return this._deviceStateStore.connect(); 1412 1413 case 4: 1414 if (!this._serviceWorkerRegistration) { 1415 _context.next = 9; 1416 break; 1417 } 1418 1419 _context.next = 7; 1420 return window.navigator.serviceWorker.ready; 1421 1422 case 7: 1423 _context.next = 12; 1424 break; 1425 1426 case 9: 1427 _context.next = 11; 1428 return getServiceWorkerRegistration(); 1429 1430 case 11: 1431 this._serviceWorkerRegistration = _context.sent; 1432 1433 case 12: 1434 _context.next = 14; 1435 return this._detectSubscriptionChange(); 1436 1437 case 14: 1438 _context.next = 16; 1439 return this._deviceStateStore.getDeviceId(); 1440 1441 case 16: 1442 this._deviceId = _context.sent; 1443 _context.next = 19; 1444 return this._deviceStateStore.getToken(); 1445 1446 case 19: 1447 this._token = _context.sent; 1448 _context.next = 22; 1449 return this._deviceStateStore.getUserId(); 1450 1451 case 22: 1452 this._userId = _context.sent; 1453 1454 case 23: 1455 case "end": 1456 return _context.stop(); 1457 } 1458 } 1459 }, _callee, this); 1460 })); 1461 1462 function _init() { 1463 return _init2.apply(this, arguments); 1464 } 1465 1466 return _init; 1467 }() // Ensure SDK is loaded and is consistent 1468 1469 }, { 1470 key: "_resolveSDKState", 1471 value: function () { 1472 var _resolveSDKState2 = asyncToGenerator( 1473 /*#__PURE__*/ 1474 regenerator.mark(function _callee2() { 1475 return regenerator.wrap(function _callee2$(_context2) { 1476 while (1) { 1477 switch (_context2.prev = _context2.next) { 1478 case 0: 1479 _context2.next = 2; 1480 return this._ready; 1481 1482 case 2: 1483 _context2.next = 4; 1484 return this._detectSubscriptionChange(); 1485 1486 case 4: 1487 case "end": 1488 return _context2.stop(); 1489 } 1490 } 1491 }, _callee2, this); 1492 })); 1493 1494 function _resolveSDKState() { 1495 return _resolveSDKState2.apply(this, arguments); 1496 } 1497 1498 return _resolveSDKState; 1499 }() 1500 }, { 1501 key: "_detectSubscriptionChange", 1502 value: function () { 1503 var _detectSubscriptionChange2 = asyncToGenerator( 1504 /*#__PURE__*/ 1505 regenerator.mark(function _callee3() { 1506 var storedToken, actualToken, pushTokenHasChanged; 1507 return regenerator.wrap(function _callee3$(_context3) { 1508 while (1) { 1509 switch (_context3.prev = _context3.next) { 1510 case 0: 1511 _context3.next = 2; 1512 return this._deviceStateStore.getToken(); 1513 1514 case 2: 1515 storedToken = _context3.sent; 1516 _context3.next = 5; 1517 return getWebPushToken(this._serviceWorkerRegistration); 1518 1519 case 5: 1520 actualToken = _context3.sent; 1521 pushTokenHasChanged = storedToken !== actualToken; 1522 1523 if (!pushTokenHasChanged) { 1524 _context3.next = 13; 1525 break; 1526 } 1527 1528 _context3.next = 10; 1529 return this._deviceStateStore.clear(); 1530 1531 case 10: 1532 this._deviceId = null; 1533 this._token = null; 1534 this._userId = null; 1535 1536 case 13: 1537 case "end": 1538 return _context3.stop(); 1539 } 1540 } 1541 }, _callee3, this); 1542 })); 1543 1544 function _detectSubscriptionChange() { 1545 return _detectSubscriptionChange2.apply(this, arguments); 1546 } 1547 1548 return _detectSubscriptionChange; 1549 }() 1550 }, {
1551 key: "getDeviceId", 1552 value: function () { 1553 var _getDeviceId = asyncToGenerator( 1554 /*#__PURE__*/ 1555 regenerator.mark(function _callee4() { 1556 var _this = this; 1557 1558 return regenerator.wrap(function _callee4$(_context4) { 1559 while (1) { 1560 switch (_context4.prev = _context4.next) { 1561 case 0: 1562 _context4.next = 2; 1563 return this._resolveSDKState(); 1564 1565 case 2: 1566 return _context4.abrupt("return", this._ready.then(function () { 1567 return _this._deviceId; 1568 })); 1569 1570 case 3: 1571 case "end": 1572 return _context4.stop(); 1573 } 1574 } 1575 }, _callee4, this); 1576 })); 1577 1578 function getDeviceId() { 1579 return _getDeviceId.apply(this, arguments); 1580 } 1581 1582 return getDeviceId; 1583 }() 1584 }, { 1585 key: "getToken", 1586 value: function () { 1587 var _getToken = asyncToGenerator( 1588 /*#__PURE__*/ 1589 regenerator.mark(function _callee5() { 1590 var _this2 = this; 1591 1592 return regenerator.wrap(function _callee5$(_context5) { 1593 while (1) { 1594 switch (_context5.prev = _context5.next) { 1595 case 0: 1596 _context5.next = 2; 1597 return this._resolveSDKState(); 1598 1599 case 2: 1600 return _context5.abrupt("return", this._ready.then(function () { 1601 return _this2._token; 1602 })); 1603 1604 case 3: 1605 case "end": 1606 return _context5.stop(); 1607 } 1608 } 1609 }, _callee5, this); 1610 })); 1611 1612 function getToken() { 1613 return _getToken.apply(this, arguments); 1614 } 1615 1616 return getToken; 1617 }() 1618 }, { 1619 key: "getUserId", 1620 value: function () { 1621 var _getUserId = asyncToGenerator( 1622 /*#__PURE__*/ 1623 regenerator.mark(function _callee6() { 1624 var _this3 = this; 1625 1626 return regenerator.wrap(function _callee6$(_context6) { 1627 while (1) { 1628 switch (_context6.prev = _context6.next) { 1629 case 0: 1630 _context6.next = 2; 1631 return this._resolveSDKState(); 1632 1633 case 2: 1634 return _context6.abrupt("return", this._ready.then(function () { 1635 return _this3._userId; 1636 })); 1637 1638 case 3: 1639 case "end": 1640 return _context6.stop(); 1641 } 1642 } 1643 }, _callee6, this); 1644 })); 1645 1646 function getUserId() { 1647 return _getUserId.apply(this, arguments); 1648 } 1649 1650 return getUserId; 1651 }() 1652 }, { 1653 key: "_throwIfNotStarted", 1654 value: function _throwIfNotStarted(message) { 1655 if (!this._deviceId) { 1656 throw new Error("".concat(message, ". SDK not registered with Beams. Did you call .start?")); 1657 } 1658 } 1659 }, { 1660 key: "start", 1661 value: function () { 1662 var _start = asyncToGenerator( 1663 /*#__PURE__*/ 1664 regenerator.mark(function _callee7() { 1665 var _ref, publicKey, token, deviceId; 1666 1667 return regenerator.wrap(function _callee7$(_context7) { 1668 while (1) { 1669 switch (_context7.prev = _context7.next) { 1670 case 0: 1671 _context7.next = 2; 1672 return this._resolveSDKState(); 1673 1674 case 2: 1675 if (isSupportedBrowser()) { 1676 _context7.next = 4; 1677 break; 1678 } 1679 1680 return _context7.abrupt("return", this); 1681 1682 case 4: 1683 if (!(this._deviceId !== null)) { 1684 _context7.next = 6; 1685 break; 1686 } 1687 1688 return _context7.abrupt("return", this); 1689 1690 case 6: 1691 _context7.next = 8; 1692 return this._getPublicKey(); 1693 1694 case 8: 1695 _ref = _context7.sent; 1696 publicKey = _ref.vapidPublicKey; 1697 _context7.next = 12; 1698 return this._getPushToken(publicKey); 1699 1700 case 12: 1701 token = _context7.sent; 1702 _context7.next = 15; 1703 return this._registerDevice(token); 1704 1705 case 15: 1706 deviceId = _context7.sent; 1707 _context7.next = 18; 1708 return this._deviceStateStore.setToken(token); 1709 1710 case 18: 1711 _context7.next = 20; 1712 return this._deviceStateStore.setDeviceId(deviceId); 1713 1714 case 20: 1715 _context7.next = 22; 1716 return this._deviceStateStore.setLastSeenSdkVersion(version); 1717 1718 case 22: 1719 _context7.next = 24; 1720 return this._deviceStateStore.setLastSeenUserAgent(window.navigator.userAgent); 1721 1722 case 24: 1723 this._token = token; 1724 this._deviceId = deviceId; 1725 return _context7.abrupt("return", this); 1726 1727 case 27: 1728 case "end": 1729 return _context7.stop(); 1730 } 1731 } 1732 }, _callee7, this); 1733 })); 1734 1735 function start() { 1736 return _start.apply(this, arguments); 1737 } 1738 1739 return start; 1740 }() 1741 }, {
1742 key: "getRegistrationState", 1743 value: function () { 1744 var _getRegistrationState = asyncToGenerator( 1745 /*#__PURE__*/ 1746 regenerator.mark(function _callee8() { 1747 return regenerator.wrap(function _callee8$(_context8) { 1748 while (1) { 1749 switch (_context8.prev = _context8.next) { 1750 case 0: 1751 _context8.next = 2; 1752 return this._resolveSDKState(); 1753 1754 case 2: 1755 if (!(Notification.permission === 'denied')) { 1756 _context8.next = 4; 1757 break; 1758 } 1759 1760 return _context8.abrupt("return", RegistrationState.PERMISSION_DENIED); 1761 1762 case 4: 1763 if (!(Notification.permission === 'granted' && this._deviceId !== null)) { 1764 _context8.next = 6; 1765 break; 1766 } 1767 1768 return _context8.abrupt("return", RegistrationState.PERMISSION_GRANTED_REGISTERED_WITH_BEAMS); 1769 1770 case 6: 1771 if (!(Notification.permission === 'granted' && this._deviceId === null)) { 1772 _context8.next = 8; 1773 break; 1774 } 1775 1776 return _context8.abrupt("return", RegistrationState.PERMISSION_GRANTED_NOT_REGISTERED_WITH_BEAMS); 1777 1778 case 8: 1779 return _context8.abrupt("return", RegistrationState.PERMISSION_PROMPT_REQUIRED); 1780 1781 case 9: 1782 case "end": 1783 return _context8.stop(); 1784 } 1785 } 1786 }, _callee8, this); 1787 })); 1788 1789 function getRegistrationState() { 1790 return _getRegistrationState.apply(this, arguments); 1791 } 1792 1793 return getRegistrationState; 1794 }() 1795 }, { 1796 key: "addDeviceInterest", 1797 value: function () { 1798 var _addDeviceInterest = asyncToGenerator( 1799 /*#__PURE__*/ 1800 regenerator.mark(function _callee9(interest) { 1801 var path, options; 1802 return regenerator.wrap(function _callee9$(_context9) { 1803 while (1) { 1804 switch (_context9.prev = _context9.next) { 1805 case 0: 1806 _context9.next = 2; 1807 return this._resolveSDKState(); 1808 1809 case 2: 1810 this._throwIfNotStarted('Could not add Device Interest'); 1811 1812 validateInterestName(interest); 1813 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/interests/").concat(encodeURIComponent(interest)); 1814 options = { 1815 method: 'POST', 1816 path: path 1817 }; 1818 _context9.next = 8; 1819 return doRequest(options); 1820 1821 case 8: 1822 case "end": 1823 return _context9.stop(); 1824 } 1825 } 1826 }, _callee9, this); 1827 })); 1828 1829 function addDeviceInterest(_x) { 1830 return _addDeviceInterest.apply(this, arguments); 1831 } 1832 1833 return addDeviceInterest; 1834 }() 1835 }, { 1836 key: "removeDeviceInterest", 1837 value: function () { 1838 var _removeDeviceInterest = asyncToGenerator( 1839 /*#__PURE__*/ 1840 regenerator.mark(function _callee10(interest) { 1841 var path, options; 1842 return regenerator.wrap(function _callee10$(_context10) { 1843 while (1) { 1844 switch (_context10.prev = _context10.next) { 1845 case 0: 1846 _context10.next = 2; 1847 return this._resolveSDKState(); 1848 1849 case 2: 1850 this._throwIfNotStarted('Could not remove Device Interest'); 1851 1852 validateInterestName(interest); 1853 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/interests/").concat(encodeURIComponent(interest)); 1854 options = { 1855 method: 'DELETE', 1856 path: path 1857 }; 1858 _context10.next = 8; 1859 return doRequest(options); 1860 1861 case 8: 1862 case "end": 1863 return _context10.stop(); 1864 } 1865 } 1866 }, _callee10, this); 1867 })); 1868 1869 function removeDeviceInterest(_x2) { 1870 return _removeDeviceInterest.apply(this, arguments); 1871 } 1872 1873 return removeDeviceInterest; 1874 }() 1875 }, {
1876 key: "getDeviceInterests", 1877 value: function () { 1878 var _getDeviceInterests = asyncToGenerator( 1879 /*#__PURE__*/ 1880 regenerator.mark(function _callee11() { 1881 var path, options; 1882 return regenerator.wrap(function _callee11$(_context11) { 1883 while (1) { 1884 switch (_context11.prev = _context11.next) { 1885 case 0: 1886 _context11.next = 2; 1887 return this._resolveSDKState(); 1888 1889 case 2: 1890 this._throwIfNotStarted('Could not get Device Interests'); 1891 1892 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/interests"); 1893 options = { 1894 method: 'GET', 1895 path: path 1896 }; 1897 _context11.next = 7; 1898 return doRequest(options); 1899 1900 case 7: 1901 _context11.t0 = _context11.sent['interests']; 1902 1903 if (_context11.t0) { 1904 _context11.next = 10; 1905 break; 1906 } 1907 1908 _context11.t0 = []; 1909 1910 case 10: 1911 return _context11.abrupt("return", _context11.t0); 1912 1913 case 11: 1914 case "end": 1915 return _context11.stop(); 1916 } 1917 } 1918 }, _callee11, this); 1919 })); 1920 1921 function getDeviceInterests() { 1922 return _getDeviceInterests.apply(this, arguments); 1923 } 1924 1925 return getDeviceInterests; 1926 }() 1927 }, { 1928 key: "setDeviceInterests", 1929 value: function () { 1930 var _setDeviceInterests = asyncToGenerator( 1931 /*#__PURE__*/ 1932 regenerator.mark(function _callee12(interests) { 1933 var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, interest, uniqueInterests, path, options; 1934 1935 return regenerator.wrap(function _callee12$(_context12) { 1936 while (1) { 1937 switch (_context12.prev = _context12.next) { 1938 case 0: 1939 _context12.next = 2; 1940 return this._resolveSDKState(); 1941 1942 case 2: 1943 this._throwIfNotStarted('Could not set Device Interests'); 1944 1945 if (!(interests === undefined || interests === null)) { 1946 _context12.next = 5; 1947 break; 1948 } 1949 1950 throw new Error('interests argument is required'); 1951 1952 case 5: 1953 if (Array.isArray(interests)) { 1954 _context12.next = 7; 1955 break; 1956 } 1957 1958 throw new Error('interests argument must be an array'); 1959 1960 case 7: 1961 if (!(interests.length > MAX_INTERESTS_NUM)) { 1962 _context12.next = 9; 1963 break; 1964 } 1965 1966 throw new Error("Number of interests (".concat(interests.length, ") exceeds maximum of ").concat(MAX_INTERESTS_NUM)); 1967 1968 case 9: 1969 _iteratorNormalCompletion = true; 1970 _didIteratorError = false; 1971 _iteratorError = undefined; 1972 _context12.prev = 12; 1973 1974 for (_iterator = interests[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { 1975 interest = _step.value; 1976 validateInterestName(interest); 1977 } 1978 1979 _context12.next = 20; 1980 break; 1981 1982 case 16: 1983 _context12.prev = 16; 1984 _context12.t0 = _context12["catch"](12); 1985 _didIteratorError = true; 1986 _iteratorError = _context12.t0; 1987 1988 case 20: 1989 _context12.prev = 20; 1990 _context12.prev = 21; 1991 1992 if (!_iteratorNormalCompletion && _iterator["return"] != null) { 1993 _iterator["return"](); 1994 } 1995 1996 case 23: 1997 _context12.prev = 23; 1998 1999 if (!_didIteratorError) { 2000 _context12.next = 26; 2001 break; 2002 } 2003 2004 throw _iteratorError; 2005 2006 case 26: 2007 return _context12.finish(23); 2008 2009 case 27: 2010 return _context12.finish(20); 2011 2012 case 28: 2013 uniqueInterests = Array.from(new Set(interests)); 2014 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/interests"); 2015 options = { 2016 method: 'PUT', 2017 path: path, 2018 body: { 2019 interests: uniqueInterests 2020 } 2021 }; 2022 _context12.next = 33; 2023 return doRequest(options); 2024 2025 case 33: 2026 case "end": 2027 return _context12.stop(); 2028 } 2029 } 2030 }, _callee12, this, [[12, 16, 20, 28], [21,, 23, 27]]); 2031 })); 2032 2033 function setDeviceInterests(_x3) { 2034 return _setDeviceInterests.apply(this, arguments); 2035 } 2036 2037 return setDeviceInterests; 2038 }() 2039 }, {
2040 key: "clearDeviceInterests", 2041 value: function () { 2042 var _clearDeviceInterests = asyncToGenerator( 2043 /*#__PURE__*/ 2044 regenerator.mark(function _callee13() { 2045 return regenerator.wrap(function _callee13$(_context13) { 2046 while (1) { 2047 switch (_context13.prev = _context13.next) { 2048 case 0: 2049 _context13.next = 2; 2050 return this._resolveSDKState(); 2051 2052 case 2: 2053 this._throwIfNotStarted('Could not clear Device Interests'); 2054 2055 _context13.next = 5; 2056 return this.setDeviceInterests([]); 2057 2058 case 5: 2059 case "end": 2060 return _context13.stop(); 2061 } 2062 } 2063 }, _callee13, this); 2064 })); 2065 2066 function clearDeviceInterests() { 2067 return _clearDeviceInterests.apply(this, arguments); 2068 } 2069 2070 return clearDeviceInterests; 2071 }() 2072 }, { 2073 key: "setUserId", 2074 value: function () { 2075 var _setUserId = asyncToGenerator( 2076 /*#__PURE__*/ 2077 regenerator.mark(function _callee14(userId, tokenProvider) { 2078 var error, path, _ref2, beamsAuthToken, options; 2079 2080 return regenerator.wrap(function _callee14$(_context14) { 2081 while (1) { 2082 switch (_context14.prev = _context14.next) { 2083 case 0: 2084 _context14.next = 2; 2085 return this._resolveSDKState(); 2086 2087 case 2: 2088 if (isSupportedBrowser()) { 2089 _context14.next = 4; 2090 break; 2091 } 2092 2093 return _context14.abrupt("return"); 2094 2095 case 4: 2096 if (!(this._deviceId === null)) { 2097 _context14.next = 7; 2098 break; 2099 } 2100 2101 error = new Error('.start must be called before .setUserId'); 2102 return _context14.abrupt("return", Promise.reject(error)); 2103 2104 case 7: 2105 if (!(typeof userId !== 'string')) { 2106 _context14.next = 9; 2107 break; 2108 } 2109 2110 throw new Error("User ID must be a string (was ".concat(userId, ")")); 2111 2112 case 9: 2113 if (!(userId === '')) { 2114 _context14.next = 11; 2115 break; 2116 } 2117 2118 throw new Error('User ID cannot be the empty string'); 2119 2120 case 11: 2121 if (!(this._userId !== null && this._userId !== userId)) { 2122 _context14.next = 13; 2123 break; 2124 } 2125 2126 throw new Error('Changing the `userId` is not allowed.'); 2127 2128 case 13: 2129 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/user"); 2130 _context14.next = 16; 2131 return tokenProvider.fetchToken(userId); 2132 2133 case 16: 2134 _ref2 = _context14.sent; 2135 beamsAuthToken = _ref2.token; 2136 options = { 2137 method: 'PUT', 2138 path: path, 2139 headers: { 2140 Authorization: "Bearer ".concat(beamsAuthToken) 2141 } 2142 }; 2143 _context14.next = 21; 2144 return doRequest(options); 2145 2146 case 21: 2147 this._userId = userId; 2148 return _context14.abrupt("return", this._deviceStateStore.setUserId(userId)); 2149 2150 case 23: 2151 case "end": 2152 return _context14.stop(); 2153 } 2154 } 2155 }, _callee14, this); 2156 })); 2157 2158 function setUserId(_x4, _x5) { 2159 return _setUserId.apply(this, arguments); 2160 } 2161 2162 return setUserId; 2163 }() 2164 }, { 2165 key: "stop", 2166 value: function () { 2167 var _stop = asyncToGenerator( 2168 /*#__PURE__*/ 2169 regenerator.mark(function _callee15() { 2170 return regenerator.wrap(function _callee15$(_context15) { 2171 while (1) { 2172 switch (_context15.prev = _context15.next) { 2173 case 0: 2174 _context15.next = 2; 2175 return this._resolveSDKState(); 2176 2177 case 2: 2178 if (isSupportedBrowser()) { 2179 _context15.next = 4; 2180 break; 2181 } 2182 2183 return _context15.abrupt("return"); 2184 2185 case 4: 2186 if (!(this._deviceId === null)) { 2187 _context15.next = 6; 2188 break; 2189 } 2190 2191 return _context15.abrupt("return"); 2192 2193 case 6: 2194 _context15.next = 8; 2195 return this._deleteDevice(); 2196 2197 case 8: 2198 _context15.next = 10; 2199 return this._deviceStateStore.clear(); 2200 2201 case 10: 2202 this._clearPushToken()["catch"](function () {}); // Not awaiting this, best effort. 2203 2204 2205 this._deviceId = null; 2206 this._token = null; 2207 this._userId = null; 2208 2209 case 14: 2210 case "end": 2211 return _context15.stop(); 2212 } 2213 } 2214 }, _callee15, this); 2215 })); 2216 2217 function stop() { 2218 return _stop.apply(this, arguments); 2219 } 2220 2221 return stop; 2222 }() 2223 }, {
2224 key: "clearAllState", 2225 value: function () { 2226 var _clearAllState = asyncToGenerator( 2227 /*#__PURE__*/ 2228 regenerator.mark(function _callee16() { 2229 return regenerator.wrap(function _callee16$(_context16) { 2230 while (1) { 2231 switch (_context16.prev = _context16.next) { 2232 case 0: 2233 if (isSupportedBrowser()) { 2234 _context16.next = 2; 2235 break; 2236 } 2237 2238 return _context16.abrupt("return"); 2239 2240 case 2: 2241 _context16.next = 4; 2242 return this.stop(); 2243 2244 case 4: 2245 _context16.next = 6; 2246 return this.start(); 2247 2248 case 6: 2249 case "end": 2250 return _context16.stop(); 2251 } 2252 } 2253 }, _callee16, this); 2254 })); 2255 2256 function clearAllState() { 2257 return _clearAllState.apply(this, arguments); 2258 } 2259 2260 return clearAllState; 2261 }() 2262 }, { 2263 key: "_getPublicKey", 2264 value: function () { 2265 var _getPublicKey2 = asyncToGenerator( 2266 /*#__PURE__*/ 2267 regenerator.mark(function _callee17() { 2268 var path, options; 2269 return regenerator.wrap(function _callee17$(_context17) { 2270 while (1) { 2271 switch (_context17.prev = _context17.next) { 2272 case 0: 2273 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/web-vapid-public-key"); 2274 options = { 2275 method: 'GET', 2276 path: path 2277 }; 2278 return _context17.abrupt("return", doRequest(options)); 2279 2280 case 3: 2281 case "end": 2282 return _context17.stop(); 2283 } 2284 } 2285 }, _callee17, this); 2286 })); 2287 2288 function _getPublicKey() { 2289 return _getPublicKey2.apply(this, arguments); 2290 } 2291 2292 return _getPublicKey; 2293 }() 2294 }, { 2295 key: "_getPushToken", 2296 value: function () { 2297 var _getPushToken2 = asyncToGenerator( 2298 /*#__PURE__*/ 2299 regenerator.mark(function _callee18(publicKey) { 2300 var sub; 2301 return regenerator.wrap(function _callee18$(_context18) { 2302 while (1) { 2303 switch (_context18.prev = _context18.next) { 2304 case 0: 2305 _context18.prev = 0; 2306 _context18.next = 3; 2307 return this._clearPushToken(); 2308 2309 case 3: 2310 _context18.next = 5; 2311 return this._serviceWorkerRegistration.pushManager.subscribe({ 2312 userVisibleOnly: true, 2313 applicationServerKey: urlBase64ToUInt8Array(publicKey) 2314 }); 2315 2316 case 5: 2317 sub = _context18.sent; 2318 return _context18.abrupt("return", btoa(JSON.stringify(sub))); 2319 2320 case 9: 2321 _context18.prev = 9; 2322 _context18.t0 = _context18["catch"](0); 2323 return _context18.abrupt("return", Promise.reject(_context18.t0)); 2324 2325 case 12: 2326 case "end": 2327 return _context18.stop(); 2328 } 2329 } 2330 }, _callee18, this, [[0, 9]]); 2331 })); 2332 2333 function _getPushToken(_x6) { 2334 return _getPushToken2.apply(this, arguments); 2335 } 2336 2337 return _getPushToken; 2338 }() 2339 }, { 2340 key: "_clearPushToken", 2341 value: function () { 2342 var _clearPushToken2 = asyncToGenerator( 2343 /*#__PURE__*/ 2344 regenerator.mark(function _callee19() { 2345 return regenerator.wrap(function _callee19$(_context19) { 2346 while (1) { 2347 switch (_context19.prev = _context19.next) { 2348 case 0: 2349 return _context19.abrupt("return", navigator.serviceWorker.ready.then(function (reg) { 2350 return reg.pushManager.getSubscription(); 2351 }).then(function (sub) {
2352 if (sub) sub.unsubscribe(); 2353 })); 2354 2355 case 1: 2356 case "end": 2357 return _context19.stop(); 2358 } 2359 } 2360 }, _callee19); 2361 })); 2362 2363 function _clearPushToken() { 2364 return _clearPushToken2.apply(this, arguments); 2365 } 2366 2367 return _clearPushToken; 2368 }() 2369 }, { 2370 key: "_registerDevice", 2371 value: function () { 2372 var _registerDevice2 = asyncToGenerator( 2373 /*#__PURE__*/ 2374 regenerator.mark(function _callee20(token) { 2375 var path, device, options, response; 2376 return regenerator.wrap(function _callee20$(_context20) { 2377 while (1) { 2378 switch (_context20.prev = _context20.next) { 2379 case 0: 2380 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web"); 2381 device = { 2382 token: token, 2383 metadata: { 2384 sdkVersion: version 2385 } 2386 }; 2387 options = { 2388 method: 'POST', 2389 path: path, 2390 body: device 2391 }; 2392 _context20.next = 5; 2393 return doRequest(options); 2394 2395 case 5: 2396 response = _context20.sent; 2397 return _context20.abrupt("return", response.id); 2398 2399 case 7: 2400 case "end": 2401 return _context20.stop(); 2402 } 2403 } 2404 }, _callee20, this); 2405 })); 2406 2407 function _registerDevice(_x7) { 2408 return _registerDevice2.apply(this, arguments); 2409 } 2410 2411 return _registerDevice; 2412 }() 2413 }, { 2414 key: "_deleteDevice", 2415 value: function () { 2416 var _deleteDevice2 = asyncToGenerator( 2417 /*#__PURE__*/ 2418 regenerator.mark(function _callee21() { 2419 var path, options; 2420 return regenerator.wrap(function _callee21$(_context21) { 2421 while (1) { 2422 switch (_context21.prev = _context21.next) { 2423 case 0: 2424 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(encodeURIComponent(this._deviceId)); 2425 options = { 2426 method: 'DELETE', 2427 path: path 2428 }; 2429 _context21.next = 4; 2430 return doRequest(options); 2431 2432 case 4: 2433 case "end": 2434 return _context21.stop(); 2435 } 2436 } 2437 }, _callee21, this); 2438 })); 2439 2440 function _deleteDevice() { 2441 return _deleteDevice2.apply(this, arguments); 2442 } 2443 2444 return _deleteDevice; 2445 }() 2446 /** 2447 * Submit SDK version and browser details (via the user agent) to Pusher Beams. 2448 */ 2449 2450 }, { 2451 key: "_updateDeviceMetadata", 2452 value: function () { 2453 var _updateDeviceMetadata2 = asyncToGenerator( 2454 /*#__PURE__*/ 2455 regenerator.mark(function _callee22() { 2456 var userAgent, storedUserAgent, storedSdkVersion, path, metadata, options; 2457 return regenerator.wrap(function _callee22$(_context22) { 2458 while (1) { 2459 switch (_context22.prev = _context22.next) { 2460 case 0: 2461 userAgent = window.navigator.userAgent; 2462 _context22.next = 3; 2463 return this._deviceStateStore.getLastSeenUserAgent(); 2464 2465 case 3: 2466 storedUserAgent = _context22.sent; 2467 _context22.next = 6; 2468 return this._deviceStateStore.getLastSeenSdkVersion(); 2469 2470 case 6: 2471 storedSdkVersion = _context22.sent; 2472 2473 if (!(userAgent === storedUserAgent && version === storedSdkVersion)) { 2474 _context22.next = 9; 2475 break; 2476 } 2477 2478 return _context22.abrupt("return"); 2479 2480 case 9: 2481 path = "".concat(this._baseURL, "/device_api/v1/instances/").concat(encodeURIComponent(this.instanceId), "/devices/web/").concat(this._deviceId, "/metadata"); 2482 metadata = { 2483 sdkVersion: version 2484 }; 2485 options = { 2486 method: 'PUT', 2487 path: path, 2488 body: metadata 2489 }; 2490 _context22.next = 14; 2491 return doRequest(options); 2492 2493 case 14: 2494 _context22.next = 16; 2495 return this._deviceStateStore.setLastSeenSdkVersion(version); 2496 2497 case 16: 2498 _context22.next = 18; 2499 return this._deviceStateStore.setLastSeenUserAgent(userAgent); 2500 2501 case 18: 2502 case "end": 2503 return _context22.stop(); 2504 } 2505 } 2506 }, _callee22, this); 2507 })); 2508 2509 function _updateDeviceMetadata() { 2510 return _updateDeviceMetadata2.apply(this, arguments); 2511 } 2512 2513 return _updateDeviceMetadata; 2514 }() 2515 }, {
2516 key: "_baseURL", 2517 get: function get() { 2518 if (this._endpoint !== null) { 2519 return this._endpoint; 2520 } 2521 2522 return "https://".concat(this.instanceId, ".pushnotifications.pusher.com"); 2523 } 2524 }]); 2525 2526 return Client; 2527 }(); 2528 2529 var validateInterestName = function validateInterestName(interest) { 2530 if (interest === undefined || interest === null) { 2531 throw new Error('Interest name is required'); 2532 } 2533 2534 if (typeof interest !== 'string') { 2535 throw new Error("Interest ".concat(interest, " is not a string")); 2536 } 2537 2538 if (!INTERESTS_REGEX.test(interest)) { 2539 throw new Error("interest \"".concat(interest, "\" contains a forbidden character. ") + 'Allowed characters are: ASCII upper/lower-case letters, ' + 'numbers or one of _-=@,.;'); 2540 } 2541 2542 if (interest.length > MAX_INTEREST_LENGTH) { 2543 throw new Error("Interest is longer than the maximum of ".concat(MAX_INTEREST_LENGTH, " chars")); 2544 } 2545 }; 2546 2547 function getServiceWorkerRegistration() { 2548 return _getServiceWorkerRegistration.apply(this, arguments); 2549 } 2550 2551 function _getServiceWorkerRegistration() { 2552 _getServiceWorkerRegistration = asyncToGenerator( 2553 /*#__PURE__*/ 2554 regenerator.mark(function _callee23() { 2555 var _ref3, swStatusCode; 2556 2557 return regenerator.wrap(function _callee23$(_context23) { 2558 while (1) { 2559 switch (_context23.prev = _context23.next) { 2560 case 0: 2561 _context23.next = 2; 2562 return fetch(SERVICE_WORKER_URL); 2563 2564 case 2: 2565 _ref3 = _context23.sent; 2566 swStatusCode = _ref3.status; 2567 2568 if (!(swStatusCode !== 200)) { 2569 _context23.next = 6; 2570 break; 2571 } 2572 2573 throw new Error('Cannot start SDK, service worker missing: No file found at /service-worker.js'); 2574 2575 case 6: 2576 window.navigator.serviceWorker.register(SERVICE_WORKER_URL, { 2577 // explicitly opting out of `importScripts` caching just in case our 2578 // customers decides to host and serve the imported scripts and 2579 // accidentally set `Cache-Control` to something other than `max-age=0` 2580 updateViaCache: 'none' 2581 }); 2582 return _context23.abrupt("return", window.navigator.serviceWorker.ready); 2583 2584 case 8: 2585 case "end": 2586 return _context23.stop(); 2587 } 2588 } 2589 }, _callee23); 2590 })); 2591 return _getServiceWorkerRegistration.apply(this, arguments); 2592 } 2593 2594 function getWebPushToken(swReg) { 2595 return swReg.pushManager.getSubscription().then(function (sub) { 2596 return !sub ? null : encodeSubscription(sub); 2597 }); 2598 } 2599 2600 function encodeSubscription(sub) { 2601 return btoa(JSON.stringify(sub)); 2602 } 2603 2604 function urlBase64ToUInt8Array(base64String) { 2605 var padding = '='.repeat((4 - base64String.length % 4) % 4); 2606 var base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/'); 2607 var rawData = window.atob(base64); 2608 return Uint8Array.from(toConsumableArray(rawData).map(function (_char) { 2609 return _char.charCodeAt(0); 2610 })); 2611 } 2612 /** 2613 * Modified from https://stackoverflow.com/questions/4565112 2614 */ 2615 2616 2617 function isSupportedBrowser() { 2618 var winNav = window.navigator; 2619 var vendorName = winNav.vendor; 2620 var isChromium = window.chrome !== null && typeof window.chrome !== 'undefined'; 2621 var isOpera = winNav.userAgent.indexOf('OPR') > -1; 2622 var isEdge = winNav.userAgent.indexOf('Edg') > -1; 2623 var isFirefox = winNav.userAgent.indexOf('Firefox') > -1; 2624 var isChrome = isChromium && vendorName === 'Google Inc.' && !isEdge && !isOpera; 2625 var isSupported = isChrome || isOpera || isFirefox || isEdge; 2626 2627 if (!isSupported) { 2628 console.warn('Pusher Web Push Notifications supports Chrome, Firefox, Edge and Opera.'); 2629 } 2630 2631 return isSupported; 2632 } 2633 2634 exports.Client = Client; 2635 exports.RegistrationState = RegistrationState; 2636 exports.TokenProvider = TokenProvider; 2637 2638 return exports; 2639 2640}({}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.