@aws-amplify/pubsub 4.3.2 → 4.3.3-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,3 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("aws_amplify_core"),require("graphql"),require("aws_amplify_auth"),require("aws_amplify_cache")):"function"==typeof define&&define.amd?define("aws_amplify_pubsub",["aws_amplify_core","graphql","aws_amplify_auth","aws_amplify_cache"],t):"object"==typeof exports?exports.aws_amplify_pubsub=t(require("aws_amplify_core"),require("graphql"),require("aws_amplify_auth"),require("aws_amplify_cache")):e.aws_amplify_pubsub=t(e.aws_amplify_core,e.graphql,e.aws_amplify_auth,e.aws_amplify_cache)}(this,(function(e,t,n,r){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=24)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){var r=n(13),o=n(14),i=o;i.v1=r,i.v4=o,e.exports=i},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";(function(e){
2
- /*!
3
- * The buffer module from node.js, for the browser.
4
- *
5
- * @author Feross Aboukhadijeh <http://feross.org>
6
- * @license MIT
7
- */
8
- var r=n(21),o=n(22),i=n(23);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=l(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),o=(e=a(e,r)).write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):l(e,t);if("Buffer"===t.type&&i(t.data))return l(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(h(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function l(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(e).length;default:if(r)return j(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function v(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,o);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var h=-1;for(i=n;i<a;i++)if(u(e,i)===u(t,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===c)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var f=!0,l=0;l<c;l++)if(u(e,i+l)!==u(t,l)){f=!1;break}if(f)return i}return-1}function _(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function m(e,t,n,r){return F(j(t,e.length-n),e,n,r)}function w(e,t,n,r){return F(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return w(e,t,n,r)}function S(e,t,n,r){return F(V(t),e,n,r)}function A(e,t,n,r){return F(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function O(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,u=e[o],h=null,f=u>239?4:u>223?3:u>191?2:1;if(o+f<=n)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(h=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),o+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return h(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},c.byteLength=d,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)v(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)v(this,t,t+3),v(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)v(this,t,t+7),v(this,t+1,t+6),v(this,t+2,t+5),v(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?I(this,0,e):y.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,o){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),h=e.slice(t,n),f=0;f<a;++f)if(u[f]!==h[f]){i=u[f],s=h[f];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return m(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function C(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function R(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=B(e[i]);return o}function N(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function k(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function U(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return i||U(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,i){return i||U(e,0,n,8),o.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var o=t-e;n=new c(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},c.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:j(new c(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function B(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function V(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,n(3))},function(e,t){e.exports=n},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var o=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,o=n;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}},function(e,t,n){e.exports=n(12).Observable},function(e,t,n){(function(t){var n;n=function(){return function(e){var t,n=e.localStorage||(t={},{setItem:function(e,n){t[e]=n},getItem:function(e){return t[e]},removeItem:function(e){delete t[e]}}),r=1,o=2,i=3,s=4,a=5,c=6,u=7,h=8,f=9,l=10,p=11,d=12,y=13,v=14,g=function(e,t){for(var n in e)if(e.hasOwnProperty(n)){if(!t.hasOwnProperty(n)){var r="Unknown property, "+n+". Valid properties are:";for(var o in t)t.hasOwnProperty(o)&&(r=r+" "+o);throw new Error(r)}if(typeof e[n]!==t[n])throw new Error(w(_.INVALID_TYPE,[typeof e[n],n]))}},b=function(e,t){return function(){return e.apply(t,arguments)}},_={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."},BUFFER_FULL:{code:18,text:"AMQJS0018E Message buffer is full, maximum buffer size: {0}."}},m={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},w=function(e,t){var n=e.text;if(t)for(var r,o,i=0;i<t.length;i++)if(r="{"+i+"}",(o=n.indexOf(r))>0){var s=n.substring(0,o),a=n.substring(o+r.length);n=s+t[i]+a}return n},E=[0,6,77,81,73,115,100,112,3],S=[0,4,77,81,84,84,4],A=function(e,t){for(var n in this.type=e,t)t.hasOwnProperty(n)&&(this[n]=t[n])};function O(e,t){var n,r=t,h=e[t],l=h>>4,d=h&=15;t+=1;var y=0,v=1;do{if(t==e.length)return[null,r];y+=(127&(n=e[t++]))*v,v*=128}while(0!=(128&n));var g=t+y;if(g>e.length)return[null,r];var b=new A(l);switch(l){case o:1&e[t++]&&(b.sessionPresent=!0),b.returnCode=e[t++];break;case i:var _=d>>1&3,m=C(e,t),w=M(e,t+=2,m);t+=m,_>0&&(b.messageIdentifier=C(e,t),t+=2);var E=new U(e.subarray(t,g));1==(1&d)&&(E.retained=!0),8==(8&d)&&(E.duplicate=!0),E.qos=_,E.destinationName=w,b.payloadMessage=E;break;case s:case a:case c:case u:case p:b.messageIdentifier=C(e,t);break;case f:b.messageIdentifier=C(e,t),t+=2,b.returnCode=e.subarray(t,g)}return[b,g]}function I(e,t,n){return t[n++]=e>>8,t[n++]=e%256,n}function T(e,t,n,r){return N(e,n,r=I(t,n,r)),r+t}function C(e,t){return 256*e[t]+e[t+1]}function R(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);r>2047?(55296<=r&&r<=56319&&(n++,t++),t+=3):r>127?t+=2:t++}return t}function N(e,t,n){for(var r=n,o=0;o<e.length;o++){var i=e.charCodeAt(o);if(55296<=i&&i<=56319){var s=e.charCodeAt(++o);if(isNaN(s))throw new Error(w(_.MALFORMED_UNICODE,[i,s]));i=s-56320+(i-55296<<10)+65536}i<=127?t[r++]=i:i<=2047?(t[r++]=i>>6&31|192,t[r++]=63&i|128):i<=65535?(t[r++]=i>>12&15|224,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>18&7|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t}function M(e,t,n){for(var r,o="",i=t;i<t+n;){var s=e[i++];if(s<128)r=s;else{var a=e[i++]-128;if(a<0)throw new Error(w(_.MALFORMED_UTF,[s.toString(16),a.toString(16),""]));if(s<224)r=64*(s-192)+a;else{var c=e[i++]-128;if(c<0)throw new Error(w(_.MALFORMED_UTF,[s.toString(16),a.toString(16),c.toString(16)]));if(s<240)r=4096*(s-224)+64*a+c;else{var u=e[i++]-128;if(u<0)throw new Error(w(_.MALFORMED_UTF,[s.toString(16),a.toString(16),c.toString(16),u.toString(16)]));if(!(s<248))throw new Error(w(_.MALFORMED_UTF,[s.toString(16),a.toString(16),c.toString(16),u.toString(16)]));r=262144*(s-240)+4096*a+64*c+u}}}r>65535&&(r-=65536,o+=String.fromCharCode(55296+(r>>10)),r=56320+(1023&r)),o+=String.fromCharCode(r)}return o}A.prototype.encode=function(){var e,t=(15&this.type)<<4,n=0,o=[],s=0;switch(void 0!==this.messageIdentifier&&(n+=2),this.type){case r:switch(this.mqttVersion){case 3:n+=E.length+3;break;case 4:n+=S.length+3}n+=R(this.clientId)+2,void 0!==this.willMessage&&(n+=R(this.willMessage.destinationName)+2,(e=this.willMessage.payloadBytes)instanceof Uint8Array||(e=new Uint8Array(u)),n+=e.byteLength+2),void 0!==this.userName&&(n+=R(this.userName)+2),void 0!==this.password&&(n+=R(this.password)+2);break;case h:t|=2;for(var a=0;a<this.topics.length;a++)o[a]=R(this.topics[a]),n+=o[a]+2;n+=this.requestedQos.length;break;case l:for(t|=2,a=0;a<this.topics.length;a++)o[a]=R(this.topics[a]),n+=o[a]+2;break;case c:t|=2;break;case i:this.payloadMessage.duplicate&&(t|=8),t=t|=this.payloadMessage.qos<<1,this.payloadMessage.retained&&(t|=1),n+=(s=R(this.payloadMessage.destinationName))+2;var u=this.payloadMessage.payloadBytes;n+=u.byteLength,u instanceof ArrayBuffer?u=new Uint8Array(u):u instanceof Uint8Array||(u=new Uint8Array(u.buffer))}var f=function(e){var t=new Array(1),n=0;do{var r=e%128;(e>>=7)>0&&(r|=128),t[n++]=r}while(e>0&&n<4);return t}(n),p=f.length+1,d=new ArrayBuffer(n+p),y=new Uint8Array(d);if(y[0]=t,y.set(f,1),this.type==i)p=T(this.payloadMessage.destinationName,s,y,p);else if(this.type==r){switch(this.mqttVersion){case 3:y.set(E,p),p+=E.length;break;case 4:y.set(S,p),p+=S.length}var v=0;this.cleanSession&&(v=2),void 0!==this.willMessage&&(v|=4,v|=this.willMessage.qos<<3,this.willMessage.retained&&(v|=32)),void 0!==this.userName&&(v|=128),void 0!==this.password&&(v|=64),y[p++]=v,p=I(this.keepAliveInterval,y,p)}switch(void 0!==this.messageIdentifier&&(p=I(this.messageIdentifier,y,p)),this.type){case r:p=T(this.clientId,R(this.clientId),y,p),void 0!==this.willMessage&&(p=T(this.willMessage.destinationName,R(this.willMessage.destinationName),y,p),p=I(e.byteLength,y,p),y.set(e,p),p+=e.byteLength),void 0!==this.userName&&(p=T(this.userName,R(this.userName),y,p)),void 0!==this.password&&(p=T(this.password,R(this.password),y,p));break;case i:y.set(u,p);break;case h:for(a=0;a<this.topics.length;a++)p=T(this.topics[a],o[a],y,p),y[p++]=this.requestedQos[a];break;case l:for(a=0;a<this.topics.length;a++)p=T(this.topics[a],o[a],y,p)}return d};var P=function(e,t){this._client=e,this._keepAliveInterval=1e3*t,this.isReset=!1;var n=new A(d).encode(),r=function(e){return function(){return o.apply(e)}},o=function(){this.isReset?(this.isReset=!1,this._client._trace("Pinger.doPing","send PINGREQ"),this._client.socket.send(n),this.timeout=setTimeout(r(this),this._keepAliveInterval)):(this._client._trace("Pinger.doPing","Timed out"),this._client._disconnected(_.PING_TIMEOUT.code,w(_.PING_TIMEOUT)))};this.reset=function(){this.isReset=!0,clearTimeout(this.timeout),this._keepAliveInterval>0&&(this.timeout=setTimeout(r(this),this._keepAliveInterval))},this.cancel=function(){clearTimeout(this.timeout)}},k=function(e,t,n,r){t||(t=30),this.timeout=setTimeout(function(e,t,n){return function(){return e.apply(t,n)}}(n,e,r),1e3*t),this.cancel=function(){clearTimeout(this.timeout)}},x=function(t,r,o,i,s){if(!("WebSocket"in e)||null===e.WebSocket)throw new Error(w(_.UNSUPPORTED,["WebSocket"]));if(!("ArrayBuffer"in e)||null===e.ArrayBuffer)throw new Error(w(_.UNSUPPORTED,["ArrayBuffer"]));for(var a in this._trace("Paho.Client",t,r,o,i,s),this.host=r,this.port=o,this.path=i,this.uri=t,this.clientId=s,this._wsuri=null,this._localKey=r+":"+o+("/mqtt"!=i?":"+i:"")+":"+s+":",this._msg_queue=[],this._buffered_msg_queue=[],this._sentMessages={},this._receivedMessages={},this._notify_msg_sent={},this._message_identifier=1,this._sequence=0,n)0!==a.indexOf("Sent:"+this._localKey)&&0!==a.indexOf("Received:"+this._localKey)||this.restore(a)};x.prototype.host=null,x.prototype.port=null,x.prototype.path=null,x.prototype.uri=null,x.prototype.clientId=null,x.prototype.socket=null,x.prototype.connected=!1,x.prototype.maxMessageIdentifier=65536,x.prototype.connectOptions=null,x.prototype.hostIndex=null,x.prototype.onConnected=null,x.prototype.onConnectionLost=null,x.prototype.onMessageDelivered=null,x.prototype.onMessageArrived=null,x.prototype.traceFunction=null,x.prototype._msg_queue=null,x.prototype._buffered_msg_queue=null,x.prototype._connectTimeout=null,x.prototype.sendPinger=null,x.prototype.receivePinger=null,x.prototype._reconnectInterval=1,x.prototype._reconnecting=!1,x.prototype._reconnectTimeout=null,x.prototype.disconnectedPublishing=!1,x.prototype.disconnectedBufferSize=5e3,x.prototype.receiveBuffer=null,x.prototype._traceBuffer=null,x.prototype._MAX_TRACE_ENTRIES=100,x.prototype.connect=function(e){var t=this._traceMask(e,"password");if(this._trace("Client.connect",t,this.socket,this.connected),this.connected)throw new Error(w(_.INVALID_STATE,["already connected"]));if(this.socket)throw new Error(w(_.INVALID_STATE,["already connected"]));this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),this.connectOptions=e,this._reconnectInterval=1,this._reconnecting=!1,e.uris?(this.hostIndex=0,this._doConnect(e.uris[0])):this._doConnect(this.uri)},x.prototype.subscribe=function(e,t){if(this._trace("Client.subscribe",e,t),!this.connected)throw new Error(w(_.INVALID_STATE,["not connected"]));var n=new A(h);n.topics=e.constructor===Array?e:[e],void 0===t.qos&&(t.qos=0),n.requestedQos=[];for(var r=0;r<n.topics.length;r++)n.requestedQos[r]=t.qos;t.onSuccess&&(n.onSuccess=function(e){t.onSuccess({invocationContext:t.invocationContext,grantedQos:e})}),t.onFailure&&(n.onFailure=function(e){t.onFailure({invocationContext:t.invocationContext,errorCode:e,errorMessage:w(e)})}),t.timeout&&(n.timeOut=new k(this,t.timeout,t.onFailure,[{invocationContext:t.invocationContext,errorCode:_.SUBSCRIBE_TIMEOUT.code,errorMessage:w(_.SUBSCRIBE_TIMEOUT)}])),this._requires_ack(n),this._schedule_message(n)},x.prototype.unsubscribe=function(e,t){if(this._trace("Client.unsubscribe",e,t),!this.connected)throw new Error(w(_.INVALID_STATE,["not connected"]));var n=new A(l);n.topics=e.constructor===Array?e:[e],t.onSuccess&&(n.callback=function(){t.onSuccess({invocationContext:t.invocationContext})}),t.timeout&&(n.timeOut=new k(this,t.timeout,t.onFailure,[{invocationContext:t.invocationContext,errorCode:_.UNSUBSCRIBE_TIMEOUT.code,errorMessage:w(_.UNSUBSCRIBE_TIMEOUT)}])),this._requires_ack(n),this._schedule_message(n)},x.prototype.send=function(e){this._trace("Client.send",e);var t=new A(i);if(t.payloadMessage=e,this.connected)e.qos>0?this._requires_ack(t):this.onMessageDelivered&&(this._notify_msg_sent[t]=this.onMessageDelivered(t.payloadMessage)),this._schedule_message(t);else{if(!this._reconnecting||!this.disconnectedPublishing)throw new Error(w(_.INVALID_STATE,["not connected"]));if(Object.keys(this._sentMessages).length+this._buffered_msg_queue.length>this.disconnectedBufferSize)throw new Error(w(_.BUFFER_FULL,[this.disconnectedBufferSize]));e.qos>0?this._requires_ack(t):(t.sequence=++this._sequence,this._buffered_msg_queue.unshift(t))}},x.prototype.disconnect=function(){if(this._trace("Client.disconnect"),this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),!this.socket)throw new Error(w(_.INVALID_STATE,["not connecting or connected"]));var e=new A(v);this._notify_msg_sent[e]=b(this._disconnected,this),this._schedule_message(e)},x.prototype.getTraceLog=function(){if(null!==this._traceBuffer){for(var e in this._trace("Client.getTraceLog",new Date),this._trace("Client.getTraceLog in flight messages",this._sentMessages.length),this._sentMessages)this._trace("_sentMessages ",e,this._sentMessages[e]);for(var e in this._receivedMessages)this._trace("_receivedMessages ",e,this._receivedMessages[e]);return this._traceBuffer}},x.prototype.startTrace=function(){null===this._traceBuffer&&(this._traceBuffer=[]),this._trace("Client.startTrace",new Date,"@VERSION@-@BUILDLEVEL@")},x.prototype.stopTrace=function(){delete this._traceBuffer},x.prototype._doConnect=function(e){if(this.connectOptions.useSSL){var t=e.split(":");t[0]="wss",e=t.join(":")}this._wsuri=e,this.connected=!1,this.connectOptions.mqttVersion<4?this.socket=new WebSocket(e,["mqttv3.1"]):this.socket=new WebSocket(e,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=b(this._on_socket_open,this),this.socket.onmessage=b(this._on_socket_message,this),this.socket.onerror=b(this._on_socket_error,this),this.socket.onclose=b(this._on_socket_close,this),this.sendPinger=new P(this,this.connectOptions.keepAliveInterval),this.receivePinger=new P(this,this.connectOptions.keepAliveInterval),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._connectTimeout=new k(this,this.connectOptions.timeout,this._disconnected,[_.CONNECT_TIMEOUT.code,w(_.CONNECT_TIMEOUT)])},x.prototype._schedule_message=function(e){this._msg_queue.unshift(e),this.connected&&this._process_queue()},x.prototype.store=function(e,t){var r={type:t.type,messageIdentifier:t.messageIdentifier,version:1};switch(t.type){case i:t.pubRecReceived&&(r.pubRecReceived=!0),r.payloadMessage={};for(var o="",s=t.payloadMessage.payloadBytes,a=0;a<s.length;a++)s[a]<=15?o=o+"0"+s[a].toString(16):o+=s[a].toString(16);r.payloadMessage.payloadHex=o,r.payloadMessage.qos=t.payloadMessage.qos,r.payloadMessage.destinationName=t.payloadMessage.destinationName,t.payloadMessage.duplicate&&(r.payloadMessage.duplicate=!0),t.payloadMessage.retained&&(r.payloadMessage.retained=!0),0===e.indexOf("Sent:")&&(void 0===t.sequence&&(t.sequence=++this._sequence),r.sequence=t.sequence);break;default:throw Error(w(_.INVALID_STORED_DATA,[e+this._localKey+t.messageIdentifier,r]))}n.setItem(e+this._localKey+t.messageIdentifier,JSON.stringify(r))},x.prototype.restore=function(e){var t=n.getItem(e),r=JSON.parse(t),o=new A(r.type,r);switch(r.type){case i:for(var s=r.payloadMessage.payloadHex,a=new ArrayBuffer(s.length/2),c=new Uint8Array(a),u=0;s.length>=2;){var h=parseInt(s.substring(0,2),16);s=s.substring(2,s.length),c[u++]=h}var f=new U(c);f.qos=r.payloadMessage.qos,f.destinationName=r.payloadMessage.destinationName,r.payloadMessage.duplicate&&(f.duplicate=!0),r.payloadMessage.retained&&(f.retained=!0),o.payloadMessage=f;break;default:throw Error(w(_.INVALID_STORED_DATA,[e,t]))}0===e.indexOf("Sent:"+this._localKey)?(o.payloadMessage.duplicate=!0,this._sentMessages[o.messageIdentifier]=o):0===e.indexOf("Received:"+this._localKey)&&(this._receivedMessages[o.messageIdentifier]=o)},x.prototype._process_queue=function(){for(var e=null;e=this._msg_queue.pop();)this._socket_send(e),this._notify_msg_sent[e]&&(this._notify_msg_sent[e](),delete this._notify_msg_sent[e])},x.prototype._requires_ack=function(e){var t=Object.keys(this._sentMessages).length;if(t>this.maxMessageIdentifier)throw Error("Too many messages:"+t);for(;void 0!==this._sentMessages[this._message_identifier];)this._message_identifier++;e.messageIdentifier=this._message_identifier,this._sentMessages[e.messageIdentifier]=e,e.type===i&&this.store("Sent:",e),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},x.prototype._on_socket_open=function(){var e=new A(r,this.connectOptions);e.clientId=this.clientId,this._socket_send(e)},x.prototype._on_socket_message=function(e){this._trace("Client._on_socket_message",e.data);for(var t=this._deframeMessages(e.data),n=0;n<t.length;n+=1)this._handleMessage(t[n])},x.prototype._deframeMessages=function(e){var t=new Uint8Array(e),n=[];if(this.receiveBuffer){var r=new Uint8Array(this.receiveBuffer.length+t.length);r.set(this.receiveBuffer),r.set(t,this.receiveBuffer.length),t=r,delete this.receiveBuffer}try{for(var o=0;o<t.length;){var i=O(t,o),s=i[0];if(o=i[1],null===s)break;n.push(s)}o<t.length&&(this.receiveBuffer=t.subarray(o))}catch(e){var a="undefined"==e.hasOwnProperty("stack")?e.stack.toString():"No Error Stack Available";return void this._disconnected(_.INTERNAL_ERROR.code,w(_.INTERNAL_ERROR,[e.message,a]))}return n},x.prototype._handleMessage=function(e){this._trace("Client._handleMessage",e);try{switch(e.type){case o:if(this._connectTimeout.cancel(),this._reconnectTimeout&&this._reconnectTimeout.cancel(),this.connectOptions.cleanSession){for(var t in this._sentMessages){var r=this._sentMessages[t];n.removeItem("Sent:"+this._localKey+r.messageIdentifier)}for(var t in this._sentMessages={},this._receivedMessages){var h=this._receivedMessages[t];n.removeItem("Received:"+this._localKey+h.messageIdentifier)}this._receivedMessages={}}if(0!==e.returnCode){this._disconnected(_.CONNACK_RETURNCODE.code,w(_.CONNACK_RETURNCODE,[e.returnCode,m[e.returnCode]]));break}this.connected=!0,this.connectOptions.uris&&(this.hostIndex=this.connectOptions.uris.length);var l=[];for(var d in this._sentMessages)this._sentMessages.hasOwnProperty(d)&&l.push(this._sentMessages[d]);if(this._buffered_msg_queue.length>0)for(var g=null;g=this._buffered_msg_queue.pop();)l.push(g),this.onMessageDelivered&&(this._notify_msg_sent[g]=this.onMessageDelivered(g.payloadMessage));l=l.sort((function(e,t){return e.sequence-t.sequence}));for(var b=0,E=l.length;b<E;b++)if((r=l[b]).type==i&&r.pubRecReceived){var S=new A(c,{messageIdentifier:r.messageIdentifier});this._schedule_message(S)}else this._schedule_message(r);this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext});var O=!1;this._reconnecting&&(O=!0,this._reconnectInterval=1,this._reconnecting=!1),this._connected(O,this._wsuri),this._process_queue();break;case i:this._receivePublish(e);break;case s:(r=this._sentMessages[e.messageIdentifier])&&(delete this._sentMessages[e.messageIdentifier],n.removeItem("Sent:"+this._localKey+e.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(r.payloadMessage));break;case a:(r=this._sentMessages[e.messageIdentifier])&&(r.pubRecReceived=!0,S=new A(c,{messageIdentifier:e.messageIdentifier}),this.store("Sent:",r),this._schedule_message(S));break;case c:h=this._receivedMessages[e.messageIdentifier],n.removeItem("Received:"+this._localKey+e.messageIdentifier),h&&(this._receiveMessage(h),delete this._receivedMessages[e.messageIdentifier]);var I=new A(u,{messageIdentifier:e.messageIdentifier});this._schedule_message(I);break;case u:r=this._sentMessages[e.messageIdentifier],delete this._sentMessages[e.messageIdentifier],n.removeItem("Sent:"+this._localKey+e.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(r.payloadMessage);break;case f:(r=this._sentMessages[e.messageIdentifier])&&(r.timeOut&&r.timeOut.cancel(),128===e.returnCode[0]?r.onFailure&&r.onFailure(e.returnCode):r.onSuccess&&r.onSuccess(e.returnCode),delete this._sentMessages[e.messageIdentifier]);break;case p:(r=this._sentMessages[e.messageIdentifier])&&(r.timeOut&&r.timeOut.cancel(),r.callback&&r.callback(),delete this._sentMessages[e.messageIdentifier]);break;case y:this.sendPinger.reset();break;case v:this._disconnected(_.INVALID_MQTT_MESSAGE_TYPE.code,w(_.INVALID_MQTT_MESSAGE_TYPE,[e.type]));break;default:this._disconnected(_.INVALID_MQTT_MESSAGE_TYPE.code,w(_.INVALID_MQTT_MESSAGE_TYPE,[e.type]))}}catch(e){var T="undefined"==e.hasOwnProperty("stack")?e.stack.toString():"No Error Stack Available";return void this._disconnected(_.INTERNAL_ERROR.code,w(_.INTERNAL_ERROR,[e.message,T]))}},x.prototype._on_socket_error=function(e){this._reconnecting||this._disconnected(_.SOCKET_ERROR.code,w(_.SOCKET_ERROR,[e.data]))},x.prototype._on_socket_close=function(){this._reconnecting||this._disconnected(_.SOCKET_CLOSE.code,w(_.SOCKET_CLOSE))},x.prototype._socket_send=function(e){if(1==e.type){var t=this._traceMask(e,"password");this._trace("Client._socket_send",t)}else this._trace("Client._socket_send",e);this.socket.send(e.encode()),this.sendPinger.reset()},x.prototype._receivePublish=function(e){switch(e.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(e);break;case 1:var t=new A(s,{messageIdentifier:e.messageIdentifier});this._schedule_message(t),this._receiveMessage(e);break;case 2:this._receivedMessages[e.messageIdentifier]=e,this.store("Received:",e);var n=new A(a,{messageIdentifier:e.messageIdentifier});this._schedule_message(n);break;default:throw Error("Invaild qos="+e.payloadMessage.qos)}},x.prototype._receiveMessage=function(e){this.onMessageArrived&&this.onMessageArrived(e.payloadMessage)},x.prototype._connected=function(e,t){this.onConnected&&this.onConnected(e,t)},x.prototype._reconnect=function(){this._trace("Client._reconnect"),this.connected||(this._reconnecting=!0,this.sendPinger.cancel(),this.receivePinger.cancel(),this._reconnectInterval<128&&(this._reconnectInterval=2*this._reconnectInterval),this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri))},x.prototype._disconnected=function(e,t){if(this._trace("Client._disconnected",e,t),void 0!==e&&this._reconnecting)this._reconnectTimeout=new k(this,this._reconnectInterval,this._reconnect);else if(this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._msg_queue=[],this._buffered_msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,1===this.socket.readyState&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndex<this.connectOptions.uris.length-1)this.hostIndex++,this._doConnect(this.connectOptions.uris[this.hostIndex]);else if(void 0===e&&(e=_.OK.code,t=w(_.OK)),this.connected){if(this.connected=!1,this.onConnectionLost&&this.onConnectionLost({errorCode:e,errorMessage:t,reconnect:this.connectOptions.reconnect,uri:this._wsuri}),e!==_.OK.code&&this.connectOptions.reconnect)return this._reconnectInterval=1,void this._reconnect()}else 4===this.connectOptions.mqttVersion&&!1===this.connectOptions.mqttVersionExplicit?(this._trace("Failed to connect V4, dropping back to V3"),this.connectOptions.mqttVersion=3,this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri)):this.connectOptions.onFailure&&this.connectOptions.onFailure({invocationContext:this.connectOptions.invocationContext,errorCode:e,errorMessage:t})},x.prototype._trace=function(){if(this.traceFunction){var e=Array.prototype.slice.call(arguments);for(var t in e)void 0!==e[t]&&e.splice(t,1,JSON.stringify(e[t]));var n=e.join("");this.traceFunction({severity:"Debug",message:n})}if(null!==this._traceBuffer){t=0;for(var r=arguments.length;t<r;t++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),0===t||void 0===arguments[t]?this._traceBuffer.push(arguments[t]):this._traceBuffer.push(" "+JSON.stringify(arguments[t]))}},x.prototype._traceMask=function(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=r==t?"******":e[r]);return n};var U=function(e){var t,n;if(!("string"==typeof e||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)))throw w(_.INVALID_ARGUMENT,[e,"newPayload"]);t=e;var r=0,o=!1,i=!1;Object.defineProperties(this,{payloadString:{enumerable:!0,get:function(){return"string"==typeof t?t:M(t,0,t.length)}},payloadBytes:{enumerable:!0,get:function(){if("string"==typeof t){var e=new ArrayBuffer(R(t)),n=new Uint8Array(e);return N(t,n,0),n}return t}},destinationName:{enumerable:!0,get:function(){return n},set:function(e){if("string"!=typeof e)throw new Error(w(_.INVALID_ARGUMENT,[e,"newDestinationName"]));n=e}},qos:{enumerable:!0,get:function(){return r},set:function(e){if(0!==e&&1!==e&&2!==e)throw new Error("Invalid argument:"+e);r=e}},retained:{enumerable:!0,get:function(){return o},set:function(e){if("boolean"!=typeof e)throw new Error(w(_.INVALID_ARGUMENT,[e,"newRetained"]));o=e}},topic:{enumerable:!0,get:function(){return n},set:function(e){n=e}},duplicate:{enumerable:!0,get:function(){return i},set:function(e){i=e}}})};return{Client:function(e,t,n,r){var o;if("string"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"host"]));if(2==arguments.length){r=t;var i=(o=e).match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(!i)throw new Error(w(_.INVALID_ARGUMENT,[e,"host"]));e=i[4]||i[2],t=parseInt(i[7]),n=i[8]}else{if(3==arguments.length&&(r=n,n="/mqtt"),"number"!=typeof t||t<0)throw new Error(w(_.INVALID_TYPE,[typeof t,"port"]));if("string"!=typeof n)throw new Error(w(_.INVALID_TYPE,[typeof n,"path"]));var s=-1!==e.indexOf(":")&&"["!==e.slice(0,1)&&"]"!==e.slice(-1);o="ws://"+(s?"["+e+"]":e)+":"+t+n}for(var a=0,c=0;c<r.length;c++){var u=r.charCodeAt(c);55296<=u&&u<=56319&&c++,a++}if("string"!=typeof r||a>65535)throw new Error(w(_.INVALID_ARGUMENT,[r,"clientId"]));var h=new x(o,e,t,n,r);Object.defineProperties(this,{host:{get:function(){return e},set:function(){throw new Error(w(_.UNSUPPORTED_OPERATION))}},port:{get:function(){return t},set:function(){throw new Error(w(_.UNSUPPORTED_OPERATION))}},path:{get:function(){return n},set:function(){throw new Error(w(_.UNSUPPORTED_OPERATION))}},uri:{get:function(){return o},set:function(){throw new Error(w(_.UNSUPPORTED_OPERATION))}},clientId:{get:function(){return h.clientId},set:function(){throw new Error(w(_.UNSUPPORTED_OPERATION))}},onConnected:{get:function(){return h.onConnected},set:function(e){if("function"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"onConnected"]));h.onConnected=e}},disconnectedPublishing:{get:function(){return h.disconnectedPublishing},set:function(e){h.disconnectedPublishing=e}},disconnectedBufferSize:{get:function(){return h.disconnectedBufferSize},set:function(e){h.disconnectedBufferSize=e}},onConnectionLost:{get:function(){return h.onConnectionLost},set:function(e){if("function"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"onConnectionLost"]));h.onConnectionLost=e}},onMessageDelivered:{get:function(){return h.onMessageDelivered},set:function(e){if("function"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"onMessageDelivered"]));h.onMessageDelivered=e}},onMessageArrived:{get:function(){return h.onMessageArrived},set:function(e){if("function"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"onMessageArrived"]));h.onMessageArrived=e}},trace:{get:function(){return h.traceFunction},set:function(e){if("function"!=typeof e)throw new Error(w(_.INVALID_TYPE,[typeof e,"onTrace"]));h.traceFunction=e}}}),this.connect=function(e){if(g(e=e||{},{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",reconnect:"boolean",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),void 0===e.keepAliveInterval&&(e.keepAliveInterval=60),e.mqttVersion>4||e.mqttVersion<3)throw new Error(w(_.INVALID_ARGUMENT,[e.mqttVersion,"connectOptions.mqttVersion"]));if(void 0===e.mqttVersion?(e.mqttVersionExplicit=!1,e.mqttVersion=4):e.mqttVersionExplicit=!0,void 0!==e.password&&void 0===e.userName)throw new Error(w(_.INVALID_ARGUMENT,[e.password,"connectOptions.password"]));if(e.willMessage){if(!(e.willMessage instanceof U))throw new Error(w(_.INVALID_TYPE,[e.willMessage,"connectOptions.willMessage"]));if(e.willMessage.stringPayload=null,void 0===e.willMessage.destinationName)throw new Error(w(_.INVALID_TYPE,[typeof e.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if(void 0===e.cleanSession&&(e.cleanSession=!0),e.hosts){if(!(e.hosts instanceof Array))throw new Error(w(_.INVALID_ARGUMENT,[e.hosts,"connectOptions.hosts"]));if(e.hosts.length<1)throw new Error(w(_.INVALID_ARGUMENT,[e.hosts,"connectOptions.hosts"]));for(var t=!1,r=0;r<e.hosts.length;r++){if("string"!=typeof e.hosts[r])throw new Error(w(_.INVALID_TYPE,[typeof e.hosts[r],"connectOptions.hosts["+r+"]"]));if(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(e.hosts[r])){if(0===r)t=!0;else if(!t)throw new Error(w(_.INVALID_ARGUMENT,[e.hosts[r],"connectOptions.hosts["+r+"]"]))}else if(t)throw new Error(w(_.INVALID_ARGUMENT,[e.hosts[r],"connectOptions.hosts["+r+"]"]))}if(t)e.uris=e.hosts;else{if(!e.ports)throw new Error(w(_.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));if(!(e.ports instanceof Array))throw new Error(w(_.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));if(e.hosts.length!==e.ports.length)throw new Error(w(_.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));for(e.uris=[],r=0;r<e.hosts.length;r++){if("number"!=typeof e.ports[r]||e.ports[r]<0)throw new Error(w(_.INVALID_TYPE,[typeof e.ports[r],"connectOptions.ports["+r+"]"]));var i=e.hosts[r],s=e.ports[r],a=-1!==i.indexOf(":");o="ws://"+(a?"["+i+"]":i)+":"+s+n,e.uris.push(o)}}}h.connect(e)},this.subscribe=function(e,t){if("string"!=typeof e&&e.constructor!==Array)throw new Error("Invalid argument:"+e);if(g(t=t||{},{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),t.timeout&&!t.onFailure)throw new Error("subscribeOptions.timeout specified with no onFailure callback.");if(void 0!==t.qos&&0!==t.qos&&1!==t.qos&&2!==t.qos)throw new Error(w(_.INVALID_ARGUMENT,[t.qos,"subscribeOptions.qos"]));h.subscribe(e,t)},this.unsubscribe=function(e,t){if("string"!=typeof e&&e.constructor!==Array)throw new Error("Invalid argument:"+e);if(g(t=t||{},{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),t.timeout&&!t.onFailure)throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");h.unsubscribe(e,t)},this.send=function(e,t,n,r){var o;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(e instanceof U)&&"string"!=typeof e)throw new Error("Invalid argument:"+typeof e);if(void 0===(o=e).destinationName)throw new Error(w(_.INVALID_ARGUMENT,[o.destinationName,"Message.destinationName"]));h.send(o)}else(o=new U(t)).destinationName=e,arguments.length>=3&&(o.qos=n),arguments.length>=4&&(o.retained=r),h.send(o)},this.publish=function(e,t,n,r){var o;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(e instanceof U)&&"string"!=typeof e)throw new Error("Invalid argument:"+typeof e);if(void 0===(o=e).destinationName)throw new Error(w(_.INVALID_ARGUMENT,[o.destinationName,"Message.destinationName"]));h.send(o)}else(o=new U(t)).destinationName=e,arguments.length>=3&&(o.qos=n),arguments.length>=4&&(o.retained=r),h.send(o)},this.disconnect=function(){h.disconnect()},this.getTraceLog=function(){return h.getTraceLog()},this.startTrace=function(){h.startTrace()},this.stopTrace=function(){h.stopTrace()},this.isConnected=function(){return h.connected}},Message:U}}(void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},e.exports=n()}).call(this,n(3))},function(e,t,n){"use strict";var r=n(15),o=n(17);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=_,t.resolve=function(e,t){return _(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?_(e,!1,!0).resolveObject(t):t},t.format=function(e){o.isString(e)&&(e=_(e));return e instanceof i?e.format():i.prototype.format.call(e)},t.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(u),f=["%","/","?",";","#"].concat(h),l=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=n(18);function _(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",u=e.split(a);u[0]=u[0].replace(/\\/g,"/");var _=e=u.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var m=c.exec(_);if(m)return this.path=_,this.href=_,this.pathname=m[1],m[2]?(this.search=m[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=s.exec(_);if(w){var E=(w=w[0]).toLowerCase();this.protocol=E,_=_.substr(w.length)}if(n||w||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var S="//"===_.substr(0,2);!S||w&&v[w]||(_=_.substr(2),this.slashes=!0)}if(!v[w]&&(S||w&&!g[w])){for(var A,O,I=-1,T=0;T<l.length;T++){-1!==(C=_.indexOf(l[T]))&&(-1===I||C<I)&&(I=C)}-1!==(O=-1===I?_.lastIndexOf("@"):_.lastIndexOf("@",I))&&(A=_.slice(0,O),_=_.slice(O+1),this.auth=decodeURIComponent(A)),I=-1;for(T=0;T<f.length;T++){var C;-1!==(C=_.indexOf(f[T]))&&(-1===I||C<I)&&(I=C)}-1===I&&(I=_.length),this.host=_.slice(0,I),_=_.slice(I),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var N=this.hostname.split(/\./),M=(T=0,N.length);T<M;T++){var P=N[T];if(P&&!P.match(p)){for(var k="",x=0,U=P.length;x<U;x++)P.charCodeAt(x)>127?k+="x":k+=P[x];if(!k.match(p)){var L=N.slice(0,T),D=N.slice(T+1),q=P.match(d);q&&(L.push(q[1]),D.unshift(q[2])),D.length&&(_="/"+D.join(".")+_),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=r.toASCII(this.hostname));var B=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+B,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!y[E])for(T=0,M=h.length;T<M;T++){var V=h[T];if(-1!==_.indexOf(V)){var F=encodeURIComponent(V);F===V&&(F=escape(V)),_=_.split(V).join(F)}}var G=_.indexOf("#");-1!==G&&(this.hash=_.substr(G),_=_.slice(0,G));var Y=_.indexOf("?");if(-1!==Y?(this.search=_.substr(Y),this.query=_.substr(Y+1),t&&(this.query=b.parse(this.query)),_=_.slice(0,Y)):t&&(this.search="",this.query={}),_&&(this.pathname=_),g[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){B=this.pathname||"";var Q=this.search||"";this.path=B+Q}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||g[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(_(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0;u<c.length;u++){var h=c[u];"protocol"!==h&&(n[h]=e[h])}return g[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!g[e.protocol]){for(var f=Object.keys(e),l=0;l<f.length;l++){var p=f[l];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||v[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var y=n.pathname||"",b=n.search||"";n.path=y+b}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var _=n.pathname&&"/"===n.pathname.charAt(0),m=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=m||_||n.host&&e.pathname,E=w,S=n.pathname&&n.pathname.split("/")||[],A=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!g[n.protocol]);if(A&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),w=w&&(""===d[0]||""===S[0])),m)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search)){if(A)n.hostname=n.host=S.shift(),(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift());return n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var O=S.slice(-1)[0],I=(n.host||e.host||S.length>1)&&("."===O||".."===O)||""===O,T=0,C=S.length;C>=0;C--)"."===(O=S[C])?S.splice(C,1):".."===O?(S.splice(C,1),T++):T&&(S.splice(C,1),T--);if(!w&&!E)for(;T--;T)S.unshift("..");!w||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var R,N=""===S[0]||S[0]&&"/"===S[0].charAt(0);A&&(n.hostname=n.host=N?"":S.length?S.shift():"",(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift()));return(w=w||n.host&&S.length)&&!N&&S.unshift(""),S.length?n.pathname=S.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t){e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}Object.defineProperty(t,"__esModule",{value:!0}),t.Observable=void 0;var s=function(){return"function"==typeof Symbol},a=function(e){return s()&&Boolean(Symbol[e])},c=function(e){return a(e)?Symbol[e]:"@@"+e};s()&&!a("observable")&&(Symbol.observable=Symbol("observable"));var u=c("iterator"),h=c("observable"),f=c("species");function l(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function p(e){var t=e.constructor;return void 0!==t&&null===(t=t[f])&&(t=void 0),void 0!==t?t:S}function d(e){return e instanceof S}function y(e){y.log?y.log(e):setTimeout((function(){throw e}))}function v(e){Promise.resolve().then((function(){try{e()}catch(e){y(e)}}))}function g(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=l(t,"unsubscribe");n&&n.call(t)}}catch(e){y(e)}}function b(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function _(e,t,n){e._state="running";var r=e._observer;try{var o=l(r,t);switch(t){case"next":o&&o.call(r,n);break;case"error":if(b(e),!o)throw n;o.call(r,n);break;case"complete":b(e),o&&o.call(r)}}catch(e){y(e)}"closed"===e._state?g(e):"running"===e._state&&(e._state="ready")}function m(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void v((function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(_(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)}))):void _(e,t,n);e._queue.push({type:t,value:n})}}var w=function(){function e(t,n){r(this,e),this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var o=new E(this);try{this._cleanup=n.call(void 0,o)}catch(e){o.error(e)}"initializing"===this._state&&(this._state="ready")}return i(e,[{key:"unsubscribe",value:function(){"closed"!==this._state&&(b(this),g(this))}},{key:"closed",get:function(){return"closed"===this._state}}]),e}(),E=function(){function e(t){r(this,e),this._subscription=t}return i(e,[{key:"next",value:function(e){m(this._subscription,"next",e)}},{key:"error",value:function(e){m(this._subscription,"error",e)}},{key:"complete",value:function(){m(this._subscription,"complete")}},{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),S=function(){function e(t){if(r(this,e),!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}return i(e,[{key:"subscribe",value:function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new w(e,this._subscriber)}},{key:"forEach",value:function(e){var t=this;return new Promise((function(n,r){if("function"==typeof e)var o=t.subscribe({next:function(t){try{e(t,i)}catch(e){r(e),o.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function i(){o.unsubscribe(),n()}}))}},{key:"map",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(p(this))((function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}},{key:"filter",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(p(this))((function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}},{key:"reduce",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=p(this),r=arguments.length>1,o=!1,i=arguments[1],s=i;return new n((function(n){return t.subscribe({next:function(t){var i=!o;if(o=!0,!i||r)try{s=e(s,t)}catch(e){return n.error(e)}else s=t},error:function(e){n.error(e)},complete:function(){if(!o&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(s),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=p(this);return new o((function(t){var r,i=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){i===n.length?(r=void 0,t.complete()):e(o.from(n[i++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}}))}},{key:"flatMap",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=p(this);return new n((function(r){var o=[],i=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var i=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=o.indexOf(i);e>=0&&o.splice(e,1),s()}});o.push(i)},error:function(e){r.error(e)},complete:function(){s()}});function s(){i.closed&&0===o.length&&r.complete()}return function(){o.forEach((function(e){return e.unsubscribe()})),i.unsubscribe()}}))}},{key:h,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=l(t,h);if(r){var o=r.call(t);if(Object(o)!==o)throw new TypeError(o+" is not an object");return d(o)&&o.constructor===n?o:new n((function(e){return o.subscribe(e)}))}if(a("iterator")&&(r=l(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,o=!1,i=void 0;try{for(var s,a=r.call(t)[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var c=s.value;if(e.next(c),e.closed)return}}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")}},{key:"of",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o="function"==typeof this?this:e;return new o((function(e){v((function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}}))}))}},{key:f,get:function(){return this}}]),e}();t.Observable=S,s()&&Object.defineProperty(S,Symbol("extensions"),{value:{symbol:h,hostReportError:y},configurable:!0})},function(e,t,n){var r,o,i=n(6),s=n(7),a=0,c=0;e.exports=function(e,t,n){var u=t&&n||0,h=t||[],f=(e=e||{}).node||r,l=void 0!==e.clockseq?e.clockseq:o;if(null==f||null==l){var p=i();null==f&&(f=r=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==l&&(l=o=16383&(p[6]<<8|p[7]))}var d=void 0!==e.msecs?e.msecs:(new Date).getTime(),y=void 0!==e.nsecs?e.nsecs:c+1,v=d-a+(y-c)/1e4;if(v<0&&void 0===e.clockseq&&(l=l+1&16383),(v<0||d>a)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=d,c=y,o=l;var g=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;h[u++]=g>>>24&255,h[u++]=g>>>16&255,h[u++]=g>>>8&255,h[u++]=255&g;var b=d/4294967296*1e4&268435455;h[u++]=b>>>8&255,h[u++]=255&b,h[u++]=b>>>24&15|16,h[u++]=b>>>16&255,h[u++]=l>>>8|128,h[u++]=255&l;for(var _=0;_<6;++_)h[u+_]=f[_];return t||s(h)}},function(e,t,n){var r=n(6),o=n(7);e.exports=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[i+a]=s[a];return t||o(s)}},function(e,t,n){(function(e,r){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){t&&t.nodeType,e&&e.nodeType;var s="object"==typeof r&&r;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,u=/^xn--/,h=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,d=String.fromCharCode;function y(e){throw new RangeError(l[e])}function v(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+v((e=e.replace(f,".")).split("."),t).join(".")}function b(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function _(e){return v(e,(function(e){var t="";return e>65535&&(t+=d((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=d(e)})).join("")}function m(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function E(e){var t,n,r,o,i,s,a,u,h,f,l,d=[],v=e.length,g=0,b=128,m=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&y("not-basic"),d.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<v;){for(i=g,s=1,a=36;o>=v&&y("invalid-input"),((u=(l=e.charCodeAt(o++))-48<10?l-22:l-65<26?l-65:l-97<26?l-97:36)>=36||u>p((c-g)/s))&&y("overflow"),g+=u*s,!(u<(h=a<=m?1:a>=m+26?26:a-m));a+=36)s>p(c/(f=36-h))&&y("overflow"),s*=f;m=w(g-i,t=d.length+1,0==i),p(g/t)>c-b&&y("overflow"),b+=p(g/t),g%=t,d.splice(g++,0,b)}return _(d)}function S(e){var t,n,r,o,i,s,a,u,h,f,l,v,g,_,E,S=[];for(v=(e=b(e)).length,t=128,n=0,i=72,s=0;s<v;++s)(l=e[s])<128&&S.push(d(l));for(r=o=S.length,o&&S.push("-");r<v;){for(a=c,s=0;s<v;++s)(l=e[s])>=t&&l<a&&(a=l);for(a-t>p((c-n)/(g=r+1))&&y("overflow"),n+=(a-t)*g,t=a,s=0;s<v;++s)if((l=e[s])<t&&++n>c&&y("overflow"),l==t){for(u=n,h=36;!(u<(f=h<=i?1:h>=i+26?26:h-i));h+=36)E=u-f,_=36-f,S.push(d(m(f+E%_,0))),u=p(E/_);S.push(d(m(u,0))),i=w(n,g,r==o),n=0,++r}++n,++t}return S.join("")}a={version:"1.4.1",ucs2:{decode:b,encode:_},decode:E,encode:S,toASCII:function(e){return g(e,(function(e){return h.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return g(e,(function(e){return u.test(e)?E(e.slice(4).toLowerCase()):e}))}},void 0===(o=function(){return a}.call(t,n,t,e))||(e.exports=o)}()}).call(this,n(16)(e),n(3))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(19),t.encode=t.stringify=n(20)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var h=0;h<u;++h){var f,l,p,d,y=e[h].replace(a,"%20"),v=y.indexOf(n);v>=0?(f=y.substr(0,v),l=y.substr(v+1)):(f=y,l=""),p=decodeURIComponent(f),d=decodeURIComponent(l),r(s,p)?o(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],a=r[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),h=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[h++]=t>>16&255,c[h++]=t>>8&255,c[h++]=255&t;2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[h++]=255&t);1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[h++]=t>>8&255,c[h++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=0,a=n-o;s<a;s+=16383)i.push(h(e,s,s+16383>a?a:s+16383));1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function h(e,t,n){for(var o,i,s=[],a=t;a<n;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
9
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
10
- t.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,h=-7,f=n?o-1:0,l=n?-1:1,p=e[t+f];for(f+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;h>0;i=256*i+e[t+f],f+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=r;h>0;s=256*s+e[t+f],f+=l,h-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=u}return(p?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,h=(1<<u)-1,f=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(t*c-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[n+p]=255&s,p+=d,s/=256,u-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"AbstractPubSubProvider",(function(){return h})),n.d(t,"AWSAppSyncProvider",(function(){return k})),n.d(t,"AWSAppSyncRealTimeProvider",(function(){return $})),n.d(t,"AWSIoTProvider",(function(){return ae})),n.d(t,"mqttTopicMatch",(function(){return _})),n.d(t,"MqttOverWSProvider",(function(){return O})),n.d(t,"PubSub",(function(){return ne})),n.d(t,"CONTROL_MSG",(function(){return re}));var r=n(8),o=n.n(r).a,i=n(0),s=n(9),a=n(2),c=function(){return(c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},u=new i.ConsoleLogger("AbstractPubSubProvider"),h=function(){function e(e){void 0===e&&(e={}),this._config=e}return e.prototype.configure=function(e){return void 0===e&&(e={}),this._config=c(c({},e),this._config),u.debug("configure "+this.getProviderName(),this._config),this.options},e.prototype.getCategory=function(){return"PubSub"},Object.defineProperty(e.prototype,"options",{get:function(){return c({},this._config)},enumerable:!0,configurable:!0}),e}();function f(e){return(f="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)}var l,p=(l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),d=function(){return(d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},y=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},v=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},b=new i.ConsoleLogger("MqttOverWSProvider");function _(e,t){for(var n=e.split("/"),r=n.length,o=t.split("/"),i=0;i<r;++i){var s=n[i],a=o[i];if("#"===s)return o.length>=r;if("+"!==s&&s!==a)return!1}return r===o.length}var m,w,E,S=function(){function e(){this.promises=new Map}return e.prototype.get=function(e,t){return y(this,void 0,void 0,(function(){var n,r;return v(this,(function(o){return(n=this.promises.get(e))?[2,n]:t?(r=t(e),this.promises.set(e,r),[2,r]):[2,void 0]}))}))},Object.defineProperty(e.prototype,"allClients",{get:function(){return Array.from(this.promises.keys())},enumerable:!0,configurable:!0}),e.prototype.remove=function(e){this.promises.delete(e)},e}(),A="undefined"!=typeof Symbol?Symbol("topic"):"@@topic",O=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,d(d({},t),{clientId:t.clientId||Object(a.v4)()}))||this;return n._clientsQueue=new S,n._topicObservers=new Map,n._clientIdObservers=new Map,n}return p(t,e),Object.defineProperty(t.prototype,"clientId",{get:function(){return this.options.clientId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"endpoint",{get:function(){return this.options.aws_pubsub_endpoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clientsQueue",{get:function(){return this._clientsQueue},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),t.prototype.getTopicForValue=function(e){return"object"===f(e)&&e[A]},t.prototype.getProviderName=function(){return"MqttOverWSProvider"},t.prototype.onDisconnect=function(e){var t=this,n=e.clientId,r=e.errorCode,o=g(e,["clientId","errorCode"]);if(0!==r){b.warn(n,JSON.stringify(d({errorCode:r},o),null,2));var i=[];if(!n)return;var s=this._clientIdObservers.get(n);if(!s)return;s.forEach((function(e){e.error("Disconnected, error code: "+r),t._topicObservers.forEach((function(t,n){t.delete(e),0===t.size&&i.push(n)}))})),this._clientIdObservers.delete(n),i.forEach((function(e){t._topicObservers.delete(e)}))}},t.prototype.newClient=function(e){var t=e.url,n=e.clientId;return y(this,void 0,void 0,(function(){var e,r=this;return v(this,(function(o){switch(o.label){case 0:return b.debug("Creating new MQTT client",n),(e=new s.Client(t,n)).onMessageArrived=function(e){var t=e.destinationName,n=e.payloadString;r._onMessage(t,n)},e.onConnectionLost=function(e){var t=e.errorCode,o=g(e,["errorCode"]);r.onDisconnect(d({clientId:n,errorCode:t},o))},[4,new Promise((function(t,n){e.connect({useSSL:r.isSSLEnabled,mqttVersion:3,onSuccess:function(){return t(e)},onFailure:n})}))];case 1:return o.sent(),[2,e]}}))}))},t.prototype.connect=function(e,t){return void 0===t&&(t={}),y(this,void 0,void 0,(function(){var n=this;return v(this,(function(r){switch(r.label){case 0:return[4,this.clientsQueue.get(e,(function(e){return n.newClient(d(d({},t),{clientId:e}))}))];case 1:return[2,r.sent()]}}))}))},t.prototype.disconnect=function(e){return y(this,void 0,void 0,(function(){var t;return v(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(e)];case 1:return(t=n.sent())&&t.isConnected()&&t.disconnect(),this.clientsQueue.remove(e),[2]}}))}))},t.prototype.publish=function(e,t){return y(this,void 0,void 0,(function(){var n,r,o,i;return v(this,(function(s){switch(s.label){case 0:return n=[].concat(e),r=JSON.stringify(t),[4,this.endpoint];case 1:return o=s.sent(),[4,this.connect(this.clientId,{url:o})];case 2:return i=s.sent(),b.debug("Publishing to topic(s)",n.join(","),r),n.forEach((function(e){return i.send(e,r)})),[2]}}))}))},t.prototype._onMessage=function(e,t){try{var n=[];this._topicObservers.forEach((function(t,r){_(r,e)&&n.push(t)}));var r=JSON.parse(t);"object"===f(r)&&(r[A]=e),n.forEach((function(e){e.forEach((function(e){return e.next(r)}))}))}catch(e){b.warn("Error handling message",e,t)}},t.prototype.subscribe=function(e,t){var n=this;void 0===t&&(t={});var r=[].concat(e);return b.debug("Subscribing to topic(s)",r.join(",")),new o((function(e){var o;r.forEach((function(t){var r=n._topicObservers.get(t);r||(r=new Set,n._topicObservers.set(t,r)),r.add(e)}));var i=t.clientId,s=void 0===i?n.clientId:i,a=n._clientIdObservers.get(s);return a||(a=new Set),a.add(e),n._clientIdObservers.set(s,a),y(n,void 0,void 0,(function(){var n,i,a,c;return v(this,(function(u){switch(u.label){case 0:return void 0!==(n=t.url)?[3,2]:[4,this.endpoint];case 1:return a=u.sent(),[3,3];case 2:a=n,u.label=3;case 3:i=a,u.label=4;case 4:return u.trys.push([4,6,,7]),[4,this.connect(s,{url:i})];case 5:return o=u.sent(),r.forEach((function(e){o.subscribe(e)})),[3,7];case 6:return c=u.sent(),e.error(c),[3,7];case 7:return[2]}}))})),function(){var t,i;return b.debug("Unsubscribing from topic(s)",r.join(",")),o&&(null===(t=n._clientIdObservers.get(s))||void 0===t||t.delete(e),0===(null===(i=n._clientIdObservers.get(s))||void 0===i?void 0:i.size)&&(n.disconnect(s),n._clientIdObservers.delete(s)),r.forEach((function(t){var r=n._topicObservers.get(t)||new Set;r.delete(e),0===r.size&&(n._topicObservers.delete(t),o.isConnected()&&o.unsubscribe(t))}))),null}}))},t}(h),I=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},C=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},R=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},N=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},M=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(N(arguments[t]));return e},P=new i.ConsoleLogger("AWSAppSyncProvider"),k=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._topicClient=new Map,t._topicAlias=new Map,t}return I(t,e),Object.defineProperty(t.prototype,"endpoint",{get:function(){throw new Error("Not supported")},enumerable:!0,configurable:!0}),t.prototype.getProviderName=function(){return"AWSAppSyncProvider"},t.prototype.publish=function(e,t,n){return T(this,void 0,void 0,(function(){return C(this,(function(e){throw new Error("Operation not supported")}))}))},t.prototype._cleanUp=function(e){var t=this;Array.from(this._topicClient.entries()).filter((function(t){return N(t,2)[1].clientId===e})).map((function(e){return N(e,1)[0]})).forEach((function(e){return t._cleanUpForTopic(e)}))},t.prototype._cleanUpForTopic=function(e){this._topicClient.delete(e),this._topicAlias.delete(e)},t.prototype.onDisconnect=function(e){var t=this,n=e.clientId,r=e.errorCode,o=R(e,["clientId","errorCode"]);0!==r&&(Array.from(this._topicClient.entries()).filter((function(e){return N(e,2)[1].clientId===n})).map((function(e){return N(e,1)[0]})).forEach((function(e){t._topicObservers.has(e)&&(t._topicObservers.get(e).forEach((function(e){e.closed||e.error(o)})),t._topicObservers.delete(e))})),this._cleanUp(n))},t.prototype.disconnect=function(t){return T(this,void 0,void 0,(function(){return C(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(t,(function(){return null}))];case 1:return n.sent(),[4,e.prototype.disconnect.call(this,t)];case 2:return n.sent(),this._cleanUp(t),[2]}}))}))},t.prototype.subscribe=function(e,t){var n=this;void 0===t&&(t={});var r=new o((function(r){var o=[].concat(e);return P.debug("Subscribing to topic(s)",o.join(",")),T(n,void 0,void 0,(function(){var e,n,i,s,a,c=this;return C(this,(function(u){switch(u.label){case 0:return o.forEach((function(e){c._topicObservers.has(e)||c._topicObservers.set(e,new Set),c._topicObservers.get(e).add(r)})),e=t.mqttConnections,n=void 0===e?[]:e,i=t.newSubscriptions,s=Object.entries(i).map((function(e){var t=N(e,2),n=t[0];return[t[1].topic,n]})),this._topicAlias=new Map(M(Array.from(this._topicAlias.entries()),s)),a=Object.entries(o.reduce((function(e,t){var r=n.find((function(e){return e.topics.indexOf(t)>-1}));if(r){var o=r.client,i=r.url;e[o]||(e[o]={url:i,topics:new Set}),e[o].topics.add(t)}return e}),{})),[4,Promise.all(a.map((function(e){var t=N(e,2),n=t[0],o=t[1],i=o.url,s=o.topics;return T(c,void 0,void 0,(function(){var e,t,o=this;return C(this,(function(a){switch(a.label){case 0:e=null,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.connect(n,{clientId:n,url:i})];case 2:return e=a.sent(),[3,4];case 3:return t=a.sent(),r.error({message:"Failed to connect",error:t}),r.complete(),[2,void 0];case 4:return s.forEach((function(t){e.isConnected()&&(e.subscribe(t),o._topicClient.set(t,e))})),[2,e]}}))}))})))];case 1:return u.sent(),[2]}}))})),function(){P.debug("Unsubscribing from topic(s)",o.join(",")),o.forEach((function(e){var t=n._topicClient.get(e);t&&t.isConnected()&&(t.unsubscribe(e),n._topicClient.delete(e),Array.from(n._topicClient.values()).some((function(e){return e===t}))||n.disconnect(t.clientId)),n._topicObservers.delete(e)}))}}));return o.from(r).map((function(e){var t=n.getTopicForValue(e),r=n._topicAlias.get(t);return e.data=Object.entries(e.data).reduce((function(e,t){var n=N(t,2),o=n[0],i=n[1];return e[r||o]=i,e}),{}),e}))},t}(O),x=n(1),U=n(10),L=n(4),D=n(11),q=n.n(D),B=n(5),j=n.n(B),V=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),F=function(){return(F=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},G=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Y=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Q=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},K=new i.Logger("AWSAppSyncRealTimeProvider"),z="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",J=[400,401,403];!function(e){e.GQL_CONNECTION_INIT="connection_init",e.GQL_CONNECTION_ERROR="connection_error",e.GQL_CONNECTION_ACK="connection_ack",e.GQL_START="start",e.GQL_START_ACK="start_ack",e.GQL_DATA="data",e.GQL_CONNECTION_KEEP_ALIVE="ka",e.GQL_STOP="stop",e.GQL_COMPLETE="complete",e.GQL_ERROR="error"}(m||(m={})),function(e){e[e.PENDING=0]="PENDING",e[e.CONNECTED=1]="CONNECTED",e[e.FAILED=2]="FAILED"}(w||(w={})),function(e){e[e.CLOSED=0]="CLOSED",e[e.READY=1]="READY",e[e.CONNECTING=2]="CONNECTING"}(E||(E={}));var W={accept:"application/json, text/javascript","content-encoding":"amz-1.0","content-type":"application/json; charset=UTF-8"},H=/^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i,$=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.socketStatus=E.CLOSED,t.keepAliveTimeout=3e5,t.subscriptionObserverMap=new Map,t.promiseArray=[],t}return V(t,e),t.prototype.getProviderName=function(){return"AWSAppSyncRealTimeProvider"},t.prototype.newClient=function(){throw new Error("Not used here")},t.prototype.publish=function(e,t,n){return G(this,void 0,void 0,(function(){return Y(this,(function(e){throw new Error("Operation not supported")}))}))},t.prototype.isCustomDomain=function(e){return null===e.match(H)},t.prototype.subscribe=function(e,t){var n=this,r=null==t?void 0:t.appSyncGraphqlEndpoint;return new o((function(e){if(t&&r){var o=Object(a.v4)();return n._startSubscriptionWithAWSAppSyncRealTime({options:t,observer:e,subscriptionId:o}).catch((function(t){e.error({errors:[F({},new x.GraphQLError(re.REALTIME_SUBSCRIPTION_INIT_ERROR+": "+t))]}),e.complete()})),function(){return G(n,void 0,void 0,(function(){var e,t;return Y(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),[4,this._waitForSubscriptionToBeConnected(o)];case 1:if(n.sent(),!(e=(this.subscriptionObserverMap.get(o)||{}).subscriptionState))return[2];if(e!==w.CONNECTED)throw new Error("Subscription never connected");return this._sendUnsubscriptionMessage(o),[3,4];case 2:return t=n.sent(),K.debug("Error while unsubscribing "+t),[3,4];case 3:return this._removeSubscriptionObserver(o),[7];case 4:return[2]}}))}))}}e.error({errors:[F({},new x.GraphQLError("Subscribe only available for AWS AppSync endpoint"))]}),e.complete()}))},Object.defineProperty(t.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),t.prototype._startSubscriptionWithAWSAppSyncRealTime=function(e){var t,n,r=e.options,o=e.observer,s=e.subscriptionId;return G(this,void 0,void 0,(function(){var e,a,c,u,h,f,l,p,d,y,v,g,b,_,E,S,A,O,I,T,C,R,N,M,P,k=this;return Y(this,(function(U){switch(U.label){case 0:return e=r.appSyncGraphqlEndpoint,a=r.authenticationType,c=r.query,u=r.variables,h=r.apiKey,f=r.region,l=r.graphql_headers,p=void 0===l?function(){return{}}:l,d=r.additionalHeaders,y=void 0===d?{}:d,v=w.PENDING,g={query:c,variables:u},this.subscriptionObserverMap.set(s,{observer:o,query:null!=c?c:"",variables:null!=u?u:{},subscriptionState:v,startAckTimeoutId:void 0}),b=JSON.stringify(g),E=[{}],[4,this._awsRealTimeHeaderBasedAuth({apiKey:h,appSyncGraphqlEndpoint:e,authenticationType:a,payload:b,canonicalUri:"",region:f,additionalHeaders:y})];case 1:return S=[F.apply(void 0,E.concat([U.sent()]))],[4,p()];case 2:_=F.apply(void 0,[F.apply(void 0,[F.apply(void 0,S.concat([U.sent()])),y]),(P={},P[i.USER_AGENT_HEADER]=i.Constants.userAgent,P)]),A={id:s,payload:{data:b,extensions:{authorization:F({},_)}},type:m.GQL_START},O=JSON.stringify(A),U.label=3;case 3:return U.trys.push([3,5,,6]),[4,this._initializeWebSocketConnection({apiKey:h,appSyncGraphqlEndpoint:e,authenticationType:a,region:f,additionalHeaders:y})];case 4:return U.sent(),[3,6];case 5:return I=U.sent(),K.debug({err:I}),T=null!==(t=I.message)&&void 0!==t?t:"",o.error({errors:[F({},new x.GraphQLError(re.CONNECTION_FAILED+": "+T))]}),o.complete(),"function"==typeof(C=(this.subscriptionObserverMap.get(s)||{}).subscriptionFailedCallback)&&C(),[2];case 6:return R=null!==(n=this.subscriptionObserverMap.get(s))&&void 0!==n?n:{},N=R.subscriptionFailedCallback,M=R.subscriptionReadyCallback,this.subscriptionObserverMap.set(s,{observer:o,subscriptionState:v,query:null!=c?c:"",variables:null!=u?u:{},subscriptionReadyCallback:M,subscriptionFailedCallback:N,startAckTimeoutId:setTimeout((function(){k._timeoutStartSubscriptionAck.call(k,s)}),15e3)}),this.awsRealTimeSocket&&this.awsRealTimeSocket.send(O),[2]}}))}))},t.prototype._waitForSubscriptionToBeConnected=function(e){return G(this,void 0,void 0,(function(){var t,n=this;return Y(this,(function(r){return(t=this.subscriptionObserverMap.get(e))&&t.subscriptionState===w.PENDING?[2,new Promise((function(r,o){var i=t.observer,s=t.subscriptionState,a=t.variables,c=t.query;n.subscriptionObserverMap.set(e,{observer:i,subscriptionState:s,variables:a,query:c,subscriptionReadyCallback:r,subscriptionFailedCallback:o})}))]:[2]}))}))},t.prototype._sendUnsubscriptionMessage=function(e){try{if(this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.socketStatus===E.READY){var t={id:e,type:m.GQL_STOP},n=JSON.stringify(t);this.awsRealTimeSocket.send(n)}}catch(e){K.debug({err:e})}},t.prototype._removeSubscriptionObserver=function(e){this.subscriptionObserverMap.delete(e),setTimeout(this._closeSocketIfRequired.bind(this),1e3)},t.prototype._closeSocketIfRequired=function(){if(!(this.subscriptionObserverMap.size>0))if(this.awsRealTimeSocket)if(this.awsRealTimeSocket.bufferedAmount>0)setTimeout(this._closeSocketIfRequired.bind(this),1e3);else{K.debug("closing WebSocket..."),this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId);var e=this.awsRealTimeSocket;e.onclose=null,e.onerror=null,e.close(1e3),this.awsRealTimeSocket=void 0,this.socketStatus=E.CLOSED}else this.socketStatus=E.CLOSED},t.prototype._handleIncomingSubscriptionMessage=function(e){K.debug("subscription message from AWS AppSync RealTime: "+e.data);var t=JSON.parse(e.data),n=t.id,r=void 0===n?"":n,o=t.payload,s=t.type,a=this.subscriptionObserverMap.get(r)||{},c=a.observer,u=void 0===c?null:c,h=a.query,f=void 0===h?"":h,l=a.variables,p=void 0===l?{}:l,d=a.startAckTimeoutId,y=a.subscriptionReadyCallback,v=a.subscriptionFailedCallback;if(K.debug({id:r,observer:u,query:f,variables:p}),s===m.GQL_DATA&&o&&o.data)u?u.next(o):K.debug("observer not found for id: "+r);else if(s!==m.GQL_START_ACK){if(s===m.GQL_CONNECTION_KEEP_ALIVE)return this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId),void(this.keepAliveTimeoutId=setTimeout(this._errorDisconnect.bind(this,re.TIMEOUT_DISCONNECT),this.keepAliveTimeout));if(s===m.GQL_ERROR){g=w.FAILED;u&&(this.subscriptionObserverMap.set(r,{observer:u,query:f,variables:p,startAckTimeoutId:d,subscriptionReadyCallback:y,subscriptionFailedCallback:v,subscriptionState:g}),u.error({errors:[F({},new x.GraphQLError(re.CONNECTION_FAILED+": "+JSON.stringify(o)))]}),d&&clearTimeout(d),u.complete(),"function"==typeof v&&v())}}else{K.debug("subscription ready for "+JSON.stringify({query:f,variables:p})),"function"==typeof y&&y(),d&&clearTimeout(d),function(e,t,n){i.Hub.dispatch("api",{event:e,data:t,message:n},"PubSub",z)}(re.SUBSCRIPTION_ACK,{query:f,variables:p},"Connection established for subscription");var g=w.CONNECTED;u&&this.subscriptionObserverMap.set(r,{observer:u,query:f,variables:p,startAckTimeoutId:void 0,subscriptionState:g,subscriptionReadyCallback:y,subscriptionFailedCallback:v})}},t.prototype._errorDisconnect=function(e){K.debug("Disconnect error: "+e),this.subscriptionObserverMap.forEach((function(t){var n=t.observer;n&&!n.closed&&n.error({errors:[F({},new x.GraphQLError(e))]})})),this.subscriptionObserverMap.clear(),this.awsRealTimeSocket&&this.awsRealTimeSocket.close(),this.socketStatus=E.CLOSED},t.prototype._timeoutStartSubscriptionAck=function(e){var t=this.subscriptionObserverMap.get(e);if(t){var n=t.observer,r=t.query,o=t.variables;if(!n)return;this.subscriptionObserverMap.set(e,{observer:n,query:r,variables:o,subscriptionState:w.FAILED}),n&&!n.closed&&(n.error({errors:[F({},new x.GraphQLError("Subscription timeout "+JSON.stringify({query:r,variables:o})))]}),n.complete()),K.debug("timeoutStartSubscription",JSON.stringify({query:r,variables:o}))}},t.prototype._initializeWebSocketConnection=function(e){var t=this,n=e.appSyncGraphqlEndpoint,r=e.authenticationType,o=e.apiKey,i=e.region,s=e.additionalHeaders;if(this.socketStatus!==E.READY)return new Promise((function(e,a){return G(t,void 0,void 0,(function(){var t,c,u,h,f,l,p,d,y,v;return Y(this,(function(g){switch(g.label){case 0:if(this.promiseArray.push({res:e,rej:a}),this.socketStatus!==E.CLOSED)return[3,5];g.label=1;case 1:return g.trys.push([1,4,,5]),this.socketStatus=E.CONNECTING,t="{}",h=(u=JSON).stringify,[4,this._awsRealTimeHeaderBasedAuth({authenticationType:r,payload:t,canonicalUri:"/connect",apiKey:o,appSyncGraphqlEndpoint:n,region:i,additionalHeaders:s})];case 2:return c=h.apply(u,[g.sent()]),f=L.Buffer.from(c).toString("base64"),l=L.Buffer.from(t).toString("base64"),p=null!=n?n:"",p=this.isCustomDomain(p)?p.concat("/realtime"):p.replace("appsync-api","appsync-realtime-api").replace("gogi-beta","grt-beta"),d=this.isSSLEnabled?"wss://":"ws://",p=p.replace("https://",d).replace("http://",d),y=p+"?header="+f+"&payload="+l,[4,this._initializeRetryableHandshake(y)];case 3:return g.sent(),this.promiseArray.forEach((function(e){var t=e.res;K.debug("Notifying connection successful"),t()})),this.socketStatus=E.READY,this.promiseArray=[],[3,5];case 4:return v=g.sent(),this.promiseArray.forEach((function(e){return(0,e.rej)(v)})),this.promiseArray=[],this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.awsRealTimeSocket.close(3001),this.awsRealTimeSocket=void 0,this.socketStatus=E.CLOSED,[3,5];case 5:return[2]}}))}))}))},t.prototype._initializeRetryableHandshake=function(e){return G(this,void 0,void 0,(function(){return Y(this,(function(t){switch(t.label){case 0:return K.debug("Initializaling retryable Handshake"),[4,Object(i.jitteredExponentialRetry)(this._initializeHandshake.bind(this),[e],5e3)];case 1:return t.sent(),[2]}}))}))},t.prototype._initializeHandshake=function(e){return G(this,void 0,void 0,(function(){var t,n,r,o,s=this;return Y(this,(function(a){switch(a.label){case 0:K.debug("Initializing handshake "+e),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,new Promise((function(t,n){var r=new WebSocket(e,"graphql-ws");r.onerror=function(){K.debug("WebSocket connection error")},r.onclose=function(){n(new Error("Connection handshake error"))},r.onopen=function(){return s.awsRealTimeSocket=r,t()}}))];case 2:return a.sent(),[4,new Promise((function(e,t){if(s.awsRealTimeSocket){var n=!1;s.awsRealTimeSocket.onerror=function(e){K.debug("WebSocket error "+JSON.stringify(e))},s.awsRealTimeSocket.onclose=function(e){K.debug("WebSocket closed "+e.reason),t(new Error(JSON.stringify(e)))},s.awsRealTimeSocket.onmessage=function(r){K.debug("subscription message from AWS AppSyncRealTime: "+r.data+" ");var o=JSON.parse(r.data),i=o.type,a=o.payload,c=(void 0===a?{}:a).connectionTimeoutMs,u=void 0===c?3e5:c;if(i===m.GQL_CONNECTION_ACK)return n=!0,s.awsRealTimeSocket&&(s.keepAliveTimeout=u,s.awsRealTimeSocket.onmessage=s._handleIncomingSubscriptionMessage.bind(s),s.awsRealTimeSocket.onerror=function(e){K.debug(e),s._errorDisconnect(re.CONNECTION_CLOSED)},s.awsRealTimeSocket.onclose=function(e){K.debug("WebSocket closed "+e.reason),s._errorDisconnect(re.CONNECTION_CLOSED)}),void e("Cool, connected to AWS AppSyncRealTime");if(i===m.GQL_CONNECTION_ERROR){var h=o.payload,f=(void 0===h?{}:h).errors,l=Q(void 0===f?[]:f,1)[0],p=void 0===l?{}:l,d=p.errorType,y=void 0===d?"":d,v=p.errorCode;t({errorType:y,errorCode:void 0===v?0:v})}};var r={type:m.GQL_CONNECTION_INIT};s.awsRealTimeSocket.send(JSON.stringify(r)),setTimeout(function(e){e||t(new Error("Connection timeout: ack from AWSRealTime was not received on 15000 ms"))}.bind(s,n),15e3)}}))];case 3:return a.sent(),[3,5];case 4:throw t=a.sent(),r=(n=t).errorType,o=n.errorCode,J.includes(o)?new i.NonRetryableError(r):r?new Error(r):t;case 5:return[2]}}))}))},t.prototype._awsRealTimeHeaderBasedAuth=function(e){var t=e.authenticationType,n=e.payload,r=e.canonicalUri,o=e.appSyncGraphqlEndpoint,i=e.apiKey,s=e.region,a=e.additionalHeaders;return G(this,void 0,void 0,(function(){var e,c,u;return Y(this,(function(h){switch(h.label){case 0:return e={API_KEY:this._awsRealTimeApiKeyHeader.bind(this),AWS_IAM:this._awsRealTimeIAMHeader.bind(this),OPENID_CONNECT:this._awsRealTimeOPENIDHeader.bind(this),AMAZON_COGNITO_USER_POOLS:this._awsRealTimeCUPHeader.bind(this),AWS_LAMBDA:this._customAuthHeader},t&&e[t]?[3,1]:(K.debug("Authentication type "+t+" not supported"),[2,""]);case 1:return c=e[t],u=U.parse(null!=o?o:"").host,[4,c({payload:n,canonicalUri:r,appSyncGraphqlEndpoint:o,apiKey:i,region:s,host:u,additionalHeaders:a})];case 2:return[2,h.sent()]}}))}))},t.prototype._awsRealTimeCUPHeader=function(e){var t=e.host;return G(this,void 0,void 0,(function(){return Y(this,(function(e){switch(e.label){case 0:return[4,j.a.currentSession()];case 1:return[2,{Authorization:e.sent().getAccessToken().getJwtToken(),host:t}]}}))}))},t.prototype._awsRealTimeOPENIDHeader=function(e){var t=e.host;return G(this,void 0,void 0,(function(){var e,n,r;return Y(this,(function(o){switch(o.label){case 0:return[4,q.a.getItem("federatedInfo")];case 1:return(n=o.sent())?(e=n.token,[3,4]):[3,2];case 2:return[4,j.a.currentAuthenticatedUser()];case 3:(r=o.sent())&&(e=r.token),o.label=4;case 4:if(!e)throw new Error("No federated jwt");return[2,{Authorization:e,host:t}]}}))}))},t.prototype._awsRealTimeApiKeyHeader=function(e){var t=e.apiKey,n=e.host;return G(this,void 0,void 0,(function(){var e,r;return Y(this,(function(o){return e=new Date,r=e.toISOString().replace(/[:\-]|\.\d{3}/g,""),[2,{host:n,"x-amz-date":r,"x-api-key":t}]}))}))},t.prototype._awsRealTimeIAMHeader=function(e){var t=e.payload,n=e.canonicalUri,r=e.appSyncGraphqlEndpoint,o=e.region;return G(this,void 0,void 0,(function(){var e,s,a;return Y(this,(function(c){switch(c.label){case 0:return e={region:o,service:"appsync"},[4,this._ensureCredentials()];case 1:if(!c.sent())throw new Error("No credentials");return[4,i.Credentials.get().then((function(e){var t=e;return{secret_key:t.secretAccessKey,access_key:t.accessKeyId,session_token:t.sessionToken}}))];case 2:return s=c.sent(),a={url:""+r+n,data:t,method:"POST",headers:F({},W)},[2,i.Signer.sign(a,s,e).headers]}}))}))},t.prototype._customAuthHeader=function(e){var t=e.host,n=e.additionalHeaders;if(!n||!n.Authorization)throw new Error("No auth token specified");return{Authorization:n.Authorization,host:t}},t.prototype._ensureCredentials=function(){return i.Credentials.get().then((function(e){if(!e)return!1;var t=i.Credentials.shear(e);return K.debug("set credentials for AWSAppSyncRealTimeProvider",t),!0})).catch((function(e){return K.warn("ensure credentials error",e),!1}))},t}(h),X=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Z=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ee=Object(i.browserOrNode)().isNode,te=new i.ConsoleLogger("PubSub"),ne=new(function(){function e(e){this._options=null!=e?e:{},te.debug("PubSub Options",this._options),this._pluggables=[],this.subscribe=this.subscribe.bind(this)}return Object.defineProperty(e.prototype,"awsAppSyncProvider",{get:function(){return this._awsAppSyncProvider||(this._awsAppSyncProvider=new k(this._options)),this._awsAppSyncProvider},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"awsAppSyncRealTimeProvider",{get:function(){return this._awsAppSyncRealTimeProvider||(this._awsAppSyncRealTimeProvider=new $(this._options)),this._awsAppSyncRealTimeProvider},enumerable:!0,configurable:!0}),e.prototype.getModuleName=function(){return"PubSub"},e.prototype.configure=function(e){var t=this,n=e?e.PubSub||e:{};return te.debug("configure PubSub",{opt:n}),this._options=Object.assign({},this._options,n),this._pluggables.map((function(e){return e.configure(t._options)})),this._options},e.prototype.addPluggable=function(e){return X(this,void 0,void 0,(function(){return Z(this,(function(t){return e&&"PubSub"===e.getCategory()?(this._pluggables.push(e),[2,e.configure(this._options)]):[2]}))}))},e.prototype.removePluggable=function(e){this._pluggables=this._pluggables.filter((function(t){return t.getProviderName()!==e}))},e.prototype.getProviderByName=function(e){return e===i.INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER?this.awsAppSyncProvider:e===i.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER?this.awsAppSyncRealTimeProvider:this._pluggables.find((function(t){return t.getProviderName()===e}))},e.prototype.getProviders=function(e){void 0===e&&(e={});var t=e.provider;if(!t)return this._pluggables;var n=this.getProviderByName(t);if(!n)throw new Error("Could not find provider named "+t);return[n]},e.prototype.publish=function(e,t,n){return X(this,void 0,void 0,(function(){return Z(this,(function(r){return[2,Promise.all(this.getProviders(n).map((function(r){return r.publish(e,t,n)})))]}))}))},e.prototype.subscribe=function(e,t){if(ee&&this._options&&this._options.ssr)throw new Error("Subscriptions are not supported for Server-Side Rendering (SSR)");te.debug("subscribe options",t);var n=this.getProviders(t);return new o((function(r){var o=n.map((function(n){return{provider:n,observable:n.subscribe(e,t)}})).map((function(e){var t=e.provider;return e.observable.subscribe({start:console.error,next:function(e){return r.next({provider:t,value:e})},error:function(e){return r.error({provider:t,error:e})}})}));return function(){return o.forEach((function(e){return e.unsubscribe()}))}}))},e}());i.Amplify.register(ne);var re,oe=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ie=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},se=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},ae=function(e){function t(t){return void 0===t&&(t={}),e.call(this,t)||this}return oe(t,e),Object.defineProperty(t.prototype,"region",{get:function(){return this.options.aws_pubsub_region},enumerable:!0,configurable:!0}),t.prototype.getProviderName=function(){return"AWSIoTProvider"},Object.defineProperty(t.prototype,"endpoint",{get:function(){return ie(this,void 0,void 0,(function(){var e,t,n,r,o,s;return se(this,(function(a){switch(a.label){case 0:return e=this.options.aws_pubsub_endpoint,t={service:"iotdevicegateway",region:this.region},[4,i.Credentials.get()];case 1:return n=a.sent(),r=n.accessKeyId,o=n.secretAccessKey,s=n.sessionToken,[2,i.Signer.signUrl(e,{access_key:r,secret_key:o,session_token:s},t)]}}))}))},enumerable:!0,configurable:!0}),t}(O);!function(e){e.CONNECTION_CLOSED="Connection closed",e.CONNECTION_FAILED="Connection failed",e.REALTIME_SUBSCRIPTION_INIT_ERROR="AppSync Realtime subscription init error",e.SUBSCRIPTION_ACK="Subscription ack",e.TIMEOUT_DISCONNECT="Timeout disconnect"}(re||(re={}));t.default=ne}])}));
1
+ /*! For license information please see aws-amplify-pubsub.min.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("aws_amplify_core"),require("graphql"),require("aws_amplify_cache"),require("aws_amplify_auth")):"function"==typeof define&&define.amd?define("aws_amplify_pubsub",["aws_amplify_core","graphql","aws_amplify_cache","aws_amplify_auth"],t):"object"==typeof exports?exports.aws_amplify_pubsub=t(require("aws_amplify_core"),require("graphql"),require("aws_amplify_cache"),require("aws_amplify_auth")):e.aws_amplify_pubsub=t(e.aws_amplify_core,e.graphql,e.aws_amplify_cache,e.aws_amplify_auth)}(this,(e,t,n,r)=>(()=>{var o={766:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,i=c(e),s=i[0],a=i[1],u=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),h=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[h++]=255&t),1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(u(e,s,s+16383>a?a:s+16383));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=i.length;s<a;++s)n[s]=i[s],r[i.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},834:(e,t,n)=>{"use strict";var r=n(766),o=n(333),i=n(906);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=l(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),o=(e=a(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):l(e,t);if("Buffer"===t.type&&i(t.data))return l(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(h(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function l(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,n);case"utf8":case"utf-8":return I(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,o);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var h=-1;for(i=n;i<a;i++)if(u(e,i)===u(t,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===c)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var f=!0,l=0;l<c;l++)if(u(e,i+l)!==u(t,l)){f=!1;break}if(f)return i}return-1}function _(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function m(e,t,n,r){return V(B(t,e.length-n),e,n,r)}function w(e,t,n,r){return V(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return w(e,t,n,r)}function S(e,t,n,r){return V(j(t),e,n,r)}function A(e,t,n,r){return V(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function O(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function I(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,u=e[o],h=null,f=u>239?4:u>223?3:u>191?2:1;if(o+f<=n)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(h=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),o+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function C(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function R(e,t,n){var r,o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var i="",s=t;s<n;++s)i+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return i}function N(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function k(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function U(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,i){return i||U(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,i){return i||U(e,0,n,8),o.write(e,t,n,r,52,8),n+8}t.lW=c,t.h2=50,c.TYPED_ARRAY_SUPPORT=void 0!==n.g.TYPED_ARRAY_SUPPORT?n.g.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return h(t),t<=0?a(null,t):void 0!==n?"string"==typeof r?a(null,t).fill(n,r):a(null,t).fill(n):a(null,t)}(0,e,t,n)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},c.byteLength=d,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?I(this,0,e):y.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",n=t.h2;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,o){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),h=e.slice(t,n),f=0;f<a;++f)if(u[f]!==h[f]){i=u[f],s=h[f];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return v(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return v(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return m(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var o=t-e;n=new c(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},c.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):k(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):k(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:B(new c(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function j(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}},333:(e,t)=>{t.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,h=-7,f=n?o-1:0,l=n?-1:1,p=e[t+f];for(f+=l,i=p&(1<<-h)-1,p>>=-h,h+=a;h>0;i=256*i+e[t+f],f+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=r;h>0;s=256*s+e[t+f],f+=l,h-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=u}return(p?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,h=(1<<u)-1,f=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(t*c-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[n+p]=255&s,p+=d,s/=256,u-=8);e[n+p-d]|=128*y}},906:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},118:function(e,t,n){var r;r=function(){return function(e){var t,n=e.localStorage||(t={},{setItem:function(e,n){t[e]=n},getItem:function(e){return t[e]},removeItem:function(e){delete t[e]}}),r=function(e,t){for(var n in e)if(e.hasOwnProperty(n)){if(!t.hasOwnProperty(n)){var r="Unknown property, "+n+". Valid properties are:";for(var o in t)t.hasOwnProperty(o)&&(r=r+" "+o);throw new Error(r)}if(typeof e[n]!==t[n])throw new Error(a(i.INVALID_TYPE,[typeof e[n],n]))}},o=function(e,t){return function(){return e.apply(t,arguments)}},i={OK:{code:0,text:"AMQJSC0000I OK."},CONNECT_TIMEOUT:{code:1,text:"AMQJSC0001E Connect timed out."},SUBSCRIBE_TIMEOUT:{code:2,text:"AMQJS0002E Subscribe timed out."},UNSUBSCRIBE_TIMEOUT:{code:3,text:"AMQJS0003E Unsubscribe timed out."},PING_TIMEOUT:{code:4,text:"AMQJS0004E Ping timed out."},INTERNAL_ERROR:{code:5,text:"AMQJS0005E Internal error. Error Message: {0}, Stack trace: {1}"},CONNACK_RETURNCODE:{code:6,text:"AMQJS0006E Bad Connack return code:{0} {1}."},SOCKET_ERROR:{code:7,text:"AMQJS0007E Socket error:{0}."},SOCKET_CLOSE:{code:8,text:"AMQJS0008I Socket closed."},MALFORMED_UTF:{code:9,text:"AMQJS0009E Malformed UTF data:{0} {1} {2}."},UNSUPPORTED:{code:10,text:"AMQJS0010E {0} is not supported by this browser."},INVALID_STATE:{code:11,text:"AMQJS0011E Invalid state {0}."},INVALID_TYPE:{code:12,text:"AMQJS0012E Invalid type {0} for {1}."},INVALID_ARGUMENT:{code:13,text:"AMQJS0013E Invalid argument {0} for {1}."},UNSUPPORTED_OPERATION:{code:14,text:"AMQJS0014E Unsupported operation."},INVALID_STORED_DATA:{code:15,text:"AMQJS0015E Invalid data in local storage key={0} value={1}."},INVALID_MQTT_MESSAGE_TYPE:{code:16,text:"AMQJS0016E Invalid MQTT message type {0}."},MALFORMED_UNICODE:{code:17,text:"AMQJS0017E Malformed Unicode string:{0} {1}."},BUFFER_FULL:{code:18,text:"AMQJS0018E Message buffer is full, maximum buffer size: {0}."}},s={0:"Connection Accepted",1:"Connection Refused: unacceptable protocol version",2:"Connection Refused: identifier rejected",3:"Connection Refused: server unavailable",4:"Connection Refused: bad user name or password",5:"Connection Refused: not authorized"},a=function(e,t){var n=e.text;if(t)for(var r,o,i=0;i<t.length;i++)if(r="{"+i+"}",(o=n.indexOf(r))>0){var s=n.substring(0,o),a=n.substring(o+r.length);n=s+t[i]+a}return n},c=[0,6,77,81,73,115,100,112,3],u=[0,4,77,81,84,84,4],h=function(e,t){for(var n in this.type=e,t)t.hasOwnProperty(n)&&(this[n]=t[n])};function f(e,t){var n,r=t,o=e[t],i=o>>4,s=o&=15;t+=1;var a=0,c=1;do{if(t==e.length)return[null,r];a+=(127&(n=e[t++]))*c,c*=128}while(0!=(128&n));var u=t+a;if(u>e.length)return[null,r];var f=new h(i);switch(i){case 2:1&e[t++]&&(f.sessionPresent=!0),f.returnCode=e[t++];break;case 3:var l=s>>1&3,p=d(e,t),y=v(e,t+=2,p);t+=p,l>0&&(f.messageIdentifier=d(e,t),t+=2);var g=new w(e.subarray(t,u));1==(1&s)&&(g.retained=!0),8==(8&s)&&(g.duplicate=!0),g.qos=l,g.destinationName=y,f.payloadMessage=g;break;case 4:case 5:case 6:case 7:case 11:f.messageIdentifier=d(e,t);break;case 9:f.messageIdentifier=d(e,t),t+=2,f.returnCode=e.subarray(t,u)}return[f,u]}function l(e,t,n){return t[n++]=e>>8,t[n++]=e%256,n}function p(e,t,n,r){return g(e,n,r=l(t,n,r)),r+t}function d(e,t){return 256*e[t]+e[t+1]}function y(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);r>2047?(55296<=r&&r<=56319&&(n++,t++),t+=3):r>127?t+=2:t++}return t}function g(e,t,n){for(var r=n,o=0;o<e.length;o++){var s=e.charCodeAt(o);if(55296<=s&&s<=56319){var c=e.charCodeAt(++o);if(isNaN(c))throw new Error(a(i.MALFORMED_UNICODE,[s,c]));s=c-56320+(s-55296<<10)+65536}s<=127?t[r++]=s:s<=2047?(t[r++]=s>>6&31|192,t[r++]=63&s|128):s<=65535?(t[r++]=s>>12&15|224,t[r++]=s>>6&63|128,t[r++]=63&s|128):(t[r++]=s>>18&7|240,t[r++]=s>>12&63|128,t[r++]=s>>6&63|128,t[r++]=63&s|128)}return t}function v(e,t,n){for(var r,o="",s=t;s<t+n;){var c=e[s++];if(c<128)r=c;else{var u=e[s++]-128;if(u<0)throw new Error(a(i.MALFORMED_UTF,[c.toString(16),u.toString(16),""]));if(c<224)r=64*(c-192)+u;else{var h=e[s++]-128;if(h<0)throw new Error(a(i.MALFORMED_UTF,[c.toString(16),u.toString(16),h.toString(16)]));if(c<240)r=4096*(c-224)+64*u+h;else{var f=e[s++]-128;if(f<0)throw new Error(a(i.MALFORMED_UTF,[c.toString(16),u.toString(16),h.toString(16),f.toString(16)]));if(!(c<248))throw new Error(a(i.MALFORMED_UTF,[c.toString(16),u.toString(16),h.toString(16),f.toString(16)]));r=262144*(c-240)+4096*u+64*h+f}}}r>65535&&(r-=65536,o+=String.fromCharCode(55296+(r>>10)),r=56320+(1023&r)),o+=String.fromCharCode(r)}return o}h.prototype.encode=function(){var e,t=(15&this.type)<<4,n=0,r=[],o=0;switch(void 0!==this.messageIdentifier&&(n+=2),this.type){case 1:switch(this.mqttVersion){case 3:n+=c.length+3;break;case 4:n+=u.length+3}n+=y(this.clientId)+2,void 0!==this.willMessage&&(n+=y(this.willMessage.destinationName)+2,(e=this.willMessage.payloadBytes)instanceof Uint8Array||(e=new Uint8Array(s)),n+=e.byteLength+2),void 0!==this.userName&&(n+=y(this.userName)+2),void 0!==this.password&&(n+=y(this.password)+2);break;case 8:t|=2;for(var i=0;i<this.topics.length;i++)r[i]=y(this.topics[i]),n+=r[i]+2;n+=this.requestedQos.length;break;case 10:for(t|=2,i=0;i<this.topics.length;i++)r[i]=y(this.topics[i]),n+=r[i]+2;break;case 6:t|=2;break;case 3:this.payloadMessage.duplicate&&(t|=8),t=t|=this.payloadMessage.qos<<1,this.payloadMessage.retained&&(t|=1),n+=(o=y(this.payloadMessage.destinationName))+2;var s=this.payloadMessage.payloadBytes;n+=s.byteLength,s instanceof ArrayBuffer?s=new Uint8Array(s):s instanceof Uint8Array||(s=new Uint8Array(s.buffer))}var a=function(e){var t=new Array(1),n=0;do{var r=e%128;(e>>=7)>0&&(r|=128),t[n++]=r}while(e>0&&n<4);return t}(n),h=a.length+1,f=new ArrayBuffer(n+h),d=new Uint8Array(f);if(d[0]=t,d.set(a,1),3==this.type)h=p(this.payloadMessage.destinationName,o,d,h);else if(1==this.type){switch(this.mqttVersion){case 3:d.set(c,h),h+=c.length;break;case 4:d.set(u,h),h+=u.length}var g=0;this.cleanSession&&(g=2),void 0!==this.willMessage&&(g|=4,g|=this.willMessage.qos<<3,this.willMessage.retained&&(g|=32)),void 0!==this.userName&&(g|=128),void 0!==this.password&&(g|=64),d[h++]=g,h=l(this.keepAliveInterval,d,h)}switch(void 0!==this.messageIdentifier&&(h=l(this.messageIdentifier,d,h)),this.type){case 1:h=p(this.clientId,y(this.clientId),d,h),void 0!==this.willMessage&&(h=p(this.willMessage.destinationName,y(this.willMessage.destinationName),d,h),h=l(e.byteLength,d,h),d.set(e,h),h+=e.byteLength),void 0!==this.userName&&(h=p(this.userName,y(this.userName),d,h)),void 0!==this.password&&(h=p(this.password,y(this.password),d,h));break;case 3:d.set(s,h);break;case 8:for(i=0;i<this.topics.length;i++)h=p(this.topics[i],r[i],d,h),d[h++]=this.requestedQos[i];break;case 10:for(i=0;i<this.topics.length;i++)h=p(this.topics[i],r[i],d,h)}return f};var b=function(e,t){this._client=e,this._keepAliveInterval=1e3*t,this.isReset=!1;var n=new h(12).encode(),r=function(e){return function(){return o.apply(e)}},o=function(){this.isReset?(this.isReset=!1,this._client._trace("Pinger.doPing","send PINGREQ"),this._client.socket.send(n),this.timeout=setTimeout(r(this),this._keepAliveInterval)):(this._client._trace("Pinger.doPing","Timed out"),this._client._disconnected(i.PING_TIMEOUT.code,a(i.PING_TIMEOUT)))};this.reset=function(){this.isReset=!0,clearTimeout(this.timeout),this._keepAliveInterval>0&&(this.timeout=setTimeout(r(this),this._keepAliveInterval))},this.cancel=function(){clearTimeout(this.timeout)}},_=function(e,t,n,r){t||(t=30),this.timeout=setTimeout(function(e,t,n){return function(){return e.apply(t,n)}}(n,e,r),1e3*t),this.cancel=function(){clearTimeout(this.timeout)}},m=function(t,r,o,s,c){if(!("WebSocket"in e)||null===e.WebSocket)throw new Error(a(i.UNSUPPORTED,["WebSocket"]));if(!("ArrayBuffer"in e)||null===e.ArrayBuffer)throw new Error(a(i.UNSUPPORTED,["ArrayBuffer"]));for(var u in this._trace("Paho.Client",t,r,o,s,c),this.host=r,this.port=o,this.path=s,this.uri=t,this.clientId=c,this._wsuri=null,this._localKey=r+":"+o+("/mqtt"!=s?":"+s:"")+":"+c+":",this._msg_queue=[],this._buffered_msg_queue=[],this._sentMessages={},this._receivedMessages={},this._notify_msg_sent={},this._message_identifier=1,this._sequence=0,n)0!==u.indexOf("Sent:"+this._localKey)&&0!==u.indexOf("Received:"+this._localKey)||this.restore(u)};m.prototype.host=null,m.prototype.port=null,m.prototype.path=null,m.prototype.uri=null,m.prototype.clientId=null,m.prototype.socket=null,m.prototype.connected=!1,m.prototype.maxMessageIdentifier=65536,m.prototype.connectOptions=null,m.prototype.hostIndex=null,m.prototype.onConnected=null,m.prototype.onConnectionLost=null,m.prototype.onMessageDelivered=null,m.prototype.onMessageArrived=null,m.prototype.traceFunction=null,m.prototype._msg_queue=null,m.prototype._buffered_msg_queue=null,m.prototype._connectTimeout=null,m.prototype.sendPinger=null,m.prototype.receivePinger=null,m.prototype._reconnectInterval=1,m.prototype._reconnecting=!1,m.prototype._reconnectTimeout=null,m.prototype.disconnectedPublishing=!1,m.prototype.disconnectedBufferSize=5e3,m.prototype.receiveBuffer=null,m.prototype._traceBuffer=null,m.prototype._MAX_TRACE_ENTRIES=100,m.prototype.connect=function(e){var t=this._traceMask(e,"password");if(this._trace("Client.connect",t,this.socket,this.connected),this.connected)throw new Error(a(i.INVALID_STATE,["already connected"]));if(this.socket)throw new Error(a(i.INVALID_STATE,["already connected"]));this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),this.connectOptions=e,this._reconnectInterval=1,this._reconnecting=!1,e.uris?(this.hostIndex=0,this._doConnect(e.uris[0])):this._doConnect(this.uri)},m.prototype.subscribe=function(e,t){if(this._trace("Client.subscribe",e,t),!this.connected)throw new Error(a(i.INVALID_STATE,["not connected"]));var n=new h(8);n.topics=e.constructor===Array?e:[e],void 0===t.qos&&(t.qos=0),n.requestedQos=[];for(var r=0;r<n.topics.length;r++)n.requestedQos[r]=t.qos;t.onSuccess&&(n.onSuccess=function(e){t.onSuccess({invocationContext:t.invocationContext,grantedQos:e})}),t.onFailure&&(n.onFailure=function(e){t.onFailure({invocationContext:t.invocationContext,errorCode:e,errorMessage:a(e)})}),t.timeout&&(n.timeOut=new _(this,t.timeout,t.onFailure,[{invocationContext:t.invocationContext,errorCode:i.SUBSCRIBE_TIMEOUT.code,errorMessage:a(i.SUBSCRIBE_TIMEOUT)}])),this._requires_ack(n),this._schedule_message(n)},m.prototype.unsubscribe=function(e,t){if(this._trace("Client.unsubscribe",e,t),!this.connected)throw new Error(a(i.INVALID_STATE,["not connected"]));var n=new h(10);n.topics=e.constructor===Array?e:[e],t.onSuccess&&(n.callback=function(){t.onSuccess({invocationContext:t.invocationContext})}),t.timeout&&(n.timeOut=new _(this,t.timeout,t.onFailure,[{invocationContext:t.invocationContext,errorCode:i.UNSUBSCRIBE_TIMEOUT.code,errorMessage:a(i.UNSUBSCRIBE_TIMEOUT)}])),this._requires_ack(n),this._schedule_message(n)},m.prototype.send=function(e){this._trace("Client.send",e);var t=new h(3);if(t.payloadMessage=e,this.connected)e.qos>0?this._requires_ack(t):this.onMessageDelivered&&(this._notify_msg_sent[t]=this.onMessageDelivered(t.payloadMessage)),this._schedule_message(t);else{if(!this._reconnecting||!this.disconnectedPublishing)throw new Error(a(i.INVALID_STATE,["not connected"]));if(Object.keys(this._sentMessages).length+this._buffered_msg_queue.length>this.disconnectedBufferSize)throw new Error(a(i.BUFFER_FULL,[this.disconnectedBufferSize]));e.qos>0?this._requires_ack(t):(t.sequence=++this._sequence,this._buffered_msg_queue.unshift(t))}},m.prototype.disconnect=function(){if(this._trace("Client.disconnect"),this._reconnecting&&(this._reconnectTimeout.cancel(),this._reconnectTimeout=null,this._reconnecting=!1),!this.socket)throw new Error(a(i.INVALID_STATE,["not connecting or connected"]));var e=new h(14);this._notify_msg_sent[e]=o(this._disconnected,this),this._schedule_message(e)},m.prototype.getTraceLog=function(){if(null!==this._traceBuffer){for(var e in this._trace("Client.getTraceLog",new Date),this._trace("Client.getTraceLog in flight messages",this._sentMessages.length),this._sentMessages)this._trace("_sentMessages ",e,this._sentMessages[e]);for(var e in this._receivedMessages)this._trace("_receivedMessages ",e,this._receivedMessages[e]);return this._traceBuffer}},m.prototype.startTrace=function(){null===this._traceBuffer&&(this._traceBuffer=[]),this._trace("Client.startTrace",new Date,"@VERSION@-@BUILDLEVEL@")},m.prototype.stopTrace=function(){delete this._traceBuffer},m.prototype._doConnect=function(e){if(this.connectOptions.useSSL){var t=e.split(":");t[0]="wss",e=t.join(":")}this._wsuri=e,this.connected=!1,this.connectOptions.mqttVersion<4?this.socket=new WebSocket(e,["mqttv3.1"]):this.socket=new WebSocket(e,["mqtt"]),this.socket.binaryType="arraybuffer",this.socket.onopen=o(this._on_socket_open,this),this.socket.onmessage=o(this._on_socket_message,this),this.socket.onerror=o(this._on_socket_error,this),this.socket.onclose=o(this._on_socket_close,this),this.sendPinger=new b(this,this.connectOptions.keepAliveInterval),this.receivePinger=new b(this,this.connectOptions.keepAliveInterval),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._connectTimeout=new _(this,this.connectOptions.timeout,this._disconnected,[i.CONNECT_TIMEOUT.code,a(i.CONNECT_TIMEOUT)])},m.prototype._schedule_message=function(e){this._msg_queue.unshift(e),this.connected&&this._process_queue()},m.prototype.store=function(e,t){var r={type:t.type,messageIdentifier:t.messageIdentifier,version:1};switch(t.type){case 3:t.pubRecReceived&&(r.pubRecReceived=!0),r.payloadMessage={};for(var o="",s=t.payloadMessage.payloadBytes,c=0;c<s.length;c++)s[c]<=15?o=o+"0"+s[c].toString(16):o+=s[c].toString(16);r.payloadMessage.payloadHex=o,r.payloadMessage.qos=t.payloadMessage.qos,r.payloadMessage.destinationName=t.payloadMessage.destinationName,t.payloadMessage.duplicate&&(r.payloadMessage.duplicate=!0),t.payloadMessage.retained&&(r.payloadMessage.retained=!0),0===e.indexOf("Sent:")&&(void 0===t.sequence&&(t.sequence=++this._sequence),r.sequence=t.sequence);break;default:throw Error(a(i.INVALID_STORED_DATA,[e+this._localKey+t.messageIdentifier,r]))}n.setItem(e+this._localKey+t.messageIdentifier,JSON.stringify(r))},m.prototype.restore=function(e){var t=n.getItem(e),r=JSON.parse(t),o=new h(r.type,r);switch(r.type){case 3:for(var s=r.payloadMessage.payloadHex,c=new ArrayBuffer(s.length/2),u=new Uint8Array(c),f=0;s.length>=2;){var l=parseInt(s.substring(0,2),16);s=s.substring(2,s.length),u[f++]=l}var p=new w(u);p.qos=r.payloadMessage.qos,p.destinationName=r.payloadMessage.destinationName,r.payloadMessage.duplicate&&(p.duplicate=!0),r.payloadMessage.retained&&(p.retained=!0),o.payloadMessage=p;break;default:throw Error(a(i.INVALID_STORED_DATA,[e,t]))}0===e.indexOf("Sent:"+this._localKey)?(o.payloadMessage.duplicate=!0,this._sentMessages[o.messageIdentifier]=o):0===e.indexOf("Received:"+this._localKey)&&(this._receivedMessages[o.messageIdentifier]=o)},m.prototype._process_queue=function(){for(var e=null;e=this._msg_queue.pop();)this._socket_send(e),this._notify_msg_sent[e]&&(this._notify_msg_sent[e](),delete this._notify_msg_sent[e])},m.prototype._requires_ack=function(e){var t=Object.keys(this._sentMessages).length;if(t>this.maxMessageIdentifier)throw Error("Too many messages:"+t);for(;void 0!==this._sentMessages[this._message_identifier];)this._message_identifier++;e.messageIdentifier=this._message_identifier,this._sentMessages[e.messageIdentifier]=e,3===e.type&&this.store("Sent:",e),this._message_identifier===this.maxMessageIdentifier&&(this._message_identifier=1)},m.prototype._on_socket_open=function(){var e=new h(1,this.connectOptions);e.clientId=this.clientId,this._socket_send(e)},m.prototype._on_socket_message=function(e){this._trace("Client._on_socket_message",e.data);for(var t=this._deframeMessages(e.data),n=0;n<t.length;n+=1)this._handleMessage(t[n])},m.prototype._deframeMessages=function(e){var t=new Uint8Array(e),n=[];if(this.receiveBuffer){var r=new Uint8Array(this.receiveBuffer.length+t.length);r.set(this.receiveBuffer),r.set(t,this.receiveBuffer.length),t=r,delete this.receiveBuffer}try{for(var o=0;o<t.length;){var s=f(t,o),c=s[0];if(o=s[1],null===c)break;n.push(c)}o<t.length&&(this.receiveBuffer=t.subarray(o))}catch(e){var u="undefined"==e.hasOwnProperty("stack")?e.stack.toString():"No Error Stack Available";return void this._disconnected(i.INTERNAL_ERROR.code,a(i.INTERNAL_ERROR,[e.message,u]))}return n},m.prototype._handleMessage=function(e){this._trace("Client._handleMessage",e);try{switch(e.type){case 2:if(this._connectTimeout.cancel(),this._reconnectTimeout&&this._reconnectTimeout.cancel(),this.connectOptions.cleanSession){for(var t in this._sentMessages){var r=this._sentMessages[t];n.removeItem("Sent:"+this._localKey+r.messageIdentifier)}for(var t in this._sentMessages={},this._receivedMessages){var o=this._receivedMessages[t];n.removeItem("Received:"+this._localKey+o.messageIdentifier)}this._receivedMessages={}}if(0!==e.returnCode){this._disconnected(i.CONNACK_RETURNCODE.code,a(i.CONNACK_RETURNCODE,[e.returnCode,s[e.returnCode]]));break}this.connected=!0,this.connectOptions.uris&&(this.hostIndex=this.connectOptions.uris.length);var c=[];for(var u in this._sentMessages)this._sentMessages.hasOwnProperty(u)&&c.push(this._sentMessages[u]);if(this._buffered_msg_queue.length>0)for(var f=null;f=this._buffered_msg_queue.pop();)c.push(f),this.onMessageDelivered&&(this._notify_msg_sent[f]=this.onMessageDelivered(f.payloadMessage));c=c.sort((function(e,t){return e.sequence-t.sequence}));for(var l=0,p=c.length;l<p;l++)if(3==(r=c[l]).type&&r.pubRecReceived){var d=new h(6,{messageIdentifier:r.messageIdentifier});this._schedule_message(d)}else this._schedule_message(r);this.connectOptions.onSuccess&&this.connectOptions.onSuccess({invocationContext:this.connectOptions.invocationContext});var y=!1;this._reconnecting&&(y=!0,this._reconnectInterval=1,this._reconnecting=!1),this._connected(y,this._wsuri),this._process_queue();break;case 3:this._receivePublish(e);break;case 4:(r=this._sentMessages[e.messageIdentifier])&&(delete this._sentMessages[e.messageIdentifier],n.removeItem("Sent:"+this._localKey+e.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(r.payloadMessage));break;case 5:(r=this._sentMessages[e.messageIdentifier])&&(r.pubRecReceived=!0,d=new h(6,{messageIdentifier:e.messageIdentifier}),this.store("Sent:",r),this._schedule_message(d));break;case 6:o=this._receivedMessages[e.messageIdentifier],n.removeItem("Received:"+this._localKey+e.messageIdentifier),o&&(this._receiveMessage(o),delete this._receivedMessages[e.messageIdentifier]);var g=new h(7,{messageIdentifier:e.messageIdentifier});this._schedule_message(g);break;case 7:r=this._sentMessages[e.messageIdentifier],delete this._sentMessages[e.messageIdentifier],n.removeItem("Sent:"+this._localKey+e.messageIdentifier),this.onMessageDelivered&&this.onMessageDelivered(r.payloadMessage);break;case 9:(r=this._sentMessages[e.messageIdentifier])&&(r.timeOut&&r.timeOut.cancel(),128===e.returnCode[0]?r.onFailure&&r.onFailure(e.returnCode):r.onSuccess&&r.onSuccess(e.returnCode),delete this._sentMessages[e.messageIdentifier]);break;case 11:(r=this._sentMessages[e.messageIdentifier])&&(r.timeOut&&r.timeOut.cancel(),r.callback&&r.callback(),delete this._sentMessages[e.messageIdentifier]);break;case 13:this.sendPinger.reset();break;case 14:this._disconnected(i.INVALID_MQTT_MESSAGE_TYPE.code,a(i.INVALID_MQTT_MESSAGE_TYPE,[e.type]));break;default:this._disconnected(i.INVALID_MQTT_MESSAGE_TYPE.code,a(i.INVALID_MQTT_MESSAGE_TYPE,[e.type]))}}catch(e){var v="undefined"==e.hasOwnProperty("stack")?e.stack.toString():"No Error Stack Available";return void this._disconnected(i.INTERNAL_ERROR.code,a(i.INTERNAL_ERROR,[e.message,v]))}},m.prototype._on_socket_error=function(e){this._reconnecting||this._disconnected(i.SOCKET_ERROR.code,a(i.SOCKET_ERROR,[e.data]))},m.prototype._on_socket_close=function(){this._reconnecting||this._disconnected(i.SOCKET_CLOSE.code,a(i.SOCKET_CLOSE))},m.prototype._socket_send=function(e){if(1==e.type){var t=this._traceMask(e,"password");this._trace("Client._socket_send",t)}else this._trace("Client._socket_send",e);this.socket.send(e.encode()),this.sendPinger.reset()},m.prototype._receivePublish=function(e){switch(e.payloadMessage.qos){case"undefined":case 0:this._receiveMessage(e);break;case 1:var t=new h(4,{messageIdentifier:e.messageIdentifier});this._schedule_message(t),this._receiveMessage(e);break;case 2:this._receivedMessages[e.messageIdentifier]=e,this.store("Received:",e);var n=new h(5,{messageIdentifier:e.messageIdentifier});this._schedule_message(n);break;default:throw Error("Invaild qos="+e.payloadMessage.qos)}},m.prototype._receiveMessage=function(e){this.onMessageArrived&&this.onMessageArrived(e.payloadMessage)},m.prototype._connected=function(e,t){this.onConnected&&this.onConnected(e,t)},m.prototype._reconnect=function(){this._trace("Client._reconnect"),this.connected||(this._reconnecting=!0,this.sendPinger.cancel(),this.receivePinger.cancel(),this._reconnectInterval<128&&(this._reconnectInterval=2*this._reconnectInterval),this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri))},m.prototype._disconnected=function(e,t){if(this._trace("Client._disconnected",e,t),void 0!==e&&this._reconnecting)this._reconnectTimeout=new _(this,this._reconnectInterval,this._reconnect);else if(this.sendPinger.cancel(),this.receivePinger.cancel(),this._connectTimeout&&(this._connectTimeout.cancel(),this._connectTimeout=null),this._msg_queue=[],this._buffered_msg_queue=[],this._notify_msg_sent={},this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,1===this.socket.readyState&&this.socket.close(),delete this.socket),this.connectOptions.uris&&this.hostIndex<this.connectOptions.uris.length-1)this.hostIndex++,this._doConnect(this.connectOptions.uris[this.hostIndex]);else if(void 0===e&&(e=i.OK.code,t=a(i.OK)),this.connected){if(this.connected=!1,this.onConnectionLost&&this.onConnectionLost({errorCode:e,errorMessage:t,reconnect:this.connectOptions.reconnect,uri:this._wsuri}),e!==i.OK.code&&this.connectOptions.reconnect)return this._reconnectInterval=1,void this._reconnect()}else 4===this.connectOptions.mqttVersion&&!1===this.connectOptions.mqttVersionExplicit?(this._trace("Failed to connect V4, dropping back to V3"),this.connectOptions.mqttVersion=3,this.connectOptions.uris?(this.hostIndex=0,this._doConnect(this.connectOptions.uris[0])):this._doConnect(this.uri)):this.connectOptions.onFailure&&this.connectOptions.onFailure({invocationContext:this.connectOptions.invocationContext,errorCode:e,errorMessage:t})},m.prototype._trace=function(){if(this.traceFunction){var e=Array.prototype.slice.call(arguments);for(var t in e)void 0!==e[t]&&e.splice(t,1,JSON.stringify(e[t]));var n=e.join("");this.traceFunction({severity:"Debug",message:n})}if(null!==this._traceBuffer){t=0;for(var r=arguments.length;t<r;t++)this._traceBuffer.length==this._MAX_TRACE_ENTRIES&&this._traceBuffer.shift(),0===t||void 0===arguments[t]?this._traceBuffer.push(arguments[t]):this._traceBuffer.push(" "+JSON.stringify(arguments[t]))}},m.prototype._traceMask=function(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=r==t?"******":e[r]);return n};var w=function(e){var t,n;if(!("string"==typeof e||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)))throw a(i.INVALID_ARGUMENT,[e,"newPayload"]);t=e;var r=0,o=!1,s=!1;Object.defineProperties(this,{payloadString:{enumerable:!0,get:function(){return"string"==typeof t?t:v(t,0,t.length)}},payloadBytes:{enumerable:!0,get:function(){if("string"==typeof t){var e=new ArrayBuffer(y(t)),n=new Uint8Array(e);return g(t,n,0),n}return t}},destinationName:{enumerable:!0,get:function(){return n},set:function(e){if("string"!=typeof e)throw new Error(a(i.INVALID_ARGUMENT,[e,"newDestinationName"]));n=e}},qos:{enumerable:!0,get:function(){return r},set:function(e){if(0!==e&&1!==e&&2!==e)throw new Error("Invalid argument:"+e);r=e}},retained:{enumerable:!0,get:function(){return o},set:function(e){if("boolean"!=typeof e)throw new Error(a(i.INVALID_ARGUMENT,[e,"newRetained"]));o=e}},topic:{enumerable:!0,get:function(){return n},set:function(e){n=e}},duplicate:{enumerable:!0,get:function(){return s},set:function(e){s=e}}})};return{Client:function(e,t,n,o){var s;if("string"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"host"]));if(2==arguments.length){o=t;var c=(s=e).match(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/);if(!c)throw new Error(a(i.INVALID_ARGUMENT,[e,"host"]));e=c[4]||c[2],t=parseInt(c[7]),n=c[8]}else{if(3==arguments.length&&(o=n,n="/mqtt"),"number"!=typeof t||t<0)throw new Error(a(i.INVALID_TYPE,[typeof t,"port"]));if("string"!=typeof n)throw new Error(a(i.INVALID_TYPE,[typeof n,"path"]));var u=-1!==e.indexOf(":")&&"["!==e.slice(0,1)&&"]"!==e.slice(-1);s="ws://"+(u?"["+e+"]":e)+":"+t+n}for(var h=0,f=0;f<o.length;f++){var l=o.charCodeAt(f);55296<=l&&l<=56319&&f++,h++}if("string"!=typeof o||h>65535)throw new Error(a(i.INVALID_ARGUMENT,[o,"clientId"]));var p=new m(s,e,t,n,o);Object.defineProperties(this,{host:{get:function(){return e},set:function(){throw new Error(a(i.UNSUPPORTED_OPERATION))}},port:{get:function(){return t},set:function(){throw new Error(a(i.UNSUPPORTED_OPERATION))}},path:{get:function(){return n},set:function(){throw new Error(a(i.UNSUPPORTED_OPERATION))}},uri:{get:function(){return s},set:function(){throw new Error(a(i.UNSUPPORTED_OPERATION))}},clientId:{get:function(){return p.clientId},set:function(){throw new Error(a(i.UNSUPPORTED_OPERATION))}},onConnected:{get:function(){return p.onConnected},set:function(e){if("function"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"onConnected"]));p.onConnected=e}},disconnectedPublishing:{get:function(){return p.disconnectedPublishing},set:function(e){p.disconnectedPublishing=e}},disconnectedBufferSize:{get:function(){return p.disconnectedBufferSize},set:function(e){p.disconnectedBufferSize=e}},onConnectionLost:{get:function(){return p.onConnectionLost},set:function(e){if("function"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"onConnectionLost"]));p.onConnectionLost=e}},onMessageDelivered:{get:function(){return p.onMessageDelivered},set:function(e){if("function"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"onMessageDelivered"]));p.onMessageDelivered=e}},onMessageArrived:{get:function(){return p.onMessageArrived},set:function(e){if("function"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"onMessageArrived"]));p.onMessageArrived=e}},trace:{get:function(){return p.traceFunction},set:function(e){if("function"!=typeof e)throw new Error(a(i.INVALID_TYPE,[typeof e,"onTrace"]));p.traceFunction=e}}}),this.connect=function(e){if(r(e=e||{},{timeout:"number",userName:"string",password:"string",willMessage:"object",keepAliveInterval:"number",cleanSession:"boolean",useSSL:"boolean",invocationContext:"object",onSuccess:"function",onFailure:"function",hosts:"object",ports:"object",reconnect:"boolean",mqttVersion:"number",mqttVersionExplicit:"boolean",uris:"object"}),void 0===e.keepAliveInterval&&(e.keepAliveInterval=60),e.mqttVersion>4||e.mqttVersion<3)throw new Error(a(i.INVALID_ARGUMENT,[e.mqttVersion,"connectOptions.mqttVersion"]));if(void 0===e.mqttVersion?(e.mqttVersionExplicit=!1,e.mqttVersion=4):e.mqttVersionExplicit=!0,void 0!==e.password&&void 0===e.userName)throw new Error(a(i.INVALID_ARGUMENT,[e.password,"connectOptions.password"]));if(e.willMessage){if(!(e.willMessage instanceof w))throw new Error(a(i.INVALID_TYPE,[e.willMessage,"connectOptions.willMessage"]));if(e.willMessage.stringPayload=null,void 0===e.willMessage.destinationName)throw new Error(a(i.INVALID_TYPE,[typeof e.willMessage.destinationName,"connectOptions.willMessage.destinationName"]))}if(void 0===e.cleanSession&&(e.cleanSession=!0),e.hosts){if(!(e.hosts instanceof Array))throw new Error(a(i.INVALID_ARGUMENT,[e.hosts,"connectOptions.hosts"]));if(e.hosts.length<1)throw new Error(a(i.INVALID_ARGUMENT,[e.hosts,"connectOptions.hosts"]));for(var t=!1,o=0;o<e.hosts.length;o++){if("string"!=typeof e.hosts[o])throw new Error(a(i.INVALID_TYPE,[typeof e.hosts[o],"connectOptions.hosts["+o+"]"]));if(/^(wss?):\/\/((\[(.+)\])|([^\/]+?))(:(\d+))?(\/.*)$/.test(e.hosts[o])){if(0===o)t=!0;else if(!t)throw new Error(a(i.INVALID_ARGUMENT,[e.hosts[o],"connectOptions.hosts["+o+"]"]))}else if(t)throw new Error(a(i.INVALID_ARGUMENT,[e.hosts[o],"connectOptions.hosts["+o+"]"]))}if(t)e.uris=e.hosts;else{if(!e.ports)throw new Error(a(i.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));if(!(e.ports instanceof Array))throw new Error(a(i.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));if(e.hosts.length!==e.ports.length)throw new Error(a(i.INVALID_ARGUMENT,[e.ports,"connectOptions.ports"]));for(e.uris=[],o=0;o<e.hosts.length;o++){if("number"!=typeof e.ports[o]||e.ports[o]<0)throw new Error(a(i.INVALID_TYPE,[typeof e.ports[o],"connectOptions.ports["+o+"]"]));var c=e.hosts[o],u=e.ports[o],h=-1!==c.indexOf(":");s="ws://"+(h?"["+c+"]":c)+":"+u+n,e.uris.push(s)}}}p.connect(e)},this.subscribe=function(e,t){if("string"!=typeof e&&e.constructor!==Array)throw new Error("Invalid argument:"+e);if(r(t=t||{},{qos:"number",invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),t.timeout&&!t.onFailure)throw new Error("subscribeOptions.timeout specified with no onFailure callback.");if(void 0!==t.qos&&0!==t.qos&&1!==t.qos&&2!==t.qos)throw new Error(a(i.INVALID_ARGUMENT,[t.qos,"subscribeOptions.qos"]));p.subscribe(e,t)},this.unsubscribe=function(e,t){if("string"!=typeof e&&e.constructor!==Array)throw new Error("Invalid argument:"+e);if(r(t=t||{},{invocationContext:"object",onSuccess:"function",onFailure:"function",timeout:"number"}),t.timeout&&!t.onFailure)throw new Error("unsubscribeOptions.timeout specified with no onFailure callback.");p.unsubscribe(e,t)},this.send=function(e,t,n,r){var o;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(e instanceof w)&&"string"!=typeof e)throw new Error("Invalid argument:"+typeof e);if(void 0===(o=e).destinationName)throw new Error(a(i.INVALID_ARGUMENT,[o.destinationName,"Message.destinationName"]));p.send(o)}else(o=new w(t)).destinationName=e,arguments.length>=3&&(o.qos=n),arguments.length>=4&&(o.retained=r),p.send(o)},this.publish=function(e,t,n,r){var o;if(0===arguments.length)throw new Error("Invalid argument.length");if(1==arguments.length){if(!(e instanceof w)&&"string"!=typeof e)throw new Error("Invalid argument:"+typeof e);if(void 0===(o=e).destinationName)throw new Error(a(i.INVALID_ARGUMENT,[o.destinationName,"Message.destinationName"]));p.send(o)}else(o=new w(t)).destinationName=e,arguments.length>=3&&(o.qos=n),arguments.length>=4&&(o.retained=r),p.send(o)},this.disconnect=function(){p.disconnect()},this.getTraceLog=function(){return p.getTraceLog()},this.startTrace=function(){p.startTrace()},this.stopTrace=function(){p.stopTrace()},this.isConnected=function(){return p.connected}},Message:w}}(void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},e.exports=r()},639:function(e,t,n){var r;e=n.nmd(e),function(o){t&&t.nodeType,e&&e.nodeType;var i="object"==typeof n.g&&n.g;i.global!==i&&i.window!==i&&i.self;var s,a=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,h=/[\x2E\u3002\uFF0E\uFF61]/g,f={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,p=String.fromCharCode;function d(e){throw RangeError(f[e])}function y(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+y((e=e.replace(h,".")).split("."),t).join(".")}function v(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=p((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+p(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function m(e,t,n){var r=0;for(e=n?l(e/700):e>>1,e+=l(e/t);e>455;r+=36)e=l(e/35);return l(r+36*e/(e+38))}function w(e){var t,n,r,o,i,s,c,u,h,f,p,y=[],g=e.length,v=0,_=128,w=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&d("not-basic"),y.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<g;){for(i=v,s=1,c=36;o>=g&&d("invalid-input"),((u=(p=e.charCodeAt(o++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||u>l((a-v)/s))&&d("overflow"),v+=u*s,!(u<(h=c<=w?1:c>=w+26?26:c-w));c+=36)s>l(a/(f=36-h))&&d("overflow"),s*=f;w=m(v-i,t=y.length+1,0==i),l(v/t)>a-_&&d("overflow"),_+=l(v/t),v%=t,y.splice(v++,0,_)}return b(y)}function E(e){var t,n,r,o,i,s,c,u,h,f,y,g,b,w,E,S=[];for(g=(e=v(e)).length,t=128,n=0,i=72,s=0;s<g;++s)(y=e[s])<128&&S.push(p(y));for(r=o=S.length,o&&S.push("-");r<g;){for(c=a,s=0;s<g;++s)(y=e[s])>=t&&y<c&&(c=y);for(c-t>l((a-n)/(b=r+1))&&d("overflow"),n+=(c-t)*b,t=c,s=0;s<g;++s)if((y=e[s])<t&&++n>a&&d("overflow"),y==t){for(u=n,h=36;!(u<(f=h<=i?1:h>=i+26?26:h-i));h+=36)E=u-f,w=36-f,S.push(p(_(f+E%w,0))),u=l(E/w);S.push(p(_(u,0))),i=m(n,b,r==o),n=0,++r}++n,++t}return S.join("")}s={version:"1.3.2",ucs2:{decode:v,encode:b},decode:w,encode:E,toASCII:function(e){return g(e,(function(e){return u.test(e)?"xn--"+E(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?w(e.slice(4).toLowerCase()):e}))}},void 0===(r=function(){return s}.call(t,n,t,e))||(e.exports=r)}()},41:e=>{"use strict";function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,n,r,o){n=n||"&",r=r||"=";var i={};if("string"!=typeof e||0===e.length)return i;var s=/\+/g;e=e.split(n);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var c=e.length;a>0&&c>a&&(c=a);for(var u=0;u<c;++u){var h,f,l,p,d=e[u].replace(s,"%20"),y=d.indexOf(r);y>=0?(h=d.substr(0,y),f=d.substr(y+1)):(h=d,f=""),l=decodeURIComponent(h),p=decodeURIComponent(f),t(i,l)?Array.isArray(i[l])?i[l].push(p):i[l]=[i[l],p]:i[l]=p}return i}},145:e=>{"use strict";var t=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,n,r,o){return n=n||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(o){var i=encodeURIComponent(t(o))+r;return Array.isArray(e[o])?e[o].map((function(e){return i+encodeURIComponent(t(e))})).join(n):i+encodeURIComponent(t(e[o]))})).join(n):o?encodeURIComponent(t(o))+r+encodeURIComponent(t(e)):""}},486:(e,t,n)=>{"use strict";t.decode=t.parse=n(41),t.encode=t.stringify=n(145)},883:(e,t,n)=>{"use strict";var r=n(639),o=n(225);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.Qc=_;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(u),f=["%","/","?",";","#"].concat(h),l=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=n(486);function _(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",u=e.split(a);u[0]=u[0].replace(/\\/g,"/");var _=e=u.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var m=c.exec(_);if(m)return this.path=_,this.href=_,this.pathname=m[1],m[2]?(this.search=m[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var w=s.exec(_);if(w){var E=(w=w[0]).toLowerCase();this.protocol=E,_=_.substr(w.length)}if(n||w||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var S="//"===_.substr(0,2);!S||w&&g[w]||(_=_.substr(2),this.slashes=!0)}if(!g[w]&&(S||w&&!v[w])){for(var A,O,I=-1,T=0;T<l.length;T++)-1!==(C=_.indexOf(l[T]))&&(-1===I||C<I)&&(I=C);for(-1!==(O=-1===I?_.lastIndexOf("@"):_.lastIndexOf("@",I))&&(A=_.slice(0,O),_=_.slice(O+1),this.auth=decodeURIComponent(A)),I=-1,T=0;T<f.length;T++){var C;-1!==(C=_.indexOf(f[T]))&&(-1===I||C<I)&&(I=C)}-1===I&&(I=_.length),this.host=_.slice(0,I),_=_.slice(I),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var N=this.hostname.split(/\./),M=(T=0,N.length);T<M;T++){var P=N[T];if(P&&!P.match(p)){for(var k="",x=0,U=P.length;x<U;x++)P.charCodeAt(x)>127?k+="x":k+=P[x];if(!k.match(p)){var L=N.slice(0,T),D=N.slice(T+1),q=P.match(d);q&&(L.push(q[1]),D.unshift(q[2])),D.length&&(_="/"+D.join(".")+_),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=r.toASCII(this.hostname));var B=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+B,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!y[E])for(T=0,M=h.length;T<M;T++){var V=h[T];if(-1!==_.indexOf(V)){var F=encodeURIComponent(V);F===V&&(F=escape(V)),_=_.split(V).join(F)}}var G=_.indexOf("#");-1!==G&&(this.hash=_.substr(G),_=_.slice(0,G));var Y=_.indexOf("?");if(-1!==Y?(this.search=_.substr(Y),this.query=_.substr(Y+1),t&&(this.query=b.parse(this.query)),_=_.slice(0,Y)):t&&(this.search="",this.query={}),_&&(this.pathname=_),v[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){B=this.pathname||"";var Q=this.search||"";this.path=B+Q}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(_(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0;u<c.length;u++){var h=c[u];"protocol"!==h&&(n[h]=e[h])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var f=Object.keys(e),l=0;l<f.length;l++){var p=f[l];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||g[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var y=n.pathname||"",b=n.search||"";n.path=y+b}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var _=n.pathname&&"/"===n.pathname.charAt(0),m=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=m||_||n.host&&e.pathname,E=w,S=n.pathname&&n.pathname.split("/")||[],A=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(A&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),w=w&&(""===d[0]||""===S[0])),m)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return A&&(n.hostname=n.host=S.shift(),(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var O=S.slice(-1)[0],I=(n.host||e.host||S.length>1)&&("."===O||".."===O)||""===O,T=0,C=S.length;C>=0;C--)"."===(O=S[C])?S.splice(C,1):".."===O?(S.splice(C,1),T++):T&&(S.splice(C,1),T--);if(!w&&!E)for(;T--;T)S.unshift("..");!w||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var R,N=""===S[0]||S[0]&&"/"===S[0].charAt(0);return A&&(n.hostname=n.host=N?"":S.length?S.shift():"",(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),(w=w||n.host&&S.length)&&!N&&S.unshift(""),S.length?n.pathname=S.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},225:e=>{"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},22:(e,t,n)=>{var r=n(481),o=n(426),i=o;i.v1=r,i.v4=o,e.exports=i},725:e=>{for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);e.exports=function(e,n){var r=n||0,o=t;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}},157:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},481:(e,t,n)=>{var r,o,i=n(157),s=n(725),a=0,c=0;e.exports=function(e,t,n){var u=t&&n||0,h=t||[],f=(e=e||{}).node||r,l=void 0!==e.clockseq?e.clockseq:o;if(null==f||null==l){var p=i();null==f&&(f=r=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==l&&(l=o=16383&(p[6]<<8|p[7]))}var d=void 0!==e.msecs?e.msecs:(new Date).getTime(),y=void 0!==e.nsecs?e.nsecs:c+1,g=d-a+(y-c)/1e4;if(g<0&&void 0===e.clockseq&&(l=l+1&16383),(g<0||d>a)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=d,c=y,o=l;var v=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;h[u++]=v>>>24&255,h[u++]=v>>>16&255,h[u++]=v>>>8&255,h[u++]=255&v;var b=d/4294967296*1e4&268435455;h[u++]=b>>>8&255,h[u++]=255&b,h[u++]=b>>>24&15|16,h[u++]=b>>>16&255,h[u++]=l>>>8|128,h[u++]=255&l;for(var _=0;_<6;++_)h[u+_]=f[_];return t||s(h)}},426:(e,t,n)=>{var r=n(157),o=n(725);e.exports=function(e,t,n){var i=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[i+a]=s[a];return t||o(s)}},603:(e,t,n)=>{e.exports=n(821).Observable},821:(e,t)=>{"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}t.Observable=void 0;var i=function(){return"function"==typeof Symbol},s=function(e){return i()&&Boolean(Symbol[e])},a=function(e){return s(e)?Symbol[e]:"@@"+e};i()&&!s("observable")&&(Symbol.observable=Symbol("observable"));var c=a("iterator"),u=a("observable"),h=a("species");function f(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function l(e){var t=e.constructor;return void 0!==t&&null===(t=t[h])&&(t=void 0),void 0!==t?t:E}function p(e){return e instanceof E}function d(e){d.log?d.log(e):setTimeout((function(){throw e}))}function y(e){Promise.resolve().then((function(){try{e()}catch(e){d(e)}}))}function g(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=f(t,"unsubscribe");n&&n.call(t)}}catch(e){d(e)}}function v(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function b(e,t,n){e._state="running";var r=e._observer;try{var o=f(r,t);switch(t){case"next":o&&o.call(r,n);break;case"error":if(v(e),!o)throw n;o.call(r,n);break;case"complete":v(e),o&&o.call(r)}}catch(e){d(e)}"closed"===e._state?g(e):"running"===e._state&&(e._state="ready")}function _(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void y((function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(b(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)}))):void b(e,t,n);e._queue.push({type:t,value:n})}}var m=function(){function e(t,r){n(this,e),this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var o=new w(this);try{this._cleanup=r.call(void 0,o)}catch(e){o.error(e)}"initializing"===this._state&&(this._state="ready")}return o(e,[{key:"unsubscribe",value:function(){"closed"!==this._state&&(v(this),g(this))}},{key:"closed",get:function(){return"closed"===this._state}}]),e}(),w=function(){function e(t){n(this,e),this._subscription=t}return o(e,[{key:"next",value:function(e){_(this._subscription,"next",e)}},{key:"error",value:function(e){_(this._subscription,"error",e)}},{key:"complete",value:function(){_(this._subscription,"complete")}},{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),E=function(){function e(t){if(n(this,e),!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}return o(e,[{key:"subscribe",value:function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new m(e,this._subscriber)}},{key:"forEach",value:function(e){var t=this;return new Promise((function(n,r){if("function"==typeof e)var o=t.subscribe({next:function(t){try{e(t,i)}catch(e){r(e),o.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function i(){o.unsubscribe(),n()}}))}},{key:"map",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(l(this))((function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}},{key:"filter",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(l(this))((function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}},{key:"reduce",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=l(this),r=arguments.length>1,o=!1,i=arguments[1],s=i;return new n((function(n){return t.subscribe({next:function(t){var i=!o;if(o=!0,!i||r)try{s=e(s,t)}catch(e){return n.error(e)}else s=t},error:function(e){n.error(e)},complete:function(){if(!o&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(s),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=l(this);return new o((function(t){var r,i=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){i===n.length?(r=void 0,t.complete()):e(o.from(n[i++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}}))}},{key:"flatMap",value:function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=l(this);return new n((function(r){var o=[],i=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var i=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=o.indexOf(i);e>=0&&o.splice(e,1),s()}});o.push(i)},error:function(e){r.error(e)},complete:function(){s()}});function s(){i.closed&&0===o.length&&r.complete()}return function(){o.forEach((function(e){return e.unsubscribe()})),i.unsubscribe()}}))}},{key:u,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,u);if(r){var o=r.call(t);if(Object(o)!==o)throw new TypeError(o+" is not an object");return p(o)&&o.constructor===n?o:new n((function(e){return o.subscribe(e)}))}if(s("iterator")&&(r=f(t,c)))return new n((function(e){y((function(){if(!e.closed){var n=!0,o=!1,i=void 0;try{for(var s,a=r.call(t)[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var c=s.value;if(e.next(c),e.closed)return}}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){y((function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")}},{key:"of",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o="function"==typeof this?this:e;return new o((function(e){y((function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}}))}))}},{key:h,get:function(){return this}}]),e}();t.Observable=E,i()&&Object.defineProperty(E,Symbol("extensions"),{value:{symbol:u,hostReportError:d},configurable:!0})},648:e=>{"use strict";e.exports=r},877:e=>{"use strict";e.exports=n},346:t=>{"use strict";t.exports=e},957:e=>{"use strict";e.exports=t}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={id:e,loaded:!1,exports:{}};return o[e].call(n.exports,n,n.exports,s),n.loaded=!0,n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var a={};return(()=>{"use strict";s.r(a),s.d(a,{AWSAppSyncProvider:()=>N,AWSAppSyncRealTimeProvider:()=>z,AWSIoTProvider:()=>te,AbstractPubSubProvider:()=>u,CONTROL_MSG:()=>X,MqttOverWSProvider:()=>A,PubSub:()=>Z,default:()=>ne,mqttTopicMatch:()=>b});var e=s(603);const t=s.n(e)();var n=s(346),r=s(118),o=s(22),i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},c=new n.ConsoleLogger("AbstractPubSubProvider"),u=function(){function e(e){void 0===e&&(e={}),this._config=e}return e.prototype.configure=function(e){return void 0===e&&(e={}),this._config=i(i({},e),this._config),c.debug("configure "+this.getProviderName(),this._config),this.options},e.prototype.getCategory=function(){return"PubSub"},Object.defineProperty(e.prototype,"options",{get:function(){return i({},this._config)},enumerable:!0,configurable:!0}),e}();function h(e){return(h="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)}var f,l=(f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),p=function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},d=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},y=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},v=new n.ConsoleLogger("MqttOverWSProvider");function b(e,t){for(var n=e.split("/"),r=n.length,o=t.split("/"),i=0;i<r;++i){var s=n[i],a=o[i];if("#"===s)return o.length>=r;if("+"!==s&&s!==a)return!1}return r===o.length}var _,m,w,E=function(){function e(){this.promises=new Map}return e.prototype.get=function(e,t){return d(this,void 0,void 0,(function(){var n,r;return y(this,(function(o){return(n=this.promises.get(e))?[2,n]:t?(r=t(e),this.promises.set(e,r),[2,r]):[2,void 0]}))}))},Object.defineProperty(e.prototype,"allClients",{get:function(){return Array.from(this.promises.keys())},enumerable:!0,configurable:!0}),e.prototype.remove=function(e){this.promises.delete(e)},e}(),S="undefined"!=typeof Symbol?Symbol("topic"):"@@topic",A=function(e){function n(t){void 0===t&&(t={});var n=e.call(this,p(p({},t),{clientId:t.clientId||(0,o.v4)()}))||this;return n._clientsQueue=new E,n._topicObservers=new Map,n._clientIdObservers=new Map,n}return l(n,e),Object.defineProperty(n.prototype,"clientId",{get:function(){return this.options.clientId},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"endpoint",{get:function(){return this.options.aws_pubsub_endpoint},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"clientsQueue",{get:function(){return this._clientsQueue},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),n.prototype.getTopicForValue=function(e){return"object"===h(e)&&e[S]},n.prototype.getProviderName=function(){return"MqttOverWSProvider"},n.prototype.onDisconnect=function(e){var t=this,n=e.clientId,r=e.errorCode,o=g(e,["clientId","errorCode"]);if(0!==r){v.warn(n,JSON.stringify(p({errorCode:r},o),null,2));var i=[];if(!n)return;var s=this._clientIdObservers.get(n);if(!s)return;s.forEach((function(e){e.error("Disconnected, error code: "+r),t._topicObservers.forEach((function(t,n){t.delete(e),0===t.size&&i.push(n)}))})),this._clientIdObservers.delete(n),i.forEach((function(e){t._topicObservers.delete(e)}))}},n.prototype.newClient=function(e){var t=e.url,n=e.clientId;return d(this,void 0,void 0,(function(){var e,o=this;return y(this,(function(i){switch(i.label){case 0:return v.debug("Creating new MQTT client",n),(e=new r.Client(t,n)).onMessageArrived=function(e){var t=e.destinationName,n=e.payloadString;o._onMessage(t,n)},e.onConnectionLost=function(e){var t=e.errorCode,r=g(e,["errorCode"]);o.onDisconnect(p({clientId:n,errorCode:t},r))},[4,new Promise((function(t,n){e.connect({useSSL:o.isSSLEnabled,mqttVersion:3,onSuccess:function(){return t(e)},onFailure:n})}))];case 1:return i.sent(),[2,e]}}))}))},n.prototype.connect=function(e,t){return void 0===t&&(t={}),d(this,void 0,void 0,(function(){var n=this;return y(this,(function(r){switch(r.label){case 0:return[4,this.clientsQueue.get(e,(function(e){return n.newClient(p(p({},t),{clientId:e}))}))];case 1:return[2,r.sent()]}}))}))},n.prototype.disconnect=function(e){return d(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(e)];case 1:return(t=n.sent())&&t.isConnected()&&t.disconnect(),this.clientsQueue.remove(e),[2]}}))}))},n.prototype.publish=function(e,t){return d(this,void 0,void 0,(function(){var n,r,o,i;return y(this,(function(s){switch(s.label){case 0:return n=[].concat(e),r=JSON.stringify(t),[4,this.endpoint];case 1:return o=s.sent(),[4,this.connect(this.clientId,{url:o})];case 2:return i=s.sent(),v.debug("Publishing to topic(s)",n.join(","),r),n.forEach((function(e){return i.send(e,r)})),[2]}}))}))},n.prototype._onMessage=function(e,t){try{var n=[];this._topicObservers.forEach((function(t,r){b(r,e)&&n.push(t)}));var r=JSON.parse(t);"object"===h(r)&&(r[S]=e),n.forEach((function(e){e.forEach((function(e){return e.next(r)}))}))}catch(e){v.warn("Error handling message",e,t)}},n.prototype.subscribe=function(e,n){var r=this;void 0===n&&(n={});var o=[].concat(e);return v.debug("Subscribing to topic(s)",o.join(",")),new t((function(e){var t;o.forEach((function(t){var n=r._topicObservers.get(t);n||(n=new Set,r._topicObservers.set(t,n)),n.add(e)}));var i=n.clientId,s=void 0===i?r.clientId:i,a=r._clientIdObservers.get(s);return a||(a=new Set),a.add(e),r._clientIdObservers.set(s,a),d(r,void 0,void 0,(function(){var r,i,a,c;return y(this,(function(u){switch(u.label){case 0:return void 0!==(r=n.url)?[3,2]:[4,this.endpoint];case 1:return a=u.sent(),[3,3];case 2:a=r,u.label=3;case 3:i=a,u.label=4;case 4:return u.trys.push([4,6,,7]),[4,this.connect(s,{url:i})];case 5:return t=u.sent(),o.forEach((function(e){t.subscribe(e)})),[3,7];case 6:return c=u.sent(),e.error(c),[3,7];case 7:return[2]}}))})),function(){var n,i;return v.debug("Unsubscribing from topic(s)",o.join(",")),t&&(null===(n=r._clientIdObservers.get(s))||void 0===n||n.delete(e),0===(null===(i=r._clientIdObservers.get(s))||void 0===i?void 0:i.size)&&(r.disconnect(s),r._clientIdObservers.delete(s)),o.forEach((function(n){var o=r._topicObservers.get(n)||new Set;o.delete(e),0===o.size&&(r._topicObservers.delete(n),t.isConnected()&&t.unsubscribe(n))}))),null}}))},n}(u),O=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),I=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},T=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},R=new n.ConsoleLogger("AWSAppSyncProvider"),N=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._topicClient=new Map,t._topicAlias=new Map,t}return O(n,e),Object.defineProperty(n.prototype,"endpoint",{get:function(){throw new Error("Not supported")},enumerable:!0,configurable:!0}),n.prototype.getProviderName=function(){return"AWSAppSyncProvider"},n.prototype.publish=function(e,t,n){return I(this,void 0,void 0,(function(){return T(this,(function(e){throw new Error("Operation not supported")}))}))},n.prototype._cleanUp=function(e){var t=this;Array.from(this._topicClient.entries()).filter((function(t){return C(t,2)[1].clientId===e})).map((function(e){return C(e,1)[0]})).forEach((function(e){return t._cleanUpForTopic(e)}))},n.prototype._cleanUpForTopic=function(e){this._topicClient.delete(e),this._topicAlias.delete(e)},n.prototype.onDisconnect=function(e){var t=this,n=e.clientId,r=e.errorCode,o=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["clientId","errorCode"]);0!==r&&(Array.from(this._topicClient.entries()).filter((function(e){return C(e,2)[1].clientId===n})).map((function(e){return C(e,1)[0]})).forEach((function(e){t._topicObservers.has(e)&&(t._topicObservers.get(e).forEach((function(e){e.closed||e.error(o)})),t._topicObservers.delete(e))})),this._cleanUp(n))},n.prototype.disconnect=function(t){return I(this,void 0,void 0,(function(){return T(this,(function(n){switch(n.label){case 0:return[4,this.clientsQueue.get(t,(function(){return null}))];case 1:return n.sent(),[4,e.prototype.disconnect.call(this,t)];case 2:return n.sent(),this._cleanUp(t),[2]}}))}))},n.prototype.subscribe=function(e,n){var r=this;void 0===n&&(n={});var o=new t((function(t){var o=[].concat(e);return R.debug("Subscribing to topic(s)",o.join(",")),I(r,void 0,void 0,(function(){var e,r,i,s,a,c=this;return T(this,(function(u){switch(u.label){case 0:return o.forEach((function(e){c._topicObservers.has(e)||c._topicObservers.set(e,new Set),c._topicObservers.get(e).add(t)})),e=n.mqttConnections,r=void 0===e?[]:e,i=n.newSubscriptions,s=Object.entries(i).map((function(e){var t=C(e,2),n=t[0];return[t[1].topic,n]})),this._topicAlias=new Map(function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(C(arguments[t]));return e}(Array.from(this._topicAlias.entries()),s)),a=Object.entries(o.reduce((function(e,t){var n=r.find((function(e){return e.topics.indexOf(t)>-1}));if(n){var o=n.client,i=n.url;e[o]||(e[o]={url:i,topics:new Set}),e[o].topics.add(t)}return e}),{})),[4,Promise.all(a.map((function(e){var n=C(e,2),r=n[0],o=n[1],i=o.url,s=o.topics;return I(c,void 0,void 0,(function(){var e,n,o=this;return T(this,(function(a){switch(a.label){case 0:e=null,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.connect(r,{clientId:r,url:i})];case 2:return e=a.sent(),[3,4];case 3:return n=a.sent(),t.error({message:"Failed to connect",error:n}),t.complete(),[2,void 0];case 4:return s.forEach((function(t){e.isConnected()&&(e.subscribe(t),o._topicClient.set(t,e))})),[2,e]}}))}))})))];case 1:return u.sent(),[2]}}))})),function(){R.debug("Unsubscribing from topic(s)",o.join(",")),o.forEach((function(e){var t=r._topicClient.get(e);t&&t.isConnected()&&(t.unsubscribe(e),r._topicClient.delete(e),Array.from(r._topicClient.values()).some((function(e){return e===t}))||r.disconnect(t.clientId)),r._topicObservers.delete(e)}))}}));return t.from(o).map((function(e){var t=r.getTopicForValue(e),n=r._topicAlias.get(t);return e.data=Object.entries(e.data).reduce((function(e,t){var r=C(t,2),o=r[0],i=r[1];return e[n||o]=i,e}),{}),e}))},n}(A),M=s(957),P=s(883),k=s(834),x=s(877),U=s.n(x),L=s(648),D=s.n(L),q=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),B=function(){return(B=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},j=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},V=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},F=new n.Logger("AWSAppSyncRealTimeProvider"),G="undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("amplify_default"):"@@amplify_default",Y=[400,401,403];!function(e){e.GQL_CONNECTION_INIT="connection_init",e.GQL_CONNECTION_ERROR="connection_error",e.GQL_CONNECTION_ACK="connection_ack",e.GQL_START="start",e.GQL_START_ACK="start_ack",e.GQL_DATA="data",e.GQL_CONNECTION_KEEP_ALIVE="ka",e.GQL_STOP="stop",e.GQL_COMPLETE="complete",e.GQL_ERROR="error"}(_||(_={})),function(e){e[e.PENDING=0]="PENDING",e[e.CONNECTED=1]="CONNECTED",e[e.FAILED=2]="FAILED"}(m||(m={})),function(e){e[e.CLOSED=0]="CLOSED",e[e.READY=1]="READY",e[e.CONNECTING=2]="CONNECTING"}(w||(w={}));var Q={accept:"application/json, text/javascript","content-encoding":"amz-1.0","content-type":"application/json; charset=UTF-8"},K=/^https:\/\/\w{26}\.appsync\-api\.\w{2}(?:(?:\-\w{2,})+)\-\d\.amazonaws.com\/graphql$/i,z=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.socketStatus=w.CLOSED,t.keepAliveTimeout=3e5,t.subscriptionObserverMap=new Map,t.promiseArray=[],t}return q(r,e),r.prototype.getProviderName=function(){return"AWSAppSyncRealTimeProvider"},r.prototype.newClient=function(){throw new Error("Not used here")},r.prototype.publish=function(e,t,n){return j(this,void 0,void 0,(function(){return V(this,(function(e){throw new Error("Operation not supported")}))}))},r.prototype.isCustomDomain=function(e){return null===e.match(K)},r.prototype.subscribe=function(e,n){var r=this,i=null==n?void 0:n.appSyncGraphqlEndpoint;return new t((function(e){if(n&&i){var t=(0,o.v4)();return r._startSubscriptionWithAWSAppSyncRealTime({options:n,observer:e,subscriptionId:t}).catch((function(t){e.error({errors:[B({},new M.GraphQLError(X.REALTIME_SUBSCRIPTION_INIT_ERROR+": "+t))]}),e.complete()})),function(){return j(r,void 0,void 0,(function(){var e,n;return V(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,3,4]),[4,this._waitForSubscriptionToBeConnected(t)];case 1:if(r.sent(),!(e=(this.subscriptionObserverMap.get(t)||{}).subscriptionState))return[2];if(e!==m.CONNECTED)throw new Error("Subscription never connected");return this._sendUnsubscriptionMessage(t),[3,4];case 2:return n=r.sent(),F.debug("Error while unsubscribing "+n),[3,4];case 3:return this._removeSubscriptionObserver(t),[7];case 4:return[2]}}))}))}}e.error({errors:[B({},new M.GraphQLError("Subscribe only available for AWS AppSync endpoint"))]}),e.complete()}))},Object.defineProperty(r.prototype,"isSSLEnabled",{get:function(){return!this.options.aws_appsync_dangerously_connect_to_http_endpoint_for_testing},enumerable:!0,configurable:!0}),r.prototype._startSubscriptionWithAWSAppSyncRealTime=function(e){var t,r,o=e.options,i=e.observer,s=e.subscriptionId;return j(this,void 0,void 0,(function(){var e,a,c,u,h,f,l,p,d,y,g,v,b,w,E,S,A,O,I,T,C,R,N,P,k,x=this;return V(this,(function(U){switch(U.label){case 0:return e=o.appSyncGraphqlEndpoint,a=o.authenticationType,c=o.query,u=o.variables,h=o.apiKey,f=o.region,l=o.graphql_headers,p=void 0===l?function(){return{}}:l,d=o.additionalHeaders,y=void 0===d?{}:d,g=m.PENDING,v={query:c,variables:u},this.subscriptionObserverMap.set(s,{observer:i,query:null!=c?c:"",variables:null!=u?u:{},subscriptionState:g,startAckTimeoutId:void 0}),b=JSON.stringify(v),E=[{}],[4,this._awsRealTimeHeaderBasedAuth({apiKey:h,appSyncGraphqlEndpoint:e,authenticationType:a,payload:b,canonicalUri:"",region:f,additionalHeaders:y})];case 1:return S=[B.apply(void 0,E.concat([U.sent()]))],[4,p()];case 2:w=B.apply(void 0,[B.apply(void 0,[B.apply(void 0,S.concat([U.sent()])),y]),(k={},k[n.USER_AGENT_HEADER]=n.Constants.userAgent,k)]),A={id:s,payload:{data:b,extensions:{authorization:B({},w)}},type:_.GQL_START},O=JSON.stringify(A),U.label=3;case 3:return U.trys.push([3,5,,6]),[4,this._initializeWebSocketConnection({apiKey:h,appSyncGraphqlEndpoint:e,authenticationType:a,region:f,additionalHeaders:y})];case 4:return U.sent(),[3,6];case 5:return I=U.sent(),F.debug({err:I}),T=null!==(t=I.message)&&void 0!==t?t:"",i.error({errors:[B({},new M.GraphQLError(X.CONNECTION_FAILED+": "+T))]}),i.complete(),"function"==typeof(C=(this.subscriptionObserverMap.get(s)||{}).subscriptionFailedCallback)&&C(),[2];case 6:return R=null!==(r=this.subscriptionObserverMap.get(s))&&void 0!==r?r:{},N=R.subscriptionFailedCallback,P=R.subscriptionReadyCallback,this.subscriptionObserverMap.set(s,{observer:i,subscriptionState:g,query:null!=c?c:"",variables:null!=u?u:{},subscriptionReadyCallback:P,subscriptionFailedCallback:N,startAckTimeoutId:setTimeout((function(){x._timeoutStartSubscriptionAck.call(x,s)}),15e3)}),this.awsRealTimeSocket&&this.awsRealTimeSocket.send(O),[2]}}))}))},r.prototype._waitForSubscriptionToBeConnected=function(e){return j(this,void 0,void 0,(function(){var t,n=this;return V(this,(function(r){return(t=this.subscriptionObserverMap.get(e))&&t.subscriptionState===m.PENDING?[2,new Promise((function(r,o){var i=t.observer,s=t.subscriptionState,a=t.variables,c=t.query;n.subscriptionObserverMap.set(e,{observer:i,subscriptionState:s,variables:a,query:c,subscriptionReadyCallback:r,subscriptionFailedCallback:o})}))]:[2]}))}))},r.prototype._sendUnsubscriptionMessage=function(e){try{if(this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.socketStatus===w.READY){var t={id:e,type:_.GQL_STOP},n=JSON.stringify(t);this.awsRealTimeSocket.send(n)}}catch(e){F.debug({err:e})}},r.prototype._removeSubscriptionObserver=function(e){this.subscriptionObserverMap.delete(e),setTimeout(this._closeSocketIfRequired.bind(this),1e3)},r.prototype._closeSocketIfRequired=function(){if(!(this.subscriptionObserverMap.size>0))if(this.awsRealTimeSocket)if(this.awsRealTimeSocket.bufferedAmount>0)setTimeout(this._closeSocketIfRequired.bind(this),1e3);else{F.debug("closing WebSocket..."),this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId);var e=this.awsRealTimeSocket;e.onclose=null,e.onerror=null,e.close(1e3),this.awsRealTimeSocket=void 0,this.socketStatus=w.CLOSED}else this.socketStatus=w.CLOSED},r.prototype._handleIncomingSubscriptionMessage=function(e){F.debug("subscription message from AWS AppSync RealTime: "+e.data);var t,r,o=JSON.parse(e.data),i=o.id,s=void 0===i?"":i,a=o.payload,c=o.type,u=this.subscriptionObserverMap.get(s)||{},h=u.observer,f=void 0===h?null:h,l=u.query,p=void 0===l?"":l,d=u.variables,y=void 0===d?{}:d,g=u.startAckTimeoutId,v=u.subscriptionReadyCallback,b=u.subscriptionFailedCallback;if(F.debug({id:s,observer:f,query:p,variables:y}),c===_.GQL_DATA&&a&&a.data)f?f.next(a):F.debug("observer not found for id: "+s);else if(c!==_.GQL_START_ACK){if(c===_.GQL_CONNECTION_KEEP_ALIVE)return this.keepAliveTimeoutId&&clearTimeout(this.keepAliveTimeoutId),void(this.keepAliveTimeoutId=setTimeout(this._errorDisconnect.bind(this,X.TIMEOUT_DISCONNECT),this.keepAliveTimeout));c===_.GQL_ERROR&&(w=m.FAILED,f&&(this.subscriptionObserverMap.set(s,{observer:f,query:p,variables:y,startAckTimeoutId:g,subscriptionReadyCallback:v,subscriptionFailedCallback:b,subscriptionState:w}),f.error({errors:[B({},new M.GraphQLError(X.CONNECTION_FAILED+": "+JSON.stringify(a)))]}),g&&clearTimeout(g),f.complete(),"function"==typeof b&&b()))}else{F.debug("subscription ready for "+JSON.stringify({query:p,variables:y})),"function"==typeof v&&v(),g&&clearTimeout(g),t=X.SUBSCRIPTION_ACK,r={query:p,variables:y},n.Hub.dispatch("api",{event:t,data:r,message:"Connection established for subscription"},"PubSub",G);var w=m.CONNECTED;f&&this.subscriptionObserverMap.set(s,{observer:f,query:p,variables:y,startAckTimeoutId:void 0,subscriptionState:w,subscriptionReadyCallback:v,subscriptionFailedCallback:b})}},r.prototype._errorDisconnect=function(e){F.debug("Disconnect error: "+e),this.subscriptionObserverMap.forEach((function(t){var n=t.observer;n&&!n.closed&&n.error({errors:[B({},new M.GraphQLError(e))]})})),this.subscriptionObserverMap.clear(),this.awsRealTimeSocket&&this.awsRealTimeSocket.close(),this.socketStatus=w.CLOSED},r.prototype._timeoutStartSubscriptionAck=function(e){var t=this.subscriptionObserverMap.get(e);if(t){var n=t.observer,r=t.query,o=t.variables;if(!n)return;this.subscriptionObserverMap.set(e,{observer:n,query:r,variables:o,subscriptionState:m.FAILED}),n&&!n.closed&&(n.error({errors:[B({},new M.GraphQLError("Subscription timeout "+JSON.stringify({query:r,variables:o})))]}),n.complete()),F.debug("timeoutStartSubscription",JSON.stringify({query:r,variables:o}))}},r.prototype._initializeWebSocketConnection=function(e){var t=this,n=e.appSyncGraphqlEndpoint,r=e.authenticationType,o=e.apiKey,i=e.region,s=e.additionalHeaders;if(this.socketStatus!==w.READY)return new Promise((function(e,a){return j(t,void 0,void 0,(function(){var t,c,u,h,f,l,p,d,y,g;return V(this,(function(v){switch(v.label){case 0:if(this.promiseArray.push({res:e,rej:a}),this.socketStatus!==w.CLOSED)return[3,5];v.label=1;case 1:return v.trys.push([1,4,,5]),this.socketStatus=w.CONNECTING,t="{}",h=(u=JSON).stringify,[4,this._awsRealTimeHeaderBasedAuth({authenticationType:r,payload:t,canonicalUri:"/connect",apiKey:o,appSyncGraphqlEndpoint:n,region:i,additionalHeaders:s})];case 2:return c=h.apply(u,[v.sent()]),f=k.lW.from(c).toString("base64"),l=k.lW.from(t).toString("base64"),p=null!=n?n:"",p=this.isCustomDomain(p)?p.concat("/realtime"):p.replace("appsync-api","appsync-realtime-api").replace("gogi-beta","grt-beta"),d=this.isSSLEnabled?"wss://":"ws://",p=p.replace("https://",d).replace("http://",d),y=p+"?header="+f+"&payload="+l,[4,this._initializeRetryableHandshake(y)];case 3:return v.sent(),this.promiseArray.forEach((function(e){var t=e.res;F.debug("Notifying connection successful"),t()})),this.socketStatus=w.READY,this.promiseArray=[],[3,5];case 4:return g=v.sent(),this.promiseArray.forEach((function(e){return(0,e.rej)(g)})),this.promiseArray=[],this.awsRealTimeSocket&&this.awsRealTimeSocket.readyState===WebSocket.OPEN&&this.awsRealTimeSocket.close(3001),this.awsRealTimeSocket=void 0,this.socketStatus=w.CLOSED,[3,5];case 5:return[2]}}))}))}))},r.prototype._initializeRetryableHandshake=function(e){return j(this,void 0,void 0,(function(){return V(this,(function(t){switch(t.label){case 0:return F.debug("Initializaling retryable Handshake"),[4,(0,n.jitteredExponentialRetry)(this._initializeHandshake.bind(this),[e],5e3)];case 1:return t.sent(),[2]}}))}))},r.prototype._initializeHandshake=function(e){return j(this,void 0,void 0,(function(){var t,r,o,i,s=this;return V(this,(function(a){switch(a.label){case 0:F.debug("Initializing handshake "+e),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,new Promise((function(t,n){var r=new WebSocket(e,"graphql-ws");r.onerror=function(){F.debug("WebSocket connection error")},r.onclose=function(){n(new Error("Connection handshake error"))},r.onopen=function(){return s.awsRealTimeSocket=r,t()}}))];case 2:return a.sent(),[4,new Promise((function(e,t){if(s.awsRealTimeSocket){var n=!1;s.awsRealTimeSocket.onerror=function(e){F.debug("WebSocket error "+JSON.stringify(e))},s.awsRealTimeSocket.onclose=function(e){F.debug("WebSocket closed "+e.reason),t(new Error(JSON.stringify(e)))},s.awsRealTimeSocket.onmessage=function(r){F.debug("subscription message from AWS AppSyncRealTime: "+r.data+" ");var o=JSON.parse(r.data),i=o.type,a=o.payload,c=(void 0===a?{}:a).connectionTimeoutMs,u=void 0===c?3e5:c;if(i===_.GQL_CONNECTION_ACK)return n=!0,s.awsRealTimeSocket&&(s.keepAliveTimeout=u,s.awsRealTimeSocket.onmessage=s._handleIncomingSubscriptionMessage.bind(s),s.awsRealTimeSocket.onerror=function(e){F.debug(e),s._errorDisconnect(X.CONNECTION_CLOSED)},s.awsRealTimeSocket.onclose=function(e){F.debug("WebSocket closed "+e.reason),s._errorDisconnect(X.CONNECTION_CLOSED)}),void e("Cool, connected to AWS AppSyncRealTime");if(i===_.GQL_CONNECTION_ERROR){var h=o.payload,f=(void 0===h?{}:h).errors,l=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(void 0===f?[]:f,1)[0],p=void 0===l?{}:l,d=p.errorType,y=void 0===d?"":d,g=p.errorCode;t({errorType:y,errorCode:void 0===g?0:g})}};var r={type:_.GQL_CONNECTION_INIT};s.awsRealTimeSocket.send(JSON.stringify(r)),setTimeout(function(e){e||t(new Error("Connection timeout: ack from AWSRealTime was not received on 15000 ms"))}.bind(s,n),15e3)}}))];case 3:return a.sent(),[3,5];case 4:throw t=a.sent(),o=(r=t).errorType,i=r.errorCode,Y.includes(i)?new n.NonRetryableError(o):o?new Error(o):t;case 5:return[2]}}))}))},r.prototype._awsRealTimeHeaderBasedAuth=function(e){var t=e.authenticationType,n=e.payload,r=e.canonicalUri,o=e.appSyncGraphqlEndpoint,i=e.apiKey,s=e.region,a=e.additionalHeaders;return j(this,void 0,void 0,(function(){var e,c,u;return V(this,(function(h){switch(h.label){case 0:return e={API_KEY:this._awsRealTimeApiKeyHeader.bind(this),AWS_IAM:this._awsRealTimeIAMHeader.bind(this),OPENID_CONNECT:this._awsRealTimeOPENIDHeader.bind(this),AMAZON_COGNITO_USER_POOLS:this._awsRealTimeCUPHeader.bind(this),AWS_LAMBDA:this._customAuthHeader},t&&e[t]?[3,1]:(F.debug("Authentication type "+t+" not supported"),[2,""]);case 1:return c=e[t],u=P.Qc(null!=o?o:"").host,[4,c({payload:n,canonicalUri:r,appSyncGraphqlEndpoint:o,apiKey:i,region:s,host:u,additionalHeaders:a})];case 2:return[2,h.sent()]}}))}))},r.prototype._awsRealTimeCUPHeader=function(e){var t=e.host;return j(this,void 0,void 0,(function(){return V(this,(function(e){switch(e.label){case 0:return[4,D().currentSession()];case 1:return[2,{Authorization:e.sent().getAccessToken().getJwtToken(),host:t}]}}))}))},r.prototype._awsRealTimeOPENIDHeader=function(e){var t=e.host;return j(this,void 0,void 0,(function(){var e,n,r;return V(this,(function(o){switch(o.label){case 0:return[4,U().getItem("federatedInfo")];case 1:return(n=o.sent())?(e=n.token,[3,4]):[3,2];case 2:return[4,D().currentAuthenticatedUser()];case 3:(r=o.sent())&&(e=r.token),o.label=4;case 4:if(!e)throw new Error("No federated jwt");return[2,{Authorization:e,host:t}]}}))}))},r.prototype._awsRealTimeApiKeyHeader=function(e){var t=e.apiKey,n=e.host;return j(this,void 0,void 0,(function(){var e,r;return V(this,(function(o){return e=new Date,r=e.toISOString().replace(/[:\-]|\.\d{3}/g,""),[2,{host:n,"x-amz-date":r,"x-api-key":t}]}))}))},r.prototype._awsRealTimeIAMHeader=function(e){var t=e.payload,r=e.canonicalUri,o=e.appSyncGraphqlEndpoint,i=e.region;return j(this,void 0,void 0,(function(){var e,s,a;return V(this,(function(c){switch(c.label){case 0:return e={region:i,service:"appsync"},[4,this._ensureCredentials()];case 1:if(!c.sent())throw new Error("No credentials");return[4,n.Credentials.get().then((function(e){var t=e;return{secret_key:t.secretAccessKey,access_key:t.accessKeyId,session_token:t.sessionToken}}))];case 2:return s=c.sent(),a={url:""+o+r,data:t,method:"POST",headers:B({},Q)},[2,n.Signer.sign(a,s,e).headers]}}))}))},r.prototype._customAuthHeader=function(e){var t=e.host,n=e.additionalHeaders;if(!n||!n.Authorization)throw new Error("No auth token specified");return{Authorization:n.Authorization,host:t}},r.prototype._ensureCredentials=function(){return n.Credentials.get().then((function(e){if(!e)return!1;var t=n.Credentials.shear(e);return F.debug("set credentials for AWSAppSyncRealTimeProvider",t),!0})).catch((function(e){return F.warn("ensure credentials error",e),!1}))},r}(u),W=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},J=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},H=(0,n.browserOrNode)().isNode,$=new n.ConsoleLogger("PubSub"),Z=new(function(){function e(e){this._options=null!=e?e:{},$.debug("PubSub Options",this._options),this._pluggables=[],this.subscribe=this.subscribe.bind(this)}return Object.defineProperty(e.prototype,"awsAppSyncProvider",{get:function(){return this._awsAppSyncProvider||(this._awsAppSyncProvider=new N(this._options)),this._awsAppSyncProvider},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"awsAppSyncRealTimeProvider",{get:function(){return this._awsAppSyncRealTimeProvider||(this._awsAppSyncRealTimeProvider=new z(this._options)),this._awsAppSyncRealTimeProvider},enumerable:!0,configurable:!0}),e.prototype.getModuleName=function(){return"PubSub"},e.prototype.configure=function(e){var t=this,n=e?e.PubSub||e:{};return $.debug("configure PubSub",{opt:n}),this._options=Object.assign({},this._options,n),this._pluggables.map((function(e){return e.configure(t._options)})),this._options},e.prototype.addPluggable=function(e){return W(this,void 0,void 0,(function(){return J(this,(function(t){return e&&"PubSub"===e.getCategory()?(this._pluggables.push(e),[2,e.configure(this._options)]):[2]}))}))},e.prototype.removePluggable=function(e){this._pluggables=this._pluggables.filter((function(t){return t.getProviderName()!==e}))},e.prototype.getProviderByName=function(e){return e===n.INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER?this.awsAppSyncProvider:e===n.INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER?this.awsAppSyncRealTimeProvider:this._pluggables.find((function(t){return t.getProviderName()===e}))},e.prototype.getProviders=function(e){void 0===e&&(e={});var t=e.provider;if(!t)return this._pluggables;var n=this.getProviderByName(t);if(!n)throw new Error("Could not find provider named "+t);return[n]},e.prototype.publish=function(e,t,n){return W(this,void 0,void 0,(function(){return J(this,(function(r){return[2,Promise.all(this.getProviders(n).map((function(r){return r.publish(e,t,n)})))]}))}))},e.prototype.subscribe=function(e,n){if(H&&this._options&&this._options.ssr)throw new Error("Subscriptions are not supported for Server-Side Rendering (SSR)");$.debug("subscribe options",n);var r=this.getProviders(n);return new t((function(t){var o=r.map((function(t){return{provider:t,observable:t.subscribe(e,n)}})).map((function(e){var n=e.provider;return e.observable.subscribe({start:console.error,next:function(e){return t.next({provider:n,value:e})},error:function(e){return t.error({provider:n,error:e})}})}));return function(){return o.forEach((function(e){return e.unsubscribe()}))}}))},e}());n.Amplify.register(Z);var X,ee=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),te=function(e){function t(t){return void 0===t&&(t={}),e.call(this,t)||this}return ee(t,e),Object.defineProperty(t.prototype,"region",{get:function(){return this.options.aws_pubsub_region},enumerable:!0,configurable:!0}),t.prototype.getProviderName=function(){return"AWSIoTProvider"},Object.defineProperty(t.prototype,"endpoint",{get:function(){return e=this,t=void 0,o=function(){var e,t,r,o,i,s;return function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(a){switch(a.label){case 0:return e=this.options.aws_pubsub_endpoint,t={service:"iotdevicegateway",region:this.region},[4,n.Credentials.get()];case 1:return r=a.sent(),o=r.accessKeyId,i=r.secretAccessKey,s=r.sessionToken,[2,n.Signer.signUrl(e,{access_key:o,secret_key:i,session_token:s},t)]}}))},new((r=void 0)||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}));var e,t,r,o},enumerable:!0,configurable:!0}),t}(A);!function(e){e.CONNECTION_CLOSED="Connection closed",e.CONNECTION_FAILED="Connection failed",e.REALTIME_SUBSCRIPTION_INIT_ERROR="AppSync Realtime subscription init error",e.SUBSCRIPTION_ACK="Subscription ack",e.TIMEOUT_DISCONNECT="Timeout disconnect"}(X||(X={}));const ne=Z})(),a})());
11
3
  //# sourceMappingURL=aws-amplify-pubsub.min.js.map