(function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(t){return e[t]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)})([function(e,t,r){window.SpeechSDK=r(1)},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),o=r(4);o.Events.instance.attachListener(new i.ConsoleLoggingListener),n(r(30))},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(3)),n(r(23)),n(r(155)),n(r(156)),n(r(157)),n(r(158)),n(r(168)),n(r(169)),n(r(170))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=function(){function e(e){var t=this;void 0===e&&(e=n.EventType.Warning),this.onEvent=function(e){if(e.eventType>=t.privLogLevelFilter){var r=t.toString(e);switch(e.eventType){case n.EventType.Debug:console.debug(r);break;case n.EventType.Info:console.info(r);break;case n.EventType.Warning:console.warn(r);break;case n.EventType.Error:console.error(r);break;default:console.log(r)}}},this.toString=function(e){var t=[""+e.EventTime,""+e.Name];for(var r in e)if(r&&e.hasOwnProperty(r)&&"eventTime"!==r&&"eventType"!==r&&"eventId"!==r&&"name"!==r&&"constructor"!==r){var n=e[r],i="";null!=n&&(i="number"==typeof n||"string"==typeof n?n.toString():JSON.stringify(n)),t.push(r+": "+i)}return t.join(" | ")},this.privLogLevelFilter=e}return e}();t.ConsoleLoggingListener=i},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(5)),n(r(8)),n(r(9)),n(r(11)),n(r(10)),n(r(12)),n(r(13)),n(r(7)),n(r(14)),n(r(15)),n(r(6)),n(r(16)),n(r(17)),n(r(18)),n(r(19)),n(r(20));var i=r(21);t.TranslationStatus=i.TranslationStatus,n(r(22))},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(6),s=function(e){function t(t,r,n){void 0===n&&(n=o.EventType.Info);var i=e.call(this,t,n)||this;return i.privAudioSourceId=r,i}return i(t,e),Object.defineProperty(t.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),t}(o.PlatformEvent);t.AudioSourceEvent=s;var a=function(e){function t(t){return e.call(this,"AudioSourceInitializingEvent",t)||this}return i(t,e),t}(s);t.AudioSourceInitializingEvent=a;var c=function(e){function t(t){return e.call(this,"AudioSourceReadyEvent",t)||this}return i(t,e),t}(s);t.AudioSourceReadyEvent=c;var p=function(e){function t(t){return e.call(this,"AudioSourceOffEvent",t)||this}return i(t,e),t}(s);t.AudioSourceOffEvent=p;var u=function(e){function t(t,r){var n=e.call(this,"AudioSourceErrorEvent",t,o.EventType.Error)||this;return n.privError=r,n}return i(t,e),Object.defineProperty(t.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),t}(s);t.AudioSourceErrorEvent=u;var v=function(e){function t(t,r,n){var i=e.call(this,t,r)||this;return i.privAudioNodeId=n,i}return i(t,e),Object.defineProperty(t.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),t}(s);t.AudioStreamNodeEvent=v;var f=function(e){function t(t,r){return e.call(this,"AudioStreamNodeAttachingEvent",t,r)||this}return i(t,e),t}(v);t.AudioStreamNodeAttachingEvent=f;var h=function(e){function t(t,r){return e.call(this,"AudioStreamNodeAttachedEvent",t,r)||this}return i(t,e),t}(v);t.AudioStreamNodeAttachedEvent=h;var l=function(e){function t(t,r){return e.call(this,"AudioStreamNodeDetachedEvent",t,r)||this}return i(t,e),t}(v);t.AudioStreamNodeDetachedEvent=l;var d=function(e){function t(t,r,n){var i=e.call(this,"AudioStreamNodeErrorEvent",t,r)||this;return i.privError=n,i}return i(t,e),Object.defineProperty(t.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),t}(v);t.AudioStreamNodeErrorEvent=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(7);(function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warning=2]="Warning",e[e.Error=3]="Error"})(t.EventType||(t.EventType={}));var i=function(){function e(e,t){this.privName=e,this.privEventId=n.createNoDashGuid(),this.privEventTime=(new Date).toISOString(),this.privEventType=t,this.privMetadata={}}return Object.defineProperty(e.prototype,"name",{get:function(){return this.privName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventId",{get:function(){return this.privEventId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventTime",{get:function(){return this.privEventTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventType",{get:function(){return this.privEventType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"metadata",{get:function(){return this.privMetadata},enumerable:!0,configurable:!0}),e}();t.PlatformEvent=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){var e=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)});return t};t.createGuid=n;var i=function(){return n().replace(new RegExp("-","g"),"").toUpperCase()};t.createNoDashGuid=i},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(6),s=function(e){function t(t,r,n){void 0===n&&(n=o.EventType.Info);var i=e.call(this,t,n)||this;return i.privJsonResult=r,i}return i(t,e),Object.defineProperty(t.prototype,"jsonString",{get:function(){return this.privJsonResult},enumerable:!0,configurable:!0}),t}(o.PlatformEvent);t.ServiceEvent=s;var a=function(e){function t(t,r,n){void 0===n&&(n=o.EventType.Info);var i=e.call(this,t,n)||this;return i.privConnectionId=r,i}return i(t,e),Object.defineProperty(t.prototype,"connectionId",{get:function(){return this.privConnectionId},enumerable:!0,configurable:!0}),t}(o.PlatformEvent);t.ConnectionEvent=a;var c=function(e){function t(t,r,n){var i=e.call(this,"ConnectionStartEvent",t)||this;return i.privUri=r,i.privHeaders=n,i}return i(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this.privUri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"headers",{get:function(){return this.privHeaders},enumerable:!0,configurable:!0}),t}(a);t.ConnectionStartEvent=c;var p=function(e){function t(t,r){return e.call(this,"ConnectionEstablishedEvent",t)||this}return i(t,e),t}(a);t.ConnectionEstablishedEvent=p;var u=function(e){function t(t,r,n){var i=e.call(this,"ConnectionClosedEvent",t,o.EventType.Debug)||this;return i.privRreason=n,i.privStatusCode=r,i}return i(t,e),Object.defineProperty(t.prototype,"reason",{get:function(){return this.privRreason},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),t}(a);t.ConnectionClosedEvent=u;var v=function(e){function t(t,r,n){var i=e.call(this,"ConnectionErrorEvent",t,o.EventType.Debug)||this;return i.privMessage=r,i.privType=n,i}return i(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return this.privMessage},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this.privType},enumerable:!0,configurable:!0}),t}(a);t.ConnectionErrorEvent=v;var f=function(e){function t(t,r,n){var i=e.call(this,"ConnectionEstablishErrorEvent",t,o.EventType.Error)||this;return i.privStatusCode=r,i.privReason=n,i}return i(t,e),Object.defineProperty(t.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),t}(a);t.ConnectionEstablishErrorEvent=f;var h=function(e){function t(t,r,n){var i=e.call(this,"ConnectionMessageReceivedEvent",t)||this;return i.privNetworkReceivedTime=r,i.privMessage=n,i}return i(t,e),Object.defineProperty(t.prototype,"networkReceivedTime",{get:function(){return this.privNetworkReceivedTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"message",{get:function(){return this.privMessage},enumerable:!0,configurable:!0}),t}(a);t.ConnectionMessageReceivedEvent=h;var l=function(e){function t(t,r,n){var i=e.call(this,"ConnectionMessageSentEvent",t)||this;return i.privNetworkSentTime=r,i.privMessage=n,i}return i(t,e),Object.defineProperty(t.prototype,"networkSentTime",{get:function(){return this.privNetworkSentTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"message",{get:function(){return this.privMessage},enumerable:!0,configurable:!0}),t}(a);t.ConnectionMessageSentEvent=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(10),o=r(7);(function(e){e[e.Text=0]="Text",e[e.Binary=1]="Binary"})(n=t.MessageType||(t.MessageType={}));var s=function(){function e(e,t,r,s){if(this.privBody=null,e===n.Text&&t&&"string"!=typeof t)throw new i.InvalidOperationError("Payload must be a string");if(e===n.Binary&&t&&!(t instanceof ArrayBuffer))throw new i.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=s||o.createNoDashGuid(),this.messageType){case n.Binary:this.privSize=null!==this.binaryBody?this.binaryBody.byteLength:0;break;case n.Text:this.privSize=this.textBody.length}}return Object.defineProperty(e.prototype,"messageType",{get:function(){return this.privMessageType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){return this.privHeaders},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textBody",{get:function(){if(this.privMessageType===n.Binary)throw new i.InvalidOperationError("Not supported for binary message");return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryBody",{get:function(){if(this.privMessageType===n.Text)throw new i.InvalidOperationError("Not supported for text message");return this.privBody},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),e}();t.ConnectionMessage=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t)||this;return r.name="ArgumentNull",r.message=t,r}return i(t,e),t}(Error);t.ArgumentNullError=o;var s=function(e){function t(t){var r=e.call(this,t)||this;return r.name="InvalidOperation",r.message=t,r}return i(t,e),t}(Error);t.InvalidOperationError=s;var a=function(e){function t(t,r){var n=e.call(this,r)||this;return n.name=t+"ObjectDisposed",n.message=r,n}return i(t,e),t}(Error);t.ObjectDisposedError=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.privStatusCode=e,this.privReason=t}return Object.defineProperty(e.prototype,"statusCode",{get:function(){return this.privStatusCode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),e}();t.ConnectionOpenResponse=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10),i=r(13),o=function(){function e(){}return Object.defineProperty(e,"instance",{get:function(){return e.privInstance},enumerable:!0,configurable:!0}),e.privInstance=new i.EventSource,e.setEventSource=function(t){if(!t)throw new n.ArgumentNullError("eventSource");e.privInstance=t},e}();t.Events=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10),i=r(7),o=function(){function e(e){var t=this;this.privEventListeners={},this.privIsDisposed=!1,this.onEvent=function(e){if(t.isDisposed())throw new n.ObjectDisposedError("EventSource");if(t.metadata)for(var r in t.metadata)r&&e.metadata&&(e.metadata[r]||(e.metadata[r]=t.metadata[r]));for(var i in t.privEventListeners)i&&t.privEventListeners[i]&&t.privEventListeners[i](e)},this.attach=function(e){var r=i.createNoDashGuid();return t.privEventListeners[r]=e,{detach:function(){delete t.privEventListeners[r]}}},this.attachListener=function(e){return t.attach(e.onEvent)},this.isDisposed=function(){return t.privIsDisposed},this.dispose=function(){t.privEventListeners=null,t.privIsDisposed=!0},this.privMetadata=e}return Object.defineProperty(e.prototype,"metadata",{get:function(){return this.privMetadata},enumerable:!0,configurable:!0}),e}();t.EventSource=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.None=0]="None",e[e.Connected=1]="Connected",e[e.Connecting=2]="Connecting",e[e.Disconnected=3]="Disconnected"}(t.ConnectionState||(t.ConnectionState={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10),i=function(){function e(t){var r=this;if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.get=function(e){return r.throwIfDisposed(),r.privList[e]},this.first=function(){return r.get(0)},this.last=function(){return r.get(r.length()-1)},this.add=function(e){r.throwIfDisposed(),r.insertAt(r.privList.length,e)},this.insertAt=function(e,t){r.throwIfDisposed(),0===e?r.privList.unshift(t):e===r.privList.length?r.privList.push(t):r.privList.splice(e,0,t),r.triggerSubscriptions(r.privAddSubscriptions)},this.removeFirst=function(){return r.throwIfDisposed(),r.removeAt(0)},this.removeLast=function(){return r.throwIfDisposed(),r.removeAt(r.length()-1)},this.removeAt=function(e){return r.throwIfDisposed(),r.remove(e,1)[0]},this.remove=function(e,t){r.throwIfDisposed();var n=r.privList.splice(e,t);return r.triggerSubscriptions(r.privRemoveSubscriptions),n},this.clear=function(){r.throwIfDisposed(),r.remove(0,r.length())},this.length=function(){return r.throwIfDisposed(),r.privList.length},this.onAdded=function(e){r.throwIfDisposed();var t=r.privSubscriptionIdCounter++;return r.privAddSubscriptions[t]=e,{detach:function(){delete r.privAddSubscriptions[t]}}},this.onRemoved=function(e){r.throwIfDisposed();var t=r.privSubscriptionIdCounter++;return r.privRemoveSubscriptions[t]=e,{detach:function(){delete r.privRemoveSubscriptions[t]}}},this.onDisposed=function(e){r.throwIfDisposed();var t=r.privSubscriptionIdCounter++;return r.privDisposedSubscriptions[t]=e,{detach:function(){delete r.privDisposedSubscriptions[t]}}},this.join=function(e){return r.throwIfDisposed(),r.privList.join(e)},this.toArray=function(){var e=Array();return r.privList.forEach(function(t){e.push(t)}),e},this.any=function(e){return r.throwIfDisposed(),e?r.where(e).length()>0:r.length()>0},this.all=function(e){return r.throwIfDisposed(),r.where(e).length()===r.length()},this.forEach=function(e){r.throwIfDisposed();for(var t=0;t0&&t.privPromiseStore.first().result().isCompleted;){var e=t.privPromiseStore.removeFirst();e.result().isError||t.privList.add(e.result().result)}})},this.dequeue=function(){t.throwIfDispose();var e=new s.Deferred;return t.privSubscribers&&(t.privSubscribers.add({deferral:e,type:n.Dequeue}),t.drain()),e.promise()},this.peek=function(){t.throwIfDispose();var e=new s.Deferred,r=t.privSubscribers;return r&&(t.privSubscribers.add({deferral:e,type:n.Peek}),t.drain()),e.promise()},this.length=function(){return t.throwIfDispose(),t.privList.length()},this.isDisposed=function(){return null==t.privSubscribers},this.drainAndDispose=function(e,r){if(!t.isDisposed()&&!t.privIsDisposing){t.privDisposeReason=r,t.privIsDisposing=!0;var n=t.privSubscribers;if(n){for(;n.length()>0;){var i=n.removeFirst();i.deferral.resolve(void 0)}t.privSubscribers===n&&(t.privSubscribers=n)}for(var o=0,a=t.privDetachables;o0&&e)return s.PromiseHelper.whenAll(t.privPromiseStore.toArray()).continueWith(function(){return t.privSubscribers=null,t.privList.forEach(function(t,r){e(t)}),t.privList=null,!0});t.privSubscribers=null,t.privList=null}return s.PromiseHelper.fromResult(!0)},this.dispose=function(e){t.drainAndDispose(null,e)},this.drain=function(){if(!t.privIsDrainInProgress&&!t.privIsDisposing){t.privIsDrainInProgress=!0;var e=t.privSubscribers,r=t.privList;if(e&&r){for(;r.length()>0&&e.length()>0&&!t.privIsDisposing;){var i=e.removeFirst();if(i.type===n.Peek)i.deferral.resolve(r.first());else{var o=r.removeFirst();i.deferral.resolve(o)}}t.privSubscribers===e&&(t.privSubscribers=e),t.privList===r&&(t.privList=r)}t.privIsDrainInProgress=!1}},this.throwIfDispose=function(){if(t.isDisposed()){if(t.privDisposeReason)throw new i.InvalidOperationError(t.privDisposeReason);throw new i.ObjectDisposedError("Queue")}if(t.privIsDisposing)throw new i.InvalidOperationError("Queue disposing")},this.privList=e||new o.List,this.privDetachables=[],this.privSubscribers=new o.List,this.privDetachables.push(this.privList.onAdded(this.drain))}return e}();t.Queue=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(9),i=r(10),o=r(7),s=function(){function e(e,t,r){if(this.privPayload=null,!t)throw new i.ArgumentNullError("payload");if(e===n.MessageType.Binary&&!(t instanceof ArrayBuffer))throw new i.InvalidOperationError("Payload must be ArrayBuffer");if(e===n.MessageType.Text&&"string"!=typeof t)throw new i.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||o.createNoDashGuid()}return Object.defineProperty(e.prototype,"messageType",{get:function(){return this.privMessageType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"payload",{get:function(){return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textContent",{get:function(){if(this.privMessageType===n.MessageType.Binary)throw new i.InvalidOperationError("Not supported for binary message");return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryContent",{get:function(){if(this.privMessageType===n.MessageType.Text)throw new i.InvalidOperationError("Not supported for text message");return this.privPayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),e}();t.RawWebsocketMessage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){var r=this;this.encode=function(e){var t=r.downSampleAudioFrame(e,r.privActualSampleRate,r.privDesiredSampleRate);if(!t)return null;var n=2*t.length,i=new ArrayBuffer(n),o=new DataView(i);return r.floatTo16BitPCM(o,0,t),i},this.setString=function(e,t,r){for(var n=0;nt)return e;for(var n=t/r,i=Math.round(e.length/n),o=new Float32Array(i),s=0,a=0;ae.byteLength)return r.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),o.PromiseHelper.fromResult(e.byteLength);r.set(this.privLastChunkView),n=this.privLastChunkView.length,this.privLastChunkView=void 0}var i=new o.Deferred,s=function(){ne.byteLength-n?(a=o.buffer.slice(0,e.byteLength-n),t.privLastChunkView=new Int8Array(o.buffer.slice(e.byteLength-n))):a=o.buffer,r.set(new Int8Array(a),n),n+=a.byteLength,s()}}):i.resolve(n)};return s(),i.promise()},t.prototype.write=function(e){s.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})},t.prototype.close=function(){this.privStream.close()},t}(p);t.PullAudioOutputStreamImpl=u;var v=function(e){function t(){return e.call(this)||this}return i(t,e),t.create=function(e){return new f(e)},t}(c);t.PushAudioOutputStream=v;var f=function(e){function t(t){var r=e.call(this)||this;return r.privId=o.createNoDashGuid(),r.privCallback=t,r}return i(t,e),Object.defineProperty(t.prototype,"format",{set:function(e){},enumerable:!0,configurable:!0}),t.prototype.write=function(e){this.privCallback.write&&this.privCallback.write(e)},t.prototype.close=function(){this.privCallback.close&&this.privCallback.close()},t.prototype.id=function(){return this.privId},t}(v);t.PushAudioOutputStreamImpl=f},function(e,t,r){"use strict";var n,i,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s,a=r(38),c=r(24);(function(e){e[e.PCM=1]="PCM",e[e.MuLaw=2]="MuLaw",e[e.Siren=3]="Siren",e[e.MP3=4]="MP3",e[e.SILKSkype=5]="SILKSkype"})(s=t.AudioFormatTag||(t.AudioFormatTag={}));var p=function(e){function t(t,r,n,i,o,s,a,c,p){var u=e.call(this,n,s,r)||this;return u.formatTag=t,u.avgBytesPerSec=i,u.blockAlign=o,u.priAudioFormatString=a,u.priRequestAudioFormatString=c,u.priHasHeader=p,u}return o(t,e),t.fromSpeechSynthesisOutputFormat=function(e){return t.fromSpeechSynthesisOutputFormatString(t.SpeechSynthesisOutputFormatToString[e])},t.fromSpeechSynthesisOutputFormatString=function(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new t(s.PCM,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new t(s.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new t(s.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new t(s.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new t(s.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new t(s.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new t(s.MP3,1,16e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new t(s.MP3,1,16e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new t(s.MP3,1,16e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new t(s.SILKSkype,1,16e3,32e3,2,16,e,e,!1) ;case"riff-8khz-16bit-mono-pcm":return new t(s.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new t(s.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new t(s.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new t(s.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new t(s.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new t(s.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"riff-16khz-16bit-mono-pcm":default:return new t(s.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}},t.getDefaultOutputFormat=function(){return t.fromSpeechSynthesisOutputFormatString("")},Object.defineProperty(t.prototype,"hasHeader",{get:function(){return this.priHasHeader},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"header",{get:function(){if(this.hasHeader)return this.privHeader},enumerable:!0,configurable:!0}),t.prototype.updateHeader=function(e){if(this.priHasHeader){var t=new DataView(this.privHeader);t.setUint32(40,e,!0)}},Object.defineProperty(t.prototype,"requestAudioFormatString",{get:function(){return this.priRequestAudioFormatString},enumerable:!0,configurable:!0}),t.SpeechSynthesisOutputFormatToString=(i={},i[a.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]="raw-8khz-8bit-mono-mulaw",i[a.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]="riff-16khz-16kbps-mono-siren",i[a.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]="audio-16khz-16kbps-mono-siren",i[a.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]="audio-16khz-32kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]="audio-16khz-128kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]="audio-16khz-64kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]="audio-24khz-48kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]="audio-24khz-96kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]="audio-24khz-160kbitrate-mono-mp3",i[a.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]="raw-16khz-16bit-mono-truesilk",i[a.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]="riff-16khz-16bit-mono-pcm",i[a.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]="riff-8khz-16bit-mono-pcm",i[a.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]="riff-24khz-16bit-mono-pcm",i[a.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]="riff-8khz-8bit-mono-mulaw",i[a.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]="raw-16khz-16bit-mono-pcm",i[a.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]="raw-24khz-16bit-mono-pcm",i[a.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]="raw-8khz-16bit-mono-pcm",i),t}(c.AudioStreamFormatImpl);t.AudioOutputFormatImpl=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",e[e.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",e[e.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",e[e.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",e[e.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",e[e.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",e[e.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",e[e.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",e[e.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",e[e.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",e[e.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",e[e.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",e[e.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",e[e.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",e[e.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",e[e.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",e[e.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm"}(t.SpeechSynthesisOutputFormat||(t.SpeechSynthesisOutputFormat={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Error=0]="Error",e[e.EndOfStream=1]="EndOfStream"}(t.CancellationReason||(t.CancellationReason={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e}();t.PullAudioInputStreamCallback=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e}();t.PushAudioOutputStreamCallback=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(32),i=function(){function e(){this.privDisposed=!1}return e.fromFile=function(e){throw n.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")},e.fromStream=function(e){throw n.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")},e.prototype.close=function(){this.privDisposed||(this.privDisposed=!0)},e}();t.KeywordRecognitionModel=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privSessionId=e}return Object.defineProperty(e.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),e}();t.SessionEventArgs=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r){var n=e.call(this,r)||this;return n.privOffset=t,n}return i(t,e),Object.defineProperty(t.prototype,"offset",{get:function(){return this.privOffset},enumerable:!0,configurable:!0}),t}(o.SessionEventArgs);t.RecognitionEventArgs=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Simple=0]="Simple",e[e.Detailed=1]="Detailed"}(t.OutputFormat||(t.OutputFormat={}))},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n){var i=e.call(this,r,n)||this;return i.privResult=t,i}return i(t,e),Object.defineProperty(t.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.IntentRecognitionEventArgs=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n,i,o,s,a){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=i,this.privErrorDetails=o,this.privJson=s,this.privProperties=a}return Object.defineProperty(e.prototype,"resultId",{get:function(){return this.privResultId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this.privText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this.privDuration},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"offset",{get:function(){return this.privOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"json",{get:function(){return this.privJson},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e}();t.RecognitionResult=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n,i,o,s,a,c){return e.call(this,t,r,n,i,o,s,a,c)||this}return i(t,e),t}(o.RecognitionResult);t.SpeechRecognitionResult=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n,i,o,s,a,c,p){var u=e.call(this,r,n,i,o,s,a,c,p)||this;return u.privIntentId=t,u}return i(t,e),Object.defineProperty(t.prototype,"intentId",{get:function(){return this.privIntentId},enumerable:!0,configurable:!0}),t}(o.SpeechRecognitionResult);t.IntentRecognitionResult=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(32),s=function(){function e(){}return e.fromEndpoint=function(e){o.Contracts.throwIfNull(e,"uri"),o.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");var t=new a,r=e.host.indexOf(".");if(-1===r)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);var n=e.pathname.lastIndexOf("/")+1;if(-1===n)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),void 0===t.subscriptionKey)throw new Error("Could not determine subscription key from endpoint");return t},e.fromAppId=function(e){o.Contracts.throwIfNullOrWhitespace(e,"appId");var t=new a;return t.appId=e,t},e.fromSubscription=function(e,t,r){o.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),o.Contracts.throwIfNullOrWhitespace(t,"appId"),o.Contracts.throwIfNullOrWhitespace(r,"region");var n=new a;return n.appId=t,n.region=r,n.subscriptionKey=e,n},e}();t.LanguageUnderstandingModel=s;var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(s);t.LanguageUnderstandingModelImpl=a},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n){var i=e.call(this,r,n)||this;return i.privResult=t,i}return i(t,e),Object.defineProperty(t.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.SpeechRecognitionEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n,i,o){var s=e.call(this,i,o)||this;return s.privReason=t,s.privErrorDetails=r,s.privErrorCode=n,s}return i(t,e),Object.defineProperty(t.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.SpeechRecognitionCanceledEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n){var i=e.call(this,r,n)||this;return i.privResult=t,i}return i(t,e),Object.defineProperty(t.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.TranslationRecognitionEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r){var n=e.call(this,r)||this;return n.privResult=t,n}return i(t,e),Object.defineProperty(t.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),t}(o.SessionEventArgs);t.TranslationSynthesisEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n,i,o,s,a,c,p){var u=e.call(this,r,n,i,o,s,a,c,p)||this;return u.privTranslations=t,u}return i(t,e),Object.defineProperty(t.prototype,"translations",{get:function(){return this.privTranslations},enumerable:!0,configurable:!0}),t}(o.SpeechRecognitionResult);t.TranslationRecognitionResult=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){this.privReason=e,this.privAudio=t}return Object.defineProperty(e.prototype,"audio",{get:function(){return this.privAudio},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),e}();t.TranslationSynthesisResult=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.NoMatch=0]="NoMatch",e[e.Canceled=1]="Canceled",e[e.RecognizingSpeech=2]="RecognizingSpeech",e[e.RecognizedSpeech=3]="RecognizedSpeech",e[e.RecognizingIntent=4]="RecognizingIntent",e[e.RecognizedIntent=5]="RecognizedIntent",e[e.TranslatingSpeech=6]="TranslatingSpeech",e[e.TranslatedSpeech=7]="TranslatedSpeech",e[e.SynthesizingAudio=8]="SynthesizingAudio",e[e.SynthesizingAudioCompleted=9]="SynthesizingAudioCompleted",e[e.SynthesizingAudioStarted=10]="SynthesizingAudioStarted"}(t.ResultReason||(t.ResultReason={}))},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(25),s=r(32),a=r(30),c=function(){function e(){}return e.fromSubscription=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new p;return r.setProperty(a.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(a.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(a.PropertyId.SpeechServiceConnection_Key,e),r},e.fromEndpoint=function(e,t){s.Contracts.throwIfNull(e,"endpoint");var r=new p;return r.setProperty(a.PropertyId.SpeechServiceConnection_Endpoint,e.href),void 0!==t&&r.setProperty(a.PropertyId.SpeechServiceConnection_Key,t),r},e.fromHost=function(e,t){s.Contracts.throwIfNull(e,"hostName");var r=new p;return r.setProperty(a.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(""===e.port?"":":"+e.port)),void 0!==t&&r.setProperty(a.PropertyId.SpeechServiceConnection_Key,t),r},e.fromAuthorizationToken=function(e,t){s.Contracts.throwIfNull(e,"authorizationToken"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new p;return r.setProperty(a.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(a.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r},e.prototype.close=function(){},e}();t.SpeechConfig=c;var p=function(e){function t(){var t=e.call(this)||this;return t.privProperties=new a.PropertyCollection,t.speechRecognitionLanguage="en-US",t.outputFormat=a.OutputFormat.Simple,t}return i(t,e),Object.defineProperty(t.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return new URL(this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_Endpoint))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionKey",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_Key)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"region",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_Region)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"authorizationToken",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechRecognitionLanguage",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage)},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputFormat",{get:function(){return a.OutputFormat[this.privProperties.getProperty(o.OutputFormatPropertyName,void 0)]},set:function(e){this.privProperties.setProperty(o.OutputFormatPropertyName,a.OutputFormat[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"endpointId",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_EndpointId)},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_EndpointId,e)},enumerable:!0,configurable:!0}),t.prototype.setProperty=function(e,t){s.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)},t.prototype.getProperty=function(e,t){return this.privProperties.getProperty(e,t)},t.prototype.setProxy=function(e,t,r,n){this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyPassword],n)},t.prototype.setServiceProperty=function(e,t,r){var n=JSON.parse(this.privProperties.getProperty(o.ServicePropertiesPropertyName,"{}"));n[e]=t,this.privProperties.setProperty(o.ServicePropertiesPropertyName,JSON.stringify(n))},t.prototype.setProfanity=function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceResponse_ProfanityOption,a.ProfanityOption[e])},t.prototype.enableAudioLogging=function(){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")},t.prototype.requestWordLevelTimestamps=function(){this.privProperties.setProperty(a.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")},t.prototype.enableDictation=function(){this.privProperties.setProperty(o.ForceDictationPropertyName,"true")},t.prototype.clone=function(){var e=new t;return e.privProperties=this.privProperties.clone(),e},Object.defineProperty(t.prototype,"speechSynthesisLanguage",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthLanguage)},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechSynthesisVoiceName",{get:function(){return this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthVoice)},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthVoice,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechSynthesisOutputFormat",{get:function(){return a.SpeechSynthesisOutputFormat[this.privProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]},set:function(e){this.privProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,a.SpeechSynthesisOutputFormat[e])},enumerable:!0,configurable:!0}),t}(c);t.SpeechConfigImpl=p},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(25),s=r(32),a=r(30),c=function(e){function t(){return e.call(this)||this}return i(t,e),t.fromSubscription=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new p;return r.properties.setProperty(a.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(a.PropertyId.SpeechServiceConnection_Region,t),r},t.fromAuthorizationToken=function(e,t){s.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),s.Contracts.throwIfNullOrWhitespace(t,"region");var r=new p;return r.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(a.PropertyId.SpeechServiceConnection_Region,t),r},t.fromHost=function(e,t){s.Contracts.throwIfNull(e,"hostName");var r=new p;return r.setProperty(a.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(""===e.port?"":":"+e.port)),void 0!==t&&r.setProperty(a.PropertyId.SpeechServiceConnection_Key,t),r},t.fromEndpoint=function(e,t){s.Contracts.throwIfNull(e,"endpoint"),s.Contracts.throwIfNull(t,"subscriptionKey");var r=new p;return r.properties.setProperty(a.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(a.PropertyId.SpeechServiceConnection_Key,t),r},t}(a.SpeechConfig);t.SpeechTranslationConfig=c;var p=function(e){function t(){var t=e.call(this)||this;return t.privSpeechProperties=new a.PropertyCollection,t.outputFormat=a.OutputFormat.Simple,t}return i(t,e),Object.defineProperty(t.prototype,"authorizationToken",{set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechRecognitionLanguage",{set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscriptionKey",{get:function(){return this.privSpeechProperties.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputFormat",{get:function(){return a.OutputFormat[this.privSpeechProperties.getProperty(o.OutputFormatPropertyName,void 0)]},set:function(e){this.privSpeechProperties.setProperty(o.OutputFormatPropertyName,a.OutputFormat[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"endpointId",{get:function(){return this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_EndpointId)},set:function(e){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_EndpointId,e)},enumerable:!0,configurable:!0}),t.prototype.addTargetLanguage=function(e){s.Contracts.throwIfNullOrWhitespace(e,"value");var t=this.targetLanguages;t.push(e),this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(","))},Object.defineProperty(t.prototype,"targetLanguages",{get:function(){return void 0!==this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)?this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"voiceName",{get:function(){return this.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_TranslationVoice])},set:function(e){s.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"region",{get:function(){return this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_Region)},enumerable:!0,configurable:!0}),t.prototype.setProxy=function(e,t,r,n){this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_ProxyPassword],n)},t.prototype.getProperty=function(e,t){return this.privSpeechProperties.getProperty(e,t)},t.prototype.setProperty=function(e,t){this.privSpeechProperties.setProperty(e,t)},Object.defineProperty(t.prototype,"properties",{get:function(){return this.privSpeechProperties},enumerable:!0,configurable:!0}),t.prototype.close=function(){},t.prototype.setServiceProperty=function(e,t,r){var n=JSON.parse(this.privSpeechProperties.getProperty(o.ServicePropertiesPropertyName,"{}"));n[e]=t,this.privSpeechProperties.setProperty(o.ServicePropertiesPropertyName,JSON.stringify(n))},t.prototype.setProfanity=function(e){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceResponse_ProfanityOption,a.ProfanityOption[e])},t.prototype.enableAudioLogging=function(){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")},t.prototype.requestWordLevelTimestamps=function(){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")},t.prototype.enableDictation=function(){this.privSpeechProperties.setProperty(o.ForceDictationPropertyName,"true")},Object.defineProperty(t.prototype,"speechSynthesisLanguage",{get:function(){return this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthLanguage)},set:function(e){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthLanguage,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechSynthesisVoiceName",{get:function(){return this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthVoice)},set:function(e){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthVoice,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechSynthesisOutputFormat",{get:function(){return a.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]},set:function(e){this.privSpeechProperties.setProperty(a.PropertyId.SpeechServiceConnection_SynthOutputFormat,a.SpeechSynthesisOutputFormat[e])},enumerable:!0,configurable:!0}),t}(c);t.SpeechTranslationConfigImpl=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(30),i=function(){function e(){this.privKeys=[],this.privValues=[]}return e.prototype.getProperty=function(e,t){var r;r="string"==typeof e?e:n.PropertyId[e];for(var i=0;i0&&s!==r.me.displayName&&r.changeNicknameAsync(s)}}catch(t){}},r.onConversationExpiration=function(e,t){var n,i;try{(null===(n=r.privConversationTranslator)||void 0===n?void 0:n.conversationExpiration)&&(null===(i=r.privConversationTranslator)||void 0===i||i.conversationExpiration(r.privConversationTranslator,t))}catch(t){}},r.privProperties=new c.PropertyCollection,r.privManager=new s.ConversationManager;var n=t.getProperty(c.PropertyId[c.PropertyId.SpeechServiceConnection_RecoLanguage]);n||t.setProperty(c.PropertyId[c.PropertyId.SpeechServiceConnection_RecoLanguage],s.ConversationTranslatorConfig.defaultLanguageCode),r.privLanguage=t.getProperty(c.PropertyId[c.PropertyId.SpeechServiceConnection_RecoLanguage]),0===t.targetLanguages.length&&t.addTargetLanguage(r.privLanguage);var i=t.getProperty(c.PropertyId[c.PropertyId.SpeechServiceResponse_ProfanityOption]);i||t.setProfanity(c.ProfanityOption.Masked);var p=t.getProperty(c.PropertyId[c.PropertyId.ConversationTranslator_Name]);(null==p||p.length<=1||p.length>50)&&(p="Host"),t.setProperty(c.PropertyId[c.PropertyId.ConversationTranslator_Name],p),r.privConfig=t;var u=t;return a.Contracts.throwIfNull(u,"speechConfig"),r.privProperties=u.properties.clone(),r.privIsConnected=!1,r.privParticipants=new s.InternalParticipants,r.privIsReady=!1,r}return i(t,e),Object.defineProperty(t.prototype,"conversationTranslator",{set:function(e){this.privConversationTranslator=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"room",{get:function(){return this.privRoom},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"connection",{get:function(){return this.privConversationRecognizer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"authorizationToken",{get:function(){return this.privToken},set:function(e){a.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"config",{get:function(){return this.privConfig},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"conversationId",{get:function(){return this.privRoom?this.privRoom.roomId:""},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechRecognitionLanguage",{get:function(){return this.privLanguage},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isMutedByHost",{get:function(){var e,t;return(null===(e=this.privParticipants.me)||void 0===e||!e.isHost)&&(null===(t=this.privParticipants.me)||void 0===t?void 0:t.isMuted)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isConnected",{get:function(){return this.privIsConnected&&this.privIsReady},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"participants",{get:function(){return this.toParticipants(!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"me",{get:function(){return this.toParticipant(this.privParticipants.me)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"host",{get:function(){return this.toParticipant(this.privParticipants.host)},enumerable:!0,configurable:!0}),t.prototype.createConversationAsync=function(e,t){var r=this;try{this.privConversationRecognizer&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,function(n){n||r.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedConnect),t),r.privRoom=n,r.handleCallback(e,t)},function(e){r.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.startConversationAsync=function(e,t){var r=this;try{this.privConversationRecognizer&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedStart),t),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=new s.ConversationTranslatorRecognizer(this.privConfig),this.privConversationRecognizer.conversation=this.privRoom,this.privConversationRecognizerConnection=c.Connection.fromRecognizer(this.privConversationRecognizer),this.privConversationRecognizerConnection.connected=this.onConnected,this.privConversationRecognizerConnection.disconnected=this.onDisconnected,this.privConversationRecognizer.canceled=this.onCanceled,this.privConversationRecognizer.participantUpdateCommandReceived=this.onParticipantUpdateCommandReceived,this.privConversationRecognizer.lockRoomCommandReceived=this.onLockRoomCommandReceived,this.privConversationRecognizer.muteAllCommandReceived=this.onMuteAllCommandReceived,this.privConversationRecognizer.participantJoinCommandReceived=this.onParticipantJoinCommandReceived,this.privConversationRecognizer.participantLeaveCommandReceived=this.onParticipantLeaveCommandReceived,this.privConversationRecognizer.translationReceived=this.onTranslationReceived,this.privConversationRecognizer.participantsListReceived=this.onParticipantsListReceived,this.privConversationRecognizer.conversationExpiration=this.onConversationExpiration,this.privConversationRecognizer.connect(this.privRoom.token,function(){r.handleCallback(e,t)},function(e){r.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.joinConversationAsync=function(e,t,r,n,i){var o=this;try{a.Contracts.throwIfNullOrWhitespace(e,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","conversationId")),a.Contracts.throwIfNullOrWhitespace(t,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","nickname")),a.Contracts.throwIfNullOrWhitespace(r,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,function(e){a.Contracts.throwIfNullOrUndefined(e,s.ConversationTranslatorConfig.strings.permissionDeniedConnect),o.privRoom=e,o.privConfig.authorizationToken=e.cognitiveSpeechAuthToken,n&&n(e.cognitiveSpeechAuthToken)},function(e){o.handleError(e,i)})}catch(e){this.handleError(e,i)}},t.prototype.deleteConversationAsync=function(e,t){var r=this;try{a.Contracts.throwIfNullOrUndefined(this.privProperties,s.ConversationTranslatorConfig.strings.permissionDeniedConnect),a.Contracts.throwIfNullOrWhitespace(this.privRoom.token,s.ConversationTranslatorConfig.strings.permissionDeniedConnect),this.privManager.leave(this.privProperties,this.privRoom.token,function(){r.handleCallback(e,t)},function(e){r.handleError(e,t)}),this.dispose()}catch(e){this.handleError(e,t)}},t.prototype.endConversationAsync=function(e,t){try{this.close(!0),this.handleCallback(e,t)}catch(e){this.handleError(e,t)}},t.prototype.lockConversationAsync=function(e,t){var r,n=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedConversation.replace("{command}","lock")),t),null===(r=this.privConversationRecognizer)||void 0===r||r.sendLockRequest(!0,function(){n.handleCallback(e,t)},function(e){n.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.muteAllParticipantsAsync=function(e,t){var r,n=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,s.ConversationTranslatorConfig.strings.permissionDeniedSend),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedConversation.replace("{command}","mute")),t),null===(r=this.privConversationRecognizer)||void 0===r||r.sendMuteAllRequest(!0,function(){n.handleCallback(e,t)},function(e){n.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.muteParticipantAsync=function(e,t,r){var n,i=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrWhitespace(e,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","userId")),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSend||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedParticipant.replace("{command}","mute")),r);var o=this.privParticipants.getParticipantIndex(e);-1===o&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.invalidParticipantRequest),r),null===(n=this.privConversationRecognizer)||void 0===n||n.sendMuteRequest(e,!0,function(){i.handleCallback(t,r)},function(e){i.handleError(e,r)})}catch(e){this.handleError(e,r)}},t.prototype.removeParticipantAsync=function(e,t,r){var n,i=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedParticipant.replace("{command}","remove")),r);var o="";if("string"==typeof e)o=e;else if(e.hasOwnProperty("id")){var c=e;o=c.id}else if(e.hasOwnProperty("userId")){var p=e;o=p.userId}a.Contracts.throwIfNullOrWhitespace(o,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","userId"));var u=this.participants.findIndex(function(e){return e.id===o});-1===u&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.invalidParticipantRequest),r),null===(n=this.privConversationRecognizer)||void 0===n||n.sendEjectRequest(o,function(){i.handleCallback(t,r)},function(e){i.handleError(e,r)})}catch(e){this.handleError(e,r)}},t.prototype.unlockConversationAsync=function(e,t){var r,n=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedConversation.replace("{command}","unlock")),t),null===(r=this.privConversationRecognizer)||void 0===r||r.sendLockRequest(!1,function(){n.handleCallback(e,t)},function(e){n.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.unmuteAllParticipantsAsync=function(e,t){var r,n=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedConversation.replace("{command}","unmute all")),t),null===(r=this.privConversationRecognizer)||void 0===r||r.sendMuteAllRequest(!1,function(){n.handleCallback(e,t)},function(e){n.handleError(e,t)})}catch(e){this.handleError(e,t)}},t.prototype.unmuteParticipantAsync=function(e,t,r){var n,i=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrWhitespace(e,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","userId")),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSend||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedSend),r),this.me.isHost||this.me.id===e||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedParticipant.replace("{command}","mute")),r) ;var o=this.privParticipants.getParticipantIndex(e);-1===o&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.invalidParticipantRequest),r),null===(n=this.privConversationRecognizer)||void 0===n||n.sendMuteRequest(e,!1,function(){i.handleCallback(t,r)},function(e){i.handleError(e,r)})}catch(e){this.handleError(e,r)}},t.prototype.sendTextMessageAsync=function(e,t,r){var n,i=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrWhitespace(e,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","message")),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSend||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedSend),r),e.length>s.ConversationTranslatorConfig.textMessageMaxLength&&this.handleError(new Error(s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","message length")),r),null===(n=this.privConversationRecognizer)||void 0===n||n.sendMessageRequest(e,function(){i.handleCallback(t,r)},function(e){i.handleError(e,r)})}catch(e){this.handleError(e,r)}},t.prototype.changeNicknameAsync=function(e,t,r){var n,i=this;try{a.Contracts.throwIfDisposed(this.privIsDisposed),a.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),a.Contracts.throwIfNullOrWhitespace(e,s.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","nickname")),a.Contracts.throwIfNullOrUndefined(this.privRoom,s.ConversationTranslatorConfig.strings.permissionDeniedSend),this.canSend||this.handleError(new Error(s.ConversationTranslatorConfig.strings.permissionDeniedSend),r),null===(n=this.privConversationRecognizer)||void 0===n||n.sendChangeNicknameRequest(e,function(){i.handleCallback(t,r)},function(e){i.handleError(e,r)})}catch(e){this.handleError(e,r)}},t.prototype.isDisposed=function(){return this.privIsDisposed},t.prototype.dispose=function(e){var t;this.isDisposed||(this.privIsDisposed=!0,null===(t=this.config)||void 0===t||t.close(),this.privConversationRecognizerConnection&&(this.privConversationRecognizerConnection.closeConnection(),this.privConversationRecognizerConnection.close(),this.privConversationRecognizerConnection=void 0),this.privConfig=void 0,this.privLanguage=void 0,this.privProperties=void 0,this.privRoom=void 0,this.privToken=void 0,this.privManager=void 0,this.privConversationRecognizer=void 0,this.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0,this.privRoom=void 0)},t.prototype.close=function(e){var t,r,n;try{this.privIsConnected=!1,null===(t=this.privConversationRecognizerConnection)||void 0===t||t.closeConnection(),null===(r=this.privConversationRecognizerConnection)||void 0===r||r.close(),this.privConversationRecognizer.close(),this.privConversationRecognizerConnection=void 0,this.privConversationRecognizer=void 0,null===(n=this.privConversationTranslator)||void 0===n||n.dispose()}catch(e){}e&&this.dispose()},Object.defineProperty(t.prototype,"canSend",{get:function(){var e;return this.privIsConnected&&!(null===(e=this.privParticipants.me)||void 0===e?void 0:e.isMuted)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canSendAsHost",{get:function(){var e;return this.privIsConnected&&(null===(e=this.privParticipants.me)||void 0===e?void 0:e.isHost)},enumerable:!0,configurable:!0}),t.prototype.handleCallback=function(e,t){if(e){try{e()}catch(e){t&&t(e)}e=void 0}},t.prototype.handleError=function(e,t){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)},t.prototype.toParticipants=function(e){var t=this,r=this.privParticipants.participants.map(function(e){return t.toParticipant(e)});return e?r:r.filter(function(e){return!1===e.isHost})},t.prototype.toParticipant=function(e){return new c.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage)},t}(p);t.ConversationImpl=u},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r){var n=e.call(this,r)||this;return n.privExpirationTime=t,n}return i(t,e),Object.defineProperty(t.prototype,"expirationTime",{get:function(){return this.privExpirationTime},enumerable:!0,configurable:!0}),t}(o.SessionEventArgs);t.ConversationExpirationEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n){var i=e.call(this,n)||this;return i.privReason=t,i.privParticipant=r,i}return i(t,e),Object.defineProperty(t.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"participants",{get:function(){return this.privParticipant},enumerable:!0,configurable:!0}),t}(o.SessionEventArgs);t.ConversationParticipantsChangedEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n,i,o){var s=e.call(this,i,o)||this;return s.privReason=t,s.privErrorDetails=r,s.privErrorCode=n,s}return i(t,e),Object.defineProperty(t.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errorCode",{get:function(){return this.privErrorCode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.ConversationTranslationCanceledEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(30),s=function(e){function t(t,r,n){var i=e.call(this,r,n)||this;return i.privResult=t,i}return i(t,e),Object.defineProperty(t.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),t}(o.RecognitionEventArgs);t.ConversationTranslationEventArgs=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(55),s=function(e){function t(t,r,n,i,o,s,a,c,p,u,v){var f=e.call(this,r,i,o,s,a,c,p,u,v)||this;return f.privId=t,f.privOrigLang=n,f}return i(t,e),Object.defineProperty(t.prototype,"participantId",{get:function(){return this.privId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"originalLang",{get:function(){return this.privOrigLang},enumerable:!0,configurable:!0}),t}(o.TranslationRecognitionResult);t.ConversationTranslationResult=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(25),o=r(32),s=r(30),a=r(92),c=r(91);(function(e){e[e.Inactive=0]="Inactive",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected"})(n=t.SpeechState||(t.SpeechState={}));var p=function(){function e(e){var t=this;this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privSpeechState=n.Inactive,this.onSpeechConnected=function(e){t.privSpeechState=n.Connected},this.onSpeechDisconnected=function(e){t.privSpeechState=n.Inactive,t.cancelSpeech()},this.onSpeechRecognized=function(e,r){var n;(null===(n=r.result)||void 0===n?void 0:n.errorDetails)&&(t.cancelSpeech(),t.fireCancelEvent(r.result.errorDetails))},this.onSpeechRecognizing=function(e,t){},this.onSpeechCanceled=function(e,r){if(t.privSpeechState!==n.Inactive)try{t.cancelSpeech()}catch(e){t.privSpeechState=n.Inactive}},this.onSpeechSessionStarted=function(e,r){t.privSpeechState=n.Connected},this.onSpeechSessionStopped=function(e,r){t.privSpeechState=n.Inactive},this.privProperties=new s.PropertyCollection,this.privAudioConfig=e}return Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speechRecognitionLanguage",{get:function(){return this.privSpeechRecognitionLanguage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participants",{get:function(){var e;return null===(e=this.privConversation)||void 0===e?void 0:e.participants},enumerable:!0,configurable:!0}),e.prototype.joinConversationAsync=function(e,t,r,n,c){var p=this;try{if("string"==typeof e){o.Contracts.throwIfNullOrUndefined(e,i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(t,i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(i.ConversationTranslatorConfig.strings.permissionDeniedStart),c);var u=r;null!=u&&""!==u||(u=i.ConversationTranslatorConfig.defaultLanguageCode),this.privSpeechTranslationConfig=s.SpeechTranslationConfig.fromSubscription(i.ConversationTranslatorConfig.auth.placeholderSubscriptionKey,i.ConversationTranslatorConfig.auth.placeholderRegion),this.privSpeechTranslationConfig.setProfanity(s.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(u),this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage],u),this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.ConversationTranslator_Name],t);var v=this.privProperties.getProperty(s.PropertyId.ConversationTranslator_Host);v&&this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.ConversationTranslator_Host],v);var f=this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_Host);f&&this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Host],f),this.privConversation=new a.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,u,function(e){e||p.handleError(new Error(i.ConversationTranslatorConfig.strings.permissionDeniedConnect),c),p.privSpeechTranslationConfig.authorizationToken=e,p.privConversation.startConversationAsync(function(){p.handleCallback(n,c)},function(e){p.handleError(e,c)})},function(e){p.handleError(e,c)})}else"object"==typeof e?(o.Contracts.throwIfNullOrUndefined(e,i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","conversation id")),o.Contracts.throwIfNullOrWhitespace(t,i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(s.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,o.Contracts.throwIfNullOrUndefined(this.privConversation,i.ConversationTranslatorConfig.strings.permissionDeniedConnect),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,i.ConversationTranslatorConfig.strings.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(e){this.handleError(e,"string"==typeof r?c:n)}},e.prototype.leaveConversationAsync=function(e,t){var r=this;try{this.cancelSpeech(),this.privConversation.endConversationAsync(function(){r.privConversation.deleteConversationAsync(function(){r.handleCallback(e,t),r.dispose()},function(e){r.handleError(e,t)})},function(e){r.handleError(e,t)})}catch(e){this.handleError(e,t)}},e.prototype.sendTextMessageAsync=function(e,t,r){var n;try{o.Contracts.throwIfNullOrUndefined(this.privConversation,i.ConversationTranslatorConfig.strings.permissionDeniedSend),o.Contracts.throwIfNullOrWhitespace(e,i.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}",e)),null===(n=this.privConversation)||void 0===n||n.sendTextMessageAsync(e,t,r)}catch(e){this.handleError(e,r)}},e.prototype.startTranscribingAsync=function(e,t){var r=this;try{o.Contracts.throwIfNullOrUndefined(this.privConversation,i.ConversationTranslatorConfig.strings.permissionDeniedSend),o.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,i.ConversationTranslatorConfig.strings.permissionDeniedConnect),this.canSpeak||this.handleError(new Error(i.ConversationTranslatorConfig.strings.permissionDeniedSend),t),void 0===this.privTranslationRecognizer?this.connectTranslatorRecognizer(function(){r.startContinuousRecognition(function(){r.privIsSpeaking=!0,r.handleCallback(e,t)},function(e){r.privIsSpeaking=!1,r.cancelSpeech(),r.handleError(e,t)})},function(e){r.handleError(e,t)}):this.startContinuousRecognition(function(){r.privIsSpeaking=!0,r.handleCallback(e,t)},function(e){r.privIsSpeaking=!1,r.cancelSpeech(),r.handleError(e,t)})}catch(e){this.handleError(e,t),this.cancelSpeech()}},e.prototype.stopTranscribingAsync=function(e,t){var r,n=this;try{if(!this.privIsSpeaking)return this.cancelSpeech(),void this.handleCallback(e,t);this.privIsSpeaking=!1,null===(r=this.privTranslationRecognizer)||void 0===r||r.stopContinuousRecognitionAsync(function(){n.handleCallback(e,t)},function(e){n.handleError(e,t),n.cancelSpeech()})}catch(e){this.handleError(e,t),this.cancelSpeech()}},e.prototype.isDisposed=function(){return this.privIsDisposed},e.prototype.dispose=function(e){var t,r;this.isDisposed&&!this.privIsSpeaking||(this.cancelSpeech(),this.privIsDisposed=!0,null===(t=this.privSpeechTranslationConfig)||void 0===t||t.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,null===(r=this.privConversation)||void 0===r||r.dispose(),this.privConversation=void 0)},e.prototype.connectTranslatorRecognizer=function(e,t){try{void 0===this.privAudioConfig&&(this.privAudioConfig=s.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Key])===i.ConversationTranslatorConfig.auth.placeholderSubscriptionKey&&this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Key],"");var r=encodeURIComponent(this.privConversation.room.token),n=this.privSpeechTranslationConfig.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Host],i.ConversationTranslatorConfig.speechHost);n=n.replace("{region}",this.privConversation.room.cognitiveSpeechRegion);var o="wss://"+n+i.ConversationTranslatorConfig.speechPath+"?"+i.ConversationTranslatorConfig.params.token+"="+r;this.privSpeechTranslationConfig.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_Endpoint],o),this.privTranslationRecognizer=new s.TranslationRecognizer(this.privSpeechTranslationConfig,this.privAudioConfig),this.privTranslationRecognizerConnection=s.Connection.fromRecognizer(this.privTranslationRecognizer),this.privTranslationRecognizerConnection.connected=this.onSpeechConnected,this.privTranslationRecognizerConnection.disconnected=this.onSpeechDisconnected,this.privTranslationRecognizer.recognized=this.onSpeechRecognized,this.privTranslationRecognizer.recognizing=this.onSpeechRecognizing,this.privTranslationRecognizer.canceled=this.onSpeechCanceled,this.privTranslationRecognizer.sessionStarted=this.onSpeechSessionStarted,this.privTranslationRecognizer.sessionStopped=this.onSpeechSessionStopped,this.handleCallback(e,t)}catch(e){this.handleError(e,t),this.cancelSpeech()}},e.prototype.startContinuousRecognition=function(e,t){this.privTranslationRecognizer.startContinuousRecognitionAsync(e,t)},e.prototype.fireCancelEvent=function(e){var t,r,n,i,o,a,p;try{if(this.canceled){var u=new c.ConversationTranslationCanceledEventArgs((r=null===(t=e)||void 0===t?void 0:t.reason,null!=r?r:s.CancellationReason.Error),(i=null===(n=e)||void 0===n?void 0:n.errorDetails,null!=i?i:e),(a=null===(o=e)||void 0===o?void 0:o.errorCode,null!=a?a:s.CancellationErrorCode.RuntimeError),void 0,null===(p=e)||void 0===p?void 0:p.sessionId);this.canceled(this,u)}}catch(e){}},e.prototype.cancelSpeech=function(){var e,t;try{this.privIsSpeaking=!1,null===(e=this.privTranslationRecognizer)||void 0===e||e.stopContinuousRecognitionAsync(),null===(t=this.privTranslationRecognizerConnection)||void 0===t||t.closeConnection(),this.privTranslationRecognizerConnection=void 0,this.privTranslationRecognizer=void 0,this.privSpeechState=n.Inactive}catch(e){}},Object.defineProperty(e.prototype,"canSpeak",{get:function(){return!!this.privConversation.isConnected&&(!this.privIsSpeaking&&this.privSpeechState!==n.Connected&&this.privSpeechState!==n.Connecting&&!this.privConversation.isMutedByHost)},enumerable:!0,configurable:!0}),e.prototype.handleCallback=function(e,t){if(e){try{e()}catch(e){t&&t(e)}e=void 0}},e.prototype.handleError=function(e,t){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e)},e}();t.ConversationTranslator=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(30),i=function(){function e(e){this.privUserId=e}return Object.defineProperty(e.prototype,"userId",{get:function(){return this.privUserId},enumerable:!0,configurable:!0}),e}();t.User=i;var o=function(){function e(e,t,r,i,o,s,a){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=i,this.privIsMuted=o,this.privIsUsingTts=s,this.privPreferredLanguage=a,this.privPoperties=new n.PropertyCollection}return Object.defineProperty(e.prototype,"avatar",{get:function(){return this.privAvatar},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayName",{get:function(){return this.privDisplayName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"preferredLanguage",{get:function(){return this.privPreferredLanguage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this.privIsHost},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isMuted",{get:function(){return this.privIsMuted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTts",{get:function(){return this.privIsUsingTts},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privPoperties},enumerable:!0,configurable:!0}),e}();t.Participant=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.JoinedConversation=0]="JoinedConversation",e[e.LeftConversation=1]="LeftConversation",e[e.Updated=2]="Updated"}(t.ParticipantChangedReason||(t.ParticipantChangedReason={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(25),i=r(4),o=r(33),s=r(37),a=r(36),c=r(32),p=r(30),u=function(){function e(e,t){var r=e;c.Contracts.throwIfNull(r,"speechConfig"),null!==t&&(this.audioConfig=void 0!==t?t:p.AudioConfig.fromDefaultSpeakerOutput()),this.privProperties=r.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.privConnectionFactory=new n.SpeechSynthesisConnectionFactory,this.synthesisRequestQueue=new i.Queue,this.implCommonRSynthesizeSetup()}return Object.defineProperty(e.prototype,"authorizationToken",{get:function(){return this.properties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token)},set:function(e){c.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(p.PropertyId.SpeechServiceAuthorization_Token,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e.buildSsml=function(e,t){var r,n=(r={},r["ar-EG"]="Microsoft Server Speech Text to Speech Voice (ar-EG, Hoda)",r["ar-SA"]="Microsoft Server Speech Text to Speech Voice (ar-SA, Naayf)",r["bg-BG"]="Microsoft Server Speech Text to Speech Voice (bg-BG, Ivan)",r["ca-ES"]="Microsoft Server Speech Text to Speech Voice (ca-ES, HerenaRUS)",r["cs-CZ"]="Microsoft Server Speech Text to Speech Voice (cs-CZ, Jakub)",r["da-DK"]="Microsoft Server Speech Text to Speech Voice (da-DK, HelleRUS)",r["de-AT"]="Microsoft Server Speech Text to Speech Voice (de-AT, Michael)",r["de-CH"]="Microsoft Server Speech Text to Speech Voice (de-CH, Karsten)",r["de-DE"]="Microsoft Server Speech Text to Speech Voice (de-DE, HeddaRUS)",r["el-GR"]="Microsoft Server Speech Text to Speech Voice (el-GR, Stefanos)",r["en-AU"]="Microsoft Server Speech Text to Speech Voice (en-AU, HayleyRUS)",r["en-CA"]="Microsoft Server Speech Text to Speech Voice (en-CA, HeatherRUS)",r["en-GB"]="Microsoft Server Speech Text to Speech Voice (en-GB, HazelRUS)",r["en-IE"]="Microsoft Server Speech Text to Speech Voice (en-IE, Sean)",r["en-IN"]="Microsoft Server Speech Text to Speech Voice (en-IN, PriyaRUS)",r["en-US"]="Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)",r["es-ES"]="Microsoft Server Speech Text to Speech Voice (es-ES, HelenaRUS)",r["es-MX"]="Microsoft Server Speech Text to Speech Voice (es-MX, HildaRUS)",r["fi-FI"]="Microsoft Server Speech Text to Speech Voice (fi-FI, HeidiRUS)",r["fr-CA"]="Microsoft Server Speech Text to Speech Voice (fr-CA, HarmonieRUS)",r["fr-CH"]="Microsoft Server Speech Text to Speech Voice (fr-CH, Guillaume)",r["fr-FR"]="Microsoft Server Speech Text to Speech Voice (fr-FR, HortenseRUS)",r["he-IL"]="Microsoft Server Speech Text to Speech Voice (he-IL, Asaf)",r["hi-IN"]="Microsoft Server Speech Text to Speech Voice (hi-IN, Kalpana)",r["hr-HR"]="Microsoft Server Speech Text to Speech Voice (hr-HR, Matej)",r["hu-HU"]="Microsoft Server Speech Text to Speech Voice (hu-HU, Szabolcs)",r["id-ID"]="Microsoft Server Speech Text to Speech Voice (id-ID, Andika)",r["it-IT"]="Microsoft Server Speech Text to Speech Voice (it-IT, LuciaRUS)",r["ja-JP"]="Microsoft Server Speech Text to Speech Voice (ja-JP, HarukaRUS)",r["ko-KR"]="Microsoft Server Speech Text to Speech Voice (ko-KR, HeamiRUS)",r["ms-MY"]="Microsoft Server Speech Text to Speech Voice (ms-MY, Rizwan)",r["nb-NO"]="Microsoft Server Speech Text to Speech Voice (nb-NO, HuldaRUS)",r["nl-NL"]="Microsoft Server Speech Text to Speech Voice (nl-NL, HannaRUS)",r["pl-PL"]="Microsoft Server Speech Text to Speech Voice (pl-PL, PaulinaRUS)",r["pt-BR"]="Microsoft Server Speech Text to Speech Voice (pt-BR, HeloisaRUS)",r["pt-PT"]="Microsoft Server Speech Text to Speech Voice (pt-PT, HeliaRUS)",r["ro-RO"]="Microsoft Server Speech Text to Speech Voice (ro-RO, Andrei)",r["ru-RU"]="Microsoft Server Speech Text to Speech Voice (ru-RU, EkaterinaRUS)",r["sk-SK"]="Microsoft Server Speech Text to Speech Voice (sk-SK, Filip)",r["sl-SI"]="Microsoft Server Speech Text to Speech Voice (sl-SI, Lado)",r["sv-SE"]="Microsoft Server Speech Text to Speech Voice (sv-SE, HedvigRUS)",r["ta-IN"]="Microsoft Server Speech Text to Speech Voice (ta-IN, Valluvar)",r["te-IN"]="Microsoft Server Speech Text to Speech Voice (te-IN, Chitra)",r["th-TH"]="Microsoft Server Speech Text to Speech Voice (th-TH, Pattara)",r["tr-TR"]="Microsoft Server Speech Text to Speech Voice (tr-TR, SedaRUS)",r["vi-VN"]="Microsoft Server Speech Text to Speech Voice (vi-VN, An)",r["zh-CN"]="Microsoft Server Speech Text to Speech Voice (zh-CN, HuihuiRUS)",r["zh-HK"]="Microsoft Server Speech Text to Speech Voice (zh-HK, TracyRUS)",r["zh-TW"]="Microsoft Server Speech Text to Speech Voice (zh-TW, HanHanRUS)",r),i=t.getProperty(p.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),o=t.getProperty(p.PropertyId.SpeechServiceConnection_SynthVoice,n[i]);return""+this.XMLEncode(e)+""},e.prototype.speakTextAsync=function(e,t,r,n){this.speakImpl(e,!1,t,r,n)},e.prototype.speakSsmlAsync=function(e,t,r,n){this.speakImpl(e,!0,t,r,n)},e.prototype.close=function(){c.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)},Object.defineProperty(e.prototype,"internalData",{get:function(){return this.privAdapter},enumerable:!0,configurable:!0}),e.prototype.dispose=function(e){this.privDisposed||(e&&this.privAdapter&&this.privAdapter.dispose(),this.privDisposed=!0)},e.prototype.createSynthesizerConfig=function(e){return new n.SynthesizerConfig(e,this.privProperties)},e.prototype.createSynthesisAdapter=function(e,t,r,i){return new n.SynthesisAdapterBase(e,t,i,this,this.audioConfig)},e.prototype.implCommonRSynthesizeSetup=function(){var e=this,t="undefined"!=typeof window?"Browser":"Node",r="unknown",o="unknown";"undefined"!=typeof navigator&&(t=t+"/"+navigator.platform,r=navigator.userAgent,o=navigator.appVersion);var a=this.createSynthesizerConfig(new n.SpeechServiceConfig(new n.Context(new n.OS(t,r,o)))),c=this.privProperties.getProperty(p.PropertyId.SpeechServiceConnection_Key,void 0),u=c&&""!==c?new n.CognitiveSubscriptionKeyAuthentication(c):new n.CognitiveTokenAuthentication(function(t){var r=e.privProperties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token,void 0);return i.PromiseHelper.fromResult(r)},function(t){var r=e.privProperties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token,void 0);return i.PromiseHelper.fromResult(r)});this.privAdapter=this.createSynthesisAdapter(u,this.privConnectionFactory,this.audioConfig,a),this.privAdapter.audioOutputFormat=s.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(p.SpeechSynthesisOutputFormat[this.properties.getProperty(p.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])},e.prototype.speakImpl=function(e,t,r,n,s){var u=this;try{c.Contracts.throwIfDisposed(this.privDisposed);var f=i.createNoDashGuid(),h=void 0;h=s instanceof p.PushAudioOutputStreamCallback?new a.PushAudioOutputStreamImpl(s):s instanceof p.PullAudioOutputStream?s:void 0!==s?new o.AudioFileWriter(s):void 0,this.synthesisRequestQueue.enqueue(new v(f,e,t,function(e){if(u.privSynthesizing=!1,r)try{r(e)}catch(e){n&&n(e)}r=void 0,u.adapterSpeak()},function(e){n&&n(e)},h)),this.adapterSpeak()}catch(e){if(n)if(e instanceof Error){var l=e;n(l.name+": "+l.message)}else n(e);this.dispose(!0)}},e.prototype.adapterSpeak=function(){var e=this;return this.privDisposed||this.privSynthesizing?i.PromiseHelper.fromResult(!0):(this.privSynthesizing=!0,this.synthesisRequestQueue.dequeue().onSuccessContinueWithPromise(function(t){return e.privAdapter.Speak(t.text,t.isSSML,t.requestId,t.cb,t.err,t.dataStream)}))},e.XMLEncode=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},e}();t.SpeechSynthesizer=u;var v=function(){function e(e,t,r,n,i,o){this.requestId=e,this.text=t,this.isSSML=r,this.cb=n,this.err=i,this.dataStream=o}return e}();t.SynthesisRequest=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n,i){this.privResultId=e,this.privReason=t,this.privAudioData=r,this.privErrorDetails=n,this.privProperties=i}return Object.defineProperty(e.prototype,"resultId",{get:function(){return this.privResultId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reason",{get:function(){return this.privReason},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioData",{get:function(){return this.privAudioData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorDetails",{get:function(){return this.privErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),e}();t.SpeechSynthesisResult=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privResult=e}return Object.defineProperty(e.prototype,"result",{get:function(){return this.privResult},enumerable:!0,configurable:!0}),e}();t.SpeechSynthesisEventArgs=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,r,n){this.privAduioOffset=e,this.privText=t,this.privWordLength=r,this.privTextOffset=n}return Object.defineProperty(e.prototype,"audioOffset",{get:function(){return this.privAduioOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this.privText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wordLength",{get:function(){return this.privWordLength},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textOffset",{get:function(){return this.privTextOffset},enumerable:!0,configurable:!0}),e}();t.SpeechSynthesisWordBoundaryEventArgs=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=function(e){function t(t,r,n,i){void 0===i&&(i=o.EventType.Info);var s=e.call(this,t,i)||this;return s.privRequestId=r,s.privSessionId=n,s}return i(t,e),Object.defineProperty(t.prototype,"requestId",{get:function(){return this.privRequestId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this.privSessionId},enumerable:!0,configurable:!0}),t}(o.PlatformEvent);t.SpeechRecognitionEvent=s;var a=function(e){function t(t,r,n,i){var o=e.call(this,"RecognitionTriggeredEvent",t,r)||this;return o.privAudioSourceId=n,o.privAudioNodeId=i,o}return i(t,e),Object.defineProperty(t.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),t}(s);t.RecognitionTriggeredEvent=a;var c=function(e){function t(t,r,n,i){var o=e.call(this,"ListeningStartedEvent",t,r)||this;return o.privAudioSourceId=n,o.privAudioNodeId=i,o}return i(t,e),Object.defineProperty(t.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),t}(s);t.ListeningStartedEvent=c;var p=function(e){function t(t,r,n){var i=e.call(this,"ConnectingToServiceEvent",t,n)||this;return i.privAuthFetchEventid=r,i}return i(t,e),Object.defineProperty(t.prototype,"authFetchEventid",{get:function(){return this.privAuthFetchEventid},enumerable:!0, configurable:!0}),t}(s);t.ConnectingToServiceEvent=p;var u,v=function(e){function t(t,r,n,i,o){var s=e.call(this,"RecognitionStartedEvent",t,o)||this;return s.privAudioSourceId=r,s.privAudioNodeId=n,s.privAuthFetchEventId=i,s}return i(t,e),Object.defineProperty(t.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"authFetchEventId",{get:function(){return this.privAuthFetchEventId},enumerable:!0,configurable:!0}),t}(s);t.RecognitionStartedEvent=v,function(e){e[e.Success=0]="Success",e[e.AudioSourceError=1]="AudioSourceError",e[e.AudioSourceTimeout=2]="AudioSourceTimeout",e[e.AuthTokenFetchError=3]="AuthTokenFetchError",e[e.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",e[e.UnAuthorized=5]="UnAuthorized",e[e.ConnectTimeout=6]="ConnectTimeout",e[e.ConnectError=7]="ConnectError",e[e.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",e[e.UnknownError=9]="UnknownError"}(u=t.RecognitionCompletionStatus||(t.RecognitionCompletionStatus={}));var f=function(e){function t(t,r,n,i,s,a,c,p){var v=e.call(this,"RecognitionEndedEvent",t,s,c===u.Success?o.EventType.Info:o.EventType.Error)||this;return v.privAudioSourceId=r,v.privAudioNodeId=n,v.privAuthFetchEventId=i,v.privStatus=c,v.privError=p,v.privServiceTag=a,v}return i(t,e),Object.defineProperty(t.prototype,"audioSourceId",{get:function(){return this.privAudioSourceId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"audioNodeId",{get:function(){return this.privAudioNodeId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"authFetchEventId",{get:function(){return this.privAuthFetchEventId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"serviceTag",{get:function(){return this.privServiceTag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.privStatus},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"error",{get:function(){return this.privError},enumerable:!0,configurable:!0}),t}(s);t.RecognitionEndedEvent=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=r(4),o=r(30),s=r(25),a=r(107),c=function(){function e(t,r,n,c,p){var u=this;if(this.recognizeOverride=void 0,this.disconnectOverride=void 0,this.sendTelemetryData=function(){var t=u.privRequestSession.getTelemetry();if(!0!==e.telemetryDataEnabled||u.privIsDisposed||null===t)return i.PromiseHelper.fromResult(!0);if(e.telemetryData)try{e.telemetryData(t)}catch(e){}return u.fetchConnection().onSuccessContinueWith(function(e){return e.send(new a.SpeechConnectionMessage(i.MessageType.Text,"telemetry",u.privRequestSession.requestId,"application/json",t))})},this.receiveMessageOverride=void 0,this.receiveMessage=function(){return u.fetchConnection().on(function(e){return e.read().onSuccessContinueWithPromise(function(e){if(void 0!==u.receiveMessageOverride)return u.receiveMessageOverride();if(u.privIsDisposed)return i.PromiseHelper.fromResult(void 0);if(!e)return u.privRequestSession.isRecognizing?u.receiveMessage():i.PromiseHelper.fromResult(!0);u.privServiceHasSentMessage=!0;var t=a.SpeechConnectionMessage.fromConnectionMessage(e);if(t.requestId.toLowerCase()===u.privRequestSession.requestId.toLowerCase())switch(t.path.toLowerCase()){case"turn.start":u.privMustReportEndOfStream=!0,u.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":var r=s.SpeechDetected.fromJSON(t.textBody),n=new o.RecognitionEventArgs(r.Offset,u.privRequestSession.sessionId);u.privRecognizer.speechStartDetected&&u.privRecognizer.speechStartDetected(u.privRecognizer,n);break;case"speech.enddetected":var c=void 0;c=t.textBody.length>0?t.textBody:"{ Offset: 0 }";var p=s.SpeechDetected.fromJSON(c);u.privRecognizerConfig.isContinuousRecognition&&u.privRequestSession.onServiceRecognized(p.Offset+u.privRequestSession.currentTurnAudioOffset);var v=new o.RecognitionEventArgs(p.Offset+u.privRequestSession.currentTurnAudioOffset,u.privRequestSession.sessionId);u.privRecognizer.speechEndDetected&&u.privRecognizer.speechEndDetected(u.privRecognizer,v);break;case"turn.end":u.sendTelemetryData(),u.privRequestSession.isSpeechEnded&&u.privMustReportEndOfStream&&(u.privMustReportEndOfStream=!1,u.cancelRecognitionLocal(o.CancellationReason.EndOfStream,o.CancellationErrorCode.NoError,void 0));var f=new o.SessionEventArgs(u.privRequestSession.sessionId);if(u.privRequestSession.onServiceTurnEndResponse(u.privRecognizerConfig.isContinuousRecognition),!u.privRecognizerConfig.isContinuousRecognition||u.privRequestSession.isSpeechEnded||!u.privRequestSession.isRecognizing)return u.privRecognizer.sessionStopped&&u.privRecognizer.sessionStopped(u.privRecognizer,f),i.PromiseHelper.fromResult(!0);u.fetchConnection().onSuccessContinueWith(function(e){u.sendSpeechContext(e),u.sendWaveHeader(e)});break;default:u.processTypeSpecificMessages(t)||u.privServiceEvents&&u.serviceEvents.onEvent(new i.ServiceEvent(t.path.toLowerCase(),t.textBody))}return u.receiveMessage()})},function(e){})},this.sendSpeechContext=function(e){var t=u.speechContext.toJSON();return t?e.send(new a.SpeechConnectionMessage(i.MessageType.Text,"speech.context",u.privRequestSession.requestId,"application/json",t)):i.PromiseHelper.fromResult(!0)},this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.fetchConnectionOverride=void 0,this.sendSpeechServiceConfig=function(t,r,n){if(!0!==e.telemetryDataEnabled){var o=JSON.parse(n),s={context:{system:o.context.system}};n=JSON.stringify(s)}return n?t.send(new a.SpeechConnectionMessage(i.MessageType.Text,"speech.config",r.requestId,"application/json",n)):i.PromiseHelper.fromResult(!0)},this.sendAudio=function(e){return u.audioSource.format.onSuccessContinueWithPromise(function(t){var r=new i.Deferred,n=Date.now(),o=u.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(o,10),c=u.privRequestSession.recogNumber,p=function(){u.privIsDisposed||u.privRequestSession.isSpeechEnded||!u.privRequestSession.isRecognizing||u.privRequestSession.recogNumber!==c||u.fetchConnection().on(function(o){e.read().on(function(e){var c,v;u.privRequestSession.isSpeechEnded?r.resolve(!0):(!e||e.isEnd?(c=null,v=0):(c=e.buffer,u.privRequestSession.onAudioSent(c.byteLength),v=s>=u.privRequestSession.bytesSent?0:Math.max(0,n-Date.now())),setTimeout(function(){var s;null!==c&&(n=Date.now()+1e3*c.byteLength/(2*t.avgBytesPerSec));var v=o.send(new a.SpeechConnectionMessage(i.MessageType.Binary,"audio",u.privRequestSession.requestId,null,c));(null===(s=e)||void 0===s?void 0:s.isEnd)?(u.privRequestSession.onSpeechEnded(),r.resolve(!0)):v.continueWith(function(e){p()})},v))},function(e){u.privRequestSession.isSpeechEnded?r.resolve(!0):r.reject(e)})},function(e){r.reject(e)})};return p(),r.promise()})},this.fetchConnection=function(){return void 0!==u.fetchConnectionOverride?u.fetchConnectionOverride():u.configureConnection()},!t)throw new i.ArgumentNullError("authentication");if(!r)throw new i.ArgumentNullError("connectionFactory");if(!n)throw new i.ArgumentNullError("audioSource");if(!c)throw new i.ArgumentNullError("recognizerConfig");this.privMustReportEndOfStream=!1,this.privAuthentication=t,this.privConnectionFactory=r,this.privAudioSource=n,this.privRecognizerConfig=c,this.privIsDisposed=!1,this.privRecognizer=p,this.privRequestSession=new s.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new i.EventSource,this.privServiceEvents=new i.EventSource,this.privDynamicGrammar=new s.DynamicGrammarBuilder,this.privSpeechContext=new s.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new s.AgentConfig}return Object.defineProperty(e.prototype,"audioSource",{get:function(){return this.privAudioSource},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speechContext",{get:function(){return this.privSpeechContext},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dynamicGrammar",{get:function(){return this.privDynamicGrammar},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"agentConfig",{get:function(){return this.privAgentConfig},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"conversationTranslatorToken",{set:function(e){this.privRecognizerConfig.parameters.setProperty(o.PropertyId.ConversationTranslator_Token,e)},enumerable:!0,configurable:!0}),e.prototype.isDisposed=function(){return this.privIsDisposed},e.prototype.dispose=function(e){this.privIsDisposed=!0,this.privConnectionConfigurationPromise&&this.privConnectionConfigurationPromise.onSuccessContinueWith(function(t){t.dispose(e)})},Object.defineProperty(e.prototype,"connectionEvents",{get:function(){return this.privConnectionEvents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"serviceEvents",{get:function(){return this.privServiceEvents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recognitionMode",{get:function(){return this.privRecognizerConfig.recognitionMode},enumerable:!0,configurable:!0}),e.prototype.recognize=function(e,t,r){var s=this;return void 0!==this.recognizeOverride?this.recognizeOverride(e,t,r):(this.privConnectionConfigurationPromise=null,this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events),this.connectImpl(),this.audioSource.attach(this.privRequestSession.audioNodeId).onSuccessContinueWithPromise(function(e){var t;return s.audioSource.format.onSuccessContinueWithPromise(function(r){return t=new n.ReplayableAudioNode(e,r.avgBytesPerSec),s.privRequestSession.onAudioSourceAttachCompleted(t,!1),s.audioSource.deviceInfo.onSuccessContinueWithPromise(function(e){return s.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:e},s.configureConnection().continueWithPromise(function(e){if(e.isError)return s.cancelRecognitionLocal(o.CancellationReason.Error,o.CancellationErrorCode.ConnectionFailure,e.error),i.PromiseHelper.fromError(e.error);var r=new o.SessionEventArgs(s.privRequestSession.sessionId);s.privRecognizer.sessionStarted&&s.privRecognizer.sessionStarted(s.privRecognizer,r);s.receiveMessage();var n=s.sendAudio(t);return n.on(function(e){},function(e){s.cancelRecognitionLocal(o.CancellationReason.Error,o.CancellationErrorCode.RuntimeError,e)}),i.PromiseHelper.fromResult(!0)})})})}))},e.prototype.stopRecognizing=function(){var e=this;return this.privRequestSession.isRecognizing?(this.audioSource.turnOff(),this.sendFinalAudio().onSuccessContinueWithPromise(function(t){return e.privRequestSession.onStopRecognizing(),e.privRequestSession.turnCompletionPromise.onSuccessContinueWith(function(t){return e.privRequestSession.onStopRecognizing(),e.privRequestSession.dispose(),!0})})):i.PromiseHelper.fromResult(!0)},e.prototype.connect=function(){this.connectImpl().result()},e.prototype.connectAsync=function(e,t){this.connectImpl().continueWith(function(r){try{r.isError?t&&t(r.error):r.isCompleted&&e&&e()}catch(e){t&&t(e)}})},e.prototype.disconnect=function(){void 0===this.disconnectOverride?(this.cancelRecognitionLocal(o.CancellationReason.Error,o.CancellationErrorCode.NoError,"Disconnecting"),this.privConnectionPromise.result().isCompleted?this.privConnectionPromise.result().isError||(this.privConnectionPromise.result().result.dispose(),this.privConnectionPromise=null):this.privConnectionPromise.onSuccessContinueWith(function(e){e.dispose()})):this.disconnectOverride()},e.prototype.disconnectAsync=function(e,t){try{if(void 0!==this.disconnectOverride)return this.disconnectOverride(),void(e&&e());this.cancelRecognitionLocal(o.CancellationReason.Error,o.CancellationErrorCode.NoError,"Disconnecting"),this.privConnectionPromise.continueWith(function(r){try{r.isError?t&&t(r.error):r.isCompleted&&(r.result.dispose(),e&&e())}catch(e){t&&t(e)}})}catch(e){t&&t(e)}},e.prototype.sendMessage=function(e){},Object.defineProperty(e.prototype,"activityTemplate",{get:function(){return this.privActivityTemplate},set:function(e){this.privActivityTemplate=e},enumerable:!0,configurable:!0}),e.prototype.cancelRecognitionLocal=function(e,t,r){this.privRequestSession.isRecognizing&&(this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))},e.prototype.sendWaveHeader=function(e){var t=this;return this.audioSource.format.onSuccessContinueWithPromise(function(r){return e.send(new a.SpeechConnectionMessage(i.MessageType.Binary,"audio",t.privRequestSession.requestId,"audio/x-wav",r.header))})},e.prototype.connectImpl=function(e){var t=this;if(void 0===e&&(e=!1),void 0!==this.connectImplOverride)return this.connectImplOverride(e);if(this.privConnectionPromise)return this.privConnectionPromise.result().isCompleted&&(this.privConnectionPromise.result().isError||this.privConnectionPromise.result().result.state()===i.ConnectionState.Disconnected)&&!0===this.privServiceHasSentMessage?(this.privConnectionId=null,this.privConnectionPromise=null,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise;this.privAuthFetchEventId=i.createNoDashGuid(),this.privConnectionId=i.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);var r=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=r.continueWithPromise(function(r){if(r.isError)throw t.privRequestSession.onAuthCompleted(!0,r.error),new Error(r.error);t.privRequestSession.onAuthCompleted(!1);var n=t.privConnectionFactory.create(t.privRecognizerConfig,r.result,t.privConnectionId);return t.privRequestSession.listenForServiceTelemetry(n.events),n.events.attach(function(e){t.connectionEvents.onEvent(e)}),n.open().onSuccessContinueWithPromise(function(r){return 200===r.statusCode?(t.privRequestSession.onPreConnectionStart(t.privAuthFetchEventId,t.privConnectionId),t.privRequestSession.onConnectionEstablishCompleted(r.statusCode),i.PromiseHelper.fromResult(n)):403!==r.statusCode||e?(t.privRequestSession.onConnectionEstablishCompleted(r.statusCode,r.reason),i.PromiseHelper.fromError("Unable to contact server. StatusCode: "+r.statusCode+", "+t.privRecognizerConfig.parameters.getProperty(o.PropertyId.SpeechServiceConnection_Endpoint)+" Reason: "+r.reason)):t.connectImpl(!0)})}),this.privConnectionPromise},e.prototype.writeBufferToConsole=function(e){var t="Buffer Size: ";if(null===e)t+="null";else{var r=new Uint8Array(e);t+=e.byteLength+"\r\n";for(var n=0;n0&&(o=e.parseHeaders(a[0]),a.length>1&&(s=a[1]))}r.resolve(new n.ConnectionMessage(t.messageType,s,o,t.id))}else if(t.messageType===n.MessageType.Binary){var c=t.binaryContent;o={},s=null;if(!c||c.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");var p=new DataView(c),u=p.getInt16(0);if(c.byteLengthu+2&&(s=c.slice(2+u)),r.resolve(new n.ConnectionMessage(t.messageType,s,o,t.id))}}catch(e){r.reject("Error formatting the message. Error: "+e)}return r.promise()},this.fromConnectionMessage=function(t){var r=new n.Deferred;try{if(t.messageType===n.MessageType.Text){var o=""+e.makeHeaders(t)+i+(t.textBody?t.textBody:"");r.resolve(new n.RawWebsocketMessage(n.MessageType.Text,o,t.id))}else if(t.messageType===n.MessageType.Binary){var s=e.makeHeaders(t),a=t.binaryBody,c=new Int8Array(e.stringToArrayBuffer(s)),p=(o=new ArrayBuffer(2+c.byteLength+(a?a.byteLength:0)),new DataView(o));p.setInt16(0,c.length);for(var u=0;u0?o.substr(0,s).trim().toLowerCase():o,c=s>0&&o.length>s+1?o.substr(s+1).trim():"";t[a]=c}}}return t},this.stringToArrayBuffer=function(e){for(var t=new ArrayBuffer(e.length),r=new DataView(t),n=0;n0&&e.push({PhraseLatencyMs:o.privPhraseLatencies}),o.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:o.privHypothesisLatencies});var t={Metrics:e,ReceivedMessages:o.privReceivedMessages},r=JSON.stringify(t);return o.privReceivedMessages={},o.privListeningTriggerMetric=null,o.privMicMetric=null,o.privConnectionEstablishMetric=null,o.privPhraseLatencies=[],o.privHypothesisLatencies=[],r},this.dispose=function(){o.privIsDisposed=!0},this.getConnectionError=function(e){switch(e){case 400:case 1002:case 1003:case 1005:case 1007:case 1008:case 1009:return"BadRequest";case 401:return"Unauthorized";case 403:return"Forbidden";case 503:case 1001:return"ServerUnavailable";case 500:case 1011:return"ServerError";case 408:case 504:return"Timeout";default:return"statuscode:"+e.toString()}},this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}return e.prototype.phraseReceived=function(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)},e.prototype.hypothesisReceived=function(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)},Object.defineProperty(e.prototype,"hasTelemetry",{get:function(){return 0!==Object.keys(this.privReceivedMessages).length||null!==this.privListeningTriggerMetric||null!==this.privMicMetric||null!==this.privConnectionEstablishMetric||0!==this.privPhraseLatencies.length||0!==this.privHypothesisLatencies.length},enumerable:!0,configurable:!0}),e}();t.ServiceTelemetryListener=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privContext={},this.privDynamicGrammar=e}return e.prototype.setSection=function(e,t){this.privContext[e]=t},e.prototype.toJSON=function(){var e=this.privDynamicGrammar.generateGrammarObject();this.setSection("dgi",e);var t=JSON.stringify(this.privContext);return t},e}();t.SpeechContext=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.addPhrase=function(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)},e.prototype.clearPhrases=function(){this.privPhrases=void 0},e.prototype.addReferenceGrammar=function(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)},e.prototype.clearGrammars=function(){this.privGrammars=void 0},e.prototype.generateGrammarObject=function(){if(void 0!==this.privGrammars||void 0!==this.privPhrases){var e={};if(e.ReferenceGrammars=this.privGrammars,void 0!==this.privPhrases&&0!==this.privPhrases.length){var t=[];this.privPhrases.forEach(function(e,r,n){t.push({Text:e})}),e.Groups=[{Type:"Generic",Items:t}]}return e}},e}();t.DynamicGrammarBuilder=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),s=r(4),a=r(30),c=r(131),p=r(25),u=r(133),v=r(107),f=function(e){function t(t,r,n,i,u){var f=e.call(this,t,r,n,i,u)||this;return f.sendMessage=function(e){var t=s.createGuid(),r=s.createNoDashGuid(),n={context:{interactionId:t},messagePayload:e,version:.5},i=JSON.stringify(n);f.fetchDialogConnection().onSuccessContinueWith(function(e){e.send(new v.SpeechConnectionMessage(s.MessageType.Text,"agent",r,"application/json",i))})},f.listenOnce=function(e,t,r){return f.privRecognizerConfig.recognitionMode=e,f.privSuccessCallback=t,f.privErrorCallback=r,f.privDialogRequestSession.startNewRecognition(),f.privDialogRequestSession.listenForServiceTelemetry(f.privDialogAudioSource.events),f.dialogConnectImpl(),f.sendPreAudioMessages(),f.privDialogAudioSource.attach(f.privDialogRequestSession.audioNodeId).continueWithPromise(function(e){var t;return e.isError?(f.cancelRecognition(f.privDialogRequestSession.sessionId,f.privDialogRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.ConnectionFailure,e.error),s.PromiseHelper.fromError(e.error)):f.privDialogAudioSource.format.onSuccessContinueWithPromise(function(r){return t=new o.ReplayableAudioNode(e.result,r.avgBytesPerSec),f.privDialogRequestSession.onAudioSourceAttachCompleted(t,!1),f.privDialogAudioSource.deviceInfo.onSuccessContinueWithPromise(function(e){return f.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:e},f.configConnection().continueWithPromise(function(e){if(e.isError)return f.cancelRecognitionLocal(a.CancellationReason.Error,a.CancellationErrorCode.ConnectionFailure,e.error),s.PromiseHelper.fromError(e.error);var r=new a.SessionEventArgs(f.privDialogRequestSession.sessionId);f.privRecognizer.sessionStarted&&f.privRecognizer.sessionStarted(f.privRecognizer,r);var n=f.sendAudio(t);return n.on(function(e){},function(e){f.cancelRecognition(f.privDialogRequestSession.sessionId,f.privDialogRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.RuntimeError,e)}),s.PromiseHelper.fromResult(!0)})})})})},f.sendAudio=function(e){return f.privDialogAudioSource.format.onSuccessContinueWithPromise(function(t){var r=new s.Deferred,n=Date.now(),i=f.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),o=t.avgBytesPerSec/1e3*parseInt(i,10),a=f.privDialogRequestSession.recogNumber,c=function(){f.privDialogIsDisposed||f.privDialogRequestSession.isSpeechEnded||!f.privDialogRequestSession.isRecognizing||f.privDialogRequestSession.recogNumber!==a||f.fetchDialogConnection().on(function(i){e.read().on(function(e){var a,p;f.privDialogRequestSession.isSpeechEnded?r.resolve(!0):(!e||e.isEnd?(a=null,p=0):(a=e.buffer,f.privDialogRequestSession.onAudioSent(a.byteLength),p=o>=f.privDialogRequestSession.bytesSent?0:Math.max(0,n-Date.now())),setTimeout(function(){null!==a&&(n=Date.now()+1e3*a.byteLength/(2*t.avgBytesPerSec));var o=i.send(new v.SpeechConnectionMessage(s.MessageType.Binary,"audio",f.privDialogRequestSession.requestId,null,a));e&&!e.isEnd?o.continueWith(function(e){c()}):(f.privDialogRequestSession.onSpeechEnded(),r.resolve(!0))},p))},function(e){f.privDialogRequestSession.isSpeechEnded?r.resolve(!0):r.reject(e)})},function(e){r.reject(e)})};return c(),r.promise()})},f.receiveDialogMessageOverride=function(){var e=new s.Deferred;return f.fetchDialogConnection().on(function(t){return t.read().onSuccessContinueWithPromise(function(t){var r=f.isDisposed(),n=!f.isDisposed()&&f.terminateMessageLoop;if(r||n)return e.resolve(void 0),s.PromiseHelper.fromResult(void 0);if(!t)return f.receiveDialogMessageOverride();var i=v.SpeechConnectionMessage.fromConnectionMessage(t);switch(i.path.toLowerCase()){case"turn.start":var o=i.requestId.toUpperCase(),c=f.privDialogRequestSession.requestId.toUpperCase();o!==c?f.privTurnStateManager.StartTurn(o):f.privDialogRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":var u=p.SpeechDetected.fromJSON(i.textBody),h=new a.RecognitionEventArgs(u.Offset,f.privDialogRequestSession.sessionId);f.privRecognizer.speechStartDetected&&f.privRecognizer.speechStartDetected(f.privRecognizer,h);break;case"speech.enddetected":var l=void 0;l=i.textBody.length>0?i.textBody:"{ Offset: 0 }";var d=p.SpeechDetected.fromJSON(l);f.privDialogRequestSession.onServiceRecognized(d.Offset+f.privDialogRequestSession.currentTurnAudioOffset);var g=new a.RecognitionEventArgs(d.Offset+f.privDialogRequestSession.currentTurnAudioOffset,f.privDialogRequestSession.sessionId);f.privRecognizer.speechEndDetected&&f.privRecognizer.speechEndDetected(f.privRecognizer,g);break;case"turn.end":var y=i.requestId.toUpperCase();c=f.privDialogRequestSession.requestId.toUpperCase();if(y!==c)f.privTurnStateManager.CompleteTurn(y);else{var m=new a.SessionEventArgs(f.privDialogRequestSession.sessionId);if(f.privDialogRequestSession.onServiceTurnEndResponse(!1),f.privDialogRequestSession.isSpeechEnded&&f.privRecognizer.sessionStopped&&f.privRecognizer.sessionStopped(f.privRecognizer,m),f.privSuccessCallback&&f.privLastResult){try{f.privSuccessCallback(f.privLastResult),f.privLastResult=null}catch(e){f.privErrorCallback&&f.privErrorCallback(e)}f.privSuccessCallback=void 0, f.privErrorCallback=void 0}}break;default:f.processTypeSpecificMessages(i)||f.serviceEvents&&f.serviceEvents.onEvent(new s.ServiceEvent(i.path.toLowerCase(),i.textBody))}return f.receiveDialogMessageOverride()})},function(t){return f.terminateMessageLoop=!0,e.resolve(void 0),s.PromiseHelper.fromResult(void 0)}),e.promise()},f.fetchDialogConnection=function(){return f.configConnection()},f.sendAgentConfig=function(e){if(f.agentConfig&&!f.agentConfigSent){if("custom_commands"===f.privRecognizerConfig.parameters.getProperty(a.PropertyId.Conversation_DialogType)){var t=f.agentConfig.get();t.botInfo.commandsCulture=f.privRecognizerConfig.parameters.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),f.agentConfig.set(t)}var r=f.agentConfig.toJsonString();return f.agentConfigSent=!0,e.send(new v.SpeechConnectionMessage(s.MessageType.Text,"agent.config",f.privDialogRequestSession.requestId,"application/json",r))}return s.PromiseHelper.fromResult(!0)},f.sendAgentContext=function(e){var t=s.createGuid(),r=f.privDialogServiceConnector.properties.getProperty(a.PropertyId.Conversation_Speech_Activity_Template),n={channelData:"",context:{interactionId:t},messagePayload:void 0===typeof r?void 0:r,version:.5},i=JSON.stringify(n);return e.send(new v.SpeechConnectionMessage(s.MessageType.Text,"speech.agent.context",f.privDialogRequestSession.requestId,"application/json",i))},f.privDialogServiceConnector=u,f.privDialogAuthentication=t,f.receiveMessageOverride=f.receiveDialogMessageOverride,f.privTurnStateManager=new c.DialogServiceTurnStateManager,f.recognizeOverride=f.listenOnce,f.connectImplOverride=f.dialogConnectImpl,f.configConnectionOverride=f.configConnection,f.fetchConnectionOverride=f.fetchDialogConnection,f.disconnectOverride=f.privDisconnect,f.privDialogAudioSource=n,f.privDialogRequestSession=new p.RequestSession(n.id()),f.privDialogConnectionFactory=r,f.privDialogIsDisposed=!1,f.agentConfigSent=!1,f.privLastResult=null,f}return i(t,e),t.prototype.isDisposed=function(){return this.privDialogIsDisposed},t.prototype.dispose=function(e){this.privDialogIsDisposed=!0,this.privConnectionConfigPromise&&this.privConnectionConfigPromise.onSuccessContinueWith(function(t){t.dispose(e)})},t.prototype.privDisconnect=function(){this.cancelRecognition(this.privDialogRequestSession.sessionId,this.privDialogRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1,this.privDialogConnectionPromise.result().isCompleted?this.privDialogConnectionPromise.result().isError||(this.privDialogConnectionPromise.result().result.dispose(),this.privDialogConnectionPromise=null):this.privDialogConnectionPromise.onSuccessContinueWith(function(e){e.dispose()})},t.prototype.processTypeSpecificMessages=function(e){var t,r,n=new a.PropertyCollection;switch(e.messageType===s.MessageType.Text&&n.setProperty(a.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.phrase":var i=p.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privDialogRequestSession.onPhraseRecognized(this.privDialogRequestSession.currentTurnAudioOffset+i.Offset+i.Duration),i.RecognitionStatus===p.RecognitionStatus.Success){var o=this.fireEventForResult(i,n);if(this.privLastResult=o.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,o)}catch(e){}}r=!0;break;case"speech.hypothesis":var c=p.SpeechHypothesis.fromJSON(e.textBody),v=c.Offset+this.privDialogRequestSession.currentTurnAudioOffset;t=new a.SpeechRecognitionResult(this.privDialogRequestSession.requestId,a.ResultReason.RecognizingSpeech,c.Text,c.Duration,v,void 0,e.textBody,n),this.privDialogRequestSession.onHypothesis(v);var f=new a.SpeechRecognitionEventArgs(t,c.Duration,this.privDialogRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,f)}catch(e){}r=!0;break;case"audio":var h=e.requestId.toUpperCase(),l=this.privTurnStateManager.GetTurn(h);try{e.binaryBody?l.audioStream.write(e.binaryBody):l.endAudioStream()}catch(e){}r=!0;break;case"response":var d=e.requestId.toUpperCase(),g=u.ActivityPayloadResponse.fromJSON(e.textBody);l=this.privTurnStateManager.GetTurn(d);if(g.conversationId){var y=this.agentConfig.get();y.botInfo.conversationId=g.conversationId,this.agentConfig.set(y)}var m=l.processActivityPayload(g),S=new a.ActivityReceivedEventArgs(g.messagePayload,m);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,S)}catch(e){}r=!0}return r},t.prototype.cancelRecognition=function(e,t,r,n,i){if(this.terminateMessageLoop=!0,this.privDialogRequestSession.isRecognizing&&this.privDialogRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){var o=new a.PropertyCollection;o.setProperty(p.CancellationErrorCodePropertyName,a.CancellationErrorCode[n]);var s=new a.SpeechRecognitionCanceledEventArgs(r,i,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,s)}catch(e){}if(this.privSuccessCallback){var c=new a.SpeechRecognitionResult(void 0,a.ResultReason.Canceled,void 0,void 0,void 0,i,void 0,o);try{this.privSuccessCallback(c),this.privSuccessCallback=void 0}catch(e){}}}},t.prototype.sendWaveHeader=function(e){var t=this;return this.audioSource.format.onSuccessContinueWithPromise(function(r){return e.send(new v.SpeechConnectionMessage(s.MessageType.Binary,"audio",t.privDialogRequestSession.requestId,"audio/x-wav",r.header))})},t.prototype.dialogConnectImpl=function(e){var t=this;if(void 0===e&&(e=!1),this.privDialogConnectionPromise)return this.privDialogConnectionPromise.result().isCompleted&&(this.privDialogConnectionPromise.result().isError||this.privDialogConnectionPromise.result().result.state()===s.ConnectionState.Disconnected)?(this.agentConfigSent=!1,this.privDialogConnectionPromise=null,this.terminateMessageLoop=!0,this.configConnection()):this.privDialogConnectionPromise;this.privDialogAuthFetchEventId=s.createNoDashGuid(),void 0===this.privConnectionId&&(this.privConnectionId=s.createNoDashGuid()),this.privDialogRequestSession.onPreConnectionStart(this.privDialogAuthFetchEventId,this.privConnectionId);var r=e?this.privDialogAuthentication.fetchOnExpiry(this.privDialogAuthFetchEventId):this.privDialogAuthentication.fetch(this.privDialogAuthFetchEventId);return this.privDialogConnectionPromise=r.continueWithPromise(function(r){if(r.isError)throw t.privDialogRequestSession.onAuthCompleted(!0,r.error),new Error(r.error);t.privDialogRequestSession.onAuthCompleted(!1);var n=t.privDialogConnectionFactory.create(t.privRecognizerConfig,r.result,t.privConnectionId);return t.privDialogRequestSession.listenForServiceTelemetry(n.events),n.events.attach(function(e){t.connectionEvents.onEvent(e)}),n.open().onSuccessContinueWithPromise(function(r){return 200===r.statusCode?(t.privDialogRequestSession.onPreConnectionStart(t.privDialogAuthFetchEventId,t.privConnectionId),t.privDialogRequestSession.onConnectionEstablishCompleted(r.statusCode),s.PromiseHelper.fromResult(n)):403!==r.statusCode||e?(t.privDialogRequestSession.onConnectionEstablishCompleted(r.statusCode,r.reason),s.PromiseHelper.fromError("Unable to contact server. StatusCode: "+r.statusCode+", "+t.privRecognizerConfig.parameters.getProperty(a.PropertyId.SpeechServiceConnection_Endpoint)+" Reason: "+r.reason)):t.dialogConnectImpl(!0)})}),this.privConnectionLoop=this.startMessageLoop(),this.privDialogConnectionPromise},t.prototype.startMessageLoop=function(){var e=this;this.terminateMessageLoop=!1;var t=this.receiveDialogMessageOverride();return t.on(function(e){return!0},function(t){e.cancelRecognition(e.privDialogRequestSession.sessionId,e.privDialogRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.RuntimeError,t)})},t.prototype.configConnection=function(){var e=this;return this.privConnectionConfigPromise?this.privConnectionConfigPromise.result().isCompleted&&(this.privConnectionConfigPromise.result().isError||this.privConnectionConfigPromise.result().result.state()===s.ConnectionState.Disconnected)?(this.privConnectionConfigPromise=null,this.configConnection()):this.privConnectionConfigPromise:this.terminateMessageLoop?(this.terminateMessageLoop=!1,s.PromiseHelper.fromError("Connection to service terminated.")):(this.privConnectionConfigPromise=this.dialogConnectImpl().onSuccessContinueWithPromise(function(t){return e.sendSpeechServiceConfig(t,e.privDialogRequestSession,e.privRecognizerConfig.SpeechServiceConfig.serialize()).onSuccessContinueWithPromise(function(r){return e.sendAgentConfig(t).onSuccessContinueWith(function(e){return t})})}),this.privConnectionConfigPromise)},t.prototype.sendPreAudioMessages=function(){var e=this;this.fetchDialogConnection().onSuccessContinueWith(function(t){e.sendAgentContext(t),e.sendWaveHeader(t)})},t.prototype.fireEventForResult=function(e,t){var r=p.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privDialogRequestSession.currentTurnAudioOffset,i=new a.SpeechRecognitionResult(this.privDialogRequestSession.requestId,r,e.DisplayText,e.Duration,n,void 0,JSON.stringify(e),t),o=new a.SpeechRecognitionEventArgs(i,n,this.privDialogRequestSession.sessionId);return o},t}(p.ServiceRecognizerBase);t.DialogServiceAdapter=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(10),i=r(132),o=function(){function e(){this.privTurnMap=new Map}return e.prototype.StartTurn=function(e){if(this.privTurnMap.has(e))throw new n.InvalidOperationError("Service error: There is already a turn with id:"+e);var t=new i.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)},e.prototype.GetTurn=function(e){return this.privTurnMap.get(e)},e.prototype.CompleteTurn=function(e){if(!this.privTurnMap.has(e))throw new n.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);var t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t},e}();t.DialogServiceTurnStateManager=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(37),i=r(36),o=r(133),s=function(){function e(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}return Object.defineProperty(e.prototype,"audioStream",{get:function(){return this.resetTurnEndTimeout(),this.privAudioStream},enumerable:!0,configurable:!0}),e.prototype.processActivityPayload=function(e){return e.messageDataStreamType===o.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=i.AudioOutputStream.createPullStream(),this.privAudioStream.format=n.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream},e.prototype.endAudioStream=function(){null===this.privAudioStream||this.privAudioStream.isClosed||this.privAudioStream.close()},e.prototype.complete=function(){void 0!==this.privTimeoutToken&&clearTimeout(this.privTimeoutToken),this.endAudioStream()},e.prototype.resetTurnEndTimeout=function(){var e=this;void 0!==this.privTimeoutToken&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout(function(){e.privTurnManager.CompleteTurn(e.privRequestId)},2e3)},e}();t.DialogServiceTurnState=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privActivityResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"conversationId",{get:function(){return this.privActivityResponse.conversationId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"messageDataStreamType",{get:function(){return this.privActivityResponse.messageDataStreamType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"messagePayload",{get:function(){return this.privActivityResponse.messagePayload},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this.privActivityResponse.version},enumerable:!0,configurable:!0}),e}();t.ActivityPayloadResponse=n,function(e){e[e.None=0]="None",e[e.TextToSpeechAudio=1]="TextToSpeechAudio"}(t.MessageDataStreamType||(t.MessageDataStreamType={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.prototype.toJsonString=function(){return JSON.stringify(this.iPrivConfig)},e.prototype.get=function(){return this.iPrivConfig},e.prototype.set=function(e){this.iPrivConfig=e},e}();t.AgentConfig=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(136);t.ConversationManager=n.ConversationManager;var i=r(137);t.ConversationTranslatorConfig=i.ConversationTranslatorConfig;var o=r(138);t.ConversationTranslatorRecognizer=o.ConversationTranslatorRecognizer;var s=r(144);t.ConversationReceivedTranslationEventArgs=s.ConversationReceivedTranslationEventArgs,t.LockRoomEventArgs=s.LockRoomEventArgs,t.MuteAllEventArgs=s.MuteAllEventArgs,t.ParticipantAttributeEventArgs=s.ParticipantAttributeEventArgs,t.ParticipantEventArgs=s.ParticipantEventArgs,t.ParticipantsListEventArgs=s.ParticipantsListEventArgs;var a=r(145);t.ConversationTranslatorCommandTypes=a.ConversationTranslatorCommandTypes,t.ConversationTranslatorMessageTypes=a.ConversationTranslatorMessageTypes,t.InternalParticipants=a.InternalParticipants},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(32),i=r(30),o=r(137),s=function(){function e(){}return e.prototype.createOrJoin=function(e,t,r,s){try{n.Contracts.throwIfNullOrUndefined(e,"args");var a=e.getProperty(i.PropertyId.SpeechServiceConnection_RecoLanguage,o.ConversationTranslatorConfig.defaultLanguageCode),c=e.getProperty(i.PropertyId.ConversationTranslator_Name),p=e.getProperty(i.PropertyId.ConversationTranslator_Host,o.ConversationTranslatorConfig.host),u=e.getProperty(i.PropertyId.ConversationTranslator_CorrelationId),v=e.getProperty(i.PropertyId.SpeechServiceConnection_Key),f=e.getProperty(i.PropertyId.SpeechServiceConnection_Region),h=e.getProperty(i.PropertyId.SpeechServiceAuthorization_Token);n.Contracts.throwIfNullOrWhitespace(a,"languageCode"),n.Contracts.throwIfNullOrWhitespace(c,"nickname"),n.Contracts.throwIfNullOrWhitespace(p,"endpointHost");var l={};l[o.ConversationTranslatorConfig.params.apiVersion]=o.ConversationTranslatorConfig.apiVersion,l[o.ConversationTranslatorConfig.params.languageCode]=a,l[o.ConversationTranslatorConfig.params.nickname]=c;var d={};u&&(d[o.ConversationTranslatorConfig.params.correlationId]=u),d[o.ConversationTranslatorConfig.params.clientAppId]=o.ConversationTranslatorConfig.clientAppId,void 0!==t?l[o.ConversationTranslatorConfig.params.roomId]=t:(n.Contracts.throwIfNullOrUndefined(f,o.ConversationTranslatorConfig.strings.authInvalidSubscriptionRegion),d[o.ConversationTranslatorConfig.params.subscriptionRegion]=f,v?d[o.ConversationTranslatorConfig.params.subscriptionKey]=v:h?d[o.ConversationTranslatorConfig.params.authorization]="Bearer "+h:n.Contracts.throwIfNullOrUndefined(v,o.ConversationTranslatorConfig.strings.authInvalidSubscriptionKey));var g={};g.headers=d;var y="https://"+p+o.ConversationTranslatorConfig.restPath;o.request("post",y,l,null,g,function(e){var t=o.extractHeaderValue(o.ConversationTranslatorConfig.params.requestId,e.headers);if(e.ok){var n=JSON.parse(e.data);if(n&&(n.requestId=t),r){try{r(n)}catch(e){s&&s(e)}r=void 0}}else if(s){var i=o.ConversationTranslatorConfig.strings.invalidCreateJoinConversationResponse.replace("{status}",e.status.toString()),a=void 0;try{a=JSON.parse(e.data),i+=" ["+a.error.code+": "+a.error.message+"]"}catch(t){i+=" ["+e.data+"]"}t&&(i+=" "+t),s(i)}})}catch(e){if(s)if(e instanceof Error){var m=e;s(m.name+": "+m.message)}else s(e)}},e.prototype.leave=function(e,t,r,s){try{n.Contracts.throwIfNullOrUndefined(e,o.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","config")),n.Contracts.throwIfNullOrWhitespace(t,o.ConversationTranslatorConfig.strings.invalidArgs.replace("{arg}","token"));var a=e.getProperty(i.PropertyId.ConversationTranslator_Host,o.ConversationTranslatorConfig.host),c=e.getProperty(i.PropertyId.ConversationTranslator_CorrelationId),p={};p[o.ConversationTranslatorConfig.params.apiVersion]=o.ConversationTranslatorConfig.apiVersion,p[o.ConversationTranslatorConfig.params.sessionToken]=t;var u={};c&&(u[o.ConversationTranslatorConfig.params.correlationId]=c);var v={};v.headers=u;var f="https://"+a+o.ConversationTranslatorConfig.restPath;o.request("delete",f,p,null,v,function(e){if(e.ok,r){try{r()}catch(e){s&&s(e)}r=void 0}})}catch(e){if(s)if(e instanceof Error){var h=e;s(h.name+": "+h.message)}else s(e)}},e}();t.ConversationManager=s},function(e,t,r){"use strict";function n(e){return void 0===e&&(e={}),Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}function i(e,t){void 0===t&&(t={});var r=n(t);return r?e+(-1===e.indexOf("?")?"?":"&")+r:e}function o(e){return{data:e.responseText,headers:e.getAllResponseHeaders(),json:function(){return JSON.parse(e.responseText)},ok:e.status>=200&&e.status<300,status:e.status,statusText:e.statusText}}function s(e,t){return void 0===t&&(t=null),{data:t||e.statusText,headers:e.getAllResponseHeaders(),json:function(){return JSON.parse(t||'"'+e.statusText+'"')},ok:!1,status:e.status,statusText:e.statusText}}function a(e,t){var r="";try{var n=t.trim().split(/[\r\n]+/),i={};n.forEach(function(e){var t=e.split(": "),r=t.shift().toLowerCase(),n=t.join(": ");i[r]=n}),r=i[e.toLowerCase()]}catch(e){}return r}function c(e,r,n,a,c,p){void 0===n&&(n={}),void 0===a&&(a=null),void 0===c&&(c=t.ConversationTranslatorConfig.defaultRequestOptions);var u=c.ignoreCache||t.ConversationTranslatorConfig.defaultRequestOptions.ignoreCache,v=c.headers||t.ConversationTranslatorConfig.defaultRequestOptions.headers,f=c.timeout||t.ConversationTranslatorConfig.defaultRequestOptions.timeout,h=new XMLHttpRequest;h.open(e,i(r,n),!0),v&&Object.keys(v).forEach(function(e){return h.setRequestHeader(e,v[e])}),u&&h.setRequestHeader("Cache-Control","no-cache"),h.timeout=f,h.onload=function(e){p(o(h))},h.onerror=function(e){p(s(h,"Failed to make request."))},h.ontimeout=function(e){p(s(h,"Request took longer than expected."))},"post"===e&&a?(h.setRequestHeader("Content-Type","application/json"),h.send(JSON.stringify(a))):h.send()}function p(e,t,r){e?e.continueWith(function(e){try{e.isError?r&&r(e.error):t&&t()}catch(t){r&&r("'Unhandled error on promise callback: "+t+". InnerError: "+e.error+"'")}}):r&&r("Null promise")}Object.defineProperty(t,"__esModule",{value:!0}),t.ConversationTranslatorConfig={apiVersion:"2.0",auth:{placeholderRegion:"westus",placeholderSubscriptionKey:"abcdefghijklmnopqrstuvwxyz012345"},clientAppId:"FC539C22-1767-4F1F-84BC-B4D811114F15",defaultLanguageCode:"en-US",defaultRequestOptions:{headers:{Accept:"application/json"},ignoreCache:!1,timeout:5e3},host:"dev.microsofttranslator.com",params:{apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",correlationId:"X-CorrelationId",languageCode:"language",nickname:"nickname",profanity:"profanity",requestId:"X-RequestId",roomId:"roomid",sessionToken:"token",subscriptionKey:"Ocp-Apim-Subscription-Key",subscriptionRegion:"Ocp-Apim-Subscription-Region",token:"X-CapitoToken"},restPath:"/capito/room",speechHost:"{region}.s2s.speech.microsoft.com",speechPath:"/speech/translation/cognitiveservices/v1",strings:{authInvalidSubscriptionKey:"You must specify either an authentication token to use, or a Cognitive Speech subscription key.",authInvalidSubscriptionRegion:"You must specify the Cognitive Speech region to use.",invalidArgs:"Required input not found: {arg}.",invalidCreateJoinConversationResponse:"Creating/Joining conversation failed with HTTP {status}.",invalidParticipantRequest:"The requested participant was not found.",permissionDeniedConnect:"Required credentials not found.",permissionDeniedConversation:"Invalid operation: only the host can {command} the conversation.",permissionDeniedParticipant:"Invalid operation: only the host can {command} a participant.",permissionDeniedSend:"Invalid operation: the conversation is not in a connected state.",permissionDeniedStart:"Invalid operation: there is already an active conversation."},textMessageMaxLength:1e3,webSocketPath:"/capito/translate"},t.extractHeaderValue=a,t.request=c,t.PromiseToEmptyCallback=p},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(25),s=r(32),a=r(30),c=r(139),p=r(142),u=r(145),v=r(137),f=function(e){function t(t,r){var n=this,i=t;return s.Contracts.throwIfNull(i,"speechConfig"),n=e.call(this,r,i.properties,new c.ConversationConnectionFactory)||this,n.privIsDisposed=!1,n.privProperties=i.properties.clone(),n}return i(t,e),Object.defineProperty(t.prototype,"conversation",{set:function(e){this.privRoom=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"speechRecognitionLanguage",{get:function(){return this.privSpeechRecognitionLanguage},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"properties",{get:function(){return this.privProperties},enumerable:!0,configurable:!0}),t.prototype.isDisposed=function(){return this.privIsDisposed},t.prototype.connect=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.privReco.connectAsync(t,r)}catch(e){if(r)if(e instanceof Error){var n=e;r(n.name+": "+n.message)}else r(e)}},t.prototype.disconnect=function(e,t){try{s.Contracts.throwIfDisposed(this.privIsDisposed),this.privRoom=void 0,this.privReco.disconnectAsync(e,t)}catch(e){if(t)if(e instanceof Error){var r=e;t(r.name+": "+r.message)}else t(e);this.dispose(!0)}},t.prototype.sendMessageRequest=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),s.Contracts.throwIfNullOrWhitespace(e,"message");var n={participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:u.ConversationTranslatorMessageTypes.instantMessage};this.sendMessage(JSON.stringify(n),t,r)}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e);this.dispose(!0)}},t.prototype.sendLockRequest=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),s.Contracts.throwIfNullOrUndefined(e,"isLocked");var n={command:u.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:u.ConversationTranslatorMessageTypes.participantCommand,value:e};this.sendMessage(JSON.stringify(n),t,r)}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e);this.dispose(!0)}},t.prototype.sendMuteAllRequest=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),s.Contracts.throwIfNullOrUndefined(e,"isMuted");var n={command:u.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:u.ConversationTranslatorMessageTypes.participantCommand,value:e};this.sendMessage(JSON.stringify(n),t,r)}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e);this.dispose(!0)}},t.prototype.sendMuteRequest=function(e,t,r,n){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId"),s.Contracts.throwIfNullOrUndefined(t,"isMuted");var i={command:u.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:u.ConversationTranslatorMessageTypes.participantCommand,value:t};this.sendMessage(JSON.stringify(i),r,n)}catch(e){if(n)if(e instanceof Error){var o=e;n(o.name+": "+o.message)}else n(e);this.dispose(!0)}},t.prototype.sendEjectRequest=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"participantId");var n={command:u.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:u.ConversationTranslatorMessageTypes.participantCommand};if(this.sendMessage(JSON.stringify(n),t,r),t)try{t()}catch(e){r&&r(e)}}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e);this.dispose(!0)}},t.prototype.sendChangeNicknameRequest=function(e,t,r){try{s.Contracts.throwIfDisposed(this.privIsDisposed),s.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),s.Contracts.throwIfNullOrWhitespace(e,"nickname");var n={command:u.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:u.ConversationTranslatorMessageTypes.participantCommand,value:e};this.sendMessage(JSON.stringify(n),t,r)}catch(e){if(r)if(e instanceof Error){var i=e;r(i.name+": "+i.message)}else r(e);this.dispose(!0)}},t.prototype.close=function(){s.Contracts.throwIfDisposed(this.privIsDisposed),this.dispose(!0)},t.prototype.dispose=function(t){this.privIsDisposed||t&&(this.privIsDisposed=!0,e.prototype.dispose.call(this,t))},t.prototype.createRecognizerConfig=function(e){return new o.RecognizerConfig(e,this.privProperties)},t.prototype.createServiceRecognizer=function(e,t,r,n){var i=r;return new p.ConversationServiceAdapter(e,t,i,n,this)},t.prototype.sendMessage=function(e,t,r){var n=this.privReco;v.PromiseToEmptyCallback(n.sendMessageAsync(e),t,r)},t}(a.Recognizer);t.ConversationTranslatorRecognizer=f},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),s=r(4),a=r(32),c=r(30),p=r(65),u=r(137),v=r(140),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.create=function(e,t,r){var n=e.parameters.getProperty(c.PropertyId.ConversationTranslator_Host,u.ConversationTranslatorConfig.host),i=e.parameters.getProperty(c.PropertyId.ConversationTranslator_CorrelationId,s.createGuid()),p="wss://"+n+u.ConversationTranslatorConfig.webSocketPath,f=e.parameters.getProperty(c.PropertyId.ConversationTranslator_Token,void 0);a.Contracts.throwIfNullOrUndefined(f,"token");var h={};return h[u.ConversationTranslatorConfig.params.apiVersion]=u.ConversationTranslatorConfig.apiVersion,h[u.ConversationTranslatorConfig.params.token]=f,h[u.ConversationTranslatorConfig.params.correlationId]=i,new o.WebsocketConnection(p,h,{},new v.ConversationWebsocketMessageFormatter,o.ProxyInfo.fromRecognizerConfig(e),r)},t}(p.ConnectionFactoryBase);t.ConversationConnectionFactory=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(141),o=function(){function e(){this.toConnectionMessage=function(e){var t=new n.Deferred;try{if(e.messageType===n.MessageType.Text){var r=new i.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===n.MessageType.Binary&&t.resolve(new i.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(e){t.reject("Error formatting the message. Error: "+e)}return t.promise()},this.fromConnectionMessage=function(e){var t=new n.Deferred;try{if(e.messageType===n.MessageType.Text){var r=""+(e.textBody?e.textBody:"");t.resolve(new n.RawWebsocketMessage(n.MessageType.Text,r,e.id))}}catch(e){t.reject("Error formatting the message. "+e)}return t.promise()}}return e}();t.ConversationWebsocketMessageFormatter=o},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=function(e){function t(t,r,n,i){var o=e.call(this,t,r,n,i)||this,s=JSON.parse(o.textBody);return void 0!==s.type&&(o.privConversationMessageType=s.type),o}return i(t,e),Object.defineProperty(t.prototype,"conversationMessageType",{get:function(){return this.privConversationMessageType},enumerable:!0,configurable:!0}),t}(o.ConnectionMessage);t.ConversationConnectionMessage=s},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=r(16),a=r(30),c=r(25),p=r(141),u=r(143),v=r(144),f=r(145),h=r(146),l=function(e){function t(t,r,n,i,c){var l=e.call(this,t,r,n,i,c)||this;return l.privUtteranceId="",l.sendMessageAsync=function(e){var t=new s.Sink;return l.fetchConversationConnection().continueWith(function(r){try{r.isError?t.reject(r.error):r.result.send(new p.ConversationConnectionMessage(o.MessageType.Text,e)).continueWith(function(e){try{e.isError?t.reject(e.error):t.resolve(e.result)}catch(e){t.reject("Unhandled inner error: "+e)}})}catch(e){t.reject("Unhandled error: "+e)}}),new o.Promise(t)},l.noOp=function(){},l.receiveConversationMessageOverride=function(e,t){var r=new o.Deferred;return l.fetchConversationConnection().on(function(e){return e.read().onSuccessContinueWithPromise(function(e){var t=l.isDisposed(),n=!l.isDisposed()&&l.terminateMessageLoop,i=l.privConversationRequestSession.sessionId;if(t||n)return r.resolve(void 0),o.PromiseHelper.fromResult(void 0);if(!e)return l.receiveConversationMessageOverride();try{switch(e.conversationMessageType.toLowerCase()){case"info":case"participant_command":case"command":var s=h.CommandResponsePayload.fromJSON(e.textBody);switch(s.command.toLowerCase()){case"participantlist":var c=h.ParticipantsListPayloadResponse.fromJSON(e.textBody),p=c.participants.map(function(e){var t={avatar:e.avatar,displayName:e.nickname,id:e.participantId,isHost:e.ishost,isMuted:e.ismuted,isUsingTts:e.usetts,preferredLanguage:e.locale};return t});l.privConversationServiceConnector.participantsListReceived&&l.privConversationServiceConnector.participantsListReceived(l.privConversationServiceConnector,new v.ParticipantsListEventArgs(c.roomid,c.token,c.translateTo,c.profanityFilter,c.roomProfanityFilter,c.roomLocked,c.muteAll,p,i));break;case"settranslatetolanguages": l.privConversationServiceConnector.participantUpdateCommandReceived&&l.privConversationServiceConnector.participantUpdateCommandReceived(l.privConversationServiceConnector,new v.ParticipantAttributeEventArgs(s.participantId,f.ConversationTranslatorCommandTypes.setTranslateToLanguages,s.value,i));break;case"setprofanityfiltering":l.privConversationServiceConnector.participantUpdateCommandReceived&&l.privConversationServiceConnector.participantUpdateCommandReceived(l.privConversationServiceConnector,new v.ParticipantAttributeEventArgs(s.participantId,f.ConversationTranslatorCommandTypes.setProfanityFiltering,s.value,i));break;case"setmute":l.privConversationServiceConnector.participantUpdateCommandReceived&&l.privConversationServiceConnector.participantUpdateCommandReceived(l.privConversationServiceConnector,new v.ParticipantAttributeEventArgs(s.participantId,f.ConversationTranslatorCommandTypes.setMute,s.value,i));break;case"setmuteall":l.privConversationServiceConnector.muteAllCommandReceived&&l.privConversationServiceConnector.muteAllCommandReceived(l.privConversationServiceConnector,new v.MuteAllEventArgs(s.value,i));break;case"roomexpirationwarning":l.privConversationServiceConnector.conversationExpiration&&l.privConversationServiceConnector.conversationExpiration(l.privConversationServiceConnector,new a.ConversationExpirationEventArgs(s.value,l.privConversationRequestSession.sessionId));break;case"setusetts":l.privConversationServiceConnector.participantUpdateCommandReceived&&l.privConversationServiceConnector.participantUpdateCommandReceived(l.privConversationServiceConnector,new v.ParticipantAttributeEventArgs(s.participantId,f.ConversationTranslatorCommandTypes.setUseTTS,s.value,i));break;case"setlockstate":l.privConversationServiceConnector.lockRoomCommandReceived&&l.privConversationServiceConnector.lockRoomCommandReceived(l.privConversationServiceConnector,new v.LockRoomEventArgs(s.value,i));break;case"changenickname":l.privConversationServiceConnector.participantUpdateCommandReceived&&l.privConversationServiceConnector.participantUpdateCommandReceived(l.privConversationServiceConnector,new v.ParticipantAttributeEventArgs(s.participantId,f.ConversationTranslatorCommandTypes.changeNickname,s.nickname,i));break;case"joinsession":var u=h.ParticipantPayloadResponse.fromJSON(e.textBody),d={avatar:u.avatar,displayName:u.nickname,id:u.participantId,isHost:u.ishost,isMuted:u.ismuted,isUsingTts:u.usetts,preferredLanguage:u.locale};l.privConversationServiceConnector.participantJoinCommandReceived&&l.privConversationServiceConnector.participantJoinCommandReceived(l.privConversationServiceConnector,new v.ParticipantEventArgs(d,i));break;case"leavesession":var g={id:s.participantId};l.privConversationServiceConnector.participantLeaveCommandReceived&&l.privConversationServiceConnector.participantLeaveCommandReceived(l.privConversationServiceConnector,new v.ParticipantEventArgs(g,i));break;case"disconnectsession":s.participantId}break;case"partial":case"final":var y=h.SpeechResponsePayload.fromJSON(e.textBody),m=new a.ConversationTranslationResult(y.participantId,l.getTranslations(y.translations),y.language,void 0,void 0,y.recognition,void 0,void 0,e.textBody,void 0);y.isFinal?void 0!==m.text&&m.text.length>0&&y.id!==l.privUtteranceId&&l.privConversationServiceConnector.translationReceived&&l.privConversationServiceConnector.translationReceived(l.privConversationServiceConnector,new v.ConversationReceivedTranslationEventArgs(f.ConversationTranslatorMessageTypes.final,m,i)):l.privConversationServiceConnector.translationReceived&&l.privConversationServiceConnector.translationReceived(l.privConversationServiceConnector,new v.ConversationReceivedTranslationEventArgs(f.ConversationTranslatorMessageTypes.partial,m,i)),l.privUtteranceId=y.id;break;case"translated_message":var S=h.TextResponsePayload.fromJSON(e.textBody),C=new a.ConversationTranslationResult(S.participantId,l.getTranslations(S.translations),S.language,void 0,void 0,S.originalText,void 0,void 0,void 0,e.textBody,void 0);l.privConversationServiceConnector.translationReceived&&l.privConversationServiceConnector.translationReceived(l.privConversationServiceConnector,new v.ConversationReceivedTranslationEventArgs(f.ConversationTranslatorMessageTypes.instantMessage,C,i))}}catch(e){}return l.receiveConversationMessageOverride()})},function(e){l.terminateMessageLoop=!0}),r.promise()},l.fetchConversationConnection=function(){return l.configConnection()},l.privConversationServiceConnector=c,l.privConversationAuthentication=t,l.receiveMessageOverride=l.receiveConversationMessageOverride,l.recognizeOverride=l.noOp,l.connectImplOverride=l.conversationConnectImpl,l.configConnectionOverride=l.configConnection,l.fetchConnectionOverride=l.fetchConversationConnection,l.disconnectOverride=l.privDisconnect,l.privConversationRequestSession=new u.ConversationRequestSession(o.createNoDashGuid()),l.privConversationConnectionFactory=r,l.privConversationIsDisposed=!1,l}return i(t,e),t.prototype.isDisposed=function(){return this.privConversationIsDisposed},t.prototype.dispose=function(e){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise&&this.privConnectionConfigPromise.onSuccessContinueWith(function(t){t.dispose(e)})},t.prototype.sendMessage=function(e){this.fetchConversationConnection().onSuccessContinueWith(function(t){t.send(new p.ConversationConnectionMessage(o.MessageType.Text,e))})},t.prototype.privDisconnect=function(){this.terminateMessageLoop||(this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,a.CancellationReason.Error,a.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.privConversationConnectionPromise.result().isCompleted?this.privConversationConnectionPromise.result().isError||(this.privConversationConnectionPromise.result().result.dispose(),this.privConversationConnectionPromise=null):this.privConversationConnectionPromise.onSuccessContinueWith(function(e){e.dispose()}))},t.prototype.processTypeSpecificMessages=function(e,t,r){return!0},t.prototype.cancelRecognition=function(e,t,r,n,i){this.terminateMessageLoop=!0;var o=new a.ConversationTranslationCanceledEventArgs(r,i,n,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch(e){}},t.prototype.conversationConnectImpl=function(e){var t=this;if(void 0===e&&(e=!1),this.privConversationConnectionPromise)return this.privConversationConnectionPromise.result().isCompleted&&(this.privConversationConnectionPromise.result().isError||this.privConversationConnectionPromise.result().result.state()===o.ConnectionState.Disconnected)?(this.privConnectionId=null,this.privConversationConnectionPromise=null,this.terminateMessageLoop=!0,this.conversationConnectImpl()):this.privConversationConnectionPromise;this.privConversationAuthFetchEventId=o.createNoDashGuid(),void 0===this.privConnectionId&&(this.privConnectionId=o.createNoDashGuid()),this.privConversationRequestSession.onPreConnectionStart(this.privConversationAuthFetchEventId,this.privConnectionId);var r=e?this.privConversationAuthentication.fetchOnExpiry(this.privConversationAuthFetchEventId):this.privConversationAuthentication.fetch(this.privConversationAuthFetchEventId);return this.privConversationConnectionPromise=r.continueWithPromise(function(r){if(r.isError)throw t.privConversationRequestSession.onAuthCompleted(!0,r.error),new Error(r.error);t.privConversationRequestSession.onAuthCompleted(!1);var n=t.privConversationConnectionFactory.create(t.privRecognizerConfig,r.result,t.privConnectionId);return n.events.attach(function(e){t.connectionEvents.onEvent(e)}),n.open().onSuccessContinueWithPromise(function(r){if(200===r.statusCode){t.privConversationRequestSession.onPreConnectionStart(t.privConversationAuthFetchEventId,t.privConnectionId),t.privConversationRequestSession.onConnectionEstablishCompleted(r.statusCode);var i=new a.SessionEventArgs(t.privConversationRequestSession.sessionId);return t.privConversationServiceConnector.connectionOpened&&t.privConversationServiceConnector.connectionOpened(t.privConversationServiceConnector,i),o.PromiseHelper.fromResult(n)}return 403!==r.statusCode||e?(t.privConversationRequestSession.onConnectionEstablishCompleted(r.statusCode,r.reason),o.PromiseHelper.fromError("Unable to contact server. StatusCode: "+r.statusCode+", "+t.privRecognizerConfig.parameters.getProperty(a.PropertyId.SpeechServiceConnection_Endpoint)+" Reason: "+r.reason)):t.conversationConnectImpl(!0)})}),this.privConnectionLoop=this.startMessageLoop(),this.privConversationConnectionPromise},t.prototype.startMessageLoop=function(){var e=this;this.terminateMessageLoop=!1;var t=this.receiveConversationMessageOverride();return t.on(function(e){return!0},function(t){e.cancelRecognition(e.privRequestSession?e.privRequestSession.sessionId:"",e.privRequestSession?e.privRequestSession.requestId:"",a.CancellationReason.Error,a.CancellationErrorCode.RuntimeError,t)})},t.prototype.configConnection=function(){return this.privConnectionConfigPromise?this.privConnectionConfigPromise.result().isCompleted&&(this.privConnectionConfigPromise.result().isError||this.privConnectionConfigPromise.result().result.state()===o.ConnectionState.Disconnected)?(this.privConnectionConfigPromise=null,this.configConnection()):this.privConnectionConfigPromise:this.terminateMessageLoop?o.PromiseHelper.fromResult(void 0):(this.privConnectionConfigPromise=this.conversationConnectImpl().onSuccessContinueWith(function(e){return e}),this.privConnectionConfigPromise)},t.prototype.getTranslations=function(e){var t;if(void 0!==e){t=new a.Translations;for(var r=0,n=e;r-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}},e.prototype.getParticipantIndex=function(e){return this.participants.findIndex(function(t){return t.id===e})},e.prototype.getParticipant=function(e){return this.participants.find(function(t){return t.id===e})},e.prototype.deleteParticipant=function(e){this.participants=this.participants.filter(function(t){return t.id!==e})},Object.defineProperty(e.prototype,"host",{get:function(){return this.participants.find(function(e){return!0===e.isHost})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"me",{get:function(){return this.getParticipant(this.meId)},enumerable:!0,configurable:!0}),e}();t.InternalParticipants=n,t.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"},t.ConversationTranslatorCommandTypes={changeNickname:"ChangeNickname",disconnectSession:"DisconnectSession",ejectParticipant:"EjectParticipant",instant_message:"instant_message",joinSession:"JoinSession",leaveSession:"LeaveSession",participantList:"ParticipantList",roomExpirationWarning:"RoomExpirationWarning",setLockState:"SetLockState",setMute:"SetMute",setMuteAll:"SetMuteAll",setProfanityFiltering:"SetProfanityFiltering",setTranslateToLanguages:"SetTranslateToLanguages",setUseTTS:"SetUseTTS"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(147);t.CommandResponsePayload=n.CommandResponsePayload;var i=r(148);t.ParticipantsListPayloadResponse=i.ParticipantsListPayloadResponse,t.ParticipantPayloadResponse=i.ParticipantPayloadResponse;var o=r(149);t.SpeechResponsePayload=o.SpeechResponsePayload,t.TextResponsePayload=o.TextResponsePayload},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privCommandResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"type",{get:function(){return this.privCommandResponse.type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"command",{get:function(){return this.privCommandResponse.command},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privCommandResponse.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nickname",{get:function(){return this.privCommandResponse.nickname},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participantId",{get:function(){return this.privCommandResponse.participantId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"roomid",{get:function(){return this.privCommandResponse.roomid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.privCommandResponse.value},enumerable:!0,configurable:!0}),e}();t.CommandResponsePayload=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privParticipantsPayloadResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"roomid",{get:function(){return this.privParticipantsPayloadResponse.roomid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privParticipantsPayloadResponse.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"command",{get:function(){return this.privParticipantsPayloadResponse.command},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participants",{get:function(){return this.privParticipantsPayloadResponse.participants},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this.privParticipantsPayloadResponse.token},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"translateTo",{get:function(){return this.privParticipantsPayloadResponse.translateTo},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"profanityFilter",{get:function(){return this.privParticipantsPayloadResponse.profanityFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"roomProfanityFilter",{get:function(){return this.privParticipantsPayloadResponse.roomProfanityFilter},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"roomLocked",{get:function(){return this.privParticipantsPayloadResponse.roomLocked},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"muteAll",{get:function(){return this.privParticipantsPayloadResponse.muteAll},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.privParticipantsPayloadResponse.type},enumerable:!0,configurable:!0}),e}();t.ParticipantsListPayloadResponse=n;var i=function(){function e(e){this.privParticipantPayloadResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"nickname",{get:function(){return this.privParticipantPayloadResponse.nickname},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"locale",{get:function(){return this.privParticipantPayloadResponse.locale},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usetts",{get:function(){return this.privParticipantPayloadResponse.usetts},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ismuted",{get:function(){return this.privParticipantPayloadResponse.ismuted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ishost",{get:function(){return this.privParticipantPayloadResponse.ishost},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participantId",{get:function(){return this.privParticipantPayloadResponse.participantId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"avatar",{get:function(){return this.privParticipantPayloadResponse.avatar},enumerable:!0,configurable:!0}),e}();t.ParticipantPayloadResponse=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privSpeechResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"recognition",{get:function(){return this.privSpeechResponse.recognition},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"translations",{get:function(){return this.privSpeechResponse.translations},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privSpeechResponse.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"language",{get:function(){return this.privSpeechResponse.language},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nickname",{get:function(){return this.privSpeechResponse.nickname},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participantId",{get:function(){return this.privSpeechResponse.participantId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"roomid",{get:function(){return this.privSpeechResponse.roomid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timestamp",{get:function(){return this.privSpeechResponse.timestamp},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.privSpeechResponse.type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isFinal",{get:function(){return"final"===this.privSpeechResponse.type},enumerable:!0,configurable:!0}),e}();t.SpeechResponsePayload=n;var i=function(){function e(e){this.privTextResponse=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"originalText",{get:function(){return this.privTextResponse.originalText},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"translations",{get:function(){return this.privTextResponse.translations},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.privTextResponse.id},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"language",{get:function(){return this.privTextResponse.language},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nickname",{get:function(){return this.privTextResponse.nickname},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"participantId",{get:function(){return this.privTextResponse.participantId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"roomid",{get:function(){return this.privTextResponse.roomid},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timestamp",{get:function(){return this.privTextResponse.timestamp},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.privTextResponse.type},enumerable:!0,configurable:!0}),e}();t.TextResponsePayload=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.privSynthesisAudioMetadata=JSON.parse(e)}return e.fromJSON=function(t){return new e(t)},Object.defineProperty(e.prototype,"Metadata",{get:function(){return this.privSynthesisAudioMetadata.Metadata},enumerable:!0,configurable:!0}),e}();t.SynthesisAudioMetadata=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(36),o=r(152),s=r(153),a=function(){function e(){var e=this;this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privTextOffset=0,this.onPreConnectionStart=function(t,r){e.privAuthFetchEventId=t,e.onEvent(new s.ConnectingToSynthesisServiceEvent(e.privRequestId,e.privAuthFetchEventId))},this.onAuthCompleted=function(t,r){t&&e.onComplete()},this.onConnectionEstablishCompleted=function(t,r){if(200===t)return e.onEvent(new s.SynthesisStartedEvent(e.requestId,e.privAuthFetchEventId)),void(e.privBytesReceived=0);403===t&&e.onComplete()},this.onServiceResponseMessage=function(t){var r=JSON.parse(t);e.streamId=r.audio.streamId},this.onServiceTurnEndResponse=function(){e.privTurnDeferral.resolve(!0),e.onComplete()},this.onServiceTurnStartResponse=function(){e.privTurnDeferral.state()===n.PromiseState.None&&e.privTurnDeferral.reject("Another turn started before current completed."),e.privTurnDeferral=new n.Deferred},this.dispose=function(t){e.privIsDisposed||(e.privIsDisposed=!0)},this.onEvent=function(e){n.Events.instance.onEvent(e)},this.onComplete=function(){e.privIsSynthesizing&&(e.privIsSynthesizing=!1,e.privIsSynthesisEnded=!0,e.privAudioOutputStream.close(),void 0!==e.privTurnAudioDestination&&(e.privTurnAudioDestination.close(),e.privTurnAudioDestination=void 0))},this.privRequestId=n.createNoDashGuid(),this.privAudioNodeId=n.createNoDashGuid(),this.privTurnDeferral=new n.Deferred,this.privTurnDeferral.resolve(!0)}return Object.defineProperty(e.prototype,"requestId",{get:function(){return this.privRequestId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamId",{get:function(){return this.privStreamId},set:function(e){this.privStreamId=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"audioOutputFormat",{get:function(){return this.privAudioOutputFormat},set:function(e){this.privAudioOutputFormat=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"turnCompletionPromise",{get:function(){return this.privTurnDeferral.promise()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSynthesisEnded",{get:function(){return this.privIsSynthesisEnded},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSynthesizing",{get:function(){return this.privIsSynthesizing},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTextOffset",{get:function(){return this.privTextOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bytesReceived",{get:function(){return this.privBytesReceived},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allReceivedAudio",{get:function(){return this.privReceivedAudio?this.privReceivedAudio:this.privIsSynthesisEnded?(this.readAllAudioFromStream(),this.allReceivedAudio):null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allReceivedAudioWithHeader",{get:function(){return this.privReceivedAudioWithHeader?this.privReceivedAudioWithHeader:this.privIsSynthesisEnded?this.audioOutputFormat.hasHeader?(this.privReceivedAudioWithHeader=o.SynthesisAdapterBase.addHeader(this.allReceivedAudio,this.audioOutputFormat),this.allReceivedAudioWithHeader):this.allReceivedAudio:null},enumerable:!0,configurable:!0}),e.prototype.startNewSynthesis=function(e,t,r,n){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new i.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,void 0!==n&&(this.privTurnAudioDestination=n,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new s.SynthesisTriggeredEvent(this.requestId,void 0,void 0===n?void 0:n.id()))},e.prototype.onAudioChunkReceived=function(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,void 0!==this.privTurnAudioDestination&&this.privTurnAudioDestination.write(e))},e.prototype.onWordBoundaryEvent=function(e){this.updateTextOffset(e)},e.prototype.onStopSynthesizing=function(){this.onComplete()},e.prototype.updateTextOffset=function(e){this.privTextOffset>=0&&(this.privTextOffset=this.privRawText.indexOf(e,this.privTextOffset+this.privTextOffset>0?1:0),this.privIsSSML&&this.privRawText.indexOf("<",this.privTextOffset+1)>this.privRawText.indexOf(">",this.privTextOffset+1)&&this.updateTextOffset(e))},e.prototype.readAllAudioFromStream=function(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{this.privAudioOutputStream.read(this.privReceivedAudio)}catch(e){this.privReceivedAudio=new ArrayBuffer(0)}}},e}();t.SynthesisTurn=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(30),o=r(25),s=r(107),a=function(){function e(t,r,a,c,p){var u=this;if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.fetchConnectionOverride=void 0,this.receiveMessage=function(){return u.fetchConnection().on(function(t){return t.read().onSuccessContinueWithPromise(function(t){if(void 0!==u.receiveMessageOverride)return u.receiveMessageOverride();if(u.privIsDisposed)return n.PromiseHelper.fromResult(void 0);if(!t)return u.privSynthesisTurn.isSynthesizing?u.receiveMessage():n.PromiseHelper.fromResult(!0);u.privServiceHasSentMessage=!0;var r=s.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===u.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":u.privSynthesisTurn.onServiceTurnStartResponse();break;case"response":u.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":if(u.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody){if(u.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),u.privSpeechSynthesizer.synthesizing)try{var a=e.addHeader(r.binaryBody,u.privSynthesisTurn.audioOutputFormat),c=new i.SpeechSynthesisEventArgs(new i.SpeechSynthesisResult(u.privSynthesisTurn.requestId,i.ResultReason.SynthesizingAudio,a));u.privSpeechSynthesizer.synthesizing(u.privSpeechSynthesizer,c)}catch(e){}void 0!==u.privSessionAudioDestination&&u.privSessionAudioDestination.write(r.binaryBody)}break;case"audio.metadata":for(var p=o.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata,v=0,f=p;v=2*o;)e<<=1,r>>=1;return t.createScriptProcessor(e,1,1)}}(),a=new n.RiffPcmEncoder(t.sampleRate,o);s.onaudioprocess=function(e){var t=e.inputBuffer.getChannelData(0);if(i&&!i.isClosed){var r=a.encode(t);r&&(i.writeStreamChunk({buffer:r,isEnd:!1,timeReceived:Date.now()}),!1)}};var c=t.createMediaStreamSource(r);e.privSpeechProcessorScript&&t.audioWorklet?t.audioWorklet.addModule(e.privSpeechProcessorScript).then(function(){var n=new AudioWorkletNode(t,"speech-processor");n.port.onmessage=function(e){var t=e.data;if(i&&!i.isClosed){var r=a.encode(t);r&&(i.writeStreamChunk({buffer:r,isEnd:!1,timeReceived:Date.now()}),!1)}},c.connect(n),n.connect(t.destination),e.privMediaResources={scriptProcessorNode:n,source:c,stream:r}}).catch(function(){c.connect(s),s.connect(t.destination),e.privMediaResources={scriptProcessorNode:s,source:c,stream:r}}):(c.connect(s),s.connect(t.destination),e.privMediaResources={scriptProcessorNode:s,source:c,stream:r})},this.releaseMediaResources=function(t){e.privMediaResources&&(e.privMediaResources.scriptProcessorNode&&(e.privMediaResources.scriptProcessorNode.disconnect(t.destination),e.privMediaResources.scriptProcessorNode=null),e.privMediaResources.source&&(e.privMediaResources.source.disconnect(),e.privMediaResources.stream.getTracks().forEach(function(e){return e.stop()}),e.privMediaResources.source=null))}}return e.prototype.setWorkletUrl=function(e){this.privSpeechProcessorScript=e},e}();t.PcmRecorder=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=r(158),o=function(){function e(e,t,r,o,s,a){var c=this;if(this.privIsDisposed=!1,this.dispose=function(){c.privIsDisposed=!0,c.privConnectionMessageAdapter&&c.privConnectionMessageAdapter.close()},this.isDisposed=function(){return c.privIsDisposed},this.state=function(){return c.privConnectionMessageAdapter.state},this.open=function(){return c.privConnectionMessageAdapter.open()},this.send=function(e){return c.privConnectionMessageAdapter.send(e)},this.read=function(){return c.privConnectionMessageAdapter.read()},!e)throw new n.ArgumentNullError("uri");if(!o)throw new n.ArgumentNullError("messageFormatter");this.privMessageFormatter=o;var p="",u=0;if(t)for(var v in t)if(v){p+=0===u&&-1===e.indexOf("?")?"?":"&";var f=encodeURIComponent(t[v]);p+=v+"="+f,u++}if(r)for(var h in r)if(h){p+=0===u?"?":"&";f=encodeURIComponent(r[h]);p+=h+"="+f,u++}this.privUri=e+p,this.privId=a||n.createNoDashGuid(),this.privConnectionMessageAdapter=new i.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,r)}return Object.defineProperty(e.prototype,"id",{get:function(){return this.privId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){return this.privConnectionMessageAdapter.events},enumerable:!0,configurable:!0}),e}();t.WebsocketConnection=o},function(e,t,r){"use strict";(function(e,n){Object.defineProperty(t,"__esModule",{value:!0});var i=r(4),o=r(165),s=r(166),a=r(167),c=function(){function t(r,c,p,u,v){var f=this;if(this.open=function(){if(f.privConnectionState===i.ConnectionState.Disconnected)return i.PromiseHelper.fromError("Cannot open a connection that is in "+f.privConnectionState+" state");if(f.privConnectionEstablishDeferral)return f.privConnectionEstablishDeferral.promise();f.privConnectionEstablishDeferral=new i.Deferred,f.privCertificateValidatedDeferral=new i.Deferred,f.privConnectionState=i.ConnectionState.Connecting;try{var r=void 0!==e&&"0"!==e.env.NODE_TLS_REJECT_UNAUTHORIZED&&!f.privUri.startsWith("ws:");if("undefined"==typeof WebSocket||t.forceNpmWebSocket)if(void 0!==f.proxyInfo&&void 0!==f.proxyInfo.HostName&&f.proxyInfo.Port>0){var c={host:f.proxyInfo.HostName,port:f.proxyInfo.Port};void 0!==f.proxyInfo.UserName&&(c.headers={"Proxy-Authentication":"Basic "+new n(f.proxyInfo.UserName+":"+(void 0===f.proxyInfo.Password)?"":f.proxyInfo.Password).toString("base64")},r&&(c.headers.requestOCSP="true"));var p=new o(c),u={agent:p,headers:f.privHeaders};f.privWebsocketClient=new s(f.privUri,u),r?f.privWebsocketClient.addListener("upgrade",function(e){var t=e.socket,r=t.getPeerCertificate(!0);t.cork(),a.check({cert:r.raw,httpOptions:u,issuer:r.issuerCertificate.raw},function(e,r){e?(f.privCertificateValidatedDeferral.reject(e.message),t.destroy(e)):(f.privCertificateValidatedDeferral.resolve(!0),t.uncork())})}):f.privCertificateValidatedDeferral.resolve(!0)}else{var v={headers:f.privHeaders};f.privCertificateValidatedDeferral.resolve(!0),r&&(v.agent=new a.Agent({})),f.privWebsocketClient=new s(f.privUri,v)}else f.privCertificateValidatedDeferral.resolve(!0),f.privWebsocketClient=new WebSocket(f.privUri);f.privWebsocketClient.binaryType="arraybuffer",f.privReceivingMessageQueue=new i.Queue,f.privDisconnectDeferral=new i.Deferred,f.privSendMessageQueue=new i.Queue,f.processSendQueue()}catch(e){return f.privConnectionEstablishDeferral.resolve(new i.ConnectionOpenResponse(500,e)),f.privConnectionEstablishDeferral.promise()}return f.onEvent(new i.ConnectionStartEvent(f.privConnectionId,f.privUri)),f.privWebsocketClient.onopen=function(e){f.privCertificateValidatedDeferral.promise().on(function(){f.privConnectionState=i.ConnectionState.Connected,f.onEvent(new i.ConnectionEstablishedEvent(f.privConnectionId)),f.privConnectionEstablishDeferral.resolve(new i.ConnectionOpenResponse(200,""))},function(e){f.privConnectionEstablishDeferral.reject(e)})},f.privWebsocketClient.onerror=function(e){f.onEvent(new i.ConnectionErrorEvent(f.privConnectionId,e.message,e.type)),f.privLastErrorReceived=e.message},f.privWebsocketClient.onclose=function(e){f.privConnectionState===i.ConnectionState.Connecting?(f.privConnectionState=i.ConnectionState.Disconnected,f.privConnectionEstablishDeferral.resolve(new i.ConnectionOpenResponse(e.code,e.reason+" "+f.privLastErrorReceived))):f.onEvent(new i.ConnectionClosedEvent(f.privConnectionId,e.code,e.reason)),f.onClose(e.code,e.reason)},f.privWebsocketClient.onmessage=function(e){var t=(new Date).toISOString();if(f.privConnectionState===i.ConnectionState.Connected){var r=new i.Deferred;if(f.privReceivingMessageQueue.enqueueFromPromise(r.promise()),e.data instanceof ArrayBuffer){var n=new i.RawWebsocketMessage(i.MessageType.Binary,e.data);f.privMessageFormatter.toConnectionMessage(n).on(function(e){f.onEvent(new i.ConnectionMessageReceivedEvent(f.privConnectionId,t,e)),r.resolve(e)},function(e){r.reject("Invalid binary message format. Error: "+e)})}else{n=new i.RawWebsocketMessage(i.MessageType.Text,e.data);f.privMessageFormatter.toConnectionMessage(n).on(function(e){f.onEvent(new i.ConnectionMessageReceivedEvent(f.privConnectionId,t,e)),r.resolve(e)},function(e){r.reject("Invalid text message format. Error: "+e)})}}},f.privConnectionEstablishDeferral.promise()},this.send=function(e){if(f.privConnectionState!==i.ConnectionState.Connected)return i.PromiseHelper.fromError("Cannot send on connection that is in "+f.privConnectionState+" state");var t=new i.Deferred,r=new i.Deferred;return f.privSendMessageQueue.enqueueFromPromise(r.promise()),f.privMessageFormatter.fromConnectionMessage(e).on(function(n){r.resolve({Message:e,RawWebsocketMessage:n,sendStatusDeferral:t})},function(e){r.reject("Error formatting the message. "+e)}),t.promise()},this.read=function(){return f.privConnectionState!==i.ConnectionState.Connected?i.PromiseHelper.fromError("Cannot read on connection that is in "+f.privConnectionState+" state"):f.privReceivingMessageQueue.dequeue()},this.close=function(e){if(!f.privWebsocketClient){var t=new i.Deferred;return t.resolve(!0),t.promise()}return f.privConnectionState!==i.ConnectionState.Disconnected&&f.privWebsocketClient.close(1e3,e||"Normal closure by client"),f.privDisconnectDeferral.promise()},this.sendRawMessage=function(e){try{return e?(f.onEvent(new i.ConnectionMessageSentEvent(f.privConnectionId,(new Date).toISOString(),e.Message)),f.isWebsocketOpen?(f.privWebsocketClient.send(e.RawWebsocketMessage.payload),i.PromiseHelper.fromResult(!0)):i.PromiseHelper.fromError("websocket send error: Websocket not ready")):i.PromiseHelper.fromResult(!0)}catch(e){return i.PromiseHelper.fromError("websocket send error: "+e)}},this.onClose=function(e,t){var r="Connection closed. "+e+": "+t;f.privConnectionState=i.ConnectionState.Disconnected,f.privDisconnectDeferral.resolve(!0),f.privReceivingMessageQueue.dispose(t),f.privReceivingMessageQueue.drainAndDispose(function(e){},r),f.privSendMessageQueue.drainAndDispose(function(e){e.sendStatusDeferral.reject(r)},r)},this.processSendQueue=function(){f.privSendMessageQueue.dequeue().on(function(e){e&&f.sendRawMessage(e).on(function(t){e.sendStatusDeferral.resolve(t),f.processSendQueue()},function(t){e.sendStatusDeferral.reject(t),f.processSendQueue()})},function(e){})},this.onEvent=function(e){f.privConnectionEvents.onEvent(e),i.Events.instance.onEvent(e)},!r)throw new i.ArgumentNullError("uri");if(!p)throw new i.ArgumentNullError("messageFormatter");this.proxyInfo=u,this.privConnectionEvents=new i.EventSource,this.privConnectionId=c,this.privMessageFormatter=p,this.privConnectionState=i.ConnectionState.None,this.privUri=r,this.privHeaders=v,this.privLastErrorReceived=""}return Object.defineProperty(t.prototype,"state",{get:function(){return this.privConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){return this.privConnectionEvents},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isWebsocketOpen",{get:function(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN},enumerable:!0,configurable:!0}),t.forceNpmWebSocket=!1,t}();t.WebsocketMessageAdapter=c}).call(this,r(159),r(160).Buffer)},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(u===setTimeout)return setTimeout(e,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function o(e){if(v===clearTimeout)return clearTimeout(e);if((v===n||!v)&&clearTimeout)return v=clearTimeout,clearTimeout(e);try{return v(e)}catch(t){try{return v.call(null,e)}catch(t){return v.call(this,e)}}}function s(){d&&h&&(d=!1,h.length?l=h.concat(l):g=-1,l.length&&a())}function a(){if(!d){var e=i(s);d=!0;for(var t=l.length;t;){for(h=l,l=[];++g1)for(var r=1;r=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),s.alloc(+e)}function y(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,r);case"utf8":case"utf-8":return _(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function S(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function C(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var s,a=1,c=e.length,p=t.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,c/=2,p/=2,r/=2}if(i){var u=-1;for(s=r;sc&&(r=c-p),s=r;s>=0;s--){for(var v=!0,f=0;fi&&(n=i)):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s239?4:p>223?3:p>191?2:1 ;if(i+v<=r)switch(v){case 1:p<128&&(u=p);break;case 2:o=e[i+1],128==(192&o)&&(c=(31&p)<<6|63&o,c>127&&(u=c));break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&p)<<12|(63&o)<<6|63&s,c>2047&&(c<55296||c>57343)&&(u=c));break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&p)<<18|(63&o)<<12|(63&s)<<6|63&a,c>65535&&c<1114112&&(u=c))}null===u?(u=65533,v=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=v}return A(n)}function A(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function z(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function x(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function L(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function F(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(e,t,r,n,i){return i||F(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,i){return i||F(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(e,t,r,n,52,8),r+8}function q(e){if(e=W(e).replace(te,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function W(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function K(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function J(e){for(var t=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function G(e){return X.toByteArray(q(e))}function Q(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Y(e){return e!=e}var X=r(162),Z=r(163),$=r(164);t.Buffer=s,t.SlowBuffer=g,t.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),t.kMaxLength=i(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,r){return a(null,e,t,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,r){return p(null,e,t,r)},s.allocUnsafe=function(e){return u(null,e)},s.allocUnsafeSlow=function(e){return u(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,a=r-t,c=Math.min(o,a),p=this.slice(n,i),u=e.slice(t,r),v=0;vi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return P(this,e,t,r);case"utf8":case"utf-8":return R(this,e,t,r);case"ascii":return I(this,e,t,r);case"latin1":case"binary":return O(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;s.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,o=0;++o=i&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),Z.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),Z.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),Z.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),Z.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){var i=Math.pow(2,8*r)-1;z(this,e,t,r,i,0)}var o=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+o]=e/s&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);z(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);z(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,r){return B(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return B(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function i(e){var t=n(e),r=t[0],i=t[1];return 3*(r+i)/4-i}function o(e,t,r){return 3*(t+r)/4-r}function s(e){var t,r,i=n(e),s=i[0],a=i[1],c=new f(o(e,s,a)),p=0,u=a>0?s-4:s;for(r=0;r>16&255,c[p++]=t>>8&255,c[p++]=255&t;return 2===a&&(t=v[e.charCodeAt(r)]<<2|v[e.charCodeAt(r+1)]>>4,c[p++]=255&t),1===a&&(t=v[e.charCodeAt(r)]<<10|v[e.charCodeAt(r+1)]<<4|v[e.charCodeAt(r+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t),c}function a(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function c(e,t,r){for(var n,i=[],o=t;oa?a:s+o));return 1===n?(t=e[r-1],i.push(u[t>>2]+u[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(u[t>>10]+u[t>>4&63]+u[t<<2&63]+"=")),i.join("")}t.byteLength=i,t.toByteArray=s,t.fromByteArray=p;for(var u=[],v=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,d=h.length;l>1,u=-7,v=r?i-1:0,f=r?-1:1,h=e[t+v];for(v+=f,o=h&(1<<-u)-1,h>>=-u,u+=a;u>0;o=256*o+e[t+v],v+=f,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+v],v+=f,u-=8);if(0===o)o=1-p;else{if(o===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=p}return(h?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,p=8*o-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,l=n?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),t+=s+v>=1?f/c:f*Math.pow(2,1-v),t*c>=2&&(s++,c/=2),s+v>=u?(a=0,s=u):s+v>=1?(a=(t*c-1)*Math.pow(2,i),s+=v):(a=t*Math.pow(2,v-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=l,a/=256,i-=8);for(s=s<0;e[r+h]=255&s,h+=l,s/=256,p-=8);e[r+h-l]|=128*d}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){},function(e,t){},function(e,t){},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=function(){function e(e,t){var r=this;this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.id=function(){return r.privAudioNode.id()},this.privAudioNode=e,this.privBytesPerSecond=t}return e.prototype.read=function(){var e=this;if(this.privReplay&&0!==this.privBuffers.length){var t=this.privReplayOffset-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7);0!=r%2&&r++;for(var i=0;i=this.privBuffers[i].chunk.buffer.byteLength;)r-=this.privBuffers[i++].chunk.buffer.byteLength;var s=this.privBuffers[i].chunk.buffer.slice(r);return this.privReplayOffset+=s.byteLength/this.privBytesPerSecond*1e7,i===this.privBuffers.length-1&&(this.privReplay=!1),n.PromiseHelper.fromResult({buffer:s,isEnd:!1,timeReceived:this.privBuffers[i].chunk.timeReceived})}return this.privAudioNode.read().onSuccessContinueWith(function(t){return t&&t.buffer&&(e.privBuffers.push(new o(t,e.privBufferSerial++,e.privBufferedBytes)),e.privBufferedBytes+=t.buffer.byteLength),t})},e.prototype.detach=function(){this.privAudioNode.detach(),this.privBuffers=void 0},e.prototype.replay=function(){this.privBuffers&&0!==this.privBuffers.length&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)},e.prototype.shrinkBuffers=function(e){if(void 0!==this.privBuffers){this.privLastShrinkOffset=e;for(var t=e-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7),n=0;n=this.privBuffers[n].chunk.buffer.byteLength;)r-=this.privBuffers[n++].chunk.buffer.byteLength;this.privBufferStartOffset=Math.round(e-r/this.privBytesPerSecond*1e7),this.privBuffers=this.privBuffers.slice(n)}},e.prototype.findTimeAtOffset=function(e){if(e=i&&e<=o)return n.chunk.timeReceived}return 0},e}();t.ReplayableAudioNode=i;var o=function(){function e(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}return e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(30),i=function(){function e(e,t,r,n){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=n}return e.fromParameters=function(t){return new e(t.getProperty(n.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(t.getProperty(n.PropertyId.SpeechServiceConnection_ProxyPort),10),t.getProperty(n.PropertyId.SpeechServiceConnection_ProxyUserName),t.getProperty(n.PropertyId.SpeechServiceConnection_ProxyPassword))},e.fromRecognizerConfig=function(e){return this.fromParameters(e.parameters)},Object.defineProperty(e.prototype,"HostName",{get:function(){return this.privProxyHostName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Port",{get:function(){return this.privProxyPort},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"UserName",{get:function(){return this.privProxyUserName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Password",{get:function(){return this.privProxyPassword},enumerable:!0,configurable:!0}),e}();t.ProxyInfo=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),i=function(){function e(e){this.privId=e||n.createNoDashGuid()}return e.prototype.id=function(){return this.privId},e.prototype.write=function(e){},e.prototype.close=function(){},Object.defineProperty(e.prototype,"format",{set:function(e){},enumerable:!0,configurable:!0}),e}();t.SpeakerAudioDestination=i}]);