From f3a8a61dc56d51f2cde39afbe5f9a2ecbab3b9d9 Mon Sep 17 00:00:00 2001 From: chabokci Date: Wed, 6 Mar 2019 23:29:07 +0330 Subject: [PATCH] 1.2.2 --- dist/ChabokSDKWorker.js | 2 +- dist/chabokpush.min.js | 4 ++-- package.json | 2 +- sample/index.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/ChabokSDKWorker.js b/dist/ChabokSDKWorker.js index b7913af..2aacc67 100644 --- a/dist/ChabokSDKWorker.js +++ b/dist/ChabokSDKWorker.js @@ -1,3 +1,3 @@ -/*! chabokpush - 1.2.1 | (c) 2017, 2019 ADP digital | ISC | http://chabokpush.com/ */ +/*! chabokpush - 1.2.2 | (c) 2017, 2019 ADP digital | ISC | http://chabokpush.com/ */ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("chabokpush",[],n):"object"==typeof exports?exports.chabokpush=n():t.chabokpush=n()}("undefined"!=typeof self?self:this,function(){return function(t){function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=168)}({168:function(t,n,e){"use strict";self.addEventListener("push",function(t){if(console.log("self",self),t.data.json()){var n=t.data.json();n.silent||(n.clickUrl&&(n.data=n.data||{},n.data.clickUrl=n.clickUrl),t.waitUntil(self.registration.showNotification(n.title,n)))}}),self.addEventListener("pushsubscriptionchange",function(t){var n=t.oldSubscription.options;t.waitUntil(self.registration.pushManager.subscribe(n).then(function(t){}))}),self.addEventListener("notificationclick",function(t){var n="/";t&&t.notification&&t.notification.data&&t.notification.data.clickUrl&&(n=t.notification.data.clickUrl),t.notification.close(),t.waitUntil(self.clients.matchAll({type:"window"}).then(function(t){for(var e=0;e1)for(var n=1;n0&&u.length>s&&!u.warned){u.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=u.length,r(c)}return t}function a(){for(var t=[],e=0;e0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)b(a,this,e);else for(var u=a.length,c=f(a,u),n=0;n=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():h(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r=0;r--)this.removeListener(t,e[r]);return this},i.prototype.listeners=function(t){return c(this,t,!0)},i.prototype.rawListeners=function(t){return c(this,t,!1)},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):l.call(t,e)},i.prototype.listenerCount=l,i.prototype.eventNames=function(){return this._eventsCount>0?d(this._events):[]}},function(t,e,n){"use strict";function r(t){if(!(this instanceof r))return new r(t);c.call(this,t),l.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||s.nextTick(o,this)}function o(t){t.end()}var s=n(12),a=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=r;var u=n(13);u.inherits=n(5);var c=n(34),l=n(38);u.inherits(r,c);for(var f=a(l.prototype),h=0;h0;)r=d.nextValue(),t=Math.floor(r*e.length),n.push(e.splice(t,1)[0]);return n.join("")}function u(){return p||(p=a())}function c(t){return u()[t]}function l(){return f||g}var f,h,p,d=n(160),g="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";t.exports={get:l,characters:o,seed:s,lookup:c,shuffled:u}},function(t,e,n){"use strict";t.exports=n(59)()?Object.assign:n(60)},function(t,e,n){"use strict";(function(e){function r(t,e){!i.isUndefined(t)&&i.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var i=n(1),o=n(73),s={"Content-Type":"application/x-www-form-urlencoded"},a={adapter:function(){var t;return"undefined"!=typeof XMLHttpRequest?t=n(29):void 0!==e&&(t=n(29)),t}(),transformRequest:[function(t,e){return o(e,"Content-Type"),i.isFormData(t)||i.isArrayBuffer(t)||i.isBuffer(t)||i.isStream(t)||i.isFile(t)||i.isBlob(t)?t:i.isArrayBufferView(t)?t.buffer:i.isURLSearchParams(t)?(r(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):i.isObject(t)?(r(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(t){a.headers[t]={}}),i.forEach(["post","put","patch"],function(t){a.headers[t]=i.merge(s)}),t.exports=a}).call(e,n(0))},function(t,e){function n(){for(var t={},e=0;e=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),o.alloc(+t)}function b(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return H(t).length;e=(""+e).toLowerCase(),r=!0}}function y(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return j(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return P(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function m(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:_(t,e,n,r,i);if("number"==typeof e)return e&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):_(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function _(t,e,n,r,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}var c;if(i){var l=-1;for(c=n;ca&&(n=a-u),c=n;c>=0;c--){for(var f=!0,h=0;hi&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=n){var u,c,l,f;switch(a){case 1:o<128&&(s=o);break;case 2:u=t[i+1],128==(192&u)&&(f=(31&o)<<6|63&u)>127&&(s=f);break;case 3:u=t[i+1],c=t[i+2],128==(192&u)&&128==(192&c)&&(f=(15&o)<<12|(63&u)<<6|63&c)>2047&&(f<55296||f>57343)&&(s=f);break;case 4:u=t[i+1],c=t[i+2],l=t[i+3],128==(192&u)&&128==(192&c)&&128==(192&l)&&(f=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&l)>65535&&f<1114112&&(s=f)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return A(r)}function A(t){var e=t.length;if(e<=Z)return String.fromCharCode.apply(String,t);for(var n="",r=0;rr)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,s){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function L(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function U(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function B(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(t,e,n,r,i){return i||B(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,n,r,23,4),n+4}function q(t,e,n,r,i){return i||B(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,n,r,52,8),n+8}function F(t){if(t=W(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function K(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,e){e=e||1/0;for(var n,r=t.length,i=null,o=[],s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function z(t){for(var e=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function G(t){return X.toByteArray(F(t))}function V(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function $(t){return t!==t}/*! * The buffer module from node.js, for the browser. * @@ -11,5 +11,5 @@ var X=n(90),J=n(91),Q=n(35);e.Buffer=o,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,o.T * @author Feross Aboukhadijeh * @license MIT */ -t.exports=function(t){return null!=t&&(n(t)||r(t)||!!t._isBuffer)}},function(t,e,n){"use strict";function r(t){this.defaults=t,this.interceptors={request:new s,response:new s}}var i=n(20),o=n(1),s=n(81),a=n(82);r.prototype.request=function(t){"string"==typeof t&&(t=o.merge({url:arguments[0]},arguments[1])),t=o.merge(i,this.defaults,{method:"get"},t),t.method=t.method.toLowerCase();var e=[a,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},o.forEach(["delete","get","head","options"],function(t){r.prototype[t]=function(e,n){return this.request(o.merge(n||{},{method:t,url:e}))}}),o.forEach(["post","put","patch"],function(t){r.prototype[t]=function(e,n,r){return this.request(o.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=r},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";var r=n(30);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},function(t,e,n){"use strict";t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t}},function(t,e,n){"use strict";function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(1);t.exports=function(t,e,n){if(!e)return t;var o;if(n)o=n(e);else if(i.isURLSearchParams(e))o=e.toString();else{var s=[];i.forEach(e,function(t,e){null!==t&&void 0!==t&&(i.isArray(t)&&(e+="[]"),i.isArray(t)||(t=[t]),i.forEach(t,function(t){i.isDate(t)?t=t.toISOString():i.isObject(t)&&(t=JSON.stringify(t)),s.push(r(e)+"="+r(t))}))}),o=s.join("&")}return o&&(t+=(-1===t.indexOf("?")?"?":"&")+o),t}},function(t,e,n){"use strict";var r=n(1),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,o,s={};return t?(r.forEach(t.split("\n"),function(t){if(o=t.indexOf(":"),e=r.trim(t.substr(0,o)).toLowerCase(),n=r.trim(t.substr(o+1)),e){if(s[e]&&i.indexOf(e)>=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([n]):s[e]?s[e]+", "+n:n}}),s):s}},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return e=t(window.location.href),function(n){var i=r.isString(n)?t(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return function(){return!0}}()},function(t,e,n){"use strict";function r(){this.message="String contains an invalid character"}function i(t){for(var e,n,i=String(t),s="",a=0,u=o;i.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new r;e=e<<8|n}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",t.exports=i},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,i,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e,n){"use strict";function r(){this.handlers=[]}var i=n(1);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){"use strict";function r(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var i=n(1),o=n(83),s=n(31),a=n(20),u=n(84),c=n(85);t.exports=function(t){return r(t),t.baseURL&&!u(t.url)&&(t.url=c(t.baseURL,t.url)),t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),i.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||a.adapter)(t).then(function(e){return r(t),e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(r(t),e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,n){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,n){"use strict";function r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var n=this;t(function(t){n.reason||(n.reason=new i(t),e(n.reason))})}var i=n(32);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var t;return{token:new r(function(e){t=e}),cancel:t}},t.exports=r},function(t,e,n){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,n){"use strict";(function(e){function r(t){var e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function i(t,e){function n(t){return e.servers&&(t._reconnectCount&&t._reconnectCount!==e.servers.length||(t._reconnectCount=0),e.host=e.servers[t._reconnectCount].host,e.port=e.servers[t._reconnectCount].port,e.protocol=e.servers[t._reconnectCount].protocol?e.servers[t._reconnectCount].protocol:e.defaultProtocol,e.hostname=e.host,t._reconnectCount++),c[e.protocol](t,e)}if("object"!=typeof t||e||(e=t,t=null),e=e||{},t){var i=a.parse(t,!0);if(null!=i.port&&(i.port=Number(i.port)),e=u(i,e),null===e.protocol)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(r(e),e.query&&"string"==typeof e.query.clientId&&(e.clientId=e.query.clientId),e.cert&&e.key){if(!e.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs"].indexOf(e.protocol))switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}if(!c[e.protocol]){var s=-1!==["mqtts","wss"].indexOf(e.protocol);e.protocol=["mqtt","mqtts","ws","wss","wx","wxs"].filter(function(t,e){return(!s||e%2!=0)&&"function"==typeof c[t]})[0]}if(!1===e.clean&&!e.clientId)throw new Error("Missing clientId for unclean clients");return e.protocol&&(e.defaultProtocol=e.protocol),new o(n,e)}var o=n(89),s=n(33),a=n(49),u=n(21),c={};"browser"!==e.title?(c.mqtt=n(51),c.tcp=n(51),c.ssl=n(24),c.tls=n(24),c.mqtts=n(24)):(c.wx=n(52),c.wxs=n(52)),c.ws=n(54),c.wss=n(54),t.exports=i,t.exports.connect=i,t.exports.MqttClient=o,t.exports.Store=s}).call(e,n(0))},function(t,e,n){"use strict";(function(e,r){function i(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function o(t,e,n){t.emit("packetsend",e),!p.writeToStream(e,t.stream)&&n?t.stream.once("drain",n):n&&n()}function s(t){t&&Object.keys(t).forEach(function(e){"function"==typeof t[e]&&(t[e](new Error("Connection closed")),delete t[e])})}function a(t,e,n){t.outgoingStore.put(e,function(r){if(r)return n&&n(r);o(t,e,n)})}function u(){}function c(t,e){var n,r=this;if(!(this instanceof c))return new c(t,e);this.options=e||{};for(n in _)void 0===this.options[n]?this.options[n]=_[n]:this.options[n]=e[n];this.options.clientId="string"==typeof this.options.clientId?this.options.clientId:i(),this.streamBuilder=t,this.outgoingStore=this.options.outgoingStore||new f,this.incomingStore=this.options.incomingStore||new f,this.queueQoSZero=void 0===this.options.queueQoSZero||this.options.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this.on("connect",function(){function t(){n.destroy(),n=null}function e(){if(n){var t,i=n.read(1);if(!i)return void n.once("readable",e);r.disconnecting||r.reconnectTimer?n.destroy&&n.destroy():(t=r.outgoing[i.messageId],r.outgoing[i.messageId]=function(n,r){t&&t(n,r),e()},r._sendPacket(i))}}if(!this.disconnected){this.connected=!0;var n=this.outgoingStore.createStream();this.once("close",t),n.on("end",function(){r.removeListener("close",t)}),n.on("error",function(e){r.removeListener("close",t),r.emit("error",e)}),e()}}),this.on("close",function(){this.connected=!1,clearTimeout(this.connackTimer)}),this.on("connect",this._setupPingTimer),this.on("connect",function(){function t(){var n=e.shift(),i=null;n&&(i=n.packet,r._sendPacket(i,function(e){n.cb&&n.cb(e),t()}))}var e=this.queue;t()});var o=!0;this.on("connect",function(){!o&&this.options.clean&&Object.keys(this._resubscribeTopics).length>0&&(this.options.resubscribe?(this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics)):this._resubscribeTopics={}),o=!1}),this.on("close",function(){null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null)}),this.on("close",this._setupReconnect),l.EventEmitter.call(this),this._setupStream()}var l=n(9),f=n(33),h=n(46),p=n(133),d=n(14).Writable,g=n(5),b=n(142),y=n(143),v=n(21),m=e.setImmediate||function(t){r.nextTick(t)},_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0};g(c,l.EventEmitter),c.prototype._setupStream=function(){function t(){r.nextTick(e)}function e(){var e=l.shift(),n=c;e?i._handlePacket(e,t):(c=null,n())}var n,i=this,s=new d,a=p.parser(this.options),c=null,l=[];this._clearReconnect(),this.stream=this.streamBuilder(this),a.on("packet",function(t){l.push(t)}),s._write=function(t,n,r){c=r,a.parse(t),e()},this.stream.pipe(s),this.stream.on("error",u),h(this.stream,this.emit.bind(this,"close")),n=Object.create(this.options),n.cmd="connect",o(this,n),a.on("error",this.emit.bind(this,"error")),this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){i._cleanUp(!0)},this.options.connectTimeout)},c.prototype._handlePacket=function(t,e){switch(this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"pingresp":this._handlePingresp(t),e()}},c.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},c.prototype.publish=function(t,e,n,r){var i;if("function"==typeof n&&(r=n,n=null),n=v({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(i={cmd:"publish",topic:t,payload:e,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},n.qos){case 1:case 2:this.outgoing[i.messageId]=r||u,this._sendPacket(i);break;default:this._sendPacket(i,r)}return this},c.prototype.subscribe=function(){var t,e,n=Array.prototype.slice.call(arguments),r=[],i=n.shift(),o=i.resubscribe,s=n.pop()||u,a=n.pop(),c=this;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof s&&(a=s,s=u),null!==(e=y.validateTopics(i)))return m(s,new Error("Invalid topic "+e)),this;if(this._checkDisconnecting(s))return this;if(a=v({qos:0},a),Array.isArray(i)?i.forEach(function(t){(c._resubscribeTopics[t]0&&(c._resubscribeTopics[t.topic]=t.qos,l.push(t.topic))}),c.messageIdToTopic[t.messageId]=l}return this.outgoing[t.messageId]=function(t,e){if(!t)for(var n=e.granted,i=0;i0?this.once("outgoingEmpty",setTimeout.bind(null,r,10)):r(),this)},c.prototype.removeOutgoingMessage=function(t){var e=this.outgoing[t];return delete this.outgoing[t],this.outgoingStore.del({messageId:t},function(){e(new Error("Message removed"))}),this},c.prototype.reconnect=function(t){var e=this,n=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new f,e.outgoingStore=e.options.outgoingStore||new f,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},c.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},c.prototype._setupReconnect=function(){var t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),t.reconnectTimer=setInterval(function(){t._reconnect()},t.options.reconnectPeriod))},c.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},c.prototype._cleanUp=function(t,e){e&&this.stream.on("close",e),t?(0===this.options.reconnectPeriod&&this.options.clean&&s(this.outgoing),this.stream.destroy()):this._sendPacket({cmd:"disconnect"},m.bind(null,this.stream.end.bind(this.stream))),this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null),e&&!this.connected&&(this.stream.removeListener("close",e),e())},c.prototype._sendPacket=function(t,e){if(!this.connected)return void(0===(t.qos||0)&&this.queueQoSZero||"publish"!==t.cmd?this.queue.push({packet:t,cb:e}):t.qos>0?(e=this.outgoing[t.messageId],this.outgoingStore.put(t,function(t){if(t)return e&&e(t)})):e&&e(new Error("No connection to broker")));switch(this._shiftPingInterval(),t.cmd){case"publish":break;case"pubrel":return void a(this,t,e);default:return void o(this,t,e)}switch(t.qos){case 2:case 1:a(this,t,e);break;case 0:default:o(this,t,e)}},c.prototype._setupPingTimer=function(){var t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=b(function(){t._checkPing()},1e3*this.options.keepalive))},c.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},c.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},c.prototype._handlePingresp=function(){this.pingResp=!0},c.prototype._handleConnack=function(t){var e=t.returnCode,n=["","Unacceptable protocol version","Identifier rejected","Server unavailable","Bad username or password","Not authorized"];if(clearTimeout(this.connackTimer),0===e)this.reconnecting=!1,this.emit("connect",t);else if(e>0){var r=new Error("Connection refused: "+n[e]);r.code=e,this.emit("error",r)}},c.prototype._handlePublish=function(t,e){e=void 0!==e?e:u;var n=t.topic.toString(),r=t.payload,i=t.qos,o=t.messageId,s=this;switch(i){case 2:this.incomingStore.put(t,function(t){if(t)return e(t);s._sendPacket({cmd:"pubrec",messageId:o},e)});break;case 1:this.emit("message",n,r,t),this.handleMessage(t,function(t){if(t)return e(t);s._sendPacket({cmd:"puback",messageId:o},e)});break;case 0:this.emit("message",n,r,t),this.handleMessage(t,e)}},c.prototype.handleMessage=function(t,e){e()},c.prototype._handleAck=function(t){var e=t.messageId,n=t.cmd,r=null,i=this.outgoing[e],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[e],this.outgoingStore.del(t,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:e},this._sendPacket(r);break;case"suback":if(delete this.outgoing[e],1===t.granted.length&&0!=(128&t.granted[0])){var s=this.messageIdToTopic[e];s&&s.forEach(function(t){delete o._resubscribeTopics[t]})}i(null,t);break;case"unsuback":delete this.outgoing[e],i(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}},c.prototype._handlePubrel=function(t,e){e=void 0!==e?e:u;var n=t.messageId,r=this,i={cmd:"pubcomp",messageId:n};r.incomingStore.get(t,function(n,o){n||"pubrel"===o.cmd?r._sendPacket(i,e):(r.emit("message",o.topic,o.payload,o),r.incomingStore.put(t,function(t){if(t)return e(t);r.handleMessage(o,function(t){if(t)return e(t);r._sendPacket(i,e)})}))})},c.prototype._nextId=function(){var t=this.nextId++;return 65536===this.nextId&&(this.nextId=1),t},c.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},t.exports=c}).call(e,n(3),n(0))},function(t,e,n){"use strict";function r(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function i(t){var e=r(t),n=e[0],i=e[1];return 3*(n+i)/4-i}function o(t,e,n){return 3*(e+n)/4-n}function s(t){for(var e,n=r(t),i=n[0],s=n[1],a=new h(o(t,i,s)),u=0,c=s>0?i-4:i,l=0;l>16&255,a[u++]=e>>8&255,a[u++]=255&e;return 2===s&&(e=f[t.charCodeAt(l)]<<2|f[t.charCodeAt(l+1)]>>4,a[u++]=255&e),1===s&&(e=f[t.charCodeAt(l)]<<10|f[t.charCodeAt(l+1)]<<4|f[t.charCodeAt(l+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e),a}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function u(t,e,n){for(var r,i=[],o=e;os?s:o+16383));return 1===r?(e=t[n-1],i.push(l[e>>2]+l[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],i.push(l[e>>10]+l[e>>4&63]+l[e<<2&63]+"=")),i.join("")}e.byteLength=i,e.toByteArray=s,e.fromByteArray=c;for(var l=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,g=p.length;d>1,l=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+f>=1?h/u:h*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},function(t,e){},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){t.copy(e,n)}var o=n(4).Buffer,s=n(94);t.exports=function(){function t(){r(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var e=o.allocUnsafe(t>>>0),n=this.head,r=0;n;)i(n.data,e,r),r+=n.data.length,n=n.next;return e},t}(),s&&s.inspect&&s.inspect.custom&&(t.exports.prototype[s.inspect.custom]=function(){var t=s.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(t){function r(t,e){this._id=t,this._clearFn=e}var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;e.setTimeout=function(){return new r(o.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new r(o.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(96),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,n(3))},function(t,e,n){(function(t,e){!function(t,n){"use strict";function r(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=0?c(l):i(this.length)-c(u(l)),e=l;e0?1:-1}},function(t,e,n){"use strict";var r=n(11),i={function:!0,object:!0};t.exports=function(t){return r(t)&&i[typeof t]||!1}},function(t,e,n){"use strict";var r,i=Object.create;n(43)()||(r=n(44)),t.exports=function(){var t,e,n;return r?1!==r.level?i:(t={},e={},n={configurable:!1,enumerable:!1,writable:!0,value:void 0},Object.getOwnPropertyNames(Object.prototype).forEach(function(t){if("__proto__"===t)return void(e[t]={configurable:!0,enumerable:!1,writable:!0,value:void 0});e[t]=n}),Object.defineProperties(t,e),Object.defineProperty(r,"nullPolyfill",{configurable:!1,enumerable:!1,writable:!1,value:t}),function(e,n){return i(null===e?t:e,n)}):i}()},function(t,e,n){"use strict";var r,i,o,s,a,u,c,l=n(8),f=n(7),h=Function.prototype.apply,p=Function.prototype.call,d=Object.create,g=Object.defineProperty,b=Object.defineProperties,y=Object.prototype.hasOwnProperty,v={configurable:!0,enumerable:!1,writable:!0};r=function(t,e){var n;return f(e),y.call(this,"__ee__")?n=this.__ee__:(n=v.value=d(null),g(this,"__ee__",v),v.value=null),n[t]?"object"==typeof n[t]?n[t].push(e):n[t]=[n[t],e]:n[t]=e,this},i=function(t,e){var n,i;return f(e),i=this,r.call(this,t,n=function(){o.call(i,t,n),h.call(e,this,arguments)}),n.__eeOnceListener__=e,this},o=function(t,e){var n,r,i,o;if(f(e),!y.call(this,"__ee__"))return this;if(n=this.__ee__,!n[t])return this;if("object"==typeof(r=n[t]))for(o=0;i=r[o];++o)i!==e&&i.__eeOnceListener__!==e||(2===r.length?n[t]=r[o?0:1]:r.splice(o,1));else r!==e&&r.__eeOnceListener__!==e||delete n[t];return this},s=function(t){var e,n,r,i,o;if(y.call(this,"__ee__")&&(i=this.__ee__[t]))if("object"==typeof i){for(n=arguments.length,o=new Array(n-1),e=1;e=55296&&b<=56319&&(g+=t[++p]),u.call(e,y,g,f),!h);++p);}},function(t,e,n){"use strict";var r=n(16),i=n(17),o=n(116),s=n(126),a=n(45),u=n(6).iterator;t.exports=function(t){return"function"==typeof a(t)[u]?t[u]():r(t)?new o(t):i(t)?new s(t):new o(t)}},function(t,e,n){"use strict";var r,i=n(15),o=n(27),s=n(8),a=n(6),u=n(23),c=Object.defineProperty;r=t.exports=function(t,e){if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");u.call(this,t),e=e?o.call(e,"key+value")?"key+value":o.call(e,"key")?"key":"value":"value",c(this,"__kind__",s("",e))},i&&i(r,u),delete r.prototype.constructor,r.prototype=Object.create(u.prototype,{_resolve:s(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),c(r.prototype,a.toStringTag,s("c","Array Iterator"))},function(t,e,n){"use strict";var r,i=n(118),o=n(26),s=n(7),a=n(123),u=n(7),c=n(2),l=Function.prototype.bind,f=Object.defineProperty,h=Object.prototype.hasOwnProperty;r=function(t,e,n){var r,o=c(e)&&u(e.value);return r=i(e),delete r.writable,delete r.value,r.get=function(){return!n.overwriteDefinition&&h.call(this,t)?o:(e.value=l.call(o,n.resolveContext?n.resolveContext(this):this),f(this,t,e),this[t])},r},t.exports=function(t){var e=o(arguments[1]);return null!=e.resolveContext&&s(e.resolveContext),a(t,function(t,n){return r(n,t,e)})}},function(t,e,n){"use strict";var r=n(119),i=n(19),o=n(2);t.exports=function(t){var e=Object(o(t)),n=arguments[1],s=Object(arguments[2]);if(e!==t&&!n)return e;var a={};return n?r(n,function(e){(s.ensure||e in t)&&(a[e]=t[e])}):i(a,t),a}},function(t,e,n){"use strict";t.exports=n(120)()?Array.from:n(121)},function(t,e,n){"use strict";t.exports=function(){var t,e,n=Array.from;return"function"==typeof n&&(t=["raz","dwa"],e=n(t),Boolean(e&&e!==t&&"dwa"===e[1]))}},function(t,e,n){"use strict";var r=n(6).iterator,i=n(16),o=n(122),s=n(42),a=n(7),u=n(2),c=n(11),l=n(17),f=Array.isArray,h=Function.prototype.call,p={configurable:!0,enumerable:!0,writable:!0,value:null},d=Object.defineProperty;t.exports=function(t){var e,n,g,b,y,v,m,_,w,S,E=arguments[1],k=arguments[2];if(t=Object(u(t)),c(E)&&a(E),this&&this!==Array&&o(this))e=this;else{if(!E){if(i(t))return 1!==(y=t.length)?Array.apply(null,t):(b=new Array(1),b[0]=t[0],b);if(f(t)){for(b=new Array(y=t.length),n=0;n=55296&&v<=56319&&(S+=t[++n]),S=E?h.call(E,k,S,g):S,e?(p.value=S,d(b,g,p)):b[g]=S,++g;y=g}if(void 0===y)for(y=s(t.length),e&&(b=new e(y)),n=0;n=55296&&e<=56319?n+this.__list__[this.__nextIndex__++]:n)})}),u(r.prototype,s.toStringTag,o("c","String Iterator"))},function(t,e,n){"use strict";var r,i=n(15),o=n(8),s=n(23),a=n(6).toStringTag,u=n(128),c=Object.defineProperties,l=s.prototype._unBind;r=t.exports=function(t,e){if(!(this instanceof r))return new r(t,e);s.call(this,t.__mapKeysData__,t),e&&u[e]||(e="key+value"),c(this,{__kind__:o("",e),__values__:o("w",t.__mapValuesData__)})},i&&i(r,s),r.prototype=Object.create(s.prototype,{constructor:o(r),_resolve:o(function(t){return"value"===this.__kind__?this.__values__[t]:"key"===this.__kind__?this.__list__[t]:[this.__list__[t],this.__values__[t]]}),_unBind:o(function(){this.__values__=null,l.call(this)}),toString:o(function(){return"[object Map Iterator]"})}),Object.defineProperty(r.prototype,a,o("c","Map Iterator"))},function(t,e,n){"use strict";t.exports=n(129)("key","value","key+value")},function(t,e,n){"use strict";var r=Array.prototype.forEach,i=Object.create;t.exports=function(t){var e=i(null);return r.call(arguments,function(t){e[t]=!0}),e}},function(t,e,n){"use strict";t.exports=function(){return"undefined"!=typeof Map&&"[object Map]"===Object.prototype.toString.call(new Map)}()},function(t,e,n){function r(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function i(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},n=t.name||"Function wrapped with `once`";return e.onceError=n+" shouldn't be called more than once",e.called=!1,e}var o=n(132);t.exports=o(r),t.exports.strict=o(i),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})})},function(t,e){function n(t,e){function r(){for(var e=new Array(arguments.length),n=0;n0)&&this[this._states[this._stateCounter]]()&&!this.error;)++this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var t=this._list.readUInt8(0);return this.packet.cmd=u.types[t>>u.CMD_SHIFT],this.packet.retain=0!=(t&u.RETAIN_MASK),this.packet.qos=t>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!=(t&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var t,e=0,n=1,r=0,i=!0;e<5&&(t=this._list.readUInt8(e++),r+=n*(t&u.LENGTH_MASK),n*=128,0!=(t&u.LENGTH_FIN_MASK));)if(this._list.length<=e){i=!1;break}return i&&(this.packet.length=r,this._list.consume(e)),i},r.prototype._parsePayload=function(){var t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this._emitError(new Error("Not supported"))}t=!0}return t},r.prototype._parseConnect=function(){var t,e,n,r,i,o,s={},a=this.packet;if(null===(t=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==t&&"MQIsdp"!==t)return this._emitError(new Error("Invalid protocolId"));if(a.protocolId=t,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!==a.protocolVersion&&4!==a.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(++this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!=(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!=(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this._emitError(new Error("Packet too short"));if(null===(e=this._parseString()))return this._emitError(new Error("Packet too short"));if(a.clientId=e,s.will){if(null===(n=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(a.will.topic=n,null===(r=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));a.will.payload=r}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));a.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));a.password=i}return a},r.prototype._parseConnack=function(){var t=this.packet;return this._list.length<2?null:(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),t.returnCode=this._list.readUInt8(this._pos),-1===t.returnCode?this._emitError(new Error("Cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));t.qos>0&&!this._parseMessageId()||(t.payload=this._list.slice(this._pos,t.length))},r.prototype._parseSubscribe=function(){var t,e,n=this.packet;if(1!==n.qos)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(e=this._list.toString("utf8",this._pos,r),this._pos+=n,e)},r.prototype._parseBuffer=function(){var t,e=this._parseNum(),n=e+this._pos;return-1===e||n>this._list.length||n>this.packet.length?null:(t=this._list.slice(this._pos,n),this._pos+=e,t)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var t=this._list.readUInt16BE(this._pos);return this._pos+=2,t},r.prototype._newPacket=function(){return this.packet&&(this._list.consume(this.packet.length),this.emit("packet",this.packet)),this.packet=new a,!0},r.prototype._emitError=function(t){this.error=t,this.emit("error",t)},t.exports=r},function(t,e,n){function r(t){if(!(this instanceof r))return new r(t);if(this._bufs=[],this.length=0,"function"==typeof t){this._callback=t;var e=function(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function(t){t.on("error",e)}),this.on("unpipe",function(t){t.removeListener("error",e)})}else this.append(t);i.call(this)}var i=n(136),o=n(137),s=n(4).Buffer;o.inherits(r,i),r.prototype._offset=function(t){var e,n=0,r=0;if(0===t)return[0,0];for(;rthis.length)&&(r=this.length),n>=this.length)return t||s.alloc(0);if(r<=0)return t||s.alloc(0);var i,o,a=!!t,u=this._offset(n),c=r-n,l=c,f=a&&e||0,h=u[1];if(0===n&&r==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:s.concat(this._bufs,this.length);for(o=0;oi)){this._bufs[o].copy(t,f,h,h+l);break}this._bufs[o].copy(t,f,h),f+=i,l-=i,h&&(h=0)}return t},r.prototype.shallowSlice=function(t,e){t=t||0,e=e||this.length,t<0&&(t+=this.length),e<0&&(e+=this.length);var n=this._offset(t),i=this._offset(e),o=this._bufs.slice(n[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=n[1]&&(o[0]=o[0].slice(n[1])),new r(o)},r.prototype.toString=function(t,e,n){return this.slice(e,n).toString(t)},r.prototype.consume=function(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var t=0,e=new r;t=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=i),a(r,t,r.depth)}function i(t,e){var n=r.styles[e];return n?"["+r.colors[n][0]+"m"+t+"["+r.colors[n][1]+"m":t}function o(t,e){return t}function s(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function a(t,n,r){if(t.customInspect&&n&&x(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=a(t,i,r)),i}var o=u(t,n);if(o)return o;var d=Object.keys(n),g=s(d);if(t.showHidden&&(d=Object.getOwnPropertyNames(n)),k(n)&&(d.indexOf("message")>=0||d.indexOf("description")>=0))return c(n);if(0===d.length){if(x(n)){var b=n.name?": "+n.name:"";return t.stylize("[Function"+b+"]","special")}if(w(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return t.stylize(Date.prototype.toString.call(n),"date");if(k(n))return c(n)}var y="",m=!1,_=["{","}"];if(p(n)&&(m=!0,_=["[","]"]),x(n)){y=" [Function"+(n.name?": "+n.name:"")+"]"}if(w(n)&&(y=" "+RegExp.prototype.toString.call(n)),E(n)&&(y=" "+Date.prototype.toUTCString.call(n)),k(n)&&(y=" "+c(n)),0===d.length&&(!m||0==n.length))return _[0]+y+_[1];if(r<0)return w(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var S;return S=m?l(t,n,r,g,d):d.map(function(e){return f(t,n,r,g,e,m)}),t.seen.pop(),h(S,y,_)}function u(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):d(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,i){for(var o=[],s=0,a=e.length;s-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n"))):u=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+u}function h(t,e,n){var r=0;return t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function b(t){return null==t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return"symbol"==typeof t}function _(t){return void 0===t}function w(t){return S(t)&&"[object RegExp]"===I(t)}function S(t){return"object"==typeof t&&null!==t}function E(t){return S(t)&&"[object Date]"===I(t)}function k(t){return S(t)&&("[object Error]"===I(t)||t instanceof Error)}function x(t){return"function"==typeof t}function O(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function I(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}function A(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),U[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function C(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}function j(e){function n(){for(var n=[],r=0;r=o)return t;switch(t){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(t){return"[Circular]"}default:return t}}),a=i[n];n>8,0),e.writeUInt8(255&t,1),e}function i(){for(var t=0;t0){t=new Array(arguments.length-2);for(var e=0;e1&&(r=n[0]+"@",t=n[1]),t=t.replace(C,"."),r+a(t.split("."),e).join(".")}function c(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function f(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:w}function h(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function p(t,e,n){var r=0;for(t=n?M(t/x):t>>1,t+=M(t/e);t>R*E>>1;r+=w)t=M(t/R);return M(r+(R+1)*t/(t+k))}function d(t){var e,n,r,i,o,a,u,c,h,d,g=[],b=t.length,y=0,v=I,m=O;for(n=t.lastIndexOf(T),n<0&&(n=0),r=0;r=128&&s("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i=b&&s("invalid-input"),c=f(t.charCodeAt(i++)),(c>=w||c>M((_-y)/a))&&s("overflow"),y+=c*a,h=u<=m?S:u>=m+E?E:u-m,!(cM(_/d)&&s("overflow"),a*=d;e=g.length+1,m=p(y-o,e,0==o),M(y/e)>_-v&&s("overflow"),v+=M(y/e),y%=e,g.splice(y++,0,v)}return l(g)}function g(t){var e,n,r,i,o,a,u,l,f,d,g,b,y,v,m,k=[];for(t=c(t),b=t.length,e=I,n=0,o=O,a=0;a=e&&gM((_-n)/y)&&s("overflow"),n+=(u-e)*y,e=u,a=0;a_&&s("overflow"),g==e){for(l=n,f=w;d=f<=o?S:f>=o+E?E:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=w-S,M=Math.floor,N=String.fromCharCode;m={version:"1.4.1",ucs2:{decode:c,encode:l},decode:d,encode:g,toASCII:y,toUnicode:b},void 0!==(i=function(){return m}.call(e,n,e,t))&&(t.exports=i)}()}).call(e,n(50)(t),n(3))},function(t,e,n){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){"use strict";e.decode=e.parse=n(147),e.encode=e.stringify=n(148)},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,b),h=g.substr(b+1)):(f=g,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),r(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function r(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r64)&&!/\s|\/|\\|\+|\*|#/gi.test(t))},encryptedStorage:function(){var t=this;return{get:function(e){return i.get(e)?JSON.parse(t.decrypt(i.get(e))):{}},set:function(e,n){return n="object"===(void 0===n?"undefined":r(n))?JSON.stringify(n):n,i.set(e,t.encrypt(n)),t}}},decrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)-s.charCodeAt(e%s.length))}).join("")},encrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)+s.charCodeAt(e%s.length))}).join("")},getAppDomain:function(t,e){return e?o.HOST_DEV:-1===o.EXCLUSIVE_APPIDS.indexOf(t)?t.replace("-demo","")+"."+o.HOST:o.HOST},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},defaultDevice:function(t){var e=t.appId,i=t.userId,s=t.token,u=t.realtime,c=t.error;s=s||"disabled";var l="ALLOWED",f=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{type:null};"object"===(void 0===s?"undefined":r(s))?s=JSON.stringify(s):"DENIED"===s?(l=s,s="NOT_EXIST"):s.startsWith("NOT_SUPPORTED")&&(l=s,s="NOT_EXIST"),c&&(l="ERR",s="NOT_EXIST");var h={realtime:u,launchCount:+this.encryptedStorage().get(o.STORAGE_KEY).launchCount,launchTime:Date.now(),appId:e,userId:i,deviceToken:s,deviceType:"web",tokenStatus:l,tokenErr:c?{message:c.message,code:c.code}:null,deviceModel:a.name?a.name.toLowerCase():"NodeJS",osVersion:a.os.version,deviceManufacture:a.os.family,browserVersion:a.version,appVersion:n(157).version,subscriptions:o.DEFAULT_CHANNELS,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,connection:f.type};return"$omit_token"===s&&(delete h.deviceToken,delete h.tokenStatus,delete h.tokenErr),h},toTopicName:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"user",i=void 0,o=void 0;switch(r){case"user":var s=n.split("/");"public"===s[0]?(i=s[0],o=s[1]):(i=e,o=s[0]);break;case"publish":i="*"===e?"public":e,o=n;break;case"event":case"track":i=n,o=e||"+";break;default:throw new Error("Invalid topic type.")}return["app",t,r,i,o].join("/")},fromChabokChannel:function(t){var e=t.split("/"),n=void 0;switch(e.length){case 1:n="public/"+e[0];break;case 2:if("public"!==e[0]&&"private"!==e[0])throw new Error("Invalid channel name format, please read documentations.");n="public"===e[0]?"public/"+e[1]:e[1];break;default:throw new Error("Invalid channel name format, please read documentations.")}return n},toChabokMessage:function(t,e){var n=t.split("/"),r=n[3]+"/"+n[4];try{var i=JSON.parse(e);return i.channel=r,i}catch(t){return console.error("Invalid Chabok Payload ",e),e}},toEventMessage:function(t,e){var n=t.split("/"),r=n[1],i=n[3],o=n[4],s={appId:r,eventName:i,deviceId:o,receivedAt:Date.now()};try{return s.data=JSON.parse(e),s.createdAt=s.data.createdAt,s.id=s.data.id,s}catch(t){return console.error("Invalid Chabok event ",e),e}}};t.exports=u},function(t,e){!function(e,n){var r={version:"2.7.1",areas:{},apis:{},inherit:function(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e},stringify:function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)},parse:function(t){try{return JSON.parse(t)}catch(e){return t}},fn:function(t,e){r.storeAPI[t]=e;for(var n in r.apis)r.apis[n][t]=e},get:function(t,e){return t.getItem(e)},set:function(t,e,n){t.setItem(e,n)},remove:function(t,e){t.removeItem(e)},key:function(t,e){return t.key(e)},length:function(t){return t.length},clear:function(t){t.clear()},Store:function(t,e,n){var i=r.inherit(r.storeAPI,function(t,e,n){return 0===arguments.length?i.getAll():"function"==typeof e?i.transact(t,e,n):void 0!==e?i.set(t,e,n):"string"==typeof t||"number"==typeof t?i.get(t):t?i.setAll(t,e):i.clear()});i._id=t;try{e.setItem("_-bad-_","wolf"),i._area=e,e.removeItem("_-bad-_")}catch(t){}return i._area||(i._area=r.inherit(r.storageAPI,{items:{},name:"fake"})),i._ns=n||"",r.areas[t]||(r.areas[t]=i._area),r.apis[i._ns+i._id]||(r.apis[i._ns+i._id]=i),i},storeAPI:{area:function(t,e){var n=this[t];return n&&n.area||(n=r.Store(t,e,this._ns),this[t]||(this[t]=n)),n},namespace:function(t,e){if(!t)return this._ns?this._ns.substring(0,this._ns.length-1):"";var n=t,i=this[n];return i&&i.namespace||(i=r.Store(this._id,this._area,this._ns+n+"."),this[n]||(this[n]=i),e||i.area("session",r.areas.session)),i},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(t){return this._area.has?this._area.has(this._in(t)):!!(this._in(t)in this._area)},size:function(){return this.keys().length},each:function(t,e){for(var n=0,i=r.length(this._area);nr.length(this._area)&&(i--,n--)}return e||this},keys:function(t){return this.each(function(t,e){e.push(t)},t||[])},get:function(t,e){var n=r.get(this._area,this._in(t));return null!==n?r.parse(n):e||n},getAll:function(t){return this.each(function(t,e){e[t]=this.get(t)},t||{})},transact:function(t,e,n){var r=this.get(t,n),i=e(r);return this.set(t,void 0===i?r:i),this},set:function(t,e,n){var i=this.get(t);return null!=i&&!1===n?e:r.set(this._area,this._in(t),r.stringify(e),n)||i},setAll:function(t,e){var n,r;for(var i in t)r=t[i],this.set(i,r,e)!==r&&(n=!0);return n},add:function(t,e){var n=this.get(t);if(n instanceof Array)e=n.concat(e);else if(null!==n){var i=typeof n;if(i===typeof e&&"object"===i){for(var o in e)n[o]=e[o];e=n}else e=n+e}return r.set(this._area,this._in(t),r.stringify(e)),e},remove:function(t){var e=this.get(t);return r.remove(this._area,this._in(t)),e},clear:function(){return this._ns?this.each(function(t){r.remove(this._area,this._in(t))},1):r.clear(this._area),this},clearAll:function(){var t=this._area;for(var e in r.areas)r.areas.hasOwnProperty(e)&&(this._area=r.areas[e],this.clear());return this._area=t,this},_in:function(t){return"string"!=typeof t&&(t=r.stringify(t)),this._ns?this._ns+t:t},_out:function(t){return this._ns?t&&0===t.indexOf(this._ns)?t.substring(this._ns.length):void 0:t}},storageAPI:{length:0,has:function(t){return this.items.hasOwnProperty(t)},key:function(t){var e=0;for(var n in this.items)if(this.has(n)&&t===e++)return n},setItem:function(t,e){this.has(t)||this.length++,this.items[t]=e},removeItem:function(t){this.has(t)&&(delete this.items[t],this.length--)},getItem:function(t){return this.has(t)?this.items[t]:null},clear:function(){for(var t in this.items)this.removeItem(t)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},i=r.Store("local",function(){try{return localStorage}catch(t){}}());i.local=i,i._=r,i.area("session",function(){try{return sessionStorage}catch(t){}}()),"function"==typeof n&&void 0!==n.amd?n("store2",[],function(){return i}):void 0!==t&&t.exports?t.exports=i:(e.store&&(r.conflict=e.store),e.store=i)}(this,this&&this.define)},function(t,e,n){(function(t,r){var i;(function(){"use strict";function o(t){return t=String(t),t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return e&&n&&/^Win/i.test(t)&&!/^Windows Phone /i.test(t)&&(r=r[/[\d.]+$/.exec(t)])&&(t="Windows "+r),t=String(t),e&&n&&(t=t.replace(RegExp(e,"i"),n)),t=u(t.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function a(t,e){var n=-1,r=t?t.length:0;if("number"==typeof r&&r>-1&&r<=w)for(;++n3&&"WebKit"||/\bOpera\b/.test(D)&&(/\bOPR\b/.test(t)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(B)&&"WebKit"||!B&&/\bMSIE\b/i.test(t)&&("Mac OS"==W?"Tasman":"Trident")||"WebKit"==B&&/\bPlayStation\b(?! Vita\b)/i.test(D)&&"NetFront")&&(B=[b]),"IE"==D&&(b=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(D+=" Mobile",W="Windows Phone "+(/\+$/.test(b)?b:b+".x"),M.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(D="IE Mobile",W="Windows Phone 8.x",M.unshift("desktop mode"),U||(U=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=D&&"Trident"==B&&(b=/\brv:([\d.]+)/.exec(t))&&(D&&M.push("identifying as "+D+(U?" "+U:"")),D="IE",U=b[1]),L){if(f(r,"global"))if(O&&(b=O.lang.System,R=b.getProperty("os.arch"),W=W||b.getProperty("os.name")+" "+b.getProperty("os.version")),I){try{U=r.require("ringo/engine").version.join("."),D="RingoJS"}catch(t){(b=r.system)&&b.global.system==r.system&&(D="Narwhal",W||(W=b[0].os||null))}D||(D="Rhino")}else"object"==typeof r.process&&!r.process.browser&&(b=r.process)&&("object"==typeof b.versions&&("string"==typeof b.versions.electron?(M.push("Node "+b.versions.node),D="Electron",U=b.versions.electron):"string"==typeof b.versions.nw&&(M.push("Chromium "+U,"Node "+b.versions.node),D="NW.js",U=b.versions.nw)),D||(D="Node.js",R=b.arch,W=b.platform,U=/[\d.]+/.exec(b.version),U=U?U[0]:null));else l(b=r.runtime)==_?(D="Adobe AIR",W=b.flash.system.Capabilities.os):l(b=r.phantom)==k?(D="PhantomJS",U=(b=b.version||null)&&b.major+"."+b.minor+"."+b.patch):"number"==typeof P.documentMode&&(b=/\bTrident\/(\d+)/i.exec(t))?(U=[U,P.documentMode],(b=+b[1]+4)!=U[1]&&(M.push("IE "+U[1]+" mode"),B&&(B[1]=""),U[1]=b),U="IE"==D?String(U[1].toFixed(1)):U[0]):"number"==typeof P.documentMode&&/^(?:Chrome|Firefox)\b/.test(D)&&(M.push("masking as "+D+" "+U),D="IE",U="11.0",B=["Trident"],W="Windows");W=W&&u(W)}if(U&&(b=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(U)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(L&&o.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(N=/b/i.test(b)?"beta":"alpha",U=U.replace(RegExp(b+"\\+?$"),"")+("beta"==N?A:T)+(/\d+\+?/.exec(b)||"")),"Fennec"==D||"Firefox"==D&&/\b(?:Android|Firefox OS)\b/.test(W))D="Firefox Mobile";else if("Maxthon"==D&&U)U=U.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(q))"Xbox 360"==q&&(W=null),"Xbox 360"==q&&/\bIEMobile\b/.test(t)&&M.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(D)&&(!D||q||/Browser|Mobi/.test(D))||"Windows CE"!=W&&!/Mobi/i.test(t))if("IE"==D&&L)try{null===r.external&&M.unshift("platform preview")}catch(t){M.unshift("embedded")}else(/\bBlackBerry\b/.test(q)||/\bBB10\b/.test(t))&&(b=(RegExp(q.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||U)?(b=[b,/BB10/.test(t)],W=(b[1]?(q=null,F="BlackBerry"):"Device Software")+" "+b[0],U=null):this!=c&&"Wii"!=q&&(L&&C||/Opera/.test(D)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==D&&/\bOS X (?:\d+\.){2,}/.test(W)||"IE"==D&&(W&&!/^Win/.test(W)&&U>5.5||/\bWindows XP\b/.test(W)&&U>8||8==U&&!/\bTrident\b/.test(t)))&&!S.test(b=g.call(c,t.replace(S,"")+";"))&&b.name&&(b="ing as "+b.name+((b=b.version)?" "+b:""),S.test(D)?(/\bIE\b/.test(b)&&"Mac OS"==W&&(W=null),b="identify"+b):(b="mask"+b,D=j?u(j.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(b)&&(W=null),L||(U=null)),B=["Presto"],M.push(b));else D+=" Mobile";(b=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(b=[parseFloat(b.replace(/\.(\d)$/,".0$1")),b],"Safari"==D&&"+"==b[1].slice(-1)?(D="WebKit Nightly",N="alpha",U=b[1].slice(0,-1)):U!=b[1]&&U!=(b[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(U=null),b[1]=(/\bChrome\/([\d.]+)/i.exec(t)||0)[1],537.36==b[0]&&537.36==b[2]&&parseFloat(b[1])>=28&&"WebKit"==B&&(B=["Blink"]),L&&(m||b[1])?(B&&(B[1]="like Chrome"),b=b[1]||(b=b[0],b<530?1:b<532?2:b<532.05?3:b<533?4:b<534.03?5:b<534.07?6:b<534.1?7:b<534.13?8:b<534.16?9:b<534.24?10:b<534.3?11:b<535.01?12:b<535.02?"13+":b<535.07?15:b<535.11?16:b<535.19?17:b<536.05?18:b<536.1?19:b<537.01?20:b<537.11?"21+":b<537.13?23:b<537.18?24:b<537.24?25:b<537.36?26:"Blink"!=B?"27":"28")):(B&&(B[1]="like Safari"),b=b[0],b=b<400?1:b<500?2:b<526?3:b<533?4:b<534?"4+":b<535?5:b<537?6:b<538?7:b<601?8:"8"),B&&(B[1]+=" "+(b+="number"==typeof b?".x":/[.+]/.test(b)?"":"+")),"Safari"==D&&(!U||parseInt(U)>45)&&(U=b)),"Opera"==D&&(b=/\bzbov|zvav$/.exec(W))?(D+=" ",M.unshift("desktop mode"),"zvav"==b?(D+="Mini",U=null):D+="Mobile",W=W.replace(RegExp(" *"+b+"$"),"")):"Safari"==D&&/\bChrome\b/.exec(B&&B[1])&&(M.unshift("desktop mode"),D="Chrome Mobile",U=null,/\bOS X\b/.test(W)?(F="Apple",W="iOS 4.3+"):W=null),U&&0==U.indexOf(b=/[\d.]+$/.exec(W))&&t.indexOf("/"+b+"-")>-1&&(W=d(W.replace(b,""))),B&&!/\b(?:Avant|Nook)\b/.test(D)&&(/Browser|Lunascape|Maxthon/.test(D)||"Safari"!=D&&/^iOS/.test(W)&&/\bSafari\b/.test(B[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(D)&&B[1])&&(b=B[B.length-1])&&M.push(b),M.length&&(M=["("+M.join("; ")+")"]),F&&q&&q.indexOf(F)<0&&M.push("on "+F),q&&M.push((/^on /.test(M[M.length-1])?"":"on ")+q),W&&(b=/ ([\d.+]+)$/.exec(W),v=b&&"/"==W.charAt(W.length-b[0].length-1),W={architecture:32,family:b&&!v?W.replace(b[0],""):W,version:b?b[1]:null,toString:function(){var t=this.version;return this.family+(t&&!v?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(b=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(R))&&!/\bi686\b/i.test(R)?(W&&(W.architecture=64,W.family=W.family.replace(RegExp(" *"+b),"")),D&&(/\bWOW64\b/i.test(t)||L&&/\w(?:86|32)$/.test(o.cpuClass||o.platform)&&!/\bWin64; x64\b/i.test(t))&&M.unshift("32-bit")):W&&/^OS X/.test(W.family)&&"Chrome"==D&&parseFloat(U)>=39&&(W.architecture=64),t||(t=null);var K={};return K.description=t,K.layout=B&&B[0],K.manufacturer=F,K.name=D,K.prerelease=N,K.product=q,K.ua=t,K.version=D&&U,K.os=W||{architecture:null,family:null,version:null,toString:function(){return"null"}},K.parse=g,K.toString=n,K.version&&M.unshift(U),K.name&&M.unshift(D),W&&D&&(W!=String(W).split(" ")[0]||W!=D.split(" ")[0]&&!q)&&M.push(q?"("+W+")":"on "+W),M.length&&(K.description=M.join(" ")),K}var b={function:!0,object:!0},y=b[typeof window]&&window||this,v=b[typeof e]&&e,m=b[typeof t]&&t&&!t.nodeType&&t,_=v&&m&&"object"==typeof r&&r;!_||_.global!==_&&_.window!==_&&_.self!==_||(y=_);var w=Math.pow(2,53)-1,S=/\bOpera/,E=Object.prototype,k=E.hasOwnProperty,x=E.toString,O=g();y.platform=O,void 0!==(i=function(){return O}.call(e,n,e,t))&&(t.exports=i)}).call(this)}).call(e,n(50)(t),n(3))},function(t,e){t.exports={name:"chabokpush",version:"1.2.1",description:"Chabok Javascript client for browsers, React-Native, Web Workers & Node.js",main:"dist/chabokpush.min.js",homepage:"http://chabokpush.com/",scripts:{build:"webpack --env build","demo-build":"webpack --env demo && node ./development.js","dev-build":"webpack --env demo && NODE_ENV=staging node ./development.js",dev:"webpack --progress --colors --watch --env dev",pretest:"webpack --env build",test:"mocha --compilers js:babel-core/register --colors ./test/*.spec.js -r ./test/setup.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js -r ./test/setup.js",release:"./release.sh"},repository:{type:"git",url:"https://github.com/chabokpush/chabok-client-js.git"},author:"ADP digital",license:"ISC",eslintConfig:{env:{browser:!0,node:!0},parserOptions:{ecmaVersion:6,sourceType:"module"},rules:{semi:2}},dependencies:{axios:"^0.17.1","es6-symbol":"^3.1.1","faye-websocket":"^0.11.1",mqtt:"^2.15.0",platform:"^1.3.4",shortid:"^2.2.8",store2:"^2.5.2"},devDependencies:{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.3","babel-loader":"^7.1.2","babel-plugin-add-module-exports":"0.2.1","babel-preset-es2015":"6.24.1",chai:"^4.1.2","copy-webpack-plugin":"^4.3.0",eslint:"^4.13.1","eslint-loader":"^1.9.0","html-webpack-plugin":"^2.30.1",mocha:"^4.0.1",webpack:"^3.10.0",yargs:"^10.0.3"}}},function(t,e,n){"use strict";t.exports=n(159)},function(t,e,n){"use strict";function r(e){return a.seed(e),t.exports}function i(e){return l=e,t.exports}function o(t){return void 0!==t&&a.characters(t),a.shuffled()}function s(){return u(l)}var a=n(18),u=n(161),c=n(165),l=n(166)||0;t.exports=s,t.exports.generate=s,t.exports.seed=r,t.exports.worker=i,t.exports.characters=o,t.exports.isValid=c},function(t,e,n){"use strict";function r(){return(o=(9301*o+49297)%233280)/233280}function i(t){o=t}var o=1;t.exports={nextValue:r,seed:i}},function(t,e,n){"use strict";function r(t){var e="",n=Math.floor(.001*(Date.now()-a));return n===o?i++:(i=0,o=n),e+=s(u),e+=s(t),i>0&&(e+=s(i)),e+=s(n)}var i,o,s=n(162),a=(n(18),1459707606518),u=6;t.exports=r},function(t,e,n){"use strict";function r(t){for(var e,n=0,r="";!e;)r+=s(o,i.get(),1),e=t=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([n]):s[e]?s[e]+", "+n:n}}),s):s}},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return e=t(window.location.href),function(n){var i=r.isString(n)?t(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return function(){return!0}}()},function(t,e,n){"use strict";function r(){this.message="String contains an invalid character"}function i(t){for(var e,n,i=String(t),s="",a=0,u=o;i.charAt(0|a)||(u="=",a%1);s+=u.charAt(63&e>>8-a%1*8)){if((n=i.charCodeAt(a+=.75))>255)throw new r;e=e<<8|n}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",t.exports=i},function(t,e,n){"use strict";var r=n(1);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,i,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e,n){"use strict";function r(){this.handlers=[]}var i=n(1);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){"use strict";function r(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var i=n(1),o=n(83),s=n(31),a=n(20),u=n(84),c=n(85);t.exports=function(t){return r(t),t.baseURL&&!u(t.url)&&(t.url=c(t.baseURL,t.url)),t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),i.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||a.adapter)(t).then(function(e){return r(t),e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return s(e)||(r(t),e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(t,e,n){"use strict";var r=n(1);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,n){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,n){"use strict";function r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t});var n=this;t(function(t){n.reason||(n.reason=new i(t),e(n.reason))})}var i=n(32);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var t;return{token:new r(function(e){t=e}),cancel:t}},t.exports=r},function(t,e,n){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,n){"use strict";(function(e){function r(t){var e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}function i(t,e){function n(t){return e.servers&&(t._reconnectCount&&t._reconnectCount!==e.servers.length||(t._reconnectCount=0),e.host=e.servers[t._reconnectCount].host,e.port=e.servers[t._reconnectCount].port,e.protocol=e.servers[t._reconnectCount].protocol?e.servers[t._reconnectCount].protocol:e.defaultProtocol,e.hostname=e.host,t._reconnectCount++),c[e.protocol](t,e)}if("object"!=typeof t||e||(e=t,t=null),e=e||{},t){var i=a.parse(t,!0);if(null!=i.port&&(i.port=Number(i.port)),e=u(i,e),null===e.protocol)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(r(e),e.query&&"string"==typeof e.query.clientId&&(e.clientId=e.query.clientId),e.cert&&e.key){if(!e.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs"].indexOf(e.protocol))switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}if(!c[e.protocol]){var s=-1!==["mqtts","wss"].indexOf(e.protocol);e.protocol=["mqtt","mqtts","ws","wss","wx","wxs"].filter(function(t,e){return(!s||e%2!=0)&&"function"==typeof c[t]})[0]}if(!1===e.clean&&!e.clientId)throw new Error("Missing clientId for unclean clients");return e.protocol&&(e.defaultProtocol=e.protocol),new o(n,e)}var o=n(89),s=n(33),a=n(49),u=n(21),c={};"browser"!==e.title?(c.mqtt=n(51),c.tcp=n(51),c.ssl=n(24),c.tls=n(24),c.mqtts=n(24)):(c.wx=n(52),c.wxs=n(52)),c.ws=n(54),c.wss=n(54),t.exports=i,t.exports.connect=i,t.exports.MqttClient=o,t.exports.Store=s}).call(e,n(0))},function(t,e,n){"use strict";(function(e,r){function i(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function o(t,e,n){t.emit("packetsend",e),!p.writeToStream(e,t.stream)&&n?t.stream.once("drain",n):n&&n()}function s(t){t&&Object.keys(t).forEach(function(e){"function"==typeof t[e]&&(t[e](new Error("Connection closed")),delete t[e])})}function a(t,e,n){t.outgoingStore.put(e,function(r){if(r)return n&&n(r);o(t,e,n)})}function u(){}function c(t,e){var n,r=this;if(!(this instanceof c))return new c(t,e);this.options=e||{};for(n in _)void 0===this.options[n]?this.options[n]=_[n]:this.options[n]=e[n];this.options.clientId="string"==typeof this.options.clientId?this.options.clientId:i(),this.streamBuilder=t,this.outgoingStore=this.options.outgoingStore||new f,this.incomingStore=this.options.incomingStore||new f,this.queueQoSZero=void 0===this.options.queueQoSZero||this.options.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this.on("connect",function(){function t(){n.destroy(),n=null}function e(){if(n){var t,i=n.read(1);if(!i)return void n.once("readable",e);r.disconnecting||r.reconnectTimer?n.destroy&&n.destroy():(t=r.outgoing[i.messageId],r.outgoing[i.messageId]=function(n,r){t&&t(n,r),e()},r._sendPacket(i))}}if(!this.disconnected){this.connected=!0;var n=this.outgoingStore.createStream();this.once("close",t),n.on("end",function(){r.removeListener("close",t)}),n.on("error",function(e){r.removeListener("close",t),r.emit("error",e)}),e()}}),this.on("close",function(){this.connected=!1,clearTimeout(this.connackTimer)}),this.on("connect",this._setupPingTimer),this.on("connect",function(){function t(){var n=e.shift(),i=null;n&&(i=n.packet,r._sendPacket(i,function(e){n.cb&&n.cb(e),t()}))}var e=this.queue;t()});var o=!0;this.on("connect",function(){!o&&this.options.clean&&Object.keys(this._resubscribeTopics).length>0&&(this.options.resubscribe?(this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics)):this._resubscribeTopics={}),o=!1}),this.on("close",function(){null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null)}),this.on("close",this._setupReconnect),l.EventEmitter.call(this),this._setupStream()}var l=n(9),f=n(33),h=n(46),p=n(133),d=n(14).Writable,g=n(5),b=n(142),y=n(143),v=n(21),m=e.setImmediate||function(t){r.nextTick(t)},_={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0};g(c,l.EventEmitter),c.prototype._setupStream=function(){function t(){r.nextTick(e)}function e(){var e=l.shift(),n=c;e?i._handlePacket(e,t):(c=null,n())}var n,i=this,s=new d,a=p.parser(this.options),c=null,l=[];this._clearReconnect(),this.stream=this.streamBuilder(this),a.on("packet",function(t){l.push(t)}),s._write=function(t,n,r){c=r,a.parse(t),e()},this.stream.pipe(s),this.stream.on("error",u),h(this.stream,this.emit.bind(this,"close")),n=Object.create(this.options),n.cmd="connect",o(this,n),a.on("error",this.emit.bind(this,"error")),this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout(function(){i._cleanUp(!0)},this.options.connectTimeout)},c.prototype._handlePacket=function(t,e){switch(this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"pingresp":this._handlePingresp(t),e()}},c.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},c.prototype.publish=function(t,e,n,r){var i;if("function"==typeof n&&(r=n,n=null),n=v({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(i={cmd:"publish",topic:t,payload:e,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},n.qos){case 1:case 2:this.outgoing[i.messageId]=r||u,this._sendPacket(i);break;default:this._sendPacket(i,r)}return this},c.prototype.subscribe=function(){var t,e,n=Array.prototype.slice.call(arguments),r=[],i=n.shift(),o=i.resubscribe,s=n.pop()||u,a=n.pop(),c=this;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof s&&(a=s,s=u),null!==(e=y.validateTopics(i)))return m(s,new Error("Invalid topic "+e)),this;if(this._checkDisconnecting(s))return this;if(a=v({qos:0},a),Array.isArray(i)?i.forEach(function(t){(c._resubscribeTopics[t]0&&(c._resubscribeTopics[t.topic]=t.qos,l.push(t.topic))}),c.messageIdToTopic[t.messageId]=l}return this.outgoing[t.messageId]=function(t,e){if(!t)for(var n=e.granted,i=0;i0?this.once("outgoingEmpty",setTimeout.bind(null,r,10)):r(),this)},c.prototype.removeOutgoingMessage=function(t){var e=this.outgoing[t];return delete this.outgoing[t],this.outgoingStore.del({messageId:t},function(){e(new Error("Message removed"))}),this},c.prototype.reconnect=function(t){var e=this,n=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new f,e.outgoingStore=e.options.outgoingStore||new f,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},c.prototype._reconnect=function(){this.emit("reconnect"),this._setupStream()},c.prototype._setupReconnect=function(){var t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0&&(this.reconnecting||(this.emit("offline"),this.reconnecting=!0),t.reconnectTimer=setInterval(function(){t._reconnect()},t.options.reconnectPeriod))},c.prototype._clearReconnect=function(){this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},c.prototype._cleanUp=function(t,e){e&&this.stream.on("close",e),t?(0===this.options.reconnectPeriod&&this.options.clean&&s(this.outgoing),this.stream.destroy()):this._sendPacket({cmd:"disconnect"},m.bind(null,this.stream.end.bind(this.stream))),this.disconnecting||(this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(this.pingTimer.clear(),this.pingTimer=null),e&&!this.connected&&(this.stream.removeListener("close",e),e())},c.prototype._sendPacket=function(t,e){if(!this.connected)return void(0===(t.qos||0)&&this.queueQoSZero||"publish"!==t.cmd?this.queue.push({packet:t,cb:e}):t.qos>0?(e=this.outgoing[t.messageId],this.outgoingStore.put(t,function(t){if(t)return e&&e(t)})):e&&e(new Error("No connection to broker")));switch(this._shiftPingInterval(),t.cmd){case"publish":break;case"pubrel":return void a(this,t,e);default:return void o(this,t,e)}switch(t.qos){case 2:case 1:a(this,t,e);break;case 0:default:o(this,t,e)}},c.prototype._setupPingTimer=function(){var t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=b(function(){t._checkPing()},1e3*this.options.keepalive))},c.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},c.prototype._checkPing=function(){this.pingResp?(this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):this._cleanUp(!0)},c.prototype._handlePingresp=function(){this.pingResp=!0},c.prototype._handleConnack=function(t){var e=t.returnCode,n=["","Unacceptable protocol version","Identifier rejected","Server unavailable","Bad username or password","Not authorized"];if(clearTimeout(this.connackTimer),0===e)this.reconnecting=!1,this.emit("connect",t);else if(e>0){var r=new Error("Connection refused: "+n[e]);r.code=e,this.emit("error",r)}},c.prototype._handlePublish=function(t,e){e=void 0!==e?e:u;var n=t.topic.toString(),r=t.payload,i=t.qos,o=t.messageId,s=this;switch(i){case 2:this.incomingStore.put(t,function(t){if(t)return e(t);s._sendPacket({cmd:"pubrec",messageId:o},e)});break;case 1:this.emit("message",n,r,t),this.handleMessage(t,function(t){if(t)return e(t);s._sendPacket({cmd:"puback",messageId:o},e)});break;case 0:this.emit("message",n,r,t),this.handleMessage(t,e)}},c.prototype.handleMessage=function(t,e){e()},c.prototype._handleAck=function(t){var e=t.messageId,n=t.cmd,r=null,i=this.outgoing[e],o=this;if(i){switch(n){case"pubcomp":case"puback":delete this.outgoing[e],this.outgoingStore.del(t,i);break;case"pubrec":r={cmd:"pubrel",qos:2,messageId:e},this._sendPacket(r);break;case"suback":if(delete this.outgoing[e],1===t.granted.length&&0!=(128&t.granted[0])){var s=this.messageIdToTopic[e];s&&s.forEach(function(t){delete o._resubscribeTopics[t]})}i(null,t);break;case"unsuback":delete this.outgoing[e],i(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}},c.prototype._handlePubrel=function(t,e){e=void 0!==e?e:u;var n=t.messageId,r=this,i={cmd:"pubcomp",messageId:n};r.incomingStore.get(t,function(n,o){n||"pubrel"===o.cmd?r._sendPacket(i,e):(r.emit("message",o.topic,o.payload,o),r.incomingStore.put(t,function(t){if(t)return e(t);r.handleMessage(o,function(t){if(t)return e(t);r._sendPacket(i,e)})}))})},c.prototype._nextId=function(){var t=this.nextId++;return 65536===this.nextId&&(this.nextId=1),t},c.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},t.exports=c}).call(e,n(3),n(0))},function(t,e,n){"use strict";function r(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function i(t){var e=r(t),n=e[0],i=e[1];return 3*(n+i)/4-i}function o(t,e,n){return 3*(e+n)/4-n}function s(t){for(var e,n=r(t),i=n[0],s=n[1],a=new h(o(t,i,s)),u=0,c=s>0?i-4:i,l=0;l>16&255,a[u++]=e>>8&255,a[u++]=255&e;return 2===s&&(e=f[t.charCodeAt(l)]<<2|f[t.charCodeAt(l+1)]>>4,a[u++]=255&e),1===s&&(e=f[t.charCodeAt(l)]<<10|f[t.charCodeAt(l+1)]<<4|f[t.charCodeAt(l+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e),a}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function u(t,e,n){for(var r,i=[],o=e;os?s:o+16383));return 1===r?(e=t[n-1],i.push(l[e>>2]+l[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],i.push(l[e>>10]+l[e>>4&63]+l[e<<2&63]+"=")),i.join("")}e.byteLength=i,e.toByteArray=s,e.fromByteArray=c;for(var l=[],f=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,g=p.length;d>1,l=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+f>=1?h/u:h*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[n+p]=255&s,p+=d,s/=256,c-=8);t[n+p-d]|=128*g}},function(t,e){},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e,n){t.copy(e,n)}var o=n(4).Buffer,s=n(94);t.exports=function(){function t(){r(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var e=o.allocUnsafe(t>>>0),n=this.head,r=0;n;)i(n.data,e,r),r+=n.data.length,n=n.next;return e},t}(),s&&s.inspect&&s.inspect.custom&&(t.exports.prototype[s.inspect.custom]=function(){var t=s.inspect({length:this.length});return this.constructor.name+" "+t})},function(t,e){},function(t,e,n){(function(t){function r(t,e){this._id=t,this._clearFn=e}var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;e.setTimeout=function(){return new r(o.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new r(o.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(96),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,n(3))},function(t,e,n){(function(t,e){!function(t,n){"use strict";function r(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=0?c(l):i(this.length)-c(u(l)),e=l;e0?1:-1}},function(t,e,n){"use strict";var r=n(11),i={function:!0,object:!0};t.exports=function(t){return r(t)&&i[typeof t]||!1}},function(t,e,n){"use strict";var r,i=Object.create;n(43)()||(r=n(44)),t.exports=function(){var t,e,n;return r?1!==r.level?i:(t={},e={},n={configurable:!1,enumerable:!1,writable:!0,value:void 0},Object.getOwnPropertyNames(Object.prototype).forEach(function(t){if("__proto__"===t)return void(e[t]={configurable:!0,enumerable:!1,writable:!0,value:void 0});e[t]=n}),Object.defineProperties(t,e),Object.defineProperty(r,"nullPolyfill",{configurable:!1,enumerable:!1,writable:!1,value:t}),function(e,n){return i(null===e?t:e,n)}):i}()},function(t,e,n){"use strict";var r,i,o,s,a,u,c,l=n(8),f=n(7),h=Function.prototype.apply,p=Function.prototype.call,d=Object.create,g=Object.defineProperty,b=Object.defineProperties,y=Object.prototype.hasOwnProperty,v={configurable:!0,enumerable:!1,writable:!0};r=function(t,e){var n;return f(e),y.call(this,"__ee__")?n=this.__ee__:(n=v.value=d(null),g(this,"__ee__",v),v.value=null),n[t]?"object"==typeof n[t]?n[t].push(e):n[t]=[n[t],e]:n[t]=e,this},i=function(t,e){var n,i;return f(e),i=this,r.call(this,t,n=function(){o.call(i,t,n),h.call(e,this,arguments)}),n.__eeOnceListener__=e,this},o=function(t,e){var n,r,i,o;if(f(e),!y.call(this,"__ee__"))return this;if(n=this.__ee__,!n[t])return this;if("object"==typeof(r=n[t]))for(o=0;i=r[o];++o)i!==e&&i.__eeOnceListener__!==e||(2===r.length?n[t]=r[o?0:1]:r.splice(o,1));else r!==e&&r.__eeOnceListener__!==e||delete n[t];return this},s=function(t){var e,n,r,i,o;if(y.call(this,"__ee__")&&(i=this.__ee__[t]))if("object"==typeof i){for(n=arguments.length,o=new Array(n-1),e=1;e=55296&&b<=56319&&(g+=t[++p]),u.call(e,y,g,f),!h);++p);}},function(t,e,n){"use strict";var r=n(16),i=n(17),o=n(116),s=n(126),a=n(45),u=n(6).iterator;t.exports=function(t){return"function"==typeof a(t)[u]?t[u]():r(t)?new o(t):i(t)?new s(t):new o(t)}},function(t,e,n){"use strict";var r,i=n(15),o=n(27),s=n(8),a=n(6),u=n(23),c=Object.defineProperty;r=t.exports=function(t,e){if(!(this instanceof r))throw new TypeError("Constructor requires 'new'");u.call(this,t),e=e?o.call(e,"key+value")?"key+value":o.call(e,"key")?"key":"value":"value",c(this,"__kind__",s("",e))},i&&i(r,u),delete r.prototype.constructor,r.prototype=Object.create(u.prototype,{_resolve:s(function(t){return"value"===this.__kind__?this.__list__[t]:"key+value"===this.__kind__?[t,this.__list__[t]]:t})}),c(r.prototype,a.toStringTag,s("c","Array Iterator"))},function(t,e,n){"use strict";var r,i=n(118),o=n(26),s=n(7),a=n(123),u=n(7),c=n(2),l=Function.prototype.bind,f=Object.defineProperty,h=Object.prototype.hasOwnProperty;r=function(t,e,n){var r,o=c(e)&&u(e.value);return r=i(e),delete r.writable,delete r.value,r.get=function(){return!n.overwriteDefinition&&h.call(this,t)?o:(e.value=l.call(o,n.resolveContext?n.resolveContext(this):this),f(this,t,e),this[t])},r},t.exports=function(t){var e=o(arguments[1]);return null!=e.resolveContext&&s(e.resolveContext),a(t,function(t,n){return r(n,t,e)})}},function(t,e,n){"use strict";var r=n(119),i=n(19),o=n(2);t.exports=function(t){var e=Object(o(t)),n=arguments[1],s=Object(arguments[2]);if(e!==t&&!n)return e;var a={};return n?r(n,function(e){(s.ensure||e in t)&&(a[e]=t[e])}):i(a,t),a}},function(t,e,n){"use strict";t.exports=n(120)()?Array.from:n(121)},function(t,e,n){"use strict";t.exports=function(){var t,e,n=Array.from;return"function"==typeof n&&(t=["raz","dwa"],e=n(t),Boolean(e&&e!==t&&"dwa"===e[1]))}},function(t,e,n){"use strict";var r=n(6).iterator,i=n(16),o=n(122),s=n(42),a=n(7),u=n(2),c=n(11),l=n(17),f=Array.isArray,h=Function.prototype.call,p={configurable:!0,enumerable:!0,writable:!0,value:null},d=Object.defineProperty;t.exports=function(t){var e,n,g,b,y,v,m,_,w,S,E=arguments[1],k=arguments[2];if(t=Object(u(t)),c(E)&&a(E),this&&this!==Array&&o(this))e=this;else{if(!E){if(i(t))return 1!==(y=t.length)?Array.apply(null,t):(b=new Array(1),b[0]=t[0],b);if(f(t)){for(b=new Array(y=t.length),n=0;n=55296&&v<=56319&&(S+=t[++n]),S=E?h.call(E,k,S,g):S,e?(p.value=S,d(b,g,p)):b[g]=S,++g;y=g}if(void 0===y)for(y=s(t.length),e&&(b=new e(y)),n=0;n=55296&&e<=56319?n+this.__list__[this.__nextIndex__++]:n)})}),u(r.prototype,s.toStringTag,o("c","String Iterator"))},function(t,e,n){"use strict";var r,i=n(15),o=n(8),s=n(23),a=n(6).toStringTag,u=n(128),c=Object.defineProperties,l=s.prototype._unBind;r=t.exports=function(t,e){if(!(this instanceof r))return new r(t,e);s.call(this,t.__mapKeysData__,t),e&&u[e]||(e="key+value"),c(this,{__kind__:o("",e),__values__:o("w",t.__mapValuesData__)})},i&&i(r,s),r.prototype=Object.create(s.prototype,{constructor:o(r),_resolve:o(function(t){return"value"===this.__kind__?this.__values__[t]:"key"===this.__kind__?this.__list__[t]:[this.__list__[t],this.__values__[t]]}),_unBind:o(function(){this.__values__=null,l.call(this)}),toString:o(function(){return"[object Map Iterator]"})}),Object.defineProperty(r.prototype,a,o("c","Map Iterator"))},function(t,e,n){"use strict";t.exports=n(129)("key","value","key+value")},function(t,e,n){"use strict";var r=Array.prototype.forEach,i=Object.create;t.exports=function(t){var e=i(null);return r.call(arguments,function(t){e[t]=!0}),e}},function(t,e,n){"use strict";t.exports=function(){return"undefined"!=typeof Map&&"[object Map]"===Object.prototype.toString.call(new Map)}()},function(t,e,n){function r(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function i(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},n=t.name||"Function wrapped with `once`";return e.onceError=n+" shouldn't be called more than once",e.called=!1,e}var o=n(132);t.exports=o(r),t.exports.strict=o(i),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})})},function(t,e){function n(t,e){function r(){for(var e=new Array(arguments.length),n=0;n0)&&this[this._states[this._stateCounter]]()&&!this.error;)++this._stateCounter>=this._states.length&&(this._stateCounter=0);return this._list.length},r.prototype._parseHeader=function(){var t=this._list.readUInt8(0);return this.packet.cmd=u.types[t>>u.CMD_SHIFT],this.packet.retain=0!=(t&u.RETAIN_MASK),this.packet.qos=t>>u.QOS_SHIFT&u.QOS_MASK,this.packet.dup=0!=(t&u.DUP_MASK),this._list.consume(1),!0},r.prototype._parseLength=function(){for(var t,e=0,n=1,r=0,i=!0;e<5&&(t=this._list.readUInt8(e++),r+=n*(t&u.LENGTH_MASK),n*=128,0!=(t&u.LENGTH_FIN_MASK));)if(this._list.length<=e){i=!1;break}return i&&(this.packet.length=r,this._list.consume(e)),i},r.prototype._parsePayload=function(){var t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseMessageId();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":case"disconnect":break;default:this._emitError(new Error("Not supported"))}t=!0}return t},r.prototype._parseConnect=function(){var t,e,n,r,i,o,s={},a=this.packet;if(null===(t=this._parseString()))return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==t&&"MQIsdp"!==t)return this._emitError(new Error("Invalid protocolId"));if(a.protocolId=t,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(a.protocolVersion=this._list.readUInt8(this._pos),3!==a.protocolVersion&&4!==a.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(++this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(s.username=this._list.readUInt8(this._pos)&u.USERNAME_MASK,s.password=this._list.readUInt8(this._pos)&u.PASSWORD_MASK,s.will=this._list.readUInt8(this._pos)&u.WILL_FLAG_MASK,s.will&&(a.will={},a.will.retain=0!=(this._list.readUInt8(this._pos)&u.WILL_RETAIN_MASK),a.will.qos=(this._list.readUInt8(this._pos)&u.WILL_QOS_MASK)>>u.WILL_QOS_SHIFT),a.clean=0!=(this._list.readUInt8(this._pos)&u.CLEAN_SESSION_MASK),this._pos++,a.keepalive=this._parseNum(),-1===a.keepalive)return this._emitError(new Error("Packet too short"));if(null===(e=this._parseString()))return this._emitError(new Error("Packet too short"));if(a.clientId=e,s.will){if(null===(n=this._parseString()))return this._emitError(new Error("Cannot parse will topic"));if(a.will.topic=n,null===(r=this._parseBuffer()))return this._emitError(new Error("Cannot parse will payload"));a.will.payload=r}if(s.username){if(null===(o=this._parseString()))return this._emitError(new Error("Cannot parse username"));a.username=o}if(s.password){if(null===(i=this._parseBuffer()))return this._emitError(new Error("Cannot parse password"));a.password=i}return a},r.prototype._parseConnack=function(){var t=this.packet;return this._list.length<2?null:(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&u.SESSIONPRESENT_MASK),t.returnCode=this._list.readUInt8(this._pos),-1===t.returnCode?this._emitError(new Error("Cannot parse return code")):void 0)},r.prototype._parsePublish=function(){var t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));t.qos>0&&!this._parseMessageId()||(t.payload=this._list.slice(this._pos,t.length))},r.prototype._parseSubscribe=function(){var t,e,n=this.packet;if(1!==n.qos)return this._emitError(new Error("Wrong subscribe header"));if(n.subscriptions=[],this._parseMessageId())for(;this._posthis._list.length||r>this.packet.length?null:(e=this._list.toString("utf8",this._pos,r),this._pos+=n,e)},r.prototype._parseBuffer=function(){var t,e=this._parseNum(),n=e+this._pos;return-1===e||n>this._list.length||n>this.packet.length?null:(t=this._list.slice(this._pos,n),this._pos+=e,t)},r.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var t=this._list.readUInt16BE(this._pos);return this._pos+=2,t},r.prototype._newPacket=function(){return this.packet&&(this._list.consume(this.packet.length),this.emit("packet",this.packet)),this.packet=new a,!0},r.prototype._emitError=function(t){this.error=t,this.emit("error",t)},t.exports=r},function(t,e,n){function r(t){if(!(this instanceof r))return new r(t);if(this._bufs=[],this.length=0,"function"==typeof t){this._callback=t;var e=function(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",function(t){t.on("error",e)}),this.on("unpipe",function(t){t.removeListener("error",e)})}else this.append(t);i.call(this)}var i=n(136),o=n(137),s=n(4).Buffer;o.inherits(r,i),r.prototype._offset=function(t){var e,n=0,r=0;if(0===t)return[0,0];for(;rthis.length)&&(r=this.length),n>=this.length)return t||s.alloc(0);if(r<=0)return t||s.alloc(0);var i,o,a=!!t,u=this._offset(n),c=r-n,l=c,f=a&&e||0,h=u[1];if(0===n&&r==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:s.concat(this._bufs,this.length);for(o=0;oi)){this._bufs[o].copy(t,f,h,h+l);break}this._bufs[o].copy(t,f,h),f+=i,l-=i,h&&(h=0)}return t},r.prototype.shallowSlice=function(t,e){t=t||0,e=e||this.length,t<0&&(t+=this.length),e<0&&(e+=this.length);var n=this._offset(t),i=this._offset(e),o=this._bufs.slice(n[0],i[0]+1);return 0==i[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,i[1]),0!=n[1]&&(o[0]=o[0].slice(n[1])),new r(o)},r.prototype.toString=function(t,e,n){return this.slice(e,n).toString(t)},r.prototype.consume=function(t){for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},r.prototype.duplicate=function(){for(var t=0,e=new r;t=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(n)?r.showHidden=n:n&&e._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=i),a(r,t,r.depth)}function i(t,e){var n=r.styles[e];return n?"["+r.colors[n][0]+"m"+t+"["+r.colors[n][1]+"m":t}function o(t,e){return t}function s(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function a(t,n,r){if(t.customInspect&&n&&x(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,t);return v(i)||(i=a(t,i,r)),i}var o=u(t,n);if(o)return o;var d=Object.keys(n),g=s(d);if(t.showHidden&&(d=Object.getOwnPropertyNames(n)),k(n)&&(d.indexOf("message")>=0||d.indexOf("description")>=0))return c(n);if(0===d.length){if(x(n)){var b=n.name?": "+n.name:"";return t.stylize("[Function"+b+"]","special")}if(w(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return t.stylize(Date.prototype.toString.call(n),"date");if(k(n))return c(n)}var y="",m=!1,_=["{","}"];if(p(n)&&(m=!0,_=["[","]"]),x(n)){y=" [Function"+(n.name?": "+n.name:"")+"]"}if(w(n)&&(y=" "+RegExp.prototype.toString.call(n)),E(n)&&(y=" "+Date.prototype.toUTCString.call(n)),k(n)&&(y=" "+c(n)),0===d.length&&(!m||0==n.length))return _[0]+y+_[1];if(r<0)return w(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var S;return S=m?l(t,n,r,g,d):d.map(function(e){return f(t,n,r,g,e,m)}),t.seen.pop(),h(S,y,_)}function u(t,e){if(_(e))return t.stylize("undefined","undefined");if(v(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):d(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function c(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,n,r,i){for(var o=[],s=0,a=e.length;s-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n"))):u=t.stylize("[Circular]","special")),_(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+u}function h(t,e,n){var r=0;return t.reduce(function(t,e){return r++,e.indexOf("\n")>=0&&r++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function g(t){return null===t}function b(t){return null==t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return"symbol"==typeof t}function _(t){return void 0===t}function w(t){return S(t)&&"[object RegExp]"===I(t)}function S(t){return"object"==typeof t&&null!==t}function E(t){return S(t)&&"[object Date]"===I(t)}function k(t){return S(t)&&("[object Error]"===I(t)||t instanceof Error)}function x(t){return"function"==typeof t}function O(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function I(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}function A(){var t=new Date,e=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":");return[t.getDate(),U[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function C(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}function j(e){function n(){for(var n=[],r=0;r=o)return t;switch(t){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(t){return"[Circular]"}default:return t}}),a=i[n];n>8,0),e.writeUInt8(255&t,1),e}function i(){for(var t=0;t0){t=new Array(arguments.length-2);for(var e=0;e1&&(r=n[0]+"@",t=n[1]),t=t.replace(C,"."),r+a(t.split("."),e).join(".")}function c(t){for(var e,n,r=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function f(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:w}function h(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function p(t,e,n){var r=0;for(t=n?M(t/x):t>>1,t+=M(t/e);t>R*E>>1;r+=w)t=M(t/R);return M(r+(R+1)*t/(t+k))}function d(t){var e,n,r,i,o,a,u,c,h,d,g=[],b=t.length,y=0,v=I,m=O;for(n=t.lastIndexOf(T),n<0&&(n=0),r=0;r=128&&s("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i=b&&s("invalid-input"),c=f(t.charCodeAt(i++)),(c>=w||c>M((_-y)/a))&&s("overflow"),y+=c*a,h=u<=m?S:u>=m+E?E:u-m,!(cM(_/d)&&s("overflow"),a*=d;e=g.length+1,m=p(y-o,e,0==o),M(y/e)>_-v&&s("overflow"),v+=M(y/e),y%=e,g.splice(y++,0,v)}return l(g)}function g(t){var e,n,r,i,o,a,u,l,f,d,g,b,y,v,m,k=[];for(t=c(t),b=t.length,e=I,n=0,o=O,a=0;a=e&&gM((_-n)/y)&&s("overflow"),n+=(u-e)*y,e=u,a=0;a_&&s("overflow"),g==e){for(l=n,f=w;d=f<=o?S:f>=o+E?E:f-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=w-S,M=Math.floor,N=String.fromCharCode;m={version:"1.4.1",ucs2:{decode:c,encode:l},decode:d,encode:g,toASCII:y,toUnicode:b},void 0!==(i=function(){return m}.call(e,n,e,t))&&(t.exports=i)}()}).call(e,n(50)(t),n(3))},function(t,e,n){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){"use strict";e.decode=e.parse=n(147),e.encode=e.stringify=n(148)},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var l=0;l=0?(f=g.substr(0,b),h=g.substr(b+1)):(f=g,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),r(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function r(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r64)&&!/\s|\/|\\|\+|\*|#/gi.test(t))},encryptedStorage:function(){var t=this;return{get:function(e){return i.get(e)?JSON.parse(t.decrypt(i.get(e))):{}},set:function(e,n){return n="object"===(void 0===n?"undefined":r(n))?JSON.stringify(n):n,i.set(e,t.encrypt(n)),t}}},decrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)-s.charCodeAt(e%s.length))}).join("")},encrypt:function(t){return String(t).split("").map(function(t,e){return String.fromCharCode(t.charCodeAt(0)+s.charCodeAt(e%s.length))}).join("")},getAppDomain:function(t,e){return e?o.HOST_DEV:-1===o.EXCLUSIVE_APPIDS.indexOf(t)?t.replace("-demo","")+"."+o.HOST:o.HOST},generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},defaultDevice:function(t){var e=t.appId,i=t.userId,s=t.token,u=t.realtime,c=t.error;s=s||"disabled";var l="ALLOWED",f=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{type:null};"object"===(void 0===s?"undefined":r(s))?s=JSON.stringify(s):"DENIED"===s?(l=s,s="NOT_EXIST"):s.startsWith("NOT_SUPPORTED")&&(l=s,s="NOT_EXIST"),c&&(l="ERR",s="NOT_EXIST");var h={realtime:u,launchCount:+this.encryptedStorage().get(o.STORAGE_KEY).launchCount,launchTime:Date.now(),appId:e,userId:i,deviceToken:s,deviceType:"web",tokenStatus:l,tokenErr:c?{message:c.message,code:c.code}:null,deviceModel:a.name?a.name.toLowerCase():"NodeJS",osVersion:a.os.version,deviceManufacture:a.os.family,browserVersion:a.version,appVersion:n(157).version,subscriptions:o.DEFAULT_CHANNELS,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,connection:f.type};return"$omit_token"===s&&(delete h.deviceToken,delete h.tokenStatus,delete h.tokenErr),h},toTopicName:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"user",i=void 0,o=void 0;switch(r){case"user":var s=n.split("/");"public"===s[0]?(i=s[0],o=s[1]):(i=e,o=s[0]);break;case"publish":i="*"===e?"public":e,o=n;break;case"event":case"track":i=n,o=e||"+";break;default:throw new Error("Invalid topic type.")}return["app",t,r,i,o].join("/")},fromChabokChannel:function(t){var e=t.split("/"),n=void 0;switch(e.length){case 1:n="public/"+e[0];break;case 2:if("public"!==e[0]&&"private"!==e[0])throw new Error("Invalid channel name format, please read documentations.");n="public"===e[0]?"public/"+e[1]:e[1];break;default:throw new Error("Invalid channel name format, please read documentations.")}return n},toChabokMessage:function(t,e){var n=t.split("/"),r=n[3]+"/"+n[4];try{var i=JSON.parse(e);return i.channel=r,i}catch(t){return console.error("Invalid Chabok Payload ",e),e}},toEventMessage:function(t,e){var n=t.split("/"),r=n[1],i=n[3],o=n[4],s={appId:r,eventName:i,deviceId:o,receivedAt:Date.now()};try{return s.data=JSON.parse(e),s.createdAt=s.data.createdAt,s.id=s.data.id,s}catch(t){return console.error("Invalid Chabok event ",e),e}}};t.exports=u},function(t,e){!function(e,n){var r={version:"2.7.1",areas:{},apis:{},inherit:function(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e},stringify:function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)},parse:function(t){try{return JSON.parse(t)}catch(e){return t}},fn:function(t,e){r.storeAPI[t]=e;for(var n in r.apis)r.apis[n][t]=e},get:function(t,e){return t.getItem(e)},set:function(t,e,n){t.setItem(e,n)},remove:function(t,e){t.removeItem(e)},key:function(t,e){return t.key(e)},length:function(t){return t.length},clear:function(t){t.clear()},Store:function(t,e,n){var i=r.inherit(r.storeAPI,function(t,e,n){return 0===arguments.length?i.getAll():"function"==typeof e?i.transact(t,e,n):void 0!==e?i.set(t,e,n):"string"==typeof t||"number"==typeof t?i.get(t):t?i.setAll(t,e):i.clear()});i._id=t;try{e.setItem("_-bad-_","wolf"),i._area=e,e.removeItem("_-bad-_")}catch(t){}return i._area||(i._area=r.inherit(r.storageAPI,{items:{},name:"fake"})),i._ns=n||"",r.areas[t]||(r.areas[t]=i._area),r.apis[i._ns+i._id]||(r.apis[i._ns+i._id]=i),i},storeAPI:{area:function(t,e){var n=this[t];return n&&n.area||(n=r.Store(t,e,this._ns),this[t]||(this[t]=n)),n},namespace:function(t,e){if(!t)return this._ns?this._ns.substring(0,this._ns.length-1):"";var n=t,i=this[n];return i&&i.namespace||(i=r.Store(this._id,this._area,this._ns+n+"."),this[n]||(this[n]=i),e||i.area("session",r.areas.session)),i},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(t){return this._area.has?this._area.has(this._in(t)):!!(this._in(t)in this._area)},size:function(){return this.keys().length},each:function(t,e){for(var n=0,i=r.length(this._area);nr.length(this._area)&&(i--,n--)}return e||this},keys:function(t){return this.each(function(t,e){e.push(t)},t||[])},get:function(t,e){var n=r.get(this._area,this._in(t));return null!==n?r.parse(n):e||n},getAll:function(t){return this.each(function(t,e){e[t]=this.get(t)},t||{})},transact:function(t,e,n){var r=this.get(t,n),i=e(r);return this.set(t,void 0===i?r:i),this},set:function(t,e,n){var i=this.get(t);return null!=i&&!1===n?e:r.set(this._area,this._in(t),r.stringify(e),n)||i},setAll:function(t,e){var n,r;for(var i in t)r=t[i],this.set(i,r,e)!==r&&(n=!0);return n},add:function(t,e){var n=this.get(t);if(n instanceof Array)e=n.concat(e);else if(null!==n){var i=typeof n;if(i===typeof e&&"object"===i){for(var o in e)n[o]=e[o];e=n}else e=n+e}return r.set(this._area,this._in(t),r.stringify(e)),e},remove:function(t){var e=this.get(t);return r.remove(this._area,this._in(t)),e},clear:function(){return this._ns?this.each(function(t){r.remove(this._area,this._in(t))},1):r.clear(this._area),this},clearAll:function(){var t=this._area;for(var e in r.areas)r.areas.hasOwnProperty(e)&&(this._area=r.areas[e],this.clear());return this._area=t,this},_in:function(t){return"string"!=typeof t&&(t=r.stringify(t)),this._ns?this._ns+t:t},_out:function(t){return this._ns?t&&0===t.indexOf(this._ns)?t.substring(this._ns.length):void 0:t}},storageAPI:{length:0,has:function(t){return this.items.hasOwnProperty(t)},key:function(t){var e=0;for(var n in this.items)if(this.has(n)&&t===e++)return n},setItem:function(t,e){this.has(t)||this.length++,this.items[t]=e},removeItem:function(t){this.has(t)&&(delete this.items[t],this.length--)},getItem:function(t){return this.has(t)?this.items[t]:null},clear:function(){for(var t in this.items)this.removeItem(t)},toString:function(){return this.length+" items in "+this.name+"Storage"}}},i=r.Store("local",function(){try{return localStorage}catch(t){}}());i.local=i,i._=r,i.area("session",function(){try{return sessionStorage}catch(t){}}()),"function"==typeof n&&void 0!==n.amd?n("store2",[],function(){return i}):void 0!==t&&t.exports?t.exports=i:(e.store&&(r.conflict=e.store),e.store=i)}(this,this&&this.define)},function(t,e,n){(function(t,r){var i;(function(){"use strict";function o(t){return t=String(t),t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return e&&n&&/^Win/i.test(t)&&!/^Windows Phone /i.test(t)&&(r=r[/[\d.]+$/.exec(t)])&&(t="Windows "+r),t=String(t),e&&n&&(t=t.replace(RegExp(e,"i"),n)),t=u(t.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function a(t,e){var n=-1,r=t?t.length:0;if("number"==typeof r&&r>-1&&r<=w)for(;++n3&&"WebKit"||/\bOpera\b/.test(D)&&(/\bOPR\b/.test(t)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(B)&&"WebKit"||!B&&/\bMSIE\b/i.test(t)&&("Mac OS"==W?"Tasman":"Trident")||"WebKit"==B&&/\bPlayStation\b(?! Vita\b)/i.test(D)&&"NetFront")&&(B=[b]),"IE"==D&&(b=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(D+=" Mobile",W="Windows Phone "+(/\+$/.test(b)?b:b+".x"),M.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(D="IE Mobile",W="Windows Phone 8.x",M.unshift("desktop mode"),U||(U=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=D&&"Trident"==B&&(b=/\brv:([\d.]+)/.exec(t))&&(D&&M.push("identifying as "+D+(U?" "+U:"")),D="IE",U=b[1]),L){if(f(r,"global"))if(O&&(b=O.lang.System,R=b.getProperty("os.arch"),W=W||b.getProperty("os.name")+" "+b.getProperty("os.version")),I){try{U=r.require("ringo/engine").version.join("."),D="RingoJS"}catch(t){(b=r.system)&&b.global.system==r.system&&(D="Narwhal",W||(W=b[0].os||null))}D||(D="Rhino")}else"object"==typeof r.process&&!r.process.browser&&(b=r.process)&&("object"==typeof b.versions&&("string"==typeof b.versions.electron?(M.push("Node "+b.versions.node),D="Electron",U=b.versions.electron):"string"==typeof b.versions.nw&&(M.push("Chromium "+U,"Node "+b.versions.node),D="NW.js",U=b.versions.nw)),D||(D="Node.js",R=b.arch,W=b.platform,U=/[\d.]+/.exec(b.version),U=U?U[0]:null));else l(b=r.runtime)==_?(D="Adobe AIR",W=b.flash.system.Capabilities.os):l(b=r.phantom)==k?(D="PhantomJS",U=(b=b.version||null)&&b.major+"."+b.minor+"."+b.patch):"number"==typeof P.documentMode&&(b=/\bTrident\/(\d+)/i.exec(t))?(U=[U,P.documentMode],(b=+b[1]+4)!=U[1]&&(M.push("IE "+U[1]+" mode"),B&&(B[1]=""),U[1]=b),U="IE"==D?String(U[1].toFixed(1)):U[0]):"number"==typeof P.documentMode&&/^(?:Chrome|Firefox)\b/.test(D)&&(M.push("masking as "+D+" "+U),D="IE",U="11.0",B=["Trident"],W="Windows");W=W&&u(W)}if(U&&(b=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(U)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(L&&o.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(N=/b/i.test(b)?"beta":"alpha",U=U.replace(RegExp(b+"\\+?$"),"")+("beta"==N?A:T)+(/\d+\+?/.exec(b)||"")),"Fennec"==D||"Firefox"==D&&/\b(?:Android|Firefox OS)\b/.test(W))D="Firefox Mobile";else if("Maxthon"==D&&U)U=U.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(q))"Xbox 360"==q&&(W=null),"Xbox 360"==q&&/\bIEMobile\b/.test(t)&&M.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(D)&&(!D||q||/Browser|Mobi/.test(D))||"Windows CE"!=W&&!/Mobi/i.test(t))if("IE"==D&&L)try{null===r.external&&M.unshift("platform preview")}catch(t){M.unshift("embedded")}else(/\bBlackBerry\b/.test(q)||/\bBB10\b/.test(t))&&(b=(RegExp(q.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||U)?(b=[b,/BB10/.test(t)],W=(b[1]?(q=null,F="BlackBerry"):"Device Software")+" "+b[0],U=null):this!=c&&"Wii"!=q&&(L&&C||/Opera/.test(D)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==D&&/\bOS X (?:\d+\.){2,}/.test(W)||"IE"==D&&(W&&!/^Win/.test(W)&&U>5.5||/\bWindows XP\b/.test(W)&&U>8||8==U&&!/\bTrident\b/.test(t)))&&!S.test(b=g.call(c,t.replace(S,"")+";"))&&b.name&&(b="ing as "+b.name+((b=b.version)?" "+b:""),S.test(D)?(/\bIE\b/.test(b)&&"Mac OS"==W&&(W=null),b="identify"+b):(b="mask"+b,D=j?u(j.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(b)&&(W=null),L||(U=null)),B=["Presto"],M.push(b));else D+=" Mobile";(b=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(b=[parseFloat(b.replace(/\.(\d)$/,".0$1")),b],"Safari"==D&&"+"==b[1].slice(-1)?(D="WebKit Nightly",N="alpha",U=b[1].slice(0,-1)):U!=b[1]&&U!=(b[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(U=null),b[1]=(/\bChrome\/([\d.]+)/i.exec(t)||0)[1],537.36==b[0]&&537.36==b[2]&&parseFloat(b[1])>=28&&"WebKit"==B&&(B=["Blink"]),L&&(m||b[1])?(B&&(B[1]="like Chrome"),b=b[1]||(b=b[0],b<530?1:b<532?2:b<532.05?3:b<533?4:b<534.03?5:b<534.07?6:b<534.1?7:b<534.13?8:b<534.16?9:b<534.24?10:b<534.3?11:b<535.01?12:b<535.02?"13+":b<535.07?15:b<535.11?16:b<535.19?17:b<536.05?18:b<536.1?19:b<537.01?20:b<537.11?"21+":b<537.13?23:b<537.18?24:b<537.24?25:b<537.36?26:"Blink"!=B?"27":"28")):(B&&(B[1]="like Safari"),b=b[0],b=b<400?1:b<500?2:b<526?3:b<533?4:b<534?"4+":b<535?5:b<537?6:b<538?7:b<601?8:"8"),B&&(B[1]+=" "+(b+="number"==typeof b?".x":/[.+]/.test(b)?"":"+")),"Safari"==D&&(!U||parseInt(U)>45)&&(U=b)),"Opera"==D&&(b=/\bzbov|zvav$/.exec(W))?(D+=" ",M.unshift("desktop mode"),"zvav"==b?(D+="Mini",U=null):D+="Mobile",W=W.replace(RegExp(" *"+b+"$"),"")):"Safari"==D&&/\bChrome\b/.exec(B&&B[1])&&(M.unshift("desktop mode"),D="Chrome Mobile",U=null,/\bOS X\b/.test(W)?(F="Apple",W="iOS 4.3+"):W=null),U&&0==U.indexOf(b=/[\d.]+$/.exec(W))&&t.indexOf("/"+b+"-")>-1&&(W=d(W.replace(b,""))),B&&!/\b(?:Avant|Nook)\b/.test(D)&&(/Browser|Lunascape|Maxthon/.test(D)||"Safari"!=D&&/^iOS/.test(W)&&/\bSafari\b/.test(B[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(D)&&B[1])&&(b=B[B.length-1])&&M.push(b),M.length&&(M=["("+M.join("; ")+")"]),F&&q&&q.indexOf(F)<0&&M.push("on "+F),q&&M.push((/^on /.test(M[M.length-1])?"":"on ")+q),W&&(b=/ ([\d.+]+)$/.exec(W),v=b&&"/"==W.charAt(W.length-b[0].length-1),W={architecture:32,family:b&&!v?W.replace(b[0],""):W,version:b?b[1]:null,toString:function(){var t=this.version;return this.family+(t&&!v?" "+t:"")+(64==this.architecture?" 64-bit":"")}}),(b=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(R))&&!/\bi686\b/i.test(R)?(W&&(W.architecture=64,W.family=W.family.replace(RegExp(" *"+b),"")),D&&(/\bWOW64\b/i.test(t)||L&&/\w(?:86|32)$/.test(o.cpuClass||o.platform)&&!/\bWin64; x64\b/i.test(t))&&M.unshift("32-bit")):W&&/^OS X/.test(W.family)&&"Chrome"==D&&parseFloat(U)>=39&&(W.architecture=64),t||(t=null);var K={};return K.description=t,K.layout=B&&B[0],K.manufacturer=F,K.name=D,K.prerelease=N,K.product=q,K.ua=t,K.version=D&&U,K.os=W||{architecture:null,family:null,version:null,toString:function(){return"null"}},K.parse=g,K.toString=n,K.version&&M.unshift(U),K.name&&M.unshift(D),W&&D&&(W!=String(W).split(" ")[0]||W!=D.split(" ")[0]&&!q)&&M.push(q?"("+W+")":"on "+W),M.length&&(K.description=M.join(" ")),K}var b={function:!0,object:!0},y=b[typeof window]&&window||this,v=b[typeof e]&&e,m=b[typeof t]&&t&&!t.nodeType&&t,_=v&&m&&"object"==typeof r&&r;!_||_.global!==_&&_.window!==_&&_.self!==_||(y=_);var w=Math.pow(2,53)-1,S=/\bOpera/,E=Object.prototype,k=E.hasOwnProperty,x=E.toString,O=g();y.platform=O,void 0!==(i=function(){return O}.call(e,n,e,t))&&(t.exports=i)}).call(this)}).call(e,n(50)(t),n(3))},function(t,e){t.exports={name:"chabokpush",version:"1.2.2",description:"Chabok Javascript client for browsers, React-Native, Web Workers & Node.js",main:"dist/chabokpush.min.js",homepage:"http://chabokpush.com/",scripts:{build:"webpack --env build","demo-build":"webpack --env demo && node ./development.js","dev-build":"webpack --env demo && NODE_ENV=staging node ./development.js",dev:"webpack --progress --colors --watch --env dev",pretest:"webpack --env build",test:"mocha --compilers js:babel-core/register --colors ./test/*.spec.js -r ./test/setup.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js -r ./test/setup.js",release:"./release.sh"},repository:{type:"git",url:"https://github.com/chabokpush/chabok-client-js.git"},author:"ADP digital",license:"ISC",eslintConfig:{env:{browser:!0,node:!0},parserOptions:{ecmaVersion:6,sourceType:"module"},rules:{semi:2}},dependencies:{axios:"^0.17.1","es6-symbol":"^3.1.1","faye-websocket":"^0.11.1",mqtt:"^2.15.0",platform:"^1.3.4",shortid:"^2.2.8",store2:"^2.5.2"},devDependencies:{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-eslint":"^8.0.3","babel-loader":"^7.1.2","babel-plugin-add-module-exports":"0.2.1","babel-preset-es2015":"6.24.1",chai:"^4.1.2","copy-webpack-plugin":"^4.3.0",eslint:"^4.13.1","eslint-loader":"^1.9.0","html-webpack-plugin":"^2.30.1",mocha:"^4.0.1",webpack:"^3.10.0",yargs:"^10.0.3"}}},function(t,e,n){"use strict";t.exports=n(159)},function(t,e,n){"use strict";function r(e){return a.seed(e),t.exports}function i(e){return l=e,t.exports}function o(t){return void 0!==t&&a.characters(t),a.shuffled()}function s(){return u(l)}var a=n(18),u=n(161),c=n(165),l=n(166)||0;t.exports=s,t.exports.generate=s,t.exports.seed=r,t.exports.worker=i,t.exports.characters=o,t.exports.isValid=c},function(t,e,n){"use strict";function r(){return(o=(9301*o+49297)%233280)/233280}function i(t){o=t}var o=1;t.exports={nextValue:r,seed:i}},function(t,e,n){"use strict";function r(t){var e="",n=Math.floor(.001*(Date.now()-a));return n===o?i++:(i=0,o=n),e+=s(u),e+=s(t),i>0&&(e+=s(i)),e+=s(n)}var i,o,s=n(162),a=(n(18),1459707606518),u=6;t.exports=r},function(t,e,n){"use strict";function r(t){for(var e,n=0,r="";!e;)r+=s(o,i.get(),1),e=t - Chabok Web SDK Sample v1.2.1 + Chabok Web SDK Sample v1.2.2