softphone-vendor-headsets 2.5.5-develop.61 → 2.5.5-webpack-test.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ /*! For license information please see softhphone-vendor-headsets.min.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@gnaudio/jabra-js")):"function"==typeof define&&define.amd?define(["@gnaudio/jabra-js"],t):"object"==typeof exports?exports.SoftphoneVendorHeadsets=t(require("@gnaudio/jabra-js")):e.SoftphoneVendorHeadsets=t(e["@gnaudio/jabra-js"])}(self,(e=>(()=>{var t={419:(e,t,n)=>{"use strict";n.d(t,{A:()=>Zn});var 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)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},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 n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function a(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function s(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function u(e){return this instanceof u?(this.v=e,this):new u(e)}function l(e){return"function"==typeof e}function f(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var h=f((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function d(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var v=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var u=a(i),f=u.next();!f.done;f=u.next())f.value.remove(this)}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else i.remove(this);var d=this.initialTeardown;if(l(d))try{d()}catch(e){o=e instanceof h?e.errors:[e]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var p=a(v),y=p.next();!y.done;y=p.next()){var m=y.value;try{g(m)}catch(e){o=null!=o?o:[],e instanceof h?o=s(s([],c(o)),c(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}}if(o)throw new h(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)g(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&d(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&d(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e;var t}(),p=v.EMPTY;function y(e){return e instanceof v||e&&"closed"in e&&l(e.remove)&&l(e.add)&&l(e.unsubscribe)}function g(e){l(e)?e():e.unsubscribe()}var m=null,b=null,w=void 0,C=!1,k=!1,E={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=E.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,s([e,t],c(n))):setTimeout.apply(void 0,s([e,t],c(n)))},clearTimeout:function(e){var t=E.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function I(e){E.setTimeout((function(){if(!m)throw e;m(e)}))}function S(){}var x=O("C",void 0,void 0);function O(e,t,n){return{kind:e,value:t,error:n}}var _=null;function L(e){if(C){var t=!_;if(t&&(_={errorThrown:!1,error:null}),e(),t){var n=_,r=n.errorThrown,o=n.error;if(_=null,r)throw o}}else e()}var j=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,y(t)&&t.add(n)):n.destination=M,n}return o(t,e),t.create=function(e,t,n){return new A(e,t,n)},t.prototype.next=function(e){this.isStopped?H(function(e){return O("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?H(O("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?H(x,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(v),P=Function.prototype.bind;function T(e,t){return P.call(e,t)}var R=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){D(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){D(e)}else D(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){D(e)}},e}(),A=function(e){function t(t,n,r){var o,i,a=e.call(this)||this;return l(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:a&&k?((i=Object.create(t)).unsubscribe=function(){return a.unsubscribe()},o={next:t.next&&T(t.next,i),error:t.error&&T(t.error,i),complete:t.complete&&T(t.complete,i)}):o=t,a.destination=new R(o),a}return o(t,e),t}(j);function D(e){var t;C?(t=e,C&&_&&(_.errorThrown=!0,_.error=t)):I(e)}function H(e,t){var n=b;n&&E.setTimeout((function(){return n(e,t)}))}var M={closed:!0,next:S,error:function(e){throw e},complete:S},N="function"==typeof Symbol&&Symbol.observable||"@@observable";function F(e){return e}var U=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,i=(r=e)&&r instanceof j||function(e){return e&&l(e.next)&&l(e.error)&&l(e.complete)}(r)&&y(r)?e:new A(e,t,n);return L((function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?o._subscribe(i):o._trySubscribe(i))})),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=G(t))((function(t,r){var o=new A({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[N]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(0===(n=e).length?F:1===n.length?n[0]:function(e){return n.reduce((function(e,t){return t(e)}),e)})(this);var n},e.prototype.toPromise=function(e){var t=this;return new(e=G(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function G(e){var t;return null!==(t=null!=e?e:w)&&void 0!==t?t:Promise}var q=f((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),B=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(t,e),t.prototype.lift=function(e){var t=new J(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new q},t.prototype.next=function(e){var t=this;L((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=a(t.currentObservers),i=o.next();!i.done;i=o.next())i.value.next(e)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;L((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;L((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||o?p:(this.currentObservers=null,i.push(e),new v((function(){t.currentObservers=null,d(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new U;return e.source=this,e},t.create=function(e,t){return new J(e,t)},t}(U),J=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return o(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:p},t}(B),V=n(458),W=n(290),Y=n.n(W);function K(){return!!window._HostedContextFunctions}function z(e){return new Promise((function(t,n){try{var r=JSON.stringify(e);window.cefQuery({request:r,persistent:!1,onSuccess:function(e){try{var n=JSON.parse(e);t(n)}catch(e){t({})}},onFailure:function(e){n(e)}})}catch(e){console.error("Error requesting desktop promise",e),n(e)}}))}function $(e){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$(e)}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Q(){Q=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==$(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError($(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function X(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function ee(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){X(i,r,o,a,c,"next",e)}function c(e){X(i,r,o,a,c,"throw",e)}a(void 0)}))}}function te(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ae(r.key),r)}}function ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ne=function(){return!!e})()}function re(e){return re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},re(e)}function oe(e,t){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},oe(e,t)}function ie(e,t,n){return(t=ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(e){var t=function(e){if("object"!=$(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==$(t)?t:t+""}var ce=1,se=4,ue="callIdle",le="callIncoming",fe="callAnswering",he="callRejecting",de="callActive",ve="callEnd",pe="callOutgoing",ye=function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ie(e=function(e,t,n){return t=re(t),function(e,t){if(t&&("object"===$(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,ne()?Reflect.construct(t,n||[],re(e).constructor):t.apply(e,n))}(this,t,[].concat(r)),"vendorName","CyberAcoustics"),ie(e,"activeConversationId",void 0),ie(e,"_deviceInfo",null),ie(e,"activeDevice",void 0),ie(e,"numDeviceEventListeners",0),ie(e,"currentProductID",null),ie(e,"headsetOutputReportId",3),ie(e,"headsetInputReportId",3),ie(e,"vendorInputReportId",4),ie(e,"currentState",0),ie(e,"isHolding",!1),ie(e,"currentlDeviceLabel",void 0),ie(e,"currentCallInfo",void 0),ie(e,"currentCallState",ue),ie(e,"deviceStatus",0),ie(e,"gCmdBuf",new Uint8Array([0,0])),ie(e,"inputReportReportId",3),ie(e,"outputReportReportId",3),ie(e,"JLCommandSet",!1),ie(e,"callControlSuport",!0),ie(e,"flagSupport",15),ie(e,"handeledInputReportIds",[e.headsetInputReportId,e.vendorInputReportId]),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&oe(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!K()}},{key:"deviceLabelMatchesVendor",value:function(e){this.logger.debug("CA: matchVendor");var t=e.toLowerCase();return["ac-104enc","ac-204enc","ac-304","foundever","ca essential","ca-2890"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(m=ee(Q().mark((function e(t){var n,r,o=this;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!1,this.logger.debug("CA: Connect Attempt"),this.currentlDeviceLabel=t,this.logger.debug("CA Device String = ".concat(t)),this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.next=7,window.navigator.hid.getDevices();case 7:if(r=e.sent,this.selectDevice(r,t),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=13;break}return e.next=13,this.activeDevice.open();case 13:this.activeDevice.opened?(n=!0,this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- previously connected device")):this.logger.debug("CA: Connect FAIL- Failed connect to previously connected device");case 14:if(n){e.next=26;break}return e.prev=15,e.next=18,new Promise((function(e,n){var r=setTimeout(n,3e4);o.requestWebHidPermissions(ee(Q().mark((function i(){var a,c,s;return Q().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return o.logger.debug("Requesting web HID permissions"),a=o.deductProductId(t),i.next=4,window.navigator.hid.requestDevice({filters:[{vendorId:13201,productId:a||void 0}]});case 4:return c=i.sent,clearTimeout(r),i.next=8,o.connectFromHidPermissions(c,t);case 8:(s=i.sent)?e(s):n(),console.debug("CA: requestWebHidPermissions device found = ".concat(s," "));case 11:case"end":return i.stop()}}),i)}))))}));case 18:n=e.sent,e.next=26;break;case 21:return e.prev=21,e.t0=e.catch(15),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("CA: WebHID permissions denied"),e.abrupt("return");case 26:case"end":return e.stop()}}),e,this,[[15,21]])}))),function(e){return m.apply(this,arguments)})},{key:"connectFromHidPermissions",value:(g=ee(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice=null,this.selectDevice(t,n),!this.activeDevice){e.next=14;break}if(this.activeDevice.opened){e.next=6;break}return e.next=6,this.activeDevice.open();case 6:if(!this.activeDevice.opened){e.next=12;break}return this.handleDeviceConnect(),this.logger.debug("CA: Connect SUCCESS- from HIDWebPermission request "),e.abrupt("return",!0);case 12:return this.logger.debug("CA: Connect FAIL requesting WebHID permissions"),e.abrupt("return",!1);case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return g.apply(this,arguments)})},{key:"handleInputReport",value:function(e){var t=e.reportId;if(this.handeledInputReportIds.includes(t)){var n=e.data.getUint8(0),r=(e.data.getUint8(1)<<8)+n;this.logger.debug("CA received button press ".concat(this.formatHex(r)," reportID ").concat(t," from Device")),this.handleDeviceButtonPress(r,t)}}},{key:"handleDeviceConnect",value:(y=ee(Q().mark((function e(){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._deviceInfo={ProductName:this.activeDevice.productName},this.handleInputReport=this.handleInputReport.bind(this),this.activeDevice.addEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners++,console.debug("Installed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),this.numDeviceEventListeners>1&&(this.logger.debug("%c CA: ********************************************************","color: red"),this.logger.debug("%c CA: *****WARNING ***** MULTIPLE EVENT LISTENERS ON DEVICE!!!","color: red"),this.logger.debug("%c CA: ********************************************************","color: red")),this.currentProductID=this.activeDevice.productId,this.logger.debug("Product ID: 0x".concat(this.currentProductID.toString(16))),this.currentCallState=ue,this.headsetOutputReportId=this.outputReportReportId,this.headsetInputReportId=this.outputReportReportId,this.vendorInputReportId=4,this.handeledInputReportIds=[this.headsetInputReportId,this.vendorInputReportId],e.t0=this.currentProductID,e.next=4===e.t0?16:24===e.t0?21:23;break;case 16:return this.flagSupport=576,this.JLCommandSet=!0,ce=512,se=64,e.abrupt("break",25);case 21:return this.flagSupport=5,e.abrupt("break",25);case 23:return this.flagSupport=15,e.abrupt("break",25);case 25:this.logger.debug("flagSupport = ".concat(this.formatHex(this.flagSupport)," ")),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 27:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"selectDevice",value:function(e,t){var n=this;this.logger.debug("CA: SelectDevice");var r=t.toLowerCase(),o=!1;return e.forEach((function(e){var t;if(r.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var i,a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}(e.collections);try{for(a.s();!(i=a.n()).done;){var c=i.value;if((5===c.usage||1===c.usage)&&11===c.usagePage){n.activeDevice=e,o=!0,0!==c.inputReports.length&&(n.inputReportReportId=c.inputReports[0].reportId,n.logger.debug("CA inputReportReportId = ".concat(n.inputReportReportId))),0!==c.outputReports.length&&(n.outputReportReportId=c.outputReports[0].reportId,n.logger.debug("CA outputReportReportId = ".concat(n.outputReportReportId)));break}}}catch(e){a.e(e)}finally{a.f()}}})),o}},{key:"disconnect",value:(p=ee(Q().mark((function e(){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.activeDevice){e.next=15;break}return this.logger.debug("CA: Disconnecting"),this.ChangeCallState(ve),this.ChangeCallState(ue),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"})),this.activeDevice.removeEventListener("inputreport",this.handleInputReport),this.numDeviceEventListeners--,console.debug("Removed Device Input listener, num listeners = ".concat(this.numDeviceEventListeners," ")),e.next=10,this.activeDevice.close();case 10:this.logger.debug("CA: Device closed"),this.activeDevice=null,this._deviceInfo=null,this.currentCallState=ue,(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1});case 15:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"incomingCall",value:(v=ee(Q().mark((function e(t){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: incomingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(2);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"outgoingCall",value:(d=ee(Q().mark((function e(t){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: outgoingCall"),this.currentCallInfo=t,this.activeConversationId=t.conversationId,this.ParseStateEvents(8);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"answerCall",value:(h=ee(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: Answer Call from UI"),this.activeConversationId=t,n&&(this.logger.debug("CA: AutoAnswer"),this.ParseStateEvents(2)),this.ParseStateEvents(7);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"rejectCall",value:(f=ee(Q().mark((function e(){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: rejectCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"endCall",value:(l=ee(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endCall from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"endAllCalls",value:(u=ee(Q().mark((function e(){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: endAllCalls from UI"),this.ParseStateEvents(3);case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"setMute",value:(s=ee(Q().mark((function e(t){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setMute. Value: ".concat(t)),this.isMuted=t,this.UpdateDeviceStatus(se,t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setHold",value:(c=ee(Q().mark((function e(t,n){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.logger.debug("CA: setHold. Value: ".concat(n)),this.activeConversationId=t,this.isHolding=n;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"handleDeviceButtonPress",value:function(e,t){if(this.activeDevice)if(t===this.headsetInputReportId){if(24===this.currentProductID){switch(e){case 1:case 5:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.UpdateDeviceStatus(se,this.isMuted),this.logger.debug("CA: AC304 Mute update micMuteFlag = ".concat(this.formatHex(se)," this.isMuted = ").concat(this.isMuted))}return}switch(e){case 515:case 19:this.isMuted=!this.isMuted,this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted"}),this.setMute(this.isMuted);break;case 0:this.ParseStateEvents(5);break;case 1:this.ParseStateEvents(0);break;case 2:this.ParseStateEvents(6)}}else t===this.vendorInputReportId?2===e&&this.ParseStateEvents(1):console.debug("CA: Unhandeled input report #".concat(t.toString(16)));else this.logger.error("do not have active device")}},{key:"ParseStateEvents",value:function(e){switch(this.currentCallState){case ue:switch(e){case 2:this.ChangeCallState(le);break;case 8:this.ChangeCallState(pe)}break;case le:switch(e){case 0:case 7:this.ChangeCallState(fe);break;case 5:case 3:this.ChangeCallState(he),this.ChangeCallState(ve),this.ChangeCallState(ue)}break;case fe:switch(e){case 1:this.ChangeCallState(de);break;case 3:case 5:this.ChangeCallState(ve),this.ChangeCallState(ue)}break;case de:case pe:switch(e){case 3:case 6:this.ChangeCallState(ve),this.ChangeCallState(ue)}}}},{key:"ChangeCallState",value:function(e){switch(this.logger.debug("%cCA SETTING STATE: ".concat(e),"color: red"),this.currentCallState=e,this.currentCallState){case ue:this.deviceStatus=0;break;case le:this.UpdateDeviceStatus(8,!0);break;case pe:case fe:this.UpdateDeviceStatus(ce,!0),this.isMuted&&(this.setMute(!1),this.deviceMuteChanged({isMuted:!1,name:"CallUnmuted"}));break;case de:this.UpdateDeviceStatus(8,!1),this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId});break;case ve:this.UpdateDeviceStatus(ce,!1),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId});break;case he:this.UpdateDeviceStatus(8,!1),this.deviceRejectedCall({name:"CallRejected",conversationId:this.activeConversationId})}}},{key:"UpdateDeviceStatus",value:function(e,t){e&this.flagSupport?(this.deviceStatus=t?this.deviceStatus|e:this.deviceStatus&~e,this.SendCommandToDevice(this.deviceStatus)):console.debug("CA: UpdateDeviceStatus called with unsupported flag ".concat(e.toString(16),"... returning"))}},{key:"SendCommandToDevice",value:(a=ee(Q().mark((function e(t){return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.JLCommandSet?(this.gCmdBuf[0]=t>>8,this.gCmdBuf[1]=255&t):this.gCmdBuf[0]=t,e.next=3,this.activeDevice.sendReport(this.headsetOutputReportId,this.gCmdBuf);case 3:this.logger.debug("CA: Sent Command to Device. Value: ".concat(this.formatHex(this.gCmdBuf[0]),", ").concat(this.formatHex(this.gCmdBuf[1])," ")),this.gCmdBuf[0]=0,this.gCmdBuf[1]=0;case 6:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"formatHex",value:function(e){return"0x".concat(e.toString(16).padStart(2,"0"))}},{key:"HidMockDeviceInit",value:(i=ee(Q().mark((function e(){var t;return Q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return t=e.sent,this.activeDevice=t[0],e.abrupt("return",this.activeDevice);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_currentCallState",get:function(){return this.currentCallState},set:function(e){this.currentCallState=e}},{key:"_deviceStatus",get:function(){return this.deviceStatus},set:function(e){this.deviceStatus=e}},{key:"_activeConversationId",get:function(){return this.activeConversationId}},{key:"_currentCallInfo",get:function(){return this.currentCallInfo}},{key:"holdState",get:function(){return this.isHolding}},{key:"_headsetInputReportId",get:function(){return this.headsetInputReportId}},{key:"_vendorInputReportId",get:function(){return this.vendorInputReportId}},{key:"_headsetOutputReportId",get:function(){return this.headsetOutputReportId}},{key:"muteState",get:function(){return this.isMuted},set:function(e){this.isMuted=e}},{key:"_JLCommandSet",set:function(e){this.JLCommandSet=e}},{key:"_handeledInputReportIds",set:function(e){this.handeledInputReportIds[0]=e}},{key:"_flagSupport",set:function(e){this.flagSupport=e}},{key:"_currentProductID",set:function(e){this.currentProductID=e}}],o=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&te(n.prototype,r),o&&te(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d,v,p,y,g,m}(V.Z);ie(ye,"instance",void 0);var ge=n(606),me=n.n(ge),be=function(e){return e[e.Unknown=0]="Unknown",e[e.AcceptCall=1]="AcceptCall",e[e.TerminateCall=2]="TerminateCall",e[e.HoldCall=3]="HoldCall",e[e.ResumeCall=4]="ResumeCall",e[e.Flash=5]="Flash",e[e.CallInProgress=6]="CallInProgress",e[e.CallRinging=7]="CallRinging",e[e.CallEnded=8]="CallEnded",e[e.TransferToHeadset=9]="TransferToHeadset",e[e.TransferToSpeaker=10]="TransferToSpeaker",e[e.Mute=11]="Mute",e[e.Unmute=12]="Unmute",e[e.MobileCallRinging=13]="MobileCallRinging",e[e.MobileCallInProgress=14]="MobileCallInProgress",e[e.MobileCallEnded=15]="MobileCallEnded",e[e.DOn=16]="DOn",e[e.DOff=17]="DOff",e[e.CallIdle=18]="CallIdle",e[e.Play=19]="Play",e[e.Pause=20]="Pause",e[e.Stop=21]="Stop",e[e.DTMLKey=22]="DTMLKey",e[e.RejectCall=23]="RejectCall",e[e.MakeCall=24]="MakeCall",e[e.Hook=25]="Hook",e[e.HookIdle=26]="HookIdle",e[e.HookDocked=27]="HookDocked",e[e.HookUndocked=28]="HookUndocked",e[e.BaseEvent=29]="BaseEvent",e[e.CallAnsweredAndEnded=30]="CallAnsweredAndEnded",e[e.CallUnansweredAndEnded=31]="CallUnansweredAndEnded",e[e.DeviceChange=32]="DeviceChange",e[e.DeviceArrived=33]="DeviceArrived",e[e.DeviceRemoved=34]="DeviceRemoved",e}({});function we(e){return we="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},we(e)}function Ce(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ke(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ce(Object(n),!0).forEach((function(t){je(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ce(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ee(){Ee=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==we(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(we(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function Ie(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function Se(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Ie(i,r,o,a,c,"next",e)}function c(e){Ie(i,r,o,a,c,"throw",e)}a(void 0)}))}}function xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Pe(r.key),r)}}function Oe(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Oe=function(){return!!e})()}function _e(e){return _e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_e(e)}function Le(e,t){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Le(e,t)}function je(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=function(e){if("object"!=we(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=we(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==we(t)?t:t+""}var Te=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),je(n=function(e,t,n){return t=_e(t),function(e,t){if(t&&("object"===we(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Oe()?Reflect.construct(t,n||[],_e(e).constructor):t.apply(e,n))}(this,t,[e]),"activePollingInterval",2e3),je(n,"connectedDeviceInterval",6e3),je(n,"disconnectedDeviceInterval",2e3),je(n,"deviceIdRetryInterval",2e3),je(n,"vendorName","Plantronics"),je(n,"pluginName",void 0),je(n,"apiHost","https://127.0.0.1:32018/Spokes"),je(n,"isActive",!1),je(n,"disableEventPolling",!1),je(n,"config",void 0),je(n,"deviceStatusTimer",null),je(n,"isRetry",!1),je(n,"_deviceInfo",void 0),je(n,"callEventsTimerId",void 0),je(n,"deviceStatusTimerId",void 0),je(n,"incomingConversationId",void 0),je(n,"callMappings",{}),n.config=e,n.pluginName=e.appName||"genesys-cloud-headset-library",n._deviceInfo=null,n.callEventsTimerId=null,n.deviceStatusTimerId=null,n.incomingConversationId=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Le(e,t)}(t,e),n=t,r=[{key:"_createCallMapping",value:function(e){var t=Math.round(Math.random()*Math.pow(10,8));return this.callMappings[e]=t,this.callMappings[t]=e,this.logger.info("Created callId mapping for plantronics headset",{conversationId:e,plantronicsCallId:t}),t}},{key:"clearTimeouts",value:function(){clearTimeout(this.callEventsTimerId),clearTimeout(this.deviceStatusTimerId)}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["plantronics","plt","poly","(047f:"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){var e;return null===(e=this._deviceInfo)||void 0===e?void 0:e.ProductName}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"pollForCallEvents",value:function(){var e=this;this.callEventsTimerId&&(clearTimeout(this.callEventsTimerId),this.callEventsTimerId=null),this.isConnected&&!this.disableEventPolling&&(this.logger.debug("**** POLLING FOR CALL EVENTS ****"),this.getCallEvents()),this.callEventsTimerId=setTimeout((function(){e.pollForCallEvents()}),this.activePollingInterval)}},{key:"pollForDeviceStatus",value:function(){var e=this;this.deviceStatusTimerId&&(clearTimeout(this.deviceStatusTimerId),this.deviceStatusTimerId=null),!this.isConnected||this.isConnecting||this.disableEventPolling||(this.logger.debug("**** POLLING FOR DEVICE STATUS ****"),this.getDeviceStatus()),this.deviceStatusTimerId=setTimeout((function(){e.pollForDeviceStatus()}),this.isDeviceAttached?this.connectedDeviceInterval:this.disconnectedDeviceInterval)}},{key:"_makeRequestTask",value:(b=Se(Ee().mark((function e(t,n){return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"_fetch",value:function(e){return me()(e)}},{key:"_makeRequest",value:(m=Se(Ee().mark((function e(n,r){var o,i=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.instance,e.abrupt("return",this._fetch("".concat(this.apiHost).concat(n)).then((function(e){return e.json()})).then((function(e){if(i.isConnected||i.isConnecting){if(!1===e.ok||"Error"===e.Type_Name){if(404===e.status){if(r){i.isConnected&&i.changeConnectionStatus({isConnected:!1,isConnecting:i.isConnecting}),i.disconnect();var t=new Error("Headset: Failed connection to middleware. Headset features unavailable.");return t.handled=!0,i.logger.info(t),Promise.reject(t)}return i._makeRequestTask(n,!0)}return Y().isFirefox&&(i.errorCode="browser",i.disableRetry=!0),Promise.reject(e)}return o?(!i.isConnected&&i.changeConnectionStatus({isConnected:!0,isConnecting:i.isConnecting}),e):Promise.reject(new Error("Application destroyed."))}})).catch((function(e){return Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"_checkIsActiveTask",value:(g=Se(Ee().mark((function e(){var t;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:t=e.sent,this.isActive=!!t.length;case 4:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"_getActiveCalls",value:(y=Se(Ee().mark((function e(){var t,n,r,o=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallManagerState?");case 3:r=e.sent,n=r,e.next=11;break;case 7:return e.prev=7,e.t0=e.catch(0),this.logger.info("Error making request for active calls",e.t0),e.abrupt("return",[]);case 11:if(Array.isArray(null===(t=n)||void 0===t||null===(t=t.Result)||void 0===t?void 0:t.Calls)){e.next=13;break}return e.abrupt("return",[]);case 13:return e.abrupt("return",n.Result.Calls.filter((function(e){return e.Source===o.pluginName})));case 14:case"end":return e.stop()}}),e,this,[[0,7]])}))),function(){return y.apply(this,arguments)})},{key:"getCallEvents",value:(p=Se(Ee().mark((function e(){var t,n=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/CallServices/CallEvents?name=".concat(this.pluginName));case 3:t=e.sent,e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(0),this.logger.info("Error making request for call events",e.t0),e.abrupt("return");case 10:t.Result&&t.Result.forEach((function(e){var t=be[e.Action];if(!t)return n.logger.info("Unknown call event from headset",{event:e});var r={name:t,event:e};n.logger.debug("headset info",r),n.callCorrespondingFunction(r)}));case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return p.apply(this,arguments)})},{key:"getDeviceStatus",value:(v=Se(Ee().mark((function e(){var t=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/DeviceServices/Info").then((function(e){t._deviceInfo=e.Result})).catch((function(e){e.Err&&e.Err.Description.includes("no supported devices")||t.logger.info("Error making request for device status",e)}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"callCorrespondingFunction",value:function(e){var t=e.event.CallId.Id,n=this.callMappings[t];switch(e.name){case"AcceptCall":this.deviceAnsweredCall(ke(ke({},e),{},{conversationId:n}));break;case"RejectCall":this.endCall(n),this.deviceRejectedCall({name:e.name,conversationId:this.incomingConversationId});break;case"TerminateCall":this.deviceEndedCall(ke(ke({},e),{},{conversationId:n}));break;case"CallEnded":delete this.callMappings[t],delete this.callMappings[n],this._checkIsActiveTask();break;case"Mute":this.deviceMuteChanged(ke(ke({isMuted:!0},e),{},{conversationId:n}));break;case"Unmute":this.deviceMuteChanged(ke(ke({isMuted:!1},e),{},{conversationId:n}));break;case"HoldCall":this.deviceHoldStatusChanged(ke(ke({holdRequested:!0},e),{},{conversationId:n}));break;case"ResumeCall":this.deviceHoldStatusChanged(ke(ke({holdRequested:!1},e),{},{conversationId:n}));break;default:this.logger.info("A headset event has occurred",ke(ke({},e),{},{conversationId:n})),this.deviceEventLogs(ke(ke({},e),{},{conversationId:n}))}}},{key:"unregisterPlugin",value:(d=Se(Ee().mark((function e(){var t;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._makeRequestTask("/SessionManager/UnRegister?name=".concat(this.pluginName));case 3:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),"Invalid plugin name"!==(null===e.t0||void 0===e.t0||null===(t=e.t0.Err)||void 0===t?void 0:t.Description)){e.next=10;break}return e.abrupt("return");case 10:this.logger.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(){return d.apply(this,arguments)})},{key:"connect",value:(h=Se(Ee().mark((function e(){var t=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.pollForDeviceStatus(),this.pollForCallEvents(),e.next=5,this.unregisterPlugin();case 5:return e.abrupt("return",this._makeRequestTask("/SessionManager/Register?name=".concat(this.pluginName)).catch((function(e){return e.Err&&"Plugin exists"===e.Err.Description?t.logger.debug("Plugin already exists",e):Promise.reject(e)})).then((function(){return t._makeRequestTask("/SessionManager/IsActive?name=".concat(t.pluginName,"&active=true"))})).catch((function(e){return e.Err&&!e.isError?t.logger.debug("Is Active",e):Promise.reject(e)})).then((function(e){return!0!==(null==e?void 0:e.Result)?Promise.reject(e):t._makeRequestTask("/UserPreference/SetDefaultSoftPhone?name=".concat(t.pluginName))})).then((function(){t.getDeviceStatus()})).then((function(){return t._getActiveCalls()})).then((function(e){if(!e.length)return t.getCallEvents();t.isActive=!0,t.logger.warn("Plantronics headset should be in vanilla state but is reporting active call state.")})).catch((function(e){return null!=e&&e.handled?t.logger.error("Unable to properly connect headset"):Promise.reject(e)})).finally((function(){t.isConnecting&&t.changeConnectionStatus({isConnected:t.isConnected,isConnecting:!1})})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"disconnect",value:(f=Se(Ee().mark((function e(t){return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=2;break}return e.abrupt("return");case 2:if("alternativeClient"===t){e.next=5;break}return e.next=5,this.unregisterPlugin();case 5:this.clearTimeouts(),this._deviceInfo=null,this.isConnected&&this.changeConnectionStatus({isConnected:!1,isConnecting:this.isConnecting}),this.isActive=!1;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"incomingCall",value:function(e){this.logger.info("Inside incomingCall of selected implementation (Plantronics/Poly)");var t=e.conversationId,n=e.contactName;if(!t)throw new Error("Must provide conversationId");var r=this._createCallMapping(t);this.incomingConversationId=t;var o="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),i='"Id":"'.concat(r,'"');if(o+="&callID={".concat(encodeURI(i),"}"),n){var a='"Name":"'.concat(n,'"');o+="&contact={".concat(encodeURI(a),"}")}return this.logger.info("params of endpoint",o),this.isActive=!0,this._makeRequestTask("/CallServices/IncomingCall".concat(o))}},{key:"outgoingCall",value:(l=Se(Ee().mark((function e(t){var n,r,o,i,a,c;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.conversationId,r=t.contactName,n){e.next=3;break}throw new Error("Must provide conversationId");case 3:return o=this._createCallMapping(n),i="?name=".concat(this.pluginName,"&tones=Unknown&route=ToHeadset"),a='"Id":"'.concat(o,'"'),i+="&callID={".concat(encodeURI(a),"}"),r&&(c='"Name":"'.concat(r,'"'),i+="&contact={".concat(encodeURI(c),"}")),this.isActive=!0,e.next=11,this._makeRequestTask("/CallServices/OutgoingCall".concat(i));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Se(Ee().mark((function e(t,n){var r,o,i;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=3;break}return e.next=3,this.incomingCall({conversationId:t});case 3:return r=this.callMappings[t],o='"Id":"'.concat(r,'"'),i="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(o),"}"),this.isActive=!0,this.incomingConversationId=null,e.abrupt("return",this._makeRequestTask("/CallServices/AnswerCall".concat(i)));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:function(e){return this.incomingConversationId=null,this.endCall(e)}},{key:"endCall",value:(s=Se(Ee().mark((function e(t){var n,r,o,i;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="?name=".concat(this.pluginName),r=this.callMappings[t],o='"Id":"'.concat(r,'"'),n+="&callID={".concat(encodeURI(o),"}"),e.next=6,this._makeRequestTask("/CallServices/TerminateCall".concat(n));case 6:return i=e.sent,e.next=9,this.getCallEvents();case 9:return this._checkIsActiveTask(),e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"endAllCalls",value:(c=Se(Ee().mark((function e(){var t=this;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getActiveCalls();case 2:e.sent.forEach((function(e){return t.endCall(t.callMappings[e.CallId])}));case 4:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"setMute",value:(a=Se(Ee().mark((function e(t){var n;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequestTask("/CallServices/MuteCall?name=".concat(this.pluginName,"&muted=").concat(t));case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"setHold",value:(i=Se(Ee().mark((function e(t,n){var r,o,i,a;return Ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.callMappings[t],o='"Id":"'.concat(r,'"'),i="?name=".concat(this.pluginName,"&callID={").concat(encodeURI(o),"}"),e.next=5,this._makeRequestTask("/CallServices/".concat(n?"HoldCall":"ResumeCall").concat(i));case 5:return a=e.sent,e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})}],o=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&xe(n.prototype,r),o&&xe(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d,v,p,y,g,m,b}(V.Z);je(Te,"instance",void 0);var Re=function(e){return e.SocketConnected="SocketConnected",e.EstablishConnection="EstablishConnection",e.SPLogin="SPLoggedIn",e.SPLogout="SPLoggedOut",e.TerminateConnection="TerminateConnection",e.IncomingCall="IncomingCall",e.IncomingCallRejected="InCallRejected",e.IncomingCallAccepted="InCallAccepted",e.OutgoingCall="OutgoingCall",e.CallEnded="CallEnded",e.SystemInformation="SystemInformation",e.HeadsetConnected="HeadsetConnected",e.HeadsetDisconnected="HeadsetDisconnected",e.Hold="CallHold",e.Resume="HeldCallResumed",e.MuteFromApp="MuteHeadset",e.UnmuteFromApp="UnmuteHeadset",e.MuteFromHeadset="MuteSoftphone",e.UnmuteFromHeadset="UnmuteSoftphone",e}({}),Ae=function(e){return e.Request="Request",e.Notification="Notification",e.Ack="Acknowledgement",e}({});function De(e){return De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},De(e)}function He(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Ge(r.key),r)}}function Me(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Me=function(){return!!e})()}function Ne(e){return Ne=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ne(e)}function Fe(e,t){return Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fe(e,t)}function Ue(e,t,n){return(t=Ge(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ge(e){var t=function(e){if("object"!=De(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=De(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==De(t)?t:t+""}var qe=function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return Ue(e=function(e,t,n){return t=Ne(t),function(e,t){if(t&&("object"===De(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Me()?Reflect.construct(t,n||[],Ne(e).constructor):t.apply(e,n))}(this,t,[].concat(r)),"connectTimeout",5e3),Ue(e,"vendorName","Sennheiser"),Ue(e,"isActive",!1),Ue(e,"devices",null),Ue(e,"activeDeviceId",null),Ue(e,"websocketConnected",!1),Ue(e,"websocket",null),Ue(e,"deviceInfo",null),Ue(e,"ignoreAcknowledgement",!1),Ue(e,"webSocketOnOpen",(function(){e.websocketConnected=!0,e.logger.info("websocket open the sennheiser software")})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Fe(e,t)}(t,e),n=t,o=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],(r=[{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["senn","epos"].some((function(e){return t.includes(e)}))}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.ProductName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetHeadsetStateForCall",value:function(e){return this.ignoreAcknowledgement=!0,this.endCall(e)}},{key:"_handleError",value:function(e){this.logger.error("Non-zero return code from sennheiser",e)}},{key:"_handleAck",value:function(e){this.logger.debug("Received Ack for ".concat(e.Event))}},{key:"_sendMessage",value:function(e){this.logger.debug("sending sennheiser message",e),this.websocket.send(JSON.stringify(e))}},{key:"_registerSoftphone",value:function(){var e={Event:Re.EstablishConnection,EventType:Ae.Request,SPName:"Genesys Cloud Softphone",SPIconImage:"SPImage.ico",RedialSupport:"No",OffHookSupport:"No",MuteSupport:"Yes",DNDOption:"No"};this._sendMessage(e)}},{key:"connect",value:function(){this.ignoreAcknowledgement=!1,!this.isConnecting&&this.changeConnectionStatus({isConnected:!1,isConnecting:!0});var e=new WebSocket("wss://127.0.0.1:41088");return e.onopen=this.webSocketOnOpen.bind(this),e.onclose=this.webSocketOnClose.bind(this),e.onmessage=this._handleMessage.bind(this),this.websocket=e,Promise.resolve()}},{key:"webSocketOnClose",value:function(e){this.websocketConnected=!1,e.wasClean||this.logger.error(e),this.isConnected||(this.logger.error(new Error("Failed to connect to sennheiser software. Make sure it is installed")),Y().isFireFox&&(this.errorCode="browser",this.disableRetry=!0)),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1})}},{key:"disconnect",value:function(){return this.isConnected?(this._sendMessage({Event:Re.TerminateConnection,EventType:Ae.Request}),Promise.resolve()):Promise.resolve()}},{key:"setMute",value:function(e){return this._sendMessage({Event:e?Re.MuteFromApp:Re.UnmuteFromApp,EventType:Ae.Request}),Promise.resolve()}},{key:"setHold",value:function(e,t){return this._sendMessage({Event:t?Re.Hold:Re.Resume,EventType:Ae.Request,CallID:e}),Promise.resolve()}},{key:"incomingCall",value:function(e){return this.ignoreAcknowledgement=!1,this._sendMessage({Event:Re.IncomingCall,EventType:Ae.Request,CallID:e.conversationId}),Promise.resolve()}},{key:"answerCall",value:function(e,t){return t&&this.incomingCall({conversationId:e}),this._sendMessage({Event:Re.IncomingCallAccepted,EventType:Ae.Request,CallID:e}),Promise.resolve()}},{key:"rejectCall",value:function(e){return this._sendMessage({Event:Re.IncomingCallRejected,EventType:Ae.Request,CallID:e}),Promise.resolve()}},{key:"outgoingCall",value:function(e){this.ignoreAcknowledgement=!1;var t=e.conversationId;return this._sendMessage({Event:Re.OutgoingCall,EventType:Ae.Request,CallID:t}),Promise.resolve()}},{key:"endCall",value:function(e,t){return t||(this._sendMessage({Event:Re.Resume,EventType:Ae.Request}),this._sendMessage({Event:Re.UnmuteFromApp,EventType:Ae.Request})),this._sendMessage({Event:Re.CallEnded,EventType:Ae.Request,CallID:e}),Promise.resolve()}},{key:"endAllCalls",value:function(){return this.logger.warn("There is no functionality defined for SennheiserService.endAllCalls()"),Promise.resolve()}},{key:"_handleMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(t){return this.logger.error(t),void this.logger.error("Failed to parse sennheiser payload",{message:e})}if(this.logger.debug("incoming sennheiser message",t),t.ReturnCode)this._handleError(t);else{var n=t.CallID;if(!this.ignoreAcknowledgement)switch(t.Event){case Re.SocketConnected:this._registerSoftphone();break;case Re.EstablishConnection:this._sendMessage({Event:Re.SPLogin,EventType:Ae.Request});break;case Re.SPLogin:this.isConnected&&!this.isConnecting||this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),this._sendMessage({Event:Re.SystemInformation,EventType:Ae.Request});break;case Re.HeadsetConnected:t.HeadsetName&&(this.deviceInfo={deviceName:t.HeadsetName,headsetType:t.HeadsetType});break;case Re.HeadsetDisconnected:t.HeadsetName===this.deviceName&&(this.deviceInfo=null);break;case Re.IncomingCallAccepted:t.EventType===Ae.Notification&&this.deviceAnsweredCall({name:t.Event,conversationId:n});break;case Re.Hold:if(t.EventType===Ae.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!0,name:t.Event,conversationId:n});break;case Re.Resume:if(t.EventType===Ae.Ack){this._handleAck(t);break}this.deviceHoldStatusChanged({holdRequested:!1,name:t.Event,conversationId:n});break;case Re.MuteFromHeadset:this.deviceMuteChanged({isMuted:!0,name:t.Event});break;case Re.UnmuteFromHeadset:this.deviceMuteChanged({isMuted:!1,name:t.Event});break;case Re.CallEnded:t.EventType===Ae.Notification&&(this._sendMessage({Event:Re.UnmuteFromApp,EventType:Ae.Request}),this.deviceEndedCall({name:t.Event,conversationId:n}));break;case Re.IncomingCallRejected:t.EventType===Ae.Notification&&this.deviceRejectedCall({name:t.Event,conversationId:n});break;case Re.TerminateConnection:1===this.websocket.readyState&&this.websocket.close(),this.websocket=null;break;default:t.EventType===Ae.Ack&&this._handleAck(t)}}}}])&&He(n.prototype,r),o&&He(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(V.Z);Ue(qe,"instance",void 0);var Be=n(690),Je=f((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ve(e,t){var n="object"==typeof t;return new Promise((function(r,o){var i=new A({next:function(e){r(e),i.unsubscribe()},error:o,complete:function(){n?r(t.defaultValue):o(new Je)}});e.subscribe(i)}))}var We=function(e){function t(t,n){return e.call(this)||this}return o(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(v),Ye={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=Ye.delegate;return(null==o?void 0:o.setInterval)?o.setInterval.apply(o,s([e,t],c(n))):setInterval.apply(void 0,s([e,t],c(n)))},clearInterval:function(e){var t=Ye.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ke=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return o(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),Ye.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&Ye.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,d(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(We),ze={now:function(){return(ze.delegate||Date).now()},delegate:void 0},$e=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=ze.now,e}(),Ze=new(function(e){function t(t,n){void 0===n&&(n=$e.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return o(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}($e))(Ke);function Qe(e){return function(t){if(function(e){return l(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var Xe="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function et(e){if(e instanceof U)return e;if(null!=e){if(function(e){return l(e[N])}(e))return c=e,new U((function(e){var t=c[N]();if(l(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}(e))return o=e,new U((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(l(null==(r=e)?void 0:r.then))return n=e,new U((function(e){n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,I)}));if(function(e){return Symbol.asyncIterator&&l(null==e?void 0:e[Symbol.asyncIterator])}(e))return tt(e);if(function(e){return l(null==e?void 0:e[Xe])}(e))return t=e,new U((function(e){var n,r;try{for(var o=a(t),i=o.next();!i.done;i=o.next()){var c=i.value;if(e.next(c),e.closed)return}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()}));if(function(e){return l(null==e?void 0:e.getReader)}(e))return tt(function(e){return function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||c(e,t)}))})}function c(e,t){try{!function(e){e.value instanceof u?Promise.resolve(e.value.v).then(s,l):f(i[0][2],e)}(o[e](t))}catch(e){f(i[0][3],e)}}function s(e){c("next",e)}function l(e){c("throw",e)}function f(e,t){e(t),i.shift(),i.length&&c(i[0][0],i[0][1])}}(this,arguments,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,u(t.read())];case 3:return n=o.sent(),r=n.value,n.done?[4,u(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,u(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e))}var t,n,r,o,c;throw function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}(e)}function tt(e){return new U((function(t){(function(e,t){var n,r,o,c,s,u,l,f;return s=this,u=void 0,f=function(){var s,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,11]),n=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=a(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,o,(t=e[n](t)).done,t.value)}))}}}(e),i.label=1;case 1:return[4,n.next()];case 2:if((r=i.sent()).done)return[3,4];if(s=r.value,t.next(s),t.closed)return[2];i.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=i.sent(),o={error:u},[3,11];case 6:return i.trys.push([6,,9,10]),r&&!r.done&&(c=n.return)?[4,c.call(n)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))},new((l=void 0)||(l=Promise))((function(e,t){function n(e){try{o(f.next(e))}catch(e){t(e)}}function r(e){try{o(f.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof l?o:new l((function(e){e(o)}))).then(n,r)}o((f=f.apply(s,u||[])).next())}))})(e,t).catch((function(e){return t.error(e)}))}))}function nt(e,t,n,r,o){return new rt(e,t,n,r,o)}var rt=function(e){function t(t,n,r,o,i,a){var c=e.call(this,t)||this;return c.onFinalize=i,c.shouldUnsubscribe=a,c._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,c._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,c}return o(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(j),ot=f((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}));function it(e,t){var n,r=(n=e)instanceof Date&&!isNaN(n)?{first:e}:"number"==typeof e?{each:e}:e,o=r.first,i=r.each,a=r.with,c=void 0===a?at:a,s=r.scheduler,u=void 0===s?null!=t?t:Ze:s,l=r.meta,f=void 0===l?null:l;if(null==o&&null==i)throw new TypeError("No timeout provided.");return Qe((function(e,t){var n,r,a=null,s=0,l=function(e){r=function(e,r,o,i,u){void 0===i&&(i=0),void 0===u&&(u=!1);var l=r.schedule((function(){(function(){try{n.unsubscribe(),et(c({meta:f,lastValue:a,seen:s})).subscribe(t)}catch(e){t.error(e)}})(),u?e.add(this.schedule(null,i)):this.unsubscribe()}),i);if(e.add(l),!u)return l}(t,u,0,e)};n=e.subscribe(nt(t,(function(e){null==r||r.unsubscribe(),s++,t.next(a=e),i>0&&l(i)}),void 0,void 0,(function(){(null==r?void 0:r.closed)||null==r||r.unsubscribe(),a=null}))),!s&&l(null!=o?"number"==typeof o?o:+o-u.now():i)}))}function at(e){throw new ot(e)}function ct(e){return Qe((function(t,n){var r=!1;t.subscribe(nt(n,(function(e){r=!0,n.next(e)}),(function(){r||n.next(e),n.complete()})))}))}function st(e,t){return Qe((function(n,r){var o=0;n.subscribe(nt(r,(function(n){return e.call(t,n,o++)&&r.next(n)})))}))}var ut=new U((function(e){return e.complete()}));function lt(){return new Je}function ft(e,t){var n=arguments.length>=2;return function(r){return r.pipe(e?st((function(t,n){return e(t,n,r)})):F,1<=0?function(){return ut}:Qe((function(e,t){var n=0;e.subscribe(nt(t,(function(e){++n<=1&&(t.next(e),1<=n&&t.complete())})))})),n?ct(t):(void 0===(o=function(){return new Je})&&(o=lt),Qe((function(e,t){var n=!1;e.subscribe(nt(t,(function(e){n=!0,t.next(e)}),(function(){return n?t.complete():t.error(o())})))}))));var o}}function ht(e,t){return Qe((function(n,r){var o=0;n.subscribe(nt(r,(function(n){r.next(e.call(t,n,o++))})))}))}function dt(e){return dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dt(e)}function vt(){vt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==dt(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(dt(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function pt(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function yt(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){pt(i,r,o,a,c,"next",e)}function c(e){pt(i,r,o,a,c,"throw",e)}a(void 0)}))}}function gt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,kt(r.key),r)}}function mt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(mt=function(){return!!e})()}function bt(e){return bt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},bt(e)}function wt(e,t){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},wt(e,t)}function Ct(e,t,n){return(t=kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kt(e){var t=function(e){if("object"!=dt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==dt(t)?t:t+""}var Et=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),Ct(n=function(e,t,n){return t=bt(t),function(e,t){if(t&&("object"===dt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,mt()?Reflect.construct(t,n||[],bt(e).constructor):t.apply(e,n))}(this,t,[e]),"headsetEventSubscription",void 0),Ct(n,"isActive",!1),Ct(n,"_deviceInfo",void 0),Ct(n,"isMuted",!1),Ct(n,"isHeld",!1),Ct(n,"version",null),Ct(n,"_connectDeferred",void 0),Ct(n,"jabraSdk",void 0),Ct(n,"callControlFactory",void 0),Ct(n,"callControl",void 0),Ct(n,"ongoingCalls",0),Ct(n,"callLock",!1),Ct(n,"pendingConversationId",void 0),Ct(n,"pendingConversationIsOutbound",void 0),Ct(n,"activeConversationId",void 0),n.vendorName="Jabra",n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&wt(e,t)}(t,e),n=t,r=[{key:"isSupported",value:function(){return window.navigator.hid&&!K()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return!!["jabra"].some((function(e){return t.includes(e)}))}},{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"deviceName",get:function(){var e;return null===(e=this.deviceInfo)||void 0===e?void 0:e.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"resetState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_processEvents",value:function(e){var t=this;this.headsetEventSubscription=e.deviceSignals.subscribe(function(){var n=yt(vt().mark((function n(r){var o,i,a,c;return vt().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t.callLock){n.next=3;break}return t.logger.debug("Currently not in possession of the Call Lock; Cannot react to Device Actions"),n.abrupt("return");case 3:n.t0=r.type,n.next=n.t0===Be.SignalType.HOOK_SWITCH?6:n.t0===Be.SignalType.FLASH||n.t0===Be.SignalType.ALT_HOLD?11:n.t0===Be.SignalType.PHONE_MUTE?15:n.t0===Be.SignalType.REJECT_CALL?19:23;break;case 6:if(!t.activeConversationId||!t.pendingConversationId){n.next=9;break}return t.logger.info("ignoring hookswitch event because there is an active and incoming call"),n.abrupt("break",23);case 9:if(r.value)e.offHook(!0),e.ring(!1),t.activeConversationId=t.pendingConversationId,t.pendingConversationId=null,t.pendingConversationIsOutbound||t.deviceAnsweredCall({name:"CallOffHook",code:r.type,conversationId:t.activeConversationId});else{e.mute(!1),e.hold(!1),e.offHook(!1),t.deviceEndedCall({name:"CallOnHook",code:r.type,conversationId:t.activeConversationId});try{e.releaseCallLock()}catch(e){o=e.message,i=e.type,t.checkForCallLockError(o,i)?t.logger.info(o):t.logger.error(i,o)}finally{t.activeConversationId=null,t.callLock=!1}}return n.abrupt("break",23);case 11:return t.isHeld=!t.isHeld,e.hold(t.isHeld),t.deviceHoldStatusChanged({holdRequested:t.isHeld,name:t.isHeld?"OnHold":"ResumeCall",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 15:return t.isMuted=!t.isMuted,e.mute(t.isMuted),t.deviceMuteChanged({isMuted:t.isMuted,name:t.isMuted?"CallMuted":"CallUnmuted",code:r.type,conversationId:t.activeConversationId}),n.abrupt("break",23);case 19:e.ring(!1),t.deviceRejectedCall({name:Be.SignalType[r.type],conversationId:t.pendingConversationId}),t.pendingConversationId=null;try{t.activeConversationId||(e.releaseCallLock(),t.callLock=!1)}catch(e){a=e.message,c=e.type,t.checkForCallLockError(a,c)?t.logger.info(a):t.logger.error(c,a)}case 23:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}())}},{key:"setMute",value:(b=yt(vt().mark((function e(t){return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isMuted=t,this.callControl.mute(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"setHold",value:(m=yt(vt().mark((function e(t,n){return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return");case 2:this.isHeld=n,this.callControl.hold(n);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return m.apply(this,arguments)})},{key:"incomingCall",value:(g=yt(vt().mark((function e(t){var n,r;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 13:this.callLock&&this.callControl.ring(!0);case 14:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e){return g.apply(this,arguments)})},{key:"answerCall",value:(y=yt(vt().mark((function e(t,n){var r,o;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=13;break}return this.pendingConversationId=t,e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callLock=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(2),r=e.t0.message,o=e.t0.type,this.checkForCallLockError(r,o)?(this.logger.info(r),this.callLock=!0):this.logger.error(o,r);case 13:if(this.callLock){e.next=15;break}return e.abrupt("return");case 15:this.callControl.ring(!1),this.callControl.offHook(!0);case 17:case"end":return e.stop()}}),e,this,[[2,8]])}))),function(e,t){return y.apply(this,arguments)})},{key:"rejectCall",value:(p=yt(vt().mark((function e(){var t,n;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callLock){e.next=2;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 2:if(this.callControl.ring(!1),this.pendingConversationId=null,!this.activeConversationId)try{this.resetState(),this.callControl.releaseCallLock()}catch(e){t=e.message,n=e.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t)}finally{this.pendingConversationId=null,this.callLock=!1}case 5:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"outgoingCall",value:(v=yt(vt().mark((function e(t){var n,r;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.callControl.takeCallLock();case 3:this.callLock=e.sent,e.next=11;break;case 6:e.prev=6,e.t0=e.catch(0),n=e.t0.message,r=e.t0.type,this.checkForCallLockError(n,r)?(this.logger.info(n),this.callLock=!0):this.logger.error(r,n);case 11:this.callLock&&(this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this.callControl.offHook(!0));case 12:case"end":return e.stop()}}),e,this,[[0,6]])}))),function(e){return v.apply(this,arguments)})},{key:"endCall",value:(d=yt(vt().mark((function e(t,n){var r,o;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:if(t===this.activeConversationId&&(this.activeConversationId=null),e.prev=3,this.callLock){e.next=6;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 6:this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),e.next=16;break;case 11:e.prev=11,e.t0=e.catch(3),r=e.t0.message,o=e.t0.type,this.checkForCallLockError(r,o)?this.logger.info(r):this.logger.error(o,r);case 16:return e.prev=16,this.callLock=!1,e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[3,11,16,19]])}))),function(e,t){return d.apply(this,arguments)})},{key:"endAllCalls",value:(h=yt(vt().mark((function e(){var t,n;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.activeConversationId=null,this.callControl.offHook(!1),this.resetState(),this.callControl.releaseCallLock(),e.next=14;break;case 9:e.prev=9,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 14:return e.prev=14,this.callLock=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[0,9,14,17]])}))),function(){return h.apply(this,arguments)})},{key:"isDeviceInList",value:function(e,t){var n;return t.toLowerCase().includes(null==e||null===(n=e.name)||void 0===n?void 0:n.toLowerCase())}},{key:"connect",value:(f=yt(vt().mark((function e(t){var n,r;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isConnecting){e.next=2;break}return e.abrupt("return");case 2:if(this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),this.jabraSdk){e.next=8;break}return e.next=6,this.initializeJabraSdk();case 6:this.jabraSdk=e.sent,this.callControlFactory=this.createCallControlFactory(this.jabraSdk);case 8:return n=t.toLocaleLowerCase(),this._deviceInfo=null,e.next=12,this.deviceHasPermissions(n);case 12:if(!e.sent){e.next=22;break}return e.next=15,this.getPreviouslyConnectedDevice(n);case 15:if(r=e.sent){e.next=20;break}return console.warn('Unable to find appropriate device. Setting state to "Not Running" to allow a retry"',n),this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.abrupt("return");case 20:e.next=32;break;case 22:return e.prev=22,e.next=25,this.getDeviceFromWebhid(n);case 25:r=e.sent,e.next=32;break;case 28:return e.prev=28,e.t0=e.catch(22),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),e.abrupt("return");case 32:return e.next=34,this.callControlFactory.createCallControl(r);case 34:return this.callControl=e.sent,e.next=37,this.resetHeadsetState();case 37:this._processEvents(this.callControl),this._deviceInfo={ProductName:r.name,deviceName:r.name,attached:!0,deviceId:r.id.toString()},this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 40:case"end":return e.stop()}}),e,this,[[22,28]])}))),function(e){return f.apply(this,arguments)})},{key:"deviceHasPermissions",value:(l=yt(vt().mark((function e(t){var n,r;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:return n=e.sent,r=!1,n.forEach((function(e){var n;t.includes(null==e||null===(n=e.productName)||void 0===n?void 0:n.toLowerCase())&&(r=!0)})),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return l.apply(this,arguments)})},{key:"getPreviouslyConnectedDevice",value:(u=yt(vt().mark((function e(t){var n,r=this;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.jabraSdk.deviceList.pipe(ct(null),ft((function(e){return!!e.length})),ht((function(e){return e.find((function(e){return r.isDeviceInList(e,t)}))})),st((function(e){return!!e})),it(15e3)),e.abrupt("return",Ve(n).catch((function(e){return e instanceof ot||e instanceof Je?null:Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getDeviceFromWebhid",value:(s=yt(vt().mark((function e(t){var n=this;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.requestWebHidPermissions(Be.webHidPairing),e.abrupt("return",Ve(this.jabraSdk.deviceList.pipe(ht((function(e){return e.find((function(e){return n.isDeviceInList(e,t)}))})),st((function(e){return!!e})),ft(),it(3e4))).catch((function(e){return e instanceof ot&&(e=new Error("The selected device was not granted WebHID permissions")),n.logger.error(e),Promise.reject(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"initializeJabraSdk",value:(c=yt(vt().mark((function e(){return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,Be.init)({appId:"softphone-vendor-headsets",appName:"Softphone Headset Library",transport:Be.RequestedBrowserTransport.CHROME_EXTENSION_WITH_WEB_HID_FALLBACK}));case 1:case"end":return e.stop()}}),e)}))),function(){return c.apply(this,arguments)})},{key:"createCallControlFactory",value:function(e){return new Be.CallControlFactory(e)}},{key:"checkForCallLockError",value:function(e,t){return t===Be.ErrorType.SDK_USAGE_ERROR&&e.includes("call lock")}},{key:"resetHeadsetState",value:(a=yt(vt().mark((function e(){return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.callControl){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.callControl.takeCallLock();case 5:this.callControl.hold(!1),this.callControl.mute(!1),this.callControl.offHook(!1),this.callControl.releaseCallLock(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(2),this.logger.warn("Failed to takeCallLock in order to resetHeadsetState. Ignoring reset.");case 14:case"end":return e.stop()}}),e,this,[[2,11]])}))),function(){return a.apply(this,arguments)})},{key:"disconnect",value:(i=yt(vt().mark((function e(){var t,n;return vt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.callLock){e.next=3;break}return e.abrupt("return",this.logger.info("Currently not in possession of the Call Lock; Cannot react to Device Actions"));case 3:this.callControl.releaseCallLock(),e.next=11;break;case 6:e.prev=6,e.t0=e.catch(0),t=e.t0.message,n=e.t0.type,this.checkForCallLockError(t,n)?this.logger.info(t):this.logger.error(n,t);case 11:return e.prev=11,this.resetHeadsetState(),this.callLock=!1,this.activeConversationId&&(this.activeConversationId=null),this.headsetEventSubscription&&this.headsetEventSubscription.unsubscribe(),(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),e.finish(11);case 18:case"end":return e.stop()}}),e,this,[[0,6,11,18]])}))),function(){return i.apply(this,arguments)})}],o=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&gt(n.prototype,r),o&&gt(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d,v,p,y,g,m,b}(V.Z);Ct(Et,"instance",void 0),Ct(Et,"connectTimeout",5e3);var It=function(e){return e.Ring="ringer",e.Offhook="offhook",e.Mute="mute",e.Hold="hold",e}({}),St=function(e){return e.OffHook="OffHook",e.Mute="Mute",e.Hold="Flash",e.RejectCall="RejectCall",e}({});function xt(e){return xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xt(e)}function Ot(){Ot=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==xt(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(xt(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function _t(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function Lt(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){_t(i,r,o,a,c,"next",e)}function c(e){_t(i,r,o,a,c,"throw",e)}a(void 0)}))}}function jt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Dt(r.key),r)}}function Pt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Pt=function(){return!!e})()}function Tt(e){return Tt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Tt(e)}function Rt(e,t){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Rt(e,t)}function At(e,t,n){return(t=Dt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dt(e){var t=function(e){if("object"!=xt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==xt(t)?t:t+""}var Ht=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),At(n=function(e,t,n){return t=Tt(t),function(e,t){if(t&&("object"===xt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Pt()?Reflect.construct(t,n||[],Tt(e).constructor):t.apply(e,n))}(this,t,[e]),"isActive",!1),At(n,"devices",null),At(n,"activeDeviceId",null),At(n,"headsetState",null),At(n,"ignoreNextOffhookEvent",!1),At(n,"cefSupportsJabra",!0),At(n,"pendingConversationId",void 0),At(n,"activeConversationId",void 0),At(n,"pendingConversationIsOutbound",void 0),n.vendorName="Jabra",n.headsetState={ringing:!1,offHook:!1},n.devices=new Map,K()&&(n.isHostedContextInitialized()?n.setupNativeHandlers():n.waitForHostedContext()),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Rt(e,t)}(t,e),n=t,r=[{key:"isHostedContextInitialized",value:function(){var e;return null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext").isHosted()}},{key:"waitForHostedContext",value:function(){var e=this;setTimeout((function(){e.isHostedContextInitialized()?e.setupNativeHandlers():e.waitForHostedContext()}),500)}},{key:"setupNativeHandlers",value:function(){var e,t=null===(e=window.Orgspan)||void 0===e?void 0:e.serviceFor("application").get("hostedContext");this.cefSupportsJabra=t.supportsJabra(),t.on("JabraEvent",this.handleJabraEvent.bind(this)),t.on("JabraDeviceAttached",this.handleJabraDeviceAttached.bind(this))}},{key:"deviceInfo",get:function(){return null===this.activeDeviceId||null===this.devices||this.devices&&!this.devices.size?null:this.devices.get(this.activeDeviceId)}},{key:"deviceName",get:function(){return this.deviceInfo&&this.deviceInfo.deviceName}},{key:"isDeviceAttached",get:function(){return!!this.deviceInfo}},{key:"isHeadsetEvent",value:function(e){return"JabraEvent"===e.msg}},{key:"isDeviceEvent",value:function(e){return"JabraDeviceAttached"===e.msg}},{key:"handleCefEvent",value:function(e){this.isConnected&&(this.isDeviceEvent(e)?this.handleJabraDeviceAttached(e):this.isHeadsetEvent(e)&&this.handleJabraEvent(e))}},{key:"handleJabraDeviceAttached",value:function(e){this.logger.debug("handling jabra attach/detach event",e),this.updateDevices()}},{key:"handleJabraEvent",value:function(e){this.logger.debug("Jabra event received",e),this._processEvent(e.eventName,e.value)}},{key:"_handleOffhookEvent",value:function(e){if(e)return this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null,void(this.headsetState.ringing&&(this.pendingConversationIsOutbound||this.deviceAnsweredCall({name:"CallOffHook",conversationId:this.activeConversationId}),this._sendCmd(It.Offhook,e),this._setRinging(!1)));this.activeConversationId&&(this._sendCmd(It.Offhook,e),this.deviceEndedCall({name:"CallOnHook",conversationId:this.activeConversationId})),this._getHeadsetIntoVanillaState(),this.activeConversationId=null}},{key:"_handleMuteEvent",value:function(e){this._sendCmd(It.Mute,e),this.isMuted=e,this.deviceMuteChanged({isMuted:e,name:e?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})}},{key:"_handleHoldEvent",value:function(e){this._sendCmd(It.Hold,!!e),this.deviceHoldStatusChanged({holdRequested:!!e,name:e?"OnHold":"ResumeCall",conversationId:this.activeConversationId})}},{key:"_getHeadsetIntoVanillaState",value:function(){this.setHold(null,!1),this.setMute(!1)}},{key:"_sendCmd",value:function(e,t){var n=this.activeDeviceId;this.logger.debug("Sending command to headset",{deviceId:n,cmd:e,value:t}),window._HostedContextFunctions.sendEventToDesktop("jabraEvent",{deviceID:n,event:e,value:t})}},{key:"_setRinging",value:function(e){this._sendCmd(It.Ring,e),this.headsetState.ringing=e}},{key:"isSupported",value:function(){return K()&&this.cefSupportsJabra}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["jabra"].some((function(e){return t.includes(e)}))}},{key:"setMute",value:(d=Lt(Ot().mark((function e(t){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(It.Mute,t);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"setHold",value:(h=Lt(Ot().mark((function e(t,n){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._sendCmd(It.Hold,n);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Lt(Ot().mark((function e(t){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!1,this._setRinging(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"answerCall",value:(l=Lt(Ot().mark((function e(t,n){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n&&(this.pendingConversationId=t),this.ignoreNextOffhookEvent=!0,this._sendCmd(It.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"rejectCall",value:(u=Lt(Ot().mark((function e(){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this.pendingConversationId=null;case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"outgoingCall",value:(s=Lt(Ot().mark((function e(t){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.pendingConversationIsOutbound=!0,this._sendCmd(It.Offhook,!0);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"endCall",value:(c=Lt(Ot().mark((function e(t,n){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),n||this._sendCmd(It.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"endAllCalls",value:(a=Lt(Ot().mark((function e(){return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._setRinging(!1),this._sendCmd(It.Offhook,!1),this.activeConversationId=null;case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateDevices",value:(i=Lt(Ot().mark((function e(){var t,n=this;return Ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,z({cmd:"requestJabraDevices"});case 3:if(t=e.sent,this.changeConnectionStatus({isConnected:!0,isConnecting:!1}),t&&t.length){e.next=10;break}return this.devices.clear(),this.activeDeviceId=null,this.logger.error(new Error("No attached jabra devices")),e.abrupt("return");case 10:this.logger.info("connected jabra devices",t),this.devices.clear(),t.forEach((function(e){return n.devices.set(e.deviceID,e)})),this.activeDeviceId=t[0].deviceID,this._setRinging(!1),this.setMute(!1),e.next=22;break;case 18:e.prev=18,e.t0=e.catch(0),this.logger.error("Failed to connect to jabra",e.t0),this.disconnect();case 22:case"end":return e.stop()}}),e,this,[[0,18]])}))),function(){return i.apply(this,arguments)})},{key:"_processEvent",value:function(e,t){var n,r,o=this;switch(e){case St.OffHook:(n=function(){return o._handleOffhookEvent(t)},r=null,function(){clearTimeout(r),r=setTimeout((function(){n()}),500)})();break;case St.RejectCall:this.deviceRejectedCall({name:St.RejectCall,conversationId:this.pendingConversationId});break;case St.Mute:this._handleMuteEvent(t);break;case St.Hold:this._handleHoldEvent(t)}}},{key:"connect",value:function(){var e,t,n,r=this;return this.changeConnectionStatus({isConnected:!1,isConnecting:!0}),(e=this.updateDevices(),n=new Promise((function(e,n){t=setTimeout((function(){clearTimeout(t),n("Timed out in 5000ms")}),5e3)})).then((function(e){return clearTimeout(t),e})),Promise.race([e,n])).catch((function(e){r.logger.error("Failed to connect to Jabra",e)}))}},{key:"disconnect",value:function(){return this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),Promise.resolve()}}],o=[{key:"getInstance",value:function(e){return t.instance&&!e.createNew||(t.instance=new t(e)),t.instance}}],r&&jt(n.prototype,r),o&&jt(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d}(V.Z);function Mt(e){return Mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mt(e)}function Nt(){Nt=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==Mt(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(Mt(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function Ft(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ut(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Gt(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function qt(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Gt(i,r,o,a,c,"next",e)}function c(e){Gt(i,r,o,a,c,"throw",e)}a(void 0)}))}}function Bt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Kt(r.key),r)}}function Jt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(Jt=function(){return!!e})()}function Vt(e){return Vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Vt(e)}function Wt(e,t){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Wt(e,t)}function Yt(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kt(e){var t=function(e){if("object"!=Mt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Mt(t)?t:t+""}At(Ht,"instance",void 0);var zt,$t,Zt,Qt,Xt=function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return Yt(e=function(e,t,n){return t=Vt(t),function(e,t){if(t&&("object"===Mt(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Jt()?Reflect.construct(t,n||[],Vt(e).constructor):t.apply(e,n))}(this,t,[].concat(r)),"pendingConversationId",void 0),Yt(e,"activeConversationId",void 0),Yt(e,"_deviceInfo",null),Yt(e,"activeDevice",void 0),Yt(e,"callState",0),Yt(e,"recCallState",0),Yt(e,"isHold",!1),Yt(e,"inputReportReportId",null),Yt(e,"vendorName","Yealink"),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Wt(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!K()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["yealink","(6993:"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(p=qt(Nt().mark((function e(t){var n,r=this;return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),n=t.toLowerCase(),e.next=4,window.navigator.hid.getDevices();case 4:if(e.sent.forEach((function(e){var t;if(!r.activeDevice&&n.includes(null==e||null===(t=e.productName)||void 0===t?void 0:t.toLowerCase())){var o,i=Ft(e.collections);try{for(i.s();!(o=i.n()).done;){var a=o.value;if(5===a.usage&&11===a.usagePage){r.activeDevice=e,0!==a.inputReports.length&&(r.inputReportReportId=a.inputReports[0].reportId);break}}}catch(e){i.e(e)}finally{i.f()}}})),this.activeDevice){e.next=18;break}return e.prev=7,e.next=10,new Promise((function(e,o){var i=setTimeout(o,3e4);r.requestWebHidPermissions(qt(Nt().mark((function a(){var c,s,u,l;return Nt().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return c=r.deductProductId(t),s=[{usage:5,usagePage:11,vendorId:27027,productId:c||void 0}],a.next=4,window.navigator.hid.requestDevice({filters:s});case 4:return clearTimeout(i),a.next=7,window.navigator.hid.getDevices();case 7:u=a.sent,l=!1,u.forEach((function(t){var o;if(n.includes(null==t||null===(o=t.productName)||void 0===o?void 0:o.toLowerCase())){var i,a=Ft(t.collections);try{for(a.s();!(i=a.n()).done;){var c=i.value;if(5===c.usage&&11===c.usagePage){l=!0,0!==c.inputReports.length&&(r.inputReportReportId=c.inputReports[0].reportId),e(t);break}}}catch(e){a.e(e)}finally{a.f()}}})),l||o();case 11:case"end":return a.stop()}}),a)}))))}));case 10:this.activeDevice=e.sent,e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(7),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error("The selected device was not granted WebHID permissions"),e.abrupt("return");case 18:if(this.activeDevice.opened){e.next=21;break}return e.next=21,this.activeDevice.open();case 21:this.logger.debug("get device reportId ".concat(this.inputReportReportId)),this.activeDevice.addEventListener("inputreport",(function(e){if(e.reportId===r.inputReportReportId){var t=e.data.getUint8(0);r.processBtnPress(t)}})),this._deviceInfo={ProductName:this.activeDevice.productName},this.isConnecting&&!this.isConnected&&this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 25:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e){return p.apply(this,arguments)})},{key:"disconnect",value:(v=qt(Nt().mark((function e(){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(this.isConnected||this.isConnecting)&&this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&(this.activeDevice.close(),this.activeDevice=null,this._deviceInfo=null,this.inputReportReportId=0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"processBtnPress",value:function(e){if(this.activeDevice){this.logger.debug("User pressed button ".concat(e,". local ").concat(this.recCallState));var t=e^this.recCallState;0!==t&&(0===e||-3&this.callState?(this.recCallState=e,1&t?1&e?(this.answerCall(),this.activeConversationId?this.deviceAnsweredCall({name:"OffHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty")):this.isHold||(this.sendOpToDevice(this.isMuted?2:0),this.activeConversationId?this.deviceEndedCall({name:"OnHook",conversationId:this.activeConversationId}):this.logger.debug("activeConversationId is empty"),this.activeConversationId=null):4&t?4&e&&(this.setMute(!this.isMuted),this.deviceMuteChanged({isMuted:this.isMuted,name:this.isMuted?"CallMuted":"CallUnmuted",conversationId:this.activeConversationId})):8&t?8&e&&(this.setHold(null,!this.isHold),this.deviceHoldStatusChanged({holdRequested:this.isHold,name:this.isHold?"OnHold":"ResumeCall",conversationId:this.activeConversationId})):64&t&&64&e&&(this.deviceRejectedCall({name:"Reject",conversationId:this.pendingConversationId}),this.rejectCall())):this.logger.debug("Not talking, ignore key"))}else this.logger.error("do not have active device")}},{key:"incomingCall",value:(d=qt(Nt().mark((function e(t){var n;return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t&&(this.pendingConversationId=t.conversationId,n=this.isMuted?2:0,this.sendOpToDevice(4|n));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"outgoingCall",value:(h=qt(Nt().mark((function e(t){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.sendOpToDevice(1);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"answerCall",value:(f=qt(Nt().mark((function e(){var t;return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId&&(this.activeConversationId=this.pendingConversationId,this.pendingConversationId=null),t=this.isMuted?2:0,this.sendOpToDevice(1|t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"rejectCall",value:(l=qt(Nt().mark((function e(){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"endCall",value:(u=qt(Nt().mark((function e(t,n){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=2;break}return e.abrupt("return");case 2:t===this.activeConversationId&&(this.activeConversationId=null),this.sendOpToDevice(this.isMuted?2:0);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"endAllCalls",value:(s=qt(Nt().mark((function e(){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=null,this.sendOpToDevice(this.isMuted?2:0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"setMute",value:(c=qt(Nt().mark((function e(t){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t?this.sendOpToDevice(2|this.callState):this.sendOpToDevice(-3&this.callState);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setHold",value:(a=qt(Nt().mark((function e(t,n){var r,o;return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n?(r=-2&this.callState,this.sendOpToDevice(8|r)):(o=-9&this.callState,this.sendOpToDevice(1|o));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"sendOpToDevice",value:(i=qt(Nt().mark((function e(t){return Nt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.activeDevice&&0!==this.inputReportReportId){e.next=3;break}return this.logger.error("do not have active device"),e.abrupt("return");case 3:return this.isHold=!!(8&t),this.isMuted=!!(2&t),this.logger.debug("send to dev ".concat(t)),this.callState=t,e.next=9,this.activeDevice.sendReport(this.inputReportReportId,new Uint8Array([t]));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}],o=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Bt(n.prototype,r),o&&Bt(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d,v,p}(V.Z);function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tn(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function nn(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){tn(i,r,o,a,c,"next",e)}function c(e){tn(i,r,o,a,c,"throw",e)}a(void 0)}))}}function rn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,fn(r.key),r)}}function on(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=hn(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}function an(e,t,n){return(t=fn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cn(Object(n),!0).forEach((function(t){an(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function un(){un=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function ln(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],s=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(s=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||hn(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fn(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function hn(e,t){if(e){if("string"==typeof e)return en(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?en(e,t):void 0}}function dn(e){return 65535&e}function vn(e){return e>>>16}function pn(e){return e.isAbsolute?Qt.ToggleSwitch:Qt.ToggleButton}Yt(Xt,"instance",void 0),function(e){e[e.LED=8]="LED",e[e.TELEPHONY=11]="TELEPHONY"}(zt||(zt={})),function(e){e[e.PROGRAMMABLE_BUTTON=7]="PROGRAMMABLE_BUTTON",e[e.HOOK_SWITCH=32]="HOOK_SWITCH",e[e.FLASH=33]="FLASH",e[e.PHONE_MUTE=47]="PHONE_MUTE"}($t||($t={})),function(e){e[e.MUTE=9]="MUTE",e[e.OFF_HOOK=23]="OFF_HOOK",e[e.RING=24]="RING",e[e.HOLD=32]="HOLD"}(Zt||(Zt={})),function(e){e[e.ToggleButton=0]="ToggleButton",e[e.ToggleSwitch=1]="ToggleSwitch"}(Qt||(Qt={}));var yn,gn={usage:5,usagePage:zt.TELEPHONY},mn=[$t.HOOK_SWITCH,$t.PHONE_MUTE,$t.PROGRAMMABLE_BUTTON],bn=[Zt.OFF_HOOK,Zt.RING,Zt.MUTE],wn=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),an(this,"device",void 0),an(this,"inputEventInfos",void 0),an(this,"inputEventObserverCallbacks",void 0),an(this,"outputEventInfos",void 0),this.device=t,this.inputEventInfos=mn.reduce((function(e,t){return sn(sn({},e),{},an({},t,void 0))}),{}),this.inputEventObserverCallbacks=mn.reduce((function(e,t){return sn(sn({},e),{},an({},t,[]))}),{}),this.outputEventInfos=bn.reduce((function(e,t){return sn(sn({},e),{},an({},t,void 0))}),{}),this.parseDeviceDescriptors(),this.device.addEventListener("inputreport",(function(e){return n.onInputReport(e)}))}return t=e,n=[{key:"onInputReport",value:function(e){var t,n,r,o,i,a,c,s,u=this.device.productId;if(u>=64&&u<=130&&5===e.reportId)switch(e.data.getUint8(0)){case 32:null===(t=(n=this.inputEventObserverCallbacks[$t.HOOK_SWITCH])[0])||void 0===t||t.call(n,!0,Qt.ToggleSwitch);break;case 8:this.inputEventObserverCallbacks[$t.PROGRAMMABLE_BUTTON][0](!0,Qt.ToggleSwitch);break;case 0:null===(r=(o=this.inputEventObserverCallbacks[$t.HOOK_SWITCH])[0])||void 0===r||r.call(o,!1,Qt.ToggleSwitch);break;case 1:null===(i=(a=this.inputEventObserverCallbacks[$t.PHONE_MUTE])[0])||void 0===i||i.call(a,!1,Qt.ToggleSwitch);break;case 5:null===(c=(s=this.inputEventObserverCallbacks[$t.PHONE_MUTE])[0])||void 0===c||c.call(s,!0,Qt.ToggleSwitch)}else for(var l=0,f=mn;l<f.length;l++){var h=f[l],d=this.inputEventInfos[h];if(void 0!==d&&e.reportId===d.reportId){var v,p=Math.trunc(d.offset/8),y=d.offset%8,g=!!(e.data.getUint8(p)&1<<y),m=on(this.inputEventObserverCallbacks[h]);try{for(m.s();!(v=m.n()).done;)(0,v.value)(g,d.controlType)}catch(e){m.e(e)}finally{m.f()}}}}},{key:"close",value:(a=nn(un().mark((function e(){return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.device.opened){e.next=3;break}return e.next=3,this.device.close();case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"parseDeviceDescriptors",value:function(){if(void 0===this.device.collections)throw new Error("Undefined device collection");var e=this.device.collections.find((function(e){return e.usagePage===zt.TELEPHONY}));if(void 0===e)throw new Error("No telephony collection");e.inputReports&&this.parseInputReport(e.inputReports),e.outputReports&&this.parseOutputReport(e.outputReports)}},{key:"parseInputReport",value:function(e){var t,n,r=on(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=0;if(void 0!==o.items&&void 0!==o.reportId){var a,c=on(o.items);try{for(c.s();!(a=c.n()).done;){var s=a.value;if(void 0!==s.usages&&void 0!==s.reportSize&&void 0!==s.reportCount&&void 0!==s.isAbsolute){var u,l=on(s.usages.entries());try{for(l.s();!(u=l.n()).done;){var f=ln(u.value,2),h=f[0],d=f[1];if(vn(d)===zt.TELEPHONY||589831===d){var v=dn(d);n=v,mn.includes(n)&&(this.inputEventInfos[v]={reportId:o.reportId,offset:i+h*s.reportSize,controlType:pn(s)})}}}catch(e){l.e(e)}finally{l.f()}i+=s.reportCount*s.reportSize}}}catch(e){c.e(e)}finally{c.f()}}}}catch(e){r.e(e)}finally{r.f()}}},{key:"parseOutputReport",value:function(e){var t,n=this,r=on(e);try{var o=function(){var e=t.value;if(void 0===e.items||void 0===e.reportId)return 1;var r,o,i=0,a=[],c=on(e.items);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(void 0===s.usages||void 0===s.reportSize||void 0===s.reportCount){a=[];break}var u,l=on(s.usages.entries());try{for(l.s();!(u=l.n()).done;){var f=ln(u.value,2),h=f[0],d=f[1];if(vn(d)===zt.LED){var v=dn(d);o=v,bn.includes(o)&&a.push([v,i+h*s.reportSize])}}}catch(e){l.e(e)}finally{l.f()}i+=s.reportCount*s.reportSize}}catch(e){c.e(e)}finally{c.f()}for(var p=i,y=function(){var t=ln(m[g],2),r=t[0],o=t[1];n.outputEventInfos[r]={reportId:e.reportId,state:!1,offset:o,generator:function(){var t=new Uint8Array(p/8);return{reportId:e.reportId,data:t}},setter:function(e,t){if(o>=0){var n=Math.trunc(o/8),r=o%8;t[n]|=(e?1:0)<<r}return t}}},g=0,m=a;g<m.length;g++)y()};for(r.s();!(t=r.n()).done;)o()}catch(e){r.e(e)}finally{r.f()}}},{key:"getControlType",value:function(e){var t;if(this.supportInput(e))return null===(t=this.inputEventInfos[e])||void 0===t?void 0:t.controlType}},{key:"supportInput",value:function(e){return void 0!==this.inputEventInfos[e]}},{key:"supportOutput",value:function(e){return void 0!==this.outputEventInfos[e]}},{key:"subscribe",value:function(e,t){this.inputEventObserverCallbacks[e].push(t)}},{key:"unsubscribe",value:function(e){this.inputEventObserverCallbacks[e]=[]}},{key:"setState",value:function(e,t){if(this.device.opened){var n=this.outputEventInfos[e];void 0!==n&&(n.state=t)}}},{key:"getState",value:function(e){var t;if(this.device.opened)return null===(t=this.outputEventInfos[e])||void 0===t?void 0:t.state}},{key:"send",value:(i=nn(un().mark((function e(t){var n,r,o,i,a,c,s,u,l,f,h,d,v,p,y,g=this;return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.device.opened){e.next=2;break}return e.abrupt("return");case 2:if(!((n=this.device.productId)>=64&&n<=130)){e.next=21;break}if(r=t.get(Zt.RING),o=t.get(Zt.OFF_HOOK),i=t.get(Zt.MUTE),void 0===r){e.next=11;break}return this.setState(Zt.RING,r),e.next=11,this.device.sendReport(6,new Uint8Array([r?1:0,0]));case 11:if(void 0===o){e.next=15;break}return this.setState(Zt.OFF_HOOK,o),e.next=15,this.device.sendReport(6,new Uint8Array([o?2:0,0]));case 15:if(void 0===i){e.next=19;break}return this.setState(Zt.MUTE,i),e.next=19,this.device.sendReport(6,new Uint8Array([i?4:5,0]));case 19:e.next=58;break;case 21:a=[],c=on(t),e.prev=23,u=un().mark((function e(){var t,n,r,o,i;return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ln(s.value,2),n=t[0],r=t[1],void 0!==(o=g.outputEventInfos[n])){e.next=4;break}return e.abrupt("return",1);case 4:i=a.find((function(e){return e.reportId===(null==o?void 0:o.reportId)})),void 0===i&&a.push(null==o?void 0:o.generator()),o.state=r;case 7:case"end":return e.stop()}}),e)})),c.s();case 26:if((s=c.n()).done){e.next=32;break}return e.delegateYield(u(),"t0",28);case 28:if(!e.t0){e.next=30;break}return e.abrupt("continue",30);case 30:e.next=26;break;case 32:e.next=37;break;case 34:e.prev=34,e.t1=e.catch(23),c.e(e.t1);case 37:return e.prev=37,c.f(),e.finish(37);case 40:l=0,f=a;case 41:if(!(l<f.length)){e.next=58;break}h=f[l],d=0,v=bn;case 44:if(!(d<v.length)){e.next=53;break}if(p=v[d],void 0!==(y=this.outputEventInfos[p])&&y.reportId===h.reportId&&y.state){e.next=49;break}return e.abrupt("continue",50);case 49:h.data=y.setter(y.state,h.data);case 50:d++,e.next=44;break;case 53:return e.next=55,this.device.sendReport(h.reportId,h.data);case 55:l++,e.next=41;break;case 58:case"end":return e.stop()}}),e,this,[[23,34,37,40]])}))),function(e){return i.apply(this,arguments)})}],r=[{key:"create",value:(o=nn(un().mark((function t(n){return un().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.opened){t.next=3;break}return t.next=3,n.open();case 3:return t.abrupt("return",new e(n));case 4:case"end":return t.stop()}}),t)}))),function(e){return o.apply(this,arguments)})}],n&&rn(t.prototype,n),r&&rn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,o,i,a}(),Cn=function(e){if(!e.supportInput($t.HOOK_SWITCH))throw new Error("Device is missing hook switch support");if(!e.supportInput($t.PHONE_MUTE))throw new Error("Device is missing mute switch support")},kn=function(e){if(!e.supportOutput(Zt.RING))throw new Error("Device is missing ring support");if(!e.supportOutput(Zt.OFF_HOOK))throw new Error("Device is missing off/on hook support");if(!e.supportOutput(Zt.MUTE))throw new Error("Device is missing mute support")};function En(e){return In.apply(this,arguments)}function In(){return(In=nn(un().mark((function e(t){var n;return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wn.create(t);case 2:return n=e.sent,kn(n),Cn(n),e.abrupt("return",{productName:n.device.productName,ring:function(){return n.send(new Map([[Zt.RING,!0]]))},onHook:function(){return n.send(new Map([[Zt.OFF_HOOK,!1],[Zt.RING,!1],[Zt.MUTE,!1]]))},offHook:function(){return n.send(new Map([[Zt.OFF_HOOK,!0],[Zt.RING,!1],[Zt.MUTE,!1]]))},muteOn:function(){return n.send(new Map([[Zt.OFF_HOOK,!0],[Zt.RING,!1],[Zt.MUTE,!0]]))},muteOff:function(){return n.send(new Map([[Zt.OFF_HOOK,!0],[Zt.RING,!1],[Zt.MUTE,!1]]))},subscribe:function(e){n.subscribe($t.HOOK_SWITCH,(function(t,r){if(r===Qt.ToggleButton&&t){if(n.getState(Zt.RING))return void e(yn.ACCEPT_CALL);if(n.getState(Zt.OFF_HOOK))return void e(yn.END_CALL)}if(r===Qt.ToggleSwitch){if(t&&n.getState(Zt.RING))return void e(yn.ACCEPT_CALL);if(!t&&n.getState(Zt.OFF_HOOK))return void e(yn.END_CALL)}})),n.subscribe($t.PHONE_MUTE,(function(t,r){if(r===Qt.ToggleButton&&t)e(n.getState(Zt.MUTE)?yn.UNMUTE_CALL:yn.MUTE_CALL);else if(r===Qt.ToggleSwitch){if(t&&!n.getState(Zt.MUTE))return void e(yn.MUTE_CALL);if(!t&&n.getState(Zt.MUTE))return void e(yn.UNMUTE_CALL)}})),n.subscribe($t.PROGRAMMABLE_BUTTON,(function(t,n){t&&e(yn.REJECT_CALL)}))},unsubscribe:function(){n.unsubscribe($t.HOOK_SWITCH),n.unsubscribe($t.PHONE_MUTE),n.unsubscribe($t.PROGRAMMABLE_BUTTON)}});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Sn(e){return xn.apply(this,arguments)}function xn(){return(xn=nn(un().mark((function e(t){var n,r,o,i;return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.getDevices();case 2:n=e.sent,r=on(n),e.prev=4,r.s();case 6:if((o=r.n()).done){e.next=14;break}if(i=o.value,!t.toLowerCase().includes(i.productName.toLowerCase())){e.next=12;break}return e.next=11,En(i);case 11:return e.abrupt("return",e.sent);case 12:e.next=6;break;case 14:e.next=19;break;case 16:e.prev=16,e.t0=e.catch(4),r.e(e.t0);case 19:return e.prev=19,r.f(),e.finish(19);case 22:case"end":return e.stop()}}),e,null,[[4,16,19,22]])})))).apply(this,arguments)}function On(e){return _n.apply(this,arguments)}function _n(){return(_n=nn(un().mark((function e(t){var n;return un().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,window.navigator.hid.requestDevice({filters:[sn({vendorId:13323,productId:t.productId},gn)]});case 2:if(0!==(n=e.sent).length){e.next=5;break}throw new Error("No requested device found");case 5:return e.next=7,En(n[0]);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ln(e){return Ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ln(e)}function jn(){jn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==Ln(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(Ln(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function Pn(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function Tn(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Pn(i,r,o,a,c,"next",e)}function c(e){Pn(i,r,o,a,c,"throw",e)}a(void 0)}))}}function Rn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Nn(r.key),r)}}function An(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(An=function(){return!!e})()}function Dn(e){return Dn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Dn(e)}function Hn(e,t){return Hn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Hn(e,t)}function Mn(e,t,n){return(t=Nn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nn(e){var t=function(e){if("object"!=Ln(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Ln(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ln(t)?t:t+""}!function(e){e[e.ACCEPT_CALL=0]="ACCEPT_CALL",e[e.END_CALL=1]="END_CALL",e[e.REJECT_CALL=2]="REJECT_CALL",e[e.MUTE_CALL=3]="MUTE_CALL",e[e.UNMUTE_CALL=4]="UNMUTE_CALL"}(yn||(yn={}));var Fn=function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return Mn(e=function(e,t,n){return t=Dn(t),function(e,t){if(t&&("object"===Ln(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,An()?Reflect.construct(t,n||[],Dn(e).constructor):t.apply(e,n))}(this,t,[].concat(r)),"activeConversationId",void 0),Mn(e,"pendingConversationId",void 0),Mn(e,"_deviceInfo",null),Mn(e,"activeDevice",null),Mn(e,"vendorName","VBet"),Mn(e,"processBtnPress",(function(t){switch(t){case yn.ACCEPT_CALL:e.pendingConversationId?(e.answerCall(e.pendingConversationId),e.deviceAnsweredCall({name:"OffHook",conversationId:e.activeConversationId})):e.logger.error("No call to be answered");break;case yn.END_CALL:if(e.activeConversationId){var n=e.activeConversationId;e.endCall(n),e.deviceEndedCall({name:"OnHook",conversationId:n})}else e.logger.error("No call to be terminated");break;case yn.MUTE_CALL:case yn.UNMUTE_CALL:e.activeConversationId?(e.setMute(t===yn.MUTE_CALL),e.deviceMuteChanged({isMuted:e.isMuted,name:e.isMuted?"CallMuted":"CallUnmuted",conversationId:e.activeConversationId})):e.logger.error("No call to be muted");break;case yn.REJECT_CALL:e.pendingConversationId?(e.rejectCall(e.pendingConversationId),e.deviceRejectedCall({name:"Reject",conversationId:e.pendingConversationId})):e.logger.error("No call to be rejected")}})),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Hn(e,t)}(t,e),n=t,r=[{key:"deviceInfo",get:function(){return this._deviceInfo}},{key:"isSupported",value:function(){return window.navigator.hid&&!K()}},{key:"deviceLabelMatchesVendor",value:function(e){var t=e.toLowerCase();return["vt","340b"].some((function(e){return t.includes(e)}))}},{key:"connect",value:(d=Tn(jn().mark((function e(t){var n,r,o=this;return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.isConnecting||this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!0}),e.prev=1,e.next=4,Sn(t);case 4:if(!(n=e.sent)){e.next=9;break}this.activeDevice=n,e.next=13;break;case 9:return e.next=11,new Promise((function(e,n){var r=o.deductProductId(t),i=setTimeout((function(){return n("The selected device was not granted WebHID permissions")}),3e4);o.requestWebHidPermissions((function(){On({productId:r||void 0}).then((function(t){e(t),clearTimeout(i)})).catch((function(e){n(e)}))}))}));case 11:r=e.sent,this.activeDevice=r;case 13:e.next=20;break;case 15:return e.prev=15,e.t0=e.catch(1),this.isConnecting&&this.changeConnectionStatus({isConnected:this.isConnected,isConnecting:!1}),this.logger.error(e.t0),e.abrupt("return");case 20:this._deviceInfo={ProductName:this.activeDevice.productName},this.activeDevice.subscribe(this.processBtnPress),this.changeConnectionStatus({isConnected:!0,isConnecting:!1});case 23:case"end":return e.stop()}}),e,this,[[1,15]])}))),function(e){return d.apply(this,arguments)})},{key:"disconnect",value:(h=Tn(jn().mark((function e(){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.changeConnectionStatus({isConnected:!1,isConnecting:!1}),this.activeDevice&&this.activeDevice.unsubscribe(),this.activeDevice=null,this._deviceInfo=null,this.isMuted=!1;case 5:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Tn(jn().mark((function e(t){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId=t.conversationId,this.activeDevice.ring();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Tn(jn().mark((function e(t){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId=t.conversationId,this.activeDevice.offHook();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Tn(jn().mark((function e(t,n){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.pendingConversationId===t||n?(this.activeConversationId=t,this.pendingConversationId="",this.activeDevice.offHook()):this.logger.error("no call to be answered");case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(s=Tn(jn().mark((function e(t){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.pendingConversationId?(this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be rejected");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"endCall",value:(c=Tn(jn().mark((function e(t){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t===this.activeConversationId?(this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook()):this.logger.error("no call to be ended");case 1:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"endAllCalls",value:(a=Tn(jn().mark((function e(){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.activeConversationId="",this.pendingConversationId="",this.activeDevice.onHook();case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setMute",value:(i=Tn(jn().mark((function e(t){return jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.isMuted=t,this.isMuted?this.activeDevice.muteOn():this.activeDevice.muteOff();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}],o=[{key:"getInstance",value:function(e){return t.instance||(t.instance=new t(e)),t.instance}}],r&&Rn(n.prototype,r),o&&Rn(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a,c,s,u,l,f,h,d}(V.Z);Mn(Fn,"instance",void 0);var Un=n(308);function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}function qn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qn(Object(n),!0).forEach((function(t){zn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jn(){Jn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new j(r||[]);return o(a,"_invoke",{value:x(e,n,c)}),a}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",v="executing",p="completed",y={};function g(){}function m(){}function b(){}var w={};u(w,a,(function(){return this}));var C=Object.getPrototypeOf,k=C&&C(C(P([])));k&&k!==n&&r.call(k,a)&&(w=k);var E=b.prototype=g.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==Gn(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,n,r){var o=h;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===p){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=O(c,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=f(t,n,r);if("normal"===u.type){if(o=r.done?p:d,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=p,r.method="throw",r.arg=u.arg)}}}function O(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,O(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var i=f(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,y;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function P(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(Gn(t)+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=u(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===m||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},I(S.prototype),u(S.prototype,c,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new S(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},I(E),u(E,s,"Generator"),u(E,a,(function(){return this})),u(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=P,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:P(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function Vn(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function Wn(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){Vn(i,r,o,a,c,"next",e)}function c(e){Vn(i,r,o,a,c,"throw",e)}a(void 0)}))}}function Yn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Kn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,$n(r.key),r)}}function zn(e,t,n){return(t=$n(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $n(e){var t=function(e){if("object"!=Gn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Gn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Gn(t)?t:t+""}var Zn=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),zn(this,"plantronics",void 0),zn(this,"jabraNative",void 0),zn(this,"jabra",void 0),zn(this,"sennheiser",void 0),zn(this,"yealink",void 0),zn(this,"vbet",void 0),zn(this,"cyberAcoustics",void 0),zn(this,"selectedImplementation",void 0),zn(this,"headsetEvents$",void 0),zn(this,"headsetConversationStates",{}),zn(this,"_headsetEvents$",void 0),zn(this,"logger",void 0),this._headsetEvents$=new B,this.headsetEvents$=this._headsetEvents$.asObservable(),this.logger=t.logger||console,this.plantronics=Te.getInstance({logger:this.logger,appName:t.appName}),this.jabraNative=Ht.getInstance({logger:this.logger}),this.jabra=Et.getInstance({logger:this.logger}),this.sennheiser=qe.getInstance({logger:this.logger}),this.yealink=Xt.getInstance({logger:this.logger}),this.vbet=Fn.getInstance({logger:this.logger}),this.cyberAcoustics=ye.getInstance({logger:this.logger}),[this.plantronics,this.jabra,this.jabraNative,this.sennheiser,this.yealink,this.vbet,this.cyberAcoustics].forEach((function(e){return n.subscribeToHeadsetEvents(e)}))}return t=e,n=[{key:"implementations",get:function(){return[this.sennheiser,this.plantronics,this.jabra,this.jabraNative,this.yealink,this.vbet,this.cyberAcoustics].filter((function(e){return e.isSupported()}))}},{key:"isDifferentState",value:function(e){var t=this.headsetConversationStates[e.conversationId];return!t||Object.entries(e.state).some((function(e){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],s=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){u=!0,o=e}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Yn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yn(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),r=n[0],o=n[1];return t[r]!==o}))}},{key:"updateHeadsetState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{expectExistingConversation:!0};if(this.isDifferentState(e)){var n=this.headsetConversationStates[e.conversationId];return n?(Object.assign(n,e.state),!0):(t.expectExistingConversation&&this.logger.warn("updateHeadsetState has no existing state for provided conversationId.",{conversationId:e.conversationId}),!1)}return!1}},{key:"deviceIsSupported",value:function(e){return!!e.micLabel&&!!this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e.micLabel)}))}},{key:"activeMicChange",value:function(e,t){if(e){var n=this.implementations.find((function(t){return t.deviceLabelMatchesVendor(e)}));n?this.changeImplementation(n,e):this.selectedImplementation&&this.clearSelectedImplementation(t)}else this.clearSelectedImplementation(t)}},{key:"changeImplementation",value:(h=Wn(Jn().mark((function e(t,n){return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t!==this.selectedImplementation){e.next=2;break}return e.abrupt("return");case 2:if(!this.selectedImplementation){e.next=6;break}return this.headsetConversationStates={},e.next=6,this.selectedImplementation.disconnect();case 6:if(this.selectedImplementation=t,this._headsetEvents$.next({event:Un.S.implementationChanged,payload:t}),!t){e.next=11;break}return e.next=11,t.connect(n);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"incomingCall",value:(f=Wn(Jn().mark((function e(t,n){var r;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!1,ringing:!0},e.abrupt("return",r.incomingCall(t,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"outgoingCall",value:(l=Wn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return this.headsetConversationStates[t.conversationId]={conversationId:t.conversationId,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",n.outgoingCall(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"answerCall",value:(u=Wn(Jn().mark((function e(t,n){var r,o;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(n){e.next=9;break}if(o={ringing:!1,offHook:!0},!this.updateHeadsetState({conversationId:t,state:o})){e.next=7;break}return e.abrupt("return",r.answerCall(t));case 7:e.next=11;break;case 9:return this.headsetConversationStates[t]={conversationId:t,held:!1,muted:!1,offHook:!0,ringing:!1},e.abrupt("return",r.answerCall(t,n));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"rejectCall",value:(s=Wn(Jn().mark((function e(t){var n,r,o,i=arguments;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(i.length>1&&void 0!==i[1])||i[1],r=this.getConnectedImpl()){e.next=4;break}return e.abrupt("return");case 4:if(o={ringing:!1},!this.updateHeadsetState({conversationId:t,state:o},{expectExistingConversation:n})){e.next=9;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.rejectCall(t));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"setMute",value:(c=Wn(Jn().mark((function e(t){var n;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(!Object.values(this.headsetConversationStates).some((function(e){return e.muted!==t}))){e.next=6;break}return Object.values(this.headsetConversationStates).forEach((function(e){return e.muted=t})),e.abrupt("return",n.setMute(t));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setHold",value:(a=Wn(Jn().mark((function e(t,n){var r,o;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(o={held:n},!this.updateHeadsetState({conversationId:t,state:o})){e.next=6;break}return e.abrupt("return",r.setHold(t,n));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"endCall",value:(i=Wn(Jn().mark((function e(t,n){var r,o;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:if(o={offHook:!1},!this.updateHeadsetState({conversationId:t,state:o})){e.next=8;break}return this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t),e.abrupt("return",r.endCall(t,n));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"endAllCalls",value:(o=Wn(Jn().mark((function e(){var t,n=this;return Jn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.getConnectedImpl()){e.next=3;break}return e.abrupt("return");case 3:return Object.values(this.headsetConversationStates).forEach((function(e){e.removeTimer||(e.removeTimer=n.setRemoveTimer(e.conversationId))})),e.abrupt("return",t.endAllCalls());case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"retryConnection",value:function(e){return this.selectedImplementation?this.selectedImplementation.connect(e):Promise.reject(new Error("No active headset implementation"))}},{key:"connectionStatus",value:function(){return this.selectedImplementation?this.selectedImplementation.isConnected||this.selectedImplementation.isConnecting?this.selectedImplementation.isConnected?"running":"checking":"notRunning":"noVendor"}},{key:"resetHeadsetStateForCall",value:function(e){var t=this.getConnectedImpl();if(t)return t.resetHeadsetStateForCall(e);this.logger.info("No active implementation, headset state does not require a reset")}},{key:"getConnectedImpl",value:function(){var e=this.selectedImplementation;return e&&e.isConnected?e:null}},{key:"subscribeToHeadsetEvents",value:function(e){e.on(Un.S.deviceAnsweredCall,this.handleDeviceAnsweredCall.bind(this)),e.on(Un.S.deviceRejectedCall,this.handleDeviceRejectedCall.bind(this)),e.on(Un.S.deviceEndedCall,this.handleDeviceEndedCall.bind(this)),e.on(Un.S.deviceMuteStatusChanged,this.handleDeviceMuteStatusChanged.bind(this)),e.on(Un.S.deviceHoldStatusChanged,this.handleDeviceHoldStatusChanged.bind(this)),e.on(Un.S.deviceEventLogs,this.handleDeviceLogs.bind(this)),e.on(Un.S.deviceConnectionStatusChanged,this.handleDeviceConnectionStatusChanged.bind(this)),e.on(Un.S.webHidPermissionRequested,this.handleWebHidPermissionRequested.bind(this))}},{key:"clearSelectedImplementation",value:function(e){this.selectedImplementation&&(this.selectedImplementation.disconnect(e),this._headsetEvents$.next({event:Un.S.implementationChanged,payload:null}),this.selectedImplementation=null,this.handleDeviceConnectionStatusChanged())}},{key:"setRemoveTimer",value:function(e){var t=this;return setTimeout((function(){t.headsetConversationStates[e].removeTimer&&delete t.headsetConversationStates[e]}),2e3)}},{key:"handleDeviceAnsweredCall",value:function(e){e.vendor===this.selectedImplementation&&(this.updateHeadsetState({conversationId:e.body.conversationId,state:{ringing:!1,offHook:!0}}),this.logger.info("Headset: device answered the call"),this._headsetEvents$.next({event:Un.S.deviceAnsweredCall,payload:Bn({},e.body)}))}},{key:"handleDeviceRejectedCall",value:function(e){if(e.vendor===this.selectedImplementation){var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{ringing:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this.logger.info("Headset: device rejected the call"),this._headsetEvents$.next({event:Un.S.deviceRejectedCall,payload:Bn({},e.body)})}}},{key:"handleDeviceEndedCall",value:function(e){this.logger.info("Headset: device ended the call");var t=e.body.conversationId;this.updateHeadsetState({conversationId:t,state:{offHook:!1}})&&(this.headsetConversationStates[t].removeTimer=this.setRemoveTimer(t)),this._headsetEvents$.next({event:Un.S.deviceEndedCall,payload:Bn({},e.body)})}},{key:"handleDeviceMuteStatusChanged",value:function(e){this.logger.info("Headset: device mute status changed: ",e.body.isMuted),Object.values(this.headsetConversationStates).some((function(t){return t.muted!==e.body.isMuted}))&&Object.values(this.headsetConversationStates).forEach((function(t){return t.muted=e.body.isMuted})),this._headsetEvents$.next({event:Un.S.deviceMuteStatusChanged,payload:Bn({},e.body)})}},{key:"handleDeviceHoldStatusChanged",value:function(e){this.logger.info("Headset: device hold status changed",e.body.holdRequested);var t={held:e.body.holdRequested},n=e.body.conversationId;this.updateHeadsetState({conversationId:n,state:t}),this._headsetEvents$.next({event:Un.S.deviceHoldStatusChanged,payload:Bn({},e.body)})}},{key:"handleDeviceConnectionStatusChanged",value:function(){this._headsetEvents$.next({event:Un.S.deviceConnectionStatusChanged,payload:this.connectionStatus()})}},{key:"handleWebHidPermissionRequested",value:function(e){this.logger.debug("Requesting Webhid Permissions"),this._headsetEvents$.next({event:Un.S.webHidPermissionRequested,payload:Bn({},e.body)})}},{key:"handleDeviceLogs",value:function(e){this._headsetEvents$.next({event:Un.S.loggableEvent,payload:Bn({},e.body)})}}],r=[{key:"getInstance",value:function(t){return e.instance&&!t.createNew||(e.instance=new e(t)),e.instance}}],n&&Kn(t.prototype,n),r&&Kn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,r,o,i,a,c,s,u,l,f,h}();zn(Zn,"instance",void 0)},458:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(841);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,h(r.key),r)}}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(s=function(){return!!e})()}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function f(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}var d=function(e){function t(e){var n,i,a,c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),f((i=this,a=u(a=t),n=function(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(i,s()?Reflect.construct(a,c||[],u(i).constructor):a.apply(i,c))),"vendorName","Not Specified"),f(n,"isConnecting",!1),f(n,"isConnected",!1),f(n,"isMuted",!1),f(n,"errorCode",null),f(n,"disableRetry",!1),f(n,"logger",void 0),f(n,"config",void 0);var l=new r.EventEmitter;return Object.keys(l.__proto__).forEach((function(e){n[e]=l[e]})),n.config=e,n.vendorName=e.vendorName,n.logger=e.logger,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(t,e),n=t,(i=[{key:"isDeviceAttached",get:function(){throw new Error("".concat(this.vendorName," - isDeviceAttatched getter not implemented"))}},{key:"isSupported",value:function(){return!0}},{key:"deviceLabelMatchesVendor",value:function(e){throw new Error("".concat(this.vendorName," - deviceLabelMatchesVendor() not implemented"))}},{key:"connect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - connect() not implemented")))}},{key:"disconnect",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - disconnect() not implemented")))}},{key:"incomingCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - incomingCall() not implemented")))}},{key:"outgoingCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - outgoingCall() not implemented")))}},{key:"answerCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - answerCall() not implemented")))}},{key:"rejectCall",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - rejectCall() not implemented")))}},{key:"endCall",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - endCall() not implemented")))}},{key:"endAllCalls",value:function(){return Promise.reject(new Error("".concat(this.vendorName," - endAllCalls() not implemented")))}},{key:"setMute",value:function(e){return Promise.reject(new Error("".concat(this.vendorName," - setMute() not implemented")))}},{key:"setHold",value:function(e,t){return Promise.reject(new Error("".concat(this.vendorName," - setHold() not implemented")))}},{key:"resetHeadsetStateForCall",value:function(e){return this.rejectCall(e)}},{key:"emitEvent",value:function(e,t){this.emit(e,{vendor:this,body:a({},t)})}},{key:"requestWebHidPermissions",value:function(e){this.logger.debug("Emitting premission request event"),this.emitEvent("webHidPermissionRequested",{callback:e})}},{key:"deviceAnsweredCall",value:function(e){this.emitEvent("deviceAnsweredCall",e)}},{key:"deviceRejectedCall",value:function(e){this.emitEvent("deviceRejectedCall",e)}},{key:"deviceEndedCall",value:function(e){this.emitEvent("deviceEndedCall",e)}},{key:"deviceMuteChanged",value:function(e){this.emitEvent("deviceMuteStatusChanged",a({},e))}},{key:"deviceHoldStatusChanged",value:function(e){this.emitEvent("deviceHoldStatusChanged",a({},e))}},{key:"deviceEventLogs",value:function(e){this.emitEvent("deviceEventLogs",e)}},{key:"changeConnectionStatus",value:function(e){this.isConnected=e.isConnected,this.isConnecting=e.isConnecting,this.emitEvent("deviceConnectionStatusChanged",a({currentVendor:this},e))}},{key:"deductProductId",value:function(e){var t=null==e?void 0:e.match(/\((\w+):(\w+)\)$/);return t?parseInt(t[2],16):null}}])&&c(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i}(r.EventEmitter)},478:()=>{},308:(e,t,n)=>{"use strict";n.d(t,{S:()=>r});var r=function(e){return e.implementationChanged="implementationChanged",e.deviceHoldStatusChanged="deviceHoldStatusChanged",e.deviceMuteStatusChanged="deviceMuteStatusChanged",e.deviceAnsweredCall="deviceAnsweredCall",e.deviceEndedCall="deviceEndedCall",e.deviceRejectedCall="deviceRejectedCall",e.loggableEvent="loggableEvent",e.webHidPermissionRequested="webHidPermissionRequested",e.deviceConnectionStatusChanged="deviceConnectionStatusChanged",e.deviceEventLogs="deviceEventLogs",e}({})},16:()=>{},90:()=>{},290:function(e){e.exports=function(){"use strict";var e="undefined"==typeof window,t=!1,n=!1,r=!1,o=!1,i=!1,a=!1,c=!1,s=!1,u=!1,l=!1;return e||(t="undefined"!=typeof InstallTrigger,n=!!window.chrome,r=!!window.chrome,o=n&&!window.chrome.webstore&&!window.chrome.runtime,i=0<Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")||window.safari&&window.safari.pushNotification,a=!!window.opr&&!!window.opr.addons||!!window.opera,c=!!window.StyleMedia,s=n&&!!navigator.userAgent.match(/edg/i),u=(r||a)&&!!window.CSS,l=!(n||i||t||a||!document.documentMode)),{get isChrome(){return r},get isChromeOrChromium(){return n},get isChromium(){return o},get isFirefox(){return t},get isSafari(){return i},get isOpera(){return a},get isEdge(){return c},get isEdgeChromium(){return s},get isIE(){return l},get isBlink(){return u}}}()},841:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}p(e,t,i,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){var o,i,a,u;if(c(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),a=i[t]),void 0===a)a=i[t]=n,++e._eventsCount;else if("function"==typeof a?a=i[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=s(e))>0&&a.length>o&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=l.bind(r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):v(o,o.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function v(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function p(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)r(s,this,t);else{var u=s.length,l=v(s,u);for(n=0;n<u;++n)r(l[n],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return c(t),this.on(e,f(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return c(t),this.prependListener(e,f(this,e,t)),this},i.prototype.removeListener=function(e,t){var n,r,o,i,a;if(c(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,a||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},606:function(e,t){var n,r;n=function(e,t){"use strict";var n=5e3,r="callback";function o(e){try{delete window[e]}catch(t){window[e]=void 0}}function i(e){var t=document.getElementById(e);t&&document.getElementsByTagName("head")[0].removeChild(t)}t.exports=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],a=e,c=t.timeout||n,s=t.jsonpCallback||r,u=void 0;return new Promise((function(n,r){var l=t.jsonpCallbackFunction||"jsonp_"+Date.now()+"_"+Math.ceil(1e5*Math.random()),f=s+"_"+l;window[l]=function(e){n({ok:!0,json:function(){return Promise.resolve(e)}}),u&&clearTimeout(u),i(f),o(l)},a+=-1===a.indexOf("?")?"?":"&";var h=document.createElement("script");h.setAttribute("src",""+a+s+"="+l),t.charset&&h.setAttribute("charset",t.charset),t.nonce&&h.setAttribute("nonce",t.nonce),t.referrerPolicy&&h.setAttribute("referrerPolicy",t.referrerPolicy),t.crossorigin&&h.setAttribute("crossorigin","true"),h.id=f,document.getElementsByTagName("head")[0].appendChild(h),u=setTimeout((function(){r(new Error("JSONP request to "+e+" timed out")),o(l),i(f),window[l]=function(){o(l)}}),c),h.onerror=function(){r(new Error("JSONP request to "+e+" failed")),o(l),i(f),u&&clearTimeout(u)}}))}},void 0===(r=n.apply(t,[t,e]))||(e.exports=r)},690:t=>{"use strict";t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var i=n[e]={exports:{}};return t[e].call(i.exports,i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";r.r(o),r.d(o,{HeadsetEvents:()=>a.S,VendorImplementation:()=>t.Z,default:()=>u});var e=r(419),t=r(458),n=r(478),i={};for(const e in n)["default","VendorImplementation"].indexOf(e)<0&&(i[e]=()=>n[e]);r.d(o,i);var a=r(308),c=r(16);i={};for(const e in c)["default","VendorImplementation","HeadsetEvents"].indexOf(e)<0&&(i[e]=()=>c[e]);r.d(o,i);var s=r(90);i={};for(const e in s)["default","VendorImplementation","HeadsetEvents"].indexOf(e)<0&&(i[e]=()=>s[e]);r.d(o,i);const u=e.A})(),o})()));
3
+ //# sourceMappingURL=softhphone-vendor-headsets.min.js.map
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */