UNPKG

@deskdirector/push-events

Version:

chat utilities for DeskDirector chat

12 lines 107 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PushEvents=t():e.PushEvents=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=17)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__extends=o,r.d(t,"__assign",function(){return i}),t.__rest=s,t.__decorate=a,t.__param=u,t.__esDecorate=function(e,t,r,n,o,i){function s(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,u=n.kind,c="getter"===u?"get":"setter"===u?"set":"value",f=!t&&e?n.static?e:e.prototype:null,l=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),h=!1,p=r.length-1;p>=0;p--){var d={};for(var v in n)d[v]="access"===v?{}:n[v];for(var v in n.access)d.access[v]=n.access[v];d.addInitializer=function(e){if(h)throw new TypeError("Cannot add initializers after decoration has completed");i.push(s(e||null))};var y=(0,r[p])("accessor"===u?{get:l.get,set:l.set}:l[c],d);if("accessor"===u){if(void 0===y)continue;if(null===y||"object"!=typeof y)throw new TypeError("Object expected");(a=s(y.get))&&(l.get=a),(a=s(y.set))&&(l.set=a),(a=s(y.init))&&o.unshift(a)}else(a=s(y))&&("field"===u?o.unshift(a):l[c]=a)}f&&Object.defineProperty(f,n.name,l);h=!0},t.__runInitializers=function(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0},t.__propKey=function(e){return"symbol"==typeof e?e:"".concat(e)},t.__setFunctionName=function(e,t,r){"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):"");return Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})},t.__metadata=c,t.__awaiter=f,t.__generator=l,r.d(t,"__createBinding",function(){return h}),t.__exportStar=p,t.__values=d,t.__read=v,t.__spread=y,t.__spreadArrays=_,t.__spreadArray=g,t.__await=b,t.__asyncGenerator=w,t.__asyncDelegator=m,t.__asyncValues=E,t.__makeTemplateObject=S,t.__importStar=P,t.__importDefault=O,t.__classPrivateFieldGet=x,t.__classPrivateFieldSet=C,t.__classPrivateFieldIn=A,t.__addDisposableResource=R,t.__disposeResources=U;var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function a(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function u(e,t){return function(r,n){t(r,n,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):function(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(s,a)}u((n=n.apply(e,t||[])).next())})}function l(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var h=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&("get"in o?t.__esModule:!o.writable&&!o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function p(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||h(t,e,r)}function d(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function _(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}function g(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function w(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n={},s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){o[e]&&(n[e]=function(t){return new Promise(function(r,n){i.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof b?Promise.resolve(e.value.v).then(u,c):f(i[0][2],e)}(o[e](t))}catch(e){f(i[0][3],e)}}function u(e){a("next",e)}function c(e){a("throw",e)}function f(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function m(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:b(e[n](t)),done:!1}:o?o(t):t}:o}}function E(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=d(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,o,(t=e[r](t)).done,t.value)})}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function P(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&h(t,e,r);return T(t,e),t}function O(e){return e&&e.__esModule?e:{default:e}}function x(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function C(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}function A(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function R(e,t,r){if(null!==t&&void 0!==t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var j="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function U(e){function t(t){e.error=e.hasError?new j(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function r(){for(;e.stack.length;){var n=e.stack.pop();try{var o=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(o).then(r,function(e){return t(e),r()})}catch(e){t(e)}}if(e.hasError)throw e.error}()}t.default={__extends:o,__assign:i,__rest:s,__decorate:a,__param:u,__metadata:c,__awaiter:f,__generator:l,__createBinding:h,__exportStar:p,__values:d,__read:v,__spread:y,__spreadArrays:_,__spreadArray:g,__await:b,__asyncGenerator:w,__asyncDelegator:m,__asyncValues:E,__makeTemplateObject:S,__importStar:P,__importDefault:O,__classPrivateFieldGet:x,__classPrivateFieldSet:C,__classPrivateFieldIn:A,__addDisposableResource:R,__disposeResources:U}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(33),t),n.__exportStar(r(36),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(40),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(2),t),n.__exportStar(r(41),t),n.__exportStar(r(53),t),n.__exportStar(r(57),t),n.__exportStar(r(62),t),n.__exportStar(r(67),t),n.__exportStar(r(70),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sseEvents=t.SseEvents=void 0;var n=r(16),o=r(111),i=function(){return function(){this.notifications=new n.NotificationEvents,this.sessions=new n.SessionEvents,this.tickets=new n.TicketEvents,this.users=new n.UserEvents,this.connection=new o.ConnectionEvents}}();t.SseEvents=i,t.sseEvents=new i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SseReceiver=void 0;var n=r(0),o=r(9),i=r(1),s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.__extends(t,e),t.prototype.noSuchMethod=function(e,t){i.logger.warn("Unhandled target ".concat(e," was sent to the ").concat(this.name," receiver")),i.logger.warn("Message: ".concat(t))},t}(o.ServerEventReceiver);t.SseReceiver=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpError=void 0;var n=function(){return function(e){this.status=e.status,this.statusText=e.statusText,this.data=e.data}}();t.HttpError=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(25),t),n.__exportStar(r(8),t),n.__exportStar(r(4),t),n.__exportStar(r(3),t),n.__exportStar(r(16),t),n.__exportStar(r(12),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SseClient=void 0;var n=r(0),o=r(26),i=r(9),s=r(1),a=r(12),u=r(3),c=r(74),f=r(4),l=function(){function e(e,t,r){var n=this;this.config=e,this.api=t,this.authBeforeConnect=r,this.isConnecting=!1,this.isConnected=!1,this.onBeforeUnload=function(e){n.disconnect()}}return Object.defineProperty(e.prototype,"Config",{get:function(){return this.config},set:function(e){this.config=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"IsConnected",{get:function(){return this.isConnected},enumerable:!1,configurable:!0}),e.prototype.connect=function(){return n.__awaiter(this,void 0,void 0,function(){var e;return n.__generator(this,function(t){switch(t.label){case 0:if(this.isConnecting||this.isConnected)return[2];s.logger.info("Connecting to messaging server"),this.isConnecting=!0,t.label=1;case 1:return t.trys.push([1,4,5,6]),this.authBeforeConnect?[4,this.api.authenticate(this.config)]:[3,3];case 2:t.sent(),t.label=3;case 3:return this.createClient(),[3,6];case 4:if(!((e=t.sent())instanceof a.MessagingAuthError))throw e;return this.onError(e),[3,6];case 5:return this.isConnecting=!1,[7];case 6:return[2]}})})},e.prototype.reconnect=function(){return n.__awaiter(this,void 0,void 0,function(){return n.__generator(this,function(e){switch(e.label){case 0:return[4,this.disconnect()];case 1:return e.sent(),[2,this.connect()]}})})},e.prototype.disconnect=function(){return n.__awaiter(this,void 0,void 0,function(){return n.__generator(this,function(e){switch(e.label){case 0:return this.client?(s.logger.info("Stopping server events client"),[4,this.client.stop()]):[2];case 1:return e.sent(),this.isConnected=!1,f.sseEvents.connection.disconnected.raise(new u.DisconnectedEvent),window.removeEventListener("beforeunload",this.onBeforeUnload),s.logger.info("Removing messaging server cookies"),[4,this.api.logout(this.config)];case 2:return[2,e.sent()]}})})},e.prototype.createClient=function(){s.logger.info("Creating new server events client");var e=this.config.token,t=e.tokenType?e.tokenType:"Bearer",r="".concat(t," ").concat(e.token),n=new o.EventSourcePolyfill(this.getStreamUrl(),{withCredentials:!0,headers:{Authorization:r}}),a=this.client=new i.ServerEventsClient(this.config.url,this.config.channels,void 0,n);n.addEventListener("error",a.onError),n.addEventListener("message",function(e){return a.onMessage(e)}),this.registerReceivers(),this.client.start()},e.prototype.getStreamUrl=function(){var e,t,r=(0,i.combinePaths)(this.config.url,"event-stream")+"?",n=null!==(t=null===(e=this.config.channels)||void 0===e?void 0:e.join(","))&&void 0!==t?t:"";return r+="channels=".concat(n),r+="&t=".concat((new Date).getTime())},e.prototype.registerReceivers=function(){var e=this;if(this.client){var t=new c.ChatSessionReceiver,r=new c.TicketReceiver,n=new c.NotificationReceiver,o=new c.UserReceiver;this.client.registerNamedReceiver(t.name,t),this.client.registerNamedReceiver(r.name,r),this.client.registerNamedReceiver(n.name,n),this.client.registerNamedReceiver(o.name,o),this.client.registerHandler("onDdPulse",function(){return e.onDdPulse()}),this.client.registerHandler("onConnect",function(t){return e.onConnect(t)}),this.client.onError=function(t){return e.onError(t)}}},e.prototype.onConnect=function(e){this.isConnected=!0;var t=new u.ConnectedEvent(e);f.sseEvents.connection.connected.raise(t),s.logger.info("Connected to event stream"),s.logger.info(t),window.addEventListener("beforeunload",this.onBeforeUnload)},e.prototype.onError=function(e){this.disconnect(),s.logger.error("Error received from server event client"),s.logger.error(e)},e.prototype.onDdPulse=function(){s.logger.info("Received pulse")},e}();t.SseClient=l},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),r(31);var n=function(){return function(){}}();t.ResponseStatus=n;var o=function(){return function(){}}();t.ResponseError=o;var i=function(){return function(){}}();t.ErrorResponse=i;var s=function(){function e(){}return e.prototype.tryResolve=function(e){return new e},e}();t.NewInstanceResolver=s;var a=function(){function e(){}return e.prototype.tryResolve=function(e){return e.instance||(e.instance=new e)},e}();t.SingletonInstanceResolver=a;var u={onConnect:"ServerEventConnect",onHeartbeat:"ServerEventHeartbeat",onJoin:"ServerEventJoin",onLeave:"ServerEventLeave",onUpdate:"ServerEventUpdate"};!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSED=2]="CLOSED"}(t.ReadyState||(t.ReadyState={}));var c=function(){function e(e,r,n,o){void 0===n&&(n={}),void 0===o&&(o=null);var i=this;if(this.channels=r,this.options=n,this.eventSource=o,this.onMessage=function(e){if(!i.stopped){var r=i.options;if(void 0===n)var n={querySelectorAll:function(e){return[]}};var o=t.splitOnFirst(e.data," "),s=null,a=o[0],c=t.splitOnFirst(a,"@");c.length>1&&(s=c[0],a=c[1]);var f=o[1],l=null;try{l=f?JSON.parse(f):null}catch(e){}if((o=t.splitOnFirst(a,".")).length<=1)throw"invalid selector format: "+a;var h=o[0],p=o[1].replace(new RegExp("%20","g")," "),d=t.splitOnFirst(p,"$"),v=d[0],y=d[1],_=y&&n.querySelectorAll(y),g=_&&_[0],b={eventId:parseInt(e.lastEventId),data:e.data,type:u[v]||"ServerEventMessage",channel:s,selector:a,json:f,body:l,op:h,target:d[0],cssSelector:y,meta:{}},w="object"==typeof l?Object.assign({},b,l):b;if(!r.validate||!1!==r.validate(b)){var m=new Headers;if(m.set("Content-Type","text/plain"),"cmd"===h)if("onConnect"===v){if(i.connectionInfo=w,"string"==typeof l.heartbeatIntervalMs&&(i.connectionInfo.heartbeatIntervalMs=parseInt(l.heartbeatIntervalMs)),"string"==typeof l.idleTimeoutMs&&(i.connectionInfo.idleTimeoutMs=parseInt(l.idleTimeoutMs)),Object.assign(r,l),(T=r.handlers.onConnect)&&(T.call(g||n.body,i.connectionInfo,b),i.stopped))return;r.heartbeatUrl&&(r.heartbeat&&clearInterval(r.heartbeat),r.heartbeat=setInterval(function(){if(i.eventSource.readyState===EventSource.CLOSED){clearInterval(r.heartbeat);var e=r.handlers.onStop;return null!=e&&e.apply(i.eventSource),void i.reconnectServerEvents({error:new Error("EventSource is CLOSED")})}fetch(new Request(r.heartbeatUrl,{method:"POST",mode:"cors",headers:m})).then(function(e){if(!e.ok)throw new Error(e.status+" - "+e.statusText)}).catch(function(e){return i.reconnectServerEvents({error:e})})},i.connectionInfo&&i.connectionInfo.heartbeatIntervalMs||r.heartbeatIntervalMs||1e4)),r.unRegisterUrl&&"undefined"!=typeof window&&(window.onunload=function(){return i.stop()}),i.updateSubscriberUrl=r.updateSubscriberUrl,i.updateChannels((r.channels||"").split(","))}else{var E="onJoin"==v||"onLeave"==v||"onUpdate"==v;if(T=r.handlers[v])E?T.call(g||n.body,w):T.call(g||n.body,l,b);else if(!E){var S=r.receivers&&r.receivers.cmd;i.invokeReceiver(S,v,g,b,"cmd")}E&&(T=r.handlers.onCommand)&&T.call(g||n.body,w)}else"trigger"===h?i.raiseEvent(p,b):"css"===h&&t.css(_||n.querySelectorAll("body"),v,l);var T;S=r.receivers&&r.receivers[h];if(i.invokeReceiver(S,v,g,b,h),!u[v])(T=r.handlers.onMessage)&&T.call(g||n.body,w);r.onTick&&r.onTick()}}},this.onError=function(e){if(!i.stopped){e||(e=event);var t=i.options.onException;null!=t&&t.call(i.eventSource,e),i.options.onTick&&i.options.onTick()}},0===this.channels.length)throw"at least 1 channel is required";this.resolver=this.options.resolver||new s,this.eventStreamUri=t.combinePaths(e,"event-stream")+"?",this.updateChannels(r),this.serviceClient=new g(e),this.listeners={},this.withCredentials=!0,this.options.handlers||(this.options.handlers={})}return e.prototype.getEventSourceOptions=function(){return{withCredentials:this.withCredentials}},e.prototype.reconnectServerEvents=function(e){var t=this;if(void 0===e&&(e={}),!this.stopped){e.error&&this.onError(e.error);var r=this.eventSource,n=e.url||this.eventStreamUri||r.url;null!=this.options.resolveStreamUrl&&(n=this.options.resolveStreamUrl(n));var o=this.EventSource?new this.EventSource(n,this.getEventSourceOptions()):new EventSource(n,this.getEventSourceOptions());o.addEventListener("error",function(n){return e.onerror||r.onerror||t.onError}),o.addEventListener("message",e.onmessage||r.onmessage||this.onMessage);var i=this.options.onReconnect;return null!=i&&i.call(o,e.error),r.removeEventListener&&(r.removeEventListener("error",this.onError),r.removeEventListener("message",this.onMessage)),r.close(),this.eventSource=o}},e.prototype.start=function(){var e=this;if(this.stopped=!1,null==this.eventSource||this.eventSource.readyState===EventSource.CLOSED){var t=this.eventStreamUri;null!=this.options.resolveStreamUrl&&(t=this.options.resolveStreamUrl(t)),this.eventSource=this.EventSource?new this.EventSource(t,this.getEventSourceOptions()):new EventSource(t,this.getEventSourceOptions()),this.eventSource.addEventListener("error",this.onError),this.eventSource.addEventListener("message",function(t){return e.onMessage(t)})}return this},e.prototype.stop=function(){this.stopped=!0,this.eventSource&&this.eventSource.close();var e=this.options;e&&e.heartbeat&&clearInterval(e.heartbeat);var t=this.connectionInfo;return null==t||null==t.unRegisterUrl?new Promise(function(e,t){return e()}):(this.connectionInfo=null,fetch(new Request(t.unRegisterUrl,{method:"POST",mode:"cors"})).then(function(e){if(!e.ok)throw new Error(e.status+" - "+e.statusText)}).catch(this.onError))},e.prototype.invokeReceiver=function(e,t,r,n,o){if(e)if("function"==typeof e&&(e=this.resolver.tryResolve(e)),t=t.replace("-",""),e.client=this,e.request=n,"function"==typeof e[t])e[t].call(r||e,n.body,n);else if(t in e)e[t]=n.body;else{var i=t.toLowerCase();for(var s in e)if(s.toLowerCase()==i)return void("function"==typeof e[s]?e[s].call(r||e,n.body,n):e[s]=n.body);var a=e.noSuchMethod;"function"==typeof a&&a.call(r||e,n.target,n)}},e.prototype.hasConnected=function(){return null!=this.connectionInfo},e.prototype.registerHandler=function(e,t){return this.options.handlers||(this.options.handlers={}),this.options.handlers[e]=t,this},e.prototype.setResolver=function(e){return this.options.resolver=e,this},e.prototype.registerReceiver=function(e){return this.registerNamedReceiver("cmd",e)},e.prototype.registerNamedReceiver=function(e,t){return this.options.receivers||(this.options.receivers={}),this.options.receivers[e]=t,this},e.prototype.unregisterReceiver=function(e){return void 0===e&&(e="cmd"),this.options.receivers&&delete this.options.receivers[e],this},e.prototype.updateChannels=function(e){this.channels=e;var t=null!=this.eventSource?this.eventSource.url:this.eventStreamUri;this.eventStreamUri=t.substring(0,Math.min(t.indexOf("?"),t.length))+"?channels="+e.join(",")+"&t="+(new Date).getTime()},e.prototype.update=function(e,t){var r="string"==typeof e?e.split(","):e,n="string"==typeof t?t.split(","):t,o=[];for(var i in this.channels){var s=this.channels[i];null!=n&&-1!==n.indexOf(s)||o.push(s)}if(r)for(var i in r){s=r[i];-1===o.indexOf(s)&&o.push(s)}this.updateChannels(o)},e.prototype.addListener=function(e,t){return(this.listeners[e]||(this.listeners[e]=[])).push(t),this},e.prototype.removeListener=function(e,t){var r=this.listeners[e];if(r){var n=r.indexOf(t);n>=0&&r.splice(n,1)}return this},e.prototype.raiseEvent=function(e,t){var r=this,n=this.listeners[e];n&&n.forEach(function(e){try{e(t)}catch(e){r.onError(e)}})},e.prototype.getConnectionInfo=function(){if(null==this.connectionInfo)throw"Not Connected";return this.connectionInfo},e.prototype.getSubscriptionId=function(){return this.getConnectionInfo().id},e.prototype.updateSubscriber=function(e){var t=this;return null==e.id&&(e.id=this.getSubscriptionId()),this.serviceClient.post(e).then(function(r){t.update(e.subscribeChannels,e.unsubscribeChannels)}).catch(this.onError)},e.prototype.subscribeToChannels=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=new l;return n.id=this.getSubscriptionId(),n.subscribeChannels=t,this.serviceClient.post(n).then(function(r){e.update(t,null)}).catch(this.onError)},e.prototype.unsubscribeFromChannels=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=new l;return n.id=this.getSubscriptionId(),n.unsubscribeChannels=t,this.serviceClient.post(n).then(function(r){e.update(null,t)}).catch(this.onError)},e.prototype.getChannelSubscribers=function(){var e=this,t=new p;return t.channels=this.channels,this.serviceClient.get(t).then(function(t){return t.map(function(t){return e.toServerEventUser(t)})}).catch(function(t){return e.onError(t),[]})},e.prototype.toServerEventUser=function(e){var t=e.channels,r=new d;for(var n in r.userId=e.userId,r.displayName=e.displayName,r.profileUrl=e.profileUrl,r.channels=t?t.split(","):null,e)"userId"!=n&&"displayName"!=n&&"profileUrl"!=n&&"channels"!=n&&(null==r.meta&&(r.meta={}),r.meta[n]=e[n]);return r},e.UnknownChannel="*",e}();t.ServerEventsClient=c;var f=function(){function e(){}return e.prototype.noSuchMethod=function(e,t){},e}();t.ServerEventReceiver=f;var l=function(){function e(){}return e.prototype.createResponse=function(){return new h},e.prototype.getTypeName=function(){return"UpdateEventSubscriber"},e}();t.UpdateEventSubscriber=l;var h=function(){return function(){}}();t.UpdateEventSubscriberResponse=h;var p=function(){function e(){}return e.prototype.createResponse=function(){return[]},e.prototype.getTypeName=function(){return"GetEventSubscribers"},e}();t.GetEventSubscribers=p;var d=function(){return function(){}}();t.ServerEventUser=d;var v=function(){function e(){}return e.Get="GET",e.Post="POST",e.Put="PUT",e.Delete="DELETE",e.Patch="PATCH",e.Head="HEAD",e.Options="OPTIONS",e.hasRequestBody=function(e){return!("GET"===e||"DELETE"===e||"HEAD"===e||"OPTIONS"===e)},e}();t.HttpMethods=v;var y=function(){function e(){}return e.prototype.createResponse=function(){return new _},e.prototype.getTypeName=function(){return"GetAccessToken"},e}(),_=function(){return function(){}}();t.GetAccessTokenResponse=_;var g=function(){function e(e){if(null==e)throw"baseUrl is required";this.baseUrl=e,this.replyBaseUrl=t.combinePaths(e,"json","reply")+"/",this.oneWayBaseUrl=t.combinePaths(e,"json","oneway")+"/",this.mode="cors",this.credentials="include",this.headers=new Headers,this.headers.set("Content-Type","application/json"),this.manageCookies="undefined"==typeof document,this.cookies={}}return e.prototype.setCredentials=function(e,t){this.userName=e,this.password=t},e.prototype.setBearerToken=function(e){this.bearerToken=e},e.prototype.get=function(e,t){return"string"!=typeof e?this.send(v.Get,e,t):this.send(v.Get,null,t,this.toAbsoluteUrl(e))},e.prototype.delete=function(e,t){return"string"!=typeof e?this.send(v.Delete,e,t):this.send(v.Delete,null,t,this.toAbsoluteUrl(e))},e.prototype.post=function(e,t){return this.send(v.Post,e,t)},e.prototype.postToUrl=function(e,t,r){return this.send(v.Post,t,r,this.toAbsoluteUrl(e))},e.prototype.postBody=function(e,t,r){return this.sendBody(v.Post,e,t,r)},e.prototype.put=function(e,t){return this.send(v.Put,e,t)},e.prototype.putToUrl=function(e,t,r){return this.send(v.Put,t,r,this.toAbsoluteUrl(e))},e.prototype.putBody=function(e,t,r){return this.sendBody(v.Post,e,t,r)},e.prototype.patch=function(e,t){return this.send(v.Patch,e,t)},e.prototype.patchToUrl=function(e,t,r){return this.send(v.Patch,t,r,this.toAbsoluteUrl(e))},e.prototype.patchBody=function(e,t,r){return this.sendBody(v.Post,e,t,r)},e.prototype.createUrlFromDto=function(e,r){var n=t.combinePaths(this.replyBaseUrl,t.nameOf(r));return v.hasRequestBody(e)||(n=t.appendQueryString(n,r)),n},e.prototype.toAbsoluteUrl=function(e){return e.startsWith("http://")||e.startsWith("https://")?e:t.combinePaths(this.baseUrl,e)},e.prototype.createRequest=function(r){var n=this,o=r.method,i=r.request,s=r.url,a=r.args,u=r.body;if(s||(s=this.createUrlFromDto(o,i)),a&&(s=t.appendQueryString(s,a)),null!=this.bearerToken?this.headers.set("Authorization","Bearer "+this.bearerToken):null!=this.userName&&this.headers.set("Authorization","Basic "+e.toBase64(this.userName+":"+this.password)),this.manageCookies){var c=Object.keys(this.cookies).map(function(e){var t=n.cookies[e];return t.expires&&t.expires<new Date?null:t.name+"="+encodeURIComponent(t.value)}).filter(function(e){return!!e});c.length>0?this.headers.set("Cookie",c.join("; ")):this.headers.delete("Cookie")}var f={method:o,mode:this.mode,credentials:this.credentials,headers:this.headers,compress:!1},l=new Request(s,f);v.hasRequestBody(o)&&(l.body=u||JSON.stringify(i));var h={url:s};return null!=this.requestFilter&&this.requestFilter(l,h),[l,h]},e.prototype.createResponse=function(e,r){var n=this;if(!e.ok)throw e;if(this.manageCookies){var o=[];e.headers.forEach(function(e,t){"set-cookie"==t.toLowerCase()&&o.push(e)}),o.forEach(function(e){var r=t.parseCookie(e);r&&(n.cookies[r.name]=r)})}null!=this.responseFilter&&this.responseFilter(e);var i=r&&"string"!=typeof r&&"function"==typeof r.createResponse?r.createResponse():null;if("string"==typeof i)return e.text().then(function(e){return e});var s=e.headers.get("content-type"),a=s&&-1!==s.indexOf("application/json");if(a)return e.json().then(function(e){return e});if("undefined"!=typeof Uint8Array&&i instanceof Uint8Array){if("function"!=typeof e.arrayBuffer)throw new Error("This fetch polyfill does not implement 'arrayBuffer'");return e.arrayBuffer().then(function(e){return new Uint8Array(e)})}if("function"==typeof Blob&&i instanceof Blob){if("function"!=typeof e.blob)throw new Error("This fetch polyfill does not implement 'blob'");return e.blob().then(function(e){return e})}var u=e.headers.get("content-length");return"0"===u||null==u&&!a?i:e.json().then(function(e){return e})},e.prototype.handleError=function(e,r,n){var o=this;if(void 0===n&&(n=null),r instanceof Error)throw this.raiseError(e,r);if(r.bodyUsed)throw this.raiseError(r,b(r.status,r.statusText,n));return void 0===r.json&&r.responseStatus?new Promise(function(e,t){return t(o.raiseError(null,r))}):r.json().then(function(e){var o=t.sanitize(e);if(!o.responseStatus)throw b(r.status,r.statusText,n);throw null!=n&&(o.type=n),o}).catch(function(e){if(e instanceof Error||"undefined"!=typeof window&&e instanceof window.DOMException)throw o.raiseError(r,b(r.status,r.statusText,n));throw o.raiseError(r,e)})},e.prototype.send=function(e,t,r,n){return this.sendRequest({method:e,request:t,args:r,url:n})},e.prototype.sendBody=function(e,r,n,o){var i=t.combinePaths(this.replyBaseUrl,t.nameOf(r));return this.sendRequest({method:e,request:n,body:"string"==typeof n?n:JSON.stringify(n),url:t.appendQueryString(i,r),args:o,returns:r})},e.prototype.sendRequest=function(e){var t=this,r=this.createRequest(e),n=r[0],o=r[1],i=e.returns||e.request,s=null,a=function(){var r=t.createRequest(e),n=r[0],o=r[1];return fetch(o.url||n.url,n).then(function(e){return t.createResponse(e,i)}).catch(function(e){return t.handleError(s,e)})};return fetch(o.url||n.url,n).then(function(e){return s=e,t.createResponse(e,i)}).catch(function(e){if(401===e.status){if(t.refreshToken){var r=new y;r.refreshToken=t.refreshToken;var n=t.refreshTokenUri||t.createUrlFromDto(v.Post,r),o=t.createRequest({method:v.Post,request:r,args:null,url:n}),i=o[0];o[1];return fetch(n,i).then(function(e){return t.createResponse(e,r).then(function(e){return t.bearerToken=e.accessToken,a()})}).catch(function(e){return t.handleError(s,e,"RefreshTokenException")})}if(t.onAuthenticationRequired)return t.onAuthenticationRequired().then(a)}return t.handleError(s,e)})},e.prototype.raiseError=function(e,t){return null!=this.exceptionFilter&&this.exceptionFilter(e,t),t},e}();t.JsonServiceClient=g;var b=function(e,t,r){void 0===r&&(r=null);var o=new i;return null!=r&&(o.type=r),o.responseStatus=new n,o.responseStatus.errorCode=e&&e.toString(),o.responseStatus.message=t,o};t.toCamelCase=function(e){return e?e.charAt(0).toLowerCase()+e.substring(1):e},t.sanitize=function(e){if(e.responseStatus)return e;if(e.errors)return e;var r={};for(var n in e)e.hasOwnProperty(n)&&(e[n]instanceof Object?r[t.toCamelCase(n)]=t.sanitize(e[n]):r[t.toCamelCase(n)]=e[n]);if(r.errors=[],null!=e.Errors)for(var o=0,i=e.Errors.length;o<i;o++){var s=e.Errors[o],a={};for(var u in s)a[t.toCamelCase(u)]=s[u];r.errors.push(a)}return r},t.nameOf=function(e){if(!e)return"null";if("function"==typeof e.getTypeName)return e.getTypeName();var t=e&&e.constructor;if(null==t)throw e+" doesn't have constructor";if(t.name)return t.name;var r=t.toString();return r.substring(9,r.indexOf("("))},t.css=function(e,t,r){for(var n="string"==typeof e?document.querySelectorAll(e):e,o=0;o<n.length;o++){var i=n[o];null!=i&&null!=i.style&&(i.style[t]=r)}},t.splitOnFirst=function(e,t){if(!e)return[e];var r=e.indexOf(t);return r>=0?[e.substring(0,r),e.substring(r+1)]:[e]},t.splitOnLast=function(e,t){if(!e)return[e];var r=e.lastIndexOf(t);return r>=0?[e.substring(0,r),e.substring(r+1)]:[e]};t.humanize=function(e){return!e||e.indexOf(" ")>=0?e:function(e){return"string"!=typeof e?e:e.replace(/([A-Z]|[0-9]+)/g," $1").replace(/_/g," ").trim()}(e)},t.queryString=function(e){if(!e||-1===e.indexOf("?"))return{};for(var r=t.splitOnFirst(e,"?")[1].split("&"),n={},o=0;o<r.length;++o){var i=r[o].split("=");n[i[0]]=i.length>1?decodeURIComponent(i[1].replace(/\+/g," ")):null}return n},t.combinePaths=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r,n,o=[];for(r=0,n=e.length;r<n;r++){var i=e[r];o=-1===i.indexOf("://")?o.concat(i.split("/")):o.concat(i.lastIndexOf("/")===i.length-1?i.substring(0,i.length-1):i)}var s=[];for(r=0,n=o.length;r<n;r++){var a=o[r];a&&"."!==a&&(".."===a?s.pop():s.push(a))}return""===o[0]&&s.unshift(""),s.join("/")||(s.length?"/":".")},t.createPath=function(e,t){var r={};for(var n in t)r[n.toLowerCase()]=n;for(var o=e.split("/"),i="",s=0;s<o.length;s++){var a=o[s];if(null==a&&(a=""),"{"===a[0]&&"}"===a[a.length-1]){var u=r[a.substring(1,a.length-1).toLowerCase()];u&&(a=t[u],delete t[u])}i.length>0&&(i+="/"),i+=a}return i},t.createUrl=function(e,r){var n=t.createPath(e,r);return t.appendQueryString(n,r)},t.appendQueryString=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e+=e.indexOf("?")>=0?"&":"?",e+=r+"="+w(t[r]));return e};var w=function(e){return null==e?"":"undefined"!=typeof Uint8Array&&e instanceof Uint8Array?t.bytesToBase64(e):encodeURIComponent(e)||""};t.bytesToBase64=function(e){for(var t,r=(3-e.length%3)%3,n="",o=e.length,i=0,s=0;s<o;s++)t=s%3,i|=e[s]<<(16>>>t&24),2!==t&&e.length-s!=1||(n+=String.fromCharCode(m(i>>>18&63),m(i>>>12&63),m(i>>>6&63),m(63&i)),i=0);return 0===r?n:n.substring(0,n.length-r)+(1===r?"=":"==")};var m=function(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65},E="function"==typeof btoa?btoa:function(t){return new e(t).toString("base64")};g.toBase64=function(e){return E(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(new Number("0x"+t).valueOf())}))},t.stripQuotes=function(e){return e&&'"'==e[0]&&'"'==e[e.length]?e.slice(1,-1):e},t.tryDecode=function(e){try{return decodeURIComponent(e)}catch(t){return e}},t.parseCookie=function(e){if(!e)return null;for(var r=null,n=e.split(/; */),o=0;o<n.length;o++){var i=n[o],s=t.splitOnFirst(i,"="),a=s[0].trim(),u=s.length>1?t.tryDecode(t.stripQuotes(s[1].trim())):null;if(0==o)r={name:a,value:u,path:"/"};else{var c=a.toLowerCase();"httponly"==c?r.httpOnly=!0:"secure"==c?r.secure=!0:"expires"==c?(r.expires=new Date(u),"Invalid Date"===r.expires.toString()&&(r.expires=new Date(u.replace(/-/g," ")))):r[a]=u}}return r},t.normalizeKey=function(e){return e.toLowerCase().replace(/_/g,"")};t.normalize=function(e,r){if(function(e){return"[object Array]"===Object.prototype.toString.call(e)}(e)){if(!r)return e;for(var n=[],o=0;o<e.length;o++)n[o]=t.normalize(e[o],r);return n}if("object"!=typeof e)return e;var i={};for(var s in e)i[t.normalizeKey(s)]=r?t.normalize(e[s],r):e[s];return i},t.getField=function(e,r){return null==e||null==r?null:e[r]||e[Object.keys(e).filter(function(e){return t.normalizeKey(e)===t.normalizeKey(r)})[0]||""]},t.parseResponseStatus=function(e,r){void 0===r&&(r=null);try{var n=JSON.parse(e);return t.sanitize(n.ResponseStatus||n.responseStatus)}catch(t){return{message:r||t.message||t,__error:{error:t,json:e}}}},t.toDate=function(e){return new Date(parseFloat(/Date\(([^)]+)\)/.exec(e)[1]))},t.toDateFmt=function(e){return t.dateFmt(t.toDate(e))},t.padInt=function(e){return e<10?"0"+e:e},t.dateFmt=function(e){return void 0===e&&(e=new Date),e.getFullYear()+"/"+t.padInt(e.getMonth()+1)+"/"+t.padInt(e.getDate())},t.dateFmtHM=function(e){return void 0===e&&(e=new Date),e.getFullYear()+"/"+t.padInt(e.getMonth()+1)+"/"+t.padInt(e.getDate())+" "+t.padInt(e.getHours())+":"+t.padInt(e.getMinutes())},t.timeFmt12=function(e){return void 0===e&&(e=new Date),t.padInt((e.getHours()+24)%12||12)+":"+t.padInt(e.getMinutes())+":"+t.padInt(e.getSeconds())+" "+(e.getHours()>12?"PM":"AM")}}).call(t,r(27).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Disposable=void 0;var n=function(){return function(e){this.dispose=e.dispose}}();t.Disposable=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(39),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemMessage=t.Message=void 0;var n=r(2),o=function(){return function(e){this.id=e.mid,this.content=e.txt,this.createdDateTime=e.stamp,this.user=new n.User(e.user)}}();t.Message=o;var i=function(){return function(e){this.content=e.txt,this.createdDateTime=e.stamp}}();t.SystemMessage=i},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.NotificationType=void 0,function(e){e[e.Default=0]="Default",e[e.Ticket=1]="Ticket",e[e.TicketNote=2]="TicketNote",e[e.Global=20]="Global",e[e.Info=21]="Info"}(n||(t.NotificationType=n={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(75),t),n.__exportStar(r(77),t),n.__exportStar(r(90),t),n.__exportStar(r(96),t),n.__exportStar(r(101),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(107),t),n.__exportStar(r(108),t),n.__exportStar(r(109),t),n.__exportStar(r(110),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushEventsClient=t.Models=t.HttpError=t.EventModels=void 0;var n=r(18);Object.defineProperty(t,"PushEventsClient",{enumerable:!0,get:function(){return n.PushEventsClient}});var o=r(6);Object.defineProperty(t,"HttpError",{enumerable:!0,get:function(){return o.HttpError}});var i=r(3);t.Models=i;var s=r(15);t.EventModels=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(0).__exportStar(r(19),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(20),t),n.__exportStar(r(7),t),n.__exportStar(r(115),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(21),t),n.__exportStar(r(22),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);n.__exportStar(r(23),t),n.__exportStar(r(24),t),n.__exportStar(r(6),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sseClientFactory=void 0;var n=r(8);t.sseClientFactory=new(function(){function e(){}return e.prototype.getInstance=function(e,t,r){return new n.SseClient(e,t,r)},e}())},function(e,t,r){var n,o,i; /** @license * eventsource.js * Available under MIT License (MIT) * https://github.com/Yaffle/EventSource/ */ /** @license * eventsource.js * Available under MIT License (MIT) * https://github.com/Yaffle/EventSource/ */ !function(r){"use strict";var s=r.setTimeout,a=r.clearTimeout,u=r.XMLHttpRequest,c=r.XDomainRequest,f=r.ActiveXObject,l=r.EventSource,h=r.document,p=r.Promise,d=r.fetch,v=r.Response,y=r.TextDecoder,_=r.TextEncoder,g=r.AbortController;if("undefined"==typeof window||void 0===h||"readyState"in h||null!=h.body||(h.readyState="loading",window.addEventListener("load",function(e){h.readyState="complete"},!1)),null==u&&null!=f&&(u=function(){return new f("Microsoft.XMLHTTP")}),void 0==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),void 0==g){var b=d;d=function(e,t){var r=t.signal;return b(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then(function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}})},g=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function w(){this.bitsNeeded=0,this.codePoint=0}w.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n="",o=this.bitsNeeded,i=this.codePoint,s=0;s<e.length;s+=1){var a=e[s];0!==o&&(a<128||a>191||!t(i<<6|63&a,o-6,r(o,i)))&&(o=0,i=65533,n+=String.fromCharCode(i)),0===o?(a>=0&&a<=127?(o=0,i=a):a>=192&&a<=223?(o=6,i=31&a):a>=224&&a<=239?(o=12,i=15&a):a>=240&&a<=247?(o=18,i=7&a):(o=0,i=65533),0===o||t(i,o,r(o,i))||(o=0,i=65533)):(o-=6,i=i<<6|63&a),0===o&&(i<=65535?n+=String.fromCharCode(i):(n+=String.fromCharCode(55296+(i-65535-1>>10)),n+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=o,this.codePoint=i,n};void 0!=y&&void 0!=_&&function(){try{return"test"===(new y).decode((new _).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(y=w);var m=function(){};function E(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=m,this.onload=m,this.onerror=m,this.onreadystatechange=m,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=m}function S(e){return e.replace(/[A-Z]/g,function(e){return String.fromCharCode(e.charCodeAt(0)+32)})}function T(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),i=o.shift(),s=o.join(": ");t[S(i)]=s}this._map=t}function P(){}function O(e){this._headers=e}function x(){}function C(){this._listeners=Object.create(null)}function A(e){s(function(){throw e},0)}function R(e){this.type=e,this.target=void 0}function j(e,t){R.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function U(e,t){R.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function M(e,t){R.call(this,e),this.error=t.error}E.prototype.open=function(e,t){this._abort(!0);var r=this,n=this._xhr,o=1,i=0;this._abort=function(e){0!==r._sendTimeout&&(a(r._sendTimeout),r._sendTimeout=0),1!==o&&2!==o&&3!==o||(o=4,n.onload=m,n.onerror=m,n.onabort=m,n.onprogress=m,n.onreadystatechange=m,n.abort(),0!==i&&(a(i),i=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),o=0};var c=function(){if(1===o){var e=0,t="",i=void 0;if("contentType"in n)e=200,t="OK",i=n.contentType;else try{e=n.status,t=n.statusText,i=n.getResponseHeader("Content-Type")}catch(r){e=0,t="",i=void 0}0!==e&&(o=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=i,r.onreadystatechange())}},f=function(){if(c(),2===o||3===o){o=3;var e="";try{e=n.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},l=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:m}),f(),1===o||2===o||3===o){if(o=4,0!==i&&(a(i),i=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},h=function(){i=s(function(){h()},500),3===n.readyState&&f()};"onload"in n&&(n.onload=function(e){l("load",e)}),"onerror"in n&&(n.onerror=function(e){l("error",e)}),"onabort"in n&&(n.onabort=function(e){l("abort",e)}),"onprogress"in n&&(n.onprogress=f),"onreadystatechange"in n&&(n.onreadystatechange=function(e){!function(e){void 0!=n&&(4===n.readyState?"onload"in n&&"onerror"in n&&"onabort"in n||l(""===n.responseText?"error":"load",e):3===n.readyState?"onprogress"in n||f():2===n.readyState&&c())}(e)}),!("contentType"in n)&&"ontimeout"in u.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),n.open(e,t,!0),"readyState"in n&&(i=s(function(){h()},0))},E.prototype.abort=function(){this._abort(!1)},E.prototype.getResponseHeader=function(e){return this._contentType},E.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},E.prototype.getAllResponseHeaders=function(){return void 0!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},E.prototype.send=function(){if("ontimeout"in u.prototype&&("sendAsBinary"in u.prototype||"mozAnon"in u.prototype)||void 0==h||void 0==h.readyState||"complete"===h.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=s(function(){t._sendTimeout=0,t.send()},4)}},T.prototype.get=function(e){return this._map[S(e)]},null!=u&&null==u.HEADERS_RECEIVED&&(u.HEADERS_RECEIVED=2),P.prototype.open=function(e,t,r,n,o,i,s){e.open("GET",o);var a=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(a);a+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===u.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new T(i))}},e.withCredentials=i,s)Object.prototype.hasOwnProperty.call(s,c)&&e.setRequestHeader(c,s[c]);return e.send(),e},O.prototype.get=function(e){return this._headers.get(e)},x.prototype.open=function(e,t,r,n,o,i,s){var a=null,u=new g,c=u.signal,f=new y;return d(o,{headers:s,credentials:i?"include":"same-origin",signal:c,cache:"no-store"}).then(function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new O(e.headers)),new p(function(e,t){var n=function(){a.read().then(function(t){if(t.done)e(void 0);else{var o=f.decode(t.value,{stream:!0});r(o),n()}}).catch(function(e){t(e)})};n()})}).catch(function(e){return"AbortError"===e.name?void 0:e}).then(function(e){n(e)}),{abort:function(){null!=a&&a.cancel(),u.abort()}}},C.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(void 0!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){A(e)}}},C.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];void 0==n&&(n=[],r[e]=n);for(var o=!1,i=0;i<n.length;i+=1)n[i]===t&&(o=!0);o||n.push(t)},C.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(void 0!=n){for(var o=[],i=0;i<n.length;i+=1)n[i]!==t&&o.push(n[i]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(R.prototype),U.prototype=Object.create(R.prototype),M.prototype=Object.create(R.prototype);var I=-1,B=0,D=1,k=2,N=-1,L=0,F=1,H=2,q=3,Y=/^text\/event\-stream(;.*)?$/i,z=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),G(r)},G=function(e){return Math.min(Math.max(e,1e3),18e6)},V=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){A(e)}};function J(e,t){C.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var n=Boolean(r.withCredentials),o=r.lastEventIdQueryParameterName||"lastEventId",i=G(1e3),f=z(r.heartbeatTimeout,45e3),l="",h=i,p=!1,d=0,v=r.headers||{},y=r.Transport,_=Q&&void 0==y?void 0:new E(void 0!=y?new y:void 0!=u&&"withCredentials"in u.prototype||void 0==c?new u:new c),g=null!=y&&"string"!=typeof y?new y:void 0==_?new x:new P,b=void 0,w=0,m=I,S="",T="",O="",C="",A=L,R=0,J=0,X=function(t,r,n,o){if(m===B)if(200===t&&void 0!=n&&Y.test(n)){m=D,p=Date.now(),h=i,e.readyState=D;var s=new U("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),V(e,e.onopen,s)}else{var a="";200!==t?(r&&(r=r.replace(/\s+/g," ")),a="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):a="EventSource's response has a Content-Type specifying an unsupported type: "+(void 0==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",$();var s=new U("error",{status:t,statusT