backendless-rt-client
Version:
Backendless RT Client for connect to Backendless RT Server
15 lines • 121 kB
JavaScript
/*
* ********************************************************************************************************************
* Backendless RT Client for JavaScript. Version: 0.5.0
*
* Copyright 2012-2018 BACKENDLESS.COM. All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers,
* if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its
* suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret
* or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden
* unless prior written permission is obtained from Backendless.com.
* ********************************************************************************************************************
*/
/*! For license information please see backendless-rt-client.min.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BackendlessRTClient=e():t.BackendlessRTClient=e()}(self,(()=>(()=>{var t={969:t=>{function e(){}t.exports=function(t,n,r){var o=!1;return r=r||e,i.count=t,0===t?n():i;function i(t,e){if(i.count<=0)throw new Error("after called too many times");--i.count,t?(o=!0,n(t),n=r):0!==i.count||o||n(null,e)}}},3344:t=>{t.exports=function(t,e,n){var r=t.byteLength;if(e=e||0,n=n||r,t.slice)return t.slice(e,n);if(e<0&&(e+=r),n<0&&(n+=r),n>r&&(n=r),e>=r||e>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(n-e),s=e,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer}},842:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(4756)),i=r(n(9293)),s=r(n(7383)),a=r(n(4579)),c=r(n(3693)),u=n(3832),p=r(n(9027)),f=r(n(5595)),h=r(n(4459)),l=r(n(6753)),d=[u.NativeSocketEvents.CONNECTING,u.NativeSocketEvents.CONNECT,u.NativeSocketEvents.CONNECT_ERROR,u.NativeSocketEvents.DISCONNECT,u.NativeSocketEvents.RECONNECT_ATTEMPT];e.default=function(){return(0,a.default)((function t(e){var n=this;(0,s.default)(this,t),(0,c.default)(this,"onConnectError",(function(){n.subscriptions.hasActivity()||n.methods.hasActivity()||(n.disconnect("There are no active subscriptions and methods"),n.connectible=!0)})),(0,c.default)(this,"connectOnMethod",(function(t){return function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];if(n.connectible){var i=n.provideConnection();n.connected&&i.then((function(e){return e[t].apply(e,r)}))}}})),(0,c.default)(this,"on",this.connectOnMethod("on")),(0,c.default)(this,"emit",this.connectOnMethod("emit")),(0,c.default)(this,"onSessionDisconnect",(function(){n.subscriptions.stop(),n.methods.stop(),delete n.session,n.provideConnection()})),(0,c.default)(this,"emitSocketEventListeners",(function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];n.socketEvents[t]&&n.socketEvents[t].forEach((function(t){return t.apply(void 0,r)}))})),(0,c.default)(this,"addConnectingEventListener",(function(t){return n.addSocketEventListener(u.NativeSocketEvents.CONNECTING,t)})),(0,c.default)(this,"removeConnectingEventListener",(function(t){return n.removeSocketEventListener(u.NativeSocketEvents.CONNECTING,t)})),(0,c.default)(this,"addConnectEventListener",(function(t){return n.addSocketEventListener(u.NativeSocketEvents.CONNECT,t)})),(0,c.default)(this,"removeConnectEventListener",(function(t){return n.removeSocketEventListener(u.NativeSocketEvents.CONNECT,t)})),(0,c.default)(this,"addConnectErrorEventListener",(function(t){return n.addSocketEventListener(u.NativeSocketEvents.CONNECT_ERROR,t)})),(0,c.default)(this,"removeConnectErrorEventListener",(function(t){return n.removeSocketEventListener(u.NativeSocketEvents.CONNECT_ERROR,t)})),(0,c.default)(this,"addDisconnectEventListener",(function(t){return n.addSocketEventListener(u.NativeSocketEvents.DISCONNECT,t)})),(0,c.default)(this,"removeDisconnectEventListener",(function(t){return n.removeSocketEventListener(u.NativeSocketEvents.DISCONNECT,t)})),(0,c.default)(this,"addReconnectAttemptEventListener",(function(t){return n.addSocketEventListener(u.NativeSocketEvents.RECONNECT_ATTEMPT,t)})),(0,c.default)(this,"removeReconnectAttemptEventListener",(function(t){return n.removeSocketEventListener(u.NativeSocketEvents.RECONNECT_ATTEMPT,t)})),(0,c.default)(this,"removeConnectionListeners",(function(){d.forEach((function(t){return n.removeSocketEventListener(t)}))})),this.config=new p.default(e),this.resetSocketEvents();var r={onMessage:this.on.bind(this),emitMessage:this.emit.bind(this)};this.subscriptions=new f.default(r),this.methods=new h.default(r),this.connectible=!0,this.connected=!1}),[{key:"resetSocketEvents",value:function(){this.socketEvents={},this.addConnectErrorEventListener(this.onConnectError)}},{key:"setConfig",value:function(t){this.config.set(t),this.session&&(this.disconnect("Re-config socket connection"),this.connect())}},{key:"provideConnection",value:function(){var t=this;return this.session||(this.session=new l.default(this.config,this.emitSocketEventListeners,this.onSessionDisconnect),this.session.getSocket().then((function(){t.connected=!0,t.methods.initialize(),t.methods.restore(),t.subscriptions.initialize(),t.subscriptions.restore()}))),this.session.getSocket()}},{key:"getConnectionId",value:(t=(0,i.default)(o.default.mark((function t(){return o.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.session){t.next=4;break}return t.next=3,this.session.getConnectionId();case 3:return t.abrupt("return",t.sent);case 4:return t.abrupt("return",null);case 5:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"connect",value:function(){this.connectible=!0,this.provideConnection()}},{key:"disconnect",value:function(t){this.session&&(this.subscriptions.stop(),this.methods.stop(),this.session.terminate(),delete this.session,this.emitSocketEventListeners(u.NativeSocketEvents.DISCONNECT,t||"disconnected by client")),this.connectible=!1,this.connected=!1}},{key:"terminate",value:function(t){this.resetSocketEvents(),this.subscriptions.reset(),this.methods.reset(),this.disconnect(t||"Terminated by client")}},{key:"addSocketEventListener",value:function(t,e){return this.socketEvents[t]=this.socketEvents[t]||[],this.socketEvents[t].push(e),this}},{key:"removeSocketEventListener",value:function(t,e){return this.socketEvents[t]&&(this.socketEvents[t]=e?this.socketEvents[t].filter((function(t){return t!==e})):[],this.socketEvents[t].length||delete this.socketEvents[t]),this}}]);var t}()},9027:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(4756)),i=r(n(9293)),s=r(n(7383)),a=r(n(4579)),c=r(n(3738)),u=function(t){return void 0===t},p=function(t){return"function"==typeof t};e.default=function(){return(0,a.default)((function t(e){(0,s.default)(this,t),this.appId=null,this.debugMode=!1,this.connectQuery={},this.socketConfigTransform=null,this.hostResolver=null,this.socketConfig=null,this.set(e)}),[{key:"set",value:function(t){if(t){if(u(t.hostResolver)||p(t.hostResolver)&&(this.hostResolver=t.hostResolver),!u(t.appId)){if("string"!=typeof t.appId)throw new Error('"appId" must be String.');this.appId=t.appId}if(u(t.debugMode)||(this.debugMode=!!t.debugMode),!u(t.connectQuery))if(p(t.connectQuery))this.getConnectQuery=t.connectQuery;else{if(!function(t){return"object"===(0,c.default)(t)&&null!==t}(t.connectQuery))throw new Error('"connectQuery" must be Function or Object.');this.connectQuery=t.connectQuery}if(!u(t.socketConfigTransform)){if(!p(t.socketConfigTransform))throw new Error('"socketConfigTransform" must be Function.');this.socketConfigTransform=t.socketConfigTransform}}}},{key:"getConnectQuery",value:function(){return this.connectQuery}},{key:"getSocketConfig",value:function(){return this.socketConfig}},{key:"getHost",value:(e=(0,i.default)(o.default.mark((function t(){var e;return o.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!u(this.hostResolver)&&p(this.hostResolver)){t.next=2;break}throw new Error('"hostResolver" must be a function');case 2:return t.next=4,this.hostResolver();case 4:if((e=t.sent)&&"string"==typeof e){t.next=7;break}throw new Error('"hostResolver" must return a valid string');case 7:return t.abrupt("return",e);case 8:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"prepare",value:(t=(0,i.default)(o.default.mark((function t(){var e,n,r,i;return o.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getConnectQuery(),t.next=3,this.getHost();case 3:if(n=t.sent,r=this.appId?"".concat(n,"/").concat(this.appId):n,i=this.appId?"/".concat(this.appId):void 0,this.socketConfig={host:n,url:r,options:{path:i,query:e,forceNew:!0,autoConnect:!1,reconnection:!1}},!this.socketConfigTransform){t.next=14;break}return t.next=10,this.socketConfigTransform(this.socketConfig);case 10:if(t.t0=t.sent,t.t0){t.next=13;break}t.t0=this.socketConfig;case 13:this.socketConfig=t.t0;case 14:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,e}()},3832:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RTSubscriptionTypes=e.RTSocketEvents=e.RTMethodTypes=e.NativeSocketEvents=void 0;e.NativeSocketEvents={CONNECTING:"connecting",CONNECT:"connect",CONNECT_ERROR:"connect_error",CONNECT_TIMEOUT:"connect_timeout",DISCONNECT:"disconnect",RECONNECT:"reconnect",RECONNECT_ATTEMPT:"reconnect_attempt",RECONNECTING:"reconnecting",RECONNECT_ERROR:"reconnect_error",RECONNECT_FAILED:"reconnect_failed",ERROR:"error",PING:"ping",PONG:"pong"},e.RTSocketEvents={SUB_ON:"SUB_ON",SUB_OFF:"SUB_OFF",SUB_RES:"SUB_RES",SUB_READY:"SUB_READY",MET_REQ:"MET_REQ",MET_RES:"MET_RES"},e.RTSubscriptionTypes={OBJECTS_CHANGES:"OBJECTS_CHANGES",RELATIONS_CHANGES:"RELATIONS_CHANGES",PUB_SUB_CONNECT:"PUB_SUB_CONNECT",PUB_SUB_MESSAGES:"PUB_SUB_MESSAGES",PUB_SUB_COMMANDS:"PUB_SUB_COMMANDS",PUB_SUB_USERS:"PUB_SUB_USERS",RSO_CONNECT:"RSO_CONNECT",RSO_CHANGES:"RSO_CHANGES",RSO_CLEARED:"RSO_CLEARED",RSO_COMMANDS:"RSO_COMMANDS",RSO_INVOKE:"RSO_INVOKE",RSO_USERS:"RSO_USERS",LOGGING_MESSAGES:"LOGGING_MESSAGES",CONSOLE_MESSAGES:"CONSOLE_MESSAGES",DEVELOPER_MESSAGES:"DEVELOPER_MESSAGES",AUTOMATION_MESSAGES:"AUTOMATION_MESSAGES"},e.RTMethodTypes={SET_USER_TOKEN:"SET_USER_TOKEN",RSO_GET:"RSO_GET",RSO_SET:"RSO_SET",RSO_CLEAR:"RSO_CLEAR",RSO_COMMAND:"RSO_COMMAND",RSO_INVOKE:"RSO_INVOKE",PUB_SUB_COMMAND:"PUB_SUB_COMMAND"}},4497:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.RTScopeConnector=e.RTListeners=void 0;var o=r(n(3738)),i=r(n(5062)),s=r(n(842)),a=r(n(5620)),c=r(n(1403)),u="object"===("undefined"==typeof self?"undefined":(0,o.default)(self))&&self.self===self&&self||"object"===(void 0===n.g?"undefined":(0,o.default)(n.g))&&n.g.global===n.g&&n.g;s.default.Request=i.default,s.default.Listeners=a.default,s.default.ScopeConnector=c.default,u&&(u.BackendlessRTClient=s.default),t.exports=s.default;e.default=s.default,e.RTListeners=a.default,e.RTScopeConnector=c.default},5620:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(3693)),i=r(n(7383)),s=r(n(4579));function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){(0,o.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}e.default=function(){return(0,s.default)((function t(){(0,i.default)(this,t),this.subscriptions={},this.simpleListeners={}}),[{key:"addSubscription",value:function(t,e,n){var r=this,o=n.callback,i=n.onError,s=n.onReady,a=n.parser,u=n.params;this.subscriptions[t]=this.subscriptions[t]||[];var p=e(c(c({},u),this.getSubscriptionOptions()),{parser:a,onData:o,onError:i,onReady:s,onStop:function(){r.subscriptions[t]=r.subscriptions[t].filter((function(t){return t.subscription!==p}))}}),f={callback:o,params:u,subscription:p,stop:function(){return p.stop()}};return this.subscriptions[t].push(f),f}},{key:"getSubscriptionOptions",value:function(){return{}}},{key:"stopSubscription",value:function(t,e){var n=e.callback,r=e.matcher,o=this.subscriptions[t]=this.subscriptions[t]||[];r?o.forEach((function(t){r(t)&&t.subscription.stop()})):o.forEach((function(t){n&&t.callback!==n||t.subscription.stop()}))}},{key:"addSimpleListener",value:function(t,e){(this.simpleListeners[t]=this.simpleListeners[t]||[]).push(e)}},{key:"removeSimpleListener",value:function(t,e){this.simpleListeners[t]&&(this.simpleListeners[t]=e?this.simpleListeners[t].filter((function(t){return t!==e})):[])}},{key:"runSimpleListeners",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.simpleListeners[t]&&this.simpleListeners[t].forEach((function(t){return t.apply(void 0,n)}))}},{key:"removeAllListeners",value:function(){var t=this;Object.keys(this.subscriptions).forEach((function(e){t.subscriptions[e].forEach((function(t){return t.subscription.stop()}))})),this.simpleListeners={}}}])}()},4459:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(7383)),i=r(n(4579)),s=r(n(3693)),a=n(3832),c=r(n(5948)),u=function(t){return function(e){return this.send(t,e)}};e.default=function(){return(0,i.default)((function t(e){var n=this,r=e.onMessage,i=e.emitMessage;(0,o.default)(this,t),(0,s.default)(this,"sendRequest",(function(t){n.invocations[t]&&n.emitMessage(a.RTSocketEvents.MET_REQ,n.invocations[t].data)})),(0,s.default)(this,"onResponse",(function(t){var e=t.id,r=t.error,o=t.result;if(n.invocations[e]){var i=n.invocations[e];r?i.reject(r):i.resolve(o),delete n.invocations[e]}})),(0,s.default)(this,"setUserToken",u(a.RTMethodTypes.SET_USER_TOKEN).bind(this)),(0,s.default)(this,"sendPubSubCommand",u(a.RTMethodTypes.PUB_SUB_COMMAND).bind(this)),(0,s.default)(this,"getRSO",u(a.RTMethodTypes.RSO_GET).bind(this)),(0,s.default)(this,"setRSO",u(a.RTMethodTypes.RSO_SET).bind(this)),(0,s.default)(this,"clearRSO",u(a.RTMethodTypes.RSO_CLEAR).bind(this)),(0,s.default)(this,"sendRSOCommand",u(a.RTMethodTypes.RSO_COMMAND).bind(this)),(0,s.default)(this,"invokeRSOMethod",u(a.RTMethodTypes.RSO_INVOKE).bind(this)),this.onMessage=r,this.emitMessage=i,this.invocations={}}),[{key:"initialize",value:function(){this.onMessage(a.RTSocketEvents.MET_RES,this.onResponse)}},{key:"restore",value:function(){var t=this;Object.keys(this.invocations).forEach((function(e){t.sendRequest(e)}))}},{key:"stop",value:function(){}},{key:"reset",value:function(){this.invocations={}}},{key:"hasActivity",value:function(){return!!Object.keys(this.invocations).length}},{key:"send",value:function(t,e){var n=this,r=c.default.generateUID();return this.invocations[r]={data:{id:r,name:t,options:e}},this.sendRequest(r),new Promise((function(t,e){n.invocations[r].resolve=t,n.invocations[r].reject=e}))}}])}()},1403:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o,i,s,a,c,u,p,f=r(n(7383)),h=r(n(4579)),l=r(n(8452)),d=r(n(3072)),y=r(n(2395)),v=r(n(9511)),m=r(n(3693)),b=r(n(5871)),g=r(n(5620));function S(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function w(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?S(Object(n),!0).forEach((function(e){(0,m.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function E(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(E=function(){return!!t})()}var k="CONNECT",C="ERROR",O="COMMAND",R="USER_STATUS";e.default=(o=T(),i=T(),s=T(),a=T(),c=T(!0),p=function(t){function e(t){var n,r,o,i;return(0,f.default)(this,e),r=this,o=e,o=(0,d.default)(o),(n=(0,l.default)(r,E()?Reflect.construct(o,i||[],(0,d.default)(r).constructor):o.apply(r,i))).options=t,n.waitConnection=[],n.connect(),n}return(0,v.default)(e,t),(0,h.default)(e,[{key:"connectSubscriber",get:function(){return null}},{key:"commandSubscriber",get:function(){return null}},{key:"usersSubscriber",get:function(){return null}},{key:"commandSender",get:function(){return null}},{key:"connect",value:function(){var t=this;this.isConnected()||(this.connection=this.connectSubscriber(this.getScopeOptions(),{onError:function(e){return t.onError(e)},onReady:function(){return t.onConnect()},onStop:function(){return t.onDisconnect()}}))}},{key:"disconnect",value:function(){this.isConnected()&&this.connection.stop()}},{key:"isConnected",value:function(){return!!this.connection&&this.connection.isReady()}},{key:"getSubscriptionOptions",value:function(){return this.getScopeOptions()}},{key:"getScopeOptions",value:function(){return this.options}},{key:"onConnect",value:function(){this.waitConnection.forEach((function(t){return t()})),this.waitConnection=[],this.runSimpleListeners(k)}},{key:"onError",value:function(t){this.runSimpleListeners(C,t)}},{key:"onDisconnect",value:function(){this.connection=null}},{key:"removeAllListeners",value:function(){var t,n,r,o,i;return this.waitConnection=[],(t=e,n="removeAllListeners",r=this,o=3,i=(0,y.default)((0,d.default)(1&o?t.prototype:t),n,r),2&o&&"function"==typeof i?function(t){return i.apply(r,t)}:i)([]),this}},{key:"addConnectListener",value:function(t,e){return this.addSimpleListener(k,t),e&&this.addSimpleListener(C,e),this}},{key:"removeConnectListeners",value:function(t,e){return this.removeSimpleListener(k,t),e&&this.removeSimpleListener(C,e),this}},{key:"addCommandListener",value:function(t,e){return this.addSubscription(O,this.commandSubscriber,{callback:t,onError:e}),this}},{key:"removeCommandListeners",value:function(t){return this.stopSubscription(O,{callback:t}),this}},{key:"addUserStatusListener",value:function(t,e){return this.addSubscription(R,this.usersSubscriber,{callback:t,onError:e}),this}},{key:"removeUserStatusListeners",value:function(t){return this.stopSubscription(R,{callback:t}),this}},{key:"send",value:function(t,e){return this.commandSender(w(w({},this.getScopeOptions()),{},{type:t,data:e}))}}])}(g.default),(0,m.default)(p,"connectionRequired",T),u=p,(0,b.default)(u.prototype,"addCommandListener",[o],Object.getOwnPropertyDescriptor(u.prototype,"addCommandListener"),u.prototype),(0,b.default)(u.prototype,"removeCommandListeners",[i],Object.getOwnPropertyDescriptor(u.prototype,"removeCommandListeners"),u.prototype),(0,b.default)(u.prototype,"addUserStatusListener",[s],Object.getOwnPropertyDescriptor(u.prototype,"addUserStatusListener"),u.prototype),(0,b.default)(u.prototype,"removeUserStatusListeners",[a],Object.getOwnPropertyDescriptor(u.prototype,"removeUserStatusListeners"),u.prototype),(0,b.default)(u.prototype,"send",[c],Object.getOwnPropertyDescriptor(u.prototype,"send"),u.prototype),u);function T(t){return function(e,n,r){var o=r.value;return r.value=function(){var e=arguments,n=this,r=function(){return o.apply(n,e)};return this.isConnected()?r():t?new Promise((function(t,e){return n.waitConnection.push((function(){return r().then(t,e)}))})):(this.waitConnection.push(r),this)},r}}},6753:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(4756)),i=r(n(9293)),s=r(n(7383)),a=r(n(4579)),c=n(3832),u=r(n(5064));e.default=function(){return(0,a.default)((function t(e,n,r){(0,s.default)(this,t),this.config=e,this.dispatch=n,this.onDisconnect=r,this.connectAttempt=0,this.socketPromise=this.connect()}),[{key:"terminate",value:function(){this.terminated||(this.terminated=!0,this.dispatch=function(){},this.socketPromise.then((function(t){t&&t.close()})))}},{key:"getSocket",value:function(){var t=this;return this.socketPromise.then((function(e){return t.terminated?new Promise((function(){})):e}))}},{key:"getConnectionId",value:(t=(0,i.default)(o.default.mark((function t(){var e,n;return o.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSocket();case 2:return n=t.sent,t.abrupt("return",(null==n||null===(e=n.ioSocket)||void 0===e||null===(e=e.io)||void 0===e||null===(e=e.engine)||void 0===e?void 0:e.id)||null);case 4:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"connect",value:function(){var t=this;if(!this.terminated){this.connectAttempt=this.connectAttempt+1;var e=this.getNextReconnectionTimeout();return this.onConnecting(),this.connectAttempt>1&&this.onReconnectAttempt(this.connectAttempt-1,e),u.default.connect(this.config,this.onSocketDisconnect.bind(this)).then((function(e){return t.connectAttempt=0,t.onConnect(),e})).catch((function(n){if(t.onConnectError(n),!t.terminated)return(r=e,new Promise((function(t){return setTimeout(t,r)}))).then((function(){return t.connect()}));var r}))}}},{key:"getNextReconnectionTimeout",value:function(){var t=Math.ceil(this.connectAttempt/10),e=200*Math.pow(2,t);return Math.min(e,6e4)}},{key:"onSocketDisconnect",value:function(t){this.dispatch(c.NativeSocketEvents.DISCONNECT,t),this.terminated||(this.terminate(),this.onDisconnect())}},{key:"onConnecting",value:function(){this.dispatch(c.NativeSocketEvents.CONNECTING)}},{key:"onConnect",value:function(){this.dispatch(c.NativeSocketEvents.CONNECT)}},{key:"onConnectError",value:function(t){this.dispatch(c.NativeSocketEvents.CONNECT_ERROR,t&&t.message||t)}},{key:"onReconnectAttempt",value:function(t,e){this.dispatch(c.NativeSocketEvents.RECONNECT_ATTEMPT,t,e)}}]);var t}()},5174:(t,e,n)=>{"use strict";var r=n(5971);function o(){}function i(t){var n=""+t.type;return e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(n+=t.nsp+","),null!=t.id&&(n+=t.id),null!=t.data&&(n+=JSON.stringify(t.data)),n}function s(){}function a(){return{type:e.ERROR,data:"parser error"}}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=o,e.Decoder=s,o.prototype.encode=function(t,e){e([i(t)])},r(s.prototype),s.prototype.add=function(t){if("string"!=typeof t)throw new Error("Unknown type: "+t);this.emit("decoded",function(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return a();if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n;){if(","===(s=t.charAt(n)))break;if(r.nsp+=s,n===t.length)break}else r.nsp="/";var i=t.charAt(n+1);if(""!==i&&Number(i)==i){for(r.id="";++n;){var s;if(null==(s=t.charAt(n))||Number(s)!=s){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}t.charAt(++n)&&(r=function(t,e){try{t.data=JSON.parse(e)}catch(t){return a()}return t}(r,t.substr(n)));return r}(t))},s.prototype.destroy=function(){}},5064:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(7383)),i=r(n(4579)),s=n(3832);e.default=function(){function t(e,r){(0,o.default)(this,t);var i=n(7698);this.config=e,this.events={};var s=e.getSocketConfig(),a=s.url,c=s.options;this.ioSocket=i(a,c)}return(0,i.default)(t,[{key:"connect",value:function(){this.ioSocket.connect()}},{key:"close",value:function(){this.log("log","close socket"),this.events={},this.ioSocket.off(),this.ioSocket.close()}},{key:"on",value:function(t,e){var n=this;this.events[t]||this.ioSocket.on(t,(function(e){return n.onEvent(t,e)})),this.events[t]=this.events[t]||[],this.events[t].push(e)}},{key:"off",value:function(t,e){this.events[t]=e?this.events[t].filter((function(t){return t!==e})):[],this.events[t].length||delete this.events[t],this.events[t]||this.ioSocket.off(t)}},{key:"onEvent",value:function(t,e){this.logMessage("FROM SERVER",t,e),this.events[t]&&this.events[t].forEach((function(t){return t(e)}))}},{key:"emit",value:function(t,e){this.logMessage("TO SERVER",t,e),this.ioSocket.emit(t,e)}},{key:"log",value:function(t){if(this.config.debugMode){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=console)[t].apply(e,["[RT Client]:"].concat(r))}}},{key:"logMessage",value:function(t,e,n){this.log("log","[".concat(t,"] - [event: ").concat(e,"] - arguments: ").concat(JSON.stringify(n)," "))}}],[{key:"connect",value:function(e,n){return Promise.resolve().then((function(){return e.prepare()})).then((function(){return new Promise((function(n,r){var o=new t(e);function i(t){o.log("error","received one of [CONNECT_ERROR,CONNECT_TIMEOUT] socket event while connecting",t),a(t)}function a(t){o.log("log","close and reject socket with error:",t),o.close(),r(t)}o.on(s.NativeSocketEvents.CONNECT,(function(){o.log("log","socket connected"),n(o)})),o.on(s.NativeSocketEvents.CONNECT_ERROR,i),o.on(s.NativeSocketEvents.CONNECT_TIMEOUT,i),o.on(s.NativeSocketEvents.ERROR,(function(t){o.log("error","received ERROR event while connecting",t),a(t)})),o.connect()}))})).then((function(t){return t.on(s.NativeSocketEvents.DISCONNECT,n),t.on(s.NativeSocketEvents.ERROR,n),t}))}}])}()},5595:(t,e,n)=>{"use strict";var r=n(4994);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=r(n(7383)),i=r(n(4579)),s=r(n(3693)),a=n(3832),c=r(n(5948)),u=function(t){return function(e,n){return this.subscribe(t,e,n)}};e.default=function(){return(0,i.default)((function t(e){var n=e.onMessage,r=e.emitMessage;(0,o.default)(this,t),(0,s.default)(this,"onObjectsChanges",u(a.RTSubscriptionTypes.OBJECTS_CHANGES).bind(this)),(0,s.default)(this,"onRelationsChanges",u(a.RTSubscriptionTypes.RELATIONS_CHANGES).bind(this)),(0,s.default)(this,"connectToPubSub",u(a.RTSubscriptionTypes.PUB_SUB_CONNECT).bind(this)),(0,s.default)(this,"onPubSubMessage",u(a.RTSubscriptionTypes.PUB_SUB_MESSAGES).bind(this)),(0,s.default)(this,"onPubSubCommand",u(a.RTSubscriptionTypes.PUB_SUB_COMMANDS).bind(this)),(0,s.default)(this,"onPubSubUserStatus",u(a.RTSubscriptionTypes.PUB_SUB_USERS).bind(this)),(0,s.default)(this,"connectToRSO",u(a.RTSubscriptionTypes.RSO_CONNECT).bind(this)),(0,s.default)(this,"onRSOChanges",u(a.RTSubscriptionTypes.RSO_CHANGES).bind(this)),(0,s.default)(this,"onRSOClear",u(a.RTSubscriptionTypes.RSO_CLEARED).bind(this)),(0,s.default)(this,"onRSOCommand",u(a.RTSubscriptionTypes.RSO_COMMANDS).bind(this)),(0,s.default)(this,"onRSOInvoke",u(a.RTSubscriptionTypes.RSO_INVOKE).bind(this)),(0,s.default)(this,"onRSOUserStatus",u(a.RTSubscriptionTypes.RSO_USERS).bind(this)),(0,s.default)(this,"onLoggingMessages",u(a.RTSubscriptionTypes.LOGGING_MESSAGES).bind(this)),(0,s.default)(this,"onConsoleMessages",u(a.RTSubscriptionTypes.CONSOLE_MESSAGES).bind(this)),(0,s.default)(this,"onDeveloperMessage",u(a.RTSubscriptionTypes.DEVELOPER_MESSAGES).bind(this)),(0,s.default)(this,"onAutomationLoggingMessages",u(a.RTSubscriptionTypes.AUTOMATION_MESSAGES).bind(this)),this.onMessage=n,this.emitMessage=r,this.subscriptions={}}),[{key:"initialize",value:function(){var t=this;this.onMessage(a.RTSocketEvents.SUB_READY,(function(e){return t.onSubscriptionReady(e)})),this.onMessage(a.RTSocketEvents.SUB_RES,(function(e){return t.onSubscriptionResponse(e)}))}},{key:"stop",value:function(){var t=this;Object.keys(this.subscriptions).forEach((function(e){t.subscriptions[e].ready=!1}))}},{key:"reset",value:function(){var t=this;Object.keys(this.subscriptions).forEach((function(e){return t.stopSubscription(e)}))}},{key:"restore",value:function(){var t=this;Object.keys(this.subscriptions).forEach((function(e){t.startSubscription(e)}))}},{key:"hasActivity",value:function(){return!!Object.keys(this.subscriptions).length}},{key:"subscribe",value:function(t,e,n){var r=this,o=n.parser,i=n.onData,s=n.onError,a=n.onStop,u=n.onReady,p=c.default.generateUID();return this.subscriptions[p]={data:{id:p,name:t,options:e},ready:!1,parser:o,onData:i,onError:s,onStop:a,onReady:u},this.startSubscription(p),{isReady:function(){return!!r.subscriptions[p]&&r.subscriptions[p].ready},stop:function(){r.subscriptions[p]&&r.offSubscription(p)}}}},{key:"startSubscription",value:function(t){var e=this.subscriptions[t];this.emitMessage(a.RTSocketEvents.SUB_ON,e.data)}},{key:"stopSubscription",value:function(t){var e=this.subscriptions[t];e&&(e.onStop&&e.onStop(),delete this.subscriptions[t])}},{key:"offSubscription",value:function(t){this.subscriptions[t]&&(this.emitMessage(a.RTSocketEvents.SUB_OFF,{id:t}),this.stopSubscription(t))}},{key:"onSubscriptionReady",value:function(t){var e=t.id,n=this.subscriptions[e];n&&!n.ready&&(n.ready=!0,n.onReady&&n.onReady())}},{key:"onSubscriptionResponse",value:function(t){var e=t.id,n=t.data,r=t.error,o=this.subscriptions[e];o&&(r?(o.onError&&o.onError(r),this.stopSubscription(e)):(o.ready||(o.ready=!0,o.onReady&&o.onReady()),o.onData&&("function"==typeof o.parser&&(n=o.parser(n)),o.onData(n))))}}])}()},5948:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r={generateUID:function(){for(var t="",e=0;e<8;e++)t+=n.charAt(Math.floor(62*Math.random()));return t+Date.now()}};e.default=r},5062:function(t,e){var n,r;n="undefined"!=typeof self?self:this,r=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},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,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";(function(t){function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.castArray=void 0,e.ensureEncoding=function(t){try{var e=new URL(t);return e.origin+p(e.pathname)+e.search}catch(e){return p(t)}},e.getFormData=s,e.isStream=e.isObject=e.isNodeJS=e.isFormData=e.isBrowser=void 0,e.setFormData=function(t){i=t},e.castArray=function(t){return Array.isArray(t)?t:[t]},e.isObject=function(t){return null!=t&&"object"===r(t)},e.isFormData=function(t){return!!t&&(t instanceof s()||t&&t.constructor&&0===t.constructor.toString().trim().indexOf("function FormData"))},e.isStream=function(t){return t instanceof n(6).Stream};var o=e.isNodeJS=function(){return void 0!==t&&null!=t.versions&&null!=t.versions.node},i=(e.isBrowser=function(){return"undefined"!=typeof window&&void 0!==window.document},null);function s(){return i||(o()||"undefined"==typeof FormData?n(7):FormData)}var a=["%40","%3A","%2F"];function c(t,e){var n=e[0];return n?t.split(n).map((function(t){return c(t,e.slice(1))})).join(n):encodeURI(t)}function u(t){return t===decodeURI(t)?c(t,a):t}function p(t){return t.endsWith("/")&&(t=t.slice(0,-1)),t.split("/").map(u).join("/")}}).call(e,n(5))},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e,n){"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.Request=void 0;var o,i=n(12),s=(o=n(13))&&o.__esModule?o:{default:o},a=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==r(t)&&"function"!=typeof t)return{default:t};var n=p(e);if(n&&n.has(t))return n.get(t);var o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(o,s,a):o[s]=t[s]}return o.default=t,n&&n.set(t,o),o}(n(14)),c=n(0),u=n(15);function p(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(p=function(t){return t?n:e})(t)}function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?f(Object(n),!0).forEach((function(e){l(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function l(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function y(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function m(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,o=b(t);if(e){var i=b(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,n)}}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}var g="Content-Type",S="done";function w(t){try{return h(h({},t),{},{body:JSON.parse(t.body)})}catch(e){return t}}function E(t){if(t.status>=200&&t.status<300)return t;throw new u.ResponseError(t)}e.Request=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}(s,t);var e,n,r,o=m(s);function s(t,e,n){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(r=o.call(this)).method=e,r.path=(0,c.ensureEncoding)(t),r.body=n,r.tags=void 0,r.unwrap=!0,r.cacheTTL=0,r.headers={},r.queryParams={},r.encoding="utf8",r.timeout=0,r.withCredentials=null,r}return e=s,n=[{key:"set",value:function(t,e){if((0,c.isObject)(t))for(var n in t)this.set(n,t[n]);else void 0!==e&&(this.headers[t]=e);return this}},{key:"cacheTags",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.tags=e,this}},{key:"query",value:function(t){return Object.assign(this.queryParams,t),this}},{key:"form",value:function(t){if(t){var e=s.FormData;if(t instanceof e)this.body=t;else{var n=new e,r=function(e){e&&(0,c.castArray)(t[e]).forEach((function(t){t&&t.hasOwnProperty("value")&&t.hasOwnProperty("options")?n.append(e,t.value,t.options):n.append(e,t)}))};for(var o in t)r(o);this.body=n}}return this}},{key:"useCache",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:15e3;return this.cacheTTL=t,this}},{key:"resetCache",value:function(t){return t&&this.tags&&i.cache.deleteByTags(this.tags),this}},{key:"type",value:function(t){return this.set(g,t),this}},{key:"unwrapBody",value:function(t){return this.unwrap=t,this}},{key:"setEncoding",value:function(t){return this.encoding=t,this}},{key:"setWithCredentials",value:function(t){return this.withCredentials=t,this}},{key:"setTimeout",value:function(t){return this.timeout=t,this}},{key:"send",value:function(t){var e=this;this.emit("request",this);var n=this.path,r=a.stringify(this.queryParams);if(r&&(n+="?"+r),this.cacheTTL){var o=i.cache.get(n);if(void 0!==o)return Promise.resolve(o)}this.headers[g]||!(0,c.isObject)(t)||(0,c.isFormData)(t)||this.type("application/json"),t&&(t="application/json"===this.headers[g]&&"string"!=typeof t?JSON.stringify(t):t),s.verbose&&console.log(this.method.toUpperCase(),decodeURIComponent(n),t,this.headers);var u="boolean"==typeof this.withCredentials?this.withCredentials:s.withCredentials,p=s.send(n,this.method.toUpperCase(),this.headers,t,this.encoding,this.timeout,u).then(w).then(E).then((function(t){return e.unwrap?t.body:t})).then((function(t){return e.cacheTTL&&i.cache.set(n,t,e.tags,e.cacheTTL),t})).then((function(t){return e.tags&&"get"!==e.method&&i.cache.deleteByTags(e.tags),t}));return p.then((function(t){e.emit("response",t),e.emit(S,null,t)})).catch((function(t){e.emit("error",t),e.emit(S,t)})),p}},{key:"then",value:function(t,e){return this.promise=this.promise||this.send(this.body),this.promise.then(t,e)}},{key:"catch",value:function(t){return this.promise=this.promise||this.send(this.body),this.promise.catch(t)}}],n&&d(e.prototype,n),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),s}(s.default)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=n(4),o=n(11),i=n(2),s=n(0);Object.defineProperty(i.Request,"FormData",{get:function(){return(0,s.getFormData)()},set:function(t){(0,s.setFormData)(t)}}),i.Request.XMLHttpRequest="undefined"!=typeof XMLHttpRequest?XMLHttpRequest:void 0,i.Request.send=function(t,e,n,s,a,c,u){return(void 0!==i.Request.XMLHttpRequest?o.sendXmlHttpRequest:r.sendNodeAPIRequest)(t,e,n,s,a,c,u)},i.Request.verbose=!1,i.Request.withCredentials=!1,i.Request.methods=["get","post","put","patch","delete"],i.Request.methods.forEach((function(t){i.Request[t]=function(e,n){return new i.Request(e,t,n)}})),(e=t.exports=i.Request).default=i.Request},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sendNodeAPIRequest=function(t,e,o,i,s,a,c){return new Promise((function(u,p){var f=n(8).parse(t),h=(0,r.isFormData)(i)&&i,l=f.pathname.endsWith("/")?f.pathname.slice(0,-1):f.pathname,d="https:"===f.protocol,y={host:f.hostname,port:f.port||(d?443:80),path:l+(f.search||""),method:e,headers:o,timeout:a};"boolean"==typeof c&&(y.withCredentials=c);var v=function(){var t=n(1).Buffer,e=n(d?9:10).request(y,(function(e){var n=[],r=[],o=0,i="",a=e.statusCode,c=e.statusMessage,f=e.headers;e.on("data",(function(e){t.isBuffer(e)?e.length&&(o+=e.length,r.push(e)):n.push(e)})),e.on("end",(function(){o?(i=t.concat(r,o),null!=s&&(i=i.toString(s))):n.length&&(i=n.join()),u({status:a,statusText:c,headers:f,body:i})})),e.on("error",p)}));if(e.on("error",p),e.on("timeout",(function(){e.destroy(new Error("Connection aborted due to timeout"))})),i){if((0,r.isStream)(i))return void i.pipe(e);e.write(i)}e.end()};if(h)Object.assign(y.headers,h.getHeaders()),h.getLength((function(t,e){t||isNaN(e)||(y.headers["content-length"]=e),v()}));else{if(i&&!y.headers["content-length"]){var m=n(1).Buffer;y.headers["content-length"]=m.byteLength(i)}v()}}))};var r=n(0)},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var c,u=[],p=!1,f=-1;function h(){p&&c&&(p=!1,c.length?u=c.concat(u):f=-1,u.length&&l())}function l(){if(!p){var t=a(h);p=!0;for(var e=u.length;e;){for(c=u,u=[];++f<e;)c&&c[f].run();f=-1,e=u.length}c=null,p=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new d(t,e)),1!==u.length||p||a(l)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e){throw new Error('This Backendless JS SDK assembly is not intended for Node.js environment. You should use "lib" folder modules instead. For any questions please contact as at http://support.backendless.com/')},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sendXmlHttpRequest=function(t,e,n,o,i,s,a){return new Promise((function(c,u){var p=new r.Request.XMLHttpRequest;p.timeout=s,i||(p.responseType="arraybuffer"),p.open(e.toUpperCase(),t,!0),"boolean"==typeof a&&(p.withCredentials=a),p.onload=function(){var t,e,n=(t=p.getAllResponseHeaders(),e={},t?(t.split("\n").forEach((function(t){var n=t.indexOf(":"),r=t.substr(0,n).trim(),o=t.substr(n+1).trim();r&&(e[r]=e[r]?e[r]+", "+o:o)})),e):e),r=p,o={status:r.status,statusText:r.statusText,headers:n};"utf8"===i?o.body=p.response||p.responseText:p.response&&(o.body=new Uint8Array(p.response)),c(o),p=null},p.onerror=function(){u(new Error("Network Error")),p=null},p.ontimeout=function(){u(new Error("Connection aborted due to timeout")),p=null},Object.keys(n).forEach((function(t){p.setRequestHeader(t,n[t])})),p.send(o)}))};var r=n(2)},function(t,e,n){"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,s,a=[],c=!0,u=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=s(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}function s(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,s=void 0,s=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===r(s)?s:String(s)),o)}var i,s}Object.defineProperty(e,"__esModule",{value:!0}),e.cache=void 0;var u=function(){return(new Date).getTime()},p=function(t,e){return!!t.find((function(t){return e.find((function(e){return function(t,e){var n=t==e;return!n&&t instanceof RegExp&&(n=t.test(e)),!n&&e instanceof RegExp&&(n=e.test(t)),n}(t,e)}))}))},f=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setFlushInterval(e),this.map=new Map}var e,n,r;return e=t,n=[{key:"setFlushInterval",value:function(t){this.flushInterval=t,this.flushTimer&&(clearInterval(this.flushTimer),delete this.flushTimer)}},{key:"get",value:function(t){var e=this.map.get(t);if(e){if(e.ttl>u())return e.value;this.map.delete(t)}}},{key:"set",value:function(t,e,n,r){this.map.set(t,function(t,e,n){return{value:t,tags:e,ttl:n}}(e,n,u()+r)),this.flushInterval&&!this.flushTimer&&(this.flushTimer=setInterval(this.flush.bind(this),this.flushInterval),this.flushTimer.unref&&this.flushTimer.unref())}},{key:"delete",value:function(t){this.map.delete(t)}},{key:"deleteAll",value:function(){var t,e=i(this.map);try{for(e.s();!(t=e.n()).done;){var n=o(t.value,1)[0];this.delete(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:"deleteByTags",value:function(t){var e,n=i(this.map);try{for(n.s();!(e=n.n()).done;){var r=o(e.value,2),s=r[0],a=r[1];a.tags&&p(t,a.tags)&&this.delete(s)}}catch(t){n.e(t)}finally{n.f()}}},{key:"flush",value:function(){var t,e=u(),n=i(this.map);try{for(n.s();!(t=n.n()).done;){var r=o(t.value,2),s=r[0];r[1].ttl<e&&this.delete(s)}}catch(t){n.e(t)}finally{n.f()}}}],n&&c(e.prototype,n),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.cache=new f(6e4)},function(t,e,n){"use strict";function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,s=void 0,s=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===r(s)?s:String(s)),o)}var i,s}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.events={}}var e,n,r;return e=t,n=[{key:"on",value:function(t,e){return this.events[t]=this.events[t]||[],this.events[t].push(e),this}},{key:"off",value:function(t,e){return t?this.events[t]&&(e?this.events[t]=this.events[t].filter((function(t){return t!==e})):delete this.events[t]):this.events={},this}},{key:"emit",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.events[t]&&this.events[t].forEach((fu