compass.js
Version:
Compass Javascript Library =============
1 lines • 44.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery"),require("rxjs"),require("strophe.js"),require("strophejs-plugin-pubsub")):"function"==typeof define&&define.amd?define(["jquery","rxjs","strophe.js","strophejs-plugin-pubsub"],t):"object"==typeof exports?exports.compass=t(require("jquery"),require("rxjs"),require("strophe.js"),require("strophejs-plugin-pubsub")):e.compass=t(e.jQuery,e.rxjs,e.window,e["strophejs-plugin-pubsub"])}(window,(function(e,t,n,r){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compassLogger=t.rootLogger=void 0;var r=n(10);t.rootLogger=r,t.compassLogger=t.rootLogger.getLogger("CompassJS"),t.compassLogger.setLevel(t.compassLogger.levels.WARN)},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.Model=t.Queue=t.QueueMember=t.User=t.Language=t.QueueCallPoint=t.ListenInCallPoint=t.ResourceCallPoint=t.UserCallPoint=t.DialplanCallPoint=t.ExternalCallPoint=t.CallPoint=t.ResourceType=t.CallPointType=t.Call=t.Company=t.CompassObject=t.OtherSide=t.WrapupState=t.ReceiveCalls=t.UserStatus=t.Side=t.CallEndReason=t.CallPointState=t.CallState=void 0;var i,s,a=n(8),u=n(3);!function(e){e.connecting="CONNECTING",e.ringing="RINGING",e.answered="ANSWERED",e.on_hold="ON_HOLD",e.disconnected="DISCONNECTED"}(t.CallState||(t.CallState={})),function(e){e.connecting="CONNECTING",e.ringing="RINGING",e.answered="ANSWERED",e.inactive="INACTIVE",e.disconnected="DISCONNECTED"}(i=t.CallPointState||(t.CallPointState={})),function(e){e.sourceHangup="SOURCE_HANGUP",e.destinationHangup="DESTINATION_HANGUP",e.destinationBusy="DESTINATION_BUSY",e.unknown="unknown"}(t.CallEndReason||(t.CallEndReason={})),function(e){e[e.source=0]="source",e[e.destination=1]="destination"}(s=t.Side||(t.Side={}));var l=function(e,t,n){this.receiveCalls=e,this.displayStatus=t,this.wrapupState=n};t.UserStatus=l,function(e){e.all="ALL",e.none="NONE",e.onlyDirect="ONLY_DIRECT"}(t.ReceiveCalls||(t.ReceiveCalls={}));var c=function(e,t){this.callId=e,this.endTime=t};t.WrapupState=c,t.OtherSide=function(e){return e===s.source?s.destination:s.source};var p=function(){function e(e,t,n){this.id=e,this.domain=n,this.xmlElement=t}return e.prototype.toString=function(){return this.constructor.name+"("+this.id+")"},e}();t.CompassObject=p;var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(p);t.Company=d;var f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getEndpoint=function(e){return e===s.source?this.source:this.destination},t}(p);t.Call=f,function(e){e.unknown="Unknown",e.user="User",e.dialplan="Dialplan",e.external="External",e.resource="Resource",e.queue="Queue",e.listenIn="ListenIn"}(t.CallPointType||(t.CallPointType={})),function(e){e.conference="conference",e.extension="extension",e.forward="forward",e.ivr="ivr",e.musiconhold="musiconhold",e.nameprefix="nameprefix",e.phone="phone",e.voicemail="voicemail",e.dpswitch="dpswitch",e.externalNumber="externalNumber",e.input="input"}(t.ResourceType||(t.ResourceType={}));var h=function(e){function t(t,n,r){var o=e.call(this,t,n,r)||this;return o.state=i.inactive,o}return o(t,e),t.prototype.getDuration=function(){return T(this.timeCreated)},t.prototype.getAnsweredDuration=function(){return T(this.timeStarted)},t}(p);t.CallPoint=h;var m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(h);t.ExternalCallPoint=m;var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(h);t.DialplanCallPoint=y;var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getUser=function(){return this.domain.users[this.userId]},t}(h);t.UserCallPoint=v;var g=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(h);t.ResourceCallPoint=g;var b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getListenedToCall=function(){return this.domain.calls[this.listenedToCallId]},t}(h);t.ListenInCallPoint=b;var C=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getQueue=function(){return this.domain.queues[this.queueId]},t}(h);t.QueueCallPoint=C,function(e){e.nl="nl",e.en="en"}(t.Language||(t.Language={}));var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensions=[],t}return o(t,e),t.prototype.getQueues=function(){var e=this;return Object.values(this.domain.queues).filter((function(t){return t.isUserInQueue(e.id)}))},t.prototype.getPausedQueues=function(){var e=this;return Object.values(this.domain.queues).filter((function(t){return t.isUserPausedInQueue(e.id)}))},t.prototype.getCalls=function(){var e=this,t=function(t){return t instanceof v&&t.userId===e.id};return Object.values(this.domain.calls).filter((function(e){return t(e.source)||t(e.destination)}))},t}(p);t.User=w;var P=function(){function e(e,t,n,r,o){this.priority=0,this.pausedSince=0,this.userId=e,this.queueId=t,this.setPriority(n),this.setPausedSince(r),this.domain=o}return e.prototype.setPriority=function(e){var t=parseInt(e);isNaN(t)||(this.priority=t)},e.prototype.setPausedSince=function(e){var t=parseInt(e);isNaN(t)?this.pausedSince=0:this.pausedSince=t},e.prototype.isPaused=function(){return this.pausedSince>0},e.prototype.getUser=function(){return this.domain.users[this.userId]},e.prototype.getQueue=function(){return this.domain.queues[this.queueId]},e}();t.QueueMember=P;var _=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.queueMembers=[],t}return o(t,e),t.prototype.getUsers=function(){return this.queueMembers.map((function(e){return e.getUser()})).filter((function(e){return null!=e}))},t.prototype.getPausedUsers=function(){var e=this;return this.queueMembers.filter((function(t){return null!=e.domain.users[t.userId]&&t.isPaused()})).map((function(e){return e.getUser()}))},t.prototype.isUserInQueue=function(e){return this.queueMembers.some((function(t){return t.userId===e}))},t.prototype.isUserPausedInQueue=function(e){return this.queueMembers.some((function(t){return t.userId===e&&t.isPaused()}))},t.prototype.getQueueMember=function(e){for(var t=0,n=this.queueMembers;t<n.length;t++){var r=n[t];if(r.userId===e)return r}return null},t.prototype.getCalls=function(){var e=this,t=function(t){return t instanceof C&&t.queueId===e.id};return Object.values(this.domain.calls).filter((function(e){return t(e.source)||t(e.destination)}))},t}(p);t.Queue=_;var E=function(){function e(){this.usersSubject=new a.Subject,this.callsSubject=new a.Subject,this.queuesSubject=new a.Subject,this.callsObservable=this.callsSubject.asObservable(),this.usersObservable=this.usersSubject.asObservable(),this.queuesObservable=this.queuesSubject.asObservable(),this.calls={},this.users={},this.queues={}}return e.prototype.notifyConnected=function(){this.usersSubject.next(new u.Event(null,u.EventType.Invalidated,null)),this.queuesSubject.next(new u.Event(null,u.EventType.Invalidated,null)),this.callsSubject.next(new u.Event(null,u.EventType.Invalidated,null))},e.prototype.getUserForJid=function(e){return Object.values(this.users).find((function(t){return t.jid===e}))},e.prototype.notify=function(e){if(e.emitter instanceof _)this.queuesSubject.next(e);else if(e.emitter instanceof f)this.callsSubject.next(e);else{if(!(e.emitter instanceof w))throw new Error("Invalid emitter: "+e.emitter);this.usersSubject.next(e)}},e.prototype.clear=function(){this.calls={},this.callsSubject.complete(),this.users={},this.usersSubject.complete(),this.queues={},this.queuesSubject.complete()},e}();function T(e){if(!e)return NaN;var t=(new Date).getTime()/1e3-e;return t<0?0:t}t.Model=E},function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=t.EventType=void 0,function(e){e.Added="Added",e.Removed="Removed",e.Changed="Changed",e.CallAdded="CallAdded",e.CallRemoved="CallRemoved",e.QueueAdded="QueueAdded",e.QueueRemoved="QueueRemoved",e.UserAdded="UserAdded",e.UserRemoved="UserRemoved",e.Paused="Paused",e.Unpaused="Unpaused",e.PropertyChanged="PropertyChanged",e.Invalidated="Invalidated"}(t.EventType||(t.EventType={}));var r=function(e,t,n){void 0===n&&(n=null),this.emitter=e,this.eventType=t,this.data=n};t.Event=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64EncodeUnicode=t.randomstring=void 0,t.randomstring=function(e){void 0===e&&(e=10);for(var t,n="";n.length<e;)n+=(t=void 0,(t=Math.floor(62*Math.random()))<10?t:t<36?String.fromCharCode(t+55):String.fromCharCode(t+61));return n},t.b64EncodeUnicode=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})))}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RestApi=void 0;var i=n(0),s=n(2),a=n(4),u=[3,2],l=function(){function e(e,t,n){this._user=null,this._myCompanyUrlPromise=null,this._myFirstIdentityPromise=null,this._basedom=e,this._username=t,this.authHeader="Basic "+a.b64EncodeUnicode(this._username+":"+n),this.baseUrl="https://rest."+this._basedom}return e.prototype.get=function(e,t){return void 0===t&&(t=null),this.doRequest(e,"GET",t)},e.prototype.post=function(e,t){return void 0===t&&(t=null),this.doRequest(e,"POST",t)},e.prototype.patch=function(e,t){return this.doRequest(e,"PATCH",t)},e.prototype.delete=function(e){return this.doRequest(e,"DELETE",void 0)},e.prototype.doRequest=function(e,t,n){var r=this;return this.determineApiVersion().then((function(){return r.doRequestInternal(e,t,n)}))},e.prototype.doRequestInternal=function(e,t,n){var r=-1===e.indexOf("://")?"https://rest."+this._basedom+"/"+e:e,o="application/vnd.iperity.compass.v"+this._apiVersion+"+json",a=s.ajax(r,{method:t,headers:{Accept:o,Authorization:this.authHeader,"X-No-Redirect":"true"},contentType:o,dataType:"json",data:JSON.stringify(n),dataFilter:function(e){return""===e?"{}":e}}).fail((function(r,o,s){i.compassLogger.warn("REST "+t+" request to "+e+" with data "+JSON.stringify(n)+" failed with error: "+o)}));return Promise.resolve(a)},e.prototype.getApiVersion=function(){return r(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.determineApiVersion()]}))}))},e.prototype.determineApiVersion=function(){return r(this,void 0,void 0,(function(){var e,t,n,r,i;return o(this,(function(o){switch(o.label){case 0:if(this._apiVersion)return[2,this._apiVersion];e=0,t=u,o.label=1;case 1:if(!(e<t.length))return[3,6];n=t[e],this._apiVersion=n,o.label=2;case 2:return o.trys.push([2,4,,5]),r=this,[4,this.get("user")];case 3:return r._user=o.sent(),[2,this._apiVersion];case 4:if(i=o.sent(),this._apiVersion=null,406!==i.status)throw i;return[3,5];case 5:return e++,[3,1];case 6:throw new Error("Cannot determine Compass version")}}))}))},e.prototype.getMyUser=function(){var e=this;return this._user?Promise.resolve(this._user):this.determineApiVersion().then((function(){return e._user}))},e.prototype.getMyFirstIdentity=function(){var e=this;return this._myFirstIdentityPromise||(this._myFirstIdentityPromise=this.getMyUser().then((function(t){return e.get(t.self+"/identities").then((function(e){return e[0]}))}))),this._myFirstIdentityPromise},e.prototype.getMyCompany=function(){return this._myCompanyUrlPromise||(this._myCompanyUrlPromise=this.get("company")),this._myCompanyUrlPromise},e.prototype.getUrlForObject=function(e,t){return this.baseUrl+"/"+e+"/"+t},e}();t.RestApi=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(7);Object.defineProperty(t,"Connection",{enumerable:!0,get:function(){return r.Connection}});var o=n(1);Object.defineProperty(t,"CallEndReason",{enumerable:!0,get:function(){return o.CallEndReason}}),Object.defineProperty(t,"Side",{enumerable:!0,get:function(){return o.Side}}),Object.defineProperty(t,"OtherSide",{enumerable:!0,get:function(){return o.OtherSide}}),Object.defineProperty(t,"CallState",{enumerable:!0,get:function(){return o.CallState}}),Object.defineProperty(t,"CallPointState",{enumerable:!0,get:function(){return o.CallPointState}}),Object.defineProperty(t,"CallPointType",{enumerable:!0,get:function(){return o.CallPointType}}),Object.defineProperty(t,"Call",{enumerable:!0,get:function(){return o.Call}}),Object.defineProperty(t,"CallPoint",{enumerable:!0,get:function(){return o.CallPoint}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return o.User}}),Object.defineProperty(t,"UserCallPoint",{enumerable:!0,get:function(){return o.UserCallPoint}}),Object.defineProperty(t,"DialplanCallPoint",{enumerable:!0,get:function(){return o.DialplanCallPoint}}),Object.defineProperty(t,"ExternalCallPoint",{enumerable:!0,get:function(){return o.ExternalCallPoint}}),Object.defineProperty(t,"QueueCallPoint",{enumerable:!0,get:function(){return o.QueueCallPoint}}),Object.defineProperty(t,"ListenInCallPoint",{enumerable:!0,get:function(){return o.ListenInCallPoint}}),Object.defineProperty(t,"Queue",{enumerable:!0,get:function(){return o.Queue}}),Object.defineProperty(t,"QueueMember",{enumerable:!0,get:function(){return o.QueueMember}}),Object.defineProperty(t,"Company",{enumerable:!0,get:function(){return o.Company}}),Object.defineProperty(t,"Model",{enumerable:!0,get:function(){return o.Model}}),Object.defineProperty(t,"ReceiveCalls",{enumerable:!0,get:function(){return o.ReceiveCalls}}),Object.defineProperty(t,"UserStatus",{enumerable:!0,get:function(){return o.UserStatus}}),Object.defineProperty(t,"WrapupState",{enumerable:!0,get:function(){return o.WrapupState}});var i=n(0);Object.defineProperty(t,"compassLogger",{enumerable:!0,get:function(){return i.compassLogger}}),Object.defineProperty(t,"rootLogger",{enumerable:!0,get:function(){return i.rootLogger}});var s=n(3);Object.defineProperty(t,"Event",{enumerable:!0,get:function(){return s.Event}}),Object.defineProperty(t,"EventType",{enumerable:!0,get:function(){return s.EventType}});var a=n(5);Object.defineProperty(t,"RestApi",{enumerable:!0,get:function(){return a.RestApi}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=t.COMPASS_NS=void 0;var r=n(4),o=n(1),i=n(9),s=n(5),a=n(0),u=n(12),l=n(2);n(13);var c="http://iperity.com/compass";t.COMPASS_NS=c,u.Strophe.addNamespace("COMPASS",c),u.Strophe.addNamespace("PING","urn:xmpp:ping");var p=function(){function e(e){this.logXmpp=!1,this._closed=!1,this.model=new o.Model,this.basedom=e,this._server="uc."+this.basedom}return e.prototype.connect=function(e,t){var n=this;this._closed=!1;var r=this._internalConnect(e,t);return r.then((function(){n.model.notifyConnected(),n._autoReconnectHandler=new d(n,e,t)})),r},e.prototype.sendIQ=function(e){var t=this;return new Promise((function(n,r){t.stropheConnection.sendIQ(e,t._callback((function(e){var t=l(e);n(t)})),t._callback((function(e){var t=l(e);r(t)})))}))},e.prototype.close=function(){this._closed=!0,this._autoReconnectHandler.stop(),this.stropheConnection.disconnect(),this.stropheConnection.reset()},e.prototype.disconnect=function(){this.close(),this.model.clear()},e.prototype._internalConnect=function(e,t,n){var o=this;this._setupConnection(e);var i=e+"/"+(n=n||"Compass.js_"+r.randomstring(10));return new Promise((function(e,n){o.stropheConnection.connect(i,t,(function(r,i){var s;switch(r){case u.Strophe.Status.ERROR:n(s="Error occurred");break;case u.Strophe.Status.CONNECTING:s="Connecting...";break;case u.Strophe.Status.CONNFAIL:n(s="Connection failed");break;case u.Strophe.Status.AUTHENTICATING:s="Authenticating...";break;case u.Strophe.Status.AUTHFAIL:n(s="Authentication failed");break;case u.Strophe.Status.CONNECTED:s="Connected";var l=o._onConnected(t);l.then((function(){e()})),l.catch((function(e){n(e)}));break;case u.Strophe.Status.DISCONNECTED:s="Disconnected",!o._closed&&o._autoReconnectHandler&&o._autoReconnectHandler.reconnect();break;case u.Strophe.Status.DISCONNECTING:s="Disconnecting...";break;case u.Strophe.Status.ATTACHED:s="Attached";break;case u.Strophe.Status.REDIRECT:s="Redirect";break;case u.Strophe.Status.CONNTIMEOUT:n(s="Connection timeout")}a.compassLogger.info("STATUS: Strophe connection status '"+s+"', condition "+i),o.statusCallback&&o.statusCallback(r,s)}))}))},e.prototype._onConnected=function(e){var t=this;return this._setInvisible().then((function(){return t._sendInitialPresence()})).then((function(){return t._getCompany().catch((function(e){throw new Error("User has no company")}))})).then((function(e){return t._xmppHandler.setCompanyFromXmpp(e.find(">result")),t._subscribeToPubsub()})).then((function(){return a.compassLogger.info("Pubsub subscribed"),t._onSubscribed(e)}))},e.prototype._onSubscribed=function(e){var t=this,n=[];return n.push(this._getObjectsOfType("user").then((function(n){t._xmppHandler.setUsersFromXmpp(n);var r=t.model.getUserForJid(t.jid).username;t.rest=new s.RestApi(t.basedom,r,e)}))),n.push(this._getObjectsOfType("queue").then((function(e){t._xmppHandler.setQueuesFromXmpp(e)}))),n.push(this._getObjectsOfType("call").then((function(e){t._xmppHandler.setCallsFromXmpp(e)}))),Promise.all(n)},e.prototype._getCompany=function(){return this.sendIQ(u.$iq({to:"phone."+this._server,type:"get"}).c("request",{xmlns:c,type:"GET_COMPANY"}))},e.prototype._getObjectsOfType=function(e){return this.sendIQ(u.$iq({to:"phone."+this._server,type:"get"}).c("request",{xmlns:c,type:"GET"}).c("filter",{type:e})).then((function(e){return e.find(">result").children()}))},e.prototype._sendInitialPresence=function(){this.stropheConnection.send(u.$pres().c("priority").t("1"))},e.prototype._setInvisible=function(){var e=u.$iq({type:"set"}).c("query",{xmlns:"jabber:iq:privacy"}).c("list",{name:"invisible"}).c("item",{action:"deny",order:"1"}).c("presence-out",{}),t=u.$iq({type:"set"}).c("query",{xmlns:"jabber:iq:privacy"}).c("active",{name:"invisible"});return Promise.all([this.sendIQ(e),this.sendIQ(t)])},e.prototype._setupConnection=function(e){if(-1===e.indexOf("@"))throw new Error('JID does not contain an "@"');this._xmppHandler=new i.XmppHandler(this.model),this._domain=e.substring(e.indexOf("@")+1),this.jid=e;var t="wss://bosh."+this.basedom+"/ws";this.stropheConnection=new u.Strophe.Connection(t),this.logXmpp&&(this.stropheConnection.rawInput=function(e){return a.compassLogger.debug("IN: "+e)},this.stropheConnection.rawOutput=function(e){return a.compassLogger.debug("OUT: "+e)})},e.prototype._subscribeToPubsub=function(){var e=this,t=this.model.company.id;return new Promise((function(n,r){var o,i=e.stropheConnection.pubsub;o=e.stropheConnection.addHandler(e._callback((function(t){return function(t){var r=t.find("subscription").attr("subscription");r&&"subscribed"===r&&n(),e._onReceivePubsub(t),e.stropheConnection.deleteHandler(o)}(l(t))})),null,"message",null,null,i.service),a.compassLogger.info("Subscribing to "+t),i.subscribe(t,null,e._callback((function(t){return e._onReceivePubsub(l(t))})),(function(e){}),(function(e){return r(e)}),!1)}))},e.prototype._onReceivePubsub=function(e){var t=this;l("item",e).toArray().map((function(e){return l(e)})).forEach((function(e){var n=e.children(),r=n[0].nodeName;"notification"===r.toLowerCase()?t._xmppHandler.handleNotification(n):a.compassLogger.warn("Unknown pubsub item: "+r)}))},e.prototype._callback=function(e){var t=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{e.apply(t,n)}catch(e){a.compassLogger.error("ERROR: "+(e.stack?e+"\n"+e.stack:e))}return!0}},e}();t.Connection=p;var d=function(){function e(e,t,n){var r=this;this._pingIntervalMs=3e4,this._pingTimeoutMs=5e3,this._lastPingSentTimestamp=0,this._connection=e,this._jid=t,this._password=n,a.compassLogger.debug("Starting XMPP ping every "+this._pingIntervalMs/1e3+"s, will re-connect automatically if no response within "+this._pingTimeoutMs/1e3+"s."),this._pingTimer=setInterval((function(){return r.doPing()}),this._pingIntervalMs)}return e.prototype.stop=function(){clearInterval(this._pingTimer),this._pingTimer=void 0,this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.reconnect=function(){this._connection.close(),this._connection.connect(this._jid,this._password).then((function(){return a.compassLogger.info("Reconnected")}))},e.prototype.doPing=function(){var e=this,t=this._connection.sendIQ(u.$iq({to:"phone.uc."+this._connection.basedom,type:"get"}).c("ping",{xmlns:u.Strophe.NS.PING}));a.compassLogger.debug("XMPP ping sent"),this._lastPingSentTimestamp=(new Date).valueOf(),this._pingTimeoutTimer=setTimeout((function(){return e.pingLate()}),this._pingTimeoutMs),t.then((function(){return e.pingReceived()}))},e.prototype.pingReceived=function(){a.compassLogger.debug("Received ping after "+((new Date).valueOf()-this._lastPingSentTimestamp)+" ms"),clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0,this._lastPingSentTimestamp=0},e.prototype.pingLate=function(){a.compassLogger.warn("Didn't receive XMPP ping in time. Reconnecting..."),this.reconnect()},e}()},function(e,n){e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XmppHandler=void 0;var r,o,i=n(3),s=n(0),a=n(1),u=n(11),l=n(2),c=function(){function e(e){this.model=e,this.parser=new u.ParserRegistry(this.model),this._handler=new d(this,this.parser)}return e.prototype.setCompanyFromXmpp=function(e){var t=this.parser.parse(e,u.ObjectType.Company);this.setCompany(t),s.compassLogger.info("Discovered company: "+this.model.company.name+" ("+this.model.company.id+")")},e.prototype.setUsersFromXmpp=function(e){var t=this;s.compassLogger.info("Received users: "+e.length),this.model.users={},e.toArray().map((function(e){return l(e)})).forEach((function(e){var n=t.parser.parse(e,u.ObjectType.User);t.addUser(n,!1)}))},e.prototype.setCallsFromXmpp=function(e){var t=this;s.compassLogger.info("Received calls: "+e.length),this.model.calls={};var n=function(e){return e.find(">properties >QueueCallForCall").length},r=function(e){var n=t.parser.parse(e,u.ObjectType.Call);t.addCall(n,!1)},o=e.toArray().map((function(e){return l(e)}));o.filter((function(e){return!n(e)})).forEach(r),o.filter((function(e){return n(e)})).forEach(r)},e.prototype.setQueuesFromXmpp=function(e){var t=this;s.compassLogger.info("Received queues: "+e.length),this.model.queues={},e.toArray().map((function(e){return l(e)})).forEach((function(e){var n=t.parser.parse(e,u.ObjectType.Queue);t.addQueue(n,!1)}))},e.prototype.handleNotification=function(e){this._handler.handleNotification(e)},e.prototype.setCompany=function(e){this.model.company=e},e.prototype.addUser=function(e,t){void 0===t&&(t=!0),this.model.users[e.id]=e,t&&this.model.notify(new i.Event(e,i.EventType.Added))},e.prototype.removeUser=function(e,t){void 0===t&&(t=!0);var n=this.model.users[e];n&&(delete this.model.users[e],t&&this.model.notify(new i.Event(n,i.EventType.Removed)))},e.prototype.userUpdateStatus=function(e,t){var n=e.status;e.status=t,e.domain.notify(new i.Event(e,i.EventType.Changed,{name:"status",oldValue:n,newValue:e.status}))},e.prototype.addCall=function(e,t){void 0===t&&(t=!0),this.model.calls[e.id]=e,t&&this.sendEventsCallAdded(e)},e.prototype.removeCall=function(e,t,n){void 0===n&&(n=!0);var r=this.model.calls[e];r&&(delete this.model.calls[e],n&&this.sendEventsCallRemoved(r,{reason:t}))},e.prototype.addQueue=function(e,t){void 0===t&&(t=!0),this.model.queues[e.id]=e,t&&this.model.notify(new i.Event(e,i.EventType.Added))},e.prototype.removeQueue=function(e,t){void 0===t&&(t=!0);var n=this.model.queues[e];n&&(delete this.model.queues[e],t&&this.model.notify(new i.Event(n,i.EventType.Removed)))},e.prototype.deleteFromArray=function(e,t){var n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)},e.prototype.sendEventsCallAdded=function(e,t){void 0===t&&(t=null),this.sendEventsOnCallAndEndpoint(e,!0,t)},e.prototype.sendEventsCallRemoved=function(e,t){void 0===t&&(t=null),this.sendEventsOnCallAndEndpoint(e,!1,t)},e.prototype.sendEventsOnCallAndEndpoint=function(e,t,n){void 0===n&&(n=null),t&&e.domain.notify(new i.Event(e,i.EventType.Added,n)),this.sendEventsForCallPoint(e,e.source,t),this.sendEventsForCallPoint(e,e.destination,t),t||e.domain.notify(new i.Event(e,i.EventType.Removed,n))},e.prototype.sendEventsForCallPoint=function(e,t,n){var r=n?i.EventType.CallAdded:i.EventType.CallRemoved;if(t instanceof a.UserCallPoint){var o=t,u=o.getUser();if(!u)return void s.compassLogger.warn("Could not deliver event; user "+o.userId+" non-existing");u.domain.notify(new i.Event(u,r,{call:e}));var l=n?i.EventType.UserAdded:i.EventType.UserRemoved;e.domain.notify(new i.Event(e,l,{user:u}))}else if(t instanceof a.QueueCallPoint){var c=t,p=c.getQueue();if(!p)return void s.compassLogger.warn("Could not deliver event; queue "+c.queueId+" non-existing");p.domain.notify(new i.Event(p,r,{call:e}));var d=n?i.EventType.QueueAdded:i.EventType.QueueRemoved;e.domain.notify(new i.Event(e,d,{queue:p}))}},e.prototype.sendEventsCallUpdated=function(e,t,n){this.sendEventsForCallPoint(e,t,!1),this.sendEventsForCallPoint(e,n,!0)},e}();function p(e){return e===o.source?a.Side.source:a.Side.destination}t.XmppHandler=c,function(e){e.source="SOURCE",e.destination="DESTINATION",e.state="STATE",e.both="BOTH"}(r||(r={})),function(e){e.source="SOURCE",e.destination="DESTINATION"}(o||(o={}));var d=function(){function e(e,t){this._xmppHandler=e,this._parser=t}return e.prototype.handleNotification=function(e){s.compassLogger.debug("Notification Received");var t=e.attr("type");switch(this.getNotificationTypeUpToLevel(t,1)){case"notification.call":this.handleCallNotification(e);break;case"notification.queueMember":this.handleQueueMemberNotification(e);break;case"notification.queue":this.handleQueueNotification(e);break;case"notification.user":this.handleUserNotification(e);break;default:s.compassLogger.warn("Don't know how to handle notification type "+t+" .")}},e.prototype.handleCallNotification=function(e){s.compassLogger.debug("Call Notification Received");var t=e.attr("type");switch(this.getNotificationTypeUpToLevel(t,2)){case"notification.call.start":this.handleCallStartNotification(e);break;case"notification.call.end":this.handleCallEndNotification(e);break;case"notification.call.update":this.handleCallUpdateNotification(e);break;case"notification.call.stepresult":this.handleCallStepResultNotification(e);break;default:s.compassLogger.warn("Don't know how to handle notification type "+t+" .")}},e.prototype.handleCallStartNotification=function(e){s.compassLogger.debug("Call Start Notification Received");var t=e.find(">call"),n=this._parser.parse(t,u.ObjectType.Call);this._xmppHandler.addCall(n,!0)},e.prototype.handleCallEndNotification=function(e){s.compassLogger.debug("Call End Notification Received");var t=e.find(">callId").text(),n=e.find(">endReason").text();if(!t)throw new Error("No 'callId' in notification.call.end element.");this._xmppHandler.removeCall(t,n,!0)},e.prototype.handleCallUpdateNotification=function(e){s.compassLogger.debug("Call Update Notification Received");var t=e.find(">call"),n=e.find(">updateType").text(),o=this._parser.parse(t,u.ObjectType.Call),a=this._xmppHandler.model.calls[o.id];if(!a)return s.compassLogger.debug("Received update notification for call "+o.id+" we didn't know existed yet. Adding now."),void this._xmppHandler.addCall(o,!0);var l=a.source,c=a.destination,p=a.state,d=!1,f=!1,h=!1;switch(n){case r.source:a.source=o.source,this._xmppHandler.sendEventsCallUpdated(a,l,a.source),f=!0;break;case r.destination:a.destination=o.destination,this._xmppHandler.sendEventsCallUpdated(a,c,a.destination),h=!0;break;case r.both:a.source=o.source,f=!0,a.destination=o.destination,h=!0,this._xmppHandler.sendEventsCallUpdated(a,l,a.source),this._xmppHandler.sendEventsCallUpdated(a,c,a.destination);break;case r.state:break;default:s.compassLogger.warn("Unknown call updateType "+n)}a.state!==o.state&&(a.state=o.state,d=!0),f||a.source.state===o.source.state||(a.source=o.source,f=!0),h||a.destination.state===o.destination.state||(a.destination=o.destination,h=!0),d&&a.domain.notify(new i.Event(a,i.EventType.Changed,{updateType:"state",oldState:p})),f&&a.domain.notify(new i.Event(a,i.EventType.Changed,{updateType:"source",oldCallpoint:l})),h&&a.domain.notify(new i.Event(a,i.EventType.Changed,{updateType:"destination",oldCallpoint:c}))},e.prototype.handleCallStepResultNotification=function(e){s.compassLogger.debug("CallStepResult notification received");var t=e.find(">callId").text(),n=this._xmppHandler.model.calls[t];if(n){var r=e.find(">side").text(),o=this._parser.parse(e.find(">callpoint"),u.ObjectType.CallPoint),a=e.find(">result").text();n.domain.notify(new i.Event(n,i.EventType.Changed,{updateType:"stepResult",side:p(r),callpoint:o,result:a}))}else s.compassLogger.warn("Received stepResult notification for call "+t+" we don't know about.")},e.prototype.handleUserNotification=function(e){s.compassLogger.debug("User Notification Received");var t=e.attr("type"),n=e.find(">userId").text();if("notification.user.create"!==t){var r=this._xmppHandler.model.users[n];if(r)switch(t){case"notification.user.update":this.handlePropertiesChanged(r,e.find(">propertyChange"),this.handleUserPropertyUpdate);break;case"notification.user.destroy":this._xmppHandler.removeUser(n);break;case"notification.user.status":var o=e.find(">receiveCalls").text(),i=e.find(">displayStatus").text(),l=u.parseWrapupState(e.find(">wrapupState"));this._xmppHandler.userUpdateStatus(r,new a.UserStatus(o,i,l));break;default:s.compassLogger.warn("Unknown user notification type "+t)}else s.compassLogger.warn("Received "+t+" for "+n+", but user with that userId does not exists.")}else{if(this._xmppHandler.model.users[n])return void s.compassLogger.warn("Received "+t+" for "+n+", but user with that userId already exists.");var c=e.find(">user"),p=this._parser.parse(c,u.ObjectType.User);this._xmppHandler.addUser(p,!0)}},e.prototype.handleQueueMemberNotification=function(e){s.compassLogger.debug("QueueMember Notification Received");var t,n=e.attr("type"),r=e.find(">member"),o=r.find(">queueId").text(),u=r.find(">userId").text(),l=r.find(">priority").text(),c=r.find(">pausedSince").text(),p=this._xmppHandler.model.queues[o],d=this._xmppHandler.model.users[u];if(d)if(p)switch(n){case"notification.queueMember.enter":if(p.getQueueMember(u))return void s.compassLogger.warn("Received "+n+" for userId "+u+", but user already in queue.");t=new a.QueueMember(u,o,l,c,this._xmppHandler.model),p.queueMembers.push(t),p.domain.notify(new i.Event(p,i.EventType.UserAdded,{user:d})),d.domain.notify(new i.Event(d,i.EventType.QueueAdded,{queue:p}));break;case"notification.queueMember.leave":t=p.getQueueMember(u),this._xmppHandler.deleteFromArray(p.queueMembers,t),p.domain.notify(new i.Event(p,i.EventType.UserRemoved,{user:d})),d.domain.notify(new i.Event(d,i.EventType.QueueRemoved,{queue:p}));break;case"notification.queueMember.update":var f=(t=p.getQueueMember(u)).isPaused();if(t.setPausedSince(c),t.setPriority(l),t.isPaused()!==f){var h=t.isPaused()?i.EventType.Paused:i.EventType.Unpaused;p.domain.notify(new i.Event(p,h,{user:d})),d.domain.notify(new i.Event(d,h,{queue:p}))}break;default:s.compassLogger.warn("Don't know how to handle notification type "+n+" .")}else s.compassLogger.warn("Notification "+n+" for queue "+o+" not processed, becasue queue not found in domain.");else s.compassLogger.warn("Could not deliver event; user "+u+" non-existing")},e.prototype.handleQueueNotification=function(e){s.compassLogger.debug("Queue Notification Received");var t=e.attr("type"),n=e.find(">queueCall"),r=e.find(">queueId").text(),o=n.find(">callId").text(),i=(this._xmppHandler.model.calls[o],this._xmppHandler.model.queues[r]);if(i)switch(t){case"notification.queue.call.enter":s.compassLogger.debug("Queue Call Enter Notification Received");break;case"notification.queue.call.leave":s.compassLogger.debug("Queue Call Leave Notification Received");break;case"notification.queue.update":this.handlePropertiesChanged(i,e.find(">propertyChange"),this.handleQueuePropertyUpdate);break;case"notification.queue.destroy":this._xmppHandler.removeQueue(r,!0);break;default:s.compassLogger.warn("Don't know how to handle notification type "+t+" .")}else switch(t){case"notification.queue.create":if(this._xmppHandler.model.queues[r])return void s.compassLogger.warn("Received "+t+" for "+r+", but queue with that queueId already exists.");var a=e.find(">queue"),l=this._parser.parse(a,u.ObjectType.Queue);this._xmppHandler.addQueue(l,!0);break;default:s.compassLogger.warn("Notification "+t+" for queue "+r+" not processed, becasue queue not found in domain.")}},e.prototype.handlePropertiesChanged=function(e,t,n){t.toArray().map((function(e){return l(e)})).forEach((function(t){var r=t.find(">name").text(),o=t.find(">oldValue").text(),s=t.find(">newValue").text();n(e,r,s),e.domain.notify(new i.Event(e,i.EventType.PropertyChanged,{name:r,oldValue:o,newValue:s}))}))},e.prototype.handleUserPropertyUpdate=function(e,t,n){switch(t){case"name":e.name=n;break;case"loggedIn":e.loggedIn=u.parseBoolean(n);break;case"location":e.phoneId=u.parseNumberOrNull(n);break;default:s.compassLogger.debug("Got user property update: "+t+" is now '"+n+"'")}},e.prototype.handleQueuePropertyUpdate=function(e,t,n){switch(t){case"name":e.name=n;break;default:s.compassLogger.debug("Got queue property update: "+t+" is now '"+n+"'")}},e.prototype.getNotificationTypeUpToLevel=function(e,t){if(t<0)throw new Error("getTypeLevel: level "+t+" is below 0.");var n=e.split(".");return n.splice(t+1),n.join(".")},e}()},function(e,t,n){var r,o;!function(i,s){"use strict";void 0===(o="function"==typeof(r=function(){var e=function(){},t="undefined"!=typeof window&&void 0!==window.navigator&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(n){return"debug"===n&&(n="log"),"undefined"!=typeof console&&("trace"===n&&t?o:void 0!==console[n]?r(console,n):void 0!==console.log?r(console,"log"):e)}function s(t,r){for(var o=0;o<n.length;o++){var i=n[o];this[i]=o<t?e:this.methodFactory(i,t,r)}this.log=this.debug}function a(e,t,n){return function(){"undefined"!=typeof console&&(s.call(this,t,n),this[e].apply(this,arguments))}}function u(e,t,n){return i(e)||a.apply(this,arguments)}function l(e,t,r){var o,i=this,a="loglevel";function l(){var e;if("undefined"!=typeof window&&a){try{e=window.localStorage[a]}catch(e){}if(void 0===e)try{var t=window.document.cookie,n=t.indexOf(encodeURIComponent(a)+"=");-1!==n&&(e=/^([^;]+)/.exec(t.slice(n))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}"string"==typeof e?a+=":"+e:"symbol"==typeof e&&(a=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=r||u,i.getLevel=function(){return o},i.setLevel=function(t,r){if("string"==typeof t&&void 0!==i.levels[t.toUpperCase()]&&(t=i.levels[t.toUpperCase()]),!("number"==typeof t&&t>=0&&t<=i.levels.SILENT))throw"log.setLevel() called with invalid level: "+t;if(o=t,!1!==r&&function(e){var t=(n[e]||"silent").toUpperCase();if("undefined"!=typeof window&&a){try{return void(window.localStorage[a]=t)}catch(e){}try{window.document.cookie=encodeURIComponent(a)+"="+t+";"}catch(e){}}}(t),s.call(i,t,e),"undefined"==typeof console&&t<i.levels.SILENT)return"No console available for logging"},i.setDefaultLevel=function(e){l()||i.setLevel(e,!1)},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)};var c=l();null==c&&(c=null==t?"WARN":t),i.setLevel(c,!1)}var c=new l,p={};c.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=p[e];return t||(t=p[e]=new l(e,c.getLevel(),c.methodFactory)),t};var d="undefined"!=typeof window?window.log:void 0;return c.noConflict=function(){return"undefined"!=typeof window&&window.log===c&&(window.log=d),c},c.getLoggers=function(){return p},c.default=c,c})?r.call(t,n,t,e):r)||(e.exports=o)}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseWrapupState=t.parseBoolean=t.parseNumberOrNull=t.ParserRegistry=t.ObjectType=void 0;var r,o=n(1),i=n(0),s=n(2),a=function(e,t){this.parser=e,this.model=t};!function(e){e[e.Company=0]="Company",e[e.User=1]="User",e[e.Queue=2]="Queue",e[e.Call=3]="Call",e[e.CallPoint=4]="CallPoint"}(r=t.ObjectType||(t.ObjectType={}));var u=function(){function e(e){this._parserContext=new a(this,e)}return e.prototype.parse=function(t,n){var r=e._parsers[n];if(!r)return i.compassLogger.warn("No parser available for type "+n+", returning null."),null;if(!t)throw new Error("trying to parse null element");return r.parse(t,this._parserContext)},e.registerParser=function(t,n){e._parsers[n]=t},e._parsers={},e}();t.ParserRegistry=u;var l=function(){function e(){}return e.prototype.parse=function(e,t){var n=e.attr("id"),r=new o.User(n,e,t.model);r.name=e.find(">name").text(),r.loggedIn=w(e.find(">loggedIn").text());var i=e.find(">extensions").text();return r.extensions=i?i.split(","):[],r.jid=e.find(">identifiers>xmppJid").text(),r.username=e.find(">identifiers>compassId").text(),r.phoneId=C(e.find(">location").text()),r.contact=e.find(">contact").text(),r.language=e.find(">language").text(),e.find(">receiveCalls").length&&(r.status=new o.UserStatus(e.find(">receiveCalls").text(),e.find(">displayStatus").text(),P(e.find(">wrapupState")))),r},e}();u.registerParser(new l,r.User);var c=function(){function e(){}return e.prototype.parse=function(e,t){var n=e.find(">id").text(),r=new o.Company(n,e,t.model);return r.name=e.find(">name").text(),r},e}();u.registerParser(new c,r.Company);var p=function(){function e(){}return e.prototype.parse=function(e,t){var n=new o.Queue(e.attr("id"),e,t.model);return n.name=e.find(">name").text(),e.find("userEntries").children().toArray().map((function(e){return s(e)})).forEach((function(e){var r=e.find(">userId").text(),i=e.find(">pausedSince").text(),s=e.find(">priority").text(),a=new o.QueueMember(r,n.id,s,i,t.model);n.queueMembers.push(a)})),n},e}();u.registerParser(new p,r.Queue);var d=function(){function e(){}return e.prototype.parse=function(e,t){var n=e.attr("id"),i=new o.Call(n,e,t.model);i.state=e.find(">state").text();var s=t.parser;i.source=s.parse(e.find(">source"),r.CallPoint),i.destination=s.parse(e.find(">destination"),r.CallPoint);var a=e.find(">properties >QueueCallForCall");return a.length&&(i.parentCall=t.model.calls[a.text()]),i},e}();u.registerParser(new d,r.Call);var f=function(){function e(){}return e.register=function(e,t){this._types[t]=e},e.prototype.parse=function(t,n){var r=t.attr("type"),i=t.attr("id"),s=e._types[r],a=s?s.parse(i,t,n):new o.CallPoint(i,t,n.model);return this.fillBaseObject(a,t),a},e.prototype.fillBaseObject=function(e,t){e.type=t.attr("type"),e.state=t.find(">state").text(),e.timeCreated=Number(t.find(">timeCreated").text()),e.timeStarted=C(t.find(">timeStarted").text())},e._types={},e}();u.registerParser(new f,r.CallPoint);var h=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.UserCallPoint(e,t,n.model);return r.userId=t.find(">userId").text(),r.userName=t.find(">userName").text(),r.identityId=t.find(">identityId").text(),r},e}();f.register(new h,o.CallPointType.user);var m=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.ResourceCallPoint(e,t,n.model);return r.resourceType=t.find(">resourceType").text(),r.resourceId=t.find(">resourceId").text(),r.name=t.find(">name").text(),r},e}();f.register(new m,o.CallPointType.resource);var y=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.QueueCallPoint(e,t,n.model);return r.queueId=t.find(">queueId").text(),r.queueName=t.find(">queueName").text(),r},e}();f.register(new y,o.CallPointType.queue);var v=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.ExternalCallPoint(e,t,n.model);return r.number=t.find(">number").text(),r.name=t.find(">name").text(),r},e}();f.register(new v,o.CallPointType.external);var g=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.DialplanCallPoint(e,t,n.model);return r.exten=t.find(">exten").text(),r.description=t.find(">description").text(),r},e}();f.register(new g,o.CallPointType.dialplan);var b=function(){function e(){}return e.prototype.parse=function(e,t,n){var r=new o.ListenInCallPoint(e,t,n.model);return r.listenedToCallId=t.find(">listenedToCallId").text(),r},e}();function C(e){return""===e?null:Number(e)}function w(e){return"true"===e}function P(e){if(!e.length)return null;var t=e.find(">callId").text(),n=C(e.find(">endTime").text());return new o.WrapupState(t,n)}f.register(new b,o.CallPointType.listenIn),t.parseNumberOrNull=C,t.parseBoolean=w,t.parseWrapupState=P},function(e,t){e.exports=n},function(e,t){e.exports=r}])}));