UNPKG

jsforce

Version:

Salesforce API Library for JavaScript

4 lines (3 loc) 48.1 kB
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e=e.jsforce||(e.jsforce={}),e=e.modules||(e.modules={}),e=e.api||(e.api={}),e.Streaming=t()}}(function(){return function(){function t(e,n,i){function s(o,c){if(!n[o]){if(!e[o]){var a="function"==typeof require&&require;if(!c&&a)return a(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return s(n||t)},l,l.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}return t}()({1:[function(t,e,n){var i={};i.AuthFailure=function(t){this.incoming=function(e,n){"/meta/connect"!==e.channel&&"/meta/handshake"!==e.channel||!e.advice||"none"!=e.advice.reconnect?n(e):t(e)}},i.Replay=function(t,e){var n="replay",i=null!=e,s=e,r=t;this.setExtensionEnabled=function(t){i=t},this.setReplay=function(t){s=parseInt(t,10)},this.setChannel=function(t){r=t},this.incoming=function(t,e){"/meta/handshake"===t.channel?t.ext&&1==t.ext[n]&&(i=!0):t.channel===r&&t.data&&t.data.event&&t.data.event.replayId&&(s=t.data.event.replayId),e(t)},this.outgoing=function(t,e){if("/meta/subscribe"===t.channel&&i){t.ext||(t.ext={});var o={};o[r]=s,t.ext[n]=o}e(t)}},e.exports=i},{}],2:[function(t,e,n){"use strict";var i=window.jsforce.require("events"),s=window.jsforce.require("inherits"),r=window.jsforce.require("lodash/core"),o=t("faye"),c=t("./streaming-extension"),a=window.jsforce.require("./core"),u=function(t,e){this._streaming=t,this.name=e};u.prototype.subscribe=function(t){return this._streaming.subscribe(this.name,t)},u.prototype.unsubscribe=function(t){return this._streaming.unsubscribe(this.name,t),this};var l=function(t,e){this._streaming=t,this._name=e};l.prototype.subscribe=function(t){return this._streaming.subscribe(this._name,t)},l.prototype.unsubscribe=function(t){return this._streaming.unsubscribe(this._name,t),this},l.prototype.push=function(t,e){var n=r.isArray(t);t=n?t:[t];var i=this._streaming._conn;return this._id||(this._id=i.sobject("StreamingChannel").findOne({Name:this._name},"Id").then(function(t){return t.Id})),this._id.then(function(e){var n="/sobjects/StreamingChannel/"+e+"/push";return i.requestPost(n,{pushEvents:t})}).then(function(t){return n?t:t[0]}).thenCall(e)};var h=function(t){this._conn=t};s(h,i.EventEmitter),h.prototype._createClient=function(t,e){var n="string"==typeof t&&0===t.indexOf("/u/"),i=[this._conn.instanceUrl,"cometd"+(n===!0&&"36.0"===this._conn.version?"/replay":""),this._conn.version].join("/"),s=new o.Client(i,{});return s.setHeader("Authorization","OAuth "+this._conn.accessToken),e instanceof Array&&e.forEach(function(t){s.addExtension(t)}),s._dispatcher.getConnectionTypes().indexOf("callback-polling")===-1&&(s._dispatcher.selectTransport("long-polling"),s._dispatcher._transport.batching=!1),s},h.prototype._getFayeClient=function(t){var e=0===t.indexOf("/u/"),n=e?"generic":"pushTopic";return this._fayeClients&&this._fayeClients[n]||(this._fayeClients=this._fayeClients||{},this._fayeClients[n]=this._createClient(t)),this._fayeClients[n]},h.prototype.topic=function(t){this._topics=this._topics||{};var e=this._topics[t]=this._topics[t]||new u(this,t);return e},h.prototype.channel=function(t){return new l(this,t)},h.prototype.subscribe=function(t,e){var n=0===t.indexOf("/")?t:"/topic/"+t,i=this._getFayeClient(n);return i.subscribe(n,e)},h.prototype.unsubscribe=function(t,e){var n=0===t.indexOf("/")?t:"/topic/"+t,i=this._getFayeClient(n);return i.unsubscribe(n,e),this},h.prototype.createClient=function(t){return this._createClient(null,t)},a.on("connection:new",function(t){t.streaming=new h(t)}),a.StreamingExtension=c,e.exports=h},{"./streaming-extension":1,faye:5}],3:[function(t,e,n){"use strict";function i(){if(a.length)throw a.shift()}function s(t){var e;e=c.length?c.pop():new r,e.task=t,o(e)}function r(){this.task=null}var o=t("./raw"),c=[],a=[],u=o.makeRequestCallFromTimer(i);e.exports=s,r.prototype.call=function(){try{this.task.call()}catch(t){s.onerror?s.onerror(t):(a.push(t),u())}finally{this.task=null,c[c.length]=this}}},{"./raw":4}],4:[function(t,e,n){(function(t){"use strict";function n(t){c.length||(o(),a=!0),c[c.length]=t}function i(){for(;u<c.length;){var t=u;if(u+=1,c[t].call(),u>l){for(var e=0,n=c.length-u;e<n;e++)c[e]=c[e+u];c.length-=u,u=0}}c.length=0,u=0,a=!1}function s(t){var e=1,n=new f(t),i=document.createTextNode("");return n.observe(i,{characterData:!0}),function(){e=-e,i.data=e}}function r(t){return function(){function e(){clearTimeout(n),clearInterval(i),t()}var n=setTimeout(e,0),i=setInterval(e,50)}}e.exports=n;var o,c=[],a=!1,u=0,l=1024,h="undefined"!=typeof t?t:self,f=h.MutationObserver||h.WebKitMutationObserver;o="function"==typeof f?s(i):r(i),n.requestFlush=o,n.makeRequestCallFromTimer=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(t,e,n){"use strict";var i=t("./util/constants"),s=t("./mixins/logging"),r={VERSION:i.VERSION,Client:t("./protocol/client"),Scheduler:t("./protocol/scheduler")};s.wrapper=r,e.exports=r},{"./mixins/logging":7,"./protocol/client":11,"./protocol/scheduler":17,"./util/constants":29}],6:[function(t,e,n){(function(n){"use strict";var i=t("../util/promise");e.exports={then:function(t,e){var n=this;return this._promise||(this._promise=new i(function(t,e){n._resolve=t,n._reject=e})),0===arguments.length?this._promise:this._promise.then(t,e)},callback:function(t,e){return this.then(function(n){t.call(e,n)})},errback:function(t,e){return this.then(null,function(n){t.call(e,n)})},timeout:function(t,e){this.then();var i=this;this._timer=n.setTimeout(function(){i._reject(e)},1e3*t)},setDeferredStatus:function(t,e){this._timer&&n.clearTimeout(this._timer),this.then(),"succeeded"===t?this._resolve(e):"failed"===t?this._reject(e):delete this._promise}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/promise":34}],7:[function(t,e,n){"use strict";var i=t("../util/to_json"),s={LOG_LEVELS:{fatal:4,error:3,warn:2,info:1,debug:0},writeLog:function(t,e){var n=s.logger||(s.wrapper||s).logger;if(n){var r=Array.prototype.slice.apply(t),o="[Faye",c=this.className,a=r.shift().replace(/\?/g,function(){try{return i(r.shift())}catch(t){return"[Object]"}});c&&(o+="."+c),o+="] ","function"==typeof n[e]?n[e](o+a):"function"==typeof n&&n(o+a)}}};for(var r in s.LOG_LEVELS)(function(t){s[t]=function(){this.writeLog(arguments,t)}})(r);e.exports=s},{"../util/to_json":36}],8:[function(t,e,n){"use strict";var i=t("../util/extend"),s=t("../util/event_emitter"),r={countListeners:function(t){return this.listeners(t).length},bind:function(t,e,n){var i=Array.prototype.slice,s=function(){e.apply(n,i.call(arguments))};return this._listeners=this._listeners||[],this._listeners.push([t,e,n,s]),this.on(t,s)},unbind:function(t,e,n){this._listeners=this._listeners||[];for(var i,s=this._listeners.length;s--;)i=this._listeners[s],i[0]===t&&(!e||i[1]===e&&i[2]===n)&&(this._listeners.splice(s,1),this.removeListener(t,i[3]))}};i(r,s.prototype),r.trigger=r.emit,e.exports=r},{"../util/event_emitter":32,"../util/extend":33}],9:[function(t,e,n){(function(t){"use strict";e.exports={addTimeout:function(e,n,i,s){if(this._timeouts=this._timeouts||{},!this._timeouts.hasOwnProperty(e)){var r=this;this._timeouts[e]=t.setTimeout(function(){delete r._timeouts[e],i.call(s)},1e3*n)}},removeTimeout:function(e){this._timeouts=this._timeouts||{};var n=this._timeouts[e];n&&(t.clearTimeout(n),delete this._timeouts[e])},removeAllTimeouts:function(){this._timeouts=this._timeouts||{};for(var t in this._timeouts)this.removeTimeout(t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(t,e,n){"use strict";var i=t("../util/class"),s=t("../util/extend"),r=t("../mixins/publisher"),o=t("./grammar"),c=i({initialize:function(t){this.id=this.name=t},push:function(t){this.trigger("message",t)},isUnused:function(){return 0===this.countListeners("message")}});s(c.prototype,r),s(c,{HANDSHAKE:"/meta/handshake",CONNECT:"/meta/connect",SUBSCRIBE:"/meta/subscribe",UNSUBSCRIBE:"/meta/unsubscribe",DISCONNECT:"/meta/disconnect",META:"meta",SERVICE:"service",expand:function(t){var e=this.parse(t),n=["/**",t],i=e.slice();i[i.length-1]="*",n.push(this.unparse(i));for(var s=1,r=e.length;s<r;s++)i=e.slice(0,s),i.push("**"),n.push(this.unparse(i));return n},isValid:function(t){return o.CHANNEL_NAME.test(t)||o.CHANNEL_PATTERN.test(t)},parse:function(t){return this.isValid(t)?t.split("/").slice(1):null},unparse:function(t){return"/"+t.join("/")},isMeta:function(t){var e=this.parse(t);return e?e[0]===this.META:null},isService:function(t){var e=this.parse(t);return e?e[0]===this.SERVICE:null},isSubscribable:function(t){return this.isValid(t)?!this.isMeta(t)&&!this.isService(t):null},Set:i({initialize:function(){this._channels={}},getKeys:function(){var t=[];for(var e in this._channels)t.push(e);return t},remove:function(t){delete this._channels[t]},hasSubscription:function(t){return this._channels.hasOwnProperty(t)},subscribe:function(t,e){for(var n,i=0,s=t.length;i<s;i++){n=t[i];var r=this._channels[n]=this._channels[n]||new c(n);r.bind("message",e)}},unsubscribe:function(t,e){var n=this._channels[t];return!!n&&(n.unbind("message",e),!!n.isUnused()&&(this.remove(t),!0))},distributeMessage:function(t){for(var e=c.expand(t.channel),n=0,i=e.length;n<i;n++){var s=this._channels[e[n]];s&&s.trigger("message",t)}}})}),e.exports=c},{"../mixins/publisher":8,"../util/class":28,"../util/extend":33,"./grammar":15}],11:[function(t,e,n){(function(n){"use strict";var i=t("asap"),s=t("../util/class"),r=(t("../util/promise"),t("../util/uri")),o=t("../util/array"),c=t("../util/browser"),a=t("../util/constants"),u=t("../util/extend"),l=t("../util/validate_options"),h=t("../mixins/deferrable"),f=t("../mixins/logging"),d=t("../mixins/publisher"),p=t("./channel"),_=t("./dispatcher"),v=t("./error"),g=t("./extensible"),m=t("./publication"),y=t("./subscription"),b=s({className:"Client",UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:"handshake",RETRY:"retry",NONE:"none",CONNECTION_TIMEOUT:60,DEFAULT_ENDPOINT:"/bayeux",INTERVAL:0,initialize:function(t,e){this.info("New client created for ?",t),e=e||{},l(e,["interval","timeout","endpoints","proxy","retry","scheduler","websocketExtensions","tls","ca"]),this._channels=new p.Set,this._dispatcher=_.create(this,t||this.DEFAULT_ENDPOINT,e),this._messageId=0,this._state=this.UNCONNECTED,this._responseCallbacks={},this._advice={reconnect:this.RETRY,interval:1e3*(e.interval||this.INTERVAL),timeout:1e3*(e.timeout||this.CONNECTION_TIMEOUT)},this._dispatcher.timeout=this._advice.timeout/1e3,this._dispatcher.bind("message",this._receiveMessage,this),c.Event&&void 0!==n.onbeforeunload&&c.Event.on(n,"beforeunload",function(){o.indexOf(this._dispatcher._disabled,"autodisconnect")<0&&this.disconnect()},this)},addWebsocketExtension:function(t){return this._dispatcher.addWebsocketExtension(t)},disable:function(t){return this._dispatcher.disable(t)},setHeader:function(t,e){return this._dispatcher.setHeader(t,e)},handshake:function(t,e){if(this._advice.reconnect!==this.NONE&&this._state===this.UNCONNECTED){this._state=this.CONNECTING;var s=this;this.info("Initiating handshake with ?",r.stringify(this._dispatcher.endpoint)),this._dispatcher.selectTransport(a.MANDATORY_CONNECTION_TYPES),this._sendMessage({channel:p.HANDSHAKE,version:a.BAYEUX_VERSION,supportedConnectionTypes:this._dispatcher.getConnectionTypes()},{},function(r){r.successful?(this._state=this.CONNECTED,this._dispatcher.clientId=r.clientId,this._dispatcher.selectTransport(r.supportedConnectionTypes),this.info("Handshake successful: ?",this._dispatcher.clientId),this.subscribe(this._channels.getKeys(),!0),t&&i(function(){t.call(e)})):(this.info("Handshake unsuccessful"),n.setTimeout(function(){s.handshake(t,e)},1e3*this._dispatcher.retry),this._state=this.UNCONNECTED)},this)}},connect:function(t,e){if(this._advice.reconnect!==this.NONE&&this._state!==this.DISCONNECTED){if(this._state===this.UNCONNECTED)return this.handshake(function(){this.connect(t,e)},this);this.callback(t,e),this._state===this.CONNECTED&&(this.info("Calling deferred actions for ?",this._dispatcher.clientId),this.setDeferredStatus("succeeded"),this.setDeferredStatus("unknown"),this._connectRequest||(this._connectRequest=!0,this.info("Initiating connection for ?",this._dispatcher.clientId),this._sendMessage({channel:p.CONNECT,clientId:this._dispatcher.clientId,connectionType:this._dispatcher.connectionType},{},this._cycleConnection,this)))}},disconnect:function(){if(this._state===this.CONNECTED){this._state=this.DISCONNECTED,this.info("Disconnecting ?",this._dispatcher.clientId);var t=new m;return this._sendMessage({channel:p.DISCONNECT,clientId:this._dispatcher.clientId},{},function(e){e.successful?(this._dispatcher.close(),t.setDeferredStatus("succeeded")):t.setDeferredStatus("failed",v.parse(e.error))},this),this.info("Clearing channel listeners for ?",this._dispatcher.clientId),this._channels=new p.Set,t}},subscribe:function(t,e,n){if(t instanceof Array)return o.map(t,function(t){return this.subscribe(t,e,n)},this);var i=new y(this,t,e,n),s=e===!0,r=this._channels.hasSubscription(t);return r&&!s?(this._channels.subscribe([t],i),i.setDeferredStatus("succeeded"),i):(this.connect(function(){this.info("Client ? attempting to subscribe to ?",this._dispatcher.clientId,t),s||this._channels.subscribe([t],i),this._sendMessage({channel:p.SUBSCRIBE,clientId:this._dispatcher.clientId,subscription:t},{},function(e){if(!e.successful)return i.setDeferredStatus("failed",v.parse(e.error)),this._channels.unsubscribe(t,i);var n=[].concat(e.subscription);this.info("Subscription acknowledged for ? to ?",this._dispatcher.clientId,n),i.setDeferredStatus("succeeded")},this)},this),i)},unsubscribe:function(t,e){if(t instanceof Array)return o.map(t,function(t){return this.unsubscribe(t,e)},this);var n=this._channels.unsubscribe(t,e);n&&this.connect(function(){this.info("Client ? attempting to unsubscribe from ?",this._dispatcher.clientId,t),this._sendMessage({channel:p.UNSUBSCRIBE,clientId:this._dispatcher.clientId,subscription:t},{},function(t){if(t.successful){var e=[].concat(t.subscription);this.info("Unsubscription acknowledged for ? from ?",this._dispatcher.clientId,e)}},this)},this)},publish:function(t,e,n){l(n||{},["attempts","deadline"]);var i=new m;return this.connect(function(){this.info("Client ? queueing published message to ?: ?",this._dispatcher.clientId,t,e),this._sendMessage({channel:t,data:e,clientId:this._dispatcher.clientId},n,function(t){t.successful?i.setDeferredStatus("succeeded"):i.setDeferredStatus("failed",v.parse(t.error))},this)},this),i},_sendMessage:function(t,e,n,i){t.id=this._generateMessageId();var s=this._advice.timeout?1.2*this._advice.timeout/1e3:1.2*this._dispatcher.retry;this.pipeThroughExtensions("outgoing",t,null,function(t){t&&(n&&(this._responseCallbacks[t.id]=[n,i]),this._dispatcher.sendMessage(t,s,e||{}))},this)},_generateMessageId:function(){return this._messageId+=1,this._messageId>=Math.pow(2,32)&&(this._messageId=0),this._messageId.toString(36)},_receiveMessage:function(t){var e,n=t.id;void 0!==t.successful&&(e=this._responseCallbacks[n],delete this._responseCallbacks[n]),this.pipeThroughExtensions("incoming",t,null,function(t){t&&(t.advice&&this._handleAdvice(t.advice),this._deliverMessage(t),e&&e[0].call(e[1],t))},this)},_handleAdvice:function(t){u(this._advice,t),this._dispatcher.timeout=this._advice.timeout/1e3,this._advice.reconnect===this.HANDSHAKE&&this._state!==this.DISCONNECTED&&(this._state=this.UNCONNECTED,this._dispatcher.clientId=null,this._cycleConnection())},_deliverMessage:function(t){t.channel&&void 0!==t.data&&(this.info("Client ? calling listeners for ? with ?",this._dispatcher.clientId,t.channel,t.data),this._channels.distributeMessage(t))},_cycleConnection:function(){this._connectRequest&&(this._connectRequest=null,this.info("Closed connection for ?",this._dispatcher.clientId));var t=this;n.setTimeout(function(){t.connect()},this._advice.interval)}});u(b.prototype,h),u(b.prototype,d),u(b.prototype,f),u(b.prototype,g),e.exports=b}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../mixins/deferrable":6,"../mixins/logging":7,"../mixins/publisher":8,"../util/array":26,"../util/browser":27,"../util/class":28,"../util/constants":29,"../util/extend":33,"../util/promise":34,"../util/uri":37,"../util/validate_options":38,"./channel":10,"./dispatcher":12,"./error":13,"./extensible":14,"./publication":16,"./subscription":18,asap:3}],12:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/uri"),r=t("../util/cookies"),o=t("../util/extend"),c=t("../mixins/logging"),a=t("../mixins/publisher"),u=t("../transport"),l=t("./scheduler"),h=i({className:"Dispatcher",MAX_REQUEST_SIZE:2048,DEFAULT_RETRY:5,UP:1,DOWN:2,initialize:function(t,e,n){this._client=t,this.endpoint=s.parse(e),this._alternates=n.endpoints||{},this.cookies=r.CookieJar&&new r.CookieJar,this._disabled=[],this._envelopes={},this.headers={},this.retry=n.retry||this.DEFAULT_RETRY,this._scheduler=n.scheduler||l,this._state=0,this.transports={},this.wsExtensions=[],this.proxy=n.proxy||{},"string"==typeof this._proxy&&(this._proxy={origin:this._proxy});var i=n.websocketExtensions;if(i){i=[].concat(i);for(var o=0,c=i.length;o<c;o++)this.addWebsocketExtension(i[o])}this.tls=n.tls||{},this.tls.ca=this.tls.ca||n.ca;for(var a in this._alternates)this._alternates[a]=s.parse(this._alternates[a]);this.maxRequestSize=this.MAX_REQUEST_SIZE},endpointFor:function(t){return this._alternates[t]||this.endpoint},addWebsocketExtension:function(t){this.wsExtensions.push(t)},disable:function(t){this._disabled.push(t)},setHeader:function(t,e){this.headers[t]=e},close:function(){var t=this._transport;delete this._transport,t&&t.close()},getConnectionTypes:function(){return u.getConnectionTypes()},selectTransport:function(t){u.get(this,t,this._disabled,function(t){this.debug("Selected ? transport for ?",t.connectionType,s.stringify(t.endpoint)),t!==this._transport&&(this._transport&&this._transport.close(),this._transport=t,this.connectionType=t.connectionType)},this)},sendMessage:function(t,e,n){n=n||{};var i,s=t.id,r=n.attempts,o=n.deadline&&(new Date).getTime()+1e3*n.deadline,c=this._envelopes[s];c||(i=new this._scheduler(t,{timeout:e,interval:this.retry,attempts:r,deadline:o}),c=this._envelopes[s]={message:t,scheduler:i}),this._sendEnvelope(c)},_sendEnvelope:function(t){if(this._transport&&!t.request&&!t.timer){var e=t.message,i=t.scheduler,s=this;if(!i.isDeliverable())return i.abort(),void delete this._envelopes[e.id];t.timer=n.setTimeout(function(){s.handleError(e)},1e3*i.getTimeout()),i.send(),t.request=this._transport.sendMessage(e)}},handleResponse:function(t){var e=this._envelopes[t.id];void 0!==t.successful&&e&&(e.scheduler.succeed(),delete this._envelopes[t.id],n.clearTimeout(e.timer)),this.trigger("message",t),this._state!==this.UP&&(this._state=this.UP,this._client.trigger("transport:up"))},handleError:function(t,e){var i=this._envelopes[t.id],s=i&&i.request,r=this;if(s){s.then(function(t){t&&t.abort&&t.abort()});var o=i.scheduler;o.fail(),n.clearTimeout(i.timer),i.request=i.timer=null,e?this._sendEnvelope(i):i.timer=n.setTimeout(function(){i.timer=null,r._sendEnvelope(i)},1e3*o.getInterval()),this._state!==this.DOWN&&(this._state=this.DOWN,this._client.trigger("transport:down"))}}});h.create=function(t,e,n){return new h(t,e,n)},o(h.prototype,a),o(h.prototype,c),e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../mixins/logging":7,"../mixins/publisher":8,"../transport":19,"../util/class":28,"../util/cookies":30,"../util/extend":33,"../util/uri":37,"./scheduler":17}],13:[function(t,e,n){"use strict";var i=t("../util/class"),s=t("./grammar"),r=i({initialize:function(t,e,n){this.code=t,this.params=Array.prototype.slice.call(e),this.message=n},toString:function(){return this.code+":"+this.params.join(",")+":"+this.message}});r.parse=function(t){if(t=t||"",!s.ERROR.test(t))return new r(null,[],t);var e=t.split(":"),n=parseInt(e[0]),i=e[1].split(","),t=e[2];return new r(n,i,t)};var o={versionMismatch:[300,"Version mismatch"],conntypeMismatch:[301,"Connection types not supported"],extMismatch:[302,"Extension mismatch"],badRequest:[400,"Bad request"],clientUnknown:[401,"Unknown client"],parameterMissing:[402,"Missing required parameter"],channelForbidden:[403,"Forbidden channel"],channelUnknown:[404,"Unknown channel"],channelInvalid:[405,"Invalid channel"],extUnknown:[406,"Unknown extension"],publishFailed:[407,"Failed to publish"],serverError:[500,"Internal server error"]};for(var c in o)(function(t){r[t]=function(){return new r(o[t][0],arguments,o[t][1]).toString()}})(c);e.exports=r},{"../util/class":28,"./grammar":15}],14:[function(t,e,n){"use strict";var i=t("../util/extend"),s=t("../mixins/logging"),r={addExtension:function(t){this._extensions=this._extensions||[],this._extensions.push(t),t.added&&t.added(this)},removeExtension:function(t){if(this._extensions)for(var e=this._extensions.length;e--;)this._extensions[e]===t&&(this._extensions.splice(e,1),t.removed&&t.removed(this))},pipeThroughExtensions:function(t,e,n,i,s){if(this.debug("Passing through ? extensions: ?",t,e),!this._extensions)return i.call(s,e);var r=this._extensions.slice(),o=function(e){if(!e)return i.call(s,e);var c=r.shift();if(!c)return i.call(s,e);var a=c[t];return a?void(a.length>=3?c[t](e,n,o):c[t](e,o)):o(e)};o(e)}};i(r,s),e.exports=r},{"../mixins/logging":7,"../util/extend":33}],15:[function(t,e,n){"use strict";e.exports={CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/}},{}],16:[function(t,e,n){"use strict";var i=t("../util/class"),s=t("../mixins/deferrable");e.exports=i(s)},{"../mixins/deferrable":6,"../util/class":28}],17:[function(t,e,n){"use strict";var i=t("../util/extend"),s=function(t,e){this.message=t,this.options=e,this.attempts=0};i(s.prototype,{getTimeout:function(){return this.options.timeout},getInterval:function(){return this.options.interval},isDeliverable:function(){var t=this.options.attempts,e=this.attempts,n=this.options.deadline,i=(new Date).getTime();return!(void 0!==t&&e>=t)&&!(void 0!==n&&i>n)},send:function(){this.attempts+=1},succeed:function(){},fail:function(){},abort:function(){}}),e.exports=s},{"../util/extend":33}],18:[function(t,e,n){"use strict";var i=t("../util/class"),s=t("../util/extend"),r=t("../mixins/deferrable"),o=i({initialize:function(t,e,n,i){this._client=t,this._channels=e,this._callback=n,this._context=i,this._cancelled=!1},withChannel:function(t,e){return this._withChannel=[t,e],this},apply:function(t,e){var n=e[0];this._callback&&this._callback.call(this._context,n.data),this._withChannel&&this._withChannel[0].call(this._withChannel[1],n.channel,n.data)},cancel:function(){this._cancelled||(this._client.unsubscribe(this._channels,this),this._cancelled=!0)},unsubscribe:function(){this.cancel()}});s(o.prototype,r),e.exports=o},{"../mixins/deferrable":6,"../util/class":28,"../util/extend":33}],19:[function(t,e,n){"use strict";var i=t("./transport");i.register("websocket",t("./web_socket")),i.register("eventsource",t("./event_source")),i.register("long-polling",t("./xhr")),i.register("cross-origin-long-polling",t("./cors")),i.register("callback-polling",t("./jsonp")),e.exports=i},{"./cors":20,"./event_source":21,"./jsonp":22,"./transport":23,"./web_socket":24,"./xhr":25}],20:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/set"),r=t("../util/uri"),o=t("../util/extend"),c=t("../util/to_json"),a=t("./transport"),u=o(i(a,{encode:function(t){return"message="+encodeURIComponent(c(t))},request:function(t){var e,i=n.XDomainRequest?XDomainRequest:XMLHttpRequest,s=new i,o=++u._id,c=this._dispatcher.headers,a=this;if(s.open("POST",r.stringify(this.endpoint),!0),s.setRequestHeader){s.setRequestHeader("Pragma","no-cache");for(e in c)c.hasOwnProperty(e)&&s.setRequestHeader(e,c[e])}var l=function(){return!!s&&(u._pending.remove(o),s.onload=s.onerror=s.ontimeout=s.onprogress=null,void(s=null))};return s.onload=function(){var e;try{e=JSON.parse(s.responseText)}catch(n){}l(),e?a._receive(e):a._handleError(t)},s.onerror=s.ontimeout=function(){l(),a._handleError(t)},s.onprogress=function(){},i===n.XDomainRequest&&u._pending.add({id:o,xhr:s}),s.send(this.encode(t)),s}}),{_id:0,_pending:new s,isUsable:function(t,e,i,s){if(r.isSameOrigin(e))return i.call(s,!1);if(n.XDomainRequest)return i.call(s,e.protocol===location.protocol);if(n.XMLHttpRequest){var o=new XMLHttpRequest;return i.call(s,void 0!==o.withCredentials)}return i.call(s,!1)}});e.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/class":28,"../util/extend":33,"../util/set":35,"../util/to_json":36,"../util/uri":37,"./transport":23}],21:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/uri"),r=t("../util/copy_object"),o=t("../util/extend"),c=t("../mixins/deferrable"),a=t("./transport"),u=t("./xhr"),l=o(i(a,{initialize:function(t,e){if(a.prototype.initialize.call(this,t,e),!n.EventSource)return this.setDeferredStatus("failed");this._xhr=new u(t,e),e=r(e),e.pathname+="/"+t.clientId;var i=new n.EventSource(s.stringify(e)),o=this;i.onopen=function(){o._everConnected=!0,o.setDeferredStatus("succeeded")},i.onerror=function(){o._everConnected?o._handleError([]):(o.setDeferredStatus("failed"),i.close())},i.onmessage=function(t){var e;try{e=JSON.parse(t.data)}catch(n){}e?o._receive(e):o._handleError([])},this._socket=i},close:function(){this._socket&&(this._socket.onopen=this._socket.onerror=this._socket.onmessage=null,this._socket.close(),delete this._socket)},isUsable:function(t,e){this.callback(function(){t.call(e,!0)}),this.errback(function(){t.call(e,!1)})},encode:function(t){return this._xhr.encode(t)},request:function(t){return this._xhr.request(t)}}),{isUsable:function(t,e,n,i){var s=t.clientId;return s?void u.isUsable(t,e,function(s){return s?void this.create(t,e).isUsable(n,i):n.call(i,!1)},this):n.call(i,!1)},create:function(t,e){var n=t.transports.eventsource=t.transports.eventsource||{},i=t.clientId,o=r(e);return o.pathname+="/"+(i||""),o=s.stringify(o),n[o]=n[o]||new this(t,e),n[o]}});o(l.prototype,c),e.exports=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../mixins/deferrable":6,"../util/class":28,"../util/copy_object":31,"../util/extend":33,"../util/uri":37,"./transport":23,"./xhr":25}],22:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/uri"),r=t("../util/copy_object"),o=t("../util/extend"),c=t("../util/to_json"),a=t("./transport"),u=o(i(a,{encode:function(t){var e=r(this.endpoint);return e.query.message=c(t),e.query.jsonp="__jsonp"+u._cbCount+"__",s.stringify(e)},request:function(t){var e=document.getElementsByTagName("head")[0],i=document.createElement("script"),o=u.getCallbackName(),a=r(this.endpoint),l=this;a.query.message=c(t),a.query.jsonp=o;var h=function(){if(!n[o])return!1;n[o]=void 0;try{delete n[o]}catch(t){}i.parentNode.removeChild(i)};return n[o]=function(t){h(),l._receive(t)},i.type="text/javascript",i.src=s.stringify(a),e.appendChild(i),i.onerror=function(){h(),l._handleError(t)},{abort:h}}}),{_cbCount:0,getCallbackName:function(){return this._cbCount+=1,"__jsonp"+this._cbCount+"__"},isUsable:function(t,e,n,i){n.call(i,!0)}});e.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/class":28,"../util/copy_object":31,"../util/extend":33,"../util/to_json":36,"../util/uri":37,"./transport":23}],23:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/cookies").Cookie,r=t("../util/promise"),o=t("../util/uri"),c=t("../util/array"),a=t("../util/extend"),u=t("../mixins/logging"),l=t("../mixins/timeouts"),h=t("../protocol/channel"),f=a(i({className:"Transport",DEFAULT_PORTS:{"http:":80,"https:":443,"ws:":80,"wss:":443},MAX_DELAY:0,batching:!0,initialize:function(t,e){this._dispatcher=t,this.endpoint=e,this._outbox=[],this._proxy=a({},this._dispatcher.proxy),this._proxy.origin||(this._proxy.origin=this._findProxy())},close:function(){},encode:function(t){return""},sendMessage:function(t){return this.debug("Client ? sending message to ?: ?",this._dispatcher.clientId,o.stringify(this.endpoint),t),this.batching?(this._outbox.push(t),this._flushLargeBatch(),t.channel===h.HANDSHAKE?this._publish(.01):(t.channel===h.CONNECT&&(this._connectMessage=t),this._publish(this.MAX_DELAY))):r.resolve(this.request([t]))},_makePromise:function(){var t=this;this._requestPromise=this._requestPromise||new r(function(e){t._resolvePromise=e})},_publish:function(t){return this._makePromise(),this.addTimeout("publish",t,function(){this._flush(),delete this._requestPromise},this),this._requestPromise},_flush:function(){this.removeTimeout("publish"),this._outbox.length>1&&this._connectMessage&&(this._connectMessage.advice={timeout:0}),this._resolvePromise(this.request(this._outbox)),this._connectMessage=null,this._outbox=[]},_flushLargeBatch:function(){var t=this.encode(this._outbox);if(!(t.length<this._dispatcher.maxRequestSize)){var e=this._outbox.pop();this._makePromise(),this._flush(),e&&this._outbox.push(e)}},_receive:function(t){if(t){t=[].concat(t),this.debug("Client ? received from ? via ?: ?",this._dispatcher.clientId,o.stringify(this.endpoint),this.connectionType,t);for(var e=0,n=t.length;e<n;e++)this._dispatcher.handleResponse(t[e])}},_handleError:function(t,e){t=[].concat(t),this.debug("Client ? failed to send to ? via ?: ?",this._dispatcher.clientId,o.stringify(this.endpoint),this.connectionType,t);for(var n=0,i=t.length;n<i;n++)this._dispatcher.handleError(t[n])},_getCookies:function(){var t=this._dispatcher.cookies,e=o.stringify(this.endpoint);return t?c.map(t.getCookiesSync(e),function(t){return t.cookieString()}).join("; "):""},_storeCookies:function(t){var e,n=this._dispatcher.cookies,i=o.stringify(this.endpoint);if(t&&n){t=[].concat(t);for(var r=0,c=t.length;r<c;r++)e=s.parse(t[r]),n.setCookieSync(e,i)}},_findProxy:function(){if("undefined"!=typeof n){var t=this.endpoint.protocol;if(t){var e,i,s=t.replace(/:$/,"").toLowerCase()+"_proxy",r=s.toUpperCase(),o=n.env;return"http_proxy"===s&&o.REQUEST_METHOD?(e=Object.keys(o).filter(function(t){return/^http_proxy$/i.test(t)}),1===e.length?e[0]===s&&void 0===o[r]&&(i=o[s]):e.length>1&&(i=o[s]),i=i||o["CGI_"+r]):(i=o[s]||o[r],i&&!o[s]&&console.warn("The environment variable "+r+" is discouraged. Use "+s+".")),i}}}}),{get:function(t,e,n,i,s){var r=t.endpoint;c.asyncEach(this._transports,function(r,o){var a=r[0],u=r[1],l=t.endpointFor(a);return c.indexOf(n,a)>=0?o():c.indexOf(e,a)<0?(u.isUsable(t,l,function(){}),o()):void u.isUsable(t,l,function(e){if(!e)return o(); var n=u.hasOwnProperty("create")?u.create(t,l):new u(t,l);i.call(s,n)})},function(){throw new Error("Could not find a usable connection type for "+o.stringify(r))})},register:function(t,e){this._transports.push([t,e]),e.prototype.connectionType=t},getConnectionTypes:function(){return c.map(this._transports,function(t){return t[0]})},_transports:[]});a(f.prototype,u),a(f.prototype,l),e.exports=f}).call(this,t("_process"))},{"../mixins/logging":7,"../mixins/timeouts":9,"../protocol/channel":10,"../util/array":26,"../util/class":28,"../util/cookies":30,"../util/extend":33,"../util/promise":34,"../util/uri":37,_process:40}],24:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/promise"),r=t("../util/set"),o=t("../util/uri"),c=t("../util/browser"),a=t("../util/copy_object"),u=t("../util/extend"),l=t("../util/to_json"),h=t("../util/websocket"),f=t("../mixins/deferrable"),d=t("./transport"),p=u(i(d,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(t,e){this.callback(function(){t.call(e,!0)}),this.errback(function(){t.call(e,!1)}),this.connect()},request:function(t){this._pending=this._pending||new r;for(var e=0,n=t.length;e<n;e++)this._pending.add(t[e]);var i=this,o=new s(function(e,n){i.callback(function(n){n&&1===n.readyState&&(n.send(l(t)),e(n))}),i.connect()});return{abort:function(){o.then(function(t){t.close()})}}},connect:function(){if(!p._unloaded&&(this._state=this._state||this.UNCONNECTED,this._state===this.UNCONNECTED)){this._state=this.CONNECTING;var t=this._createSocket();if(!t)return this.setDeferredStatus("failed");var e=this;t.onopen=function(){t.headers&&e._storeCookies(t.headers["set-cookie"]),e._socket=t,e._state=e.CONNECTED,e._everConnected=!0,e._ping(),e.setDeferredStatus("succeeded",t)};var n=!1;t.onclose=t.onerror=function(){if(!n){n=!0;var i=e._state===e.CONNECTED;t.onopen=t.onclose=t.onerror=t.onmessage=null,delete e._socket,e._state=e.UNCONNECTED,e.removeTimeout("ping");var s=e._pending?e._pending.toArray():[];delete e._pending,i||e._everConnected?(e.setDeferredStatus("unknown"),e._handleError(s,i)):e.setDeferredStatus("failed")}},t.onmessage=function(t){var n;try{n=JSON.parse(t.data)}catch(i){}if(n){n=[].concat(n);for(var s=0,r=n.length;s<r;s++)void 0!==n[s].successful&&e._pending.remove(n[s]);e._receive(n)}}}},close:function(){this._socket&&this._socket.close()},_createSocket:function(){var t=p.getSocketUrl(this.endpoint),e=this._dispatcher.headers,n=this._dispatcher.wsExtensions,i=this._getCookies(),s=this._dispatcher.tls,r={extensions:n,headers:e,proxy:this._proxy,tls:s};return""!==i&&(r.headers.Cookie=i),h.create(t,[],r)},_ping:function(){this._socket&&1===this._socket.readyState&&(this._socket.send("[]"),this.addTimeout("ping",this._dispatcher.timeout/2,this._ping,this))}}),{PROTOCOLS:{"http:":"ws:","https:":"wss:"},create:function(t,e){var n=t.transports.websocket=t.transports.websocket||{};return n[e.href]=n[e.href]||new this(t,e),n[e.href]},getSocketUrl:function(t){return t=a(t),t.protocol=this.PROTOCOLS[t.protocol],o.stringify(t)},isUsable:function(t,e,n,i){this.create(t,e).isUsable(n,i)}});u(p.prototype,f),c.Event&&void 0!==n.onbeforeunload&&c.Event.on(n,"beforeunload",function(){p._unloaded=!0}),e.exports=p}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../mixins/deferrable":6,"../util/browser":27,"../util/class":28,"../util/copy_object":31,"../util/extend":33,"../util/promise":34,"../util/set":35,"../util/to_json":36,"../util/uri":37,"../util/websocket":39,"./transport":23}],25:[function(t,e,n){(function(n){"use strict";var i=t("../util/class"),s=t("../util/uri"),r=t("../util/browser"),o=t("../util/extend"),c=t("../util/to_json"),a=t("./transport"),u=o(i(a,{encode:function(t){return c(t)},request:function(t){var e,i=this.endpoint.href,s=this;if(n.XMLHttpRequest)e=new XMLHttpRequest;else{if(!n.ActiveXObject)return this._handleError(t);e=new ActiveXObject("Microsoft.XMLHTTP")}e.open("POST",i,!0),e.setRequestHeader("Content-Type","application/json"),e.setRequestHeader("Pragma","no-cache"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");var o=this._dispatcher.headers;for(var c in o)o.hasOwnProperty(c)&&e.setRequestHeader(c,o[c]);var a=function(){e.abort()};return void 0!==n.onbeforeunload&&r.Event.on(n,"beforeunload",a),e.onreadystatechange=function(){if(e&&4===e.readyState){var i=null,o=e.status,c=e.responseText,u=o>=200&&o<300||304===o||1223===o;if(void 0!==n.onbeforeunload&&r.Event.detach(n,"beforeunload",a),e.onreadystatechange=function(){},e=null,!u)return s._handleError(t);try{i=JSON.parse(c)}catch(l){}i?s._receive(i):s._handleError(t)}},e.send(this.encode(t)),e}}),{isUsable:function(t,e,n,i){var r="ReactNative"===navigator.product||s.isSameOrigin(e);n.call(i,r)}});e.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util/browser":27,"../util/class":28,"../util/extend":33,"../util/to_json":36,"../util/uri":37,"./transport":23}],26:[function(t,e,n){"use strict";e.exports={commonElement:function(t,e){for(var n=0,i=t.length;n<i;n++)if(this.indexOf(e,t[n])!==-1)return t[n];return null},indexOf:function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0,i=t.length;n<i;n++)if(t[n]===e)return n;return-1},map:function(t,e,n){if(t.map)return t.map(e,n);var i=[];if(t instanceof Array)for(var s=0,r=t.length;s<r;s++)i.push(e.call(n||null,t[s],s));else for(var o in t)t.hasOwnProperty(o)&&i.push(e.call(n||null,o,t[o]));return i},filter:function(t,e,n){if(t.filter)return t.filter(e,n);for(var i=[],s=0,r=t.length;s<r;s++)e.call(n||null,t[s],s)&&i.push(t[s]);return i},asyncEach:function(t,e,n,i){var s=t.length,r=-1,o=0,c=!1,a=function(){return o-=1,r+=1,r===s?n&&n.call(i):void e(t[r],l)},u=function(){if(!c){for(c=!0;o>0;)a();c=!1}},l=function(){o+=1,u()};l()}}},{}],27:[function(t,e,n){(function(t){"use strict";var n={_registry:[],on:function(t,e,n,i){var s=function(){n.call(i)};t.addEventListener?t.addEventListener(e,s,!1):t.attachEvent("on"+e,s),this._registry.push({_element:t,_type:e,_callback:n,_context:i,_handler:s})},detach:function(t,e,n,i){for(var s,r=this._registry.length;r--;)s=this._registry[r],t&&t!==s._element||e&&e!==s._type||n&&n!==s._callback||i&&i!==s._context||(s._element.removeEventListener?s._element.removeEventListener(s._type,s._handler,!1):s._element.detachEvent("on"+s._type,s._handler),this._registry.splice(r,1),s=null)}};void 0!==t.onunload&&n.on(t,"unload",n.detach,n),e.exports={Event:n}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],28:[function(t,e,n){"use strict";var i=t("./extend");e.exports=function(t,e){"function"!=typeof t&&(e=t,t=Object);var n=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},s=function(){};return s.prototype=t.prototype,n.prototype=new s,i(n.prototype,e),n}},{"./extend":33}],29:[function(t,e,n){e.exports={VERSION:"1.2.4",BAYEUX_VERSION:"1.0",ID_LENGTH:160,JSONP_CALLBACK:"jsonpcallback",CONNECTION_TYPES:["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],MANDATORY_CONNECTION_TYPES:["long-polling","callback-polling","in-process"]}},{}],30:[function(t,e,n){"use strict";e.exports={}},{}],31:[function(t,e,n){"use strict";var i=function(t){var e,n,s;if(t instanceof Array){for(e=[],n=t.length;n--;)e[n]=i(t[n]);return e}if("object"==typeof t){e=null===t?null:{};for(s in t)e[s]=i(t[s]);return e}return t};e.exports=i},{}],32:[function(t,e,n){function i(t,e){if(t.indexOf)return t.indexOf(e);for(var n=0;n<t.length;n++)if(e===t[n])return n;return-1}function s(){}var r="function"==typeof Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};e.exports=s,s.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||r(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var e=this._events[t];if(!e)return!1;if("function"==typeof e){switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(r(e)){for(var n=Array.prototype.slice.call(arguments,1),i=e.slice(),s=0,o=i.length;s<o;s++)i[s].apply(this,n);return!0}return!1},s.prototype.addListener=function(t,e){if("function"!=typeof e)throw new Error("addListener only takes instances of Function");return this._events||(this._events={}),this.emit("newListener",t,e),this._events[t]?r(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,this},s.prototype.on=s.prototype.addListener,s.prototype.once=function(t,e){var n=this;return n.on(t,function i(){n.removeListener(t,i),e.apply(this,arguments)}),this},s.prototype.removeListener=function(t,e){if("function"!=typeof e)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[t])return this;var n=this._events[t];if(r(n)){var s=i(n,e);if(s<0)return this;n.splice(s,1),0==n.length&&delete this._events[t]}else this._events[t]===e&&delete this._events[t];return this},s.prototype.removeAllListeners=function(t){return 0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},s.prototype.listeners=function(t){return this._events||(this._events={}),this._events[t]||(this._events[t]=[]),r(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]}},{}],33:[function(t,e,n){"use strict";e.exports=function(t,e,n){if(!e)return t;for(var i in e)e.hasOwnProperty(i)&&(t.hasOwnProperty(i)&&n===!1||t[i]!==e[i]&&(t[i]=e[i]));return t}},{}],34:[function(t,e,n){"use strict";var i=t("asap"),s=0,r=1,o=2,c=function(t){return t},a=function(t){throw t},u=function(t){if(this._state=s,this._onFulfilled=[],this._onRejected=[],"function"==typeof t){var e=this;t(function(t){p(e,t)},function(t){v(e,t)})}};u.prototype.then=function(t,e){var n=new u;return l(this,t,n),h(this,e,n),n},u.prototype["catch"]=function(t){return this.then(null,t)};var l=function(t,e,n){"function"!=typeof e&&(e=c);var i=function(t){f(e,t,n)};t._state===s?t._onFulfilled.push(i):t._state===r&&i(t._value)},h=function(t,e,n){"function"!=typeof e&&(e=a);var i=function(t){f(e,t,n)};t._state===s?t._onRejected.push(i):t._state===o&&i(t._reason)},f=function(t,e,n){i(function(){d(t,e,n)})},d=function(t,e,n){var i;try{i=t(e)}catch(s){return v(n,s)}i===n?v(n,new TypeError("Recursive promise chain detected")):p(n,i)},p=function(t,e){var n,i,s=!1;try{if(n=typeof e,i=null!==e&&("function"===n||"object"===n)&&e.then,"function"!=typeof i)return _(t,e);i.call(e,function(e){s^(s=!0)&&p(t,e)},function(e){s^(s=!0)&&v(t,e)})}catch(r){if(!(s^(s=!0)))return;v(t,r)}},_=function(t,e){if(t._state===s){t._state=r,t._value=e,t._onRejected=[];for(var n,i=t._onFulfilled;n=i.shift();)n(e)}},v=function(t,e){if(t._state===s){t._state=o,t._reason=e,t._onFulfilled=[];for(var n,i=t._onRejected;n=i.shift();)n(e)}};u.resolve=function(t){return new u(function(e,n){e(t)})},u.reject=function(t){return new u(function(e,n){n(t)})},u.all=function(t){return new u(function(e,n){var i,s=[],r=t.length;if(0===r)return e(s);for(i=0;i<r;i++)(function(t,i){u.resolve(t).then(function(t){s[i]=t,0===--r&&e(s)},n)})(t[i],i)})},u.race=function(t){return new u(function(e,n){for(var i=0,s=t.length;i<s;i++)u.resolve(t[i]).then(e,n)})},u.deferred=u.pending=function(){var t={};return t.promise=new u(function(e,n){t.resolve=e,t.reject=n}),t},e.exports=u},{asap:3}],35:[function(t,e,n){"use strict";var i=t("./class");e.exports=i({initialize:function(){this._index={}},add:function(t){var e=void 0!==t.id?t.id:t;return!this._index.hasOwnProperty(e)&&(this._index[e]=t,!0)},forEach:function(t,e){for(var n in this._index)this._index.hasOwnProperty(n)&&t.call(e,this._index[n])},isEmpty:function(){for(var t in this._index)if(this._index.hasOwnProperty(t))return!1;return!0},member:function(t){for(var e in this._index)if(this._index[e]===t)return!0;return!1},remove:function(t){var e=void 0!==t.id?t.id:t,n=this._index[e];return delete this._index[e],n},toArray:function(){var t=[];return this.forEach(function(e){t.push(e)}),t}})},{"./class":28}],36:[function(t,e,n){"use strict";e.exports=function(t){return JSON.stringify(t,function(t,e){return this[t]instanceof Array?this[t]:e})}},{}],37:[function(t,e,n){"use strict";e.exports={isURI:function(t){return t&&t.protocol&&t.host&&t.path},isSameOrigin:function(t){return t.protocol===location.protocol&&t.hostname===location.hostname&&t.port===location.port},parse:function(t){if("string"!=typeof t)return t;var e,n,i,s,r,o,c={},a=function(e,n){t=t.replace(n,function(t){return c[e]=t,""}),c[e]=c[e]||""};for(a("protocol",/^[a-z]+\:/i),a("host",/^\/\/[^\/\?#]+/),/^\//.test(t)||c.host||(t=location.pathname.replace(/[^\/]*$/,"")+t),a("pathname",/^[^\?#]*/),a("search",/^\?[^#]*/),a("hash",/^#.*/),c.protocol=c.protocol||location.protocol,c.host?(c.host=c.host.substr(2),e=c.host.split(":"),c.hostname=e[0],c.port=e[1]||""):(c.host=location.host,c.hostname=location.hostname,c.port=location.port),c.pathname=c.pathname||"/",c.path=c.pathname+c.search,n=c.search.replace(/^\?/,""),i=n?n.split("&"):[],o={},s=0,r=i.length;s<r;s++)e=i[s].split("="),o[decodeURIComponent(e[0]||"")]=decodeURIComponent(e[1]||"");return c.query=o,c.href=this.stringify(c),c},stringify:function(t){var e=t.protocol+"//"+t.hostname;return t.port&&(e+=":"+t.port),e+=t.pathname+this.queryString(t.query)+(t.hash||"")},queryString:function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return 0===e.length?"":"?"+e.join("&")}}},{}],38:[function(t,e,n){"use strict";var i=t("./array");e.exports=function(t,e){for(var n in t)if(i.indexOf(e,n)<0)throw new Error("Unrecognized option: "+n)}},{"./array":26}],39:[function(t,e,n){(function(t){"use strict";var n=t.MozWebSocket||t.WebSocket;e.exports={create:function(t,e,i){return"function"!=typeof n?null:new n(t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],40:[function(t,e,n){function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function r(t){if(h===setTimeout)return setTimeout(t,0);if((h===i||!h)&&setTimeout)return h=setTimeout,setTimeout(t,0);try{return h(t,0)}catch(e){try{return h.call(null,t,0)}catch(e){return h.call(this,t,0)}}}function o(t){if(f===clearTimeout)return clearTimeout(t);if((f===s||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function c(){v&&p&&(v=!1,p.length?_=p.concat(_):g=-1,_.length&&a())}function a(){if(!v){var t=r(c);v=!0;for(var e=_.length;e;){for(p=_,_=[];++g<e;)p&&p[g].run();g=-1,e=_.length}p=null,v=!1,o(t)}}function u(t,e){this.fun=t,this.array=e}function l(){}var h,f,d=e.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:i}catch(t){h=i}try{f="function"==typeof clearTimeout?clearTimeout:s}catch(t){f=s}}();var p,_=[],v=!1,g=-1;d.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];_.push(new u(t,e)),1!==_.length||v||r(a)},u.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=l,d.addListener=l,d.once=l,d.off=l,d.removeListener=l,d.removeAllListeners=l,d.emit=l,d.prependListener=l,d.prependOnceListener=l,d.listeners=function(t){return[]},d.binding=function(t){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(t){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},{}]},{},[2])(2)}); //# sourceMappingURL=jsforce-api-streaming.min.js.map