web-speech-cognitive-services 8.0.1-main.8743165 → 8.1.1-main.65a0e14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-speech-cognitive-services.d.mts +35 -20
- package/dist/web-speech-cognitive-services.d.ts +35 -20
- package/dist/web-speech-cognitive-services.development.js +843 -172
- package/dist/web-speech-cognitive-services.development.js.map +1 -1
- package/dist/web-speech-cognitive-services.js +141 -81
- package/dist/web-speech-cognitive-services.js.map +1 -1
- package/dist/web-speech-cognitive-services.mjs +147 -87
- package/dist/web-speech-cognitive-services.mjs.map +1 -1
- package/dist/web-speech-cognitive-services.production.min.js +12 -12
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";(()=>{var BR=Object.create;var Xf=Object.defineProperty;var FR=Object.getOwnPropertyDescriptor;var VR=Object.getOwnPropertyNames;var UR=Object.getPrototypeOf,WR=Object.prototype.hasOwnProperty;var p=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var HR=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of VR(e))!WR.call(i,n)&&n!==t&&Xf(i,n,{get:()=>e[n],enumerable:!(r=FR(e,n))||r.enumerable});return i};var Zf=(i,e,t)=>(t=i!=null?BR(UR(i)):{},HR(e||!i||!i.__esModule?Xf(t,"default",{value:i,enumerable:!0}):t,i));var Fp=p(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});Bp.default=GR;var as,JR=new Uint8Array(16);function GR(){if(!as&&(as=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!as))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return as(JR)}});var tg=p(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.default=void 0;var $R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;cs.default=$R});var sn=p(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});ps.default=void 0;var QR=YR(tg());function YR(i){return i&&i.__esModule?i:{default:i}}function XR(i){return typeof i=="string"&&QR.default.test(i)}var ZR=XR;ps.default=ZR});var an=p(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.default=void 0;on.unsafeStringify=rg;var eE=tE(sn());function tE(i){return i&&i.__esModule?i:{default:i}}var ue=[];for(let i=0;i<256;++i)ue.push((i+256).toString(16).slice(1));function rg(i,e=0){return ue[i[e+0]]+ue[i[e+1]]+ue[i[e+2]]+ue[i[e+3]]+"-"+ue[i[e+4]]+ue[i[e+5]]+"-"+ue[i[e+6]]+ue[i[e+7]]+"-"+ue[i[e+8]]+ue[i[e+9]]+"-"+ue[i[e+10]]+ue[i[e+11]]+ue[i[e+12]]+ue[i[e+13]]+ue[i[e+14]]+ue[i[e+15]]}function rE(i,e=0){let t=rg(i,e);if(!(0,eE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var iE=rE;on.default=iE});var ng=p(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.default=void 0;var nE=oE(Fp()),sE=an();function oE(i){return i&&i.__esModule?i:{default:i}}var ig,Vp,Up=0,Wp=0;function aE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||ig,o=i.clockseq!==void 0?i.clockseq:Vp;if(s==null||o==null){let l=i.random||(i.rng||nE.default)();s==null&&(s=ig=[l[0]|1,l[1],l[2],l[3],l[4],l[5]]),o==null&&(o=Vp=(l[6]<<8|l[7])&16383)}let a=i.msecs!==void 0?i.msecs:Date.now(),c=i.nsecs!==void 0?i.nsecs:Wp+1,u=a-Up+(c-Wp)/1e4;if(u<0&&i.clockseq===void 0&&(o=o+1&16383),(u<0||a>Up)&&i.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Up=a,Wp=c,Vp=o,a+=122192928e5;let d=((a&268435455)*1e4+c)%4294967296;n[r++]=d>>>24&255,n[r++]=d>>>16&255,n[r++]=d>>>8&255,n[r++]=d&255;let h=a/4294967296*1e4&268435455;n[r++]=h>>>8&255,n[r++]=h&255,n[r++]=h>>>24&15|16,n[r++]=h>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let l=0;l<6;++l)n[r+l]=s[l];return e||(0,sE.unsafeStringify)(n)}var cE=aE;us.default=cE});var Hp=p(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.default=void 0;var pE=uE(sn());function uE(i){return i&&i.__esModule?i:{default:i}}function dE(i){if(!(0,pE.default)(i))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(i.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(i.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(i.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(i.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(i.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var hE=dE;ds.default=hE});var Kp=p(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.URL=Ir.DNS=void 0;Ir.default=mE;var lE=an(),vE=fE(Hp());function fE(i){return i&&i.__esModule?i:{default:i}}function gE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var sg="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Ir.DNS=sg;var og="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Ir.URL=og;function mE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=gE(n)),typeof s=="string"&&(s=(0,vE.default)(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+n.length);if(u.set(s),u.set(n,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(let d=0;d<16;++d)o[a+d]=u[d];return o}return(0,lE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=sg,r.URL=og,r}});var cg=p(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.default=void 0;function SE(i){if(typeof i=="string"){let e=unescape(encodeURIComponent(i));i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t)}return yE(CE(PE(i),i.length*8))}function yE(i){let e=[],t=i.length*32,r="0123456789abcdef";for(let n=0;n<t;n+=8){let s=i[n>>5]>>>n%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function ag(i){return(i+64>>>9<<4)+14+1}function CE(i,e){i[e>>5]|=128<<e%32,i[ag(e)-1]=e;let t=1732584193,r=-271733879,n=-1732584194,s=271733878;for(let o=0;o<i.length;o+=16){let a=t,c=r,u=n,d=s;t=Ce(t,r,n,s,i[o],7,-680876936),s=Ce(s,t,r,n,i[o+1],12,-389564586),n=Ce(n,s,t,r,i[o+2],17,606105819),r=Ce(r,n,s,t,i[o+3],22,-1044525330),t=Ce(t,r,n,s,i[o+4],7,-176418897),s=Ce(s,t,r,n,i[o+5],12,1200080426),n=Ce(n,s,t,r,i[o+6],17,-1473231341),r=Ce(r,n,s,t,i[o+7],22,-45705983),t=Ce(t,r,n,s,i[o+8],7,1770035416),s=Ce(s,t,r,n,i[o+9],12,-1958414417),n=Ce(n,s,t,r,i[o+10],17,-42063),r=Ce(r,n,s,t,i[o+11],22,-1990404162),t=Ce(t,r,n,s,i[o+12],7,1804603682),s=Ce(s,t,r,n,i[o+13],12,-40341101),n=Ce(n,s,t,r,i[o+14],17,-1502002290),r=Ce(r,n,s,t,i[o+15],22,1236535329),t=Pe(t,r,n,s,i[o+1],5,-165796510),s=Pe(s,t,r,n,i[o+6],9,-1069501632),n=Pe(n,s,t,r,i[o+11],14,643717713),r=Pe(r,n,s,t,i[o],20,-373897302),t=Pe(t,r,n,s,i[o+5],5,-701558691),s=Pe(s,t,r,n,i[o+10],9,38016083),n=Pe(n,s,t,r,i[o+15],14,-660478335),r=Pe(r,n,s,t,i[o+4],20,-405537848),t=Pe(t,r,n,s,i[o+9],5,568446438),s=Pe(s,t,r,n,i[o+14],9,-1019803690),n=Pe(n,s,t,r,i[o+3],14,-187363961),r=Pe(r,n,s,t,i[o+8],20,1163531501),t=Pe(t,r,n,s,i[o+13],5,-1444681467),s=Pe(s,t,r,n,i[o+2],9,-51403784),n=Pe(n,s,t,r,i[o+7],14,1735328473),r=Pe(r,n,s,t,i[o+12],20,-1926607734),t=Re(t,r,n,s,i[o+5],4,-378558),s=Re(s,t,r,n,i[o+8],11,-2022574463),n=Re(n,s,t,r,i[o+11],16,1839030562),r=Re(r,n,s,t,i[o+14],23,-35309556),t=Re(t,r,n,s,i[o+1],4,-1530992060),s=Re(s,t,r,n,i[o+4],11,1272893353),n=Re(n,s,t,r,i[o+7],16,-155497632),r=Re(r,n,s,t,i[o+10],23,-1094730640),t=Re(t,r,n,s,i[o+13],4,681279174),s=Re(s,t,r,n,i[o],11,-358537222),n=Re(n,s,t,r,i[o+3],16,-722521979),r=Re(r,n,s,t,i[o+6],23,76029189),t=Re(t,r,n,s,i[o+9],4,-640364487),s=Re(s,t,r,n,i[o+12],11,-421815835),n=Re(n,s,t,r,i[o+15],16,530742520),r=Re(r,n,s,t,i[o+2],23,-995338651),t=Ee(t,r,n,s,i[o],6,-198630844),s=Ee(s,t,r,n,i[o+7],10,1126891415),n=Ee(n,s,t,r,i[o+14],15,-1416354905),r=Ee(r,n,s,t,i[o+5],21,-57434055),t=Ee(t,r,n,s,i[o+12],6,1700485571),s=Ee(s,t,r,n,i[o+3],10,-1894986606),n=Ee(n,s,t,r,i[o+10],15,-1051523),r=Ee(r,n,s,t,i[o+1],21,-2054922799),t=Ee(t,r,n,s,i[o+8],6,1873313359),s=Ee(s,t,r,n,i[o+15],10,-30611744),n=Ee(n,s,t,r,i[o+6],15,-1560198380),r=Ee(r,n,s,t,i[o+13],21,1309151649),t=Ee(t,r,n,s,i[o+4],6,-145523070),s=Ee(s,t,r,n,i[o+11],10,-1120210379),n=Ee(n,s,t,r,i[o+2],15,718787259),r=Ee(r,n,s,t,i[o+9],21,-343485551),t=tr(t,a),r=tr(r,c),n=tr(n,u),s=tr(s,d)}return[t,r,n,s]}function PE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(ag(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function tr(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function RE(i,e){return i<<e|i>>>32-e}function hs(i,e,t,r,n,s){return tr(RE(tr(tr(e,i),tr(r,s)),n),t)}function Ce(i,e,t,r,n,s,o){return hs(e&t|~e&r,i,e,n,s,o)}function Pe(i,e,t,r,n,s,o){return hs(e&r|t&~r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return hs(e^t^r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return hs(t^(e|~r),i,e,n,s,o)}var EE=SE;ls.default=EE});var ug=p(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.default=void 0;var wE=pg(Kp()),IE=pg(cg());function pg(i){return i&&i.__esModule?i:{default:i}}var TE=(0,wE.default)("v3",48,IE.default),_E=TE;vs.default=_E});var dg=p(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.default=void 0;var AE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),bE={randomUUID:AE};fs.default=bE});var vg=p(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.default=void 0;var hg=lg(dg()),OE=lg(Fp()),ME=an();function lg(i){return i&&i.__esModule?i:{default:i}}function DE(i,e,t){if(hg.default.randomUUID&&!e&&!i)return hg.default.randomUUID();i=i||{};let r=i.random||(i.rng||OE.default)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return(0,ME.unsafeStringify)(r)}var kE=DE;gs.default=kE});var fg=p(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.default=void 0;function NE(i,e,t,r){switch(i){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function Jp(i,e){return i<<e|i>>>32-e}function xE(i){let e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){let o=unescape(encodeURIComponent(i));i=[];for(let a=0;a<o.length;++a)i.push(o.charCodeAt(a))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);let r=i.length/4+2,n=Math.ceil(r/16),s=new Array(n);for(let o=0;o<n;++o){let a=new Uint32Array(16);for(let c=0;c<16;++c)a[c]=i[o*64+c*4]<<24|i[o*64+c*4+1]<<16|i[o*64+c*4+2]<<8|i[o*64+c*4+3];s[o]=a}s[n-1][14]=(i.length-1)*8/Math.pow(2,32),s[n-1][14]=Math.floor(s[n-1][14]),s[n-1][15]=(i.length-1)*8&4294967295;for(let o=0;o<n;++o){let a=new Uint32Array(80);for(let g=0;g<16;++g)a[g]=s[o][g];for(let g=16;g<80;++g)a[g]=Jp(a[g-3]^a[g-8]^a[g-14]^a[g-16],1);let c=t[0],u=t[1],d=t[2],h=t[3],l=t[4];for(let g=0;g<80;++g){let _=Math.floor(g/20),M=Jp(c,5)+NE(_,u,d,h)+l+e[_]+a[g]>>>0;l=h,h=d,d=Jp(u,30)>>>0,u=c,c=M}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+d>>>0,t[3]=t[3]+h>>>0,t[4]=t[4]+l>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var qE=xE;ms.default=qE});var mg=p(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.default=void 0;var zE=gg(Kp()),jE=gg(fg());function gg(i){return i&&i.__esModule?i:{default:i}}var LE=(0,zE.default)("v5",80,jE.default),BE=LE;Ss.default=BE});var Sg=p(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.default=void 0;var FE="00000000-0000-0000-0000-000000000000";ys.default=FE});var yg=p(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.default=void 0;var VE=UE(sn());function UE(i){return i&&i.__esModule?i:{default:i}}function WE(i){if(!(0,VE.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var HE=WE;Cs.default=HE});var Cg=p(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});Object.defineProperty(st,"NIL",{enumerable:!0,get:function(){return QE.default}});Object.defineProperty(st,"parse",{enumerable:!0,get:function(){return ew.default}});Object.defineProperty(st,"stringify",{enumerable:!0,get:function(){return ZE.default}});Object.defineProperty(st,"v1",{enumerable:!0,get:function(){return KE.default}});Object.defineProperty(st,"v3",{enumerable:!0,get:function(){return JE.default}});Object.defineProperty(st,"v4",{enumerable:!0,get:function(){return GE.default}});Object.defineProperty(st,"v5",{enumerable:!0,get:function(){return $E.default}});Object.defineProperty(st,"validate",{enumerable:!0,get:function(){return XE.default}});Object.defineProperty(st,"version",{enumerable:!0,get:function(){return YE.default}});var KE=zt(ng()),JE=zt(ug()),GE=zt(vg()),$E=zt(mg()),QE=zt(Sg()),YE=zt(yg()),XE=zt(sn()),ZE=zt(an()),ew=zt(Hp());function zt(i){return i&&i.__esModule?i:{default:i}}});var rr=p(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.createNoDashGuid=pi.createGuid=void 0;var tw=Cg(),Pg=()=>tw.v4();pi.createGuid=Pg;var rw=()=>Pg().replace(new RegExp("-","g"),"").toUpperCase();pi.createNoDashGuid=rw});var ui=p(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.PlatformEvent=Tr.EventType=void 0;var iw=rr(),nw;(function(i){i[i.Debug=0]="Debug",i[i.Info=1]="Info",i[i.Warning=2]="Warning",i[i.Error=3]="Error",i[i.None=4]="None"})(nw=Tr.EventType||(Tr.EventType={}));var Gp=class{constructor(e,t){this.privName=e,this.privEventId=iw.createNoDashGuid(),this.privEventTime=new Date().toISOString(),this.privEventType=t,this.privMetadata={}}get name(){return this.privName}get eventId(){return this.privEventId}get eventTime(){return this.privEventTime}get eventType(){return this.privEventType}get metadata(){return this.privMetadata}};Tr.PlatformEvent=Gp});var nu=p(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.AudioStreamNodeErrorEvent=Y.AudioStreamNodeDetachedEvent=Y.AudioStreamNodeAttachedEvent=Y.AudioStreamNodeAttachingEvent=Y.AudioStreamNodeEvent=Y.AudioSourceErrorEvent=Y.AudioSourceOffEvent=Y.AudioSourceReadyEvent=Y.AudioSourceInitializingEvent=Y.AudioSourceEvent=void 0;var $p=ui(),ir=class extends $p.PlatformEvent{constructor(e,t,r=$p.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};Y.AudioSourceEvent=ir;var Qp=class extends ir{constructor(e){super("AudioSourceInitializingEvent",e)}};Y.AudioSourceInitializingEvent=Qp;var Yp=class extends ir{constructor(e){super("AudioSourceReadyEvent",e)}};Y.AudioSourceReadyEvent=Yp;var Xp=class extends ir{constructor(e){super("AudioSourceOffEvent",e)}};Y.AudioSourceOffEvent=Xp;var Zp=class extends ir{constructor(e,t){super("AudioSourceErrorEvent",e,$p.EventType.Error),this.privError=t}get error(){return this.privError}};Y.AudioSourceErrorEvent=Zp;var _r=class extends ir{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};Y.AudioStreamNodeEvent=_r;var eu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};Y.AudioStreamNodeAttachingEvent=eu;var tu=class extends _r{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};Y.AudioStreamNodeAttachedEvent=tu;var ru=class extends _r{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};Y.AudioStreamNodeDetachedEvent=ru;var iu=class extends _r{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};Y.AudioStreamNodeErrorEvent=iu});var Rg=p(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.ConnectionMessageSentEvent=te.ConnectionMessageReceivedEvent=te.ConnectionEstablishErrorEvent=te.ConnectionErrorEvent=te.ConnectionClosedEvent=te.ConnectionEstablishedEvent=te.ConnectionStartEvent=te.ConnectionEvent=te.ServiceEvent=void 0;var Ar=ui(),su=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};te.ServiceEvent=su;var mt=class extends Ar.PlatformEvent{constructor(e,t,r=Ar.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};te.ConnectionEvent=mt;var ou=class extends mt{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};te.ConnectionStartEvent=ou;var au=class extends mt{constructor(e){super("ConnectionEstablishedEvent",e)}};te.ConnectionEstablishedEvent=au;var cu=class extends mt{constructor(e,t,r){super("ConnectionClosedEvent",e,Ar.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionClosedEvent=cu;var pu=class extends mt{constructor(e,t,r){super("ConnectionErrorEvent",e,Ar.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};te.ConnectionErrorEvent=pu;var uu=class extends mt{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,Ar.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionEstablishErrorEvent=uu;var du=class extends mt{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};te.ConnectionMessageReceivedEvent=du;var hu=class extends mt{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};te.ConnectionMessageSentEvent=hu});var ot=p(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.ObjectDisposedError=nr.InvalidOperationError=nr.ArgumentNullError=void 0;var lu=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};nr.ArgumentNullError=lu;var vu=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};nr.InvalidOperationError=vu;var fu=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};nr.ObjectDisposedError=fu});var mu=p(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.ConnectionMessage=Or.MessageType=void 0;var Ps=ot(),sw=rr(),br;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(br=Or.MessageType||(Or.MessageType={}));var gu=class{constructor(e,t,r,n){if(this.privBody=null,e===br.Text&&t&&typeof t!="string")throw new Ps.InvalidOperationError("Payload must be a string");if(e===br.Binary&&t&&!(t instanceof ArrayBuffer))throw new Ps.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||sw.createNoDashGuid(),this.messageType){case br.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case br.Text:this.privSize=this.textBody.length}}get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===br.Binary)throw new Ps.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===br.Text)throw new Ps.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};Or.ConnectionMessage=gu});var Eg=p(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.ConnectionOpenResponse=void 0;var Su=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};Rs.ConnectionOpenResponse=Su});var wg=p(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.DeferralMap=void 0;var yu=class{constructor(){this.privMap={}}add(e,t){this.privMap[e]=t}getId(e){return this.privMap[e]}complete(e,t){try{this.privMap[e].resolve(t)}catch(r){this.privMap[e].reject(r)}finally{this.privMap[e]=void 0}}};Es.DeferralMap=yu});var Pu=p(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.SendingAgentContextMessageEvent=di.DialogEvent=void 0;var Ig=ui(),ws=class extends Ig.PlatformEvent{constructor(e,t=Ig.EventType.Info){super(e,t)}};di.DialogEvent=ws;var Cu=class extends ws{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};di.SendingAgentContextMessageEvent=Cu});var Eu=p(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.EventSource=void 0;var ow=ot(),aw=rr(),Ru=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new ow.ObjectDisposedError("EventSource");if(this.metadata)for(let t in this.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=this.metadata[t]));for(let t in this.privEventListeners)t&&this.privEventListeners[t]&&this.privEventListeners[t](e)}attach(e){let t=aw.createNoDashGuid();return this.privEventListeners[t]=e,{detach:()=>(delete this.privEventListeners[t],Promise.resolve())}}attachListener(e){return this.attach(t=>e.onEvent(t))}attachConsoleListener(e){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach(t=>e.onEvent(t)),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}};Is.EventSource=Ru});var Tg=p(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.Events=void 0;var cw=ot(),pw=Eu(),Ts=class i{static setEventSource(e){if(!e)throw new cw.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};_s.Events=Ts;Ts.privInstance=new pw.EventSource});var Ag=p(_g=>{"use strict";Object.defineProperty(_g,"__esModule",{value:!0})});var bg=p(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.ConnectionState=void 0;var uw;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(uw=cn.ConnectionState||(cn.ConnectionState={}))});var Mg=p(Og=>{"use strict";Object.defineProperty(Og,"__esModule",{value:!0})});var kg=p(Dg=>{"use strict";Object.defineProperty(Dg,"__esModule",{value:!0})});var xg=p(Ng=>{"use strict";Object.defineProperty(Ng,"__esModule",{value:!0})});var zg=p(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0})});var Lg=p(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0})});var Fg=p(Bg=>{"use strict";Object.defineProperty(Bg,"__esModule",{value:!0})});var Ug=p(Vg=>{"use strict";Object.defineProperty(Vg,"__esModule",{value:!0})});var Hg=p(Wg=>{"use strict";Object.defineProperty(Wg,"__esModule",{value:!0})});var Iu=p(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.List=void 0;var dw=ot(),wu=class i{constructor(e){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],e)for(let t of e)this.privList.push(t)}get(e){return this.throwIfDisposed(),this.privList[e]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(e){this.throwIfDisposed(),this.insertAt(this.privList.length,e)}insertAt(e,t){this.throwIfDisposed(),e===0?this.privList.unshift(t):e===this.privList.length?this.privList.push(t):this.privList.splice(e,0,t),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(e){return this.throwIfDisposed(),this.remove(e,1)[0]}remove(e,t){this.throwIfDisposed();let r=this.privList.splice(e,t);return this.triggerSubscriptions(this.privRemoveSubscriptions),r}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[t]=e,{detach:()=>(delete this.privAddSubscriptions[t],Promise.resolve())}}onRemoved(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[t]=e,{detach:()=>(delete this.privRemoveSubscriptions[t],Promise.resolve())}}onDisposed(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[t]=e,{detach:()=>(delete this.privDisposedSubscriptions[t],Promise.resolve())}}join(e){return this.throwIfDisposed(),this.privList.join(e)}toArray(){let e=Array();return this.privList.forEach(t=>{e.push(t)}),e}any(e){return this.throwIfDisposed(),e?this.where(e).length()>0:this.length()>0}all(e){return this.throwIfDisposed(),this.where(e).length()===this.length()}forEach(e){this.throwIfDisposed();for(let t=0;t<this.length();t++)e(this.privList[t],t)}select(e){this.throwIfDisposed();let t=[];for(let r=0;r<this.privList.length;r++)t.push(e(this.privList[r],r));return new i(t)}where(e){this.throwIfDisposed();let t=new i;for(let r=0;r<this.privList.length;r++)e(this.privList[r],r)&&t.add(this.privList[r]);return t}orderBy(e){this.throwIfDisposed();let r=this.toArray().sort(e);return new i(r)}orderByDesc(e){return this.throwIfDisposed(),this.orderBy((t,r)=>e(r,t))}clone(){return this.throwIfDisposed(),new i(this.toArray())}concat(e){return this.throwIfDisposed(),new i(this.privList.concat(e.toArray()))}concatArray(e){return this.throwIfDisposed(),new i(this.privList.concat(e))}isDisposed(){return this.privList==null}dispose(e){this.isDisposed()||(this.privDisposeReason=e,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new dw.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};As.List=wu});var Au=p(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.marshalPromiseToCallbacks=be.Sink=be.Deferred=be.PromiseResultEventSource=be.PromiseResult=be.PromiseState=void 0;var jt;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(jt=be.PromiseState||(be.PromiseState={}));var bs=class{constructor(e){this.throwIfError=()=>{if(this.isError)throw this.error},e.on(t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=t)},t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=t)})}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}};be.PromiseResult=bs;var Os=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};be.PromiseResultEventSource=Os;var Tu=class{constructor(){this.resolve=e=>(this.privResolve(e),this),this.reject=e=>(this.privReject(e),this),this.privPromise=new Promise((e,t)=>{this.privResolve=e,this.privReject=t})}get promise(){return this.privPromise}};be.Deferred=Tu;var _u=class{constructor(){this.privState=jt.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new Os,this.privPromiseResult=new bs(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==jt.None)throw new Error("'Cannot resolve a completed promise'");this.privState=jt.Resolved,this.privPromiseResultEvents.setResult(e);for(let t=0;t<this.privSuccessHandlers.length;t++)this.executeSuccessCallback(e,this.privSuccessHandlers[t],this.privErrorHandlers[t]);this.detachHandlers()}reject(e){if(this.privState!==jt.None)throw new Error("'Cannot reject a completed promise'");this.privState=jt.Rejected,this.privPromiseResultEvents.setError(e);for(let t of this.privErrorHandlers)this.executeErrorCallback(e,t);this.detachHandlers()}on(e,t){e==null&&(e=()=>{}),this.privState===jt.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===jt.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===jt.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,t),this.detachHandlers())}executeSuccessCallback(e,t,r){try{t(e)}catch(n){this.executeErrorCallback(`'Unhandled callback error: ${n}'`,r)}}executeErrorCallback(e,t){if(t)try{t(e)}catch(r){throw new Error(`'Unhandled callback error: ${r}. InnerError: ${e}'`)}else throw new Error(`'Unhandled error: ${e}'`)}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}};be.Sink=_u;function hw(i,e,t){i.then(r=>{try{e&&e(r)}catch(n){if(t)try{if(n instanceof Error){let s=n;t(s.name+": "+s.message)}else t(n)}catch{}}},r=>{if(t)try{if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r)}catch{}})}be.marshalPromiseToCallbacks=hw});var Du=p(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.Queue=void 0;var bu=ot(),Ou=Iu(),Kg=Au(),pn;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(pn||(pn={}));var Mu=class{constructor(e){this.privPromiseStore=new Ou.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new Ou.List,this.privDetachables=[],this.privSubscribers=new Ou.List,this.privDetachables.push(this.privList.onAdded(()=>this.drain()))}enqueue(e){this.throwIfDispose(),this.enqueueFromPromise(new Promise(t=>t(e)))}enqueueFromPromise(e){this.throwIfDispose(),e.then(t=>{this.privList.add(t)},()=>{})}dequeue(){this.throwIfDispose();let e=new Kg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new Kg.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:pn.Peek}),this.drain()),e.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return this.privSubscribers==null}async drainAndDispose(e,t){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=t,this.privIsDisposing=!0;let r=this.privSubscribers;if(r){for(;r.length()>0;)r.removeFirst().deferral.resolve(void 0);this.privSubscribers===r&&(this.privSubscribers=r)}for(let n of this.privDetachables)await n.detach();if(this.privPromiseStore.length()>0&&e){let n=[];return this.privPromiseStore.toArray().forEach(s=>{n.push(s)}),Promise.all(n).finally(()=>{this.privSubscribers=null,this.privList.forEach(s=>{e(s)}),this.privList=null}).then()}else this.privSubscribers=null,this.privList=null}}async dispose(e){await this.drainAndDispose(null,e)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;let e=this.privSubscribers,t=this.privList;if(e&&t){for(;t.length()>0&&e.length()>0&&!this.privIsDisposing;){let r=e.removeFirst();if(r.type===pn.Peek)r.deferral.resolve(t.first());else{let n=t.removeFirst();r.deferral.resolve(n)}}this.privSubscribers===e&&(this.privSubscribers=e),this.privList===t&&(this.privList=t)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed())throw this.privDisposeReason?new bu.InvalidOperationError(this.privDisposeReason):new bu.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new bu.InvalidOperationError("Queue disposing")}};Ms.Queue=Mu});var Jg=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.RawWebsocketMessage=void 0;var Ds=mu(),un=ot(),lw=rr(),ku=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new un.ArgumentNullError("payload");if(e===Ds.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new un.InvalidOperationError("Payload must be ArrayBuffer");if(e===Ds.MessageType.Text&&typeof t!="string")throw new un.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||lw.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===Ds.MessageType.Binary)throw new un.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===Ds.MessageType.Text)throw new un.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};ks.RawWebsocketMessage=ku});var Gg=p(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.RiffPcmEncoder=void 0;var Nu=class{constructor(e,t){this.privActualSampleRate=e,this.privDesiredSampleRate=t}encode(e){let t=this.downSampleAudioFrame(e,this.privActualSampleRate,this.privDesiredSampleRate);if(!t)return null;let r=t.length*2,n=new ArrayBuffer(r),s=new DataView(n);return this.floatTo16BitPCM(s,0,t),n}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}floatTo16BitPCM(e,t,r){for(let n=0;n<r.length;n++,t+=2){let s=Math.max(-1,Math.min(1,r[n]));e.setInt16(t,s<0?s*32768:s*32767,!0)}}downSampleAudioFrame(e,t,r){if(!e)return null;if(r===t||r>t)return e;let n=t/r,s=Math.round(e.length/n),o=new Float32Array(s),a=0,c=0;for(;c<s;){let u=Math.round((c+1)*n),d=0,h=0;for(;a<u&&a<e.length;)d+=e[a++],h++;o[c++]=d/h}return o}};Ns.RiffPcmEncoder=Nu});var Yg=p(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.Stream=void 0;var $g=ot(),vw=rr(),Qg=Du(),xu=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||vw.createNoDashGuid(),this.privReaderQueue=new Qg.Queue}get isClosed(){return this.privIsWriteEnded}get isReadEnded(){return this.privIsReadEnded}get id(){return this.privId}close(){this.privIsWriteEnded||(this.writeStreamChunk({buffer:null,isEnd:!0,timeReceived:Date.now()}),this.privIsWriteEnded=!0)}writeStreamChunk(e){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(e)}catch{}}read(){if(this.privIsReadEnded)throw new $g.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then(async e=>((e===void 0||e.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),e))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new Qg.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new $g.InvalidOperationError("Stream closed")}};xs.Stream=xu});var qs=p(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.TranslationStatus=void 0;var fw;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(fw=dn.TranslationStatus||(dn.TranslationStatus={}))});var Xg=p(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.ChunkedArrayBufferStream=void 0;var gw=P(),qu=class extends gw.Stream{constructor(e,t){super(t),this.privTargetChunkSize=e,this.privNextBufferReadyBytes=0}writeStreamChunk(e){if(e.isEnd||this.privNextBufferReadyBytes===0&&e.buffer.byteLength===this.privTargetChunkSize){super.writeStreamChunk(e);return}let t=0;for(;t<e.buffer.byteLength;){this.privNextBufferToWrite===void 0&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=e.timeReceived);let r=Math.min(e.buffer.byteLength-t,this.privTargetChunkSize-this.privNextBufferReadyBytes),n=new Uint8Array(this.privNextBufferToWrite),s=new Uint8Array(e.buffer.slice(t,r+t));n.set(s,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=r,t+=r,this.privNextBufferReadyBytes===this.privTargetChunkSize&&(super.writeStreamChunk({buffer:this.privNextBufferToWrite,isEnd:!1,timeReceived:this.privNextBufferStartTime}),this.privNextBufferReadyBytes=0,this.privNextBufferToWrite=void 0)}}close(){this.privNextBufferReadyBytes!==0&&!this.isClosed&&super.writeStreamChunk({buffer:this.privNextBufferToWrite.slice(0,this.privNextBufferReadyBytes),isEnd:!1,timeReceived:this.privNextBufferStartTime}),super.close()}};zs.ChunkedArrayBufferStream=qu});var em=p(Zg=>{"use strict";Object.defineProperty(Zg,"__esModule",{value:!0})});var tm=p(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.Timeout=void 0;var St=class i{static load(){let e=new Map([[0,()=>{}]]),t=new Map,n="data:text/javascript;base64,"+btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`),s=new Worker(n);return s.addEventListener("message",({data:c})=>{if(i.isCallNotification(c)){let{params:{timerId:u}}=c,d=e.get(u);if(typeof d=="number"){let h=t.get(d);if(h===void 0||h!==u)throw new Error("The timer is in an undefined state.")}else if(typeof d<"u")d(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,d=t.get(u);if(d===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(d)}else{let{error:{message:u}}=c;throw new Error(u)}}),{clearTimeout:c=>{let u=Math.random();t.set(u,c),e.set(c,u),s.postMessage({id:u,method:"clear",params:{timerId:c}})},setTimeout:(c,u)=>{let d=Math.random();return e.set(d,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:d}}),d}}}static loadWorkerTimers(){return()=>(i.workerTimers!==null||(i.workerTimers=i.load()),i.workerTimers)}static isCallNotification(e){return e.method!==void 0&&e.method==="call"}static isClearResponse(e){return e.error===null&&typeof e.id=="number"}};js.Timeout=St;St.workerTimers=null;St.clearTimeout=i=>St.timers().clearTimeout(i);St.setTimeout=(i,e)=>St.timers().setTimeout(i,e);St.timers=St.loadWorkerTimers()});var rm=p(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.OCSPCacheUpdateErrorEvent=D.OCSPResponseRetrievedEvent=D.OCSPCacheFetchErrorEvent=D.OCSPVerificationFailedEvent=D.OCSPCacheHitEvent=D.OCSPCacheEntryNeedsRefreshEvent=D.OCSPCacheEntryExpiredEvent=D.OCSPWSUpgradeStartedEvent=D.OCSPStapleReceivedEvent=D.OCSPCacheUpdateCompleteEvent=D.OCSPDiskCacheStoreEvent=D.OCSPMemoryCacheStoreEvent=D.OCSPCacheUpdateNeededEvent=D.OCSPDiskCacheHitEvent=D.OCSPCacheMissEvent=D.OCSPMemoryCacheHitEvent=D.OCSPEvent=void 0;var de=ui(),oe=class extends de.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};D.OCSPEvent=oe;var zu=class extends oe{constructor(e){super("OCSPMemoryCacheHitEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheHitEvent=zu;var ju=class extends oe{constructor(e){super("OCSPCacheMissEvent",de.EventType.Debug,e)}};D.OCSPCacheMissEvent=ju;var Lu=class extends oe{constructor(e){super("OCSPDiskCacheHitEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheHitEvent=Lu;var Bu=class extends oe{constructor(e){super("OCSPCacheUpdateNeededEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateNeededEvent=Bu;var Fu=class extends oe{constructor(e){super("OCSPMemoryCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPMemoryCacheStoreEvent=Fu;var Vu=class extends oe{constructor(e){super("OCSPDiskCacheStoreEvent",de.EventType.Debug,e)}};D.OCSPDiskCacheStoreEvent=Vu;var Uu=class extends oe{constructor(e){super("OCSPCacheUpdateCompleteEvent",de.EventType.Debug,e)}};D.OCSPCacheUpdateCompleteEvent=Uu;var Wu=class extends oe{constructor(){super("OCSPStapleReceivedEvent",de.EventType.Debug,"")}};D.OCSPStapleReceivedEvent=Wu;var Hu=class extends oe{constructor(e){super("OCSPWSUpgradeStartedEvent",de.EventType.Debug,e)}};D.OCSPWSUpgradeStartedEvent=Hu;var Ku=class extends oe{constructor(e,t){super("OCSPCacheEntryExpiredEvent",de.EventType.Debug,e),this.privExpireTime=t}};D.OCSPCacheEntryExpiredEvent=Ku;var Ju=class extends oe{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};D.OCSPCacheEntryNeedsRefreshEvent=Ju;var Gu=class extends oe{constructor(e,t,r){super("OCSPCacheHitEvent",de.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};D.OCSPCacheHitEvent=Gu;var $u=class extends oe{constructor(e,t){super("OCSPVerificationFailedEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPVerificationFailedEvent=$u;var Qu=class extends oe{constructor(e,t){super("OCSPCacheFetchErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheFetchErrorEvent=Qu;var Yu=class extends oe{constructor(e){super("OCSPResponseRetrievedEvent",de.EventType.Debug,e)}};D.OCSPResponseRetrievedEvent=Yu;var Xu=class extends oe{constructor(e,t){super("OCSPCacheUpdateErrorEvent",de.EventType.Debug,e),this.privError=t}};D.OCSPCacheUpdateErrorEvent=Xu});var nm=p(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.BackgroundEvent=void 0;var im=P(),Zu=class extends im.PlatformEvent{constructor(e){super("BackgroundEvent",im.EventType.Error),this.privError=e}get error(){return this.privError}};Ls.BackgroundEvent=Zu});var P=p(b=>{"use strict";var mw=b&&b.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),N=b&&b.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&mw(e,i,t)};Object.defineProperty(b,"__esModule",{value:!0});N(nu(),b);N(Rg(),b);N(mu(),b);N(Eg(),b);N(wg(),b);N(Pu(),b);N(ot(),b);N(Tg(),b);N(Eu(),b);N(rr(),b);N(Ag(),b);N(bg(),b);N(Mg(),b);N(kg(),b);N(xg(),b);N(zg(),b);N(Lg(),b);N(Fg(),b);N(Ug(),b);N(Hg(),b);N(Iu(),b);N(ui(),b);N(Au(),b);N(Du(),b);N(Jg(),b);N(Gg(),b);N(Yg(),b);var Sw=qs();Object.defineProperty(b,"TranslationStatus",{enumerable:!0,get:function(){return Sw.TranslationStatus}});N(Xg(),b);N(em(),b);N(tm(),b);N(rm(),b);N(nm(),b)});var we=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.HeaderNames=void 0;var Le=class{};Bs.HeaderNames=Le;Le.AuthKey="Ocp-Apim-Subscription-Key";Le.Authorization="Authorization";Le.SpIDAuthKey="Apim-Subscription-Id";Le.ConnectionId="X-ConnectionId";Le.ContentType="Content-Type";Le.CustomCommandsAppId="X-CommandsAppId";Le.Path="Path";Le.RequestId="X-RequestId";Le.RequestStreamId="X-StreamId";Le.RequestTimestamp="X-Timestamp"});var Vs=p(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.AuthInfo=void 0;var ed=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};Fs.AuthInfo=ed});var sm=p(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.CognitiveSubscriptionKeyAuthentication=void 0;var yw=P(),Cw=we(),Pw=Vs(),td=class{constructor(e){if(!e)throw new yw.ArgumentNullError("subscriptionKey");this.privAuthInfo=new Pw.AuthInfo(Cw.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};Us.CognitiveSubscriptionKeyAuthentication=td});var pm=p(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.CognitiveTokenAuthentication=void 0;var om=P(),am=Vs(),cm=we(),Ws=class i{constructor(e,t){if(!e)throw new om.ArgumentNullError("fetchCallback");if(!t)throw new om.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new am.AuthInfo(cm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new am.AuthInfo(cm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};Hs.CognitiveTokenAuthentication=Ws;Ws.privTokenPrefix="Bearer "});var dm=p(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0})});var lm=p(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0})});var rd=p(()=>{});var id=p(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.LogLevel=void 0;var Rw=P();Object.defineProperty(Ks,"LogLevel",{enumerable:!0,get:function(){return Rw.EventType}})});var w=p(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.Contracts=void 0;var nd=class i{static throwIfNullOrUndefined(e,t){if(e==null)throw new Error("throwIfNullOrUndefined:"+t)}static throwIfNull(e,t){if(e===null)throw new Error("throwIfNull:"+t)}static throwIfNullOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)}static throwIfNullOrTooLong(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length>r)throw new Error("throwIfNullOrTooLong:"+t+" (more than "+r.toString()+" characters)")}static throwIfNullOrTooShort(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length<r)throw new Error("throwIfNullOrTooShort:"+t+" (less than "+r.toString()+" characters)")}static throwIfDisposed(e){if(e)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),e.length===0)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(let r of e)i.throwIfNullOrWhitespace(r,t)}static throwIfFileDoesNotExist(e,t){i.throwIfNullOrWhitespace(e,t)}static throwIfNotUndefined(e,t){if(e!==void 0)throw new Error("throwIfNotUndefined:"+t)}};Js.Contracts=nd});var fm=p(yt=>{"use strict";var Ew=yt&&yt.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),ww=yt&&yt.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Iw=yt&&yt.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&Ew(e,i,t);return ww(e,i),e};Object.defineProperty(yt,"__esModule",{value:!0});yt.ConsoleLoggingListener=void 0;var vm=Iw(rd()),hn=id(),Tw=w(),sd=class{constructor(e=hn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){Tw.Contracts.throwIfNullOrUndefined(vm.openSync,`
|
|
2
|
-
File System access not available`),this.privLogPath=e}set enableConsoleOutput(e){this.privEnableConsoleOutput=e}onEvent(e){if(e.eventType>=this.privLogLevelFilter){let t=this.toString(e);if(this.logCallback&&this.logCallback(t),this.privLogPath&&
|
|
3
|
-
`,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case hn.LogLevel.Debug:console.debug(t);break;case hn.LogLevel.Info:console.info(t);break;case hn.LogLevel.Warning:console.warn(t);break;case hn.LogLevel.Error:console.error(t);break;default:console.log(t);break}}}toString(e){let t=[`${e.eventTime}`,`${e.name}`],r=e;for(let n in r)if(n&&e.hasOwnProperty(n)&&n!=="eventTime"&&n!=="eventType"&&n!=="eventId"&&n!=="name"&&n!=="constructor"){let s=r[n],o="<NULL>";s!=null&&(typeof s=="number"||typeof s=="string"?o=s.toString():o=JSON.stringify(s)),t.push(`${n}: ${o}`)}return t.join(" | ")}};yt.ConsoleLoggingListener=sd});var mm=p(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0})});var sr=p(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.AudioStreamFormatImpl=Lt.AudioStreamFormat=Lt.AudioFormatTag=void 0;var ln;(function(i){i[i.PCM=1]="PCM",i[i.MuLaw=2]="MuLaw",i[i.Siren=3]="Siren",i[i.MP3=4]="MP3",i[i.SILKSkype=5]="SILKSkype",i[i.OGG_OPUS=6]="OGG_OPUS",i[i.WEBM_OPUS=7]="WEBM_OPUS",i[i.ALaw=8]="ALaw",i[i.FLAC=9]="FLAC",i[i.OPUS=10]="OPUS"})(ln=Lt.AudioFormatTag||(Lt.AudioFormatTag={}));var Gs=class{static getDefaultInputFormat(){return hi.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new hi(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new hi(e,t,r)}};Lt.AudioStreamFormat=Gs;var hi=class i extends Gs{constructor(e=16e3,t=16,r=1,n=ln.PCM){super();let s=!0;switch(n){case ln.PCM:this.formatTag=1;break;case ln.ALaw:this.formatTag=6;break;case ln.MuLaw:this.formatTag=7;break;default:s=!1}if(this.bitsPerSample=t,this.samplesPerSec=e,this.channels=r,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),s){this.privHeader=new ArrayBuffer(44);let o=new DataView(this.privHeader);this.setString(o,0,"RIFF"),o.setUint32(4,0,!0),this.setString(o,8,"WAVEfmt "),o.setUint32(16,16,!0),o.setUint16(20,this.formatTag,!0),o.setUint16(22,this.channels,!0),o.setUint32(24,this.samplesPerSec,!0),o.setUint32(28,this.avgBytesPerSec,!0),o.setUint16(32,this.channels*(this.bitsPerSample/8),!0),o.setUint16(34,this.bitsPerSample,!0),this.setString(o,36,"data"),o.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new i}static getAudioContext(e){let t=window.AudioContext||window.webkitAudioContext||!1;if(t)return e!==void 0&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new t({sampleRate:e}):new t;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}};Lt.AudioStreamFormatImpl=hi});var Cm=p(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.MicAudioSource=Mr.AudioWorkletSourceURLPropertyName=void 0;var Sm=C(),he=P(),ym=sr();Mr.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var $s=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||he.createNoDashGuid(),this.privEvents=new he.EventSource,this.privMediaStream=n||null,this.privIsClosing=!1}get format(){return Promise.resolve(i.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new he.Deferred;try{this.createAudioContext()}catch(r){if(r instanceof Error){let n=r;this.privInitializeDeferral.reject(n.name+": "+n.message)}else this.privInitializeDeferral.reject(r);return this.privInitializeDeferral.promise}let e=window.navigator,t=e.getUserMedia||e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia;if(e.mediaDevices&&(t=(r,n,s)=>{e.mediaDevices.getUserMedia(r).then(n).catch(s)}),t){let r=()=>{this.onEvent(new he.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new he.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new he.AudioSourceErrorEvent(this.privId,s))})};this.privContext.state==="suspended"?this.privContext.resume().then(r).catch(n=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${n}`)}):r()}else{let r="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(r),this.onEvent(new he.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new he.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new he.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new he.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}))}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new he.AudioStreamNodeDetachedEvent(this.privId,e)))}async turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&t.close()}this.onEvent(new he.AudioSourceOffEvent(this.privId)),this.privInitializeDeferral&&(await this.privInitializeDeferral,this.privInitializeDeferral=null),await this.destroyAudioContext()}get events(){return this.privEvents}get deviceInfo(){return this.getMicrophoneLabel().then(e=>({bitspersample:i.AUDIOFORMAT.bitsPerSample,channelcount:i.AUDIOFORMAT.channels,connectivity:Sm.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:Sm.type.Microphones}))}setProperty(e,t){if(e===Mr.AudioWorkletSourceURLPropertyName)this.privRecorder.setWorkletUrl(t);else throw new Error("Property '"+e+"' is not supported on Microphone.")}getMicrophoneLabel(){let e="microphone";if(this.privMicrophoneLabel!==void 0)return Promise.resolve(this.privMicrophoneLabel);if(this.privMediaStream===void 0||!this.privMediaStream.active)return Promise.resolve(e);this.privMicrophoneLabel=e;let t=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(t===void 0)return Promise.resolve(this.privMicrophoneLabel);let r=new he.Deferred;return navigator.mediaDevices.enumerateDevices().then(n=>{for(let s of n)if(s.deviceId===t){this.privMicrophoneLabel=s.label;break}r.resolve(this.privMicrophoneLabel)},()=>r.resolve(this.privMicrophoneLabel)),r.promise}async listen(e){await this.turnOn();let t=new he.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new he.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),he.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=ym.AudioStreamFormatImpl.getAudioContext(i.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let e=!1;"close"in this.privContext&&(e=!0),e?this.privIsClosing||(this.privIsClosing=!0,await this.privContext.close(),this.privContext=null,this.privIsClosing=!1):this.privContext!==null&&this.privContext.state==="running"&&await this.privContext.suspend()}};Mr.MicAudioSource=$s;$s.AUDIOFORMAT=ym.AudioStreamFormat.getDefaultInputFormat()});var Rm=p(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.FileAudioSource=void 0;var Pm=C(),ke=P(),_w=sr(),od=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||ke.createNoDashGuid(),this.privEvents=new ke.EventSource,this.privSource=e,typeof window<"u"&&typeof Blob<"u"&&this.privSource instanceof Blob?this.privFilename=e.name:this.privFilename=t||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){let e=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new ke.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new ke.AudioSourceInitializingEvent(this.privId)),this.onEvent(new ke.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new ke.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new ke.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new ke.AudioStreamNodeDetachedEvent(this.privId,e)),await this.turnOff()},id:()=>e,read:()=>t.read()})}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new ke.AudioStreamNodeDetachedEvent(this.privId,e)))}turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&!t.isClosed&&t.close()}return this.onEvent(new ke.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then(e=>Promise.resolve({bitspersample:e.bitsPerSample,channelcount:e.channels,connectivity:Pm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Pm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new ke.Deferred,n=s=>{let o=new DataView(s),a=g=>String.fromCharCode(o.getUint8(g),o.getUint8(g+1),o.getUint8(g+2),o.getUint8(g+3));if(a(0)!=="RIFF"){r.reject("Invalid WAV header in file, RIFF was not found");return}if(a(8)!=="WAVE"||a(12)!=="fmt "){r.reject("Invalid WAV header in file, WAVEfmt was not found");return}let c=o.getInt32(16,!0),u=o.getUint16(22,!0),d=o.getUint32(24,!0),h=o.getUint16(34,!0),l=36+Math.max(c-16,0);for(;a(l)!=="data";l+=2)if(l>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=l+8,r.resolve(_w.AudioStreamFormat.getWaveFormatPCM(d,h,u))};if(typeof window<"u"&&typeof Blob<"u"&&t instanceof Blob){let s=new FileReader;s.onload=o=>{let a=o.target.result;n(a)},s.readAsArrayBuffer(t)}else{let s=t;n(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength))}return r.promise}async upload(e){let t=r=>{let n=`Error occurred while processing '${this.privFilename}'. ${r}`;throw this.onEvent(new ke.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new ke.ChunkedArrayBufferStream(r.avgBytesPerSec/10,e);this.privStreams[e]=n;let s=this.privSource.slice(this.privHeaderEnd),o=a=>{n.isClosed||(n.writeStreamChunk({buffer:a,isEnd:!1,timeReceived:Date.now()}),n.close())};if(typeof window<"u"&&typeof Blob<"u"&&s instanceof Blob){let a=new FileReader;a.onerror=c=>t(c.toString()),a.onload=c=>{let u=c.target.result;o(u)},a.readAsArrayBuffer(s)}else{let a=s;o(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength))}return n}catch(r){t(r)}}onEvent(e){this.privEvents.onEvent(e),ke.Events.instance.onEvent(e)}};Qs.FileAudioSource=od});var Em=p(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.PcmRecorder=void 0;var Aw=P(),ad=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new Aw.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let d=0;try{return e.createScriptProcessor(d,1,1)}catch{d=2048;let l=e.sampleRate;for(;d<16384&&l>=32e3;)d<<=1,l>>=1;return e.createScriptProcessor(d,1,1)}})();u.onaudioprocess=d=>{let h=d.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}},c=!!this.privSpeechProcessorScript&&this.privSpeechProcessorScript.toLowerCase()==="ignore";if(e.audioWorklet&&!c){if(!this.privSpeechProcessorScript){let u=`class SP extends AudioWorkletProcessor {
|
|
1
|
+
"use strict";(()=>{var mE=Object.create;var _g=Object.defineProperty;var yE=Object.getOwnPropertyDescriptor;var SE=Object.getOwnPropertyNames;var CE=Object.getPrototypeOf,PE=Object.prototype.hasOwnProperty;var p=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var RE=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of SE(e))!PE.call(i,n)&&n!==t&&_g(i,n,{get:()=>e[n],enumerable:!(r=yE(e,n))||r.enumerable});return i};var Xu=(i,e,t)=>(t=i!=null?mE(CE(i)):{},RE(e||!i||!i.__esModule?_g(t,"default",{value:i,enumerable:!0}):t,i));var Yu=p(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.default=_E;var gs,EE=new Uint8Array(16);function _E(){if(!gs&&(gs=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!gs))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return gs(EE)}});var Ig=p(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.default=void 0;var IE=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;ms.default=IE});var dn=p(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.default=void 0;var wE=bE(Ig());function bE(i){return i&&i.__esModule?i:{default:i}}function AE(i){return typeof i=="string"&&wE.default.test(i)}var TE=AE;ys.default=TE});var fn=p(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.default=void 0;vn.unsafeStringify=wg;var OE=kE(dn());function kE(i){return i&&i.__esModule?i:{default:i}}var le=[];for(let i=0;i<256;++i)le.push((i+256).toString(16).slice(1));function wg(i,e=0){return le[i[e+0]]+le[i[e+1]]+le[i[e+2]]+le[i[e+3]]+"-"+le[i[e+4]]+le[i[e+5]]+"-"+le[i[e+6]]+le[i[e+7]]+"-"+le[i[e+8]]+le[i[e+9]]+"-"+le[i[e+10]]+le[i[e+11]]+le[i[e+12]]+le[i[e+13]]+le[i[e+14]]+le[i[e+15]]}function ME(i,e=0){let t=wg(i,e);if(!(0,OE.default)(t))throw TypeError("Stringified UUID is invalid");return t}var DE=ME;vn.default=DE});var Ag=p(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.default=void 0;var xE=qE(Yu()),NE=fn();function qE(i){return i&&i.__esModule?i:{default:i}}var bg,ep,tp=0,rp=0;function jE(i,e,t){let r=e&&t||0,n=e||new Array(16);i=i||{};let s=i.node||bg,o=i.clockseq!==void 0?i.clockseq:ep;if(s==null||o==null){let d=i.random||(i.rng||xE.default)();s==null&&(s=bg=[d[0]|1,d[1],d[2],d[3],d[4],d[5]]),o==null&&(o=ep=(d[6]<<8|d[7])&16383)}let a=i.msecs!==void 0?i.msecs:Date.now(),c=i.nsecs!==void 0?i.nsecs:rp+1,u=a-tp+(c-rp)/1e4;if(u<0&&i.clockseq===void 0&&(o=o+1&16383),(u<0||a>tp)&&i.nsecs===void 0&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");tp=a,rp=c,ep=o,a+=122192928e5;let l=((a&268435455)*1e4+c)%4294967296;n[r++]=l>>>24&255,n[r++]=l>>>16&255,n[r++]=l>>>8&255,n[r++]=l&255;let h=a/4294967296*1e4&268435455;n[r++]=h>>>8&255,n[r++]=h&255,n[r++]=h>>>24&15|16,n[r++]=h>>>16&255,n[r++]=o>>>8|128,n[r++]=o&255;for(let d=0;d<6;++d)n[r+d]=s[d];return e||(0,NE.unsafeStringify)(n)}var zE=jE;Ss.default=zE});var ip=p(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.default=void 0;var LE=BE(dn());function BE(i){return i&&i.__esModule?i:{default:i}}function FE(i){if(!(0,LE.default)(i))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(i.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(i.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(i.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(i.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(i.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var VE=FE;Cs.default=VE});var np=p(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.URL=Mr.DNS=void 0;Mr.default=JE;var UE=fn(),WE=HE(ip());function HE(i){return i&&i.__esModule?i:{default:i}}function KE(i){i=unescape(encodeURIComponent(i));let e=[];for(let t=0;t<i.length;++t)e.push(i.charCodeAt(t));return e}var Tg="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Mr.DNS=Tg;var Og="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Mr.URL=Og;function JE(i,e,t){function r(n,s,o,a){var c;if(typeof n=="string"&&(n=KE(n)),typeof s=="string"&&(s=(0,WE.default)(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+n.length);if(u.set(s),u.set(n,s.length),u=t(u),u[6]=u[6]&15|e,u[8]=u[8]&63|128,o){a=a||0;for(let l=0;l<16;++l)o[a+l]=u[l];return o}return(0,UE.unsafeStringify)(u)}try{r.name=i}catch{}return r.DNS=Tg,r.URL=Og,r}});var Mg=p(Rs=>{"use strict";Object.defineProperty(Rs,"__esModule",{value:!0});Rs.default=void 0;function GE(i){if(typeof i=="string"){let e=unescape(encodeURIComponent(i));i=new Uint8Array(e.length);for(let t=0;t<e.length;++t)i[t]=e.charCodeAt(t)}return $E(QE(XE(i),i.length*8))}function $E(i){let e=[],t=i.length*32,r="0123456789abcdef";for(let n=0;n<t;n+=8){let s=i[n>>5]>>>n%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function kg(i){return(i+64>>>9<<4)+14+1}function QE(i,e){i[e>>5]|=128<<e%32,i[kg(e)-1]=e;let t=1732584193,r=-271733879,n=-1732584194,s=271733878;for(let o=0;o<i.length;o+=16){let a=t,c=r,u=n,l=s;t=Pe(t,r,n,s,i[o],7,-680876936),s=Pe(s,t,r,n,i[o+1],12,-389564586),n=Pe(n,s,t,r,i[o+2],17,606105819),r=Pe(r,n,s,t,i[o+3],22,-1044525330),t=Pe(t,r,n,s,i[o+4],7,-176418897),s=Pe(s,t,r,n,i[o+5],12,1200080426),n=Pe(n,s,t,r,i[o+6],17,-1473231341),r=Pe(r,n,s,t,i[o+7],22,-45705983),t=Pe(t,r,n,s,i[o+8],7,1770035416),s=Pe(s,t,r,n,i[o+9],12,-1958414417),n=Pe(n,s,t,r,i[o+10],17,-42063),r=Pe(r,n,s,t,i[o+11],22,-1990404162),t=Pe(t,r,n,s,i[o+12],7,1804603682),s=Pe(s,t,r,n,i[o+13],12,-40341101),n=Pe(n,s,t,r,i[o+14],17,-1502002290),r=Pe(r,n,s,t,i[o+15],22,1236535329),t=Re(t,r,n,s,i[o+1],5,-165796510),s=Re(s,t,r,n,i[o+6],9,-1069501632),n=Re(n,s,t,r,i[o+11],14,643717713),r=Re(r,n,s,t,i[o],20,-373897302),t=Re(t,r,n,s,i[o+5],5,-701558691),s=Re(s,t,r,n,i[o+10],9,38016083),n=Re(n,s,t,r,i[o+15],14,-660478335),r=Re(r,n,s,t,i[o+4],20,-405537848),t=Re(t,r,n,s,i[o+9],5,568446438),s=Re(s,t,r,n,i[o+14],9,-1019803690),n=Re(n,s,t,r,i[o+3],14,-187363961),r=Re(r,n,s,t,i[o+8],20,1163531501),t=Re(t,r,n,s,i[o+13],5,-1444681467),s=Re(s,t,r,n,i[o+2],9,-51403784),n=Re(n,s,t,r,i[o+7],14,1735328473),r=Re(r,n,s,t,i[o+12],20,-1926607734),t=Ee(t,r,n,s,i[o+5],4,-378558),s=Ee(s,t,r,n,i[o+8],11,-2022574463),n=Ee(n,s,t,r,i[o+11],16,1839030562),r=Ee(r,n,s,t,i[o+14],23,-35309556),t=Ee(t,r,n,s,i[o+1],4,-1530992060),s=Ee(s,t,r,n,i[o+4],11,1272893353),n=Ee(n,s,t,r,i[o+7],16,-155497632),r=Ee(r,n,s,t,i[o+10],23,-1094730640),t=Ee(t,r,n,s,i[o+13],4,681279174),s=Ee(s,t,r,n,i[o],11,-358537222),n=Ee(n,s,t,r,i[o+3],16,-722521979),r=Ee(r,n,s,t,i[o+6],23,76029189),t=Ee(t,r,n,s,i[o+9],4,-640364487),s=Ee(s,t,r,n,i[o+12],11,-421815835),n=Ee(n,s,t,r,i[o+15],16,530742520),r=Ee(r,n,s,t,i[o+2],23,-995338651),t=_e(t,r,n,s,i[o],6,-198630844),s=_e(s,t,r,n,i[o+7],10,1126891415),n=_e(n,s,t,r,i[o+14],15,-1416354905),r=_e(r,n,s,t,i[o+5],21,-57434055),t=_e(t,r,n,s,i[o+12],6,1700485571),s=_e(s,t,r,n,i[o+3],10,-1894986606),n=_e(n,s,t,r,i[o+10],15,-1051523),r=_e(r,n,s,t,i[o+1],21,-2054922799),t=_e(t,r,n,s,i[o+8],6,1873313359),s=_e(s,t,r,n,i[o+15],10,-30611744),n=_e(n,s,t,r,i[o+6],15,-1560198380),r=_e(r,n,s,t,i[o+13],21,1309151649),t=_e(t,r,n,s,i[o+4],6,-145523070),s=_e(s,t,r,n,i[o+11],10,-1120210379),n=_e(n,s,t,r,i[o+2],15,718787259),r=_e(r,n,s,t,i[o+9],21,-343485551),t=or(t,a),r=or(r,c),n=or(n,u),s=or(s,l)}return[t,r,n,s]}function XE(i){if(i.length===0)return[];let e=i.length*8,t=new Uint32Array(kg(e));for(let r=0;r<e;r+=8)t[r>>5]|=(i[r/8]&255)<<r%32;return t}function or(i,e){let t=(i&65535)+(e&65535);return(i>>16)+(e>>16)+(t>>16)<<16|t&65535}function ZE(i,e){return i<<e|i>>>32-e}function Ps(i,e,t,r,n,s){return or(ZE(or(or(e,i),or(r,s)),n),t)}function Pe(i,e,t,r,n,s,o){return Ps(e&t|~e&r,i,e,n,s,o)}function Re(i,e,t,r,n,s,o){return Ps(e&r|t&~r,i,e,n,s,o)}function Ee(i,e,t,r,n,s,o){return Ps(e^t^r,i,e,n,s,o)}function _e(i,e,t,r,n,s,o){return Ps(t^(e|~r),i,e,n,s,o)}var YE=GE;Rs.default=YE});var xg=p(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.default=void 0;var e_=Dg(np()),t_=Dg(Mg());function Dg(i){return i&&i.__esModule?i:{default:i}}var r_=(0,e_.default)("v3",48,t_.default),i_=r_;Es.default=i_});var Ng=p(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.default=void 0;var n_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),s_={randomUUID:n_};_s.default=s_});var zg=p(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.default=void 0;var qg=jg(Ng()),o_=jg(Yu()),a_=fn();function jg(i){return i&&i.__esModule?i:{default:i}}function c_(i,e,t){if(qg.default.randomUUID&&!e&&!i)return qg.default.randomUUID();i=i||{};let r=i.random||(i.rng||o_.default)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=r[n];return e}return(0,a_.unsafeStringify)(r)}var u_=c_;Is.default=u_});var Lg=p(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.default=void 0;function p_(i,e,t,r){switch(i){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function sp(i,e){return i<<e|i>>>32-e}function l_(i){let e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof i=="string"){let o=unescape(encodeURIComponent(i));i=[];for(let a=0;a<o.length;++a)i.push(o.charCodeAt(a))}else Array.isArray(i)||(i=Array.prototype.slice.call(i));i.push(128);let r=i.length/4+2,n=Math.ceil(r/16),s=new Array(n);for(let o=0;o<n;++o){let a=new Uint32Array(16);for(let c=0;c<16;++c)a[c]=i[o*64+c*4]<<24|i[o*64+c*4+1]<<16|i[o*64+c*4+2]<<8|i[o*64+c*4+3];s[o]=a}s[n-1][14]=(i.length-1)*8/Math.pow(2,32),s[n-1][14]=Math.floor(s[n-1][14]),s[n-1][15]=(i.length-1)*8&4294967295;for(let o=0;o<n;++o){let a=new Uint32Array(80);for(let g=0;g<16;++g)a[g]=s[o][g];for(let g=16;g<80;++g)a[g]=sp(a[g-3]^a[g-8]^a[g-14]^a[g-16],1);let c=t[0],u=t[1],l=t[2],h=t[3],d=t[4];for(let g=0;g<80;++g){let M=Math.floor(g/20),D=sp(c,5)+p_(M,u,l,h)+d+e[M]+a[g]>>>0;d=h,h=l,l=sp(u,30)>>>0,u=c,c=D}t[0]=t[0]+c>>>0,t[1]=t[1]+u>>>0,t[2]=t[2]+l>>>0,t[3]=t[3]+h>>>0,t[4]=t[4]+d>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var h_=l_;ws.default=h_});var Fg=p(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.default=void 0;var d_=Bg(np()),v_=Bg(Lg());function Bg(i){return i&&i.__esModule?i:{default:i}}var f_=(0,d_.default)("v5",80,v_.default),g_=f_;bs.default=g_});var Vg=p(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.default=void 0;var m_="00000000-0000-0000-0000-000000000000";As.default=m_});var Ug=p(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.default=void 0;var y_=S_(dn());function S_(i){return i&&i.__esModule?i:{default:i}}function C_(i){if(!(0,y_.default)(i))throw TypeError("Invalid UUID");return parseInt(i.slice(14,15),16)}var P_=C_;Ts.default=P_});var Wg=p(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});Object.defineProperty(ut,"NIL",{enumerable:!0,get:function(){return w_.default}});Object.defineProperty(ut,"parse",{enumerable:!0,get:function(){return O_.default}});Object.defineProperty(ut,"stringify",{enumerable:!0,get:function(){return T_.default}});Object.defineProperty(ut,"v1",{enumerable:!0,get:function(){return R_.default}});Object.defineProperty(ut,"v3",{enumerable:!0,get:function(){return E_.default}});Object.defineProperty(ut,"v4",{enumerable:!0,get:function(){return __.default}});Object.defineProperty(ut,"v5",{enumerable:!0,get:function(){return I_.default}});Object.defineProperty(ut,"validate",{enumerable:!0,get:function(){return A_.default}});Object.defineProperty(ut,"version",{enumerable:!0,get:function(){return b_.default}});var R_=Vt(Ag()),E_=Vt(xg()),__=Vt(zg()),I_=Vt(Fg()),w_=Vt(Vg()),b_=Vt(Ug()),A_=Vt(dn()),T_=Vt(fn()),O_=Vt(ip());function Vt(i){return i&&i.__esModule?i:{default:i}}});var ar=p(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.createNoDashGuid=mi.createGuid=void 0;var k_=Wg(),Hg=()=>k_.v4();mi.createGuid=Hg;var M_=()=>Hg().replace(new RegExp("-","g"),"").toUpperCase();mi.createNoDashGuid=M_});var yi=p(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.PlatformEvent=Dr.EventType=void 0;var D_=ar(),x_;(function(i){i[i.Debug=0]="Debug",i[i.Info=1]="Info",i[i.Warning=2]="Warning",i[i.Error=3]="Error",i[i.None=4]="None"})(x_=Dr.EventType||(Dr.EventType={}));var op=class{constructor(e,t){this.privName=e,this.privEventId=D_.createNoDashGuid(),this.privEventTime=new Date().toISOString(),this.privEventType=t,this.privMetadata={}}get name(){return this.privName}get eventId(){return this.privEventId}get eventTime(){return this.privEventTime}get eventType(){return this.privEventType}get metadata(){return this.privMetadata}};Dr.PlatformEvent=op});var gp=p($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.AudioStreamNodeErrorEvent=$.AudioStreamNodeDetachedEvent=$.AudioStreamNodeAttachedEvent=$.AudioStreamNodeAttachingEvent=$.AudioStreamNodeEvent=$.AudioSourceErrorEvent=$.AudioSourceOffEvent=$.AudioSourceReadyEvent=$.AudioSourceInitializingEvent=$.AudioSourceEvent=void 0;var ap=yi(),cr=class extends ap.PlatformEvent{constructor(e,t,r=ap.EventType.Info){super(e,r),this.privAudioSourceId=t}get audioSourceId(){return this.privAudioSourceId}};$.AudioSourceEvent=cr;var cp=class extends cr{constructor(e){super("AudioSourceInitializingEvent",e)}};$.AudioSourceInitializingEvent=cp;var up=class extends cr{constructor(e){super("AudioSourceReadyEvent",e)}};$.AudioSourceReadyEvent=up;var pp=class extends cr{constructor(e){super("AudioSourceOffEvent",e)}};$.AudioSourceOffEvent=pp;var lp=class extends cr{constructor(e,t){super("AudioSourceErrorEvent",e,ap.EventType.Error),this.privError=t}get error(){return this.privError}};$.AudioSourceErrorEvent=lp;var xr=class extends cr{constructor(e,t,r){super(e,t),this.privAudioNodeId=r}get audioNodeId(){return this.privAudioNodeId}};$.AudioStreamNodeEvent=xr;var hp=class extends xr{constructor(e,t){super("AudioStreamNodeAttachingEvent",e,t)}};$.AudioStreamNodeAttachingEvent=hp;var dp=class extends xr{constructor(e,t){super("AudioStreamNodeAttachedEvent",e,t)}};$.AudioStreamNodeAttachedEvent=dp;var vp=class extends xr{constructor(e,t){super("AudioStreamNodeDetachedEvent",e,t)}};$.AudioStreamNodeDetachedEvent=vp;var fp=class extends xr{constructor(e,t,r){super("AudioStreamNodeErrorEvent",e,t),this.privError=r}get error(){return this.privError}};$.AudioStreamNodeErrorEvent=fp});var Kg=p(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.ConnectionMessageSentEvent=te.ConnectionMessageReceivedEvent=te.ConnectionEstablishErrorEvent=te.ConnectionErrorEvent=te.ConnectionClosedEvent=te.ConnectionEstablishedEvent=te.ConnectionStartEvent=te.ConnectionEvent=te.ServiceEvent=void 0;var Nr=yi(),mp=class extends Nr.PlatformEvent{constructor(e,t,r=Nr.EventType.Info){super(e,r),this.privJsonResult=t}get jsonString(){return this.privJsonResult}};te.ServiceEvent=mp;var Rt=class extends Nr.PlatformEvent{constructor(e,t,r=Nr.EventType.Info){super(e,r),this.privConnectionId=t}get connectionId(){return this.privConnectionId}};te.ConnectionEvent=Rt;var yp=class extends Rt{constructor(e,t,r){super("ConnectionStartEvent",e),this.privUri=t,this.privHeaders=r}get uri(){return this.privUri}get headers(){return this.privHeaders}};te.ConnectionStartEvent=yp;var Sp=class extends Rt{constructor(e){super("ConnectionEstablishedEvent",e)}};te.ConnectionEstablishedEvent=Sp;var Cp=class extends Rt{constructor(e,t,r){super("ConnectionClosedEvent",e,Nr.EventType.Debug),this.privReason=r,this.privStatusCode=t}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionClosedEvent=Cp;var Pp=class extends Rt{constructor(e,t,r){super("ConnectionErrorEvent",e,Nr.EventType.Debug),this.privMessage=t,this.privType=r}get message(){return this.privMessage}get type(){return this.privType}};te.ConnectionErrorEvent=Pp;var Rp=class extends Rt{constructor(e,t,r){super("ConnectionEstablishErrorEvent",e,Nr.EventType.Error),this.privStatusCode=t,this.privReason=r}get reason(){return this.privReason}get statusCode(){return this.privStatusCode}};te.ConnectionEstablishErrorEvent=Rp;var Ep=class extends Rt{constructor(e,t,r){super("ConnectionMessageReceivedEvent",e),this.privNetworkReceivedTime=t,this.privMessage=r}get networkReceivedTime(){return this.privNetworkReceivedTime}get message(){return this.privMessage}};te.ConnectionMessageReceivedEvent=Ep;var _p=class extends Rt{constructor(e,t,r){super("ConnectionMessageSentEvent",e),this.privNetworkSentTime=t,this.privMessage=r}get networkSentTime(){return this.privNetworkSentTime}get message(){return this.privMessage}};te.ConnectionMessageSentEvent=_p});var pt=p(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.ObjectDisposedError=ur.InvalidOperationError=ur.ArgumentNullError=void 0;var Ip=class extends Error{constructor(e){super(e),this.name="ArgumentNull",this.message=e}};ur.ArgumentNullError=Ip;var wp=class extends Error{constructor(e){super(e),this.name="InvalidOperation",this.message=e}};ur.InvalidOperationError=wp;var bp=class extends Error{constructor(e,t){super(t),this.name=e+"ObjectDisposed",this.message=t}};ur.ObjectDisposedError=bp});var Tp=p(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.ConnectionMessage=jr.MessageType=void 0;var Os=pt(),N_=ar(),qr;(function(i){i[i.Text=0]="Text",i[i.Binary=1]="Binary"})(qr=jr.MessageType||(jr.MessageType={}));var Ap=class{constructor(e,t,r,n){if(this.privBody=null,e===qr.Text&&t&&typeof t!="string")throw new Os.InvalidOperationError("Payload must be a string");if(e===qr.Binary&&t&&!(t instanceof ArrayBuffer))throw new Os.InvalidOperationError("Payload must be ArrayBuffer");switch(this.privMessageType=e,this.privBody=t,this.privHeaders=r||{},this.privId=n||N_.createNoDashGuid(),this.messageType){case qr.Binary:this.privSize=this.binaryBody!==null?this.binaryBody.byteLength:0;break;case qr.Text:this.privSize=this.textBody.length}}get messageType(){return this.privMessageType}get headers(){return this.privHeaders}get body(){return this.privBody}get textBody(){if(this.privMessageType===qr.Binary)throw new Os.InvalidOperationError("Not supported for binary message");return this.privBody}get binaryBody(){if(this.privMessageType===qr.Text)throw new Os.InvalidOperationError("Not supported for text message");return this.privBody}get id(){return this.privId}};jr.ConnectionMessage=Ap});var Jg=p(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.ConnectionOpenResponse=void 0;var Op=class{constructor(e,t){this.privStatusCode=e,this.privReason=t}get statusCode(){return this.privStatusCode}get reason(){return this.privReason}};ks.ConnectionOpenResponse=Op});var Gg=p(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.DeferralMap=void 0;var kp=class{constructor(){this.privMap={}}add(e,t){this.privMap[e]=t}getId(e){return this.privMap[e]}complete(e,t){try{this.privMap[e].resolve(t)}catch(r){this.privMap[e].reject(r)}finally{this.privMap[e]=void 0}}};Ms.DeferralMap=kp});var Dp=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.SendingAgentContextMessageEvent=Si.DialogEvent=void 0;var $g=yi(),Ds=class extends $g.PlatformEvent{constructor(e,t=$g.EventType.Info){super(e,t)}};Si.DialogEvent=Ds;var Mp=class extends Ds{constructor(e){super("SendingAgentContextMessageEvent"),this.privAgentConfig=e}get agentConfig(){return this.privAgentConfig}};Si.SendingAgentContextMessageEvent=Mp});var Np=p(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.EventSource=void 0;var q_=pt(),j_=ar(),xp=class{constructor(e){this.privEventListeners={},this.privIsDisposed=!1,this.privConsoleListener=void 0,this.privMetadata=e}onEvent(e){if(this.isDisposed())throw new q_.ObjectDisposedError("EventSource");if(this.metadata)for(let t in this.metadata)t&&e.metadata&&(e.metadata[t]||(e.metadata[t]=this.metadata[t]));for(let t in this.privEventListeners)t&&this.privEventListeners[t]&&this.privEventListeners[t](e)}attach(e){let t=j_.createNoDashGuid();return this.privEventListeners[t]=e,{detach:()=>(delete this.privEventListeners[t],Promise.resolve())}}attachListener(e){return this.attach(t=>e.onEvent(t))}attachConsoleListener(e){return this.privConsoleListener&&this.privConsoleListener.detach(),this.privConsoleListener=this.attach(t=>e.onEvent(t)),this.privConsoleListener}isDisposed(){return this.privIsDisposed}dispose(){this.privEventListeners=null,this.privIsDisposed=!0}get metadata(){return this.privMetadata}};xs.EventSource=xp});var Qg=p(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.Events=void 0;var z_=pt(),L_=Np(),Ns=class i{static setEventSource(e){if(!e)throw new z_.ArgumentNullError("eventSource");i.privInstance=e}static get instance(){return i.privInstance}};qs.Events=Ns;Ns.privInstance=new L_.EventSource});var Zg=p(Xg=>{"use strict";Object.defineProperty(Xg,"__esModule",{value:!0})});var Yg=p(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});gn.ConnectionState=void 0;var B_;(function(i){i[i.None=0]="None",i[i.Connected=1]="Connected",i[i.Connecting=2]="Connecting",i[i.Disconnected=3]="Disconnected"})(B_=gn.ConnectionState||(gn.ConnectionState={}))});var tm=p(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0})});var im=p(rm=>{"use strict";Object.defineProperty(rm,"__esModule",{value:!0})});var sm=p(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0})});var am=p(om=>{"use strict";Object.defineProperty(om,"__esModule",{value:!0})});var um=p(cm=>{"use strict";Object.defineProperty(cm,"__esModule",{value:!0})});var lm=p(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0})});var dm=p(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0})});var fm=p(vm=>{"use strict";Object.defineProperty(vm,"__esModule",{value:!0})});var jp=p(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.List=void 0;var F_=pt(),qp=class i{constructor(e){if(this.privSubscriptionIdCounter=0,this.privAddSubscriptions={},this.privRemoveSubscriptions={},this.privDisposedSubscriptions={},this.privDisposeReason=null,this.privList=[],e)for(let t of e)this.privList.push(t)}get(e){return this.throwIfDisposed(),this.privList[e]}first(){return this.get(0)}last(){return this.get(this.length()-1)}add(e){this.throwIfDisposed(),this.insertAt(this.privList.length,e)}insertAt(e,t){this.throwIfDisposed(),e===0?this.privList.unshift(t):e===this.privList.length?this.privList.push(t):this.privList.splice(e,0,t),this.triggerSubscriptions(this.privAddSubscriptions)}removeFirst(){return this.throwIfDisposed(),this.removeAt(0)}removeLast(){return this.throwIfDisposed(),this.removeAt(this.length()-1)}removeAt(e){return this.throwIfDisposed(),this.remove(e,1)[0]}remove(e,t){this.throwIfDisposed();let r=this.privList.splice(e,t);return this.triggerSubscriptions(this.privRemoveSubscriptions),r}clear(){this.throwIfDisposed(),this.remove(0,this.length())}length(){return this.throwIfDisposed(),this.privList.length}onAdded(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privAddSubscriptions[t]=e,{detach:()=>(delete this.privAddSubscriptions[t],Promise.resolve())}}onRemoved(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privRemoveSubscriptions[t]=e,{detach:()=>(delete this.privRemoveSubscriptions[t],Promise.resolve())}}onDisposed(e){this.throwIfDisposed();let t=this.privSubscriptionIdCounter++;return this.privDisposedSubscriptions[t]=e,{detach:()=>(delete this.privDisposedSubscriptions[t],Promise.resolve())}}join(e){return this.throwIfDisposed(),this.privList.join(e)}toArray(){let e=Array();return this.privList.forEach(t=>{e.push(t)}),e}any(e){return this.throwIfDisposed(),e?this.where(e).length()>0:this.length()>0}all(e){return this.throwIfDisposed(),this.where(e).length()===this.length()}forEach(e){this.throwIfDisposed();for(let t=0;t<this.length();t++)e(this.privList[t],t)}select(e){this.throwIfDisposed();let t=[];for(let r=0;r<this.privList.length;r++)t.push(e(this.privList[r],r));return new i(t)}where(e){this.throwIfDisposed();let t=new i;for(let r=0;r<this.privList.length;r++)e(this.privList[r],r)&&t.add(this.privList[r]);return t}orderBy(e){this.throwIfDisposed();let r=this.toArray().sort(e);return new i(r)}orderByDesc(e){return this.throwIfDisposed(),this.orderBy((t,r)=>e(r,t))}clone(){return this.throwIfDisposed(),new i(this.toArray())}concat(e){return this.throwIfDisposed(),new i(this.privList.concat(e.toArray()))}concatArray(e){return this.throwIfDisposed(),new i(this.privList.concat(e))}isDisposed(){return this.privList==null}dispose(e){this.isDisposed()||(this.privDisposeReason=e,this.privList=null,this.privAddSubscriptions=null,this.privRemoveSubscriptions=null,this.triggerSubscriptions(this.privDisposedSubscriptions))}throwIfDisposed(){if(this.isDisposed())throw new F_.ObjectDisposedError("List",this.privDisposeReason)}triggerSubscriptions(e){if(e)for(let t in e)t&&e[t]()}};js.List=qp});var Bp=p(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.marshalPromiseToCallbacks=Oe.Sink=Oe.Deferred=Oe.PromiseResultEventSource=Oe.PromiseResult=Oe.PromiseState=void 0;var Ut;(function(i){i[i.None=0]="None",i[i.Resolved=1]="Resolved",i[i.Rejected=2]="Rejected"})(Ut=Oe.PromiseState||(Oe.PromiseState={}));var zs=class{constructor(e){this.throwIfError=()=>{if(this.isError)throw this.error},e.on(t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!1,this.privResult=t)},t=>{this.privIsCompleted||(this.privIsCompleted=!0,this.privIsError=!0,this.privError=t)})}get isCompleted(){return this.privIsCompleted}get isError(){return this.privIsError}get error(){return this.privError}get result(){return this.privResult}};Oe.PromiseResult=zs;var Ls=class{constructor(){this.setResult=e=>{this.privOnSetResult(e)},this.setError=e=>{this.privOnSetError(e)},this.on=(e,t)=>{this.privOnSetResult=e,this.privOnSetError=t}}};Oe.PromiseResultEventSource=Ls;var zp=class{constructor(){this.resolve=e=>(this.privResolve(e),this),this.reject=e=>(this.privReject(e),this),this.privPromise=new Promise((e,t)=>{this.privResolve=e,this.privReject=t})}get promise(){return this.privPromise}};Oe.Deferred=zp;var Lp=class{constructor(){this.privState=Ut.None,this.privPromiseResult=null,this.privPromiseResultEvents=null,this.privSuccessHandlers=[],this.privErrorHandlers=[],this.privPromiseResultEvents=new Ls,this.privPromiseResult=new zs(this.privPromiseResultEvents)}get state(){return this.privState}get result(){return this.privPromiseResult}resolve(e){if(this.privState!==Ut.None)throw new Error("'Cannot resolve a completed promise'");this.privState=Ut.Resolved,this.privPromiseResultEvents.setResult(e);for(let t=0;t<this.privSuccessHandlers.length;t++)this.executeSuccessCallback(e,this.privSuccessHandlers[t],this.privErrorHandlers[t]);this.detachHandlers()}reject(e){if(this.privState!==Ut.None)throw new Error("'Cannot reject a completed promise'");this.privState=Ut.Rejected,this.privPromiseResultEvents.setError(e);for(let t of this.privErrorHandlers)this.executeErrorCallback(e,t);this.detachHandlers()}on(e,t){e==null&&(e=()=>{}),this.privState===Ut.None?(this.privSuccessHandlers.push(e),this.privErrorHandlers.push(t)):(this.privState===Ut.Resolved?this.executeSuccessCallback(this.privPromiseResult.result,e,t):this.privState===Ut.Rejected&&this.executeErrorCallback(this.privPromiseResult.error,t),this.detachHandlers())}executeSuccessCallback(e,t,r){try{t(e)}catch(n){this.executeErrorCallback(`'Unhandled callback error: ${n}'`,r)}}executeErrorCallback(e,t){if(t)try{t(e)}catch(r){throw new Error(`'Unhandled callback error: ${r}. InnerError: ${e}'`)}else throw new Error(`'Unhandled error: ${e}'`)}detachHandlers(){this.privErrorHandlers=[],this.privSuccessHandlers=[]}};Oe.Sink=Lp;function V_(i,e,t){i.then(r=>{try{e&&e(r)}catch(n){if(t)try{if(n instanceof Error){let s=n;t(s.name+": "+s.message)}else t(n)}catch{}}},r=>{if(t)try{if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r)}catch{}})}Oe.marshalPromiseToCallbacks=V_});var Wp=p(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.Queue=void 0;var Fp=pt(),Vp=jp(),gm=Bp(),mn;(function(i){i[i.Dequeue=0]="Dequeue",i[i.Peek=1]="Peek"})(mn||(mn={}));var Up=class{constructor(e){this.privPromiseStore=new Vp.List,this.privIsDrainInProgress=!1,this.privIsDisposing=!1,this.privDisposeReason=null,this.privList=e||new Vp.List,this.privDetachables=[],this.privSubscribers=new Vp.List,this.privDetachables.push(this.privList.onAdded(()=>this.drain()))}enqueue(e){this.throwIfDispose(),this.enqueueFromPromise(new Promise(t=>t(e)))}enqueueFromPromise(e){this.throwIfDispose(),e.then(t=>{this.privList.add(t)},()=>{})}dequeue(){this.throwIfDispose();let e=new gm.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:mn.Dequeue}),this.drain()),e.promise}peek(){this.throwIfDispose();let e=new gm.Deferred;return this.privSubscribers&&(this.privSubscribers.add({deferral:e,type:mn.Peek}),this.drain()),e.promise}length(){return this.throwIfDispose(),this.privList.length()}isDisposed(){return this.privSubscribers==null}async drainAndDispose(e,t){if(!this.isDisposed()&&!this.privIsDisposing){this.privDisposeReason=t,this.privIsDisposing=!0;let r=this.privSubscribers;if(r){for(;r.length()>0;)r.removeFirst().deferral.resolve(void 0);this.privSubscribers===r&&(this.privSubscribers=r)}for(let n of this.privDetachables)await n.detach();if(this.privPromiseStore.length()>0&&e){let n=[];return this.privPromiseStore.toArray().forEach(s=>{n.push(s)}),Promise.all(n).finally(()=>{this.privSubscribers=null,this.privList.forEach(s=>{e(s)}),this.privList=null}).then()}else this.privSubscribers=null,this.privList=null}}async dispose(e){await this.drainAndDispose(null,e)}drain(){if(!this.privIsDrainInProgress&&!this.privIsDisposing){this.privIsDrainInProgress=!0;let e=this.privSubscribers,t=this.privList;if(e&&t){for(;t.length()>0&&e.length()>0&&!this.privIsDisposing;){let r=e.removeFirst();if(r.type===mn.Peek)r.deferral.resolve(t.first());else{let n=t.removeFirst();r.deferral.resolve(n)}}this.privSubscribers===e&&(this.privSubscribers=e),this.privList===t&&(this.privList=t)}this.privIsDrainInProgress=!1}}throwIfDispose(){if(this.isDisposed())throw this.privDisposeReason?new Fp.InvalidOperationError(this.privDisposeReason):new Fp.ObjectDisposedError("Queue");if(this.privIsDisposing)throw new Fp.InvalidOperationError("Queue disposing")}};Bs.Queue=Up});var mm=p(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.RawWebsocketMessage=void 0;var Fs=Tp(),yn=pt(),U_=ar(),Hp=class{constructor(e,t,r){if(this.privPayload=null,!t)throw new yn.ArgumentNullError("payload");if(e===Fs.MessageType.Binary&&Object.getPrototypeOf(t).constructor.name!=="ArrayBuffer")throw new yn.InvalidOperationError("Payload must be ArrayBuffer");if(e===Fs.MessageType.Text&&typeof t!="string")throw new yn.InvalidOperationError("Payload must be a string");this.privMessageType=e,this.privPayload=t,this.privId=r||U_.createNoDashGuid()}get messageType(){return this.privMessageType}get payload(){return this.privPayload}get textContent(){if(this.privMessageType===Fs.MessageType.Binary)throw new yn.InvalidOperationError("Not supported for binary message");return this.privPayload}get binaryContent(){if(this.privMessageType===Fs.MessageType.Text)throw new yn.InvalidOperationError("Not supported for text message");return this.privPayload}get id(){return this.privId}};Vs.RawWebsocketMessage=Hp});var ym=p(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.RiffPcmEncoder=void 0;var Kp=class{constructor(e,t){this.privActualSampleRate=e,this.privDesiredSampleRate=t}encode(e){let t=this.downSampleAudioFrame(e,this.privActualSampleRate,this.privDesiredSampleRate);if(!t)return null;let r=t.length*2,n=new ArrayBuffer(r),s=new DataView(n);return this.floatTo16BitPCM(s,0,t),n}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}floatTo16BitPCM(e,t,r){for(let n=0;n<r.length;n++,t+=2){let s=Math.max(-1,Math.min(1,r[n]));e.setInt16(t,s<0?s*32768:s*32767,!0)}}downSampleAudioFrame(e,t,r){if(!e)return null;if(r===t||r>t)return e;let n=t/r,s=Math.round(e.length/n),o=new Float32Array(s),a=0,c=0;for(;c<s;){let u=Math.round((c+1)*n),l=0,h=0;for(;a<u&&a<e.length;)l+=e[a++],h++;o[c++]=l/h}return o}};Us.RiffPcmEncoder=Kp});var Pm=p(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.Stream=void 0;var Sm=pt(),W_=ar(),Cm=Wp(),Jp=class{constructor(e){this.privIsWriteEnded=!1,this.privIsReadEnded=!1,this.privId=e||W_.createNoDashGuid(),this.privReaderQueue=new Cm.Queue}get isClosed(){return this.privIsWriteEnded}get isReadEnded(){return this.privIsReadEnded}get id(){return this.privId}close(){this.privIsWriteEnded||(this.writeStreamChunk({buffer:null,isEnd:!0,timeReceived:Date.now()}),this.privIsWriteEnded=!0)}writeStreamChunk(e){if(this.throwIfClosed(),!this.privReaderQueue.isDisposed())try{this.privReaderQueue.enqueue(e)}catch{}}read(){if(this.privIsReadEnded)throw new Sm.InvalidOperationError("Stream read has already finished");return this.privReaderQueue.dequeue().then(async e=>((e===void 0||e.isEnd)&&await this.privReaderQueue.dispose("End of stream reached"),e))}readEnded(){this.privIsReadEnded||(this.privIsReadEnded=!0,this.privReaderQueue=new Cm.Queue)}throwIfClosed(){if(this.privIsWriteEnded)throw new Sm.InvalidOperationError("Stream closed")}};Ws.Stream=Jp});var Hs=p(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.TranslationStatus=void 0;var H_;(function(i){i[i.Success=0]="Success",i[i.Error=1]="Error"})(H_=Sn.TranslationStatus||(Sn.TranslationStatus={}))});var Rm=p(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.ChunkedArrayBufferStream=void 0;var K_=P(),Gp=class extends K_.Stream{constructor(e,t){super(t),this.privTargetChunkSize=e,this.privNextBufferReadyBytes=0}writeStreamChunk(e){if(e.isEnd||this.privNextBufferReadyBytes===0&&e.buffer.byteLength===this.privTargetChunkSize){super.writeStreamChunk(e);return}let t=0;for(;t<e.buffer.byteLength;){this.privNextBufferToWrite===void 0&&(this.privNextBufferToWrite=new ArrayBuffer(this.privTargetChunkSize),this.privNextBufferStartTime=e.timeReceived);let r=Math.min(e.buffer.byteLength-t,this.privTargetChunkSize-this.privNextBufferReadyBytes),n=new Uint8Array(this.privNextBufferToWrite),s=new Uint8Array(e.buffer.slice(t,r+t));n.set(s,this.privNextBufferReadyBytes),this.privNextBufferReadyBytes+=r,t+=r,this.privNextBufferReadyBytes===this.privTargetChunkSize&&(super.writeStreamChunk({buffer:this.privNextBufferToWrite,isEnd:!1,timeReceived:this.privNextBufferStartTime}),this.privNextBufferReadyBytes=0,this.privNextBufferToWrite=void 0)}}close(){this.privNextBufferReadyBytes!==0&&!this.isClosed&&super.writeStreamChunk({buffer:this.privNextBufferToWrite.slice(0,this.privNextBufferReadyBytes),isEnd:!1,timeReceived:this.privNextBufferStartTime}),super.close()}};Ks.ChunkedArrayBufferStream=Gp});var _m=p(Em=>{"use strict";Object.defineProperty(Em,"__esModule",{value:!0})});var Im=p(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.Timeout=void 0;var Et=class i{static load(){let e=new Map([[0,()=>{}]]),t=new Map,n="data:text/javascript;base64,"+btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`),s=new Worker(n);return s.addEventListener("message",({data:c})=>{if(i.isCallNotification(c)){let{params:{timerId:u}}=c,l=e.get(u);if(typeof l=="number"){let h=t.get(l);if(h===void 0||h!==u)throw new Error("The timer is in an undefined state.")}else if(typeof l<"u")l(),e.delete(u);else throw new Error("The timer is in an undefined state.")}else if(i.isClearResponse(c)){let{id:u}=c,l=t.get(u);if(l===void 0)throw new Error("The timer is in an undefined state.");t.delete(u),e.delete(l)}else{let{error:{message:u}}=c;throw new Error(u)}}),{clearTimeout:c=>{let u=Math.random();t.set(u,c),e.set(c,u),s.postMessage({id:u,method:"clear",params:{timerId:c}})},setTimeout:(c,u)=>{let l=Math.random();return e.set(l,c),s.postMessage({id:null,method:"set",params:{delay:u,now:performance.now(),timerId:l}}),l}}}static loadWorkerTimers(){return()=>(i.workerTimers!==null||(i.workerTimers=i.load()),i.workerTimers)}static isCallNotification(e){return e.method!==void 0&&e.method==="call"}static isClearResponse(e){return e.error===null&&typeof e.id=="number"}};Js.Timeout=Et;Et.workerTimers=null;Et.clearTimeout=i=>Et.timers().clearTimeout(i);Et.setTimeout=(i,e)=>Et.timers().setTimeout(i,e);Et.timers=Et.loadWorkerTimers()});var wm=p(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.OCSPCacheUpdateErrorEvent=O.OCSPResponseRetrievedEvent=O.OCSPCacheFetchErrorEvent=O.OCSPVerificationFailedEvent=O.OCSPCacheHitEvent=O.OCSPCacheEntryNeedsRefreshEvent=O.OCSPCacheEntryExpiredEvent=O.OCSPWSUpgradeStartedEvent=O.OCSPStapleReceivedEvent=O.OCSPCacheUpdateCompleteEvent=O.OCSPDiskCacheStoreEvent=O.OCSPMemoryCacheStoreEvent=O.OCSPCacheUpdateNeededEvent=O.OCSPDiskCacheHitEvent=O.OCSPCacheMissEvent=O.OCSPMemoryCacheHitEvent=O.OCSPEvent=void 0;var he=yi(),ae=class extends he.PlatformEvent{constructor(e,t,r){super(e,t),this.privSignature=r}};O.OCSPEvent=ae;var $p=class extends ae{constructor(e){super("OCSPMemoryCacheHitEvent",he.EventType.Debug,e)}};O.OCSPMemoryCacheHitEvent=$p;var Qp=class extends ae{constructor(e){super("OCSPCacheMissEvent",he.EventType.Debug,e)}};O.OCSPCacheMissEvent=Qp;var Xp=class extends ae{constructor(e){super("OCSPDiskCacheHitEvent",he.EventType.Debug,e)}};O.OCSPDiskCacheHitEvent=Xp;var Zp=class extends ae{constructor(e){super("OCSPCacheUpdateNeededEvent",he.EventType.Debug,e)}};O.OCSPCacheUpdateNeededEvent=Zp;var Yp=class extends ae{constructor(e){super("OCSPMemoryCacheStoreEvent",he.EventType.Debug,e)}};O.OCSPMemoryCacheStoreEvent=Yp;var el=class extends ae{constructor(e){super("OCSPDiskCacheStoreEvent",he.EventType.Debug,e)}};O.OCSPDiskCacheStoreEvent=el;var tl=class extends ae{constructor(e){super("OCSPCacheUpdateCompleteEvent",he.EventType.Debug,e)}};O.OCSPCacheUpdateCompleteEvent=tl;var rl=class extends ae{constructor(){super("OCSPStapleReceivedEvent",he.EventType.Debug,"")}};O.OCSPStapleReceivedEvent=rl;var il=class extends ae{constructor(e){super("OCSPWSUpgradeStartedEvent",he.EventType.Debug,e)}};O.OCSPWSUpgradeStartedEvent=il;var nl=class extends ae{constructor(e,t){super("OCSPCacheEntryExpiredEvent",he.EventType.Debug,e),this.privExpireTime=t}};O.OCSPCacheEntryExpiredEvent=nl;var sl=class extends ae{constructor(e,t,r){super("OCSPCacheEntryNeedsRefreshEvent",he.EventType.Debug,e),this.privExpireTime=r,this.privStartTime=t}};O.OCSPCacheEntryNeedsRefreshEvent=sl;var ol=class extends ae{constructor(e,t,r){super("OCSPCacheHitEvent",he.EventType.Debug,e),this.privExpireTime=r,this.privExpireTimeString=new Date(r).toLocaleDateString(),this.privStartTime=t,this.privStartTimeString=new Date(t).toLocaleTimeString()}};O.OCSPCacheHitEvent=ol;var al=class extends ae{constructor(e,t){super("OCSPVerificationFailedEvent",he.EventType.Debug,e),this.privError=t}};O.OCSPVerificationFailedEvent=al;var cl=class extends ae{constructor(e,t){super("OCSPCacheFetchErrorEvent",he.EventType.Debug,e),this.privError=t}};O.OCSPCacheFetchErrorEvent=cl;var ul=class extends ae{constructor(e){super("OCSPResponseRetrievedEvent",he.EventType.Debug,e)}};O.OCSPResponseRetrievedEvent=ul;var pl=class extends ae{constructor(e,t){super("OCSPCacheUpdateErrorEvent",he.EventType.Debug,e),this.privError=t}};O.OCSPCacheUpdateErrorEvent=pl});var Am=p(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.BackgroundEvent=void 0;var bm=P(),ll=class extends bm.PlatformEvent{constructor(e){super("BackgroundEvent",bm.EventType.Error),this.privError=e}get error(){return this.privError}};Gs.BackgroundEvent=ll});var P=p(A=>{"use strict";var J_=A&&A.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),x=A&&A.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&J_(e,i,t)};Object.defineProperty(A,"__esModule",{value:!0});x(gp(),A);x(Kg(),A);x(Tp(),A);x(Jg(),A);x(Gg(),A);x(Dp(),A);x(pt(),A);x(Qg(),A);x(Np(),A);x(ar(),A);x(Zg(),A);x(Yg(),A);x(tm(),A);x(im(),A);x(sm(),A);x(am(),A);x(um(),A);x(lm(),A);x(dm(),A);x(fm(),A);x(jp(),A);x(yi(),A);x(Bp(),A);x(Wp(),A);x(mm(),A);x(ym(),A);x(Pm(),A);var G_=Hs();Object.defineProperty(A,"TranslationStatus",{enumerable:!0,get:function(){return G_.TranslationStatus}});x(Rm(),A);x(_m(),A);x(Im(),A);x(wm(),A);x(Am(),A)});var Ie=p($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.HeaderNames=void 0;var Ve=class{};$s.HeaderNames=Ve;Ve.AuthKey="Ocp-Apim-Subscription-Key";Ve.Authorization="Authorization";Ve.SpIDAuthKey="Apim-Subscription-Id";Ve.ConnectionId="X-ConnectionId";Ve.ContentType="Content-Type";Ve.CustomCommandsAppId="X-CommandsAppId";Ve.Path="Path";Ve.RequestId="X-RequestId";Ve.RequestStreamId="X-StreamId";Ve.RequestTimestamp="X-Timestamp"});var Xs=p(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.AuthInfo=void 0;var hl=class{constructor(e,t){this.privHeaderName=e,this.privToken=t}get headerName(){return this.privHeaderName}get token(){return this.privToken}};Qs.AuthInfo=hl});var Tm=p(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.CognitiveSubscriptionKeyAuthentication=void 0;var $_=P(),Q_=Ie(),X_=Xs(),dl=class{constructor(e){if(!e)throw new $_.ArgumentNullError("subscriptionKey");this.privAuthInfo=new X_.AuthInfo(Q_.HeaderNames.AuthKey,e)}fetch(e){return Promise.resolve(this.privAuthInfo)}fetchOnExpiry(e){return Promise.resolve(this.privAuthInfo)}};Zs.CognitiveSubscriptionKeyAuthentication=dl});var Dm=p(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.CognitiveTokenAuthentication=void 0;var Om=P(),km=Xs(),Mm=Ie(),Ys=class i{constructor(e,t){if(!e)throw new Om.ArgumentNullError("fetchCallback");if(!t)throw new Om.ArgumentNullError("fetchOnExpiryCallback");this.privFetchCallback=e,this.privFetchOnExpiryCallback=t}fetch(e){return this.privFetchCallback(e).then(t=>new km.AuthInfo(Mm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}fetchOnExpiry(e){return this.privFetchOnExpiryCallback(e).then(t=>new km.AuthInfo(Mm.HeaderNames.Authorization,t===void 0?void 0:i.privTokenPrefix+t))}};eo.CognitiveTokenAuthentication=Ys;Ys.privTokenPrefix="Bearer "});var Nm=p(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0})});var jm=p(qm=>{"use strict";Object.defineProperty(qm,"__esModule",{value:!0})});var vl=p(()=>{});var fl=p(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.LogLevel=void 0;var Z_=P();Object.defineProperty(to,"LogLevel",{enumerable:!0,get:function(){return Z_.EventType}})});var _=p(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.Contracts=void 0;var gl=class i{static throwIfNullOrUndefined(e,t){if(e==null)throw new Error("throwIfNullOrUndefined:"+t)}static throwIfNull(e,t){if(e===null)throw new Error("throwIfNull:"+t)}static throwIfNullOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),(""+e).trim().length<1)throw new Error("throwIfNullOrWhitespace:"+t)}static throwIfNullOrTooLong(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length>r)throw new Error("throwIfNullOrTooLong:"+t+" (more than "+r.toString()+" characters)")}static throwIfNullOrTooShort(e,t,r){if(i.throwIfNullOrUndefined(e,t),(""+e).length<r)throw new Error("throwIfNullOrTooShort:"+t+" (less than "+r.toString()+" characters)")}static throwIfDisposed(e){if(e)throw new Error("the object is already disposed")}static throwIfArrayEmptyOrWhitespace(e,t){if(i.throwIfNullOrUndefined(e,t),e.length===0)throw new Error("throwIfArrayEmptyOrWhitespace:"+t);for(let r of e)i.throwIfNullOrWhitespace(r,t)}static throwIfFileDoesNotExist(e,t){i.throwIfNullOrWhitespace(e,t)}static throwIfNotUndefined(e,t){if(e!==void 0)throw new Error("throwIfNotUndefined:"+t)}};ro.Contracts=gl});var Lm=p(_t=>{"use strict";var Y_=_t&&_t.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),eI=_t&&_t.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),tI=_t&&_t.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&Y_(e,i,t);return eI(e,i),e};Object.defineProperty(_t,"__esModule",{value:!0});_t.ConsoleLoggingListener=void 0;var zm=tI(vl()),Cn=fl(),rI=_(),ml=class{constructor(e=Cn.LogLevel.None){this.privLogPath=void 0,this.privEnableConsoleOutput=!0,this.privLogLevelFilter=e}set logPath(e){rI.Contracts.throwIfNullOrUndefined(zm.openSync,`
|
|
2
|
+
File System access not available`),this.privLogPath=e}set enableConsoleOutput(e){this.privEnableConsoleOutput=e}onEvent(e){if(e.eventType>=this.privLogLevelFilter){let t=this.toString(e);if(this.logCallback&&this.logCallback(t),this.privLogPath&&zm.writeFileSync(this.privLogPath,t+`
|
|
3
|
+
`,{flag:"a+"}),this.privEnableConsoleOutput)switch(e.eventType){case Cn.LogLevel.Debug:console.debug(t);break;case Cn.LogLevel.Info:console.info(t);break;case Cn.LogLevel.Warning:console.warn(t);break;case Cn.LogLevel.Error:console.error(t);break;default:console.log(t);break}}}toString(e){let t=[`${e.eventTime}`,`${e.name}`],r=e;for(let n in r)if(n&&e.hasOwnProperty(n)&&n!=="eventTime"&&n!=="eventType"&&n!=="eventId"&&n!=="name"&&n!=="constructor"){let s=r[n],o="<NULL>";s!=null&&(typeof s=="number"||typeof s=="string"?o=s.toString():o=JSON.stringify(s)),t.push(`${n}: ${o}`)}return t.join(" | ")}};_t.ConsoleLoggingListener=ml});var Fm=p(Bm=>{"use strict";Object.defineProperty(Bm,"__esModule",{value:!0})});var pr=p(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.AudioStreamFormatImpl=Wt.AudioStreamFormat=Wt.AudioFormatTag=void 0;var Pn;(function(i){i[i.PCM=1]="PCM",i[i.MuLaw=2]="MuLaw",i[i.Siren=3]="Siren",i[i.MP3=4]="MP3",i[i.SILKSkype=5]="SILKSkype",i[i.OGG_OPUS=6]="OGG_OPUS",i[i.WEBM_OPUS=7]="WEBM_OPUS",i[i.ALaw=8]="ALaw",i[i.FLAC=9]="FLAC",i[i.OPUS=10]="OPUS"})(Pn=Wt.AudioFormatTag||(Wt.AudioFormatTag={}));var io=class{static getDefaultInputFormat(){return Ci.getDefaultInputFormat()}static getWaveFormat(e,t,r,n){return new Ci(e,t,r,n)}static getWaveFormatPCM(e,t,r){return new Ci(e,t,r)}};Wt.AudioStreamFormat=io;var Ci=class i extends io{constructor(e=16e3,t=16,r=1,n=Pn.PCM){super();let s=!0;switch(n){case Pn.PCM:this.formatTag=1;break;case Pn.ALaw:this.formatTag=6;break;case Pn.MuLaw:this.formatTag=7;break;default:s=!1}if(this.bitsPerSample=t,this.samplesPerSec=e,this.channels=r,this.avgBytesPerSec=this.samplesPerSec*this.channels*(this.bitsPerSample/8),this.blockAlign=this.channels*Math.max(this.bitsPerSample,8),s){this.privHeader=new ArrayBuffer(44);let o=new DataView(this.privHeader);this.setString(o,0,"RIFF"),o.setUint32(4,0,!0),this.setString(o,8,"WAVEfmt "),o.setUint32(16,16,!0),o.setUint16(20,this.formatTag,!0),o.setUint16(22,this.channels,!0),o.setUint32(24,this.samplesPerSec,!0),o.setUint32(28,this.avgBytesPerSec,!0),o.setUint16(32,this.channels*(this.bitsPerSample/8),!0),o.setUint16(34,this.bitsPerSample,!0),this.setString(o,36,"data"),o.setUint32(40,0,!0)}}static getDefaultInputFormat(){return new i}static getAudioContext(e){let t=window.AudioContext||window.webkitAudioContext||!1;if(t)return e!==void 0&&navigator.mediaDevices.getSupportedConstraints().sampleRate?new t({sampleRate:e}):new t;throw new Error("Browser does not support Web Audio API (AudioContext is not available).")}close(){}get header(){return this.privHeader}setString(e,t,r){for(let n=0;n<r.length;n++)e.setUint8(t+n,r.charCodeAt(n))}};Wt.AudioStreamFormatImpl=Ci});var Wm=p(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.MicAudioSource=zr.AudioWorkletSourceURLPropertyName=void 0;var Vm=C(),de=P(),Um=pr();zr.AudioWorkletSourceURLPropertyName="MICROPHONE-WorkletSourceUrl";var no=class i{constructor(e,t,r,n){this.privRecorder=e,this.deviceId=t,this.privStreams={},this.privOutputChunkSize=i.AUDIOFORMAT.avgBytesPerSec/10,this.privId=r||de.createNoDashGuid(),this.privEvents=new de.EventSource,this.privMediaStream=n||null,this.privIsClosing=!1}get format(){return Promise.resolve(i.AUDIOFORMAT)}turnOn(){if(this.privInitializeDeferral)return this.privInitializeDeferral.promise;this.privInitializeDeferral=new de.Deferred;try{this.createAudioContext()}catch(r){if(r instanceof Error){let n=r;this.privInitializeDeferral.reject(n.name+": "+n.message)}else this.privInitializeDeferral.reject(r);return this.privInitializeDeferral.promise}let e=window.navigator,t=e.getUserMedia||e.webkitGetUserMedia||e.mozGetUserMedia||e.msGetUserMedia;if(e.mediaDevices&&(t=(r,n,s)=>{e.mediaDevices.getUserMedia(r).then(n).catch(s)}),t){let r=()=>{this.onEvent(new de.AudioSourceInitializingEvent(this.privId)),this.privMediaStream&&this.privMediaStream.active?(this.onEvent(new de.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()):t({audio:this.deviceId?{deviceId:this.deviceId}:!0,video:!1},n=>{this.privMediaStream=n,this.onEvent(new de.AudioSourceReadyEvent(this.privId)),this.privInitializeDeferral.resolve()},n=>{let s=`Error occurred during microphone initialization: ${n}`;this.privInitializeDeferral.reject(s),this.onEvent(new de.AudioSourceErrorEvent(this.privId,s))})};this.privContext.state==="suspended"?this.privContext.resume().then(r).catch(n=>{this.privInitializeDeferral.reject(`Failed to initialize audio context: ${n}`)}):r()}else{let r="Browser does not support getUserMedia.";this.privInitializeDeferral.reject(r),this.onEvent(new de.AudioSourceErrorEvent(r,""))}return this.privInitializeDeferral.promise}id(){return this.privId}attach(e){return this.onEvent(new de.AudioStreamNodeAttachingEvent(this.privId,e)),this.listen(e).then(t=>(this.onEvent(new de.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(t.readEnded(),delete this.privStreams[e],this.onEvent(new de.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}))}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new de.AudioStreamNodeDetachedEvent(this.privId,e)))}async turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&t.close()}this.onEvent(new de.AudioSourceOffEvent(this.privId)),this.privInitializeDeferral&&(await this.privInitializeDeferral,this.privInitializeDeferral=null),await this.destroyAudioContext()}get events(){return this.privEvents}get deviceInfo(){return this.getMicrophoneLabel().then(e=>({bitspersample:i.AUDIOFORMAT.bitsPerSample,channelcount:i.AUDIOFORMAT.channels,connectivity:Vm.connectivity.Unknown,manufacturer:"Speech SDK",model:e,samplerate:i.AUDIOFORMAT.samplesPerSec,type:Vm.type.Microphones}))}setProperty(e,t){if(e===zr.AudioWorkletSourceURLPropertyName)this.privRecorder.setWorkletUrl(t);else throw new Error("Property '"+e+"' is not supported on Microphone.")}getMicrophoneLabel(){let e="microphone";if(this.privMicrophoneLabel!==void 0)return Promise.resolve(this.privMicrophoneLabel);if(this.privMediaStream===void 0||!this.privMediaStream.active)return Promise.resolve(e);this.privMicrophoneLabel=e;let t=this.privMediaStream.getTracks()[0].getSettings().deviceId;if(t===void 0)return Promise.resolve(this.privMicrophoneLabel);let r=new de.Deferred;return navigator.mediaDevices.enumerateDevices().then(n=>{for(let s of n)if(s.deviceId===t){this.privMicrophoneLabel=s.label;break}r.resolve(this.privMicrophoneLabel)},()=>r.resolve(this.privMicrophoneLabel)),r.promise}async listen(e){await this.turnOn();let t=new de.ChunkedArrayBufferStream(this.privOutputChunkSize,e);this.privStreams[e]=t;try{this.privRecorder.record(this.privContext,this.privMediaStream,t)}catch(n){throw this.onEvent(new de.AudioStreamNodeErrorEvent(this.privId,e,n)),n}return t}onEvent(e){this.privEvents.onEvent(e),de.Events.instance.onEvent(e)}createAudioContext(){this.privContext||(this.privContext=Um.AudioStreamFormatImpl.getAudioContext(i.AUDIOFORMAT.samplesPerSec))}async destroyAudioContext(){if(!this.privContext)return;this.privRecorder.releaseMediaResources(this.privContext);let e=!1;"close"in this.privContext&&(e=!0),e?this.privIsClosing||(this.privIsClosing=!0,await this.privContext.close(),this.privContext=null,this.privIsClosing=!1):this.privContext!==null&&this.privContext.state==="running"&&await this.privContext.suspend()}};zr.MicAudioSource=no;no.AUDIOFORMAT=Um.AudioStreamFormat.getDefaultInputFormat()});var Km=p(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.FileAudioSource=void 0;var Hm=C(),xe=P(),iI=pr(),yl=class{constructor(e,t,r){this.privStreams={},this.privHeaderEnd=44,this.privId=r||xe.createNoDashGuid(),this.privEvents=new xe.EventSource,this.privSource=e,typeof window<"u"&&typeof Blob<"u"&&this.privSource instanceof Blob?this.privFilename=e.name:this.privFilename=t||"unknown.wav",this.privAudioFormatPromise=this.readHeader()}get format(){return this.privAudioFormatPromise}turnOn(){if(this.privFilename.lastIndexOf(".wav")!==this.privFilename.length-4){let e=this.privFilename+" is not supported. Only WAVE files are allowed at the moment.";return this.onEvent(new xe.AudioSourceErrorEvent(e,"")),Promise.reject(e)}this.onEvent(new xe.AudioSourceInitializingEvent(this.privId)),this.onEvent(new xe.AudioSourceReadyEvent(this.privId))}id(){return this.privId}async attach(e){this.onEvent(new xe.AudioStreamNodeAttachingEvent(this.privId,e));let t=await this.upload(e);return this.onEvent(new xe.AudioStreamNodeAttachedEvent(this.privId,e)),Promise.resolve({detach:async()=>{t.readEnded(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)),await this.turnOff()},id:()=>e,read:()=>t.read()})}detach(e){e&&this.privStreams[e]&&(this.privStreams[e].close(),delete this.privStreams[e],this.onEvent(new xe.AudioStreamNodeDetachedEvent(this.privId,e)))}turnOff(){for(let e in this.privStreams)if(e){let t=this.privStreams[e];t&&!t.isClosed&&t.close()}return this.onEvent(new xe.AudioSourceOffEvent(this.privId)),Promise.resolve()}get events(){return this.privEvents}get deviceInfo(){return this.privAudioFormatPromise.then(e=>Promise.resolve({bitspersample:e.bitsPerSample,channelcount:e.channels,connectivity:Hm.connectivity.Unknown,manufacturer:"Speech SDK",model:"File",samplerate:e.samplesPerSec,type:Hm.type.File}))}readHeader(){let t=this.privSource.slice(0,4296),r=new xe.Deferred,n=s=>{let o=new DataView(s),a=g=>String.fromCharCode(o.getUint8(g),o.getUint8(g+1),o.getUint8(g+2),o.getUint8(g+3));if(a(0)!=="RIFF"){r.reject("Invalid WAV header in file, RIFF was not found");return}if(a(8)!=="WAVE"||a(12)!=="fmt "){r.reject("Invalid WAV header in file, WAVEfmt was not found");return}let c=o.getInt32(16,!0),u=o.getUint16(22,!0),l=o.getUint32(24,!0),h=o.getUint16(34,!0),d=36+Math.max(c-16,0);for(;a(d)!=="data";d+=2)if(d>4288){r.reject("Invalid WAV header in file, data block was not found");return}this.privHeaderEnd=d+8,r.resolve(iI.AudioStreamFormat.getWaveFormatPCM(l,h,u))};if(typeof window<"u"&&typeof Blob<"u"&&t instanceof Blob){let s=new FileReader;s.onload=o=>{let a=o.target.result;n(a)},s.readAsArrayBuffer(t)}else{let s=t;n(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength))}return r.promise}async upload(e){let t=r=>{let n=`Error occurred while processing '${this.privFilename}'. ${r}`;throw this.onEvent(new xe.AudioStreamNodeErrorEvent(this.privId,e,n)),new Error(n)};try{await this.turnOn();let r=await this.privAudioFormatPromise,n=new xe.ChunkedArrayBufferStream(r.avgBytesPerSec/10,e);this.privStreams[e]=n;let s=this.privSource.slice(this.privHeaderEnd),o=a=>{n.isClosed||(n.writeStreamChunk({buffer:a,isEnd:!1,timeReceived:Date.now()}),n.close())};if(typeof window<"u"&&typeof Blob<"u"&&s instanceof Blob){let a=new FileReader;a.onerror=c=>t(c.toString()),a.onload=c=>{let u=c.target.result;o(u)},a.readAsArrayBuffer(s)}else{let a=s;o(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength))}return n}catch(r){t(r)}}onEvent(e){this.privEvents.onEvent(e),xe.Events.instance.onEvent(e)}};so.FileAudioSource=yl});var Jm=p(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.PcmRecorder=void 0;var nI=P(),Sl=class{constructor(e){this.privStopInputOnRelease=e}record(e,t,r){let s=new nI.RiffPcmEncoder(e.sampleRate,16e3),o=e.createMediaStreamSource(t),a=()=>{let u=(()=>{let l=0;try{return e.createScriptProcessor(l,1,1)}catch{l=2048;let d=e.sampleRate;for(;l<16384&&d>=32e3;)l<<=1,d>>=1;return e.createScriptProcessor(l,1,1)}})();u.onaudioprocess=l=>{let h=l.inputBuffer.getChannelData(0);if(r&&!r.isClosed){let d=s.encode(h);d&&r.writeStreamChunk({buffer:d,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}},c=!!this.privSpeechProcessorScript&&this.privSpeechProcessorScript.toLowerCase()==="ignore";if(e.audioWorklet&&!c){if(!this.privSpeechProcessorScript){let u=`class SP extends AudioWorkletProcessor {
|
|
4
4
|
constructor(options) {
|
|
5
5
|
super(options);
|
|
6
6
|
}
|
|
@@ -14,18 +14,18 @@ File System access not available`),this.privLogPath=e}set enableConsoleOutput(e)
|
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
registerProcessor('speech-processor', SP);`,d=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(d)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=d=>{let h=d.data;if(r&&!r.isClosed){let l=s.encode(h);l&&r.writeStreamChunk({buffer:l,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}}).catch(()=>{a()})}else try{a()}catch(u){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${u}`)}}releaseMediaResources(e){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(e.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach(t=>t.stop()),this.privMediaResources.source=null))}setWorkletUrl(e){this.privSpeechProcessorScript=e}};Ys.PcmRecorder=ad});var wm=p(()=>{});var Im=p(()=>{});var Tm=p(()=>{});var _m=p(()=>{});var Am=p(()=>{});var pd=p(Ke=>{"use strict";var bw=Ke&&Ke.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),Ow=Ke&&Ke.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),bm=Ke&&Ke.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&bw(e,i,t);return Ow(e,i),e},cd=Ke&&Ke.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ke,"__esModule",{value:!0});Ke.WebsocketMessageAdapter=void 0;var Mw=bm(wm()),Dw=bm(Im()),kw=cd(Tm()),Nw=cd(_m()),xw=cd(Am()),qw=we(),T=P(),Xs=class i{constructor(e,t,r,n,s,o){if(!e)throw new T.ArgumentNullError("uri");if(!r)throw new T.ArgumentNullError("messageFormatter");this.proxyInfo=n,this.privConnectionEvents=new T.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=T.ConnectionState.None,this.privUri=e,this.privHeaders=s,this.privEnableCompression=o,this.privHeaders[qw.HeaderNames.ConnectionId]=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===T.ConnectionState.Disconnected)return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`);if(this.privConnectionEstablishDeferral)return this.privConnectionEstablishDeferral.promise;this.privConnectionEstablishDeferral=new T.Deferred,this.privCertificateValidatedDeferral=new T.Deferred,this.privConnectionState=T.ConnectionState.Connecting;try{if(typeof WebSocket<"u"&&!i.forceNpmWebSocket)this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);else{let e={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression};this.privCertificateValidatedDeferral.resolve(),e.agent=this.getAgent();let r=new URL(this.privUri).protocol;r?.toLocaleLowerCase()==="wss:"?r="https:":r?.toLocaleLowerCase()==="ws:"&&(r="http:"),e.agent.protocol=r,this.privWebsocketClient=new xw.default(this.privUri,e)}this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new T.Queue,this.privDisconnectDeferral=new T.Deferred,this.privSendMessageQueue=new T.Queue,this.processSendQueue().catch(e=>{T.Events.instance.onEvent(new T.BackgroundEvent(e))})}catch(e){return this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(500,e)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new T.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then(()=>{this.privConnectionState=T.ConnectionState.Connected,this.onEvent(new T.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(200,""))},e=>{this.privConnectionEstablishDeferral.reject(e)})},this.privWebsocketClient.onerror=e=>{this.onEvent(new T.ConnectionErrorEvent(this.privConnectionId,e.message,e.type)),this.privLastErrorReceived=e.message},this.privWebsocketClient.onclose=e=>{this.privConnectionState===T.ConnectionState.Connecting?(this.privConnectionState=T.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new T.ConnectionOpenResponse(e.code,e.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=T.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new T.ConnectionClosedEvent(this.privConnectionId,e.code,e.reason))),this.onClose(e.code,e.reason).catch(t=>{T.Events.instance.onEvent(new T.BackgroundEvent(t))})},this.privWebsocketClient.onmessage=e=>{let t=new Date().toISOString();if(this.privConnectionState===T.ConnectionState.Connected){let r=new T.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(r.promise),e.data instanceof ArrayBuffer){let n=new T.RawWebsocketMessage(T.MessageType.Binary,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid binary message format. Error: ${s}`)})}else{let n=new T.RawWebsocketMessage(T.MessageType.Text,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new T.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid text message format. Error: ${s}`)})}}},this.privConnectionEstablishDeferral.promise}send(e){if(this.privConnectionState!==T.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${T.ConnectionState[this.privConnectionState]} state`);let t=new T.Deferred,r=new T.Deferred;return this.privSendMessageQueue.enqueueFromPromise(r.promise),this.privMessageFormatter.fromConnectionMessage(e).then(n=>{r.resolve({Message:e,RawWebsocketMessage:n,sendStatusDeferral:t})},n=>{r.reject(`Error formatting the message. ${n}`)}),t.promise}read(){return this.privConnectionState!==T.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(e){if(this.privWebsocketClient)this.privConnectionState!==T.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,e||"Normal closure by client");else return Promise.resolve();return this.privDisconnectDeferral.promise}get events(){return this.privConnectionEvents}sendRawMessage(e){try{if(!e)return Promise.resolve();if(this.onEvent(new T.ConnectionMessageSentEvent(this.privConnectionId,new Date().toISOString(),e.Message)),this.isWebsocketOpen)this.privWebsocketClient.send(e.RawWebsocketMessage.payload);else return Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+e.Message.id+" "+new Error().stack);return Promise.resolve()}catch(t){return Promise.reject(`websocket send error: ${t}`)}}async onClose(e,t){let r=`Connection closed. ${e}: ${t}`;this.privConnectionState=T.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose(()=>{},r),await this.privSendMessageQueue.drainAndDispose(n=>{n.sendStatusDeferral.reject(r)},r)}async processSendQueue(){for(;;){let t=await this.privSendMessageQueue.dequeue();if(!t)return;try{await this.sendRawMessage(t),t.sendStatusDeferral.resolve()}catch(r){t.sendStatusDeferral.reject(r)}}}onEvent(e){this.privConnectionEvents.onEvent(e),T.Events.instance.onEvent(e)}getAgent(){let e=new kw.default.Agent(this.createConnection);return this.proxyInfo!==void 0&&this.proxyInfo.HostName!==void 0&&this.proxyInfo.Port>0&&(e.proxyInfo=this.proxyInfo),e}static GetProxyAgent(e){let t={host:e.HostName,port:e.Port};return e.UserName?t.headers={"Proxy-Authentication":"Basic "+new Buffer(`${e.UserName}:${e.Password===void 0?"":e.Password}`).toString("base64")}:t.headers={},t.headers.requestOCSP="true",new Nw.default(t)}createConnection(e,t){let r;if(t={...t,requestOCSP:!0,servername:t.host},this.proxyInfo){let s=i.GetProxyAgent(this.proxyInfo);r=new Promise((o,a)=>{s.callback(e,t,(c,u)=>{c?a(c):o(u)})})}else t.secureEndpoint?r=Promise.resolve(Dw.connect(t)):r=Promise.resolve(Mw.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};Ke.WebsocketMessageAdapter=Xs;Xs.forceNpmWebSocket=!1});var Om=p(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.WebsocketConnection=void 0;var ud=P(),zw=pd(),dd=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new ud.ArgumentNullError("uri");if(!n)throw new ud.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let d in t)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(d);c+=h;let l=t[d];l&&(l=encodeURIComponent(l),c+=`=${l}`),u++}}if(r){for(let d in r)if(d){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(r[d]);c+=`${d}=${h}`,u++}}this.privUri=e+c,this.privId=a||ud.createNoDashGuid(),this.privConnectionMessageAdapter=new zw.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,r,o)}async dispose(){this.privIsDisposed=!0,this.privConnectionMessageAdapter&&await this.privConnectionMessageAdapter.close()}isDisposed(){return this.privIsDisposed}get id(){return this.privId}get uri(){return this.privUri}state(){return this.privConnectionMessageAdapter.state}open(){return this.privConnectionMessageAdapter.open()}send(e){return this.privConnectionMessageAdapter.send(e)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}};Zs.WebsocketConnection=dd});var Mm=p(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.ReplayableAudioNode=void 0;var hd=class{constructor(e,t){this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.privAudioNode=e,this.privBytesPerSecond=t}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&this.privBuffers.length!==0){let e=this.privReplayOffset-this.privBufferStartOffset,t=Math.round(e*this.privBytesPerSecond*1e-7);t%2!==0&&t++;let r=0;for(;r<this.privBuffers.length&&t>=this.privBuffers[r].chunk.buffer.byteLength;)t-=this.privBuffers[r++].chunk.buffer.byteLength;if(r<this.privBuffers.length){let n=this.privBuffers[r].chunk.buffer.slice(t);return this.privReplayOffset+=n.byteLength/this.privBytesPerSecond*1e7,r===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:n,isEnd:!1,timeReceived:this.privBuffers[r].chunk.timeReceived})}}return this.privAudioNode.read().then(e=>(e&&e.buffer&&(this.privBuffers.push(new ld(e,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=e.buffer.byteLength),e))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&this.privBuffers.length!==0&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(e){if(this.privBuffers===void 0||this.privBuffers.length===0)return;this.privLastShrinkOffset=e;let t=e-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7),n=0;for(;n<this.privBuffers.length&&r>=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)}findTimeAtOffset(e){if(e<this.privBufferStartOffset||this.privBuffers===void 0)return 0;for(let t of this.privBuffers){let r=t.byteOffset/this.privBytesPerSecond*1e7,n=r+t.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(e>=r&&e<=n)return t.chunk.timeReceived}return 0}};eo.ReplayableAudioNode=hd;var ld=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var gd=p(Ct=>{"use strict";var jw=Ct&&Ct.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),Lw=Ct&&Ct.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Bw=Ct&&Ct.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&jw(e,i,t);return Lw(e,i),e};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.AudioFileWriter=void 0;var vn=Bw(rd()),vd=w(),fd=class{constructor(e){vd.Contracts.throwIfNullOrUndefined(vn.openSync,`
|
|
18
|
-
File System access not available, please use Push or PullAudioOutputStream`),this.privFd=vn.openSync(e,"w")}set format(e){vd.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let t=0;this.privAudioFormat.hasHeader&&(t=this.privAudioFormat.header.byteLength),this.privFd!==void 0&&(this.privWriteStream=vn.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){vd.Contracts.throwIfNullOrUndefined(this.privAudioFormat,"must set format before writing."),this.privWriteStream!==void 0&&this.privWriteStream.write(new Uint8Array(e.slice(0)))}close(){this.privFd!==void 0&&(this.privWriteStream.on("finish",()=>{this.privAudioFormat.hasHeader&&(this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten),vn.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),vn.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};Ct.AudioFileWriter=fd});var md=p(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.PullAudioInputStreamImpl=Je.PullAudioInputStream=Je.PushAudioInputStreamImpl=Je.PushAudioInputStream=Je.AudioInputStream=void 0;var to=C(),le=P(),Dm=rr(),Fw=f(),Vw=sr(),fn=class{constructor(){}static createPushStream(e){return gn.create(e)}static createPullStream(e,t){return mn.create(e,t)}};Je.AudioInputStream=fn;var gn=class extends fn{static create(e){return new ro(e)}};Je.PushAudioInputStream=gn;var ro=class extends gn{constructor(e){super(),e===void 0?this.privFormat=Vw.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new le.EventSource,this.privId=Dm.createNoDashGuid(),this.privStream=new le.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(e){this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:to.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:to.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.Events.instance.onEvent(e)}toBuffer(e){let t=Buffer.alloc(e.byteLength),r=new Uint8Array(e);for(let n=0;n<t.length;++n)t[n]=r[n];return t}};Je.PushAudioInputStreamImpl=ro;var mn=class extends fn{constructor(){super()}static create(e,t){return new io(e,t)}};Je.PullAudioInputStream=mn;var io=class extends mn{constructor(e,t){super(),t===void 0?this.privFormat=Fw.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new le.EventSource,this.privId=Dm.createNoDashGuid(),this.privCallback=e,this.privIsClosed=!1,this.privBufferSize=this.privFormat.avgBytesPerSec/10}get format(){return Promise.resolve(this.privFormat)}close(){this.privIsClosed=!0,this.privCallback.close()}id(){return this.privId}turnOn(){this.onEvent(new le.AudioSourceInitializingEvent(this.privId)),this.onEvent(new le.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new le.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new le.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>{let t=0,r;for(;t<this.privBufferSize;){let n=new ArrayBuffer(this.privBufferSize-t),s=this.privCallback.read(n);if(r===void 0?r=n:new Int8Array(r).set(new Int8Array(n),t),s===0)break;t+=s}return Promise.resolve({buffer:r.slice(0,t),isEnd:this.privIsClosed||t===0,timeReceived:Date.now()})}}}detach(e){this.onEvent(new le.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:to.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:to.type.Stream})}onEvent(e){this.privEvents.onEvent(e),le.Events.instance.onEvent(e)}};Je.PullAudioInputStreamImpl=io});var Sd=p(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.SpeechSynthesisOutputFormat=void 0;var Uw;(function(i){i[i.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",i[i.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",i[i.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",i[i.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",i[i.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",i[i.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",i[i.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",i[i.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",i[i.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",i[i.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",i[i.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",i[i.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",i[i.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",i[i.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",i[i.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",i[i.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",i[i.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",i[i.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",i[i.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",i[i.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",i[i.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",i[i.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",i[i.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",i[i.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",i[i.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",i[i.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",i[i.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",i[i.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",i[i.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",i[i.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",i[i.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",i[i.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",i[i.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",i[i.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",i[i.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",i[i.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",i[i.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm"})(Uw=Sn.SpeechSynthesisOutputFormat||(Sn.SpeechSynthesisOutputFormat={}))});var li=p(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.AudioOutputFormatImpl=void 0;var O=Sd(),A=sr(),no=class i extends A.AudioStreamFormatImpl{constructor(e,t,r,n,s,o,a,c,u){super(r,o,t,e),this.formatTag=e,this.avgBytesPerSec=n,this.blockAlign=s,this.priAudioFormatString=a,this.priRequestAudioFormatString=c,this.priHasHeader=u}static fromSpeechSynthesisOutputFormat(e){return e===void 0?i.getDefaultOutputFormat():i.fromSpeechSynthesisOutputFormatString(i.SpeechSynthesisOutputFormatToString[e])}static fromSpeechSynthesisOutputFormatString(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new i(A.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,24e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,e,e,!1);case"riff-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new i(A.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,e,e,!1);case"ogg-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,e,e,!1);case"raw-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,12288,2,16,e,e,!1);case"audio-48khz-192kbitrate-mono-mp3":return new i(A.AudioFormatTag.MP3,1,48e3,24576,2,16,e,e,!1);case"ogg-48khz-16bit-mono-opus":return new i(A.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,e,e,!1);case"webm-16khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,e,e,!1);case"webm-24khz-16bit-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,e,e,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,16e3,4e3,2,16,e,e,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,6e3,2,16,e,e,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new i(A.AudioFormatTag.OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-24khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,24e3,24e3,2,16,e,e,!1);case"audio-48khz-16bit-mono-flac":return new i(A.AudioFormatTag.FLAC,1,48e3,3e4,2,16,e,e,!1);case"raw-24khz-16bit-mono-truesilk":return new i(A.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,e,e,!1);case"raw-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,e,!1);case"riff-8khz-8bit-mono-alaw":return new i(A.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,e,!1);case"riff-22050hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,22050,44100,2,16,e,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,e,!1);case"riff-44100hz-16bit-mono-pcm":return new i(A.AudioFormatTag.PCM,1,44100,88200,2,16,e,"raw-44100hz-16bit-mono-pcm",!0);case"riff-16khz-16bit-mono-pcm":default:return new i(A.AudioFormatTag.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}}static getDefaultOutputFormat(){return i.fromSpeechSynthesisOutputFormatString(typeof window<"u"?"audio-24khz-48kbitrate-mono-mp3":"riff-16khz-16bit-mono-pcm")}get hasHeader(){return this.priHasHeader}get header(){if(this.hasHeader)return this.privHeader}updateHeader(e){if(this.priHasHeader){let t=new DataView(this.privHeader);t.setUint32(4,e+this.privHeader.byteLength-8,!0),t.setUint32(40,e,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(e){if(!this.hasHeader)return e;this.updateHeader(e.byteLength);let t=new Uint8Array(e.byteLength+this.header.byteLength);return t.set(new Uint8Array(this.header),0),t.set(new Uint8Array(e),this.header.byteLength),t.buffer}};so.AudioOutputFormatImpl=no;no.SpeechSynthesisOutputFormatToString={[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[O.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[O.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[O.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[O.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[O.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[O.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[O.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[O.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm"}});var Dr=p(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.PushAudioOutputStreamImpl=Ge.PushAudioOutputStream=Ge.PullAudioOutputStreamImpl=Ge.PullAudioOutputStream=Ge.AudioOutputStream=void 0;var yd=P(),Ww=w(),Hw=li(),yn=class{constructor(){}static createPullStream(){return Cn.create()}};Ge.AudioOutputStream=yn;var Cn=class extends yn{static create(){return new oo}};Ge.PullAudioOutputStream=Cn;var oo=class extends Cn{constructor(){super(),this.privId=yd.createNoDashGuid(),this.privStream=new yd.Stream}set format(e){e==null&&(this.privFormat=Hw.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=e}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(e){let t=new Int8Array(e),r=0;if(this.privLastChunkView!==void 0){if(this.privLastChunkView.length>e.byteLength)return t.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),Promise.resolve(e.byteLength);t.set(this.privLastChunkView),r=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;r<e.byteLength&&!this.privStream.isReadEnded;){let n=await this.privStream.read();if(n!==void 0&&!n.isEnd){let s;n.buffer.byteLength>e.byteLength-r?(s=n.buffer.slice(0,e.byteLength-r),this.privLastChunkView=new Int8Array(n.buffer.slice(e.byteLength-r))):s=n.buffer,t.set(new Int8Array(s),r),r+=s.byteLength}else this.privStream.readEnded()}return r}write(e){Ww.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Ge.PullAudioOutputStreamImpl=oo;var ao=class extends yn{constructor(){super()}static create(e){return new co(e)}};Ge.PushAudioOutputStream=ao;var co=class extends ao{constructor(e){super(),this.privId=yd.createNoDashGuid(),this.privCallback=e}set format(e){}write(e){this.privCallback.write&&this.privCallback.write(e)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}};Ge.PushAudioOutputStreamImpl=co});var Cd=p(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.AudioOutputConfigImpl=or.AudioConfigImpl=or.AudioConfig=void 0;var kr=ae(),Kw=w(),Nr=f(),Jw=gd(),Gw=md(),$w=Dr(),Pn=class i{static fromDefaultMicrophoneInput(){let e=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new kr.PcmRecorder(!0);return new Bt(new kr.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Bt(new kr.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Nr.PullAudioInputStreamCallback)return new Bt(new Gw.PullAudioInputStreamImpl(e));if(e instanceof Nr.AudioInputStream)return new Bt(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new kr.PcmRecorder(!1);return new Bt(new kr.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Ft(new Nr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Nr.SpeakerAudioDestination)return new Ft(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Ft(new Jw.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Nr.PushAudioOutputStreamCallback)return new Ft(new $w.PushAudioOutputStreamImpl(e));if(e instanceof Nr.PushAudioOutputStream)return new Ft(e);if(e instanceof Nr.PullAudioOutputStream)return new Ft(e);throw new Error("Not Supported Type")}};or.AudioConfig=Pn;var Bt=class extends Pn{constructor(e){super(),this.privSource=e}get format(){return this.privSource.format}close(e,t){this.privSource.turnOff().then(()=>{e&&e()},r=>{t&&t(r)})}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(e){return this.privSource.attach(e)}detach(e){return this.privSource.detach(e)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(e,t){if(Kw.Contracts.throwIfNull(t,"value"),this.privSource.setProperty!==void 0)this.privSource.setProperty(e,t);else throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(e,t){if(this.privSource.getProperty!==void 0)return this.privSource.getProperty(e,t);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}};or.AudioConfigImpl=Bt;var Ft=class extends Pn{constructor(e){super(),this.privDestination=e}set format(e){this.privDestination.format=e}write(e){this.privDestination.write(e)}close(){this.privDestination.close()}id(){return this.privDestination.id()}setProperty(){throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(){throw new Error("This AudioConfig instance does not support getting properties.")}};or.AudioOutputConfigImpl=Ft});var km=p(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.CancellationReason=void 0;var Qw;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(Qw=Rn.CancellationReason||(Rn.CancellationReason={}))});var Nm=p(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.PullAudioInputStreamCallback=void 0;var Pd=class{};po.PullAudioInputStreamCallback=Pd});var xm=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.PushAudioOutputStreamCallback=void 0;var Rd=class{};uo.PushAudioOutputStreamCallback=Rd});var zm=p(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.KeywordRecognitionModel=void 0;var qm=w(),Ed=class{constructor(){this.privDisposed=!1}static fromFile(e){throw qm.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw qm.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};ho.KeywordRecognitionModel=Ed});var jm=p(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.SessionEventArgs=void 0;var wd=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};lo.SessionEventArgs=wd});var Lm=p(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.RecognitionEventArgs=void 0;var Yw=f(),Id=class extends Yw.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};vo.RecognitionEventArgs=Id});var Bm=p(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.OutputFormat=void 0;var Xw;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(Xw=En.OutputFormat||(En.OutputFormat={}))});var Fm=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.IntentRecognitionEventArgs=void 0;var Zw=f(),Td=class extends Zw.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};fo.IntentRecognitionEventArgs=Td});var Vm=p(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.RecognitionResult=void 0;var _d=class{constructor(e,t,r,n,s,o,a,c,u,d){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=s,this.privLanguage=o,this.privLanguageDetectionConfidence=a,this.privErrorDetails=c,this.privJson=u,this.privProperties=d}get resultId(){return this.privResultId}get reason(){return this.privReason}get text(){return this.privText}get duration(){return this.privDuration}get offset(){return this.privOffset}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}get errorDetails(){return this.privErrorDetails}get json(){return this.privJson}get properties(){return this.privProperties}};go.RecognitionResult=_d});var Um=p(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.SpeechRecognitionResult=void 0;var eI=f(),Ad=class extends eI.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};mo.SpeechRecognitionResult=Ad});var Wm=p(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.IntentRecognitionResult=void 0;var tI=f(),bd=class extends tI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),this.privIntentId=e}get intentId(){return this.privIntentId}};So.IntentRecognitionResult=bd});var Hm=p(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.LanguageUnderstandingModelImpl=gi.LanguageUnderstandingModel=void 0;var vi=w(),yo=class{constructor(){}static fromEndpoint(e){vi.Contracts.throwIfNull(e,"uri"),vi.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new fi,r=e.host.indexOf(".");if(r===-1)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);let n=e.pathname.lastIndexOf("/")+1;if(n===-1)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),t.subscriptionKey===void 0)throw new Error("Could not determine subscription key from endpoint");return t}static fromAppId(e){vi.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new fi;return t.appId=e,t}static fromSubscription(e,t,r){vi.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),vi.Contracts.throwIfNullOrWhitespace(t,"appId"),vi.Contracts.throwIfNullOrWhitespace(r,"region");let n=new fi;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};gi.LanguageUnderstandingModel=yo;var fi=class extends yo{};gi.LanguageUnderstandingModelImpl=fi});var Jm=p(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.MeetingTranscriptionEventArgs=ar.ConversationTranscriptionEventArgs=ar.SpeechRecognitionEventArgs=void 0;var Km=f(),Co=class extends Km.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ar.SpeechRecognitionEventArgs=Co;var Od=class extends Km.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ar.ConversationTranscriptionEventArgs=Od;var Md=class extends Co{};ar.MeetingTranscriptionEventArgs=Md});var mi=p(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.CancellationEventArgsBase=void 0;var rI=f(),Dd=class extends rI.RecognitionEventArgs{constructor(e,t,r,n,s){super(n,s),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Po.CancellationEventArgsBase=Dd});var Gm=p(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.SpeechRecognitionCanceledEventArgs=void 0;var iI=mi(),kd=class extends iI.CancellationEventArgsBase{};Ro.SpeechRecognitionCanceledEventArgs=kd});var $m=p(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.TranslationRecognitionEventArgs=void 0;var nI=f(),Nd=class extends nI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Eo.TranslationRecognitionEventArgs=Nd});var Qm=p(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.TranslationSynthesisEventArgs=void 0;var sI=f(),xd=class extends sI.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};wo.TranslationSynthesisEventArgs=xd});var zd=p(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.TranslationRecognitionResult=void 0;var oI=f(),qd=class i extends oI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,r,n,s,o,a,c,void 0,u,d,h),this.privTranslations=e}static fromSpeechRecognitionResult(e){return new i(void 0,e.resultId,e.reason,e.text,e.duration,e.offset,e.language,e.languageDetectionConfidence,e.errorDetails,e.json,e.properties)}get translations(){return this.privTranslations}};Io.TranslationRecognitionResult=qd});var Ym=p(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.TranslationSynthesisResult=void 0;var jd=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};To.TranslationSynthesisResult=jd});var Xm=p(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.ResultReason=void 0;var aI;(function(i){i[i.NoMatch=0]="NoMatch",i[i.Canceled=1]="Canceled",i[i.RecognizingSpeech=2]="RecognizingSpeech",i[i.RecognizedSpeech=3]="RecognizedSpeech",i[i.RecognizedKeyword=4]="RecognizedKeyword",i[i.RecognizingIntent=5]="RecognizingIntent",i[i.RecognizedIntent=6]="RecognizedIntent",i[i.TranslatingSpeech=7]="TranslatingSpeech",i[i.TranslatedSpeech=8]="TranslatedSpeech",i[i.SynthesizingAudio=9]="SynthesizingAudio",i[i.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",i[i.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",i[i.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",i[i.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",i[i.RecognizedSpeakers=14]="RecognizedSpeakers",i[i.RecognizedSpeaker=15]="RecognizedSpeaker",i[i.ResetVoiceProfile=16]="ResetVoiceProfile",i[i.DeletedVoiceProfile=17]="DeletedVoiceProfile",i[i.VoicesListRetrieved=18]="VoicesListRetrieved",i[i.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",i[i.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",i[i.TranslatedInstantMessage=21]="TranslatedInstantMessage",i[i.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"})(aI=wn.ResultReason||(wn.ResultReason={}))});var Zm=p(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.SpeechConfigImpl=Si.SpeechConfig=void 0;var In=C(),xr=w(),I=f(),_o=class{constructor(){}static fromSubscription(e,t){xr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(I.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){xr.Contracts.throwIfNull(e,"endpoint");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){xr.Contracts.throwIfNull(e,"hostName");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){xr.Contracts.throwIfNull(e,"authorizationToken"),xr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new qr;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};Si.SpeechConfig=_o;var qr=class i extends _o{constructor(){super(),this.privProperties=new I.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=I.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return I.OutputFormat[this.privProperties.getProperty(In.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(In.OutputFormatPropertyName,I.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){xr.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)}getProperty(e,t){return this.privProperties.getProperty(e,t)}setProxy(e,t,r,n){this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(In.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(In.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_ProfanityOption,I.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(In.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return I.SpeechSynthesisOutputFormat[this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,I.SpeechSynthesisOutputFormat[e])}};Si.SpeechConfigImpl=qr});var eS=p(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.SpeechTranslationConfigImpl=yi.SpeechTranslationConfig=void 0;var Tn=C(),at=w(),E=f(),Ao=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){at.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){at.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),at.Contracts.throwIfNullOrWhitespace(t,"region");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){at.Contracts.throwIfNull(e,"hostName");let r=new zr;return r.setProperty(E.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}static fromEndpoint(e,t){at.Contracts.throwIfNull(e,"endpoint"),at.Contracts.throwIfNull(t,"subscriptionKey");let r=new zr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};yi.SpeechTranslationConfig=Ao;var zr=class extends Ao{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){at.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){at.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return E.OutputFormat[this.privSpeechProperties.getProperty(Tn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(Tn.OutputFormatPropertyName,E.OutputFormat[e])}get endpointId(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EndpointId,e)}addTargetLanguage(e){at.Contracts.throwIfNullOrWhitespace(e,"value");let t=this.targetLanguages;t.includes(e)||(t.push(e),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))}get targetLanguages(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(e){at.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationVoice,e)}get region(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_Region)}setProxy(e,t,r,n){this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPassword],n)}getProperty(e,t){return this.privSpeechProperties.getProperty(e,t)}setProperty(e,t){this.privSpeechProperties.setProperty(e,t)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(e,t){let r=JSON.parse(this.privSpeechProperties.getProperty(Tn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(Tn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_ProfanityOption,E.ProfanityOption[e])}enableAudioLogging(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(Tn.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return E.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,E.SpeechSynthesisOutputFormat[e])}};yi.SpeechTranslationConfigImpl=zr});var Bd=p(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.PropertyCollection=void 0;var tS=f(),Ld=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=tS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return this.privValues[n];if(t!==void 0)return String(t)}setProperty(e,t){let r;typeof e=="string"?r=e:r=tS.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r){this.privValues[n]=t;return}this.privKeys.push(r),this.privValues.push(t)}clone(){let e=new i;for(let t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e}mergeTo(e){this.privKeys.forEach(t=>{if(e.getProperty(t,void 0)===void 0){let r=this.getProperty(t);e.setProperty(t,r)}})}get keys(){return this.privKeys}};bo.PropertyCollection=Ld});var Oo=p(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.PropertyId=void 0;var cI;(function(i){i[i.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",i[i.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",i[i.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",i[i.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",i[i.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",i[i.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",i[i.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",i[i.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",i[i.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",i[i.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",i[i.SpeechServiceConnection_ProxyHostName=10]="SpeechServiceConnection_ProxyHostName",i[i.SpeechServiceConnection_ProxyPort=11]="SpeechServiceConnection_ProxyPort",i[i.SpeechServiceConnection_ProxyUserName=12]="SpeechServiceConnection_ProxyUserName",i[i.SpeechServiceConnection_ProxyPassword=13]="SpeechServiceConnection_ProxyPassword",i[i.SpeechServiceConnection_RecoMode=14]="SpeechServiceConnection_RecoMode",i[i.SpeechServiceConnection_RecoLanguage=15]="SpeechServiceConnection_RecoLanguage",i[i.Speech_SessionId=16]="Speech_SessionId",i[i.SpeechServiceConnection_SynthLanguage=17]="SpeechServiceConnection_SynthLanguage",i[i.SpeechServiceConnection_SynthVoice=18]="SpeechServiceConnection_SynthVoice",i[i.SpeechServiceConnection_SynthOutputFormat=19]="SpeechServiceConnection_SynthOutputFormat",i[i.SpeechServiceConnection_AutoDetectSourceLanguages=20]="SpeechServiceConnection_AutoDetectSourceLanguages",i[i.SpeechServiceResponse_RequestDetailedResultTrueFalse=21]="SpeechServiceResponse_RequestDetailedResultTrueFalse",i[i.SpeechServiceResponse_RequestProfanityFilterTrueFalse=22]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",i[i.SpeechServiceResponse_JsonResult=23]="SpeechServiceResponse_JsonResult",i[i.SpeechServiceResponse_JsonErrorDetails=24]="SpeechServiceResponse_JsonErrorDetails",i[i.CancellationDetails_Reason=25]="CancellationDetails_Reason",i[i.CancellationDetails_ReasonText=26]="CancellationDetails_ReasonText",i[i.CancellationDetails_ReasonDetailedText=27]="CancellationDetails_ReasonDetailedText",i[i.LanguageUnderstandingServiceResponse_JsonResult=28]="LanguageUnderstandingServiceResponse_JsonResult",i[i.SpeechServiceConnection_Url=29]="SpeechServiceConnection_Url",i[i.SpeechServiceConnection_InitialSilenceTimeoutMs=30]="SpeechServiceConnection_InitialSilenceTimeoutMs",i[i.SpeechServiceConnection_EndSilenceTimeoutMs=31]="SpeechServiceConnection_EndSilenceTimeoutMs",i[i.Speech_SegmentationSilenceTimeoutMs=32]="Speech_SegmentationSilenceTimeoutMs",i[i.SpeechServiceConnection_EnableAudioLogging=33]="SpeechServiceConnection_EnableAudioLogging",i[i.SpeechServiceConnection_LanguageIdMode=34]="SpeechServiceConnection_LanguageIdMode",i[i.SpeechServiceConnection_RecognitionEndpointVersion=35]="SpeechServiceConnection_RecognitionEndpointVersion",i[i.SpeechServiceConnection_SpeakerIdMode=36]="SpeechServiceConnection_SpeakerIdMode",i[i.SpeechServiceResponse_ProfanityOption=37]="SpeechServiceResponse_ProfanityOption",i[i.SpeechServiceResponse_PostProcessingOption=38]="SpeechServiceResponse_PostProcessingOption",i[i.SpeechServiceResponse_RequestWordLevelTimestamps=39]="SpeechServiceResponse_RequestWordLevelTimestamps",i[i.SpeechServiceResponse_StablePartialResultThreshold=40]="SpeechServiceResponse_StablePartialResultThreshold",i[i.SpeechServiceResponse_OutputFormatOption=41]="SpeechServiceResponse_OutputFormatOption",i[i.SpeechServiceResponse_TranslationRequestStablePartialResult=42]="SpeechServiceResponse_TranslationRequestStablePartialResult",i[i.SpeechServiceResponse_RequestWordBoundary=43]="SpeechServiceResponse_RequestWordBoundary",i[i.SpeechServiceResponse_RequestPunctuationBoundary=44]="SpeechServiceResponse_RequestPunctuationBoundary",i[i.SpeechServiceResponse_RequestSentenceBoundary=45]="SpeechServiceResponse_RequestSentenceBoundary",i[i.Conversation_ApplicationId=46]="Conversation_ApplicationId",i[i.Conversation_DialogType=47]="Conversation_DialogType",i[i.Conversation_Initial_Silence_Timeout=48]="Conversation_Initial_Silence_Timeout",i[i.Conversation_From_Id=49]="Conversation_From_Id",i[i.Conversation_Conversation_Id=50]="Conversation_Conversation_Id",i[i.Conversation_Custom_Voice_Deployment_Ids=51]="Conversation_Custom_Voice_Deployment_Ids",i[i.Conversation_Speech_Activity_Template=52]="Conversation_Speech_Activity_Template",i[i.Conversation_Request_Bot_Status_Messages=53]="Conversation_Request_Bot_Status_Messages",i[i.Conversation_Agent_Connection_Id=54]="Conversation_Agent_Connection_Id",i[i.SpeechServiceConnection_Host=55]="SpeechServiceConnection_Host",i[i.ConversationTranslator_Host=56]="ConversationTranslator_Host",i[i.ConversationTranslator_Name=57]="ConversationTranslator_Name",i[i.ConversationTranslator_CorrelationId=58]="ConversationTranslator_CorrelationId",i[i.ConversationTranslator_Token=59]="ConversationTranslator_Token",i[i.PronunciationAssessment_ReferenceText=60]="PronunciationAssessment_ReferenceText",i[i.PronunciationAssessment_GradingSystem=61]="PronunciationAssessment_GradingSystem",i[i.PronunciationAssessment_Granularity=62]="PronunciationAssessment_Granularity",i[i.PronunciationAssessment_EnableMiscue=63]="PronunciationAssessment_EnableMiscue",i[i.PronunciationAssessment_Json=64]="PronunciationAssessment_Json",i[i.PronunciationAssessment_Params=65]="PronunciationAssessment_Params",i[i.SpeakerRecognition_Api_Version=66]="SpeakerRecognition_Api_Version",i[i.WebWorkerLoadType=67]="WebWorkerLoadType",i[i.TalkingAvatarService_WebRTC_SDP=68]="TalkingAvatarService_WebRTC_SDP"})(cI=_n.PropertyId||(_n.PropertyId={}))});var iS=p(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.Recognizer=void 0;var jr=C(),rS=P(),Mo=w(),Do=f(),Fd=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:Do.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){Mo.Contracts.throwIfDisposed(this.privDisposed),rS.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privReco}async dispose(e){this.privDisposed||(this.privDisposed=!0,e&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return jr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){jr.ServiceRecognizerBase.telemetryDataEnabled=e}implCommonRecognizerSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createRecognizerConfig(new jr.SpeechServiceConfig(new jr.Context(new jr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){Mo.Contracts.throwIfDisposed(this.privDisposed);let t=new rS.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(e,t.resolve,t.reject);let r=await t.promise;return await this.implRecognizerStop(),r}async startContinuousRecognitionAsyncImpl(e){Mo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){Mo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(Do.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new jr.CognitiveSubscriptionKeyAuthentication(t):new jr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(Do.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(Do.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};ko.Recognizer=Fd});var nS=p(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.SpeechRecognizer=void 0;var Ci=C(),No=P(),cr=w(),Ne=f(),Vd=class i extends Ne.Recognizer{constructor(e,t){let r=e;cr.Contracts.throwIfNull(r,"speechConfig"),cr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage),Ne.PropertyId[Ne.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Ci.SpeechConnectionFactory),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Ne.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){cr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Ne.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ci.OutputFormatPropertyName,Ne.OutputFormat[Ne.OutputFormat.Simple])===Ne.OutputFormat[Ne.OutputFormat.Simple]?Ne.OutputFormat.Simple:Ne.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){No.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Ci.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){No.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Ci.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){No.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){cr.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){cr.Contracts.throwIfDisposed(this.privDisposedRecognizer),No.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Ci.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ci.SpeechServiceRecognizer(e,t,s,n,this)}};xo.SpeechRecognizer=Vd});var sS=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.IntentRecognizer=void 0;var Lr=C(),qo=P(),Ie=w(),Vt=f(),Ud=class extends Vt.Recognizer{constructor(e,t){Ie.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ie.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Lr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,Ie.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage),Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Vt.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Vt.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Vt.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}qo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Lr.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){if(Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}qo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Lr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){qo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){Ie.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(t,"intentId"),Ie.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ie.Contracts.throwIfNullOrWhitespace(e,"intentId"),Ie.Contracts.throwIfNull(t,"model");let n=t;Ie.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new Lr.AddedLmIntent(n,r)}addAllIntents(e,t){Ie.Contracts.throwIfNull(e,"model");let r=e;Ie.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new Lr.AddedLmIntent(r,t)}close(e,t){Ie.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),qo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new Lr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Lr.IntentServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,await super.dispose(e))}buildSpeechContext(){let e,t,r,n=[];this.privUmbrellaIntent!==void 0&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(let s of Object.keys(this.privAddedLmIntents)){let o=this.privAddedLmIntents[s];if(e===void 0)e=o.modelImpl.appId;else if(e!==o.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(t===void 0)t=o.modelImpl.region;else if(t!==o.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(r===void 0)r=o.modelImpl.subscriptionKey;else if(r!==o.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");let a="luis/"+e+"-PRODUCTION#"+s;n.push(a)}return{Intent:{id:e,key:r===void 0?this.privProperties.getProperty(Vt.PropertyId[Vt.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};zo.IntentRecognizer=Ud});var oS=p(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});An.VoiceProfileType=void 0;var pI;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(pI=An.VoiceProfileType||(An.VoiceProfileType={}))});var Kd=p(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.ConnectionMessageImpl=Pi.ConnectionMessage=void 0;var aS=we(),cS=P(),uI=Bd(),dI=Oo(),Wd=class{};Pi.ConnectionMessage=Wd;var Hd=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new uI.PropertyCollection,this.privConnectionMessage.headers[aS.HeaderNames.ConnectionId]&&this.privProperties.setProperty(dI.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[aS.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach(t=>{this.privProperties.setProperty(t,this.privConnectionMessage.headers[t])})}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(e=>e.toLowerCase()==="path".toLowerCase())]}get isTextMessage(){return this.privConnectionMessage.messageType===cS.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===cS.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Pi.ConnectionMessageImpl=Hd});var Qd=p(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.Connection=void 0;var Jd=C(),Gd=P(),pS=Kd(),hI=w(),bn=f(),$d=class i{static fromRecognizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}static fromSynthesizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}openConnection(e,t){Gd.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof Jd.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");Gd.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(hI.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof Jd.ServiceRecognizerBase){if(e.toLowerCase()!=="speech.context")throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.setSection(t,r)}else if(this.privInternalData instanceof Jd.SynthesisAdapterBase){if(e.toLowerCase()!=="synthesis.context")throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(t,r)}}sendMessageAsync(e,t,r,n){Gd.marshalPromiseToCallbacks(this.privInternalData.sendNetworkMessage(e,t),r,n)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach(e=>{e.name==="ConnectionEstablishedEvent"?this.connected&&this.connected(new bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new bn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new bn.ConnectionMessageEventArgs(new pS.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new bn.ConnectionMessageEventArgs(new pS.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new bn.ServiceEventArgs(e.jsonString,e.name))})}};jo.Connection=$d});var uS=p(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.TranslationRecognizer=void 0;var On=C(),Lo=P(),lI=Qd(),ct=w(),$=f(),Yd=class i extends $.Recognizer{constructor(e,t,r){let n=e;ct.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new On.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationVoice]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages),$.PropertyId[$.PropertyId.SpeechServiceConnection_TranslationToLanguages]),ct.Contracts.throwIfNullOrWhitespace(this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage),$.PropertyId[$.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty($.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty($.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Lo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(On.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Lo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(On.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Lo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(ct.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){ct.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty($.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){ct.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Lo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new On.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new On.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=lI.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};Bo.TranslationRecognizer=Yd});var dS=p(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.Translations=void 0;var vI=f(),Xd=class{constructor(){this.privMap=new vI.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};Fo.Translations=Xd});var hS=p(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.NoMatchReason=void 0;var fI;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(fI=Mn.NoMatchReason||(Mn.NoMatchReason={}))});var lS=p(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.NoMatchDetails=void 0;var Zd=C(),Vo=f(),eh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=Zd.SimpleSpeechPhrase.fromJSON(e.json),r=Vo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case Zd.RecognitionStatus.BabbleTimeout:r=Vo.NoMatchReason.InitialBabbleTimeout;break;case Zd.RecognitionStatus.InitialSilenceTimeout:r=Vo.NoMatchReason.InitialSilenceTimeout;break;default:r=Vo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};Uo.NoMatchDetails=eh});var vS=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.TranslationRecognitionCanceledEventArgs=void 0;var th=class{constructor(e,t,r,n,s){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=s,this.privSessionId=e,this.privErrorCode=n}get result(){return this.privResult}get sessionId(){return this.privSessionId}get reason(){return this.privCancelReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Wo.TranslationRecognitionCanceledEventArgs=th});var fS=p(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.IntentRecognitionCanceledEventArgs=void 0;var gI=f(),rh=class extends gI.IntentRecognitionEventArgs{constructor(e,t,r,n,s,o){super(n,s,o),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Ho.IntentRecognitionCanceledEventArgs=rh});var nh=p(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.CancellationDetailsBase=void 0;var ih=class{constructor(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}};Ko.CancellationDetailsBase=ih});var gS=p(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.CancellationDetails=void 0;var Jo=C(),mI=nh(),Ri=f(),sh=class i extends mI.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Ri.CancellationReason.Error,r=Ri.CancellationErrorCode.NoError;if(e instanceof Ri.RecognitionResult&&e.json){let n=Jo.SimpleSpeechPhrase.fromJSON(e.json);t=Jo.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=Ri.CancellationErrorCode[e.properties.getProperty(Jo.CancellationErrorCodePropertyName,Ri.CancellationErrorCode[Ri.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||Jo.EnumTranslation.implTranslateErrorDetails(r),r)}};Go.CancellationDetails=sh});var mS=p(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.CancellationErrorCode=void 0;var SI;(function(i){i[i.NoError=0]="NoError",i[i.AuthenticationFailure=1]="AuthenticationFailure",i[i.BadRequestParameters=2]="BadRequestParameters",i[i.TooManyRequests=3]="TooManyRequests",i[i.ConnectionFailure=4]="ConnectionFailure",i[i.ServiceTimeout=5]="ServiceTimeout",i[i.ServiceError=6]="ServiceError",i[i.RuntimeError=7]="RuntimeError",i[i.Forbidden=8]="Forbidden"})(SI=Dn.CancellationErrorCode||(Dn.CancellationErrorCode={}))});var SS=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.ConnectionEventArgs=void 0;var yI=f(),oh=class extends yI.SessionEventArgs{};$o.ConnectionEventArgs=oh});var yS=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.ServiceEventArgs=void 0;var CI=f(),ah=class extends CI.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};Qo.ServiceEventArgs=ah});var CS=p(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.PhraseListGrammar=void 0;var ch=class i{constructor(e){this.privGrammerBuilder=e.dynamicGrammar}static fromRecognizer(e){let t=e.internalData;return new i(t)}addPhrase(e){this.privGrammerBuilder.addPhrase(e)}addPhrases(e){this.privGrammerBuilder.addPhrase(e)}clear(){this.privGrammerBuilder.clearPhrases()}};Yo.PhraseListGrammar=ch});var Zo=p(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.DialogServiceConfigImpl=Ei.DialogServiceConfig=void 0;var PI=w(),kn=f(),Xo=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};Ei.DialogServiceConfig=Xo;var ph=class extends Xo{constructor(){super(),this.privSpeechConfig=new kn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){PI.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechConfig.speechRecognitionLanguage=e}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(e){this.privSpeechConfig.outputFormat=e}setProperty(e,t){this.privSpeechConfig.setProperty(e,t)}getProperty(e,t){return this.privSpeechConfig.getProperty(e)}setProxy(e,t,r,n){this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(kn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};Ei.DialogServiceConfigImpl=ph});var PS=p(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.BotFrameworkConfig=void 0;var Br=w(),Ut=Zo(),xe=f(),uh=class extends Ut.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"subscription"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){Br.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),Br.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Ut.DialogServiceConfigImpl;return n.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(xe.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(xe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(xe.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){Br.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);Br.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Ut.DialogServiceConfigImpl;return s.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(xe.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){Br.Contracts.throwIfNull(e,"endpoint");let r=new Ut.DialogServiceConfigImpl;return r.setProperty(xe.PropertyId.Conversation_DialogType,Ut.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(xe.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(xe.PropertyId.SpeechServiceConnection_Key,t),r}};ea.BotFrameworkConfig=uh});var RS=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.CustomCommandsConfig=void 0;var Fr=w(),Nn=Zo(),Pt=f(),dh=class extends Nn.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"subscription"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){Fr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Fr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),Fr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Nn.DialogServiceConfigImpl;return n.setProperty(Pt.PropertyId.Conversation_DialogType,Nn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(Pt.PropertyId.Conversation_ApplicationId,e),n.setProperty(Pt.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(Pt.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){Fr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(Pt.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(Pt.PropertyId.Conversation_ApplicationId)}};ta.CustomCommandsConfig=dh});var Wt=p(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.QueryParameterNames=void 0;var H=class{};ra.QueryParameterNames=H;H.BotId="botid";H.CustomSpeechDeploymentId="cid";H.CustomVoiceDeploymentId="deploymentId";H.EnableAudioLogging="storeAudio";H.EnableLanguageId="lidEnabled";H.EnableWordLevelTimestamps="wordLevelTimestamps";H.EndSilenceTimeoutMs="endSilenceTimeoutMs";H.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";H.Format="format";H.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";H.Language="language";H.Profanity="profanity";H.RequestBotStatusMessages="enableBotMessageStatus";H.StableIntermediateThreshold="stableIntermediateThreshold";H.StableTranslation="stableTranslation";H.TestHooks="testhooks";H.Postprocessing="postprocessing";H.CtsMeetingId="meetingId";H.CtsDeviceId="deviceId";H.CtsIsParticipant="isParticipant";H.EnableAvatar="enableTalkingAvatar"});var $e=p(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.ConnectionFactoryBase=void 0;var RI=C(),pr=f(),ur=Wt(),hh=class{static getHostSuffix(e){if(e){if(e.toLowerCase().startsWith("china"))return".azure.cn";if(e.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(e,t,r){new Map([[pr.PropertyId.Speech_SegmentationSilenceTimeoutMs,ur.QueryParameterNames.SegmentationSilenceTimeoutMs],[pr.PropertyId.SpeechServiceConnection_EnableAudioLogging,ur.QueryParameterNames.EnableAudioLogging],[pr.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,ur.QueryParameterNames.EndSilenceTimeoutMs],[pr.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,ur.QueryParameterNames.InitialSilenceTimeoutMs],[pr.PropertyId.SpeechServiceResponse_PostProcessingOption,ur.QueryParameterNames.Postprocessing],[pr.PropertyId.SpeechServiceResponse_ProfanityOption,ur.QueryParameterNames.Profanity],[pr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,ur.QueryParameterNames.EnableWordLevelTimestamps],[pr.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,ur.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(RI.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}setUrlParameter(e,t,r,n,s){let o=r.parameters.getProperty(e,void 0);o&&(!s||s.search(t)===-1)&&(n[t]=o.toLocaleLowerCase())}};ia.ConnectionFactoryBase=hh});var TS=p(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.DialogConnectionFactory=void 0;var ES=ae(),EI=C(),Be=f(),wS=$e(),wI=C(),IS=we(),na=Wt(),xn=class i extends wS.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Be.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Be.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Be.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[IS.HeaderNames.ConnectionId]=r,u[na.QueryParameterNames.Format]=e.parameters.getProperty(EI.OutputFormatPropertyName,Be.OutputFormat[Be.OutputFormat.Simple]).toLowerCase(),u[na.QueryParameterNames.Language]=a,u[na.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[na.QueryParameterNames.BotId]=n,s===Be.DialogServiceConfig.DialogTypes.CustomCommands&&(u[IS.HeaderNames.CustomCommandsAppId]=n));let d=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",h=s===Be.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Be.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",l={};t.token!=null&&t.token!==""&&(l[t.headerName]=t.token);let g=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let M=wS.ConnectionFactoryBase.getHostSuffix(o),J=e.parameters.getProperty(Be.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${M}`);g=`${J.endsWith("/")?J:J+"/"}${d}${i.ApiKey}/${h}`}this.setCommonUrlParams(e,u,g);let _=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new ES.WebsocketConnection(g,u,l,new wI.WebsocketMessageFormatter,ES.ProxyInfo.fromRecognizerConfig(e),_,r)}};sa.DialogConnectionFactory=xn;xn.ApiKey="api";xn.BaseUrl="convai.speech"});var _S=p(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.DialogServiceConnector=void 0;var II=TS(),lh=C(),wi=P(),oa=w(),TI=f(),dr=Oo(),vh=class extends TI.Recognizer{constructor(e,t){let r=e;oa.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new II.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){wi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){wi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(dr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){oa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(dr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(dr.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(dr.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){oa.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new wi.Deferred;await this.privReco.recognize(lh.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),wi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){wi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){oa.Contracts.throwIfDisposed(this.privIsDisposed),wi.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privIsDisposed||e&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(e))}createRecognizerConfig(e){return new lh.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new lh.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(dr.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(dr.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(dr.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(dr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};aa.DialogServiceConnector=vh});var AS=p(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.ActivityReceivedEventArgs=void 0;var fh=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};ca.ActivityReceivedEventArgs=fh});var bS=p(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.TurnStatusResponsePayload=void 0;var gh=class i{constructor(e){this.privMessageStatusResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get interactionId(){return this.privMessageStatusResponse.interactionId}get conversationId(){return this.privMessageStatusResponse.conversationId}get statusCode(){switch(this.privMessageStatusResponse.statusCode){case"Success":return 200;case"Failed":return 400;case"TimedOut":return 429;default:return this.privMessageStatusResponse.statusCode}}};pa.TurnStatusResponsePayload=gh});var OS=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.TurnStatusReceivedEventArgs=void 0;var _I=bS(),mh=class{constructor(e){this.privTurnStatus=_I.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};ua.TurnStatusReceivedEventArgs=mh});var MS=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.ServicePropertyChannel=void 0;var AI;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(AI=qn.ServicePropertyChannel||(qn.ServicePropertyChannel={}))});var DS=p(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.ProfanityOption=void 0;var bI;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})(bI=zn.ProfanityOption||(zn.ProfanityOption={}))});var kS=p(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.BaseAudioPlayer=void 0;var OI=ot(),MI=f(),DI=sr(),Sh=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=MI.AudioStreamFormat.getDefaultInputFormat()),this.init(e)}playAudioSample(e,t,r){try{this.ensureInitializedContext();let n=this.formatAudioData(e),s=new Float32Array(this.samples.length+n.length);s.set(this.samples,0),s.set(n,this.samples.length),this.samples=s,t&&t()}catch(n){r&&r(n)}}stopAudio(e,t){this.audioContext!==null&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then(()=>{e&&e()},r=>{t&&t(r)}),this.audioContext=null)}init(e){this.audioFormat=e,this.samples=new Float32Array}ensureInitializedContext(){if(this.audioContext===null){this.createAudioContext();let e=200;this.autoUpdateBufferTimer=setInterval(()=>{this.updateAudioBuffer()},e)}}createAudioContext(){this.audioContext=DI.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(e){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(e),128);case 16:return this.formatArrayBuffer(new Int16Array(e),32768);case 32:return this.formatArrayBuffer(new Int32Array(e),2147483648);default:throw new OI.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]/t;return r}updateAudioBuffer(){if(this.samples.length===0)return;let e=this.audioFormat.channels,t=this.audioContext.createBufferSource(),r=this.samples.length/e,n=this.audioContext.createBuffer(e,r,this.audioFormat.samplesPerSec);for(let s=0;s<e;s++){let o=s,a=n.getChannelData(s);for(let c=0;c<this.samples.length;c++,o+=e)a[c]=this.samples[o]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),t.buffer=n,t.connect(this.gainNode),t.start(this.startTime),this.startTime+=n.duration,this.samples=new Float32Array}async playAudio(e){this.audioContext===null&&this.createAudioContext();let t=this.audioContext.createBufferSource(),r=this.audioContext.destination;await this.audioContext.decodeAudioData(e,n=>{t.buffer=n,t.connect(r),t.start(0)})}};da.BaseAudioPlayer=Sh});var NS=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.ConnectionMessageEventArgs=void 0;var yh=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};ha.ConnectionMessageEventArgs=yh});var xS=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.VoiceProfile=void 0;var Ch=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};la.VoiceProfile=Ch});var zS=p(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.VoiceProfileEnrollmentCancellationDetails=Ii.VoiceProfileEnrollmentResult=void 0;var qS=C(),ve=f(),Ph=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new ve.PropertyCollection,this.privReason!==ve.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=ve.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(qS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get enrollmentsCount(){return this.privDetails.enrollmentsCount}get enrollmentsLength(){return this.privDetails.enrollmentsLength}get properties(){return this.privProperties}get enrollmentResultDetails(){return this.privDetails}get errorDetails(){return this.privErrorDetails}static FromIdentificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getIdentificationDetails(r),t.push(s)}return t}static FromVerificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?ve.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?ve.ResultReason.EnrolledVoiceProfile:ve.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getVerificationDetails(r),t.push(s)}return t}static getIdentificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount||0,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.identificationProfileId,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.verificationProfileId,remainingEnrollmentsCount:e.remainingEnrollments||e.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}};Ii.VoiceProfileEnrollmentResult=Ph;var Rh=class i extends ve.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=ve.CancellationReason.Error,r=ve.CancellationErrorCode.NoError;return e.properties&&(r=ve.CancellationErrorCode[e.properties.getProperty(qS.CancellationErrorCodePropertyName,ve.CancellationErrorCode[ve.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ii.VoiceProfileEnrollmentCancellationDetails=Rh});var LS=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.VoiceProfileCancellationDetails=Ti.VoiceProfileResult=void 0;var jS=C(),kI=w(),Rt=f(),Eh=class{constructor(e,t){this.privReason=e,this.privProperties=new Rt.PropertyCollection,e===Rt.ResultReason.Canceled&&(kI.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(jS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};Ti.VoiceProfileResult=Eh;var wh=class i extends Rt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Rt.CancellationReason.Error,r=Rt.CancellationErrorCode.NoError;return e.properties&&(r=Rt.CancellationErrorCode[e.properties.getProperty(jS.CancellationErrorCodePropertyName,Rt.CancellationErrorCode[Rt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ti.VoiceProfileCancellationDetails=wh});var BS=p(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.VoiceProfilePhraseResult=void 0;var NI=w(),xI=f(),Ih=class extends xI.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],NI.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};va.VoiceProfilePhraseResult=Ih});var FS=p(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.VoiceProfileClient=void 0;var Th=C(),qI=Cd(),fa=w(),Vr=f(),_h=class extends Vr.Recognizer{constructor(e){fa.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;fa.Contracts.throwIfNull(t,"speechConfig"),super(qI.AudioConfig.fromStreamInput(Vr.AudioInputStream.createPushStream()),t.properties,new Th.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Vr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){fa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Vr.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new Vr.VoiceProfile(r[0],e)}async retrieveEnrollmentResultAsync(e){return this.privVoiceAdapter.retrieveEnrollmentResult(e)}async getAllProfilesAsync(e){return this.privVoiceAdapter.getAllProfiles(e)}async getActivationPhrasesAsync(e,t){return this.privVoiceAdapter.getActivationPhrases(e,t)}async enrollProfileAsync(e,t){let r=t;return fa.Contracts.throwIfNullOrUndefined(r,"audioConfig"),this.audioConfig=t,this.privVoiceAdapter.SpeakerAudioSource=r,this.privVoiceAdapter.enrollProfile(e)}async deleteProfileAsync(e){return this.privVoiceAdapter.deleteProfile(e)}async resetProfileAsync(e){return this.privVoiceAdapter.resetProfile(e)}async close(){await this.dispose(!0)}createServiceRecognizer(e,t,r,n){let s=r;return new Th.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new Th.RecognizerConfig(e,this.properties)}getResult(e,t){return new Vr.VoiceProfileResult(e.ok?t:Vr.ResultReason.Canceled,e.statusText)}};ga.VoiceProfileClient=_h});var VS=p(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.SpeakerRecognizer=void 0;var Ah=C(),Ur=w(),bh=f(),Oh=class extends bh.Recognizer{constructor(e,t){Ur.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Ur.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Ah.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Ur.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(bh.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Ur.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(bh.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Ur.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();let t=await this.privReco.recognizeSpeaker(e);return await this.implRecognizerStop(),t}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}createRecognizerConfig(e){return new Ah.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ah.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};ma.SpeakerRecognizer=Oh});var US=p(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.SpeakerIdentificationModel=void 0;var zI=w(),jI=f(),Mh=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],zI.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==jI.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+t.profileId);this.privVoiceProfiles.push(t),this.privProfileIds.push(t.profileId)}}static fromProfiles(e){return new i(e)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}};Sa.SpeakerIdentificationModel=Mh});var HS=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.SpeakerVerificationModel=void 0;var LI=w(),WS=f(),Dh=class i{constructor(e){if(LI.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===WS.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=e}static fromProfile(e){return new i(e)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===WS.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};ya.SpeakerVerificationModel=Dh});var kh=p(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.LanguageIdMode=void 0;var BI;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(BI=jn.LanguageIdMode||(jn.LanguageIdMode={}))});var JS=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.AutoDetectSourceLanguageConfig=void 0;var FI=C(),VI=w(),Et=f(),KS=kh(),Nh=class i{constructor(){this.privProperties=new Et.PropertyCollection,this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=KS.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,FI.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){VI.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e.join()),t}static fromSourceLanguageConfigs(e){if(e.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");let t=new i,r=[];return e.forEach(n=>{if(r.push(n.language),n.endpointId!==void 0&&n.endpointId!==""){let s=n.language+Et.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(Et.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===KS.LanguageIdMode.Continuous?(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(Et.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};Ca.AutoDetectSourceLanguageConfig=Nh});var $S=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.AutoDetectSourceLanguageResult=void 0;var GS=w(),xh=class i{constructor(e,t){GS.Contracts.throwIfNullOrUndefined(e,"language"),GS.Contracts.throwIfNullOrUndefined(t,"languageDetectionConfidence"),this.privLanguage=e,this.privLanguageDetectionConfidence=t}static fromResult(e){return new i(e.language,e.languageDetectionConfidence)}static fromConversationTranscriptionResult(e){return new i(e.language,e.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}};Pa.AutoDetectSourceLanguageResult=xh});var QS=p(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.SourceLanguageConfig=void 0;var UI=w(),qh=class i{constructor(e,t){UI.Contracts.throwIfNullOrUndefined(e,"language"),this.privLanguage=e,this.privEndpointId=t}static fromLanguage(e,t){return new i(e,t)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}};Ra.SourceLanguageConfig=qh});var XS=p(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.SpeakerRecognitionCancellationDetails=Ht.SpeakerRecognitionResult=Ht.SpeakerRecognitionResultType=void 0;var YS=C(),qe=f(),Ea;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(Ea=Ht.SpeakerRecognitionResultType||(Ht.SpeakerRecognitionResultType={}));var zh=class{constructor(e,t=qe.ResultReason.RecognizedSpeaker,r=qe.CancellationErrorCode.NoError,n=""){this.privProperties=new qe.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?Ea.Identify:Ea.Verify;this.privReason=t,this.privReason!==qe.ResultReason.Canceled?s===Ea.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=qe.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=qe.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(YS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[r])),this.privProperties.setProperty(qe.PropertyId.SpeechServiceResponse_JsonResult,JSON.stringify(e))}get properties(){return this.privProperties}get reason(){return this.privReason}get profileId(){return this.privProfileId}get errorDetails(){return this.privErrorDetails}get score(){return this.privScore}};Ht.SpeakerRecognitionResult=zh;var jh=class i extends qe.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=qe.CancellationReason.Error,r=qe.CancellationErrorCode.NoError;return e.properties&&(r=qe.CancellationErrorCode[e.properties.getProperty(YS.CancellationErrorCodePropertyName,qe.CancellationErrorCode[qe.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Ht.SpeakerRecognitionCancellationDetails=jh});var Lh=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.ConversationImpl=_i.Conversation=void 0;var q=C(),Ln=P(),S=w(),x=f(),wa=class{constructor(){}static createConversationAsync(e,t,r,n){S.Contracts.throwIfNullOrUndefined(e,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Bn(e,t),Ln.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Bn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};_i.Conversation=wa;var Bn=class extends wa{constructor(e,t){if(super(),this.privErrors=q.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case q.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case q.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case q.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case q.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case q.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case q.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new x.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new x.ConversationParticipantsChangedEventArgs(x.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(x.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new x.PropertyCollection,this.privManager=new q.ConversationManager,e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage],q.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(x.PropertyId[x.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(x.ProfanityOption.Masked);let o=e.getProperty(x.PropertyId[x.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),S.Contracts.throwIfNullOrTooLong(o,"nickname",50),S.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(x.PropertyId[x.PropertyId.ConversationTranslator_Name],o)}this.privConfig=e;let n=e;S.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new q.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get conversationId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){let e=this.conversationId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of q.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,conversationProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){S.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=q.ConversationRecognizerFactory.fromConfig(this,this.privConfig),this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.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,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){S.Contracts.throwIfNullOrUndefined(e,"Participant"),Ln.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinConversationAsync(e,t,r,n,s){try{S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),S.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{S.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteConversationAsync(e,t){Ln.marshalPromiseToCallbacks(this.deleteConversationImplAsync(),e,t)}async deleteConversationImplAsync(){S.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),S.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,t){Ln.marshalPromiseToCallbacks(this.endConversationImplAsync(),e,t)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(S.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Ln.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),S.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockConversationAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),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.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.conversationInfo;return r.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new x.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"nickname"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),S.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:q.ConversationTranslatorMessageTypes.instantMessage})}};_i.ConversationImpl=Bn});var ZS=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.ConversationCommon=void 0;var Bh=class{constructor(e){this.privAudioConfig=e}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}};Ia.ConversationCommon=Bh});var ey=p(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.ConversationExpirationEventArgs=void 0;var WI=f(),Fh=class extends WI.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};Ta.ConversationExpirationEventArgs=Fh});var ty=p(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.ConversationParticipantsChangedEventArgs=void 0;var HI=f(),Vh=class extends HI.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};_a.ConversationParticipantsChangedEventArgs=Vh});var ry=p(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.ConversationTranslationCanceledEventArgs=void 0;var KI=mi(),Uh=class extends KI.CancellationEventArgsBase{};Aa.ConversationTranslationCanceledEventArgs=Uh});var iy=p(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.ConversationTranslationEventArgs=void 0;var JI=f(),Wh=class extends JI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};ba.ConversationTranslationEventArgs=Wh});var ny=p(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.ConversationTranslationResult=void 0;var GI=zd(),Hh=class extends GI.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(t,n,s,o,a,c,void 0,void 0,u,d,h),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};Oa.ConversationTranslationResult=Hh});var Jh=p(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});Ma.StringUtils=void 0;var Kh=class{static formatString(e,t){if(!e)return"";if(!t)return e;let r="",n="",s=c=>{r+=c},o=c=>{n+=c},a=s;for(let c=0;c<e.length;c++){let u=e[c],d=c+1<e.length?e[c+1]:"";switch(u){case"{":d==="{"?(a("{"),c++):a=o;break;case"}":d==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};Ma.StringUtils=Kh});var ay=p(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.ConversationTranslatorConnectionFactory=void 0;var Gh=ae(),sy=Jh(),$I=w(),Da=f(),QI=we(),Qe=Wt(),oy=$e(),$h=C(),ka=class i extends oy.ConnectionFactoryBase{constructor(e){super(),$I.Contracts.throwIfNullOrUndefined(e,"convGetter"),this.privConvGetter=e}create(e,t,r){let n=e.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase()==="TRUE",s=this.privConvGetter().room,o=s.cognitiveSpeechRegion||e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:oy.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Qe.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Qe.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Qe.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Qe.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Qe.QueryParameterNames.CtsIsParticipant;let c="",u={},d={};if(n){c=e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(Da.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=sy.StringUtils.formatString(c,a);let l=new URL(c);l.searchParams.forEach((_,M)=>{u[M]=_}),new $h.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Qe.QueryParameterNames.CtsMeetingId]=a[Qe.QueryParameterNames.CtsMeetingId],u[Qe.QueryParameterNames.CtsDeviceId]=a[Qe.QueryParameterNames.CtsDeviceId],s.isHost||(u[Qe.QueryParameterNames.CtsIsParticipant]=""),Qe.QueryParameterNames.Format in u||(u[Qe.QueryParameterNames.Format]="simple"),l.searchParams.forEach((_,M)=>{l.searchParams.set(M,u[M]),delete u[M]}),c=l.toString()}else{let l=new $h.TranslationConnectionFactory;c=l.getEndpointUrl(e,!0),c=sy.StringUtils.formatString(c,a),l.setQueryParams(u,e,c)}d[QI.HeaderNames.ConnectionId]=r,d[Gh.RestConfigBase.configParams.token]=s.token,t.token&&(d[t.headerName]=t.token);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new Gh.WebsocketConnection(c,u,d,new $h.WebsocketMessageFormatter,Gh.ProxyInfo.fromRecognizerConfig(e),h,r)}};Na.ConversationTranslatorConnectionFactory=ka;ka.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var py=p(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.ConversationTranslator=Wr.SpeechState=void 0;var Fn=C(),YI=ay(),xa=P(),pt=w(),U=f(),XI=Lh(),cy=qa(),ut;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(ut=Wr.SpeechState||(Wr.SpeechState={}));var Qh=class extends U.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new YI.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=ut.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=ut.Connected},this.sessionStopped=()=>{this.privSpeechState=ut.Inactive},this.recognizing=(s,o)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,o)},this.recognized=async(s,o)=>{o.result?.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(o.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,o)},this.canceled=async()=>{if(this.privSpeechState!==ut.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=ut.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=ut.Connected}async onCancelSpeech(){this.privSpeechState=ut.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new cy.ConversationTranslationCanceledEventArgs(U.CancellationReason.Error,e,U.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=ut.Inactive}catch{}}},Yh=class extends cy.ConversationCommon{constructor(e){super(e),this.privErrors=Fn.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new U.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){return this.privConversation?.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer||this.privIsSpeaking||this.privCTRecognizer.state===ut.Connected||this.privCTRecognizer.state===ut.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(Fn.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s);let o=r;(o==null||o==="")&&(o=Fn.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=U.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(U.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.ConversationTranslator_Name],t);let a=[U.PropertyId.SpeechServiceConnection_Host,U.PropertyId.ConversationTranslator_Host,U.PropertyId.SpeechServiceConnection_Endpoint,U.PropertyId.SpeechServiceConnection_ProxyHostName,U.PropertyId.SpeechServiceConnection_ProxyPassword,U.PropertyId.SpeechServiceConnection_ProxyPort,U.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let d=this.privProperties.getProperty(u);if(d){let h=typeof u=="string"?u:U.PropertyId[u];this.privSpeechTranslationConfig.setProperty(h,d)}}let c=JSON.parse(this.privProperties.getProperty(Fn.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],U.ServicePropertyChannel.UriQueryParameter);this.privConversation=new XI.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,o,u=>{u||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privSpeechTranslationConfig.authorizationToken=u,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync(()=>{this.handleCallback(n,s)},d=>{this.handleError(d,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(pt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),pt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(U.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),pt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(o){this.handleError(o,typeof r=="string"?s:n)}}leaveConversationAsync(e,t){xa.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){xa.marshalPromiseToCallbacks((async()=>{try{pt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),pt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),pt.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),t),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(r){throw this.privIsSpeaking=!1,await this.cancelSpeech(),r}})(),e,t)}stopTranscribingAsync(e,t){xa.marshalPromiseToCallbacks((async()=>{try{if(!this.privIsSpeaking){await this.cancelSpeech();return}this.privIsSpeaking=!1,await new Promise((r,n)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(r,n)})}catch{await this.cancelSpeech()}})(),e,t)}isDisposed(){return this.privIsDisposed}dispose(e,t,r){xa.marshalPromiseToCallbacks((async()=>{this.isDisposed&&!this.privIsSpeaking||(await this.cancelSpeech(),this.privIsDisposed=!0,this.privSpeechTranslationConfig.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,this.privConversation.dispose(),this.privConversation=void 0)})(),t,r)}async cancelSpeech(){try{this.privIsSpeaking=!1,await this.privCTRecognizer?.onCancelSpeech(),this.privCTRecognizer=void 0}catch{}}async connectTranslatorRecognizer(){try{this.privAudioConfig===void 0&&(this.privAudioConfig=U.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(U.PropertyId[U.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new Qh(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Wr.ConversationTranslator=Yh});var uy=p(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.ConversationTranscriber=void 0;var Vn=C(),Xh=P(),Hr=w(),Oe=f(),Zh=class i extends Oe.Recognizer{constructor(e,t){let r=e;Hr.Contracts.throwIfNull(r,"speechConfig"),Hr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage),Oe.PropertyId[Oe.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Vn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(Oe.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Oe.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Oe.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Oe.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Vn.OutputFormatPropertyName,Oe.OutputFormat[Oe.OutputFormat.Simple])===Oe.OutputFormat[Oe.OutputFormat.Simple]?Oe.OutputFormat.Simple:Oe.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Vn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){Xh.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Hr.Contracts.throwIfDisposed(this.privDisposedRecognizer),Xh.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Vn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Vn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};za.ConversationTranscriber=Zh});var dy=p(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.Participant=Ai.User=void 0;var ZI=f(),el=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};Ai.User=el;var tl=class i{constructor(e,t,r,n,s,o,a,c){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=n,this.privIsMuted=s,this.privIsUsingTts=o,this.privPreferredLanguage=a,this.privVoice=c,this.privProperties=new ZI.PropertyCollection}get avatar(){return this.privAvatar}get displayName(){return this.privDisplayName}get id(){return this.privId}get preferredLanguage(){return this.privPreferredLanguage}get isHost(){return this.privIsHost}get isMuted(){return this.privIsMuted}get isUsingTts(){return this.privIsUsingTts}get voice(){return this.privVoice}get properties(){return this.privProperties}static From(e,t,r){return new i(e,"",e,!1,!1,!1,t,r)}};Ai.Participant=tl});var hy=p(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.ParticipantChangedReason=void 0;var eT;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(eT=Un.ParticipantChangedReason||(Un.ParticipantChangedReason={}))});var ly=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.MeetingImpl=bi.Meeting=void 0;var j=C(),Wn=P(),y=w(),K=f(),ja=class{constructor(){}static createMeetingAsync(e,t,r,n){if(y.Contracts.throwIfNullOrUndefined(e,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),y.Contracts.throwIfNullOrUndefined(e.region,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),y.Contracts.throwIfNull(t,"meetingId"),t.length===0)throw new Error("meetingId cannot be empty");!e.subscriptionKey&&!e.getProperty(K.PropertyId[K.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,j.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new La(e,t);return Wn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};bi.Meeting=ja;var La=class extends ja{constructor(e,t){super(),this.privErrors=j.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case j.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case j.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case j.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case j.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case j.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case j.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case j.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new K.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new K.ConversationParticipantsChangedEventArgs(K.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(K.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new K.PropertyCollection,this.privManager=new j.ConversationManager,e.getProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage],j.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(K.PropertyId[K.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=t,this.privConfig=e;let n=e;y.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new j.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get meetingId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){let e=this.meetingId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of j.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,meetingProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){y.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.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,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){y.Contracts.throwIfNullOrUndefined(e,"Participant"),Wn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinMeetingAsync(e,t,r,n,s){try{y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),y.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{y.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteMeetingAsync(e,t){Wn.marshalPromiseToCallbacks(this.deleteMeetingImplAsync(),e,t)}async deleteMeetingImplAsync(){y.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),y.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,t){Wn.marshalPromiseToCallbacks(this.endMeetingImplAsync(),e,t)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(y.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Wn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),y.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockMeetingAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),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.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.meetingInfo;return r.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new K.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(e,"nickname"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:j.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:j.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),y.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:j.ConversationTranslatorMessageTypes.instantMessage})}};bi.MeetingImpl=La});var vy=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.MeetingTranscriptionCanceledEventArgs=void 0;var tT=mi(),rl=class extends tT.CancellationEventArgsBase{};Ba.MeetingTranscriptionCanceledEventArgs=rl});var fy=p(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});Fa.MeetingTranscriber=void 0;var rT=C(),il=P(),Hn=w(),Kn=f(),iT=qa(),nl=class{constructor(e){this.privAudioConfig=e,this.privProperties=new Kn.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Kn.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return Kn.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(Kn.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Hn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Kn.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;Hn.Contracts.throwIfNullOrUndefined(iT.MeetingImpl,"Meeting"),this.privRecognizer=new rT.TranscriberRecognizer(e.config,this.privAudioConfig),Hn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),il.marshalPromiseToCallbacks(n.connectTranscriberRecognizer(this.privRecognizer),t,r)}startTranscribingAsync(e,t){this.privRecognizer.startContinuousRecognitionAsync(e,t)}stopTranscribingAsync(e,t){this.privRecognizer.stopContinuousRecognitionAsync(e,t)}leaveMeetingAsync(e,t){this.privRecognizer.disconnectCallbacks(),il.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){Hn.Contracts.throwIfDisposed(this.privDisposedRecognizer),il.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}};Fa.MeetingTranscriber=nl});var gy=p(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.ConversationTranscriptionResult=void 0;var nT=f(),sl=class extends nT.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,d,h){super(e,t,r,n,s,o,a,u,d,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};Va.ConversationTranscriptionResult=sl});var qa=p(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});var my=Lh();Object.defineProperty(re,"Conversation",{enumerable:!0,get:function(){return my.Conversation}});Object.defineProperty(re,"ConversationImpl",{enumerable:!0,get:function(){return my.ConversationImpl}});var sT=ZS();Object.defineProperty(re,"ConversationCommon",{enumerable:!0,get:function(){return sT.ConversationCommon}});var oT=ey();Object.defineProperty(re,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return oT.ConversationExpirationEventArgs}});var aT=ty();Object.defineProperty(re,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return aT.ConversationParticipantsChangedEventArgs}});var cT=ry();Object.defineProperty(re,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return cT.ConversationTranslationCanceledEventArgs}});var pT=iy();Object.defineProperty(re,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return pT.ConversationTranslationEventArgs}});var uT=ny();Object.defineProperty(re,"ConversationTranslationResult",{enumerable:!0,get:function(){return uT.ConversationTranslationResult}});var dT=py();Object.defineProperty(re,"ConversationTranslator",{enumerable:!0,get:function(){return dT.ConversationTranslator}});var hT=uy();Object.defineProperty(re,"ConversationTranscriber",{enumerable:!0,get:function(){return hT.ConversationTranscriber}});var Sy=dy();Object.defineProperty(re,"Participant",{enumerable:!0,get:function(){return Sy.Participant}});Object.defineProperty(re,"User",{enumerable:!0,get:function(){return Sy.User}});var lT=hy();Object.defineProperty(re,"ParticipantChangedReason",{enumerable:!0,get:function(){return lT.ParticipantChangedReason}});var yy=ly();Object.defineProperty(re,"Meeting",{enumerable:!0,get:function(){return yy.Meeting}});Object.defineProperty(re,"MeetingImpl",{enumerable:!0,get:function(){return yy.MeetingImpl}});var vT=vy();Object.defineProperty(re,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return vT.MeetingTranscriptionCanceledEventArgs}});var fT=fy();Object.defineProperty(re,"MeetingTranscriber",{enumerable:!0,get:function(){return fT.MeetingTranscriber}});var gT=gy();Object.defineProperty(re,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return gT.ConversationTranscriptionResult}})});var Ua=p(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.SynthesisRequest=Oi.Synthesizer=void 0;var Kr=C(),mT=P(),Cy=w(),hr=f(),ol=class i{constructor(e){let t=e;Cy.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new mT.Queue}get authorizationToken(){return this.properties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Cy.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(hr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===Kr.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){let t={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-JennyNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"},r=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),n=this.properties.getProperty(hr.PropertyId.SpeechServiceConnection_SynthVoice,""),s=i.XMLEncode(e);return this.autoDetectSourceLanguage?r="en-US":n=n||t[r],n&&(s=`<voice name='${n}'>${s}</voice>`),s=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${r}'>${s}</speak>`,s}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;let e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new Kr.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createSynthesizerConfig(new Kr.SpeechServiceConfig(new Kr.Context(new Kr.OS(e,t,r)))),s=this.privProperties.getProperty(hr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Kr.CognitiveSubscriptionKeyAuthentication(s):new Kr.CognitiveTokenAuthentication(()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)},()=>{let a=this.privProperties.getProperty(hr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)});this.privAdapter=this.createSynthesisAdapter(o,this.privConnectionFactory,n),this.privRestAdapter=this.createRestSynthesisAdapter(o,n)}static XMLEncode(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};Oi.Synthesizer=ol;var al=class{constructor(e,t,r,n,s,o){this.requestId=e,this.text=t,this.isSSML=r,this.cb=n,this.err=s,this.dataStream=o}};Oi.SynthesisRequest=al});var Ry=p(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SpeechSynthesizer=void 0;var cl=C(),pl=P(),ST=gd(),yT=li(),CT=Dr(),Py=w(),lr=f(),PT=Ua(),ul=class i extends lr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:lr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new cl.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}speakTextAsync(e,t,r,n){this.speakImpl(e,!1,t,r,n)}speakSsmlAsync(e,t,r,n){this.speakImpl(e,!0,t,r,n)}async getVoicesAsync(e=""){return this.getVoices(e)}close(e,t){Py.Contracts.throwIfDisposed(this.privDisposed),pl.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new cl.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new cl.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=yT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(lr.SpeechSynthesisOutputFormat[this.properties.getProperty(lr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{Py.Contracts.throwIfDisposed(this.privDisposed);let o=pl.createNoDashGuid(),a;s instanceof lr.PushAudioOutputStreamCallback?a=new CT.PushAudioOutputStreamImpl(s):s instanceof lr.PullAudioOutputStream?a=s:s!==void 0?a=new ST.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new PT.SynthesisRequest(o,e,t,c=>{if(this.privSynthesizing=!1,r)try{r(c)}catch(u){n&&n(u)}r=void 0,this.adapterSpeak().catch(()=>{})},c=>{n&&n(c)},a)),this.adapterSpeak().catch(()=>{})}catch(o){if(n)if(o instanceof Error){let a=o;n(a.name+": "+a.message)}else n(o);this.dispose(!0).catch(()=>{})}}async getVoices(e){let t=pl.createNoDashGuid(),r=await this.privRestAdapter.getVoicesList(t);if(r.ok&&Array.isArray(r.json)){let n=r.json;return e&&e.length>0&&(n=n.filter(s=>!!s.Locale&&s.Locale.toLowerCase()===e.toLowerCase())),new lr.SynthesisVoicesResult(t,n,void 0)}else return new lr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};Wa.SpeechSynthesizer=ul});var Ey=p(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.SynthesisResult=void 0;var dl=class{constructor(e,t,r,n){this.privResultId=e,this.privReason=t,this.privErrorDetails=r,this.privProperties=n}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}};Ha.SynthesisResult=dl});var wy=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SpeechSynthesisResult=void 0;var RT=f(),hl=class extends RT.SynthesisResult{constructor(e,t,r,n,s,o){super(e,t,n,s),this.privAudioData=r,this.privAudioDuration=o}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}};Ka.SpeechSynthesisResult=hl});var Iy=p(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SpeechSynthesisEventArgs=void 0;var ll=class{constructor(e){this.privResult=e}get result(){return this.privResult}};Ja.SpeechSynthesisEventArgs=ll});var Ty=p(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SpeechSynthesisWordBoundaryEventArgs=void 0;var vl=class{constructor(e,t,r,n,s,o){this.privAudioOffset=e,this.privDuration=t,this.privText=r,this.privWordLength=n,this.privTextOffset=s,this.privBoundaryType=o}get audioOffset(){return this.privAudioOffset}get duration(){return this.privDuration}get text(){return this.privText}get wordLength(){return this.privWordLength}get textOffset(){return this.privTextOffset}get boundaryType(){return this.privBoundaryType}};Ga.SpeechSynthesisWordBoundaryEventArgs=vl});var _y=p($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.SpeechSynthesisBookmarkEventArgs=void 0;var fl=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};$a.SpeechSynthesisBookmarkEventArgs=fl});var Ay=p(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.SpeechSynthesisVisemeEventArgs=void 0;var gl=class{constructor(e,t,r){this.privAudioOffset=e,this.privVisemeId=t,this.privAnimation=r}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}};Qa.SpeechSynthesisVisemeEventArgs=gl});var by=p(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.SpeechSynthesisBoundaryType=void 0;var ET;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(ET=Jn.SpeechSynthesisBoundaryType||(Jn.SpeechSynthesisBoundaryType={}))});var Oy=p(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.SynthesisVoicesResult=void 0;var Mi=f(),ml=class extends Mi.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Mi.ResultReason.VoicesListRetrieved,void 0,new Mi.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Mi.VoiceInfo(n))}else super(e,Mi.ResultReason.Canceled,r||"Error information unavailable",new Mi.PropertyCollection)}get voices(){return this.privVoices}};Ya.SynthesisVoicesResult=ml});var My=p(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.VoiceInfo=wt.SynthesisVoiceType=wt.SynthesisVoiceGender=void 0;var dt;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(dt=wt.SynthesisVoiceGender||(wt.SynthesisVoiceGender={}));var Sl;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(Sl=wt.SynthesisVoiceType||(wt.SynthesisVoiceType={}));var wT={[dt[dt.Neutral]]:dt.Neutral,[dt[dt.Male]]:dt.Male,[dt[dt.Female]]:dt.Female},yl=class{constructor(e){if(this.privStyleList=[],e){if(this.privName=e.Name,this.privLocale=e.Locale,this.privShortName=e.ShortName,this.privLocaleName=e.LocaleName,this.privDisplayName=e.DisplayName,this.privLocalName=e.LocalName,this.privVoiceType=e.VoiceType.endsWith("Standard")?Sl.OnlineStandard:Sl.OnlineNeural,this.privGender=wT[e.Gender]||dt.Unknown,e.StyleList&&Array.isArray(e.StyleList))for(let t of e.StyleList)this.privStyleList.push(t);this.privSampleRateHertz=e.SampleRateHertz,this.privStatus=e.Status,e.ExtendedPropertyMap&&(this.privExtendedPropertyMap=e.ExtendedPropertyMap),this.privWordsPerMinute=e.WordsPerMinute,Array.isArray(e.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...e.SecondaryLocaleList]),Array.isArray(e.RolePlayList)&&(this.privRolePlayList=[...e.RolePlayList])}}get name(){return this.privName}get locale(){return this.privLocale}get shortName(){return this.privShortName}get displayName(){return this.privDisplayName}get localName(){return this.privLocalName}get localeName(){return this.privLocaleName}get gender(){return this.privGender}get voiceType(){return this.privVoiceType}get styleList(){return this.privStyleList}get sampleRateHertz(){return this.privSampleRateHertz}get status(){return this.privStatus}get extendedPropertyMap(){return this.privExtendedPropertyMap}get wordsPerMinute(){return this.privWordsPerMinute}get secondaryLocaleList(){return this.privSecondaryLocaleList}get rolePlayList(){return this.privRolePlayList}};wt.VoiceInfo=yl});var ky=p(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.SpeakerAudioDestination=void 0;var Jr=P(),IT=Dr(),Ye=sr(),TT=60*30,Dy={[Ye.AudioFormatTag.PCM]:"audio/wav",[Ye.AudioFormatTag.MuLaw]:"audio/x-wav",[Ye.AudioFormatTag.MP3]:"audio/mpeg",[Ye.AudioFormatTag.OGG_OPUS]:"audio/ogg",[Ye.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[Ye.AudioFormatTag.ALaw]:"audio/x-wav",[Ye.AudioFormatTag.FLAC]:"audio/flac"},Cl=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||Jr.createNoDashGuid(),this.privIsPaused=!1,this.privIsClosed=!1}id(){return this.privId}write(e,t,r){this.privAudioBuffer!==void 0?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then(()=>{t&&t()},n=>{r&&r(n)})):this.privAudioOutputStream!==void 0&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,t){if(this.privIsClosed=!0,this.privSourceBuffer!==void 0)this.handleSourceBufferUpdateEnd().then(()=>{e&&e()},r=>{t&&t(r)});else if(this.privAudioOutputStream!==void 0&&typeof window<"u")if((this.privFormat.formatTag===Ye.AudioFormatTag.PCM||this.privFormat.formatTag===Ye.AudioFormatTag.MuLaw||this.privFormat.formatTag===Ye.AudioFormatTag.ALaw)&&this.privFormat.hasHeader===!1)console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."),this.onAudioEnd&&this.onAudioEnd(this);else{let r=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(r).then(()=>{r=this.privFormat.addHeader(r);let n=new Blob([r],{type:Dy[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(n),this.notifyPlayback().then(()=>{e&&e()},s=>{t&&t(s)})},n=>{t&&t(n)})}else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if(typeof AudioContext<"u"||typeof window<"u"&&typeof window.webkitAudioContext<"u"){this.privFormat=e;let t=Dy[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${Ye.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):typeof MediaSource<"u"&&MediaSource.isTypeSupported(t)?(this.privAudio=new Audio,this.privAudioBuffer=[],this.privMediaSource=new MediaSource,this.privAudio.src=URL.createObjectURL(this.privMediaSource),this.privAudio.load(),this.privMediaSource.onsourceopen=()=>{this.privMediaSourceOpened=!0,this.privMediaSource.duration=TT,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{Jr.Events.instance.onEvent(new Jr.BackgroundEvent(r))})):(console.warn(`Format ${Ye.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new IT.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){return this.privAudio?.volume??-1}set volume(e){this.privAudio&&(this.privAudio.volume=e)}mute(){this.privAudio&&(this.privAudio.muted=!0)}unmute(){this.privAudio&&(this.privAudio.muted=!1)}get isClosed(){return this.privIsClosed}get currentTime(){return this.privAudio!==void 0?this.privAudio.currentTime:-1}pause(){!this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.pause(),this.privIsPaused=!0)}resume(e,t){this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.play().then(()=>{e&&e()},r=>{t&&t(r)}),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(this.privAudioBuffer!==void 0&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;let e=this.privAudioBuffer.shift();try{this.privSourceBuffer.appendBuffer(e)}catch{this.privAudioBuffer.unshift(e),console.log("buffer filled, pausing addition of binaries until space is made");return}await this.notifyPlayback()}else this.canEndStream()&&await this.handleSourceBufferUpdateEnd()}async handleSourceBufferUpdateEnd(){this.canEndStream()&&this.sourceBufferAvailable()&&(this.privMediaSource.endOfStream(),await this.notifyPlayback())}async notifyPlayback(){!this.privPlaybackStarted&&this.privAudio!==void 0&&(this.privPlaybackStarted=!0,this.onAudioStart&&this.onAudioStart(this),this.privAudio.onended=()=>{this.onAudioEnd&&this.onAudioEnd(this)},this.privIsPaused||await this.privAudio.play())}canEndStream(){return this.isClosed&&this.privSourceBuffer!==void 0&&this.privAudioBuffer.length===0&&this.privMediaSourceOpened&&!this.privAppendingToBuffer&&this.privMediaSource.readyState==="open"}sourceBufferAvailable(){return this.privSourceBuffer!==void 0&&!this.privSourceBuffer.updating}};Xa.SpeakerAudioDestination=Cl});var Ny=p(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.ConversationTranscriptionCanceledEventArgs=void 0;var _T=mi(),Pl=class extends _T.CancellationEventArgsBase{};Za.ConversationTranscriptionCanceledEventArgs=Pl});var xy=p(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.MeetingTranscriptionCanceledEventArgs=void 0;var AT=mi(),Rl=class extends AT.CancellationEventArgsBase{};ec.MeetingTranscriptionCanceledEventArgs=Rl});var qy=p(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.PronunciationAssessmentGradingSystem=void 0;var bT;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})(bT=Gn.PronunciationAssessmentGradingSystem||(Gn.PronunciationAssessmentGradingSystem={}))});var zy=p($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.PronunciationAssessmentGranularity=void 0;var OT;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(OT=$n.PronunciationAssessmentGranularity||($n.PronunciationAssessmentGranularity={}))});var jy=p(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.PronunciationAssessmentConfig=void 0;var tc=w(),Q=f(),El=class i{constructor(e,t=Q.PronunciationAssessmentGradingSystem.FivePoint,r=Q.PronunciationAssessmentGranularity.Phoneme,n=!1){tc.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new Q.PropertyCollection,this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_GradingSystem,Q.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Granularity,Q.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){tc.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new Q.PropertyCollection,t.properties.setProperty(Q.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(Q.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){tc.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(Q.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){tc.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()==="true"}set nbestPhonemeCount(e){this.privNBestPhonemeCount=e}set enableProsodyAssessment(e){this.privEnableProsodyAssessment=e}enableContentAssessmentWithTopic(e){this.privContentAssessmentTopic=e}get properties(){return this.privProperties}updateJson(){let e=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_Granularity);s&&(t.granularity=s),this.privPhonemeAlphabet&&(t.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(t.nbestPhonemeCount=this.privNBestPhonemeCount),t.enableProsodyAssessment=this.privEnableProsodyAssessment,t.dimension="Comprehensive",this.privProperties.getProperty(Q.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(Q.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};rc.PronunciationAssessmentConfig=El});var Ly=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.PronunciationAssessmentResult=Di.ContentAssessmentResult=void 0;var wl=w(),MT=f(),ic=class{constructor(e){this.privPronJson=e}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}};Di.ContentAssessmentResult=ic;var Il=class i{constructor(e){let t=JSON.parse(e);wl.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){wl.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(MT.PropertyId.SpeechServiceResponse_JsonResult);return wl.Contracts.throwIfNullOrUndefined(t,"json"),new i(t)}get detailResult(){return this.privPronJson}get accuracyScore(){return this.detailResult.PronunciationAssessment?.AccuracyScore}get pronunciationScore(){return this.detailResult.PronunciationAssessment?.PronScore}get completenessScore(){return this.detailResult.PronunciationAssessment?.CompletenessScore}get fluencyScore(){return this.detailResult.PronunciationAssessment?.FluencyScore}get prosodyScore(){return this.detailResult.PronunciationAssessment?.ProsodyScore}get contentAssessmentResult(){if(this.detailResult.ContentAssessment!==void 0)return new ic(this.detailResult)}};Di.PronunciationAssessmentResult=Il});var By=p(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.AvatarConfig=void 0;var DT=w(),kT=f(),Tl=class{constructor(e,t,r){this.privCustomized=!1,DT.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new kT.AvatarVideoFormat),this.videoFormat=r}get customized(){return this.privCustomized}set customized(e){this.privCustomized=e}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(e){this.privBackgroundColor=e}};nc.AvatarConfig=Tl});var Fy=p(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Gr.AvatarEventArgs=Gr.AvatarEventTypes=void 0;var NT;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(NT=Gr.AvatarEventTypes||(Gr.AvatarEventTypes={}));var _l=class{constructor(e,t){this.privOffset=e,this.privDescription=t}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}};Gr.AvatarEventArgs=_l});var bl=p(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.SpeechSynthesisConnectionFactory=void 0;var Vy=ae(),Qn=f(),xT=$e(),qT=C(),zT=we(),sc=Wt(),Al=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Region,void 0),o=xT.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(Qn.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),d={},h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[zT.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(sc.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(d[sc.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(sc.QueryParameterNames.EnableAvatar)===-1)&&(d[sc.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(Qn.PropertyId.SpeechServiceConnection_Url,n);let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new Vy.WebsocketConnection(n,d,h,new qT.WebsocketMessageFormatter,Vy.ProxyInfo.fromParameters(e.parameters),l,r)}};oc.SpeechSynthesisConnectionFactory=Al});var Uy=p(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.AvatarSynthesizer=void 0;var jT=bl(),LT=C(),X=P(),BT=li(),Kt=f(),ac=w(),FT=Ua(),Ol=class extends Kt.Synthesizer{constructor(e,t){super(e),ac.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new jT.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=BT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Kt.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){ac.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,ac.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new X.Deferred;e.onicegatheringstatechange=()=>{X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,X.EventType.Debug)),e.iceGatheringState==="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering complete.",X.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,X.EventType.Debug)):(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: complete",X.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering timeout.",X.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,X.Events.instance.onEvent(new X.PlatformEvent("peer connection: got local SDP.",X.EventType.Info)),this.privProperties.setProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Kt.ResultReason.SynthesizingAudioCompleted)return new Kt.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Kt.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Kt.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Kt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Kt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async stopSpeakingAsync(){for(;this.synthesisRequestQueue.length()>0;)(await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user.");return this.privAdapter.stopSpeaking()}async stopAvatarAsync(){return ac.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(e,t,r){return new LT.AvatarSynthesisAdapter(e,t,r,this,this.privAvatarConfig)}createRestSynthesisAdapter(e,t){}createSynthesizerConfig(e){let t=super.createSynthesizerConfig(e);return t.avatarEnabled=!0,t}async speak(e,t){let r=X.createNoDashGuid(),n=new X.Deferred;return this.synthesisRequestQueue.enqueue(new FT.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};cc.AvatarSynthesizer=Ol});var Wy=p(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});ki.AvatarVideoFormat=ki.Coordinate=void 0;var Ml=class{constructor(e,t){this.x=e,this.y=t}};ki.Coordinate=Ml;var Dl=class{constructor(e="H264",t=2e6,r=1920,n=1080){this.codec=e,this.bitrate=t,this.width=r,this.height=n}setCropRange(e,t){this.cropRange={bottomRight:t,topLeft:e}}};ki.AvatarVideoFormat=Dl});var Hy=p(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});pc.AvatarWebRTCConnectionResult=void 0;var VT=f(),kl=class extends VT.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};pc.AvatarWebRTCConnectionResult=kl});var Ky=p(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});dc.Diagnostics=void 0;var UT=ae(),WT=P(),uc=class{static SetLoggingLevel(e){this.privListener=new UT.ConsoleLoggingListener(e),WT.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(e){if(typeof window>"u")this.privListener&&(this.privListener.logPath=e);else throw new Error("File system logging not available in browser.")}static set onLogOutput(e){this.privListener&&(this.privListener.logCallback=e)}};dc.Diagnostics=uc;uc.privListener=void 0});var f=p(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var HT=Cd();Object.defineProperty(v,"AudioConfig",{enumerable:!0,get:function(){return HT.AudioConfig}});var Jy=sr();Object.defineProperty(v,"AudioStreamFormat",{enumerable:!0,get:function(){return Jy.AudioStreamFormat}});Object.defineProperty(v,"AudioFormatTag",{enumerable:!0,get:function(){return Jy.AudioFormatTag}});var Nl=md();Object.defineProperty(v,"AudioInputStream",{enumerable:!0,get:function(){return Nl.AudioInputStream}});Object.defineProperty(v,"PullAudioInputStream",{enumerable:!0,get:function(){return Nl.PullAudioInputStream}});Object.defineProperty(v,"PushAudioInputStream",{enumerable:!0,get:function(){return Nl.PushAudioInputStream}});var xl=Dr();Object.defineProperty(v,"AudioOutputStream",{enumerable:!0,get:function(){return xl.AudioOutputStream}});Object.defineProperty(v,"PullAudioOutputStream",{enumerable:!0,get:function(){return xl.PullAudioOutputStream}});Object.defineProperty(v,"PushAudioOutputStream",{enumerable:!0,get:function(){return xl.PushAudioOutputStream}});var KT=km();Object.defineProperty(v,"CancellationReason",{enumerable:!0,get:function(){return KT.CancellationReason}});var JT=Nm();Object.defineProperty(v,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return JT.PullAudioInputStreamCallback}});var GT=xm();Object.defineProperty(v,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return GT.PushAudioOutputStreamCallback}});var $T=zm();Object.defineProperty(v,"KeywordRecognitionModel",{enumerable:!0,get:function(){return $T.KeywordRecognitionModel}});var QT=jm();Object.defineProperty(v,"SessionEventArgs",{enumerable:!0,get:function(){return QT.SessionEventArgs}});var YT=Lm();Object.defineProperty(v,"RecognitionEventArgs",{enumerable:!0,get:function(){return YT.RecognitionEventArgs}});var XT=Bm();Object.defineProperty(v,"OutputFormat",{enumerable:!0,get:function(){return XT.OutputFormat}});var ZT=Fm();Object.defineProperty(v,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return ZT.IntentRecognitionEventArgs}});var e_=Vm();Object.defineProperty(v,"RecognitionResult",{enumerable:!0,get:function(){return e_.RecognitionResult}});var t_=Um();Object.defineProperty(v,"SpeechRecognitionResult",{enumerable:!0,get:function(){return t_.SpeechRecognitionResult}});var r_=Wm();Object.defineProperty(v,"IntentRecognitionResult",{enumerable:!0,get:function(){return r_.IntentRecognitionResult}});var i_=Hm();Object.defineProperty(v,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return i_.LanguageUnderstandingModel}});var ql=Jm();Object.defineProperty(v,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return ql.SpeechRecognitionEventArgs}});Object.defineProperty(v,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.ConversationTranscriptionEventArgs}});Object.defineProperty(v,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return ql.MeetingTranscriptionEventArgs}});var n_=Gm();Object.defineProperty(v,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return n_.SpeechRecognitionCanceledEventArgs}});var s_=$m();Object.defineProperty(v,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return s_.TranslationRecognitionEventArgs}});var o_=Qm();Object.defineProperty(v,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return o_.TranslationSynthesisEventArgs}});var a_=zd();Object.defineProperty(v,"TranslationRecognitionResult",{enumerable:!0,get:function(){return a_.TranslationRecognitionResult}});var c_=Ym();Object.defineProperty(v,"TranslationSynthesisResult",{enumerable:!0,get:function(){return c_.TranslationSynthesisResult}});var p_=Xm();Object.defineProperty(v,"ResultReason",{enumerable:!0,get:function(){return p_.ResultReason}});var Gy=Zm();Object.defineProperty(v,"SpeechConfig",{enumerable:!0,get:function(){return Gy.SpeechConfig}});Object.defineProperty(v,"SpeechConfigImpl",{enumerable:!0,get:function(){return Gy.SpeechConfigImpl}});var $y=eS();Object.defineProperty(v,"SpeechTranslationConfig",{enumerable:!0,get:function(){return $y.SpeechTranslationConfig}});Object.defineProperty(v,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return $y.SpeechTranslationConfigImpl}});var u_=Bd();Object.defineProperty(v,"PropertyCollection",{enumerable:!0,get:function(){return u_.PropertyCollection}});var d_=Oo();Object.defineProperty(v,"PropertyId",{enumerable:!0,get:function(){return d_.PropertyId}});var h_=iS();Object.defineProperty(v,"Recognizer",{enumerable:!0,get:function(){return h_.Recognizer}});var l_=nS();Object.defineProperty(v,"SpeechRecognizer",{enumerable:!0,get:function(){return l_.SpeechRecognizer}});var v_=sS();Object.defineProperty(v,"IntentRecognizer",{enumerable:!0,get:function(){return v_.IntentRecognizer}});var f_=oS();Object.defineProperty(v,"VoiceProfileType",{enumerable:!0,get:function(){return f_.VoiceProfileType}});var g_=uS();Object.defineProperty(v,"TranslationRecognizer",{enumerable:!0,get:function(){return g_.TranslationRecognizer}});var m_=dS();Object.defineProperty(v,"Translations",{enumerable:!0,get:function(){return m_.Translations}});var S_=hS();Object.defineProperty(v,"NoMatchReason",{enumerable:!0,get:function(){return S_.NoMatchReason}});var y_=lS();Object.defineProperty(v,"NoMatchDetails",{enumerable:!0,get:function(){return y_.NoMatchDetails}});var C_=vS();Object.defineProperty(v,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return C_.TranslationRecognitionCanceledEventArgs}});var P_=fS();Object.defineProperty(v,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return P_.IntentRecognitionCanceledEventArgs}});var R_=nh();Object.defineProperty(v,"CancellationDetailsBase",{enumerable:!0,get:function(){return R_.CancellationDetailsBase}});var E_=gS();Object.defineProperty(v,"CancellationDetails",{enumerable:!0,get:function(){return E_.CancellationDetails}});var w_=mS();Object.defineProperty(v,"CancellationErrorCode",{enumerable:!0,get:function(){return w_.CancellationErrorCode}});var I_=SS();Object.defineProperty(v,"ConnectionEventArgs",{enumerable:!0,get:function(){return I_.ConnectionEventArgs}});var T_=yS();Object.defineProperty(v,"ServiceEventArgs",{enumerable:!0,get:function(){return T_.ServiceEventArgs}});var __=Qd();Object.defineProperty(v,"Connection",{enumerable:!0,get:function(){return __.Connection}});var A_=CS();Object.defineProperty(v,"PhraseListGrammar",{enumerable:!0,get:function(){return A_.PhraseListGrammar}});var b_=Zo();Object.defineProperty(v,"DialogServiceConfig",{enumerable:!0,get:function(){return b_.DialogServiceConfig}});var O_=PS();Object.defineProperty(v,"BotFrameworkConfig",{enumerable:!0,get:function(){return O_.BotFrameworkConfig}});var M_=RS();Object.defineProperty(v,"CustomCommandsConfig",{enumerable:!0,get:function(){return M_.CustomCommandsConfig}});var D_=_S();Object.defineProperty(v,"DialogServiceConnector",{enumerable:!0,get:function(){return D_.DialogServiceConnector}});var k_=AS();Object.defineProperty(v,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return k_.ActivityReceivedEventArgs}});var N_=OS();Object.defineProperty(v,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return N_.TurnStatusReceivedEventArgs}});var x_=MS();Object.defineProperty(v,"ServicePropertyChannel",{enumerable:!0,get:function(){return x_.ServicePropertyChannel}});var q_=DS();Object.defineProperty(v,"ProfanityOption",{enumerable:!0,get:function(){return q_.ProfanityOption}});var z_=kS();Object.defineProperty(v,"BaseAudioPlayer",{enumerable:!0,get:function(){return z_.BaseAudioPlayer}});var j_=NS();Object.defineProperty(v,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return j_.ConnectionMessageEventArgs}});var L_=Kd();Object.defineProperty(v,"ConnectionMessage",{enumerable:!0,get:function(){return L_.ConnectionMessage}});var B_=xS();Object.defineProperty(v,"VoiceProfile",{enumerable:!0,get:function(){return B_.VoiceProfile}});var Qy=zS();Object.defineProperty(v,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return Qy.VoiceProfileEnrollmentResult}});Object.defineProperty(v,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return Qy.VoiceProfileEnrollmentCancellationDetails}});var Yy=LS();Object.defineProperty(v,"VoiceProfileResult",{enumerable:!0,get:function(){return Yy.VoiceProfileResult}});Object.defineProperty(v,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return Yy.VoiceProfileCancellationDetails}});var F_=BS();Object.defineProperty(v,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return F_.VoiceProfilePhraseResult}});var V_=FS();Object.defineProperty(v,"VoiceProfileClient",{enumerable:!0,get:function(){return V_.VoiceProfileClient}});var U_=VS();Object.defineProperty(v,"SpeakerRecognizer",{enumerable:!0,get:function(){return U_.SpeakerRecognizer}});var W_=US();Object.defineProperty(v,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return W_.SpeakerIdentificationModel}});var H_=HS();Object.defineProperty(v,"SpeakerVerificationModel",{enumerable:!0,get:function(){return H_.SpeakerVerificationModel}});var K_=JS();Object.defineProperty(v,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return K_.AutoDetectSourceLanguageConfig}});var J_=$S();Object.defineProperty(v,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return J_.AutoDetectSourceLanguageResult}});var G_=QS();Object.defineProperty(v,"SourceLanguageConfig",{enumerable:!0,get:function(){return G_.SourceLanguageConfig}});var zl=XS();Object.defineProperty(v,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResult}});Object.defineProperty(v,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return zl.SpeakerRecognitionResultType}});Object.defineProperty(v,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return zl.SpeakerRecognitionCancellationDetails}});var ze=qa();Object.defineProperty(v,"Conversation",{enumerable:!0,get:function(){return ze.Conversation}});Object.defineProperty(v,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return ze.ConversationExpirationEventArgs}});Object.defineProperty(v,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return ze.ConversationParticipantsChangedEventArgs}});Object.defineProperty(v,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationCanceledEventArgs}});Object.defineProperty(v,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationEventArgs}});Object.defineProperty(v,"ConversationTranslationResult",{enumerable:!0,get:function(){return ze.ConversationTranslationResult}});Object.defineProperty(v,"ConversationTranslator",{enumerable:!0,get:function(){return ze.ConversationTranslator}});Object.defineProperty(v,"ConversationTranscriber",{enumerable:!0,get:function(){return ze.ConversationTranscriber}});Object.defineProperty(v,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return ze.ConversationTranscriptionResult}});Object.defineProperty(v,"Meeting",{enumerable:!0,get:function(){return ze.Meeting}});Object.defineProperty(v,"MeetingTranscriber",{enumerable:!0,get:function(){return ze.MeetingTranscriber}});Object.defineProperty(v,"Participant",{enumerable:!0,get:function(){return ze.Participant}});Object.defineProperty(v,"ParticipantChangedReason",{enumerable:!0,get:function(){return ze.ParticipantChangedReason}});Object.defineProperty(v,"User",{enumerable:!0,get:function(){return ze.User}});var $_=Ua();Object.defineProperty(v,"Synthesizer",{enumerable:!0,get:function(){return $_.Synthesizer}});var Q_=Sd();Object.defineProperty(v,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return Q_.SpeechSynthesisOutputFormat}});var Y_=Ry();Object.defineProperty(v,"SpeechSynthesizer",{enumerable:!0,get:function(){return Y_.SpeechSynthesizer}});var X_=Ey();Object.defineProperty(v,"SynthesisResult",{enumerable:!0,get:function(){return X_.SynthesisResult}});var Z_=wy();Object.defineProperty(v,"SpeechSynthesisResult",{enumerable:!0,get:function(){return Z_.SpeechSynthesisResult}});var eA=Iy();Object.defineProperty(v,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return eA.SpeechSynthesisEventArgs}});var tA=Ty();Object.defineProperty(v,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return tA.SpeechSynthesisWordBoundaryEventArgs}});var rA=_y();Object.defineProperty(v,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return rA.SpeechSynthesisBookmarkEventArgs}});var iA=Ay();Object.defineProperty(v,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return iA.SpeechSynthesisVisemeEventArgs}});var nA=by();Object.defineProperty(v,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return nA.SpeechSynthesisBoundaryType}});var sA=Oy();Object.defineProperty(v,"SynthesisVoicesResult",{enumerable:!0,get:function(){return sA.SynthesisVoicesResult}});var oA=My();Object.defineProperty(v,"VoiceInfo",{enumerable:!0,get:function(){return oA.VoiceInfo}});var aA=ky();Object.defineProperty(v,"SpeakerAudioDestination",{enumerable:!0,get:function(){return aA.SpeakerAudioDestination}});var cA=Ny();Object.defineProperty(v,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return cA.ConversationTranscriptionCanceledEventArgs}});var pA=xy();Object.defineProperty(v,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return pA.MeetingTranscriptionCanceledEventArgs}});var uA=qy();Object.defineProperty(v,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return uA.PronunciationAssessmentGradingSystem}});var dA=zy();Object.defineProperty(v,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return dA.PronunciationAssessmentGranularity}});var hA=jy();Object.defineProperty(v,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return hA.PronunciationAssessmentConfig}});var lA=Ly();Object.defineProperty(v,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return lA.PronunciationAssessmentResult}});var vA=kh();Object.defineProperty(v,"LanguageIdMode",{enumerable:!0,get:function(){return vA.LanguageIdMode}});var fA=By();Object.defineProperty(v,"AvatarConfig",{enumerable:!0,get:function(){return fA.AvatarConfig}});var gA=Fy();Object.defineProperty(v,"AvatarEventArgs",{enumerable:!0,get:function(){return gA.AvatarEventArgs}});var mA=Uy();Object.defineProperty(v,"AvatarSynthesizer",{enumerable:!0,get:function(){return mA.AvatarSynthesizer}});var Xy=Wy();Object.defineProperty(v,"AvatarVideoFormat",{enumerable:!0,get:function(){return Xy.AvatarVideoFormat}});Object.defineProperty(v,"Coordinate",{enumerable:!0,get:function(){return Xy.Coordinate}});var SA=Hy();Object.defineProperty(v,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return SA.AvatarWebRTCConnectionResult}});var yA=Ky();Object.defineProperty(v,"Diagnostics",{enumerable:!0,get:function(){return yA.Diagnostics}});var CA=id();Object.defineProperty(v,"LogLevel",{enumerable:!0,get:function(){return CA.LogLevel}})});var Zy=p(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});lc.ProxyInfo=void 0;var hc=f(),jl=class i{constructor(e,t,r,n){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=n}static fromParameters(e){return new i(e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(hc.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(e){return this.fromParameters(e.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}};lc.ProxyInfo=jl});var tC=p((C1,eC)=>{"use strict";var PA=new Set(["json","buffer","string"]);eC.exports=i=>(...e)=>{let t=new Set,r,n,s,o="";return e.forEach(a=>{if(typeof a=="string")if(a.toUpperCase()===a)if(r){let c=`Can't set method to ${a}, already set to ${r}.`;throw new Error(c)}else r=a;else if(a.startsWith("http:")||a.startsWith("https:"))o=a;else if(PA.has(a))n=a;else throw new Error(`Unknown encoding, ${a}`);else if(typeof a=="number")t.add(a);else if(typeof a=="object")if(Array.isArray(a)||a instanceof Set)a.forEach(c=>t.add(c));else{if(s)throw new Error("Cannot set headers twice.");s=a}else throw new Error(`Unknown type: ${typeof a}`)}),r||(r="GET"),t.size===0&&t.add(200),i(t,r,n,s,o)}});var iC=p((P1,rC)=>{"use strict";var RA=tC(),Ll=class i extends Error{constructor(e,...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);let r;Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(let[s,o]of e.headers.entries())this.headers[s.toLowerCase()]=o}},EA=(i,e,t,r,n)=>async(s,o,a={})=>{s=n+(s||"");let c=new URL(s);if(r||(r={}),c.username&&(r.Authorization="Basic "+btoa(c.username+":"+c.password),c=new URL(c.protocol+"//"+c.host+c.pathname+c.search)),c.protocol!=="https:"&&c.protocol!=="http:")throw new Error(`Unknown protocol, ${c.protocol}`);if(o&&!(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="string"))if(typeof o=="object")o=JSON.stringify(o),r["Content-Type"]="application/json";else throw new Error("Unknown body type.");a=new Headers({...r||{},...a});let u=await fetch(c,{method:e,headers:a,body:o});if(u.statusCode=u.status,!i.has(u.status))throw new Ll(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};rC.exports=RA(EA)});var sC=p(Jt=>{"use strict";var wA=Jt&&Jt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.RestMessageAdapter=Jt.RestRequestType=void 0;var IA=wA(iC()),nC=P(),vc;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(vc=Jt.RestRequestType||(Jt.RestRequestType={}));var Bl=class{constructor(e){if(!e)throw new nC.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,t){let r="";try{let n=t.trim().split(/[\r\n]+/),s={};n.forEach(o=>{let a=o.split(": "),c=a.shift().toLowerCase(),u=a.join(": ");s[c]=u}),r=s[e.toLowerCase()]}catch{}return r}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,t){this.privHeaders[e]=t}request(e,t,r={},n=null){let s=new nC.Deferred,o=e===vc.File?"POST":e,a=(u,d={})=>{let h=u;return{data:JSON.stringify(d),headers:JSON.stringify(u.headers),json:d,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:d.error?d.error.message:h.statusText?h.statusText:h.statusMessage}},c=u=>{let d=IA.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),h=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;d(h,u).then(async l=>{if(e===vc.Delete||l.statusCode===204)s.resolve(a(l));else try{let g=await l.json();s.resolve(a(l,g))}catch{s.resolve(a(l))}}).catch(l=>{s.reject(l)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===vc.Post&&n&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),c(n),s.promise}queryParams(e={}){return Object.keys(e).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t])).join("&")}};Jt.RestMessageAdapter=Bl});var Fl=p(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.RestConfigBase=void 0;var Ni=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};fc.RestConfigBase=Ni;Ni.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Ni.privRestErrors={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."};Ni.privDefaultParams={apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",contentTypeKey:"Content-Type",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"}});var ae=p(fe=>{"use strict";var TA=fe&&fe.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),ht=fe&&fe.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&TA(e,i,t)};Object.defineProperty(fe,"__esModule",{value:!0});ht(fm(),fe);ht(mm(),fe);ht(Cm(),fe);ht(Rm(),fe);ht(Em(),fe);ht(Om(),fe);ht(pd(),fe);ht(Mm(),fe);ht(Zy(),fe);ht(sC(),fe);ht(Fl(),fe)});var cC=p(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.IntentConnectionFactory=void 0;var oC=ae(),Yn=f(),aC=$e(),_A=C(),AA=we(),Vl=class extends aC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_IntentRegion),u=aC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(Yn.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[AA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Yn.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new oC.WebsocketConnection(n,s,o,new _A.WebsocketMessageFormatter,oC.ProxyInfo.fromRecognizerConfig(e),a,r)}getSpeechRegionFromIntentRegion(e){switch(e){case"West US":case"US West":case"westus":return"uswest";case"West US 2":case"US West 2":case"westus2":return"uswest2";case"South Central US":case"US South Central":case"southcentralus":return"ussouthcentral";case"West Central US":case"US West Central":case"westcentralus":return"uswestcentral";case"East US":case"US East":case"eastus":return"useast";case"East US 2":case"US East 2":case"eastus2":return"useast2";case"West Europe":case"Europe West":case"westeurope":return"europewest";case"North Europe":case"Europe North":case"northeurope":return"europenorth";case"Brazil South":case"South Brazil":case"southbrazil":return"brazilsouth";case"Australia East":case"East Australia":case"eastaustralia":return"australiaeast";case"Southeast Asia":case"Asia Southeast":case"southeastasia":return"asiasoutheast";case"East Asia":case"Asia East":case"eastasia":return"asiaeast";default:return e}}};gc.IntentConnectionFactory=Vl});var hC=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.VoiceProfileConnectionFactory=xi.SpeakerRecognitionConnectionFactory=void 0;var pC=ae(),$r=f(),uC=$e(),bA=C(),dC=we(),mc=class extends uC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Region),d=uC.ConnectionFactoryBase.getHostSuffix(u),h=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${d}`),l=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${h}/speaker/ws/${this.scenarioToPath(l)}/${r}`}let o={format:"simple",language:e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[dC.HeaderNames.ConnectionId]=n,a[dC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty($r.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty($r.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new pC.WebsocketConnection(s,o,a,new bA.WebsocketMessageFormatter,pC.ProxyInfo.fromRecognizerConfig(e),c,n)}scenarioToPath(e){switch(e){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}},Ul=class extends mc{create(e,t,r){return super.create(e,t,"recognition",r)}};xi.SpeakerRecognitionConnectionFactory=Ul;var Wl=class extends mc{create(e,t,r){return super.create(e,t,"profile",r)}};xi.VoiceProfileConnectionFactory=Wl});var yc=p(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.RecognitionEndedEvent=ge.RecognitionCompletionStatus=ge.RecognitionStartedEvent=ge.ConnectingToServiceEvent=ge.ListeningStartedEvent=ge.RecognitionTriggeredEvent=ge.SpeechRecognitionEvent=void 0;var Sc=P(),vr=class extends Sc.PlatformEvent{constructor(e,t,r,n=Sc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};ge.SpeechRecognitionEvent=vr;var Hl=class extends vr{constructor(e,t,r,n){super("RecognitionTriggeredEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};ge.RecognitionTriggeredEvent=Hl;var Kl=class extends vr{constructor(e,t,r,n){super("ListeningStartedEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};ge.ListeningStartedEvent=Kl;var Jl=class extends vr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};ge.ConnectingToServiceEvent=Jl;var Gl=class extends vr{constructor(e,t,r,n,s){super("RecognitionStartedEvent",e,s),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}};ge.RecognitionStartedEvent=Gl;var lC;(function(i){i[i.Success=0]="Success",i[i.AudioSourceError=1]="AudioSourceError",i[i.AudioSourceTimeout=2]="AudioSourceTimeout",i[i.AuthTokenFetchError=3]="AuthTokenFetchError",i[i.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",i[i.UnAuthorized=5]="UnAuthorized",i[i.ConnectTimeout=6]="ConnectTimeout",i[i.ConnectError=7]="ConnectError",i[i.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",i[i.UnknownError=9]="UnknownError"})(lC=ge.RecognitionCompletionStatus||(ge.RecognitionCompletionStatus={}));var $l=class extends vr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===lC.Success?Sc.EventType.Info:Sc.EventType.Error),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n,this.privStatus=a,this.privError=c,this.privServiceTag=o}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}get serviceTag(){return this.privServiceTag}get status(){return this.privStatus}get error(){return this.privError}};ge.RecognitionEndedEvent=$l});var Qr=p(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.SpeechConnectionMessage=void 0;var Ql=P(),Gt=we(),Yl=class i extends Ql.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new Ql.ArgumentNullError("path");if(!r)throw new Ql.ArgumentNullError("requestId");let u={};if(u[Gt.HeaderNames.Path]=t,u[Gt.HeaderNames.RequestId]=r,u[Gt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Gt.HeaderNames.ContentType]=n),o&&(u[Gt.HeaderNames.RequestStreamId]=o),a)for(let d in a)d&&(u[d]=a[d]);c?super(e,s,u,c):super(e,s,u),this.privPath=t,this.privRequestId=r,this.privContentType=n,this.privStreamId=o,this.privAdditionalHeaders=a}get path(){return this.privPath}get requestId(){return this.privRequestId}get contentType(){return this.privContentType}get streamId(){return this.privStreamId}get additionalHeaders(){return this.privAdditionalHeaders}static fromConnectionMessage(e){let t=null,r=null,n=null,s=null,o={};if(e.headers)for(let a in e.headers)a&&(a.toLowerCase()===Gt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Gt.HeaderNames.RequestStreamId.toLowerCase()?s=e.headers[a]:o[a]=e.headers[a]);return new i(e.messageType,t,r,n,e.body,s,o,e.id)}};Cc.SpeechConnectionMessage=Yl});var vC=p(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ServiceRecognizerBase=void 0;var OA=ae(),Z=P(),B=f(),It=C(),fr=Qr(),Pc=class i{constructor(e,t,r,n,s){if(this.privConnectionConfigurationPromise=void 0,this.privConnectionPromise=void 0,this.privSetTimeout=setTimeout,this.privIsLiveAudio=!1,this.privAverageBytesPerMs=0,this.privEnableSpeakerId=!1,this.privExpectContentAssessmentResponse=!1,this.recognizeOverride=void 0,this.recognizeSpeaker=void 0,this.disconnectOverride=void 0,this.receiveMessageOverride=void 0,this.sendPrePayloadJSONOverride=void 0,this.postConnectImplOverride=void 0,this.configConnectionOverride=void 0,this.handleSpeechPhraseMessage=void 0,this.handleSpeechHypothesisMessage=void 0,!e)throw new Z.ArgumentNullError("authentication");if(!t)throw new Z.ArgumentNullError("connectionFactory");if(!r)throw new Z.ArgumentNullError("audioSource");if(!n)throw new Z.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=n.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=n,this.privIsDisposed=!1,this.privRecognizer=s,this.privRequestSession=new It.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new Z.EventSource,this.privServiceEvents=new Z.EventSource,this.privDynamicGrammar=new It.DynamicGrammarBuilder,this.privSpeechContext=new It.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new It.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=Z.Timeout.setTimeout:typeof window<"u"&&(this.privSetTimeout=window.setTimeout.bind(window)),this.connectionEvents.attach(a=>{if(a.name==="ConnectionClosedEvent"){let c=a;(c.statusCode===1003||c.statusCode===1007||c.statusCode===1002||c.statusCode===4e3||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(B.CancellationReason.Error,c.statusCode===1007?B.CancellationErrorCode.BadRequestParameters:B.CancellationErrorCode.ConnectionFailure,`${c.reason} websocket error code: ${c.statusCode}`)}}),this.privEnableSpeakerId&&(this.privDiarizationSessionId=Z.createNoDashGuid()),this.setLanguageIdJson(),this.setOutputDetailLevelJson()}setTranslationJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(e!==void 0){let t=e.split(","),r=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),n=r!==void 0?"Synthesize":"None";if(this.privSpeechContext.setSection("translation",{onSuccess:{action:n},output:{interimResults:{mode:"Always"}},targetLanguages:t}),r!==void 0){let s={};for(let o of t)s[o]=r;this.privSpeechContext.setSection("synthesis",{defaultVoices:s})}}}setSpeechSegmentationTimeoutJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0);if(e!==void 0){let t=this.recognitionMode===It.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===It.RecognitionMode.Dictation?"DICTATION":"INTERACTIVE",r=parseInt(e,10),n=this.privSpeechContext.getSection("phraseDetection");n.mode=t,n[t]={segmentation:{mode:"Custom",segmentationSilenceTimeoutMs:r}},this.privSpeechContext.setSection("phraseDetection",n)}}setLanguageIdJson(){let e=this.privSpeechContext.getSection("phraseDetection");if(this.privRecognizerConfig.autoDetectSourceLanguages!==void 0){let r=this.privRecognizerConfig.autoDetectSourceLanguages.split(","),n;this.privRecognizerConfig.languageIdMode==="Continuous"?n="DetectContinuous":n="DetectAtAudioStart",this.privSpeechContext.setSection("languageId",{Priority:"PrioritizeLatency",languages:r,mode:n,onSuccess:{action:"Recognize"},onUnknown:{action:"None"}}),this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"Auto"},phraseResults:{resultType:"Always"}});let s=this.privRecognizerConfig.sourceLanguageModels;s!==void 0&&(e.customModels=s,e.onInterim={action:"None"},e.onSuccess={action:"None"})}this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0&&(e.onInterim={action:"Translate"},e.onSuccess={action:"Translate"},this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"None"},phraseResults:{resultType:"None"}})),this.privSpeechContext.setSection("phraseDetection",e)}setOutputDetailLevelJson(){this.privEnableSpeakerId&&(this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true"?this.privSpeechContext.setWordLevelTimings():this.privRecognizerConfig.parameters.getProperty(It.OutputFormatPropertyName,B.OutputFormat[B.OutputFormat.Simple]).toLowerCase()===B.OutputFormat[B.OutputFormat.Detailed].toLocaleLowerCase()&&this.privSpeechContext.setDetailedOutputFormat())}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}get audioSource(){return this.privAudioSource}get speechContext(){return this.privSpeechContext}get dynamicGrammar(){return this.privDynamicGrammar}get agentConfig(){return this.privAgentConfig}set conversationTranslatorToken(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.SpeechServiceConnection_SpeakerIdMode,e)}set authentication(e){this.privAuthentication=e}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,this.privConnectionConfigurationPromise!==void 0)try{await(await this.privConnectionConfigurationPromise).dispose(e)}catch{return}}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}get recognitionMode(){return this.privRecognizerConfig.recognitionMode}async recognize(e,t,r){if(this.recognizeOverride!==void 0){await this.recognizeOverride(e,t,r);return}this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,this.setSpeechSegmentationTimeoutJson(),this.setTranslationJson(),this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);let n=this.connectImpl(),s;try{let c=await this.audioSource.attach(this.privRequestSession.audioNodeId),u=await this.audioSource.format,d=await this.audioSource.deviceInfo;this.privIsLiveAudio=d.type&&d.type===It.type.Microphones,s=new OA.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:d}}catch(c){throw await this.privRequestSession.onStopRecognizing(),c}try{await n}catch(c){await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.ConnectionFailure,c);return}let o=new B.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,o),this.receiveMessage(),this.sendAudio(s).catch(async c=>{await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.RuntimeError,c)})}async stopRecognizing(){if(this.privRequestSession.isRecognizing)try{await this.audioSource.turnOff(),await this.sendFinalAudio(),await this.privRequestSession.onStopRecognizing(),await this.privRequestSession.turnCompletionPromise}finally{await this.privRequestSession.dispose()}}async connect(){return await this.connectImpl(),Promise.resolve()}connectAsync(e,t){this.connectImpl().then(()=>{try{e&&e()}catch(r){t&&t(r)}},r=>{try{t&&t(r)}catch{}})}async disconnect(){if(await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.NoError,"Disconnecting"),this.disconnectOverride!==void 0&&await this.disconnectOverride(),this.privConnectionPromise!==void 0)try{await(await this.privConnectionPromise).dispose()}catch{}this.privConnectionPromise=void 0}sendMessage(e){}async sendNetworkMessage(e,t){let r=typeof t=="string"?Z.MessageType.Text:Z.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new fr.SpeechConnectionMessage(r,e,this.privRequestSession.requestId,n,t))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){let e=this.privRequestSession.getTelemetry();if(i.telemetryDataEnabled!==!0||this.privIsDisposed||e===null)return;if(i.telemetryData)try{i.telemetryData(e)}catch{}await(await this.fetchConnection()).send(new fr.SpeechConnectionMessage(Z.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,t,r){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection(),t=await e.read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(!t)return this.receiveMessage();this.privServiceHasSentMessage=!0;let r=fr.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":let n=It.SpeechDetected.fromJSON(r.textBody),s=new B.RecognitionEventArgs(n.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,s);break;case"speech.enddetected":let o;r.textBody.length>0?o=r.textBody:o="{ Offset: 0 }";let a=It.SpeechDetected.fromJSON(o),c=new B.RecognitionEventArgs(a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,c);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(B.CancellationReason.EndOfStream,B.CancellationErrorCode.NoError,void 0));let u=new B.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition),!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing){this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,u);return}else e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new Z.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{return null}}updateSpeakerDiarizationAudioOffset(){let t=this.privRequestSession.recognitionBytesSent/this.privAverageBytesPerMs;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(t)}sendSpeechContext(e,t){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();let r=this.speechContext.toJSON();if(t&&this.privRequestSession.onSpeechContext(),r)return e.send(new fr.SpeechConnectionMessage(Z.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",r))}noOp(){}async sendPrePayloadJSON(e,t=!0){if(this.sendPrePayloadJSONOverride!==void 0)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,t),await this.sendWaveHeader(e)}async sendWaveHeader(e){let t=await this.audioSource.format;return e.send(new fr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===Z.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl())):(this.privConnectionPromise=this.retryableConnect(),this.privConnectionPromise.catch(()=>{}),this.postConnectImplOverride!==void 0?this.postConnectImplOverride(this.privConnectionPromise):this.privConnectionPromise)}sendSpeechServiceConfig(e,t,r){if(t.onSpeechContext(),i.telemetryDataEnabled!==!0){let s={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(s)}if(this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()==="true"){let n=JSON.parse(r);n.context.DisableReferenceChannel="True",n.context.MicSpec="1_0_0",r=JSON.stringify(n)}if(r)return e.send(new fr.SpeechConnectionMessage(Z.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Z.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){let t=await this.audioSource.format;this.privAverageBytesPerMs=t.avgBytesPerSec/1e3;let r=Date.now(),n=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(n,10),o=this.privRequestSession.recogNumber,a=async()=>{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){let c=await this.fetchConnection(),u=await e.read();if(this.privRequestSession.isSpeechEnded)return;let d,h;if(!u||u.isEnd?(d=null,h=0):(d=u.buffer,this.privRequestSession.onAudioSent(d.byteLength),s>=this.privRequestSession.bytesSent?h=0:h=Math.max(0,r-Date.now())),h!==0&&await this.delay(h),d!==null&&(r=Date.now()+d.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new fr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,null,d)).catch(()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(()=>{})}),u?.isEnd)this.privIsLiveAudio||this.privRequestSession.onSpeechEnded();else return a()}};return a()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=Z.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:Z.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let r=0,n="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){let o=await(e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId));await this.privRequestSession.onAuthCompleted(!1);let a=this.privConnectionFactory.create(this.privRecognizerConfig,o,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(a.events),a.events.attach(u=>{this.connectionEvents.onEvent(u)});let c=await a.open();if(c.statusCode===200)return await this.privRequestSession.onConnectionEstablishCompleted(c.statusCode),Promise.resolve(a);c.statusCode===1006&&(e=!0),r=c.statusCode,n=c.reason,this.privRequestSession.onRetryConnection()}return await this.privRequestSession.onConnectionEstablishCompleted(r,n),Promise.reject(`Unable to contact server. StatusCode: ${r}, ${this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${n}`)}delay(e){return new Promise(t=>this.privSetTimeout(t,e))}writeBufferToConsole(e){let t="Buffer Size: ";if(e===null)t+="null";else{let r=new Uint8Array(e);t+=`${e.byteLength}\r
|
|
19
|
-
`;for(let n=0;n<e.byteLength;n++)t+=r[n].toString(16).padStart(2,"0")+" ",(n+1)%16===0&&(console.info(t),t="")}console.info(t)}async sendFinalAudio(){await(await this.fetchConnection()).send(new
|
|
20
|
-
`,
|
|
17
|
+
registerProcessor('speech-processor', SP);`,l=new Blob([u],{type:"application/javascript; charset=utf-8"});this.privSpeechProcessorScript=URL.createObjectURL(l)}e.audioWorklet.addModule(this.privSpeechProcessorScript).then(()=>{let u=new AudioWorkletNode(e,"speech-processor");u.port.onmessage=l=>{let h=l.data;if(r&&!r.isClosed){let d=s.encode(h);d&&r.writeStreamChunk({buffer:d,isEnd:!1,timeReceived:Date.now()})}},o.connect(u),u.connect(e.destination),this.privMediaResources={scriptProcessorNode:u,source:o,stream:t}}).catch(()=>{a()})}else try{a()}catch(u){throw new Error(`Unable to start audio worklet node for PCMRecorder: ${u}`)}}releaseMediaResources(e){this.privMediaResources&&(this.privMediaResources.scriptProcessorNode&&(this.privMediaResources.scriptProcessorNode.disconnect(e.destination),this.privMediaResources.scriptProcessorNode=null),this.privMediaResources.source&&(this.privMediaResources.source.disconnect(),this.privStopInputOnRelease&&this.privMediaResources.stream.getTracks().forEach(t=>t.stop()),this.privMediaResources.source=null))}setWorkletUrl(e){this.privSpeechProcessorScript=e}};oo.PcmRecorder=Sl});var Gm=p(()=>{});var $m=p(()=>{});var Qm=p(()=>{});var Xm=p(()=>{});var Zm=p(()=>{});var Pl=p($e=>{"use strict";var sI=$e&&$e.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),oI=$e&&$e.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),Ym=$e&&$e.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&sI(e,i,t);return oI(e,i),e},Cl=$e&&$e.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty($e,"__esModule",{value:!0});$e.WebsocketMessageAdapter=void 0;var aI=Ym(Gm()),cI=Ym($m()),uI=Cl(Qm()),pI=Cl(Xm()),lI=Cl(Zm()),hI=Ie(),w=P(),ao=class i{constructor(e,t,r,n,s,o){if(!e)throw new w.ArgumentNullError("uri");if(!r)throw new w.ArgumentNullError("messageFormatter");this.proxyInfo=n,this.privConnectionEvents=new w.EventSource,this.privConnectionId=t,this.privMessageFormatter=r,this.privConnectionState=w.ConnectionState.None,this.privUri=e,this.privHeaders=s,this.privEnableCompression=o,this.privHeaders[hI.HeaderNames.ConnectionId]=this.privConnectionId,this.privLastErrorReceived=""}get state(){return this.privConnectionState}open(){if(this.privConnectionState===w.ConnectionState.Disconnected)return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`);if(this.privConnectionEstablishDeferral)return this.privConnectionEstablishDeferral.promise;this.privConnectionEstablishDeferral=new w.Deferred,this.privCertificateValidatedDeferral=new w.Deferred,this.privConnectionState=w.ConnectionState.Connecting;try{if(typeof WebSocket<"u"&&!i.forceNpmWebSocket)this.privCertificateValidatedDeferral.resolve(),this.privWebsocketClient=new WebSocket(this.privUri);else{let e={headers:this.privHeaders,perMessageDeflate:this.privEnableCompression};this.privCertificateValidatedDeferral.resolve(),e.agent=this.getAgent();let r=new URL(this.privUri).protocol;r?.toLocaleLowerCase()==="wss:"?r="https:":r?.toLocaleLowerCase()==="ws:"&&(r="http:"),e.agent.protocol=r,this.privWebsocketClient=new lI.default(this.privUri,e)}this.privWebsocketClient.binaryType="arraybuffer",this.privReceivingMessageQueue=new w.Queue,this.privDisconnectDeferral=new w.Deferred,this.privSendMessageQueue=new w.Queue,this.processSendQueue().catch(e=>{w.Events.instance.onEvent(new w.BackgroundEvent(e))})}catch(e){return this.privConnectionEstablishDeferral.resolve(new w.ConnectionOpenResponse(500,e)),this.privConnectionEstablishDeferral.promise}return this.onEvent(new w.ConnectionStartEvent(this.privConnectionId,this.privUri)),this.privWebsocketClient.onopen=()=>{this.privCertificateValidatedDeferral.promise.then(()=>{this.privConnectionState=w.ConnectionState.Connected,this.onEvent(new w.ConnectionEstablishedEvent(this.privConnectionId)),this.privConnectionEstablishDeferral.resolve(new w.ConnectionOpenResponse(200,""))},e=>{this.privConnectionEstablishDeferral.reject(e)})},this.privWebsocketClient.onerror=e=>{this.onEvent(new w.ConnectionErrorEvent(this.privConnectionId,e.message,e.type)),this.privLastErrorReceived=e.message},this.privWebsocketClient.onclose=e=>{this.privConnectionState===w.ConnectionState.Connecting?(this.privConnectionState=w.ConnectionState.Disconnected,this.privConnectionEstablishDeferral.resolve(new w.ConnectionOpenResponse(e.code,e.reason+" "+this.privLastErrorReceived))):(this.privConnectionState=w.ConnectionState.Disconnected,this.privWebsocketClient=null,this.onEvent(new w.ConnectionClosedEvent(this.privConnectionId,e.code,e.reason))),this.onClose(e.code,e.reason).catch(t=>{w.Events.instance.onEvent(new w.BackgroundEvent(t))})},this.privWebsocketClient.onmessage=e=>{let t=new Date().toISOString();if(this.privConnectionState===w.ConnectionState.Connected){let r=new w.Deferred;if(this.privReceivingMessageQueue.enqueueFromPromise(r.promise),e.data instanceof ArrayBuffer){let n=new w.RawWebsocketMessage(w.MessageType.Binary,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new w.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid binary message format. Error: ${s}`)})}else{let n=new w.RawWebsocketMessage(w.MessageType.Text,e.data);this.privMessageFormatter.toConnectionMessage(n).then(s=>{this.onEvent(new w.ConnectionMessageReceivedEvent(this.privConnectionId,t,s)),r.resolve(s)},s=>{r.reject(`Invalid text message format. Error: ${s}`)})}}},this.privConnectionEstablishDeferral.promise}send(e){if(this.privConnectionState!==w.ConnectionState.Connected)return Promise.reject(`Cannot send on connection that is in ${w.ConnectionState[this.privConnectionState]} state`);let t=new w.Deferred,r=new w.Deferred;return this.privSendMessageQueue.enqueueFromPromise(r.promise),this.privMessageFormatter.fromConnectionMessage(e).then(n=>{r.resolve({Message:e,RawWebsocketMessage:n,sendStatusDeferral:t})},n=>{r.reject(`Error formatting the message. ${n}`)}),t.promise}read(){return this.privConnectionState!==w.ConnectionState.Connected?Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`):this.privReceivingMessageQueue.dequeue()}close(e){if(this.privWebsocketClient)this.privConnectionState!==w.ConnectionState.Disconnected&&this.privWebsocketClient.close(1e3,e||"Normal closure by client");else return Promise.resolve();return this.privDisconnectDeferral.promise}get events(){return this.privConnectionEvents}sendRawMessage(e){try{if(!e)return Promise.resolve();if(this.onEvent(new w.ConnectionMessageSentEvent(this.privConnectionId,new Date().toISOString(),e.Message)),this.isWebsocketOpen)this.privWebsocketClient.send(e.RawWebsocketMessage.payload);else return Promise.reject("websocket send error: Websocket not ready "+this.privConnectionId+" "+e.Message.id+" "+new Error().stack);return Promise.resolve()}catch(t){return Promise.reject(`websocket send error: ${t}`)}}async onClose(e,t){let r=`Connection closed. ${e}: ${t}`;this.privConnectionState=w.ConnectionState.Disconnected,this.privDisconnectDeferral.resolve(),await this.privReceivingMessageQueue.drainAndDispose(()=>{},r),await this.privSendMessageQueue.drainAndDispose(n=>{n.sendStatusDeferral.reject(r)},r)}async processSendQueue(){for(;;){let t=await this.privSendMessageQueue.dequeue();if(!t)return;try{await this.sendRawMessage(t),t.sendStatusDeferral.resolve()}catch(r){t.sendStatusDeferral.reject(r)}}}onEvent(e){this.privConnectionEvents.onEvent(e),w.Events.instance.onEvent(e)}getAgent(){let e=new uI.default.Agent(this.createConnection);return this.proxyInfo!==void 0&&this.proxyInfo.HostName!==void 0&&this.proxyInfo.Port>0&&(e.proxyInfo=this.proxyInfo),e}static GetProxyAgent(e){let t={host:e.HostName,port:e.Port};return e.UserName?t.headers={"Proxy-Authentication":"Basic "+new Buffer(`${e.UserName}:${e.Password===void 0?"":e.Password}`).toString("base64")}:t.headers={},t.headers.requestOCSP="true",new pI.default(t)}createConnection(e,t){let r;if(t={...t,requestOCSP:!0,servername:t.host},this.proxyInfo){let s=i.GetProxyAgent(this.proxyInfo);r=new Promise((o,a)=>{s.callback(e,t,(c,u)=>{c?a(c):o(u)})})}else t.secureEndpoint?r=Promise.resolve(cI.connect(t)):r=Promise.resolve(aI.connect(t));return r}get isWebsocketOpen(){return this.privWebsocketClient&&this.privWebsocketClient.readyState===this.privWebsocketClient.OPEN}};$e.WebsocketMessageAdapter=ao;ao.forceNpmWebSocket=!1});var ey=p(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.WebsocketConnection=void 0;var Rl=P(),dI=Pl(),El=class{constructor(e,t,r,n,s,o=!1,a){if(this.privIsDisposed=!1,!e)throw new Rl.ArgumentNullError("uri");if(!n)throw new Rl.ArgumentNullError("messageFormatter");this.privMessageFormatter=n;let c="",u=0;if(t){for(let l in t)if(l){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(l);c+=h;let d=t[l];d&&(d=encodeURIComponent(d),c+=`=${d}`),u++}}if(r){for(let l in r)if(l){c+=u===0&&e.indexOf("?")===-1?"?":"&";let h=encodeURIComponent(r[l]);c+=`${l}=${h}`,u++}}this.privUri=e+c,this.privId=a||Rl.createNoDashGuid(),this.privConnectionMessageAdapter=new dI.WebsocketMessageAdapter(this.privUri,this.id,this.privMessageFormatter,s,r,o)}async dispose(){this.privIsDisposed=!0,this.privConnectionMessageAdapter&&await this.privConnectionMessageAdapter.close()}isDisposed(){return this.privIsDisposed}get id(){return this.privId}get uri(){return this.privUri}state(){return this.privConnectionMessageAdapter.state}open(){return this.privConnectionMessageAdapter.open()}send(e){return this.privConnectionMessageAdapter.send(e)}read(){return this.privConnectionMessageAdapter.read()}get events(){return this.privConnectionMessageAdapter.events}};co.WebsocketConnection=El});var ty=p(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.ReplayableAudioNode=void 0;var _l=class{constructor(e,t){this.privBuffers=[],this.privReplayOffset=0,this.privLastShrinkOffset=0,this.privBufferStartOffset=0,this.privBufferSerial=0,this.privBufferedBytes=0,this.privReplay=!1,this.privLastChunkAcquiredTime=0,this.privAudioNode=e,this.privBytesPerSecond=t}id(){return this.privAudioNode.id()}read(){if(this.privReplay&&this.privBuffers.length!==0){let e=this.privReplayOffset-this.privBufferStartOffset,t=Math.round(e*this.privBytesPerSecond*1e-7);t%2!==0&&t++;let r=0;for(;r<this.privBuffers.length&&t>=this.privBuffers[r].chunk.buffer.byteLength;)t-=this.privBuffers[r++].chunk.buffer.byteLength;if(r<this.privBuffers.length){let n=this.privBuffers[r].chunk.buffer.slice(t);return this.privReplayOffset+=n.byteLength/this.privBytesPerSecond*1e7,r===this.privBuffers.length-1&&(this.privReplay=!1),Promise.resolve({buffer:n,isEnd:!1,timeReceived:this.privBuffers[r].chunk.timeReceived})}}return this.privAudioNode.read().then(e=>(e&&e.buffer&&(this.privBuffers.push(new Il(e,this.privBufferSerial++,this.privBufferedBytes)),this.privBufferedBytes+=e.buffer.byteLength),e))}detach(){return this.privBuffers=void 0,this.privAudioNode.detach()}replay(){this.privBuffers&&this.privBuffers.length!==0&&(this.privReplay=!0,this.privReplayOffset=this.privLastShrinkOffset)}shrinkBuffers(e){if(this.privBuffers===void 0||this.privBuffers.length===0)return;this.privLastShrinkOffset=e;let t=e-this.privBufferStartOffset,r=Math.round(t*this.privBytesPerSecond*1e-7),n=0;for(;n<this.privBuffers.length&&r>=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)}findTimeAtOffset(e){if(e<this.privBufferStartOffset||this.privBuffers===void 0)return 0;for(let t of this.privBuffers){let r=t.byteOffset/this.privBytesPerSecond*1e7,n=r+t.chunk.buffer.byteLength/this.privBytesPerSecond*1e7;if(e>=r&&e<=n)return t.chunk.timeReceived}return 0}};uo.ReplayableAudioNode=_l;var Il=class{constructor(e,t,r){this.chunk=e,this.serial=t,this.byteOffset=r}}});var Al=p(It=>{"use strict";var vI=It&&It.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),fI=It&&It.__setModuleDefault||(Object.create?function(i,e){Object.defineProperty(i,"default",{enumerable:!0,value:e})}:function(i,e){i.default=e}),gI=It&&It.__importStar||function(i){if(i&&i.__esModule)return i;var e={};if(i!=null)for(var t in i)t!=="default"&&Object.hasOwnProperty.call(i,t)&&vI(e,i,t);return fI(e,i),e};Object.defineProperty(It,"__esModule",{value:!0});It.AudioFileWriter=void 0;var Rn=gI(vl()),wl=_(),bl=class{constructor(e){wl.Contracts.throwIfNullOrUndefined(Rn.openSync,`
|
|
18
|
+
File System access not available, please use Push or PullAudioOutputStream`),this.privFd=Rn.openSync(e,"w")}set format(e){wl.Contracts.throwIfNotUndefined(this.privAudioFormat,"format is already set"),this.privAudioFormat=e;let t=0;this.privAudioFormat.hasHeader&&(t=this.privAudioFormat.header.byteLength),this.privFd!==void 0&&(this.privWriteStream=Rn.createWriteStream("",{fd:this.privFd,start:t,autoClose:!1}))}write(e){wl.Contracts.throwIfNullOrUndefined(this.privAudioFormat,"must set format before writing."),this.privWriteStream!==void 0&&this.privWriteStream.write(new Uint8Array(e.slice(0)))}close(){this.privFd!==void 0&&(this.privWriteStream.on("finish",()=>{this.privAudioFormat.hasHeader&&(this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten),Rn.writeSync(this.privFd,new Int8Array(this.privAudioFormat.header),0,this.privAudioFormat.header.byteLength,0)),Rn.closeSync(this.privFd),this.privFd=void 0}),this.privWriteStream.end())}id(){return this.privId}};It.AudioFileWriter=bl});var Tl=p(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.PullAudioInputStreamImpl=Qe.PullAudioInputStream=Qe.PushAudioInputStreamImpl=Qe.PushAudioInputStream=Qe.AudioInputStream=void 0;var po=C(),ve=P(),ry=ar(),mI=f(),yI=pr(),En=class{constructor(){}static createPushStream(e){return _n.create(e)}static createPullStream(e,t){return In.create(e,t)}};Qe.AudioInputStream=En;var _n=class extends En{static create(e){return new lo(e)}};Qe.PushAudioInputStream=_n;var lo=class extends _n{constructor(e){super(),e===void 0?this.privFormat=yI.AudioStreamFormatImpl.getDefaultInputFormat():this.privFormat=e,this.privEvents=new ve.EventSource,this.privId=ry.createNoDashGuid(),this.privStream=new ve.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec/10)}get format(){return Promise.resolve(this.privFormat)}write(e){this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}id(){return this.privId}turnOn(){this.onEvent(new ve.AudioSourceInitializingEvent(this.privId)),this.onEvent(new ve.AudioSourceReadyEvent(this.privId))}async attach(e){this.onEvent(new ve.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn();let t=this.privStream;return this.onEvent(new ve.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:async()=>(this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>t.read()}}detach(e){this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:po.connectivity.Unknown,manufacturer:"Speech SDK",model:"PushStream",samplerate:this.privFormat.samplesPerSec,type:po.type.Stream})}onEvent(e){this.privEvents.onEvent(e),ve.Events.instance.onEvent(e)}toBuffer(e){let t=Buffer.alloc(e.byteLength),r=new Uint8Array(e);for(let n=0;n<t.length;++n)t[n]=r[n];return t}};Qe.PushAudioInputStreamImpl=lo;var In=class extends En{constructor(){super()}static create(e,t){return new ho(e,t)}};Qe.PullAudioInputStream=In;var ho=class extends In{constructor(e,t){super(),t===void 0?this.privFormat=mI.AudioStreamFormat.getDefaultInputFormat():this.privFormat=t,this.privEvents=new ve.EventSource,this.privId=ry.createNoDashGuid(),this.privCallback=e,this.privIsClosed=!1,this.privBufferSize=this.privFormat.avgBytesPerSec/10}get format(){return Promise.resolve(this.privFormat)}close(){this.privIsClosed=!0,this.privCallback.close()}id(){return this.privId}turnOn(){this.onEvent(new ve.AudioSourceInitializingEvent(this.privId)),this.onEvent(new ve.AudioSourceReadyEvent(this.privId))}async attach(e){return this.onEvent(new ve.AudioStreamNodeAttachingEvent(this.privId,e)),await this.turnOn(),this.onEvent(new ve.AudioStreamNodeAttachedEvent(this.privId,e)),{detach:()=>(this.privCallback.close(),this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e)),this.turnOff()),id:()=>e,read:()=>{let t=0,r;for(;t<this.privBufferSize;){let n=new ArrayBuffer(this.privBufferSize-t),s=this.privCallback.read(n);if(r===void 0?r=n:new Int8Array(r).set(new Int8Array(n),t),s===0)break;t+=s}return Promise.resolve({buffer:r.slice(0,t),isEnd:this.privIsClosed||t===0,timeReceived:Date.now()})}}}detach(e){this.onEvent(new ve.AudioStreamNodeDetachedEvent(this.privId,e))}turnOff(){}get events(){return this.privEvents}get deviceInfo(){return Promise.resolve({bitspersample:this.privFormat.bitsPerSample,channelcount:this.privFormat.channels,connectivity:po.connectivity.Unknown,manufacturer:"Speech SDK",model:"PullStream",samplerate:this.privFormat.samplesPerSec,type:po.type.Stream})}onEvent(e){this.privEvents.onEvent(e),ve.Events.instance.onEvent(e)}};Qe.PullAudioInputStreamImpl=ho});var Ol=p(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.SpeechSynthesisOutputFormat=void 0;var SI;(function(i){i[i.Raw8Khz8BitMonoMULaw=0]="Raw8Khz8BitMonoMULaw",i[i.Riff16Khz16KbpsMonoSiren=1]="Riff16Khz16KbpsMonoSiren",i[i.Audio16Khz16KbpsMonoSiren=2]="Audio16Khz16KbpsMonoSiren",i[i.Audio16Khz32KBitRateMonoMp3=3]="Audio16Khz32KBitRateMonoMp3",i[i.Audio16Khz128KBitRateMonoMp3=4]="Audio16Khz128KBitRateMonoMp3",i[i.Audio16Khz64KBitRateMonoMp3=5]="Audio16Khz64KBitRateMonoMp3",i[i.Audio24Khz48KBitRateMonoMp3=6]="Audio24Khz48KBitRateMonoMp3",i[i.Audio24Khz96KBitRateMonoMp3=7]="Audio24Khz96KBitRateMonoMp3",i[i.Audio24Khz160KBitRateMonoMp3=8]="Audio24Khz160KBitRateMonoMp3",i[i.Raw16Khz16BitMonoTrueSilk=9]="Raw16Khz16BitMonoTrueSilk",i[i.Riff16Khz16BitMonoPcm=10]="Riff16Khz16BitMonoPcm",i[i.Riff8Khz16BitMonoPcm=11]="Riff8Khz16BitMonoPcm",i[i.Riff24Khz16BitMonoPcm=12]="Riff24Khz16BitMonoPcm",i[i.Riff8Khz8BitMonoMULaw=13]="Riff8Khz8BitMonoMULaw",i[i.Raw16Khz16BitMonoPcm=14]="Raw16Khz16BitMonoPcm",i[i.Raw24Khz16BitMonoPcm=15]="Raw24Khz16BitMonoPcm",i[i.Raw8Khz16BitMonoPcm=16]="Raw8Khz16BitMonoPcm",i[i.Ogg16Khz16BitMonoOpus=17]="Ogg16Khz16BitMonoOpus",i[i.Ogg24Khz16BitMonoOpus=18]="Ogg24Khz16BitMonoOpus",i[i.Raw48Khz16BitMonoPcm=19]="Raw48Khz16BitMonoPcm",i[i.Riff48Khz16BitMonoPcm=20]="Riff48Khz16BitMonoPcm",i[i.Audio48Khz96KBitRateMonoMp3=21]="Audio48Khz96KBitRateMonoMp3",i[i.Audio48Khz192KBitRateMonoMp3=22]="Audio48Khz192KBitRateMonoMp3",i[i.Ogg48Khz16BitMonoOpus=23]="Ogg48Khz16BitMonoOpus",i[i.Webm16Khz16BitMonoOpus=24]="Webm16Khz16BitMonoOpus",i[i.Webm24Khz16BitMonoOpus=25]="Webm24Khz16BitMonoOpus",i[i.Raw24Khz16BitMonoTrueSilk=26]="Raw24Khz16BitMonoTrueSilk",i[i.Raw8Khz8BitMonoALaw=27]="Raw8Khz8BitMonoALaw",i[i.Riff8Khz8BitMonoALaw=28]="Riff8Khz8BitMonoALaw",i[i.Webm24Khz16Bit24KbpsMonoOpus=29]="Webm24Khz16Bit24KbpsMonoOpus",i[i.Audio16Khz16Bit32KbpsMonoOpus=30]="Audio16Khz16Bit32KbpsMonoOpus",i[i.Audio24Khz16Bit48KbpsMonoOpus=31]="Audio24Khz16Bit48KbpsMonoOpus",i[i.Audio24Khz16Bit24KbpsMonoOpus=32]="Audio24Khz16Bit24KbpsMonoOpus",i[i.Raw22050Hz16BitMonoPcm=33]="Raw22050Hz16BitMonoPcm",i[i.Riff22050Hz16BitMonoPcm=34]="Riff22050Hz16BitMonoPcm",i[i.Raw44100Hz16BitMonoPcm=35]="Raw44100Hz16BitMonoPcm",i[i.Riff44100Hz16BitMonoPcm=36]="Riff44100Hz16BitMonoPcm"})(SI=wn.SpeechSynthesisOutputFormat||(wn.SpeechSynthesisOutputFormat={}))});var Pi=p(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.AudioOutputFormatImpl=void 0;var T=Ol(),b=pr(),vo=class i extends b.AudioStreamFormatImpl{constructor(e,t,r,n,s,o,a,c,u){super(r,o,t,e),this.formatTag=e,this.avgBytesPerSec=n,this.blockAlign=s,this.priAudioFormatString=a,this.priRequestAudioFormatString=c,this.priHasHeader=u}static fromSpeechSynthesisOutputFormat(e){return e===void 0?i.getDefaultOutputFormat():i.fromSpeechSynthesisOutputFormatString(i.SpeechSynthesisOutputFormatToString[e])}static fromSpeechSynthesisOutputFormatString(e){switch(e){case"raw-8khz-8bit-mono-mulaw":return new i(b.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,e,!1);case"riff-16khz-16kbps-mono-siren":return new i(b.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,"audio-16khz-16kbps-mono-siren",!0);case"audio-16khz-16kbps-mono-siren":return new i(b.AudioFormatTag.Siren,1,16e3,2e3,40,0,e,e,!1);case"audio-16khz-32kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,16e3,4096,2,16,e,e,!1);case"audio-16khz-128kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,16e3,16384,2,16,e,e,!1);case"audio-16khz-64kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,16e3,8192,2,16,e,e,!1);case"audio-24khz-48kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,24e3,6144,2,16,e,e,!1);case"audio-24khz-96kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,24e3,12288,2,16,e,e,!1);case"audio-24khz-160kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,24e3,20480,2,16,e,e,!1);case"raw-16khz-16bit-mono-truesilk":return new i(b.AudioFormatTag.SILKSkype,1,16e3,32e3,2,16,e,e,!1);case"riff-8khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!0);case"riff-24khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!0);case"riff-8khz-8bit-mono-mulaw":return new i(b.AudioFormatTag.MuLaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-mulaw",!0);case"raw-16khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,16e3,32e3,2,16,e,"raw-16khz-16bit-mono-pcm",!1);case"raw-24khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,24e3,48e3,2,16,e,"raw-24khz-16bit-mono-pcm",!1);case"raw-8khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,8e3,16e3,2,16,e,"raw-8khz-16bit-mono-pcm",!1);case"ogg-16khz-16bit-mono-opus":return new i(b.AudioFormatTag.OGG_OPUS,1,16e3,8192,2,16,e,e,!1);case"ogg-24khz-16bit-mono-opus":return new i(b.AudioFormatTag.OGG_OPUS,1,24e3,8192,2,16,e,e,!1);case"raw-48khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!1);case"riff-48khz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,48e3,96e3,2,16,e,"raw-48khz-16bit-mono-pcm",!0);case"audio-48khz-96kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,48e3,12288,2,16,e,e,!1);case"audio-48khz-192kbitrate-mono-mp3":return new i(b.AudioFormatTag.MP3,1,48e3,24576,2,16,e,e,!1);case"ogg-48khz-16bit-mono-opus":return new i(b.AudioFormatTag.OGG_OPUS,1,48e3,12e3,2,16,e,e,!1);case"webm-16khz-16bit-mono-opus":return new i(b.AudioFormatTag.WEBM_OPUS,1,16e3,4e3,2,16,e,e,!1);case"webm-24khz-16bit-mono-opus":return new i(b.AudioFormatTag.WEBM_OPUS,1,24e3,6e3,2,16,e,e,!1);case"webm-24khz-16bit-24kbps-mono-opus":return new i(b.AudioFormatTag.WEBM_OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-16khz-16bit-32kbps-mono-opus":return new i(b.AudioFormatTag.OPUS,1,16e3,4e3,2,16,e,e,!1);case"audio-24khz-16bit-48kbps-mono-opus":return new i(b.AudioFormatTag.OPUS,1,24e3,6e3,2,16,e,e,!1);case"audio-24khz-16bit-24kbps-mono-opus":return new i(b.AudioFormatTag.OPUS,1,24e3,3e3,2,16,e,e,!1);case"audio-24khz-16bit-mono-flac":return new i(b.AudioFormatTag.FLAC,1,24e3,24e3,2,16,e,e,!1);case"audio-48khz-16bit-mono-flac":return new i(b.AudioFormatTag.FLAC,1,48e3,3e4,2,16,e,e,!1);case"raw-24khz-16bit-mono-truesilk":return new i(b.AudioFormatTag.SILKSkype,1,24e3,48e3,2,16,e,e,!1);case"raw-8khz-8bit-mono-alaw":return new i(b.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,e,!1);case"riff-8khz-8bit-mono-alaw":return new i(b.AudioFormatTag.ALaw,1,8e3,8e3,1,8,e,"raw-8khz-8bit-mono-alaw",!0);case"raw-22050hz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,22050,44100,2,16,e,e,!1);case"riff-22050hz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,22050,44100,2,16,e,"raw-22050hz-16bit-mono-pcm",!0);case"raw-44100hz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,44100,88200,2,16,e,e,!1);case"riff-44100hz-16bit-mono-pcm":return new i(b.AudioFormatTag.PCM,1,44100,88200,2,16,e,"raw-44100hz-16bit-mono-pcm",!0);case"riff-16khz-16bit-mono-pcm":default:return new i(b.AudioFormatTag.PCM,1,16e3,32e3,2,16,"riff-16khz-16bit-mono-pcm","raw-16khz-16bit-mono-pcm",!0)}}static getDefaultOutputFormat(){return i.fromSpeechSynthesisOutputFormatString(typeof window<"u"?"audio-24khz-48kbitrate-mono-mp3":"riff-16khz-16bit-mono-pcm")}get hasHeader(){return this.priHasHeader}get header(){if(this.hasHeader)return this.privHeader}updateHeader(e){if(this.priHasHeader){let t=new DataView(this.privHeader);t.setUint32(4,e+this.privHeader.byteLength-8,!0),t.setUint32(40,e,!0)}}get requestAudioFormatString(){return this.priRequestAudioFormatString}addHeader(e){if(!this.hasHeader)return e;this.updateHeader(e.byteLength);let t=new Uint8Array(e.byteLength+this.header.byteLength);return t.set(new Uint8Array(this.header),0),t.set(new Uint8Array(e),this.header.byteLength),t.buffer}};fo.AudioOutputFormatImpl=vo;vo.SpeechSynthesisOutputFormatToString={[T.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]:"raw-8khz-8bit-mono-mulaw",[T.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]:"riff-16khz-16kbps-mono-siren",[T.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]:"audio-16khz-16kbps-mono-siren",[T.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]:"audio-16khz-32kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]:"audio-16khz-128kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]:"audio-16khz-64kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]:"audio-24khz-48kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]:"audio-24khz-96kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]:"audio-24khz-160kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]:"raw-16khz-16bit-mono-truesilk",[T.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]:"riff-16khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]:"riff-8khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]:"riff-24khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]:"riff-8khz-8bit-mono-mulaw",[T.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]:"raw-16khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]:"raw-24khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]:"raw-8khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]:"ogg-16khz-16bit-mono-opus",[T.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]:"ogg-24khz-16bit-mono-opus",[T.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]:"raw-48khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]:"riff-48khz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]:"audio-48khz-96kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]:"audio-48khz-192kbitrate-mono-mp3",[T.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]:"ogg-48khz-16bit-mono-opus",[T.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]:"webm-16khz-16bit-mono-opus",[T.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]:"webm-24khz-16bit-mono-opus",[T.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]:"webm-24khz-16bit-24kbps-mono-opus",[T.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]:"raw-24khz-16bit-mono-truesilk",[T.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]:"raw-8khz-8bit-mono-alaw",[T.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]:"riff-8khz-8bit-mono-alaw",[T.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]:"audio-16khz-16bit-32kbps-mono-opus",[T.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]:"audio-24khz-16bit-48kbps-mono-opus",[T.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]:"audio-24khz-16bit-24kbps-mono-opus",[T.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]:"raw-22050hz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]:"riff-22050hz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]:"raw-44100hz-16bit-mono-pcm",[T.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]:"riff-44100hz-16bit-mono-pcm"}});var Lr=p(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.PushAudioOutputStreamImpl=Xe.PushAudioOutputStream=Xe.PullAudioOutputStreamImpl=Xe.PullAudioOutputStream=Xe.AudioOutputStream=void 0;var kl=P(),CI=_(),PI=Pi(),bn=class{constructor(){}static createPullStream(){return An.create()}};Xe.AudioOutputStream=bn;var An=class extends bn{static create(){return new go}};Xe.PullAudioOutputStream=An;var go=class extends An{constructor(){super(),this.privId=kl.createNoDashGuid(),this.privStream=new kl.Stream}set format(e){e==null&&(this.privFormat=PI.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privFormat=e}get format(){return this.privFormat}get isClosed(){return this.privStream.isClosed}id(){return this.privId}async read(e){let t=new Int8Array(e),r=0;if(this.privLastChunkView!==void 0){if(this.privLastChunkView.length>e.byteLength)return t.set(this.privLastChunkView.slice(0,e.byteLength)),this.privLastChunkView=this.privLastChunkView.slice(e.byteLength),Promise.resolve(e.byteLength);t.set(this.privLastChunkView),r=this.privLastChunkView.length,this.privLastChunkView=void 0}for(;r<e.byteLength&&!this.privStream.isReadEnded;){let n=await this.privStream.read();if(n!==void 0&&!n.isEnd){let s;n.buffer.byteLength>e.byteLength-r?(s=n.buffer.slice(0,e.byteLength-r),this.privLastChunkView=new Int8Array(n.buffer.slice(e.byteLength-r))):s=n.buffer,t.set(new Int8Array(s),r),r+=s.byteLength}else this.privStream.readEnded()}return r}write(e){CI.Contracts.throwIfNullOrUndefined(this.privStream,"must set format before writing"),this.privStream.writeStreamChunk({buffer:e,isEnd:!1,timeReceived:Date.now()})}close(){this.privStream.close()}};Xe.PullAudioOutputStreamImpl=go;var mo=class extends bn{constructor(){super()}static create(e){return new yo(e)}};Xe.PushAudioOutputStream=mo;var yo=class extends mo{constructor(e){super(),this.privId=kl.createNoDashGuid(),this.privCallback=e}set format(e){}write(e){this.privCallback.write&&this.privCallback.write(e)}close(){this.privCallback.close&&this.privCallback.close()}id(){return this.privId}};Xe.PushAudioOutputStreamImpl=yo});var Ml=p(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.AudioOutputConfigImpl=lr.AudioConfigImpl=lr.AudioConfig=void 0;var Br=ce(),RI=_(),Fr=f(),EI=Al(),_I=Tl(),II=Lr(),Tn=class i{static fromDefaultMicrophoneInput(){let e=new Br.PcmRecorder(!0);return new Ht(new Br.MicAudioSource(e))}static fromMicrophoneInput(e){let t=new Br.PcmRecorder(!0);return new Ht(new Br.MicAudioSource(t,e))}static fromWavFileInput(e,t="unnamedBuffer.wav"){return new Ht(new Br.FileAudioSource(e,t))}static fromStreamInput(e){if(e instanceof Fr.PullAudioInputStreamCallback)return new Ht(new _I.PullAudioInputStreamImpl(e));if(e instanceof Fr.AudioInputStream)return new Ht(e);if(typeof MediaStream<"u"&&e instanceof MediaStream){let t=new Br.PcmRecorder(!1);return new Ht(new Br.MicAudioSource(t,null,null,e))}throw new Error("Not Supported Type")}static fromDefaultSpeakerOutput(){return new Kt(new Fr.SpeakerAudioDestination)}static fromSpeakerOutput(e){if(e===void 0)return i.fromDefaultSpeakerOutput();if(e instanceof Fr.SpeakerAudioDestination)return new Kt(e);throw new Error("Not Supported Type")}static fromAudioFileOutput(e){return new Kt(new EI.AudioFileWriter(e))}static fromStreamOutput(e){if(e instanceof Fr.PushAudioOutputStreamCallback)return new Kt(new II.PushAudioOutputStreamImpl(e));if(e instanceof Fr.PushAudioOutputStream)return new Kt(e);if(e instanceof Fr.PullAudioOutputStream)return new Kt(e);throw new Error("Not Supported Type")}};lr.AudioConfig=Tn;var Ht=class extends Tn{constructor(e){super(),this.privSource=e}get format(){return this.privSource.format}close(e,t){this.privSource.turnOff().then(()=>{e&&e()},r=>{t&&t(r)})}id(){return this.privSource.id()}turnOn(){return this.privSource.turnOn()}attach(e){return this.privSource.attach(e)}detach(e){return this.privSource.detach(e)}turnOff(){return this.privSource.turnOff()}get events(){return this.privSource.events}setProperty(e,t){if(RI.Contracts.throwIfNull(t,"value"),this.privSource.setProperty!==void 0)this.privSource.setProperty(e,t);else throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(e,t){if(this.privSource.getProperty!==void 0)return this.privSource.getProperty(e,t);throw new Error("This AudioConfig instance does not support getting properties.")}get deviceInfo(){return this.privSource.deviceInfo}};lr.AudioConfigImpl=Ht;var Kt=class extends Tn{constructor(e){super(),this.privDestination=e}set format(e){this.privDestination.format=e}write(e){this.privDestination.write(e)}close(){this.privDestination.close()}id(){return this.privDestination.id()}setProperty(){throw new Error("This AudioConfig instance does not support setting properties.")}getProperty(){throw new Error("This AudioConfig instance does not support getting properties.")}};lr.AudioOutputConfigImpl=Kt});var iy=p(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.CancellationReason=void 0;var wI;(function(i){i[i.Error=0]="Error",i[i.EndOfStream=1]="EndOfStream"})(wI=On.CancellationReason||(On.CancellationReason={}))});var ny=p(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.PullAudioInputStreamCallback=void 0;var Dl=class{};So.PullAudioInputStreamCallback=Dl});var sy=p(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.PushAudioOutputStreamCallback=void 0;var xl=class{};Co.PushAudioOutputStreamCallback=xl});var ay=p(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.KeywordRecognitionModel=void 0;var oy=_(),Nl=class{constructor(){this.privDisposed=!1}static fromFile(e){throw oy.Contracts.throwIfFileDoesNotExist(e,"fileName"),new Error("Not yet implemented.")}static fromStream(e){throw oy.Contracts.throwIfNull(e,"file"),new Error("Not yet implemented.")}close(){this.privDisposed||(this.privDisposed=!0)}};Po.KeywordRecognitionModel=Nl});var cy=p(Ro=>{"use strict";Object.defineProperty(Ro,"__esModule",{value:!0});Ro.SessionEventArgs=void 0;var ql=class{constructor(e){this.privSessionId=e}get sessionId(){return this.privSessionId}};Ro.SessionEventArgs=ql});var uy=p(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.RecognitionEventArgs=void 0;var bI=f(),jl=class extends bI.SessionEventArgs{constructor(e,t){super(t),this.privOffset=e}get offset(){return this.privOffset}};Eo.RecognitionEventArgs=jl});var py=p(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.OutputFormat=void 0;var AI;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(AI=kn.OutputFormat||(kn.OutputFormat={}))});var ly=p(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.IntentRecognitionEventArgs=void 0;var TI=f(),zl=class extends TI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};_o.IntentRecognitionEventArgs=zl});var hy=p(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.RecognitionResult=void 0;var Ll=class{constructor(e,t,r,n,s,o,a,c,u,l){this.privResultId=e,this.privReason=t,this.privText=r,this.privDuration=n,this.privOffset=s,this.privLanguage=o,this.privLanguageDetectionConfidence=a,this.privErrorDetails=c,this.privJson=u,this.privProperties=l}get resultId(){return this.privResultId}get reason(){return this.privReason}get text(){return this.privText}get duration(){return this.privDuration}get offset(){return this.privOffset}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}get errorDetails(){return this.privErrorDetails}get json(){return this.privJson}get properties(){return this.privProperties}};Io.RecognitionResult=Ll});var dy=p(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.SpeechRecognitionResult=void 0;var OI=f(),Bl=class extends OI.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,l,h){super(e,t,r,n,s,o,a,u,l,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};wo.SpeechRecognitionResult=Bl});var vy=p(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.IntentRecognitionResult=void 0;var kI=f(),Fl=class extends kI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,l,h){super(t,r,n,s,o,a,c,void 0,u,l,h),this.privIntentId=e}get intentId(){return this.privIntentId}};bo.IntentRecognitionResult=Fl});var fy=p(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.LanguageUnderstandingModelImpl=_i.LanguageUnderstandingModel=void 0;var Ri=_(),Ao=class{constructor(){}static fromEndpoint(e){Ri.Contracts.throwIfNull(e,"uri"),Ri.Contracts.throwIfNullOrWhitespace(e.hostname,"uri");let t=new Ei,r=e.host.indexOf(".");if(r===-1)throw new Error("Could not determine region from endpoint");t.region=e.host.substr(0,r);let n=e.pathname.lastIndexOf("/")+1;if(n===-1)throw new Error("Could not determine appId from endpoint");if(t.appId=e.pathname.substr(n),t.subscriptionKey=e.searchParams.get("subscription-key"),t.subscriptionKey===void 0)throw new Error("Could not determine subscription key from endpoint");return t}static fromAppId(e){Ri.Contracts.throwIfNullOrWhitespace(e,"appId");let t=new Ei;return t.appId=e,t}static fromSubscription(e,t,r){Ri.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),Ri.Contracts.throwIfNullOrWhitespace(t,"appId"),Ri.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Ei;return n.appId=t,n.region=r,n.subscriptionKey=e,n}};_i.LanguageUnderstandingModel=Ao;var Ei=class extends Ao{};_i.LanguageUnderstandingModelImpl=Ei});var my=p(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.MeetingTranscriptionEventArgs=hr.ConversationTranscriptionEventArgs=hr.SpeechRecognitionEventArgs=void 0;var gy=f(),To=class extends gy.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};hr.SpeechRecognitionEventArgs=To;var Vl=class extends gy.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};hr.ConversationTranscriptionEventArgs=Vl;var Ul=class extends To{};hr.MeetingTranscriptionEventArgs=Ul});var Ii=p(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.CancellationEventArgsBase=void 0;var MI=f(),Wl=class extends MI.RecognitionEventArgs{constructor(e,t,r,n,s){super(n,s),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Oo.CancellationEventArgsBase=Wl});var yy=p(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.SpeechRecognitionCanceledEventArgs=void 0;var DI=Ii(),Hl=class extends DI.CancellationEventArgsBase{};ko.SpeechRecognitionCanceledEventArgs=Hl});var Sy=p(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.TranslationRecognitionEventArgs=void 0;var xI=f(),Kl=class extends xI.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};Mo.TranslationRecognitionEventArgs=Kl});var Cy=p(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.TranslationSynthesisEventArgs=void 0;var NI=f(),Jl=class extends NI.SessionEventArgs{constructor(e,t){super(t),this.privResult=e}get result(){return this.privResult}};Do.TranslationSynthesisEventArgs=Jl});var $l=p(xo=>{"use strict";Object.defineProperty(xo,"__esModule",{value:!0});xo.TranslationRecognitionResult=void 0;var qI=f(),Gl=class i extends qI.SpeechRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,l,h){super(t,r,n,s,o,a,c,void 0,u,l,h),this.privTranslations=e}static fromSpeechRecognitionResult(e){return new i(void 0,e.resultId,e.reason,e.text,e.duration,e.offset,e.language,e.languageDetectionConfidence,e.errorDetails,e.json,e.properties)}get translations(){return this.privTranslations}};xo.TranslationRecognitionResult=Gl});var Py=p(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.TranslationSynthesisResult=void 0;var Ql=class{constructor(e,t){this.privReason=e,this.privAudio=t}get audio(){return this.privAudio}get reason(){return this.privReason}};No.TranslationSynthesisResult=Ql});var Ry=p(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.ResultReason=void 0;var jI;(function(i){i[i.NoMatch=0]="NoMatch",i[i.Canceled=1]="Canceled",i[i.RecognizingSpeech=2]="RecognizingSpeech",i[i.RecognizedSpeech=3]="RecognizedSpeech",i[i.RecognizedKeyword=4]="RecognizedKeyword",i[i.RecognizingIntent=5]="RecognizingIntent",i[i.RecognizedIntent=6]="RecognizedIntent",i[i.TranslatingSpeech=7]="TranslatingSpeech",i[i.TranslatedSpeech=8]="TranslatedSpeech",i[i.SynthesizingAudio=9]="SynthesizingAudio",i[i.SynthesizingAudioCompleted=10]="SynthesizingAudioCompleted",i[i.SynthesizingAudioStarted=11]="SynthesizingAudioStarted",i[i.EnrollingVoiceProfile=12]="EnrollingVoiceProfile",i[i.EnrolledVoiceProfile=13]="EnrolledVoiceProfile",i[i.RecognizedSpeakers=14]="RecognizedSpeakers",i[i.RecognizedSpeaker=15]="RecognizedSpeaker",i[i.ResetVoiceProfile=16]="ResetVoiceProfile",i[i.DeletedVoiceProfile=17]="DeletedVoiceProfile",i[i.VoicesListRetrieved=18]="VoicesListRetrieved",i[i.TranslatingParticipantSpeech=19]="TranslatingParticipantSpeech",i[i.TranslatedParticipantSpeech=20]="TranslatedParticipantSpeech",i[i.TranslatedInstantMessage=21]="TranslatedInstantMessage",i[i.TranslatedParticipantInstantMessage=22]="TranslatedParticipantInstantMessage"})(jI=Mn.ResultReason||(Mn.ResultReason={}))});var Ey=p(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.SpeechConfigImpl=wi.SpeechConfig=void 0;var Dn=C(),Vr=_(),I=f(),qo=class{constructor(){}static fromSubscription(e,t){Vr.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),Vr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Ur;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.setProperty(I.PropertyId.SpeechServiceConnection_Key,e),r}static fromEndpoint(e,t){Vr.Contracts.throwIfNull(e,"endpoint");let r=new Ur;return r.setProperty(I.PropertyId.SpeechServiceConnection_Endpoint,e.href),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromHost(e,t){Vr.Contracts.throwIfNull(e,"hostName");let r=new Ur;return r.setProperty(I.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(I.PropertyId.SpeechServiceConnection_Key,t),r}static fromAuthorizationToken(e,t){Vr.Contracts.throwIfNull(e,"authorizationToken"),Vr.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Ur;return r.setProperty(I.PropertyId.SpeechServiceConnection_Region,t),r.setProperty(I.PropertyId.SpeechServiceConnection_IntentRegion,t),r.authorizationToken=e,r}close(){}};wi.SpeechConfig=qo;var Ur=class i extends qo{constructor(){super(),this.privProperties=new I.PropertyCollection,this.speechRecognitionLanguage="en-US",this.outputFormat=I.OutputFormat.Simple}get properties(){return this.privProperties}get endPoint(){return new URL(this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Endpoint))}get subscriptionKey(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Key)}get region(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_Region)}get authorizationToken(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage)}set speechRecognitionLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get autoDetectSourceLanguages(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)}set autoDetectSourceLanguages(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e)}get outputFormat(){return I.OutputFormat[this.privProperties.getProperty(Dn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privProperties.setProperty(Dn.OutputFormatPropertyName,I.OutputFormat[e])}get endpointId(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EndpointId,e)}setProperty(e,t){Vr.Contracts.throwIfNull(t,"value"),this.privProperties.setProperty(e,t)}getProperty(e,t){return this.privProperties.getProperty(e,t)}setProxy(e,t,r,n){this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(I.PropertyId[I.PropertyId.SpeechServiceConnection_ProxyPassword],n)}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty(Dn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty(Dn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_ProfanityOption,I.ProfanityOption[e])}enableAudioLogging(){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privProperties.setProperty(I.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privProperties.setProperty(Dn.ForceDictationPropertyName,"true")}clone(){let e=new i;return e.privProperties=this.privProperties.clone(),e}get speechSynthesisLanguage(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return I.SpeechSynthesisOutputFormat[this.privProperties.getProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privProperties.setProperty(I.PropertyId.SpeechServiceConnection_SynthOutputFormat,I.SpeechSynthesisOutputFormat[e])}};wi.SpeechConfigImpl=Ur});var _y=p(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.SpeechTranslationConfigImpl=bi.SpeechTranslationConfig=void 0;var xn=C(),lt=_(),E=f(),jo=class extends E.SpeechConfig{constructor(){super()}static fromSubscription(e,t){lt.Contracts.throwIfNullOrWhitespace(e,"subscriptionKey"),lt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Wr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromAuthorizationToken(e,t){lt.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),lt.Contracts.throwIfNullOrWhitespace(t,"region");let r=new Wr;return r.properties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Region,t),r}static fromHost(e,t){lt.Contracts.throwIfNull(e,"hostName");let r=new Wr;return r.setProperty(E.PropertyId.SpeechServiceConnection_Host,e.protocol+"//"+e.hostname+(e.port===""?"":":"+e.port)),t!==void 0&&r.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}static fromEndpoint(e,t){lt.Contracts.throwIfNull(e,"endpoint"),lt.Contracts.throwIfNull(t,"subscriptionKey");let r=new Wr;return r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Endpoint,e.href),r.properties.setProperty(E.PropertyId.SpeechServiceConnection_Key,t),r}};bi.SpeechTranslationConfig=jo;var Wr=class extends jo{constructor(){super(),this.privSpeechProperties=new E.PropertyCollection,this.outputFormat=E.OutputFormat.Simple}set authorizationToken(e){lt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceAuthorization_Token,e)}set speechRecognitionLanguage(e){lt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_RecoLanguage,e)}get speechRecognitionLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_RecoLanguage])}get subscriptionKey(){return this.privSpeechProperties.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_Key])}get outputFormat(){return E.OutputFormat[this.privSpeechProperties.getProperty(xn.OutputFormatPropertyName,void 0)]}set outputFormat(e){this.privSpeechProperties.setProperty(xn.OutputFormatPropertyName,E.OutputFormat[e])}get endpointId(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_EndpointId)}set endpointId(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EndpointId,e)}addTargetLanguage(e){lt.Contracts.throwIfNullOrWhitespace(e,"value");let t=this.targetLanguages;t.includes(e)||(t.push(e),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))}get targetLanguages(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","):[]}get voiceName(){return this.getProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_TranslationVoice])}set voiceName(e){lt.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_TranslationVoice,e)}get region(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_Region)}setProxy(e,t,r,n){this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyHostName],e),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPort],t),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyUserName],r),this.setProperty(E.PropertyId[E.PropertyId.SpeechServiceConnection_ProxyPassword],n)}getProperty(e,t){return this.privSpeechProperties.getProperty(e,t)}setProperty(e,t){this.privSpeechProperties.setProperty(e,t)}get properties(){return this.privSpeechProperties}close(){}setServiceProperty(e,t){let r=JSON.parse(this.privSpeechProperties.getProperty(xn.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privSpeechProperties.setProperty(xn.ServicePropertiesPropertyName,JSON.stringify(r))}setProfanity(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_ProfanityOption,E.ProfanityOption[e])}enableAudioLogging(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_EnableAudioLogging,"true")}requestWordLevelTimestamps(){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"true")}enableDictation(){this.privSpeechProperties.setProperty(xn.ForceDictationPropertyName,"true")}get speechSynthesisLanguage(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage)}set speechSynthesisLanguage(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthLanguage,e)}get speechSynthesisVoiceName(){return this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthVoice)}set speechSynthesisVoiceName(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthVoice,e)}get speechSynthesisOutputFormat(){return E.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)]}set speechSynthesisOutputFormat(e){this.privSpeechProperties.setProperty(E.PropertyId.SpeechServiceConnection_SynthOutputFormat,E.SpeechSynthesisOutputFormat[e])}};bi.SpeechTranslationConfigImpl=Wr});var Zl=p(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.PropertyCollection=void 0;var Iy=f(),Xl=class i{constructor(){this.privKeys=[],this.privValues=[]}getProperty(e,t){let r;typeof e=="string"?r=e:r=Iy.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r)return this.privValues[n];if(t!==void 0)return String(t)}setProperty(e,t){let r;typeof e=="string"?r=e:r=Iy.PropertyId[e];for(let n=0;n<this.privKeys.length;n++)if(this.privKeys[n]===r){this.privValues[n]=t;return}this.privKeys.push(r),this.privValues.push(t)}clone(){let e=new i;for(let t=0;t<this.privKeys.length;t++)e.privKeys.push(this.privKeys[t]),e.privValues.push(this.privValues[t]);return e}mergeTo(e){this.privKeys.forEach(t=>{if(e.getProperty(t,void 0)===void 0){let r=this.getProperty(t);e.setProperty(t,r)}})}get keys(){return this.privKeys}};zo.PropertyCollection=Xl});var Lo=p(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.PropertyId=void 0;var zI;(function(i){i[i.SpeechServiceConnection_Key=0]="SpeechServiceConnection_Key",i[i.SpeechServiceConnection_Endpoint=1]="SpeechServiceConnection_Endpoint",i[i.SpeechServiceConnection_Region=2]="SpeechServiceConnection_Region",i[i.SpeechServiceAuthorization_Token=3]="SpeechServiceAuthorization_Token",i[i.SpeechServiceAuthorization_Type=4]="SpeechServiceAuthorization_Type",i[i.SpeechServiceConnection_EndpointId=5]="SpeechServiceConnection_EndpointId",i[i.SpeechServiceConnection_TranslationToLanguages=6]="SpeechServiceConnection_TranslationToLanguages",i[i.SpeechServiceConnection_TranslationVoice=7]="SpeechServiceConnection_TranslationVoice",i[i.SpeechServiceConnection_TranslationFeatures=8]="SpeechServiceConnection_TranslationFeatures",i[i.SpeechServiceConnection_IntentRegion=9]="SpeechServiceConnection_IntentRegion",i[i.SpeechServiceConnection_ProxyHostName=10]="SpeechServiceConnection_ProxyHostName",i[i.SpeechServiceConnection_ProxyPort=11]="SpeechServiceConnection_ProxyPort",i[i.SpeechServiceConnection_ProxyUserName=12]="SpeechServiceConnection_ProxyUserName",i[i.SpeechServiceConnection_ProxyPassword=13]="SpeechServiceConnection_ProxyPassword",i[i.SpeechServiceConnection_RecoMode=14]="SpeechServiceConnection_RecoMode",i[i.SpeechServiceConnection_RecoLanguage=15]="SpeechServiceConnection_RecoLanguage",i[i.Speech_SessionId=16]="Speech_SessionId",i[i.SpeechServiceConnection_SynthLanguage=17]="SpeechServiceConnection_SynthLanguage",i[i.SpeechServiceConnection_SynthVoice=18]="SpeechServiceConnection_SynthVoice",i[i.SpeechServiceConnection_SynthOutputFormat=19]="SpeechServiceConnection_SynthOutputFormat",i[i.SpeechServiceConnection_AutoDetectSourceLanguages=20]="SpeechServiceConnection_AutoDetectSourceLanguages",i[i.SpeechServiceResponse_RequestDetailedResultTrueFalse=21]="SpeechServiceResponse_RequestDetailedResultTrueFalse",i[i.SpeechServiceResponse_RequestProfanityFilterTrueFalse=22]="SpeechServiceResponse_RequestProfanityFilterTrueFalse",i[i.SpeechServiceResponse_JsonResult=23]="SpeechServiceResponse_JsonResult",i[i.SpeechServiceResponse_JsonErrorDetails=24]="SpeechServiceResponse_JsonErrorDetails",i[i.CancellationDetails_Reason=25]="CancellationDetails_Reason",i[i.CancellationDetails_ReasonText=26]="CancellationDetails_ReasonText",i[i.CancellationDetails_ReasonDetailedText=27]="CancellationDetails_ReasonDetailedText",i[i.LanguageUnderstandingServiceResponse_JsonResult=28]="LanguageUnderstandingServiceResponse_JsonResult",i[i.SpeechServiceConnection_Url=29]="SpeechServiceConnection_Url",i[i.SpeechServiceConnection_InitialSilenceTimeoutMs=30]="SpeechServiceConnection_InitialSilenceTimeoutMs",i[i.SpeechServiceConnection_EndSilenceTimeoutMs=31]="SpeechServiceConnection_EndSilenceTimeoutMs",i[i.Speech_SegmentationSilenceTimeoutMs=32]="Speech_SegmentationSilenceTimeoutMs",i[i.SpeechServiceConnection_EnableAudioLogging=33]="SpeechServiceConnection_EnableAudioLogging",i[i.SpeechServiceConnection_LanguageIdMode=34]="SpeechServiceConnection_LanguageIdMode",i[i.SpeechServiceConnection_RecognitionEndpointVersion=35]="SpeechServiceConnection_RecognitionEndpointVersion",i[i.SpeechServiceConnection_SpeakerIdMode=36]="SpeechServiceConnection_SpeakerIdMode",i[i.SpeechServiceResponse_ProfanityOption=37]="SpeechServiceResponse_ProfanityOption",i[i.SpeechServiceResponse_PostProcessingOption=38]="SpeechServiceResponse_PostProcessingOption",i[i.SpeechServiceResponse_RequestWordLevelTimestamps=39]="SpeechServiceResponse_RequestWordLevelTimestamps",i[i.SpeechServiceResponse_StablePartialResultThreshold=40]="SpeechServiceResponse_StablePartialResultThreshold",i[i.SpeechServiceResponse_OutputFormatOption=41]="SpeechServiceResponse_OutputFormatOption",i[i.SpeechServiceResponse_TranslationRequestStablePartialResult=42]="SpeechServiceResponse_TranslationRequestStablePartialResult",i[i.SpeechServiceResponse_RequestWordBoundary=43]="SpeechServiceResponse_RequestWordBoundary",i[i.SpeechServiceResponse_RequestPunctuationBoundary=44]="SpeechServiceResponse_RequestPunctuationBoundary",i[i.SpeechServiceResponse_RequestSentenceBoundary=45]="SpeechServiceResponse_RequestSentenceBoundary",i[i.Conversation_ApplicationId=46]="Conversation_ApplicationId",i[i.Conversation_DialogType=47]="Conversation_DialogType",i[i.Conversation_Initial_Silence_Timeout=48]="Conversation_Initial_Silence_Timeout",i[i.Conversation_From_Id=49]="Conversation_From_Id",i[i.Conversation_Conversation_Id=50]="Conversation_Conversation_Id",i[i.Conversation_Custom_Voice_Deployment_Ids=51]="Conversation_Custom_Voice_Deployment_Ids",i[i.Conversation_Speech_Activity_Template=52]="Conversation_Speech_Activity_Template",i[i.Conversation_Request_Bot_Status_Messages=53]="Conversation_Request_Bot_Status_Messages",i[i.Conversation_Agent_Connection_Id=54]="Conversation_Agent_Connection_Id",i[i.SpeechServiceConnection_Host=55]="SpeechServiceConnection_Host",i[i.ConversationTranslator_Host=56]="ConversationTranslator_Host",i[i.ConversationTranslator_Name=57]="ConversationTranslator_Name",i[i.ConversationTranslator_CorrelationId=58]="ConversationTranslator_CorrelationId",i[i.ConversationTranslator_Token=59]="ConversationTranslator_Token",i[i.PronunciationAssessment_ReferenceText=60]="PronunciationAssessment_ReferenceText",i[i.PronunciationAssessment_GradingSystem=61]="PronunciationAssessment_GradingSystem",i[i.PronunciationAssessment_Granularity=62]="PronunciationAssessment_Granularity",i[i.PronunciationAssessment_EnableMiscue=63]="PronunciationAssessment_EnableMiscue",i[i.PronunciationAssessment_Json=64]="PronunciationAssessment_Json",i[i.PronunciationAssessment_Params=65]="PronunciationAssessment_Params",i[i.SpeakerRecognition_Api_Version=66]="SpeakerRecognition_Api_Version",i[i.WebWorkerLoadType=67]="WebWorkerLoadType",i[i.TalkingAvatarService_WebRTC_SDP=68]="TalkingAvatarService_WebRTC_SDP"})(zI=Nn.PropertyId||(Nn.PropertyId={}))});var by=p(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.Recognizer=void 0;var Hr=C(),wy=P(),Bo=_(),Fo=f(),Yl=class i{constructor(e,t,r){this.audioConfig=e!==void 0?e:Fo.AudioConfig.fromDefaultMicrophoneInput(),this.privDisposed=!1,this.privProperties=t.clone(),this.privConnectionFactory=r,this.implCommonRecognizerSetup()}close(e,t){Bo.Contracts.throwIfDisposed(this.privDisposed),wy.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privReco}async dispose(e){this.privDisposed||(this.privDisposed=!0,e&&this.privReco&&(await this.privReco.audioSource.turnOff(),await this.privReco.dispose()))}static get telemetryEnabled(){return Hr.ServiceRecognizerBase.telemetryDataEnabled}static enableTelemetry(e){Hr.ServiceRecognizerBase.telemetryDataEnabled=e}implCommonRecognizerSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createRecognizerConfig(new Hr.SpeechServiceConfig(new Hr.Context(new Hr.OS(e,t,r))));this.privReco=this.createServiceRecognizer(i.getAuthFromProperties(this.privProperties),this.privConnectionFactory,this.audioConfig,n)}async recognizeOnceAsyncImpl(e){Bo.Contracts.throwIfDisposed(this.privDisposed);let t=new wy.Deferred;await this.implRecognizerStop(),await this.privReco.recognize(e,t.resolve,t.reject);let r=await t.promise;return await this.implRecognizerStop(),r}async startContinuousRecognitionAsyncImpl(e){Bo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop(),await this.privReco.recognize(e,void 0,void 0)}async stopContinuousRecognitionAsyncImpl(){Bo.Contracts.throwIfDisposed(this.privDisposed),await this.implRecognizerStop()}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}static getAuthFromProperties(e){let t=e.getProperty(Fo.PropertyId.SpeechServiceConnection_Key,void 0);return t&&t!==""?new Hr.CognitiveSubscriptionKeyAuthentication(t):new Hr.CognitiveTokenAuthentication(()=>{let n=e.getProperty(Fo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)},()=>{let n=e.getProperty(Fo.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(n)})}};Vo.Recognizer=Yl});var Ay=p(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.SpeechRecognizer=void 0;var Ai=C(),Uo=P(),dr=_(),Ne=f(),eh=class i extends Ne.Recognizer{constructor(e,t){let r=e;dr.Contracts.throwIfNull(r,"speechConfig"),dr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage),Ne.PropertyId[Ne.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Ai.SpeechConnectionFactory),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return dr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(Ne.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){dr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Ne.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return dr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ne.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return dr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Ai.OutputFormatPropertyName,Ne.OutputFormat[Ne.OutputFormat.Simple])===Ne.OutputFormat[Ne.OutputFormat.Simple]?Ne.OutputFormat.Simple:Ne.OutputFormat.Detailed}get properties(){return this.privProperties}recognizeOnceAsync(e,t){Uo.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Ai.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Uo.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Ai.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Uo.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){dr.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e){e&&e()}close(e,t){dr.Contracts.throwIfDisposed(this.privDisposedRecognizer),Uo.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Ai.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ai.SpeechServiceRecognizer(e,t,s,n,this)}};Wo.SpeechRecognizer=eh});var Ty=p(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.IntentRecognizer=void 0;var Kr=C(),Ho=P(),we=_(),Jt=f(),th=class extends Jt.Recognizer{constructor(e,t){we.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;we.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Kr.IntentConnectionFactory),this.privAddedIntents=[],this.privAddedLmIntents={},this.privDisposedIntentRecognizer=!1,this.privProperties=r.properties,we.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Jt.PropertyId.SpeechServiceConnection_RecoLanguage),Jt.PropertyId[Jt.PropertyId.SpeechServiceConnection_RecoLanguage])}get speechRecognitionLanguage(){return we.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),this.properties.getProperty(Jt.PropertyId.SpeechServiceConnection_RecoLanguage)}get authorizationToken(){return this.properties.getProperty(Jt.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(Jt.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}recognizeOnceAsync(e,t){if(we.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}Ho.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Kr.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){if(Object.keys(this.privAddedLmIntents).length!==0||this.privUmbrellaIntent!==void 0){let r=this.buildSpeechContext();this.privReco.speechContext.setSection("intent",r.Intent),this.privReco.dynamicGrammar.addReferenceGrammar(r.ReferenceGrammars),this.privReco.setIntents(this.privAddedLmIntents,this.privUmbrellaIntent)}Ho.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Kr.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Ho.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}startKeywordRecognitionAsync(e,t,r){we.Contracts.throwIfNull(e,"model"),r&&r("Not yet implemented.")}stopKeywordRecognitionAsync(e,t){if(e)try{e()}catch(r){t&&t(r)}}addIntent(e,t){we.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),we.Contracts.throwIfNullOrWhitespace(t,"intentId"),we.Contracts.throwIfNullOrWhitespace(e,"simplePhrase"),this.privAddedIntents.push([t,e])}addIntentWithLanguageModel(e,t,r){we.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),we.Contracts.throwIfNullOrWhitespace(e,"intentId"),we.Contracts.throwIfNull(t,"model");let n=t;we.Contracts.throwIfNullOrWhitespace(n.appId,"model.appId"),this.privAddedLmIntents[e]=new Kr.AddedLmIntent(n,r)}addAllIntents(e,t){we.Contracts.throwIfNull(e,"model");let r=e;we.Contracts.throwIfNullOrWhitespace(r.appId,"model.appId"),this.privUmbrellaIntent=new Kr.AddedLmIntent(r,t)}close(e,t){we.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer),Ho.marshalPromiseToCallbacks(this.dispose(!0),e,t)}createRecognizerConfig(e){return new Kr.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Kr.IntentServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedIntentRecognizer||e&&(this.privDisposedIntentRecognizer=!0,await super.dispose(e))}buildSpeechContext(){let e,t,r,n=[];this.privUmbrellaIntent!==void 0&&(e=this.privUmbrellaIntent.modelImpl.appId,t=this.privUmbrellaIntent.modelImpl.region,r=this.privUmbrellaIntent.modelImpl.subscriptionKey);for(let s of Object.keys(this.privAddedLmIntents)){let o=this.privAddedLmIntents[s];if(e===void 0)e=o.modelImpl.appId;else if(e!==o.modelImpl.appId)throw new Error("Intents must all be from the same LUIS model");if(t===void 0)t=o.modelImpl.region;else if(t!==o.modelImpl.region)throw new Error("Intents must all be from the same LUIS model in a single region");if(r===void 0)r=o.modelImpl.subscriptionKey;else if(r!==o.modelImpl.subscriptionKey)throw new Error("Intents must all use the same subscription key");let a="luis/"+e+"-PRODUCTION#"+s;n.push(a)}return{Intent:{id:e,key:r===void 0?this.privProperties.getProperty(Jt.PropertyId[Jt.PropertyId.SpeechServiceConnection_Key]):r,provider:"LUIS"},ReferenceGrammars:this.privUmbrellaIntent===void 0?n:["luis/"+e+"-PRODUCTION"]}}};Ko.IntentRecognizer=th});var Oy=p(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.VoiceProfileType=void 0;var LI;(function(i){i[i.TextIndependentIdentification=0]="TextIndependentIdentification",i[i.TextDependentVerification=1]="TextDependentVerification",i[i.TextIndependentVerification=2]="TextIndependentVerification"})(LI=qn.VoiceProfileType||(qn.VoiceProfileType={}))});var nh=p(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.ConnectionMessageImpl=Ti.ConnectionMessage=void 0;var ky=Ie(),My=P(),BI=Zl(),FI=Lo(),rh=class{};Ti.ConnectionMessage=rh;var ih=class{constructor(e){this.privConnectionMessage=e,this.privProperties=new BI.PropertyCollection,this.privConnectionMessage.headers[ky.HeaderNames.ConnectionId]&&this.privProperties.setProperty(FI.PropertyId.Speech_SessionId,this.privConnectionMessage.headers[ky.HeaderNames.ConnectionId]),Object.keys(this.privConnectionMessage.headers).forEach(t=>{this.privProperties.setProperty(t,this.privConnectionMessage.headers[t])})}get path(){return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(e=>e.toLowerCase()==="path".toLowerCase())]}get isTextMessage(){return this.privConnectionMessage.messageType===My.MessageType.Text}get isBinaryMessage(){return this.privConnectionMessage.messageType===My.MessageType.Binary}get TextMessage(){return this.privConnectionMessage.textBody}get binaryMessage(){return this.privConnectionMessage.binaryBody}get properties(){return this.privProperties}toString(){return""}};Ti.ConnectionMessageImpl=ih});var ch=p(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.Connection=void 0;var sh=C(),oh=P(),Dy=nh(),VI=_(),jn=f(),ah=class i{static fromRecognizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}static fromSynthesizer(e){let t=e.internalData,r=new i;return r.privInternalData=t,r.setupEvents(),r}openConnection(e,t){oh.marshalPromiseToCallbacks(this.privInternalData.connect(),e,t)}closeConnection(e,t){if(this.privInternalData instanceof sh.SynthesisAdapterBase)throw new Error("Disconnecting a synthesizer's connection is currently not supported");oh.marshalPromiseToCallbacks(this.privInternalData.disconnect(),e,t)}setMessageProperty(e,t,r){if(VI.Contracts.throwIfNullOrWhitespace(t,"propertyName"),this.privInternalData instanceof sh.ServiceRecognizerBase){if(e.toLowerCase()!=="speech.context")throw new Error("Only speech.context message property sets are currently supported for recognizer");this.privInternalData.speechContext.setSection(t,r)}else if(this.privInternalData instanceof sh.SynthesisAdapterBase){if(e.toLowerCase()!=="synthesis.context")throw new Error("Only synthesis.context message property sets are currently supported for synthesizer");this.privInternalData.synthesisContext.setSection(t,r)}}sendMessageAsync(e,t,r,n){oh.marshalPromiseToCallbacks(this.privInternalData.sendNetworkMessage(e,t),r,n)}close(){}setupEvents(){this.privEventListener=this.privInternalData.connectionEvents.attach(e=>{e.name==="ConnectionEstablishedEvent"?this.connected&&this.connected(new jn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionClosedEvent"?this.disconnected&&this.disconnected(new jn.ConnectionEventArgs(e.connectionId)):e.name==="ConnectionMessageSentEvent"?this.messageSent&&this.messageSent(new jn.ConnectionMessageEventArgs(new Dy.ConnectionMessageImpl(e.message))):e.name==="ConnectionMessageReceivedEvent"&&this.messageReceived&&this.messageReceived(new jn.ConnectionMessageEventArgs(new Dy.ConnectionMessageImpl(e.message)))}),this.privServiceEventListener=this.privInternalData.serviceEvents.attach(e=>{this.receivedServiceMessage&&this.receivedServiceMessage(new jn.ServiceEventArgs(e.jsonString,e.name))})}};Jo.Connection=ah});var xy=p($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.TranslationRecognizer=void 0;var zn=C(),Go=P(),UI=ch(),ht=_(),J=f(),uh=class i extends J.Recognizer{constructor(e,t,r){let n=e;ht.Contracts.throwIfNull(n,"speechConfig"),super(t,n.properties,r||new zn.TranslationConnectionFactory),this.privDisposedTranslationRecognizer=!1,this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)!==void 0&&ht.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationVoice]),ht.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages),J.PropertyId[J.PropertyId.SpeechServiceConnection_TranslationToLanguages]),ht.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage),J.PropertyId[J.PropertyId.SpeechServiceConnection_RecoLanguage])}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get speechRecognitionLanguage(){return ht.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_RecoLanguage)}get targetLanguages(){return ht.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",")}get voiceName(){return ht.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationVoice,void 0)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(J.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){this.properties.setProperty(J.PropertyId.SpeechServiceAuthorization_Token,e)}recognizeOnceAsync(e,t){ht.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Go.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(zn.RecognitionMode.Interactive),e,t)}startContinuousRecognitionAsync(e,t){Go.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(zn.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){Go.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}removeTargetLanguage(e){if(ht.Contracts.throwIfNullOrUndefined(e,"language to be removed"),this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0){let t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),r=t.indexOf(e);r>-1&&(t.splice(r,1),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")),this.updateLanguages(t))}}addTargetLanguage(e){ht.Contracts.throwIfNullOrUndefined(e,"language to be added");let t=[];this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0?(t=this.properties.getProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","),t.includes(e)||(t.push(e),this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,t.join(",")))):(this.properties.setProperty(J.PropertyId.SpeechServiceConnection_TranslationToLanguages,e),t=[e]),this.updateLanguages(t)}close(e,t){ht.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer),Go.marshalPromiseToCallbacks(this.dispose(!0),e,t)}onConnection(){}async dispose(e){this.privDisposedTranslationRecognizer||(this.privDisposedTranslationRecognizer=!0,e&&(await this.implRecognizerStop(),await super.dispose(e)))}createRecognizerConfig(e){return new zn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new zn.TranslationServiceRecognizer(e,t,s,n,this)}updateLanguages(e){let t=UI.Connection.fromRecognizer(this);t&&(t.setMessageProperty("speech.context","translationcontext",{to:e}),t.sendMessageAsync("event",JSON.stringify({id:"translation",name:"updateLanguage",to:e})))}};$o.TranslationRecognizer=uh});var Ny=p(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.Translations=void 0;var WI=f(),ph=class{constructor(){this.privMap=new WI.PropertyCollection}get languages(){return this.privMap.keys}get(e,t){return this.privMap.getProperty(e,t)}set(e,t){this.privMap.setProperty(e,t)}};Qo.Translations=ph});var qy=p(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.NoMatchReason=void 0;var HI;(function(i){i[i.NotRecognized=0]="NotRecognized",i[i.InitialSilenceTimeout=1]="InitialSilenceTimeout",i[i.InitialBabbleTimeout=2]="InitialBabbleTimeout"})(HI=Ln.NoMatchReason||(Ln.NoMatchReason={}))});var jy=p(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.NoMatchDetails=void 0;var lh=C(),Xo=f(),hh=class i{constructor(e){this.privReason=e}static fromResult(e){let t=lh.SimpleSpeechPhrase.fromJSON(e.json),r=Xo.NoMatchReason.NotRecognized;switch(t.RecognitionStatus){case lh.RecognitionStatus.BabbleTimeout:r=Xo.NoMatchReason.InitialBabbleTimeout;break;case lh.RecognitionStatus.InitialSilenceTimeout:r=Xo.NoMatchReason.InitialSilenceTimeout;break;default:r=Xo.NoMatchReason.NotRecognized;break}return new i(r)}get reason(){return this.privReason}};Zo.NoMatchDetails=hh});var zy=p(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.TranslationRecognitionCanceledEventArgs=void 0;var dh=class{constructor(e,t,r,n,s){this.privCancelReason=t,this.privErrorDetails=r,this.privResult=s,this.privSessionId=e,this.privErrorCode=n}get result(){return this.privResult}get sessionId(){return this.privSessionId}get reason(){return this.privCancelReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};Yo.TranslationRecognitionCanceledEventArgs=dh});var Ly=p(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});ea.IntentRecognitionCanceledEventArgs=void 0;var KI=f(),vh=class extends KI.IntentRecognitionEventArgs{constructor(e,t,r,n,s,o){super(n,s,o),this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorCode(){return this.privErrorCode}get errorDetails(){return this.privErrorDetails}};ea.IntentRecognitionCanceledEventArgs=vh});var gh=p(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.CancellationDetailsBase=void 0;var fh=class{constructor(e,t,r){this.privReason=e,this.privErrorDetails=t,this.privErrorCode=r}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get ErrorCode(){return this.privErrorCode}};ta.CancellationDetailsBase=fh});var By=p(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.CancellationDetails=void 0;var ra=C(),JI=gh(),Oi=f(),mh=class i extends JI.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=Oi.CancellationReason.Error,r=Oi.CancellationErrorCode.NoError;if(e instanceof Oi.RecognitionResult&&e.json){let n=ra.SimpleSpeechPhrase.fromJSON(e.json);t=ra.EnumTranslation.implTranslateCancelResult(n.RecognitionStatus)}return e.properties&&(r=Oi.CancellationErrorCode[e.properties.getProperty(ra.CancellationErrorCodePropertyName,Oi.CancellationErrorCode[Oi.CancellationErrorCode.NoError])]),new i(t,e.errorDetails||ra.EnumTranslation.implTranslateErrorDetails(r),r)}};ia.CancellationDetails=mh});var Fy=p(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.CancellationErrorCode=void 0;var GI;(function(i){i[i.NoError=0]="NoError",i[i.AuthenticationFailure=1]="AuthenticationFailure",i[i.BadRequestParameters=2]="BadRequestParameters",i[i.TooManyRequests=3]="TooManyRequests",i[i.ConnectionFailure=4]="ConnectionFailure",i[i.ServiceTimeout=5]="ServiceTimeout",i[i.ServiceError=6]="ServiceError",i[i.RuntimeError=7]="RuntimeError",i[i.Forbidden=8]="Forbidden"})(GI=Bn.CancellationErrorCode||(Bn.CancellationErrorCode={}))});var Vy=p(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.ConnectionEventArgs=void 0;var $I=f(),yh=class extends $I.SessionEventArgs{};na.ConnectionEventArgs=yh});var Uy=p(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.ServiceEventArgs=void 0;var QI=f(),Sh=class extends QI.SessionEventArgs{constructor(e,t,r){super(r),this.privJsonResult=e,this.privEventName=t}get jsonString(){return this.privJsonResult}get eventName(){return this.privEventName}};sa.ServiceEventArgs=Sh});var Wy=p(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.PhraseListGrammar=void 0;var Ch=class i{constructor(e){this.privGrammerBuilder=e.dynamicGrammar}static fromRecognizer(e){let t=e.internalData;return new i(t)}addPhrase(e){this.privGrammerBuilder.addPhrase(e)}addPhrases(e){this.privGrammerBuilder.addPhrase(e)}clear(){this.privGrammerBuilder.clearPhrases()}};oa.PhraseListGrammar=Ch});var ca=p(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});ki.DialogServiceConfigImpl=ki.DialogServiceConfig=void 0;var XI=_(),Fn=f(),aa=class{constructor(){}set applicationId(e){}static get DialogTypes(){return{BotFramework:"bot_framework",CustomCommands:"custom_commands"}}};ki.DialogServiceConfig=aa;var Ph=class extends aa{constructor(){super(),this.privSpeechConfig=new Fn.SpeechConfigImpl}get properties(){return this.privSpeechConfig.properties}get speechRecognitionLanguage(){return this.privSpeechConfig.speechRecognitionLanguage}set speechRecognitionLanguage(e){XI.Contracts.throwIfNullOrWhitespace(e,"value"),this.privSpeechConfig.speechRecognitionLanguage=e}get outputFormat(){return this.privSpeechConfig.outputFormat}set outputFormat(e){this.privSpeechConfig.outputFormat=e}setProperty(e,t){this.privSpeechConfig.setProperty(e,t)}getProperty(e,t){return this.privSpeechConfig.getProperty(e)}setProxy(e,t,r,n){this.setProperty(Fn.PropertyId.SpeechServiceConnection_ProxyHostName,e),this.setProperty(Fn.PropertyId.SpeechServiceConnection_ProxyPort,`${t}`),r&&this.setProperty(Fn.PropertyId.SpeechServiceConnection_ProxyUserName,r),n&&this.setProperty(Fn.PropertyId.SpeechServiceConnection_ProxyPassword,n)}setServiceProperty(e,t,r){this.privSpeechConfig.setServiceProperty(e,t)}close(){}};ki.DialogServiceConfigImpl=Ph});var Hy=p(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.BotFrameworkConfig=void 0;var Jr=_(),Gt=ca(),qe=f(),Rh=class extends Gt.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Jr.Contracts.throwIfNullOrWhitespace(e,"subscription"),Jr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Gt.DialogServiceConfigImpl;return n.setProperty(qe.PropertyId.Conversation_DialogType,Gt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(qe.PropertyId.SpeechServiceConnection_Key,e),n.setProperty(qe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(qe.PropertyId.Conversation_ApplicationId,r),n}static fromAuthorizationToken(e,t,r){Jr.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),Jr.Contracts.throwIfNullOrWhitespace(t,"region");let n=new Gt.DialogServiceConfigImpl;return n.setProperty(qe.PropertyId.Conversation_DialogType,Gt.DialogServiceConfig.DialogTypes.BotFramework),n.setProperty(qe.PropertyId.SpeechServiceAuthorization_Token,e),n.setProperty(qe.PropertyId.SpeechServiceConnection_Region,t),r&&n.setProperty(qe.PropertyId.Conversation_ApplicationId,r),n}static fromHost(e,t,r){Jr.Contracts.throwIfNullOrUndefined(e,"host");let n=e instanceof URL?e:new URL(`wss://${e}.convai.speech.azure.us`);Jr.Contracts.throwIfNullOrUndefined(n,"resolvedHost");let s=new Gt.DialogServiceConfigImpl;return s.setProperty(qe.PropertyId.Conversation_DialogType,Gt.DialogServiceConfig.DialogTypes.BotFramework),s.setProperty(qe.PropertyId.SpeechServiceConnection_Host,n.toString()),t!==void 0&&s.setProperty(qe.PropertyId.SpeechServiceConnection_Key,t),s}static fromEndpoint(e,t){Jr.Contracts.throwIfNull(e,"endpoint");let r=new Gt.DialogServiceConfigImpl;return r.setProperty(qe.PropertyId.Conversation_DialogType,Gt.DialogServiceConfig.DialogTypes.BotFramework),r.setProperty(qe.PropertyId.SpeechServiceConnection_Endpoint,e.toString()),t!==void 0&&r.setProperty(qe.PropertyId.SpeechServiceConnection_Key,t),r}};ua.BotFrameworkConfig=Rh});var Ky=p(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.CustomCommandsConfig=void 0;var Gr=_(),Vn=ca(),wt=f(),Eh=class extends Vn.DialogServiceConfigImpl{constructor(){super()}static fromSubscription(e,t,r){Gr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Gr.Contracts.throwIfNullOrWhitespace(t,"subscription"),Gr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Vn.DialogServiceConfigImpl;return n.setProperty(wt.PropertyId.Conversation_DialogType,Vn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(wt.PropertyId.Conversation_ApplicationId,e),n.setProperty(wt.PropertyId.SpeechServiceConnection_Key,t),n.setProperty(wt.PropertyId.SpeechServiceConnection_Region,r),n}static fromAuthorizationToken(e,t,r){Gr.Contracts.throwIfNullOrWhitespace(e,"applicationId"),Gr.Contracts.throwIfNullOrWhitespace(t,"authorizationToken"),Gr.Contracts.throwIfNullOrWhitespace(r,"region");let n=new Vn.DialogServiceConfigImpl;return n.setProperty(wt.PropertyId.Conversation_DialogType,Vn.DialogServiceConfig.DialogTypes.CustomCommands),n.setProperty(wt.PropertyId.Conversation_ApplicationId,e),n.setProperty(wt.PropertyId.SpeechServiceAuthorization_Token,t),n.setProperty(wt.PropertyId.SpeechServiceConnection_Region,r),n}set applicationId(e){Gr.Contracts.throwIfNullOrWhitespace(e,"value"),this.setProperty(wt.PropertyId.Conversation_ApplicationId,e)}get applicationId(){return this.getProperty(wt.PropertyId.Conversation_ApplicationId)}};pa.CustomCommandsConfig=Eh});var $t=p(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.QueryParameterNames=void 0;var W=class{};la.QueryParameterNames=W;W.BotId="botid";W.CustomSpeechDeploymentId="cid";W.CustomVoiceDeploymentId="deploymentId";W.EnableAudioLogging="storeAudio";W.EnableLanguageId="lidEnabled";W.EnableWordLevelTimestamps="wordLevelTimestamps";W.EndSilenceTimeoutMs="endSilenceTimeoutMs";W.SegmentationSilenceTimeoutMs="segmentationSilenceTimeoutMs";W.Format="format";W.InitialSilenceTimeoutMs="initialSilenceTimeoutMs";W.Language="language";W.Profanity="profanity";W.RequestBotStatusMessages="enableBotMessageStatus";W.StableIntermediateThreshold="stableIntermediateThreshold";W.StableTranslation="stableTranslation";W.TestHooks="testhooks";W.Postprocessing="postprocessing";W.CtsMeetingId="meetingId";W.CtsDeviceId="deviceId";W.CtsIsParticipant="isParticipant";W.EnableAvatar="enableTalkingAvatar"});var Ze=p(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.ConnectionFactoryBase=void 0;var ZI=C(),vr=f(),fr=$t(),_h=class{static getHostSuffix(e){if(e){if(e.toLowerCase().startsWith("china"))return".azure.cn";if(e.toLowerCase().startsWith("usgov"))return".azure.us"}return".microsoft.com"}setCommonUrlParams(e,t,r){new Map([[vr.PropertyId.Speech_SegmentationSilenceTimeoutMs,fr.QueryParameterNames.SegmentationSilenceTimeoutMs],[vr.PropertyId.SpeechServiceConnection_EnableAudioLogging,fr.QueryParameterNames.EnableAudioLogging],[vr.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,fr.QueryParameterNames.EndSilenceTimeoutMs],[vr.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,fr.QueryParameterNames.InitialSilenceTimeoutMs],[vr.PropertyId.SpeechServiceResponse_PostProcessingOption,fr.QueryParameterNames.Postprocessing],[vr.PropertyId.SpeechServiceResponse_ProfanityOption,fr.QueryParameterNames.Profanity],[vr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,fr.QueryParameterNames.EnableWordLevelTimestamps],[vr.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,fr.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(ZI.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}setUrlParameter(e,t,r,n,s){let o=r.parameters.getProperty(e,void 0);o&&(!s||s.search(t)===-1)&&(n[t]=o.toLocaleLowerCase())}};ha.ConnectionFactoryBase=_h});var Qy=p(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.DialogConnectionFactory=void 0;var Jy=ce(),YI=C(),Ue=f(),Gy=Ze(),ew=C(),$y=Ie(),da=$t(),Un=class i extends Gy.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(Ue.PropertyId.Conversation_ApplicationId,""),s=e.parameters.getProperty(Ue.PropertyId.Conversation_DialogType),o=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Region),a=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_RecoLanguage,"en-US"),c=e.parameters.getProperty(Ue.PropertyId.Conversation_Request_Bot_Status_Messages,"true"),u={};u[$y.HeaderNames.ConnectionId]=r,u[da.QueryParameterNames.Format]=e.parameters.getProperty(YI.OutputFormatPropertyName,Ue.OutputFormat[Ue.OutputFormat.Simple]).toLowerCase(),u[da.QueryParameterNames.Language]=a,u[da.QueryParameterNames.RequestBotStatusMessages]=c,n&&(u[da.QueryParameterNames.BotId]=n,s===Ue.DialogServiceConfig.DialogTypes.CustomCommands&&(u[$y.HeaderNames.CustomCommandsAppId]=n));let l=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"commands/":"",h=s===Ue.DialogServiceConfig.DialogTypes.CustomCommands?"v1":s===Ue.DialogServiceConfig.DialogTypes.BotFramework?"v3":"v0",d={};t.token!=null&&t.token!==""&&(d[t.headerName]=t.token);let g=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Endpoint,"");if(!g){let D=Gy.ConnectionFactoryBase.getHostSuffix(o),oe=e.parameters.getProperty(Ue.PropertyId.SpeechServiceConnection_Host,`wss://${o}.${i.BaseUrl}${D}`);g=`${oe.endsWith("/")?oe:oe+"/"}${l}${i.ApiKey}/${h}`}this.setCommonUrlParams(e,u,g);let M=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new Jy.WebsocketConnection(g,u,d,new ew.WebsocketMessageFormatter,Jy.ProxyInfo.fromRecognizerConfig(e),M,r)}};va.DialogConnectionFactory=Un;Un.ApiKey="api";Un.BaseUrl="convai.speech"});var Xy=p(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.DialogServiceConnector=void 0;var tw=Qy(),Ih=C(),Mi=P(),fa=_(),rw=f(),gr=Lo(),wh=class extends rw.Recognizer{constructor(e,t){let r=e;fa.Contracts.throwIfNull(e,"dialogConfig"),super(t,r.properties,new tw.DialogConnectionFactory),this.isTurnComplete=!0,this.privIsDisposed=!1,this.privProperties=r.properties.clone();let n=this.buildAgentConfig();this.privReco.agentConfig.set(n)}connect(e,t){Mi.marshalPromiseToCallbacks(this.privReco.connect(),e,t)}disconnect(e,t){Mi.marshalPromiseToCallbacks(this.privReco.disconnect(),e,t)}get authorizationToken(){return this.properties.getProperty(gr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){fa.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(gr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get speechActivityTemplate(){return this.properties.getProperty(gr.PropertyId.Conversation_Speech_Activity_Template)}set speechActivityTemplate(e){this.properties.setProperty(gr.PropertyId.Conversation_Speech_Activity_Template,e)}listenOnceAsync(e,t){if(this.isTurnComplete){fa.Contracts.throwIfDisposed(this.privIsDisposed);let n=(async()=>{await this.privReco.connect(),await this.implRecognizerStop(),this.isTurnComplete=!1;let s=new Mi.Deferred;await this.privReco.recognize(Ih.RecognitionMode.Conversation,s.resolve,s.reject);let o=await s.promise;return await this.implRecognizerStop(),o})();n.catch(()=>{this.dispose(!0).catch(()=>{})}),Mi.marshalPromiseToCallbacks(n.finally(()=>{this.isTurnComplete=!0}),e,t)}}sendActivityAsync(e,t,r){Mi.marshalPromiseToCallbacks(this.privReco.sendMessage(e),t,r)}close(e,t){fa.Contracts.throwIfDisposed(this.privIsDisposed),Mi.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privIsDisposed||e&&(this.privIsDisposed=!0,await this.implRecognizerStop(),await super.dispose(e))}createRecognizerConfig(e){return new Ih.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Ih.DialogServiceAdapter(e,t,s,n,this)}buildAgentConfig(){return{botInfo:{commType:this.properties.getProperty("Conversation_Communication_Type","Default"),commandsCulture:void 0,connectionId:this.properties.getProperty(gr.PropertyId.Conversation_Agent_Connection_Id),conversationId:this.properties.getProperty(gr.PropertyId.Conversation_Conversation_Id,void 0),fromId:this.properties.getProperty(gr.PropertyId.Conversation_From_Id,void 0),ttsAudioFormat:this.properties.getProperty(gr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)},version:.2}}};ga.DialogServiceConnector=wh});var Zy=p(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.ActivityReceivedEventArgs=void 0;var bh=class{constructor(e,t){this.privActivity=e,this.privAudioStream=t}get activity(){return this.privActivity}get audioStream(){return this.privAudioStream}};ma.ActivityReceivedEventArgs=bh});var Yy=p(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.TurnStatusResponsePayload=void 0;var Ah=class i{constructor(e){this.privMessageStatusResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get interactionId(){return this.privMessageStatusResponse.interactionId}get conversationId(){return this.privMessageStatusResponse.conversationId}get statusCode(){switch(this.privMessageStatusResponse.statusCode){case"Success":return 200;case"Failed":return 400;case"TimedOut":return 429;default:return this.privMessageStatusResponse.statusCode}}};ya.TurnStatusResponsePayload=Ah});var eS=p(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.TurnStatusReceivedEventArgs=void 0;var iw=Yy(),Th=class{constructor(e){this.privTurnStatus=iw.TurnStatusResponsePayload.fromJSON(e)}get interactionId(){return this.privTurnStatus.interactionId}get conversationId(){return this.privTurnStatus.conversationId}get statusCode(){return this.privTurnStatus.statusCode}};Sa.TurnStatusReceivedEventArgs=Th});var tS=p(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.ServicePropertyChannel=void 0;var nw;(function(i){i[i.UriQueryParameter=0]="UriQueryParameter"})(nw=Wn.ServicePropertyChannel||(Wn.ServicePropertyChannel={}))});var rS=p(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.ProfanityOption=void 0;var sw;(function(i){i[i.Masked=0]="Masked",i[i.Removed=1]="Removed",i[i.Raw=2]="Raw"})(sw=Hn.ProfanityOption||(Hn.ProfanityOption={}))});var iS=p(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.BaseAudioPlayer=void 0;var ow=pt(),aw=f(),cw=pr(),Oh=class{constructor(e){this.audioContext=null,this.gainNode=null,this.autoUpdateBufferTimer=0,e===void 0&&(e=aw.AudioStreamFormat.getDefaultInputFormat()),this.init(e)}playAudioSample(e,t,r){try{this.ensureInitializedContext();let n=this.formatAudioData(e),s=new Float32Array(this.samples.length+n.length);s.set(this.samples,0),s.set(n,this.samples.length),this.samples=s,t&&t()}catch(n){r&&r(n)}}stopAudio(e,t){this.audioContext!==null&&(this.samples=new Float32Array,clearInterval(this.autoUpdateBufferTimer),this.audioContext.close().then(()=>{e&&e()},r=>{t&&t(r)}),this.audioContext=null)}init(e){this.audioFormat=e,this.samples=new Float32Array}ensureInitializedContext(){if(this.audioContext===null){this.createAudioContext();let e=200;this.autoUpdateBufferTimer=setInterval(()=>{this.updateAudioBuffer()},e)}}createAudioContext(){this.audioContext=cw.AudioStreamFormatImpl.getAudioContext(),this.gainNode=this.audioContext.createGain(),this.gainNode.gain.value=1,this.gainNode.connect(this.audioContext.destination),this.startTime=this.audioContext.currentTime}formatAudioData(e){switch(this.audioFormat.bitsPerSample){case 8:return this.formatArrayBuffer(new Int8Array(e),128);case 16:return this.formatArrayBuffer(new Int16Array(e),32768);case 32:return this.formatArrayBuffer(new Int32Array(e),2147483648);default:throw new ow.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time")}}formatArrayBuffer(e,t){let r=new Float32Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]/t;return r}updateAudioBuffer(){if(this.samples.length===0)return;let e=this.audioFormat.channels,t=this.audioContext.createBufferSource(),r=this.samples.length/e,n=this.audioContext.createBuffer(e,r,this.audioFormat.samplesPerSec);for(let s=0;s<e;s++){let o=s,a=n.getChannelData(s);for(let c=0;c<this.samples.length;c++,o+=e)a[c]=this.samples[o]}this.startTime<this.audioContext.currentTime&&(this.startTime=this.audioContext.currentTime),t.buffer=n,t.connect(this.gainNode),t.start(this.startTime),this.startTime+=n.duration,this.samples=new Float32Array}async playAudio(e){this.audioContext===null&&this.createAudioContext();let t=this.audioContext.createBufferSource(),r=this.audioContext.destination;await this.audioContext.decodeAudioData(e,n=>{t.buffer=n,t.connect(r),t.start(0)})}};Ca.BaseAudioPlayer=Oh});var nS=p(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});Pa.ConnectionMessageEventArgs=void 0;var kh=class{constructor(e){this.privConnectionMessage=e}get message(){return this.privConnectionMessage}toString(){return"Message: "+this.privConnectionMessage.toString()}};Pa.ConnectionMessageEventArgs=kh});var sS=p(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.VoiceProfile=void 0;var Mh=class{constructor(e,t){this.privId=e,this.privProfileType=t}get profileId(){return this.privId}get profileType(){return this.privProfileType}};Ra.VoiceProfile=Mh});var aS=p(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.VoiceProfileEnrollmentCancellationDetails=Di.VoiceProfileEnrollmentResult=void 0;var oS=C(),fe=f(),Dh=class i{constructor(e,t,r){this.privReason=e,this.privProperties=new fe.PropertyCollection,this.privReason!==fe.ResultReason.Canceled?t&&(this.privDetails=JSON.parse(t),this.privDetails.enrollmentStatus.toLowerCase()==="enrolling"&&(this.privReason=fe.ResultReason.EnrollingVoiceProfile)):(this.privErrorDetails=r,this.privProperties.setProperty(oS.CancellationErrorCodePropertyName,fe.CancellationErrorCode[fe.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get enrollmentsCount(){return this.privDetails.enrollmentsCount}get enrollmentsLength(){return this.privDetails.enrollmentsLength}get properties(){return this.privProperties}get enrollmentResultDetails(){return this.privDetails}get errorDetails(){return this.privErrorDetails}static FromIdentificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?fe.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?fe.ResultReason.EnrolledVoiceProfile:fe.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getIdentificationDetails(r),t.push(s)}return t}static FromVerificationProfileList(e){let t=[];for(let r of e.value){let n=r.enrollmentStatus.toLowerCase()==="enrolling"?fe.ResultReason.EnrollingVoiceProfile:r.enrollmentStatus.toLowerCase()==="enrolled"?fe.ResultReason.EnrolledVoiceProfile:fe.ResultReason.Canceled,s=new i(n,null,null);s.privDetails=this.getVerificationDetails(r),t.push(s)}return t}static getIdentificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount||0,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.identificationProfileId,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}static getVerificationDetails(e){return{audioLength:e.audioLength?parseFloat(e.audioLength):0,audioSpeechLength:e.audioSpeechLength?parseFloat(e.audioSpeechLength):0,enrollmentStatus:e.enrollmentStatus,enrollmentsCount:e.enrollmentsCount,enrollmentsLength:e.enrollmentsLength?parseFloat(e.enrollmentsLength):0,enrollmentsSpeechLength:e.enrollmentsSpeechLength?parseFloat(e.enrollmentsSpeechLength):0,profileId:e.profileId||e.verificationProfileId,remainingEnrollmentsCount:e.remainingEnrollments||e.remainingEnrollmentsCount,remainingEnrollmentsSpeechLength:e.remainingEnrollmentsSpeechLength?parseFloat(e.remainingEnrollmentsSpeechLength):0}}};Di.VoiceProfileEnrollmentResult=Dh;var xh=class i extends fe.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=fe.CancellationReason.Error,r=fe.CancellationErrorCode.NoError;return e.properties&&(r=fe.CancellationErrorCode[e.properties.getProperty(oS.CancellationErrorCodePropertyName,fe.CancellationErrorCode[fe.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Di.VoiceProfileEnrollmentCancellationDetails=xh});var uS=p(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.VoiceProfileCancellationDetails=xi.VoiceProfileResult=void 0;var cS=C(),uw=_(),bt=f(),Nh=class{constructor(e,t){this.privReason=e,this.privProperties=new bt.PropertyCollection,e===bt.ResultReason.Canceled&&(uw.Contracts.throwIfNullOrUndefined(t,"statusText"),this.privErrorDetails=t,this.privProperties.setProperty(cS.CancellationErrorCodePropertyName,bt.CancellationErrorCode[bt.CancellationErrorCode.ServiceError]))}get reason(){return this.privReason}get properties(){return this.privProperties}get errorDetails(){return this.privErrorDetails}};xi.VoiceProfileResult=Nh;var qh=class i extends bt.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=bt.CancellationReason.Error,r=bt.CancellationErrorCode.NoError;return e.properties&&(r=bt.CancellationErrorCode[e.properties.getProperty(cS.CancellationErrorCodePropertyName,bt.CancellationErrorCode[bt.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};xi.VoiceProfileCancellationDetails=qh});var pS=p(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.VoiceProfilePhraseResult=void 0;var pw=_(),lw=f(),jh=class extends lw.VoiceProfileResult{constructor(e,t,r,n){super(e,t),this.privPhrases=[],pw.Contracts.throwIfNullOrUndefined(n,"phrase array"),this.privType=r,n&&n[0]&&(this.privPhrases=n)}get phrases(){return this.privPhrases}get type(){return this.privType}};Ea.VoiceProfilePhraseResult=jh});var lS=p(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.VoiceProfileClient=void 0;var zh=C(),hw=Ml(),_a=_(),$r=f(),Lh=class extends $r.Recognizer{constructor(e){_a.Contracts.throwIfNullOrUndefined(e,"speechConfig");let t=e;_a.Contracts.throwIfNull(t,"speechConfig"),super(hw.AudioConfig.fromStreamInput($r.AudioInputStream.createPushStream()),t.properties,new zh.VoiceProfileConnectionFactory),this.privProperties=t.properties.clone(),this.privVoiceAdapter=this.privReco,this.privDisposedVoiceAdapter=!1}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty($r.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){_a.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty($r.PropertyId.SpeechServiceAuthorization_Token,e)}async createProfileAsync(e,t){let r=await this.privVoiceAdapter.createProfile(e,t);return new $r.VoiceProfile(r[0],e)}async retrieveEnrollmentResultAsync(e){return this.privVoiceAdapter.retrieveEnrollmentResult(e)}async getAllProfilesAsync(e){return this.privVoiceAdapter.getAllProfiles(e)}async getActivationPhrasesAsync(e,t){return this.privVoiceAdapter.getActivationPhrases(e,t)}async enrollProfileAsync(e,t){let r=t;return _a.Contracts.throwIfNullOrUndefined(r,"audioConfig"),this.audioConfig=t,this.privVoiceAdapter.SpeakerAudioSource=r,this.privVoiceAdapter.enrollProfile(e)}async deleteProfileAsync(e){return this.privVoiceAdapter.deleteProfile(e)}async resetProfileAsync(e){return this.privVoiceAdapter.resetProfile(e)}async close(){await this.dispose(!0)}createServiceRecognizer(e,t,r,n){let s=r;return new zh.VoiceServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedVoiceAdapter||(this.privDisposedVoiceAdapter=!0,e&&await super.dispose(e))}createRecognizerConfig(e){return new zh.RecognizerConfig(e,this.properties)}getResult(e,t){return new $r.VoiceProfileResult(e.ok?t:$r.ResultReason.Canceled,e.statusText)}};Ia.VoiceProfileClient=Lh});var hS=p(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.SpeakerRecognizer=void 0;var Bh=C(),Qr=_(),Fh=f(),Vh=class extends Fh.Recognizer{constructor(e,t){Qr.Contracts.throwIfNullOrUndefined(e,"speechConfig");let r=e;Qr.Contracts.throwIfNullOrUndefined(r,"speechConfig"),super(t,r.properties,new Bh.SpeakerRecognitionConnectionFactory),this.privAudioConfigImpl=t,Qr.Contracts.throwIfNull(this.privAudioConfigImpl,"audioConfig"),this.privDisposedSpeakerRecognizer=!1,this.privProperties=r.properties}get authorizationToken(){return this.properties.getProperty(Fh.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Qr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Fh.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}async recognizeOnceAsync(e){return Qr.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),this.recognizeSpeakerOnceAsyncImpl(e)}async close(){Qr.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.dispose(!0)}async recognizeSpeakerOnceAsyncImpl(e){Qr.Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer),await this.implRecognizerStop();let t=await this.privReco.recognizeSpeaker(e);return await this.implRecognizerStop(),t}async implRecognizerStop(){this.privReco&&await this.privReco.stopRecognizing()}createRecognizerConfig(e){return new Bh.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Bh.SpeakerServiceRecognizer(e,t,s,n,this)}async dispose(e){this.privDisposedSpeakerRecognizer||e&&(this.privDisposedSpeakerRecognizer=!0,await super.dispose(e))}};wa.SpeakerRecognizer=Vh});var dS=p(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.SpeakerIdentificationModel=void 0;var dw=_(),vw=f(),Uh=class i{constructor(e){if(this.privVoiceProfiles=[],this.privProfileIds=[],dw.Contracts.throwIfNullOrUndefined(e,"VoiceProfiles"),e.length===0)throw new Error("Empty Voice Profiles array");for(let t of e){if(t.profileType!==vw.VoiceProfileType.TextIndependentIdentification)throw new Error("Identification model can only be created from Identification profile: "+t.profileId);this.privVoiceProfiles.push(t),this.privProfileIds.push(t.profileId)}}static fromProfiles(e){return new i(e)}get voiceProfileIds(){return this.privProfileIds.join(",")}get profileIds(){return this.privProfileIds}get scenario(){return"TextIndependentIdentification"}};ba.SpeakerIdentificationModel=Uh});var fS=p(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.SpeakerVerificationModel=void 0;var fw=_(),vS=f(),Wh=class i{constructor(e){if(fw.Contracts.throwIfNullOrUndefined(e,"VoiceProfile"),e.profileType===vS.VoiceProfileType.TextIndependentIdentification)throw new Error("Verification model cannot be created from Identification profile");this.privVoiceProfile=e}static fromProfile(e){return new i(e)}get voiceProfile(){return this.privVoiceProfile}get profileIds(){return[this.voiceProfile.profileId]}get scenario(){return this.voiceProfile.profileType===vS.VoiceProfileType.TextDependentVerification?"TextDependentVerification":"TextIndependentVerification"}};Aa.SpeakerVerificationModel=Wh});var Hh=p(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});Kn.LanguageIdMode=void 0;var gw;(function(i){i[i.AtStart=0]="AtStart",i[i.Continuous=1]="Continuous"})(gw=Kn.LanguageIdMode||(Kn.LanguageIdMode={}))});var mS=p(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.AutoDetectSourceLanguageConfig=void 0;var mw=C(),yw=_(),At=f(),gS=Hh(),Kh=class i{constructor(){this.privProperties=new At.PropertyCollection,this.privProperties.setProperty(At.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart"),this.privLanguageIdMode=gS.LanguageIdMode.AtStart}static fromOpenRange(){let e=new i;return e.properties.setProperty(At.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,mw.AutoDetectSourceLanguagesOpenRangeOptionName),e}static fromLanguages(e){yw.Contracts.throwIfArrayEmptyOrWhitespace(e,"languages");let t=new i;return t.properties.setProperty(At.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,e.join()),t}static fromSourceLanguageConfigs(e){if(e.length<1)throw new Error("Expected non-empty SourceLanguageConfig array.");let t=new i,r=[];return e.forEach(n=>{if(r.push(n.language),n.endpointId!==void 0&&n.endpointId!==""){let s=n.language+At.PropertyId.SpeechServiceConnection_EndpointId.toString();t.properties.setProperty(s,n.endpointId)}}),t.properties.setProperty(At.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,r.join()),t}get properties(){return this.privProperties}set mode(e){e===gS.LanguageIdMode.Continuous?(this.privProperties.setProperty(At.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privProperties.setProperty(At.PropertyId.SpeechServiceConnection_LanguageIdMode,"Continuous")):(this.privProperties.setProperty(At.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"1"),this.privProperties.setProperty(At.PropertyId.SpeechServiceConnection_LanguageIdMode,"AtStart")),this.privLanguageIdMode=e}};Ta.AutoDetectSourceLanguageConfig=Kh});var SS=p(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.AutoDetectSourceLanguageResult=void 0;var yS=_(),Jh=class i{constructor(e,t){yS.Contracts.throwIfNullOrUndefined(e,"language"),yS.Contracts.throwIfNullOrUndefined(t,"languageDetectionConfidence"),this.privLanguage=e,this.privLanguageDetectionConfidence=t}static fromResult(e){return new i(e.language,e.languageDetectionConfidence)}static fromConversationTranscriptionResult(e){return new i(e.language,e.languageDetectionConfidence)}get language(){return this.privLanguage}get languageDetectionConfidence(){return this.privLanguageDetectionConfidence}};Oa.AutoDetectSourceLanguageResult=Jh});var CS=p(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});ka.SourceLanguageConfig=void 0;var Sw=_(),Gh=class i{constructor(e,t){Sw.Contracts.throwIfNullOrUndefined(e,"language"),this.privLanguage=e,this.privEndpointId=t}static fromLanguage(e,t){return new i(e,t)}get language(){return this.privLanguage}get endpointId(){return this.privEndpointId}};ka.SourceLanguageConfig=Gh});var RS=p(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.SpeakerRecognitionCancellationDetails=Qt.SpeakerRecognitionResult=Qt.SpeakerRecognitionResultType=void 0;var PS=C(),je=f(),Ma;(function(i){i[i.Verify=0]="Verify",i[i.Identify=1]="Identify"})(Ma=Qt.SpeakerRecognitionResultType||(Qt.SpeakerRecognitionResultType={}));var $h=class{constructor(e,t=je.ResultReason.RecognizedSpeaker,r=je.CancellationErrorCode.NoError,n=""){this.privProperties=new je.PropertyCollection;let s=e.scenario==="TextIndependentIdentification"?Ma.Identify:Ma.Verify;this.privReason=t,this.privReason!==je.ResultReason.Canceled?s===Ma.Identify?(this.privProfileId=e.identificationResult.identifiedProfile.profileId,this.privScore=e.identificationResult.identifiedProfile.score,this.privReason=je.ResultReason.RecognizedSpeakers):(this.privScore=e.verificationResult.score,e.verificationResult.recognitionResult.toLowerCase()!=="accept"&&(this.privReason=je.ResultReason.NoMatch),e.verificationResult.profileId!==void 0&&e.verificationResult.profileId!==""&&(this.privProfileId=e.verificationResult.profileId)):(this.privErrorDetails=n,this.privProperties.setProperty(PS.CancellationErrorCodePropertyName,je.CancellationErrorCode[r])),this.privProperties.setProperty(je.PropertyId.SpeechServiceResponse_JsonResult,JSON.stringify(e))}get properties(){return this.privProperties}get reason(){return this.privReason}get profileId(){return this.privProfileId}get errorDetails(){return this.privErrorDetails}get score(){return this.privScore}};Qt.SpeakerRecognitionResult=$h;var Qh=class i extends je.CancellationDetailsBase{constructor(e,t,r){super(e,t,r)}static fromResult(e){let t=je.CancellationReason.Error,r=je.CancellationErrorCode.NoError;return e.properties&&(r=je.CancellationErrorCode[e.properties.getProperty(PS.CancellationErrorCodePropertyName,je.CancellationErrorCode[je.CancellationErrorCode.NoError])]),new i(t,e.errorDetails,r)}};Qt.SpeakerRecognitionCancellationDetails=Qh});var Xh=p(Ni=>{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});Ni.ConversationImpl=Ni.Conversation=void 0;var q=C(),Jn=P(),y=_(),N=f(),Da=class{constructor(){}static createConversationAsync(e,t,r,n){y.Contracts.throwIfNullOrUndefined(e,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),y.Contracts.throwIfNullOrUndefined(e.region,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),!e.subscriptionKey&&!e.getProperty(N.PropertyId[N.PropertyId.SpeechServiceAuthorization_Token])&&y.Contracts.throwIfNullOrUndefined(e.subscriptionKey,q.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s,o,a;return typeof t=="string"?(s=new Gn(e,t),Jn.marshalPromiseToCallbacks((async()=>{})(),r,n)):(s=new Gn(e),o=t,a=r,s.createConversationAsync(()=>{o&&o()},c=>{a&&a(c)})),s}};Ni.Conversation=Da;var Gn=class extends Da{constructor(e,t){if(super(),this.privErrors=q.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case q.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case q.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case q.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case q.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case q.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new N.ConversationParticipantsChangedEventArgs(N.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new N.ConversationParticipantsChangedEventArgs(N.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new N.ConversationParticipantsChangedEventArgs(N.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new N.ConversationParticipantsChangedEventArgs(N.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case q.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new N.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new N.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case q.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new N.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new N.ConversationParticipantsChangedEventArgs(N.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(N.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new N.PropertyCollection,this.privManager=new q.ConversationManager,e.getProperty(N.PropertyId[N.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(N.PropertyId[N.PropertyId.SpeechServiceConnection_RecoLanguage],q.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(N.PropertyId[N.PropertyId.SpeechServiceConnection_RecoLanguage]),t)this.privConversationId=t;else{e.targetLanguages.length===0&&e.addTargetLanguage(this.privLanguage),e.getProperty(N.PropertyId[N.PropertyId.SpeechServiceResponse_ProfanityOption])||e.setProfanity(N.ProfanityOption.Masked);let o=e.getProperty(N.PropertyId[N.PropertyId.ConversationTranslator_Name]);o==null&&(o="Host"),y.Contracts.throwIfNullOrTooLong(o,"nickname",50),y.Contracts.throwIfNullOrTooShort(o,"nickname",2),e.setProperty(N.PropertyId[N.PropertyId.ConversationTranslator_Name],o)}this.privConfig=e;let n=e;y.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new q.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get conversationId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get conversationInfo(){let e=this.conversationId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of q.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,conversationProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){y.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}set conversationTranslator(e){this.privConversationTranslator=e}onToken(e){this.privConversationTranslator.onToken(e)}createConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startConversationAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer=q.ConversationRecognizerFactory.fromConfig(this,this.privConfig),this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.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,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){y.Contracts.throwIfNullOrUndefined(e,"Participant"),Jn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinConversationAsync(e,t,r,n,s){try{y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),y.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{y.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteConversationAsync(e,t){Jn.marshalPromiseToCallbacks(this.deleteConversationImplAsync(),e,t)}async deleteConversationImplAsync(){y.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),y.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endConversationAsync(e,t){Jn.marshalPromiseToCallbacks(this.endConversationImplAsync(),e,t)}endConversationImplAsync(){return this.close(!0)}lockConversationAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(y.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Jn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),y.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockConversationAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{y.Contracts.throwIfDisposed(this.privIsDisposed),y.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),y.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),y.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),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.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.conversation=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.conversationInfo;return r.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.conversationInfo;return t.participants=[e],this.privTranscriberRecognizer.pushConversationEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new N.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(e,"nickname"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:q.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:q.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return y.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),y.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),y.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:q.ConversationTranslatorMessageTypes.instantMessage})}};Ni.ConversationImpl=Gn});var ES=p(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.ConversationCommon=void 0;var Zh=class{constructor(e){this.privAudioConfig=e}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}};xa.ConversationCommon=Zh});var _S=p(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.ConversationExpirationEventArgs=void 0;var Cw=f(),Yh=class extends Cw.SessionEventArgs{constructor(e,t){super(t),this.privExpirationTime=e}get expirationTime(){return this.privExpirationTime}};Na.ConversationExpirationEventArgs=Yh});var IS=p(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.ConversationParticipantsChangedEventArgs=void 0;var Pw=f(),ed=class extends Pw.SessionEventArgs{constructor(e,t,r){super(r),this.privReason=e,this.privParticipant=t}get reason(){return this.privReason}get participants(){return this.privParticipant}};qa.ConversationParticipantsChangedEventArgs=ed});var wS=p(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.ConversationTranslationCanceledEventArgs=void 0;var Rw=Ii(),td=class extends Rw.CancellationEventArgsBase{};ja.ConversationTranslationCanceledEventArgs=td});var bS=p(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.ConversationTranslationEventArgs=void 0;var Ew=f(),rd=class extends Ew.RecognitionEventArgs{constructor(e,t,r){super(t,r),this.privResult=e}get result(){return this.privResult}};za.ConversationTranslationEventArgs=rd});var AS=p(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.ConversationTranslationResult=void 0;var _w=$l(),id=class extends _w.TranslationRecognitionResult{constructor(e,t,r,n,s,o,a,c,u,l,h){super(t,n,s,o,a,c,void 0,void 0,u,l,h),this.privId=e,this.privOrigLang=r}get participantId(){return this.privId}get originalLang(){return this.privOrigLang}};La.ConversationTranslationResult=id});var sd=p(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.StringUtils=void 0;var nd=class{static formatString(e,t){if(!e)return"";if(!t)return e;let r="",n="",s=c=>{r+=c},o=c=>{n+=c},a=s;for(let c=0;c<e.length;c++){let u=e[c],l=c+1<e.length?e[c+1]:"";switch(u){case"{":l==="{"?(a("{"),c++):a=o;break;case"}":l==="}"?(a("}"),c++):(t.hasOwnProperty(n)&&(r+=t[n]),a=s,n="");break;default:a(u);break}}return r}};Ba.StringUtils=nd});var kS=p(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.ConversationTranslatorConnectionFactory=void 0;var od=ce(),TS=sd(),Iw=_(),Fa=f(),ww=Ie(),Ye=$t(),OS=Ze(),ad=C(),Va=class i extends OS.ConnectionFactoryBase{constructor(e){super(),Iw.Contracts.throwIfNullOrUndefined(e,"convGetter"),this.privConvGetter=e}create(e,t,r){let n=e.parameters.getProperty("ConversationTranslator_MultiChannelAudio","").toUpperCase()==="TRUE",s=this.privConvGetter().room,o=s.cognitiveSpeechRegion||e.parameters.getProperty(Fa.PropertyId.SpeechServiceConnection_Region,""),a={hostSuffix:OS.ConnectionFactoryBase.getHostSuffix(o),path:i.CTS_VIRT_MIC_PATH,region:encodeURIComponent(o)};a[Ye.QueryParameterNames.Language]=encodeURIComponent(e.parameters.getProperty(Fa.PropertyId.SpeechServiceConnection_RecoLanguage,"")),a[Ye.QueryParameterNames.CtsMeetingId]=encodeURIComponent(s.roomId),a[Ye.QueryParameterNames.CtsDeviceId]=encodeURIComponent(s.participantId),a[Ye.QueryParameterNames.CtsIsParticipant]=s.isHost?"":"&"+Ye.QueryParameterNames.CtsIsParticipant;let c="",u={},l={};if(n){c=e.parameters.getProperty(Fa.PropertyId.SpeechServiceConnection_Endpoint),c||(c="wss://"+e.parameters.getProperty(Fa.PropertyId.SpeechServiceConnection_Host,"transcribe.{region}.cts.speech{hostSuffix}")+"{path}"),c=TS.StringUtils.formatString(c,a);let d=new URL(c);d.searchParams.forEach((M,D)=>{u[D]=M}),new ad.TranscriberConnectionFactory().setQueryParams(u,e,c),u[Ye.QueryParameterNames.CtsMeetingId]=a[Ye.QueryParameterNames.CtsMeetingId],u[Ye.QueryParameterNames.CtsDeviceId]=a[Ye.QueryParameterNames.CtsDeviceId],s.isHost||(u[Ye.QueryParameterNames.CtsIsParticipant]=""),Ye.QueryParameterNames.Format in u||(u[Ye.QueryParameterNames.Format]="simple"),d.searchParams.forEach((M,D)=>{d.searchParams.set(D,u[D]),delete u[D]}),c=d.toString()}else{let d=new ad.TranslationConnectionFactory;c=d.getEndpointUrl(e,!0),c=TS.StringUtils.formatString(c,a),d.setQueryParams(u,e,c)}l[ww.HeaderNames.ConnectionId]=r,l[od.RestConfigBase.configParams.token]=s.token,t.token&&(l[t.headerName]=t.token);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","").toUpperCase()==="TRUE";return new od.WebsocketConnection(c,u,l,new ad.WebsocketMessageFormatter,od.ProxyInfo.fromRecognizerConfig(e),h,r)}};Ua.ConversationTranslatorConnectionFactory=Va;Va.CTS_VIRT_MIC_PATH="/speech/recognition/dynamicaudio"});var DS=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.ConversationTranslator=Xr.SpeechState=void 0;var $n=C(),bw=kS(),Wa=P(),dt=_(),V=f(),Aw=Xh(),MS=Ha(),vt;(function(i){i[i.Inactive=0]="Inactive",i[i.Connecting=1]="Connecting",i[i.Connected=2]="Connected"})(vt=Xr.SpeechState||(Xr.SpeechState={}));var cd=class extends V.TranslationRecognizer{constructor(e,t,r,n){super(e,t,new bw.ConversationTranslatorConnectionFactory(n)),this.privSpeechState=vt.Inactive,r&&(this.privTranslator=r,this.sessionStarted=()=>{this.privSpeechState=vt.Connected},this.sessionStopped=()=>{this.privSpeechState=vt.Inactive},this.recognizing=(s,o)=>{this.privTranslator.recognizing&&this.privTranslator.recognizing(this.privTranslator,o)},this.recognized=async(s,o)=>{o.result?.errorDetails?(await this.cancelSpeech(),this.fireCancelEvent(o.result.errorDetails)):this.privTranslator.recognized&&this.privTranslator.recognized(this.privTranslator,o)},this.canceled=async()=>{if(this.privSpeechState!==vt.Inactive)try{await this.cancelSpeech()}catch{this.privSpeechState=vt.Inactive}})}get state(){return this.privSpeechState}set state(e){this.privSpeechState=e}set authentication(e){this.privReco.authentication=e}onConnection(){this.privSpeechState=vt.Connected}async onCancelSpeech(){this.privSpeechState=vt.Inactive,await this.cancelSpeech()}fireCancelEvent(e){try{if(this.privTranslator.canceled){let t=new MS.ConversationTranslationCanceledEventArgs(V.CancellationReason.Error,e,V.CancellationErrorCode.RuntimeError);this.privTranslator.canceled(this.privTranslator,t)}}catch{}}async cancelSpeech(){try{this.stopContinuousRecognitionAsync(),await this.privReco?.disconnect(),this.privSpeechState=vt.Inactive}catch{}}},ud=class extends MS.ConversationCommon{constructor(e){super(e),this.privErrors=$n.ConversationConnectionConfig.restErrors,this.privIsDisposed=!1,this.privIsSpeaking=!1,this.privPlaceholderKey="abcdefghijklmnopqrstuvwxyz012345",this.privPlaceholderRegion="westus",this.privProperties=new V.PropertyCollection}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get participants(){return this.privConversation?.participants}get canSpeak(){return!(!this.privConversation.isConnected||!this.privCTRecognizer||this.privIsSpeaking||this.privCTRecognizer.state===vt.Connected||this.privCTRecognizer.state===vt.Connecting||this.privConversation.isMutedByHost)}onToken(e){this.privCTRecognizer.authentication=e}setServiceProperty(e,t){let r=JSON.parse(this.privProperties.getProperty($n.ServicePropertiesPropertyName,"{}"));r[e]=t,this.privProperties.setProperty($n.ServicePropertiesPropertyName,JSON.stringify(r))}joinConversationAsync(e,t,r,n,s){try{if(typeof e=="string"){dt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),dt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privConversation&&this.handleError(new Error(this.privErrors.permissionDeniedStart),s);let o=r;(o==null||o==="")&&(o=$n.ConversationConnectionConfig.defaultLanguageCode),this.privSpeechTranslationConfig=V.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey,this.privPlaceholderRegion),this.privSpeechTranslationConfig.setProfanity(V.ProfanityOption.Masked),this.privSpeechTranslationConfig.addTargetLanguage(o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_RecoLanguage],o),this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.ConversationTranslator_Name],t);let a=[V.PropertyId.SpeechServiceConnection_Host,V.PropertyId.ConversationTranslator_Host,V.PropertyId.SpeechServiceConnection_Endpoint,V.PropertyId.SpeechServiceConnection_ProxyHostName,V.PropertyId.SpeechServiceConnection_ProxyPassword,V.PropertyId.SpeechServiceConnection_ProxyPort,V.PropertyId.SpeechServiceConnection_ProxyUserName,"ConversationTranslator_MultiChannelAudio","ConversationTranslator_Region"];for(let u of a){let l=this.privProperties.getProperty(u);if(l){let h=typeof u=="string"?u:V.PropertyId[u];this.privSpeechTranslationConfig.setProperty(h,l)}}let c=JSON.parse(this.privProperties.getProperty($n.ServicePropertiesPropertyName,"{}"));for(let u of Object.keys(c))this.privSpeechTranslationConfig.setServiceProperty(u,c[u],V.ServicePropertyChannel.UriQueryParameter);this.privConversation=new Aw.ConversationImpl(this.privSpeechTranslationConfig),this.privConversation.conversationTranslator=this,this.privConversation.joinConversationAsync(e,t,o,u=>{u||this.handleError(new Error(this.privErrors.permissionDeniedConnect),s),this.privSpeechTranslationConfig.authorizationToken=u,this.privConversation.room.isHost=!1,this.privConversation.startConversationAsync(()=>{this.handleCallback(n,s)},l=>{this.handleError(l,s)})},u=>{this.handleError(u,s)})}else typeof e=="object"?(dt.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","conversation id")),dt.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),this.privProperties.setProperty(V.PropertyId.ConversationTranslator_Name,t),this.privConversation=e,this.privConversation.conversationTranslator=this,this.privConversation.room.isHost=!0,dt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedConnect),dt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privSpeechTranslationConfig=e.config,this.handleCallback(r,n)):this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","invalid conversation type")),n)}catch(o){this.handleError(o,typeof r=="string"?s:n)}}leaveConversationAsync(e,t){Wa.marshalPromiseToCallbacks((async()=>{await this.cancelSpeech(),await this.privConversation.endConversationImplAsync(),await this.privConversation.deleteConversationImplAsync(),this.dispose()})(),e,t)}sendTextMessageAsync(e,t,r){try{dt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),dt.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}",e)),this.privConversation.sendTextMessageAsync(e,t,r)}catch(n){this.handleError(n,r)}}startTranscribingAsync(e,t){Wa.marshalPromiseToCallbacks((async()=>{try{dt.Contracts.throwIfNullOrUndefined(this.privConversation,this.privErrors.permissionDeniedSend),dt.Contracts.throwIfNullOrUndefined(this.privConversation.room.token,this.privErrors.permissionDeniedConnect),this.privCTRecognizer===void 0&&await this.connectTranslatorRecognizer(),dt.Contracts.throwIfNullOrUndefined(this.privCTRecognizer,this.privErrors.permissionDeniedSend),this.canSpeak||this.handleError(new Error(this.privErrors.permissionDeniedSend),t),await this.startContinuousRecognition(),this.privIsSpeaking=!0}catch(r){throw this.privIsSpeaking=!1,await this.cancelSpeech(),r}})(),e,t)}stopTranscribingAsync(e,t){Wa.marshalPromiseToCallbacks((async()=>{try{if(!this.privIsSpeaking){await this.cancelSpeech();return}this.privIsSpeaking=!1,await new Promise((r,n)=>{this.privCTRecognizer.stopContinuousRecognitionAsync(r,n)})}catch{await this.cancelSpeech()}})(),e,t)}isDisposed(){return this.privIsDisposed}dispose(e,t,r){Wa.marshalPromiseToCallbacks((async()=>{this.isDisposed&&!this.privIsSpeaking||(await this.cancelSpeech(),this.privIsDisposed=!0,this.privSpeechTranslationConfig.close(),this.privSpeechRecognitionLanguage=void 0,this.privProperties=void 0,this.privAudioConfig=void 0,this.privSpeechTranslationConfig=void 0,this.privConversation.dispose(),this.privConversation=void 0)})(),t,r)}async cancelSpeech(){try{this.privIsSpeaking=!1,await this.privCTRecognizer?.onCancelSpeech(),this.privCTRecognizer=void 0}catch{}}async connectTranslatorRecognizer(){try{this.privAudioConfig===void 0&&(this.privAudioConfig=V.AudioConfig.fromDefaultMicrophoneInput()),this.privSpeechTranslationConfig.getProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key])===this.privPlaceholderKey&&this.privSpeechTranslationConfig.setProperty(V.PropertyId[V.PropertyId.SpeechServiceConnection_Key],"");let e=()=>this.privConversation;this.privCTRecognizer=new cd(this.privSpeechTranslationConfig,this.privAudioConfig,this,e)}catch(e){throw await this.cancelSpeech(),e}}startContinuousRecognition(){return new Promise((e,t)=>{this.privCTRecognizer.startContinuousRecognitionAsync(e,t)})}};Xr.ConversationTranslator=ud});var xS=p(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.ConversationTranscriber=void 0;var Qn=C(),pd=P(),Zr=_(),ke=f(),ld=class i extends ke.Recognizer{constructor(e,t){let r=e;Zr.Contracts.throwIfNull(r,"speechConfig"),Zr.Contracts.throwIfNullOrWhitespace(r.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage),ke.PropertyId[ke.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Qn.ConversationTranscriberConnectionFactory),this.privProperties.setProperty(ke.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,"2"),this.privDisposedRecognizer=!1}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}get endpointId(){return Zr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_EndpointId,"00000000-0000-0000-0000-000000000000")}get authorizationToken(){return this.properties.getProperty(ke.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Zr.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(ke.PropertyId.SpeechServiceAuthorization_Token,e)}get speechRecognitionLanguage(){return Zr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(ke.PropertyId.SpeechServiceConnection_RecoLanguage)}get outputFormat(){return Zr.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Qn.OutputFormatPropertyName,ke.OutputFormat[ke.OutputFormat.Simple])===ke.OutputFormat[ke.OutputFormat.Simple]?ke.OutputFormat.Simple:ke.OutputFormat.Detailed}get properties(){return this.privProperties}startTranscribingAsync(e,t){pd.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Qn.RecognitionMode.Conversation),e,t)}stopTranscribingAsync(e,t){pd.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}close(e,t){Zr.Contracts.throwIfDisposed(this.privDisposedRecognizer),pd.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Qn.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return n.isSpeakerDiarizationEnabled=!0,new Qn.ConversationTranscriptionServiceRecognizer(e,t,s,n,this)}};Ka.ConversationTranscriber=ld});var NS=p(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});qi.Participant=qi.User=void 0;var Tw=f(),hd=class{constructor(e){this.privUserId=e}get userId(){return this.privUserId}};qi.User=hd;var dd=class i{constructor(e,t,r,n,s,o,a,c){this.privId=e,this.privAvatar=t,this.privDisplayName=r,this.privIsHost=n,this.privIsMuted=s,this.privIsUsingTts=o,this.privPreferredLanguage=a,this.privVoice=c,this.privProperties=new Tw.PropertyCollection}get avatar(){return this.privAvatar}get displayName(){return this.privDisplayName}get id(){return this.privId}get preferredLanguage(){return this.privPreferredLanguage}get isHost(){return this.privIsHost}get isMuted(){return this.privIsMuted}get isUsingTts(){return this.privIsUsingTts}get voice(){return this.privVoice}get properties(){return this.privProperties}static From(e,t,r){return new i(e,"",e,!1,!1,!1,t,r)}};qi.Participant=dd});var qS=p(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.ParticipantChangedReason=void 0;var Ow;(function(i){i[i.JoinedConversation=0]="JoinedConversation",i[i.LeftConversation=1]="LeftConversation",i[i.Updated=2]="Updated"})(Ow=Xn.ParticipantChangedReason||(Xn.ParticipantChangedReason={}))});var jS=p(ji=>{"use strict";Object.defineProperty(ji,"__esModule",{value:!0});ji.MeetingImpl=ji.Meeting=void 0;var z=C(),Zn=P(),S=_(),H=f(),Ja=class{constructor(){}static createMeetingAsync(e,t,r,n){if(S.Contracts.throwIfNullOrUndefined(e,z.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","config")),S.Contracts.throwIfNullOrUndefined(e.region,z.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Region")),S.Contracts.throwIfNull(t,"meetingId"),t.length===0)throw new Error("meetingId cannot be empty");!e.subscriptionKey&&!e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceAuthorization_Token])&&S.Contracts.throwIfNullOrUndefined(e.subscriptionKey,z.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}","SpeechServiceConnection_Key"));let s=new Ga(e,t);return Zn.marshalPromiseToCallbacks((async()=>{})(),r,n),s}};ji.Meeting=Ja;var Ga=class extends Ja{constructor(e,t){super(),this.privErrors=z.ConversationConnectionConfig.restErrors,this.onConnected=s=>{this.privIsConnected=!0;try{this.privConversationTranslator?.sessionStarted&&this.privConversationTranslator.sessionStarted(this.privConversationTranslator,s)}catch{}},this.onDisconnected=s=>{try{this.privConversationTranslator?.sessionStopped&&this.privConversationTranslator.sessionStopped(this.privConversationTranslator,s)}catch{}finally{this.close(!1)}},this.onCanceled=(s,o)=>{try{this.privConversationTranslator?.canceled&&this.privConversationTranslator.canceled(this.privConversationTranslator,o)}catch{}},this.onParticipantUpdateCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.id);if(a!==void 0){switch(o.key){case z.ConversationTranslatorCommandTypes.changeNickname:a.displayName=o.value;break;case z.ConversationTranslatorCommandTypes.setUseTTS:a.isUsingTts=o.value;break;case z.ConversationTranslatorCommandTypes.setProfanityFiltering:a.profanity=o.value;break;case z.ConversationTranslatorCommandTypes.setMute:a.isMuted=o.value;break;case z.ConversationTranslatorCommandTypes.setTranslateToLanguages:a.translateToLanguages=o.value;break}this.privParticipants.addOrUpdateParticipant(a),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,[this.toParticipant(a)],o.sessionId))}}catch{}},this.onLockRoomCommandReceived=()=>{},this.onMuteAllCommandReceived=(s,o)=>{try{this.privParticipants.participants.forEach(a=>a.isMuted=a.isHost?!1:o.isMuted),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.Updated,this.toParticipants(!1),o.sessionId))}catch{}},this.onParticipantJoinCommandReceived=(s,o)=>{try{let a=this.privParticipants.addOrUpdateParticipant(o.participant);a!==void 0&&this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,[this.toParticipant(a)],o.sessionId))}catch{}},this.onParticipantLeaveCommandReceived=(s,o)=>{try{let a=this.privParticipants.getParticipant(o.participant.id);a!==void 0&&(this.privParticipants.deleteParticipant(o.participant.id),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.LeftConversation,[this.toParticipant(a)],o.sessionId)))}catch{}},this.onTranslationReceived=(s,o)=>{try{switch(o.command){case z.ConversationTranslatorMessageTypes.final:this.privConversationTranslator&&this.privConversationTranslator.transcribed(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case z.ConversationTranslatorMessageTypes.partial:this.privConversationTranslator&&this.privConversationTranslator.transcribing(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break;case z.ConversationTranslatorMessageTypes.instantMessage:this.privConversationTranslator&&this.privConversationTranslator.textMessageReceived(this.privConversationTranslator,new H.ConversationTranslationEventArgs(o.payload,void 0,o.sessionId));break}}catch{}},this.onParticipantsListReceived=(s,o)=>{try{if(o.sessionToken!==void 0&&o.sessionToken!==null&&(this.privRoom.token=o.sessionToken),this.privParticipants.participants=[...o.participants],this.privParticipants.me!==void 0&&(this.privIsReady=!0),this.privConversationTranslator&&this.privConversationTranslator.participantsChanged(this.privConversationTranslator,new H.ConversationParticipantsChangedEventArgs(H.ParticipantChangedReason.JoinedConversation,this.toParticipants(!0),o.sessionId)),this.me.isHost){let a=this.privConversationTranslator?.properties.getProperty(H.PropertyId.ConversationTranslator_Name);a!==void 0&&a.length>0&&a!==this.me.displayName&&this.changeNicknameAsync(a)}}catch{}},this.onConversationExpiration=(s,o)=>{try{this.privConversationTranslator&&this.privConversationTranslator.conversationExpiration(this.privConversationTranslator,o)}catch{}},this.privIsConnected=!1,this.privIsDisposed=!1,this.privConversationId="",this.privProperties=new H.PropertyCollection,this.privManager=new z.ConversationManager,e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage])||e.setProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage],z.ConversationConnectionConfig.defaultLanguageCode),this.privLanguage=e.getProperty(H.PropertyId[H.PropertyId.SpeechServiceConnection_RecoLanguage]),this.privConversationId=t,this.privConfig=e;let n=e;S.Contracts.throwIfNull(n,"speechConfig"),this.privProperties=n.properties.clone(),this.privIsConnected=!1,this.privParticipants=new z.InternalParticipants,this.privIsReady=!1,this.privTextMessageMaxLength=1e3}get room(){return this.privRoom}get connection(){return this.privConversationRecognizer}get config(){return this.privConfig}get meetingId(){return this.privRoom?this.privRoom.roomId:this.privConversationId}get properties(){return this.privProperties}get speechRecognitionLanguage(){return this.privLanguage}get isMutedByHost(){return this.privParticipants.me?.isHost?!1:this.privParticipants.me?.isMuted}get isConnected(){return this.privIsConnected&&this.privIsReady}get participants(){return this.toParticipants(!0)}get me(){return this.toParticipant(this.privParticipants.me)}get host(){return this.toParticipant(this.privParticipants.host)}get transcriberRecognizer(){return this.privTranscriberRecognizer}get meetingInfo(){let e=this.meetingId,t=this.participants.map(s=>({id:s.id,preferredLanguage:s.preferredLanguage,voice:s.voice})),r={};for(let s of z.ConversationConnectionConfig.transcriptionEventKeys){let o=this.properties.getProperty(s,"");o!==""&&(r[s]=o)}return{id:e,participants:t,meetingProperties:r}}get canSend(){return this.privIsConnected&&!this.privParticipants.me?.isMuted}get canSendAsHost(){return this.privIsConnected&&this.privParticipants.me?.isHost}get authorizationToken(){return this.privToken}set authorizationToken(e){S.Contracts.throwIfNullOrWhitespace(e,"authorizationToken"),this.privToken=e}createMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),this.privManager.createOrJoin(this.privProperties,void 0,r=>{r||this.handleError(new Error(this.privErrors.permissionDeniedConnect),t),this.privRoom=r,this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}startMeetingAsync(e,t){try{this.privConversationRecognizer&&this.handleError(new Error(this.privErrors.permissionDeniedStart),t),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedConnect),this.privParticipants.meId=this.privRoom.participantId,this.privConversationRecognizer.connected=this.onConnected,this.privConversationRecognizer.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,()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}addParticipantAsync(e,t,r){S.Contracts.throwIfNullOrUndefined(e,"Participant"),Zn.marshalPromiseToCallbacks(this.addParticipantImplAsync(e),t,r)}joinMeetingAsync(e,t,r,n,s){try{S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","conversationId")),S.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrWhitespace(r,this.privErrors.invalidArgs.replace("{arg}","language")),this.privManager.createOrJoin(this.privProperties,e,o=>{S.Contracts.throwIfNullOrUndefined(o,this.privErrors.permissionDeniedConnect),this.privRoom=o,this.privConfig.authorizationToken=o.cognitiveSpeechAuthToken,n&&n(o.cognitiveSpeechAuthToken)},o=>{this.handleError(o,s)})}catch(o){this.handleError(o,s)}}deleteMeetingAsync(e,t){Zn.marshalPromiseToCallbacks(this.deleteMeetingImplAsync(),e,t)}async deleteMeetingImplAsync(){S.Contracts.throwIfNullOrUndefined(this.privProperties,this.privErrors.permissionDeniedConnect),S.Contracts.throwIfNullOrWhitespace(this.privRoom.token,this.privErrors.permissionDeniedConnect),await this.privManager.leave(this.privProperties,this.privRoom.token),this.dispose()}endMeetingAsync(e,t){Zn.marshalPromiseToCallbacks(this.endMeetingImplAsync(),e,t)}endMeetingImplAsync(){return this.close(!0)}lockMeetingAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","lock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer,this.privErrors.permissionDeniedSend),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","mute")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}muteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!0),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}removeParticipantAsync(e,t,r){try{if(S.Contracts.throwIfDisposed(this.privIsDisposed),this.privTranscriberRecognizer&&e.hasOwnProperty("id"))Zn.marshalPromiseToCallbacks(this.removeParticipantImplAsync(e),t,r);else{S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","remove")),r);let n="";typeof e=="string"?n=e:e.hasOwnProperty("id")?n=e.id:e.hasOwnProperty("userId")&&(n=e.userId),S.Contracts.throwIfNullOrWhitespace(n,this.privErrors.invalidArgs.replace("{arg}","userId")),this.participants.findIndex(o=>o.id===n)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getEjectCommand(n),()=>{this.handleCallback(t,r)},o=>{this.handleError(o,r)})}}catch(n){this.handleError(n,r)}}unlockMeetingAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unlock")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getLockCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteAllParticipantsAsync(e,t){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSendAsHost||this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}","unmute all")),t),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1),()=>{this.handleCallback(e,t)},r=>{this.handleError(r,t)})}catch(r){this.handleError(r,t)}}unmuteParticipantAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","userId")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),!this.me.isHost&&this.me.id!==e&&this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}","mute")),r),this.privParticipants.getParticipantIndex(e)===-1&&this.handleError(new Error(this.privErrors.invalidParticipantRequest),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMuteCommand(e,!1),()=>{this.handleCallback(t,r)},s=>{this.handleError(s,r)})}catch(n){this.handleError(n,r)}}sendTextMessageAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","message")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),e.length>this.privTextMessageMaxLength&&this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}","message length")),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getMessageCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}setTranslatedLanguagesAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfArrayEmptyOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","languages")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}changeNicknameAsync(e,t,r){try{S.Contracts.throwIfDisposed(this.privIsDisposed),S.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()),S.Contracts.throwIfNullOrWhitespace(e,this.privErrors.invalidArgs.replace("{arg}","nickname")),S.Contracts.throwIfNullOrUndefined(this.privRoom,this.privErrors.permissionDeniedSend),this.canSend||this.handleError(new Error(this.privErrors.permissionDeniedSend),r),this.privConversationRecognizer&&this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(e),()=>{this.handleCallback(t,r)},n=>{this.handleError(n,r)})}catch(n){this.handleError(n,r)}}isDisposed(){return this.privIsDisposed}dispose(){this.isDisposed||(this.privIsDisposed=!0,this.config&&this.config.close(),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.privIsConnected=!1,this.privIsReady=!1,this.privParticipants=void 0)}async connectTranscriberRecognizer(e){this.privTranscriberRecognizer&&await this.privTranscriberRecognizer.close(),await e.enforceAudioGating(),this.privTranscriberRecognizer=e,this.privTranscriberRecognizer.meeting=this}getKeepAlive(){let e=this.me?this.me.displayName:"default_nickname";return JSON.stringify({id:"0",nickname:e,participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.keepAlive})}addParticipantImplAsync(e){if(this.privParticipants.addOrUpdateParticipant(e)!==void 0&&this.privTranscriberRecognizer){let r=this.meetingInfo;return r.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(r,"join")}}removeParticipantImplAsync(e){this.privParticipants.deleteParticipant(e.id);let t=this.meetingInfo;return t.participants=[e],this.privTranscriberRecognizer.pushMeetingEvent(t,"leave")}async close(e){try{this.privIsConnected=!1,await this.privConversationRecognizer?.close(),this.privConversationRecognizer=void 0,this.privConversationTranslator&&this.privConversationTranslator.dispose()}catch(t){throw t}e&&this.dispose()}handleCallback(e,t){if(e){try{e()}catch(r){t&&t(r)}e=void 0}}handleError(e,t){if(t)if(e instanceof Error){let r=e;t(r.name+": "+r.message)}else t(e)}toParticipants(e){let t=this.privParticipants.participants.map(r=>this.toParticipant(r));return e?t:t.filter(r=>r.isHost===!1)}toParticipant(e){return new H.Participant(e.id,e.avatar,e.displayName,e.isHost,e.isMuted,e.isUsingTts,e.preferredLanguage,e.voice)}getMuteAllCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingd"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.setMuteAll,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMuteCommand(e,t){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"conversationId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.setMute,participantId:e,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand,value:t})}getLockCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.setLockState,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand,value:e})}getEjectCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),S.Contracts.throwIfNullOrWhitespace(e,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.ejectParticipant,participantId:e,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand})}getSetTranslateToLanguagesCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.setTranslateToLanguages,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand,value:e})}getChangeNicknameCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),S.Contracts.throwIfNullOrWhitespace(e,"nickname"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),JSON.stringify({command:z.ConversationTranslatorCommandTypes.changeNickname,nickname:e,participantId:this.privRoom.participantId,roomid:this.privRoom.roomId,type:z.ConversationTranslatorMessageTypes.participantCommand,value:e})}getMessageCommand(e){return S.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId,"meetingId"),S.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId,"participantId"),S.Contracts.throwIfNullOrWhitespace(e,"message"),JSON.stringify({participantId:this.privRoom.participantId,roomId:this.privRoom.roomId,text:e,type:z.ConversationTranslatorMessageTypes.instantMessage})}};ji.MeetingImpl=Ga});var zS=p($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.MeetingTranscriptionCanceledEventArgs=void 0;var kw=Ii(),vd=class extends kw.CancellationEventArgsBase{};$a.MeetingTranscriptionCanceledEventArgs=vd});var LS=p(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.MeetingTranscriber=void 0;var Mw=C(),fd=P(),Yn=_(),es=f(),Dw=Ha(),gd=class{constructor(e){this.privAudioConfig=e,this.privProperties=new es.PropertyCollection,this.privRecognizer=void 0,this.privDisposedRecognizer=!1}get speechRecognitionLanguage(){return Yn.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(es.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get internalData(){return this.privRecognizer.internalData}get connection(){return es.Connection.fromRecognizer(this.privRecognizer)}get authorizationToken(){return this.properties.getProperty(es.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){Yn.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(es.PropertyId.SpeechServiceAuthorization_Token,e)}joinMeetingAsync(e,t,r){let n=e;Yn.Contracts.throwIfNullOrUndefined(Dw.MeetingImpl,"Meeting"),this.privRecognizer=new Mw.TranscriberRecognizer(e.config,this.privAudioConfig),Yn.Contracts.throwIfNullOrUndefined(this.privRecognizer,"Recognizer"),this.privRecognizer.connectMeetingCallbacks(this),fd.marshalPromiseToCallbacks(n.connectTranscriberRecognizer(this.privRecognizer),t,r)}startTranscribingAsync(e,t){this.privRecognizer.startContinuousRecognitionAsync(e,t)}stopTranscribingAsync(e,t){this.privRecognizer.stopContinuousRecognitionAsync(e,t)}leaveMeetingAsync(e,t){this.privRecognizer.disconnectCallbacks(),fd.marshalPromiseToCallbacks((async()=>{})(),e,t)}close(e,t){Yn.Contracts.throwIfDisposed(this.privDisposedRecognizer),fd.marshalPromiseToCallbacks(this.dispose(!0),e,t)}async dispose(e){this.privDisposedRecognizer||(this.privRecognizer&&(await this.privRecognizer.close(),this.privRecognizer=void 0),e&&(this.privDisposedRecognizer=!0))}};Qa.MeetingTranscriber=gd});var BS=p(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.ConversationTranscriptionResult=void 0;var xw=f(),md=class extends xw.RecognitionResult{constructor(e,t,r,n,s,o,a,c,u,l,h){super(e,t,r,n,s,o,a,u,l,h),this.privSpeakerId=c}get speakerId(){return this.privSpeakerId}};Xa.ConversationTranscriptionResult=md});var Ha=p(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});var FS=Xh();Object.defineProperty(re,"Conversation",{enumerable:!0,get:function(){return FS.Conversation}});Object.defineProperty(re,"ConversationImpl",{enumerable:!0,get:function(){return FS.ConversationImpl}});var Nw=ES();Object.defineProperty(re,"ConversationCommon",{enumerable:!0,get:function(){return Nw.ConversationCommon}});var qw=_S();Object.defineProperty(re,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return qw.ConversationExpirationEventArgs}});var jw=IS();Object.defineProperty(re,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return jw.ConversationParticipantsChangedEventArgs}});var zw=wS();Object.defineProperty(re,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return zw.ConversationTranslationCanceledEventArgs}});var Lw=bS();Object.defineProperty(re,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return Lw.ConversationTranslationEventArgs}});var Bw=AS();Object.defineProperty(re,"ConversationTranslationResult",{enumerable:!0,get:function(){return Bw.ConversationTranslationResult}});var Fw=DS();Object.defineProperty(re,"ConversationTranslator",{enumerable:!0,get:function(){return Fw.ConversationTranslator}});var Vw=xS();Object.defineProperty(re,"ConversationTranscriber",{enumerable:!0,get:function(){return Vw.ConversationTranscriber}});var VS=NS();Object.defineProperty(re,"Participant",{enumerable:!0,get:function(){return VS.Participant}});Object.defineProperty(re,"User",{enumerable:!0,get:function(){return VS.User}});var Uw=qS();Object.defineProperty(re,"ParticipantChangedReason",{enumerable:!0,get:function(){return Uw.ParticipantChangedReason}});var US=jS();Object.defineProperty(re,"Meeting",{enumerable:!0,get:function(){return US.Meeting}});Object.defineProperty(re,"MeetingImpl",{enumerable:!0,get:function(){return US.MeetingImpl}});var Ww=zS();Object.defineProperty(re,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return Ww.MeetingTranscriptionCanceledEventArgs}});var Hw=LS();Object.defineProperty(re,"MeetingTranscriber",{enumerable:!0,get:function(){return Hw.MeetingTranscriber}});var Kw=BS();Object.defineProperty(re,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return Kw.ConversationTranscriptionResult}})});var Za=p(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});zi.SynthesisRequest=zi.Synthesizer=void 0;var Yr=C(),Jw=P(),WS=_(),mr=f(),yd=class i{constructor(e){let t=e;WS.Contracts.throwIfNull(t,"speechConfig"),this.privProperties=t.properties.clone(),this.privDisposed=!1,this.privSynthesizing=!1,this.synthesisRequestQueue=new Jw.Queue}get authorizationToken(){return this.properties.getProperty(mr.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){WS.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(mr.PropertyId.SpeechServiceAuthorization_Token,e)}get properties(){return this.privProperties}get autoDetectSourceLanguage(){return this.properties.getProperty(mr.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages)===Yr.AutoDetectSourceLanguagesOpenRangeOptionName}buildSsml(e){let t={"af-ZA":"af-ZA-AdriNeural","am-ET":"am-ET-AmehaNeural","ar-AE":"ar-AE-FatimaNeural","ar-BH":"ar-BH-AliNeural","ar-DZ":"ar-DZ-AminaNeural","ar-EG":"ar-EG-SalmaNeural","ar-IQ":"ar-IQ-BasselNeural","ar-JO":"ar-JO-SanaNeural","ar-KW":"ar-KW-FahedNeural","ar-LY":"ar-LY-ImanNeural","ar-MA":"ar-MA-JamalNeural","ar-QA":"ar-QA-AmalNeural","ar-SA":"ar-SA-HamedNeural","ar-SY":"ar-SY-AmanyNeural","ar-TN":"ar-TN-HediNeural","ar-YE":"ar-YE-MaryamNeural","bg-BG":"bg-BG-BorislavNeural","bn-BD":"bn-BD-NabanitaNeural","bn-IN":"bn-IN-BashkarNeural","ca-ES":"ca-ES-JoanaNeural","cs-CZ":"cs-CZ-AntoninNeural","cy-GB":"cy-GB-AledNeural","da-DK":"da-DK-ChristelNeural","de-AT":"de-AT-IngridNeural","de-CH":"de-CH-JanNeural","de-DE":"de-DE-KatjaNeural","el-GR":"el-GR-AthinaNeural","en-AU":"en-AU-NatashaNeural","en-CA":"en-CA-ClaraNeural","en-GB":"en-GB-LibbyNeural","en-HK":"en-HK-SamNeural","en-IE":"en-IE-ConnorNeural","en-IN":"en-IN-NeerjaNeural","en-KE":"en-KE-AsiliaNeural","en-NG":"en-NG-AbeoNeural","en-NZ":"en-NZ-MitchellNeural","en-PH":"en-PH-JamesNeural","en-SG":"en-SG-LunaNeural","en-TZ":"en-TZ-ElimuNeural","en-US":"en-US-JennyNeural","en-ZA":"en-ZA-LeahNeural","es-AR":"es-AR-ElenaNeural","es-BO":"es-BO-MarceloNeural","es-CL":"es-CL-CatalinaNeural","es-CO":"es-CO-GonzaloNeural","es-CR":"es-CR-JuanNeural","es-CU":"es-CU-BelkysNeural","es-DO":"es-DO-EmilioNeural","es-EC":"es-EC-AndreaNeural","es-ES":"es-ES-AlvaroNeural","es-GQ":"es-GQ-JavierNeural","es-GT":"es-GT-AndresNeural","es-HN":"es-HN-CarlosNeural","es-MX":"es-MX-DaliaNeural","es-NI":"es-NI-FedericoNeural","es-PA":"es-PA-MargaritaNeural","es-PE":"es-PE-AlexNeural","es-PR":"es-PR-KarinaNeural","es-PY":"es-PY-MarioNeural","es-SV":"es-SV-LorenaNeural","es-US":"es-US-AlonsoNeural","es-UY":"es-UY-MateoNeural","es-VE":"es-VE-PaolaNeural","et-EE":"et-EE-AnuNeural","fa-IR":"fa-IR-DilaraNeural","fi-FI":"fi-FI-SelmaNeural","fil-PH":"fil-PH-AngeloNeural","fr-BE":"fr-BE-CharlineNeural","fr-CA":"fr-CA-SylvieNeural","fr-CH":"fr-CH-ArianeNeural","fr-FR":"fr-FR-DeniseNeural","ga-IE":"ga-IE-ColmNeural","gl-ES":"gl-ES-RoiNeural","gu-IN":"gu-IN-DhwaniNeural","he-IL":"he-IL-AvriNeural","hi-IN":"hi-IN-MadhurNeural","hr-HR":"hr-HR-GabrijelaNeural","hu-HU":"hu-HU-NoemiNeural","id-ID":"id-ID-ArdiNeural","is-IS":"is-IS-GudrunNeural","it-IT":"it-IT-IsabellaNeural","ja-JP":"ja-JP-NanamiNeural","jv-ID":"jv-ID-DimasNeural","kk-KZ":"kk-KZ-AigulNeural","km-KH":"km-KH-PisethNeural","kn-IN":"kn-IN-GaganNeural","ko-KR":"ko-KR-SunHiNeural","lo-LA":"lo-LA-ChanthavongNeural","lt-LT":"lt-LT-LeonasNeural","lv-LV":"lv-LV-EveritaNeural","mk-MK":"mk-MK-AleksandarNeural","ml-IN":"ml-IN-MidhunNeural","mr-IN":"mr-IN-AarohiNeural","ms-MY":"ms-MY-OsmanNeural","mt-MT":"mt-MT-GraceNeural","my-MM":"my-MM-NilarNeural","nb-NO":"nb-NO-PernilleNeural","nl-BE":"nl-BE-ArnaudNeural","nl-NL":"nl-NL-ColetteNeural","pl-PL":"pl-PL-AgnieszkaNeural","ps-AF":"ps-AF-GulNawazNeural","pt-BR":"pt-BR-FranciscaNeural","pt-PT":"pt-PT-DuarteNeural","ro-RO":"ro-RO-AlinaNeural","ru-RU":"ru-RU-SvetlanaNeural","si-LK":"si-LK-SameeraNeural","sk-SK":"sk-SK-LukasNeural","sl-SI":"sl-SI-PetraNeural","so-SO":"so-SO-MuuseNeural","sr-RS":"sr-RS-NicholasNeural","su-ID":"su-ID-JajangNeural","sv-SE":"sv-SE-SofieNeural","sw-KE":"sw-KE-RafikiNeural","sw-TZ":"sw-TZ-DaudiNeural","ta-IN":"ta-IN-PallaviNeural","ta-LK":"ta-LK-KumarNeural","ta-SG":"ta-SG-AnbuNeural","te-IN":"te-IN-MohanNeural","th-TH":"th-TH-PremwadeeNeural","tr-TR":"tr-TR-AhmetNeural","uk-UA":"uk-UA-OstapNeural","ur-IN":"ur-IN-GulNeural","ur-PK":"ur-PK-AsadNeural","uz-UZ":"uz-UZ-MadinaNeural","vi-VN":"vi-VN-HoaiMyNeural","zh-CN":"zh-CN-XiaoxiaoNeural","zh-HK":"zh-HK-HiuMaanNeural","zh-TW":"zh-TW-HsiaoChenNeural","zu-ZA":"zu-ZA-ThandoNeural"},r=this.properties.getProperty(mr.PropertyId.SpeechServiceConnection_SynthLanguage,"en-US"),n=this.properties.getProperty(mr.PropertyId.SpeechServiceConnection_SynthVoice,""),s=i.XMLEncode(e);return this.autoDetectSourceLanguage?r="en-US":n=n||t[r],n&&(s=`<voice name='${n}'>${s}</voice>`),s=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${r}'>${s}</speak>`,s}async dispose(e){this.privDisposed||(e&&this.privAdapter&&await this.privAdapter.dispose(),this.privDisposed=!0)}async adapterSpeak(){if(!this.privDisposed&&!this.privSynthesizing){this.privSynthesizing=!0;let e=await this.synthesisRequestQueue.dequeue();return this.privAdapter.Speak(e.text,e.isSSML,e.requestId,e.cb,e.err,e.dataStream)}}createSynthesizerConfig(e){return new Yr.SynthesizerConfig(e,this.privProperties)}implCommonSynthesizeSetup(){let e=typeof window<"u"?"Browser":"Node",t="unknown",r="unknown";typeof navigator<"u"&&(e=e+"/"+navigator.platform,t=navigator.userAgent,r=navigator.appVersion);let n=this.createSynthesizerConfig(new Yr.SpeechServiceConfig(new Yr.Context(new Yr.OS(e,t,r)))),s=this.privProperties.getProperty(mr.PropertyId.SpeechServiceConnection_Key,void 0),o=s&&s!==""?new Yr.CognitiveSubscriptionKeyAuthentication(s):new Yr.CognitiveTokenAuthentication(()=>{let a=this.privProperties.getProperty(mr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)},()=>{let a=this.privProperties.getProperty(mr.PropertyId.SpeechServiceAuthorization_Token,void 0);return Promise.resolve(a)});this.privAdapter=this.createSynthesisAdapter(o,this.privConnectionFactory,n),this.privRestAdapter=this.createRestSynthesisAdapter(o,n)}static XMLEncode(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}};zi.Synthesizer=yd;var Sd=class{constructor(e,t,r,n,s,o){this.requestId=e,this.text=t,this.isSSML=r,this.cb=n,this.err=s,this.dataStream=o}};zi.SynthesisRequest=Sd});var KS=p(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.SpeechSynthesizer=void 0;var Cd=C(),Pd=P(),Gw=Al(),$w=Pi(),Qw=Lr(),HS=_(),yr=f(),Xw=Za(),Rd=class i extends yr.Synthesizer{constructor(e,t){super(e),t!==null&&(t===void 0?this.audioConfig=typeof window>"u"?void 0:yr.AudioConfig.fromDefaultSpeakerOutput():this.audioConfig=t),this.privConnectionFactory=new Cd.SpeechSynthesisConnectionFactory,this.implCommonSynthesizeSetup()}static FromConfig(e,t,r){let n=e;return t.properties.mergeTo(n.properties),new i(e,r)}speakTextAsync(e,t,r,n){this.speakImpl(e,!1,t,r,n)}speakSsmlAsync(e,t,r,n){this.speakImpl(e,!0,t,r,n)}async getVoicesAsync(e=""){return this.getVoices(e)}close(e,t){HS.Contracts.throwIfDisposed(this.privDisposed),Pd.marshalPromiseToCallbacks(this.dispose(!0),e,t)}get internalData(){return this.privAdapter}createSynthesisAdapter(e,t,r){return new Cd.SpeechSynthesisAdapter(e,t,r,this,this.audioConfig)}createRestSynthesisAdapter(e,t){return new Cd.SynthesisRestAdapter(t,e)}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=$w.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(yr.SpeechSynthesisOutputFormat[this.properties.getProperty(yr.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0)])}speakImpl(e,t,r,n,s){try{HS.Contracts.throwIfDisposed(this.privDisposed);let o=Pd.createNoDashGuid(),a;s instanceof yr.PushAudioOutputStreamCallback?a=new Qw.PushAudioOutputStreamImpl(s):s instanceof yr.PullAudioOutputStream?a=s:s!==void 0?a=new Gw.AudioFileWriter(s):a=void 0,this.synthesisRequestQueue.enqueue(new Xw.SynthesisRequest(o,e,t,c=>{if(this.privSynthesizing=!1,r)try{r(c)}catch(u){n&&n(u)}r=void 0,this.adapterSpeak().catch(()=>{})},c=>{n&&n(c)},a)),this.adapterSpeak().catch(()=>{})}catch(o){if(n)if(o instanceof Error){let a=o;n(a.name+": "+a.message)}else n(o);this.dispose(!0).catch(()=>{})}}async getVoices(e){let t=Pd.createNoDashGuid(),r=await this.privRestAdapter.getVoicesList(t);if(r.ok&&Array.isArray(r.json)){let n=r.json;return e&&e.length>0&&(n=n.filter(s=>!!s.Locale&&s.Locale.toLowerCase()===e.toLowerCase())),new yr.SynthesisVoicesResult(t,n,void 0)}else return new yr.SynthesisVoicesResult(t,void 0,`Error: ${r.status}: ${r.statusText}`)}};Ya.SpeechSynthesizer=Rd});var JS=p(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.SynthesisResult=void 0;var Ed=class{constructor(e,t,r,n){this.privResultId=e,this.privReason=t,this.privErrorDetails=r,this.privProperties=n}get resultId(){return this.privResultId}get reason(){return this.privReason}get errorDetails(){return this.privErrorDetails}get properties(){return this.privProperties}};ec.SynthesisResult=Ed});var GS=p(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.SpeechSynthesisResult=void 0;var Zw=f(),_d=class extends Zw.SynthesisResult{constructor(e,t,r,n,s,o){super(e,t,n,s),this.privAudioData=r,this.privAudioDuration=o}get audioData(){return this.privAudioData}get audioDuration(){return this.privAudioDuration}};tc.SpeechSynthesisResult=_d});var $S=p(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.SpeechSynthesisEventArgs=void 0;var Id=class{constructor(e){this.privResult=e}get result(){return this.privResult}};rc.SpeechSynthesisEventArgs=Id});var QS=p(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.SpeechSynthesisWordBoundaryEventArgs=void 0;var wd=class{constructor(e,t,r,n,s,o){this.privAudioOffset=e,this.privDuration=t,this.privText=r,this.privWordLength=n,this.privTextOffset=s,this.privBoundaryType=o}get audioOffset(){return this.privAudioOffset}get duration(){return this.privDuration}get text(){return this.privText}get wordLength(){return this.privWordLength}get textOffset(){return this.privTextOffset}get boundaryType(){return this.privBoundaryType}};ic.SpeechSynthesisWordBoundaryEventArgs=wd});var XS=p(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.SpeechSynthesisBookmarkEventArgs=void 0;var bd=class{constructor(e,t){this.privAudioOffset=e,this.privText=t}get audioOffset(){return this.privAudioOffset}get text(){return this.privText}};nc.SpeechSynthesisBookmarkEventArgs=bd});var ZS=p(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.SpeechSynthesisVisemeEventArgs=void 0;var Ad=class{constructor(e,t,r){this.privAudioOffset=e,this.privVisemeId=t,this.privAnimation=r}get audioOffset(){return this.privAudioOffset}get visemeId(){return this.privVisemeId}get animation(){return this.privAnimation}};sc.SpeechSynthesisVisemeEventArgs=Ad});var YS=p(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.SpeechSynthesisBoundaryType=void 0;var Yw;(function(i){i.Word="WordBoundary",i.Punctuation="PunctuationBoundary",i.Sentence="SentenceBoundary"})(Yw=ts.SpeechSynthesisBoundaryType||(ts.SpeechSynthesisBoundaryType={}))});var eC=p(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.SynthesisVoicesResult=void 0;var Li=f(),Td=class extends Li.SynthesisResult{constructor(e,t,r){if(Array.isArray(t)){super(e,Li.ResultReason.VoicesListRetrieved,void 0,new Li.PropertyCollection),this.privVoices=[];for(let n of t)this.privVoices.push(new Li.VoiceInfo(n))}else super(e,Li.ResultReason.Canceled,r||"Error information unavailable",new Li.PropertyCollection)}get voices(){return this.privVoices}};oc.SynthesisVoicesResult=Td});var tC=p(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.VoiceInfo=Tt.SynthesisVoiceType=Tt.SynthesisVoiceGender=void 0;var ft;(function(i){i[i.Unknown=0]="Unknown",i[i.Female=1]="Female",i[i.Male=2]="Male",i[i.Neutral=3]="Neutral"})(ft=Tt.SynthesisVoiceGender||(Tt.SynthesisVoiceGender={}));var Od;(function(i){i[i.OnlineNeural=1]="OnlineNeural",i[i.OnlineStandard=2]="OnlineStandard",i[i.OfflineNeural=3]="OfflineNeural",i[i.OfflineStandard=4]="OfflineStandard"})(Od=Tt.SynthesisVoiceType||(Tt.SynthesisVoiceType={}));var eb={[ft[ft.Neutral]]:ft.Neutral,[ft[ft.Male]]:ft.Male,[ft[ft.Female]]:ft.Female},kd=class{constructor(e){if(this.privStyleList=[],e){if(this.privName=e.Name,this.privLocale=e.Locale,this.privShortName=e.ShortName,this.privLocaleName=e.LocaleName,this.privDisplayName=e.DisplayName,this.privLocalName=e.LocalName,this.privVoiceType=e.VoiceType.endsWith("Standard")?Od.OnlineStandard:Od.OnlineNeural,this.privGender=eb[e.Gender]||ft.Unknown,e.StyleList&&Array.isArray(e.StyleList))for(let t of e.StyleList)this.privStyleList.push(t);this.privSampleRateHertz=e.SampleRateHertz,this.privStatus=e.Status,e.ExtendedPropertyMap&&(this.privExtendedPropertyMap=e.ExtendedPropertyMap),this.privWordsPerMinute=e.WordsPerMinute,Array.isArray(e.SecondaryLocaleList)&&(this.privSecondaryLocaleList=[...e.SecondaryLocaleList]),Array.isArray(e.RolePlayList)&&(this.privRolePlayList=[...e.RolePlayList])}}get name(){return this.privName}get locale(){return this.privLocale}get shortName(){return this.privShortName}get displayName(){return this.privDisplayName}get localName(){return this.privLocalName}get localeName(){return this.privLocaleName}get gender(){return this.privGender}get voiceType(){return this.privVoiceType}get styleList(){return this.privStyleList}get sampleRateHertz(){return this.privSampleRateHertz}get status(){return this.privStatus}get extendedPropertyMap(){return this.privExtendedPropertyMap}get wordsPerMinute(){return this.privWordsPerMinute}get secondaryLocaleList(){return this.privSecondaryLocaleList}get rolePlayList(){return this.privRolePlayList}};Tt.VoiceInfo=kd});var iC=p(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});ac.SpeakerAudioDestination=void 0;var ei=P(),tb=Lr(),et=pr(),rb=60*30,rC={[et.AudioFormatTag.PCM]:"audio/wav",[et.AudioFormatTag.MuLaw]:"audio/x-wav",[et.AudioFormatTag.MP3]:"audio/mpeg",[et.AudioFormatTag.OGG_OPUS]:"audio/ogg",[et.AudioFormatTag.WEBM_OPUS]:"audio/webm; codecs=opus",[et.AudioFormatTag.ALaw]:"audio/x-wav",[et.AudioFormatTag.FLAC]:"audio/flac"},Md=class{constructor(e){this.privPlaybackStarted=!1,this.privAppendingToBuffer=!1,this.privMediaSourceOpened=!1,this.privBytesReceived=0,this.privId=e||ei.createNoDashGuid(),this.privIsPaused=!1,this.privIsClosed=!1}id(){return this.privId}write(e,t,r){this.privAudioBuffer!==void 0?(this.privAudioBuffer.push(e),this.updateSourceBuffer().then(()=>{t&&t()},n=>{r&&r(n)})):this.privAudioOutputStream!==void 0&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength)}close(e,t){if(this.privIsClosed=!0,this.privSourceBuffer!==void 0)this.handleSourceBufferUpdateEnd().then(()=>{e&&e()},r=>{t&&t(r)});else if(this.privAudioOutputStream!==void 0&&typeof window<"u")if((this.privFormat.formatTag===et.AudioFormatTag.PCM||this.privFormat.formatTag===et.AudioFormatTag.MuLaw||this.privFormat.formatTag===et.AudioFormatTag.ALaw)&&this.privFormat.hasHeader===!1)console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."),this.onAudioEnd&&this.onAudioEnd(this);else{let r=new ArrayBuffer(this.privBytesReceived);this.privAudioOutputStream.read(r).then(()=>{r=this.privFormat.addHeader(r);let n=new Blob([r],{type:rC[this.privFormat.formatTag]});this.privAudio.src=window.URL.createObjectURL(n),this.notifyPlayback().then(()=>{e&&e()},s=>{t&&t(s)})},n=>{t&&t(n)})}else this.onAudioEnd&&this.onAudioEnd(this)}set format(e){if(typeof AudioContext<"u"||typeof window<"u"&&typeof window.webkitAudioContext<"u"){this.privFormat=e;let t=rC[this.privFormat.formatTag];t===void 0?console.warn(`Unknown mimeType for format ${et.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`):typeof MediaSource<"u"&&MediaSource.isTypeSupported(t)?(this.privAudio=new Audio,this.privAudioBuffer=[],this.privMediaSource=new MediaSource,this.privAudio.src=URL.createObjectURL(this.privMediaSource),this.privAudio.load(),this.privMediaSource.onsourceopen=()=>{this.privMediaSourceOpened=!0,this.privMediaSource.duration=rb,this.privSourceBuffer=this.privMediaSource.addSourceBuffer(t),this.privSourceBuffer.onupdate=()=>{this.updateSourceBuffer().catch(r=>{ei.Events.instance.onEvent(new ei.BackgroundEvent(r))})},this.privSourceBuffer.onupdateend=()=>{this.handleSourceBufferUpdateEnd().catch(r=>{ei.Events.instance.onEvent(new ei.BackgroundEvent(r))})},this.privSourceBuffer.onupdatestart=()=>{this.privAppendingToBuffer=!1}},this.updateSourceBuffer().catch(r=>{ei.Events.instance.onEvent(new ei.BackgroundEvent(r))})):(console.warn(`Format ${et.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`),this.privAudioOutputStream=new tb.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privFormat,this.privAudio=new Audio)}}get volume(){return this.privAudio?.volume??-1}set volume(e){this.privAudio&&(this.privAudio.volume=e)}mute(){this.privAudio&&(this.privAudio.muted=!0)}unmute(){this.privAudio&&(this.privAudio.muted=!1)}get isClosed(){return this.privIsClosed}get currentTime(){return this.privAudio!==void 0?this.privAudio.currentTime:-1}pause(){!this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.pause(),this.privIsPaused=!0)}resume(e,t){this.privIsPaused&&this.privAudio!==void 0&&(this.privAudio.play().then(()=>{e&&e()},r=>{t&&t(r)}),this.privIsPaused=!1)}get internalAudio(){return this.privAudio}async updateSourceBuffer(){if(this.privAudioBuffer!==void 0&&this.privAudioBuffer.length>0&&this.sourceBufferAvailable()){this.privAppendingToBuffer=!0;let e=this.privAudioBuffer.shift();try{this.privSourceBuffer.appendBuffer(e)}catch{this.privAudioBuffer.unshift(e),console.log("buffer filled, pausing addition of binaries until space is made");return}await this.notifyPlayback()}else this.canEndStream()&&await this.handleSourceBufferUpdateEnd()}async handleSourceBufferUpdateEnd(){this.canEndStream()&&this.sourceBufferAvailable()&&(this.privMediaSource.endOfStream(),await this.notifyPlayback())}async notifyPlayback(){!this.privPlaybackStarted&&this.privAudio!==void 0&&(this.privPlaybackStarted=!0,this.onAudioStart&&this.onAudioStart(this),this.privAudio.onended=()=>{this.onAudioEnd&&this.onAudioEnd(this)},this.privIsPaused||await this.privAudio.play())}canEndStream(){return this.isClosed&&this.privSourceBuffer!==void 0&&this.privAudioBuffer.length===0&&this.privMediaSourceOpened&&!this.privAppendingToBuffer&&this.privMediaSource.readyState==="open"}sourceBufferAvailable(){return this.privSourceBuffer!==void 0&&!this.privSourceBuffer.updating}};ac.SpeakerAudioDestination=Md});var nC=p(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});cc.ConversationTranscriptionCanceledEventArgs=void 0;var ib=Ii(),Dd=class extends ib.CancellationEventArgsBase{};cc.ConversationTranscriptionCanceledEventArgs=Dd});var sC=p(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});uc.MeetingTranscriptionCanceledEventArgs=void 0;var nb=Ii(),xd=class extends nb.CancellationEventArgsBase{};uc.MeetingTranscriptionCanceledEventArgs=xd});var oC=p(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.PronunciationAssessmentGradingSystem=void 0;var sb;(function(i){i[i.FivePoint=1]="FivePoint",i[i.HundredMark=2]="HundredMark"})(sb=rs.PronunciationAssessmentGradingSystem||(rs.PronunciationAssessmentGradingSystem={}))});var aC=p(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.PronunciationAssessmentGranularity=void 0;var ob;(function(i){i[i.Phoneme=1]="Phoneme",i[i.Word=2]="Word",i[i.FullText=3]="FullText"})(ob=is.PronunciationAssessmentGranularity||(is.PronunciationAssessmentGranularity={}))});var cC=p(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});lc.PronunciationAssessmentConfig=void 0;var pc=_(),G=f(),Nd=class i{constructor(e,t=G.PronunciationAssessmentGradingSystem.FivePoint,r=G.PronunciationAssessmentGranularity.Phoneme,n=!1){pc.Contracts.throwIfNullOrUndefined(e,"referenceText"),this.privProperties=new G.PropertyCollection,this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_GradingSystem,G.PronunciationAssessmentGradingSystem[t]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Granularity,G.PronunciationAssessmentGranularity[r]),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,String(n))}static fromJSON(e){pc.Contracts.throwIfNullOrUndefined(e,"json");let t=new i("");return t.privProperties=new G.PropertyCollection,t.properties.setProperty(G.PropertyId.PronunciationAssessment_Json,e),t}toJSON(){return this.updateJson(),this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Params)}applyTo(e){this.updateJson();let t=e.internalData;t.expectContentAssessmentResponse=!!this.privContentAssessmentTopic,t.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(G.PropertyId.PronunciationAssessment_Params),this.privContentAssessmentTopic,t.isSpeakerDiarizationEnabled)}get referenceText(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText)}set referenceText(e){pc.Contracts.throwIfNullOrWhitespace(e,"referenceText"),this.properties.setProperty(G.PropertyId.PronunciationAssessment_ReferenceText,e)}set phonemeAlphabet(e){pc.Contracts.throwIfNullOrWhitespace(e,"phonemeAlphabet"),this.privPhonemeAlphabet=e}set enableMiscue(e){let t=e?"true":"false";this.properties.setProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,t)}get enableMiscue(){return this.properties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue,"false").toLowerCase()==="true"}set nbestPhonemeCount(e){this.privNBestPhonemeCount=e}set enableProsodyAssessment(e){this.privEnableProsodyAssessment=e}enableContentAssessmentWithTopic(e){this.privContentAssessmentTopic=e}get properties(){return this.privProperties}updateJson(){let e=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Json,"{}"),t=JSON.parse(e),r=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_ReferenceText);r&&(t.referenceText=r);let n=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_GradingSystem);n&&(t.gradingSystem=n);let s=this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_Granularity);s&&(t.granularity=s),this.privPhonemeAlphabet&&(t.phonemeAlphabet=this.privPhonemeAlphabet),this.privNBestPhonemeCount&&(t.nbestPhonemeCount=this.privNBestPhonemeCount),t.enableProsodyAssessment=this.privEnableProsodyAssessment,t.dimension="Comprehensive",this.privProperties.getProperty(G.PropertyId.PronunciationAssessment_EnableMiscue)&&(t.enableMiscue=this.enableMiscue),this.privProperties.setProperty(G.PropertyId.PronunciationAssessment_Params,JSON.stringify(t))}};lc.PronunciationAssessmentConfig=Nd});var uC=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.PronunciationAssessmentResult=Bi.ContentAssessmentResult=void 0;var qd=_(),ab=f(),hc=class{constructor(e){this.privPronJson=e}get grammarScore(){return this.privPronJson.ContentAssessment.GrammarScore}get vocabularyScore(){return this.privPronJson.ContentAssessment.VocabularyScore}get topicScore(){return this.privPronJson.ContentAssessment.TopicScore}};Bi.ContentAssessmentResult=hc;var jd=class i{constructor(e){let t=JSON.parse(e);qd.Contracts.throwIfNullOrUndefined(t.NBest[0],"NBest"),this.privPronJson=t.NBest[0]}static fromResult(e){qd.Contracts.throwIfNullOrUndefined(e,"result");let t=e.properties.getProperty(ab.PropertyId.SpeechServiceResponse_JsonResult);return qd.Contracts.throwIfNullOrUndefined(t,"json"),new i(t)}get detailResult(){return this.privPronJson}get accuracyScore(){return this.detailResult.PronunciationAssessment?.AccuracyScore}get pronunciationScore(){return this.detailResult.PronunciationAssessment?.PronScore}get completenessScore(){return this.detailResult.PronunciationAssessment?.CompletenessScore}get fluencyScore(){return this.detailResult.PronunciationAssessment?.FluencyScore}get prosodyScore(){return this.detailResult.PronunciationAssessment?.ProsodyScore}get contentAssessmentResult(){if(this.detailResult.ContentAssessment!==void 0)return new hc(this.detailResult)}};Bi.PronunciationAssessmentResult=jd});var pC=p(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});dc.AvatarConfig=void 0;var cb=_(),ub=f(),zd=class{constructor(e,t,r){this.privCustomized=!1,cb.Contracts.throwIfNullOrWhitespace(e,"character"),this.character=e,this.style=t,r===void 0&&(r=new ub.AvatarVideoFormat),this.videoFormat=r}get customized(){return this.privCustomized}set customized(e){this.privCustomized=e}get backgroundColor(){return this.privBackgroundColor}set backgroundColor(e){this.privBackgroundColor=e}};dc.AvatarConfig=zd});var lC=p(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.AvatarEventArgs=ti.AvatarEventTypes=void 0;var pb;(function(i){i.SwitchedToSpeaking="SwitchedToSpeaking",i.SwitchedToIdle="SwitchedToIdle",i.SessionClosed="SessionClosed"})(pb=ti.AvatarEventTypes||(ti.AvatarEventTypes={}));var Ld=class{constructor(e,t){this.privOffset=e,this.privDescription=t}get type(){return this.privType}get offset(){return this.privOffset}get description(){return this.privDescription}};ti.AvatarEventArgs=Ld});var Fd=p(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});fc.SpeechSynthesisConnectionFactory=void 0;var hC=ce(),ns=f(),lb=Ze(),hb=C(),db=Ie(),vc=$t(),Bd=class{constructor(){this.synthesisUri="/cognitiveservices/websocket/v1"}create(e,t,r){let n=e.parameters.getProperty(ns.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(ns.PropertyId.SpeechServiceConnection_Region,void 0),o=lb.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(ns.PropertyId.SpeechServiceConnection_EndpointId,void 0),c=a===void 0?"tts":"voice",u=e.parameters.getProperty(ns.PropertyId.SpeechServiceConnection_Host,"wss://"+s+"."+c+".speech"+o),l={},h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[db.HeaderNames.ConnectionId]=r,a!==void 0&&a!==""&&(!n||n.search(vc.QueryParameterNames.CustomVoiceDeploymentId)===-1)&&(l[vc.QueryParameterNames.CustomVoiceDeploymentId]=a),e.avatarEnabled&&(!n||n.search(vc.QueryParameterNames.EnableAvatar)===-1)&&(l[vc.QueryParameterNames.EnableAvatar]="true"),n||(n=u+this.synthesisUri),e.parameters.setProperty(ns.PropertyId.SpeechServiceConnection_Url,n);let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new hC.WebsocketConnection(n,l,h,new hb.WebsocketMessageFormatter,hC.ProxyInfo.fromParameters(e.parameters),d,r)}};fc.SpeechSynthesisConnectionFactory=Bd});var dC=p(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.AvatarSynthesizer=void 0;var vb=Fd(),fb=C(),X=P(),gb=Pi(),Xt=f(),gc=_(),mb=Za(),Vd=class extends Xt.Synthesizer{constructor(e,t){super(e),gc.Contracts.throwIfNullOrUndefined(t,"avatarConfig"),this.privConnectionFactory=new vb.SpeechSynthesisConnectionFactory,this.privAvatarConfig=t,this.implCommonSynthesizeSetup()}implCommonSynthesizeSetup(){super.implCommonSynthesizeSetup(),this.privAdapter.audioOutputFormat=gb.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Xt.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm)}async startAvatarAsync(e){gc.Contracts.throwIfNullOrUndefined(e,"peerConnection"),this.privIceServers=e.getConfiguration().iceServers,gc.Contracts.throwIfNullOrUndefined(this.privIceServers,"Ice servers must be set.");let t=new X.Deferred;e.onicegatheringstatechange=()=>{X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering state: "+e.iceGatheringState,X.EventType.Debug)),e.iceGatheringState==="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering complete.",X.EventType.Info)),t.resolve())},e.onicecandidate=a=>{a.candidate?X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: "+a.candidate.candidate,X.EventType.Debug)):(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice candidate: complete",X.EventType.Debug)),t.resolve())},setTimeout(()=>{e.iceGatheringState!=="complete"&&(X.Events.instance.onEvent(new X.PlatformEvent("peer connection: ice gathering timeout.",X.EventType.Warning)),t.resolve())},2e3);let r=await e.createOffer();await e.setLocalDescription(r),await t.promise,X.Events.instance.onEvent(new X.PlatformEvent("peer connection: got local SDP.",X.EventType.Info)),this.privProperties.setProperty(Xt.PropertyId.TalkingAvatarService_WebRTC_SDP,JSON.stringify(e.localDescription));let n=await this.speak("",!1);if(n.reason!==Xt.ResultReason.SynthesizingAudioCompleted)return new Xt.SynthesisResult(n.resultId,n.reason,n.errorDetails,n.properties);let s=atob(n.properties.getProperty(Xt.PropertyId.TalkingAvatarService_WebRTC_SDP)),o=new RTCSessionDescription(JSON.parse(s));return await e.setRemoteDescription(o),new Xt.SynthesisResult(n.resultId,n.reason,void 0,n.properties)}async speakTextAsync(e){let t=await this.speak(e,!1);return new Xt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async speakSsmlAsync(e){let t=await this.speak(e,!0);return new Xt.SynthesisResult(t.resultId,t.reason,t.errorDetails,t.properties)}async stopSpeakingAsync(){for(;this.synthesisRequestQueue.length()>0;)(await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user.");return this.privAdapter.stopSpeaking()}async stopAvatarAsync(){return gc.Contracts.throwIfDisposed(this.privDisposed),this.dispose(!0)}async close(){if(!this.privDisposed)return this.dispose(!0)}get iceServers(){return this.privIceServers}createSynthesisAdapter(e,t,r){return new fb.AvatarSynthesisAdapter(e,t,r,this,this.privAvatarConfig)}createRestSynthesisAdapter(e,t){}createSynthesizerConfig(e){let t=super.createSynthesizerConfig(e);return t.avatarEnabled=!0,t}async speak(e,t){let r=X.createNoDashGuid(),n=new X.Deferred;return this.synthesisRequestQueue.enqueue(new mb.SynthesisRequest(r,e,t,s=>{n.resolve(s),this.privSynthesizing=!1,this.adapterSpeak()},s=>{n.reject(s),this.privSynthesizing=!1})),this.adapterSpeak(),n.promise}};mc.AvatarSynthesizer=Vd});var vC=p(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.AvatarVideoFormat=Fi.Coordinate=void 0;var Ud=class{constructor(e,t){this.x=e,this.y=t}};Fi.Coordinate=Ud;var Wd=class{constructor(e="H264",t=2e6,r=1920,n=1080){this.codec=e,this.bitrate=t,this.width=r,this.height=n}setCropRange(e,t){this.cropRange={bottomRight:t,topLeft:e}}};Fi.AvatarVideoFormat=Wd});var fC=p(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.AvatarWebRTCConnectionResult=void 0;var yb=f(),Hd=class extends yb.SynthesisResult{constructor(e,t,r,n,s){super(t,r,n,s),this.privSDPAnswer=e}get SDPAnswer(){return this.privSDPAnswer}};yc.AvatarWebRTCConnectionResult=Hd});var gC=p(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});Cc.Diagnostics=void 0;var Sb=ce(),Cb=P(),Sc=class{static SetLoggingLevel(e){this.privListener=new Sb.ConsoleLoggingListener(e),Cb.Events.instance.attachConsoleListener(this.privListener)}static StartConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!0)}static StopConsoleOutput(){this.privListener&&(this.privListener.enableConsoleOutput=!1)}static SetLogOutputPath(e){if(typeof window>"u")this.privListener&&(this.privListener.logPath=e);else throw new Error("File system logging not available in browser.")}static set onLogOutput(e){this.privListener&&(this.privListener.logCallback=e)}};Cc.Diagnostics=Sc;Sc.privListener=void 0});var f=p(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});var Pb=Ml();Object.defineProperty(v,"AudioConfig",{enumerable:!0,get:function(){return Pb.AudioConfig}});var mC=pr();Object.defineProperty(v,"AudioStreamFormat",{enumerable:!0,get:function(){return mC.AudioStreamFormat}});Object.defineProperty(v,"AudioFormatTag",{enumerable:!0,get:function(){return mC.AudioFormatTag}});var Kd=Tl();Object.defineProperty(v,"AudioInputStream",{enumerable:!0,get:function(){return Kd.AudioInputStream}});Object.defineProperty(v,"PullAudioInputStream",{enumerable:!0,get:function(){return Kd.PullAudioInputStream}});Object.defineProperty(v,"PushAudioInputStream",{enumerable:!0,get:function(){return Kd.PushAudioInputStream}});var Jd=Lr();Object.defineProperty(v,"AudioOutputStream",{enumerable:!0,get:function(){return Jd.AudioOutputStream}});Object.defineProperty(v,"PullAudioOutputStream",{enumerable:!0,get:function(){return Jd.PullAudioOutputStream}});Object.defineProperty(v,"PushAudioOutputStream",{enumerable:!0,get:function(){return Jd.PushAudioOutputStream}});var Rb=iy();Object.defineProperty(v,"CancellationReason",{enumerable:!0,get:function(){return Rb.CancellationReason}});var Eb=ny();Object.defineProperty(v,"PullAudioInputStreamCallback",{enumerable:!0,get:function(){return Eb.PullAudioInputStreamCallback}});var _b=sy();Object.defineProperty(v,"PushAudioOutputStreamCallback",{enumerable:!0,get:function(){return _b.PushAudioOutputStreamCallback}});var Ib=ay();Object.defineProperty(v,"KeywordRecognitionModel",{enumerable:!0,get:function(){return Ib.KeywordRecognitionModel}});var wb=cy();Object.defineProperty(v,"SessionEventArgs",{enumerable:!0,get:function(){return wb.SessionEventArgs}});var bb=uy();Object.defineProperty(v,"RecognitionEventArgs",{enumerable:!0,get:function(){return bb.RecognitionEventArgs}});var Ab=py();Object.defineProperty(v,"OutputFormat",{enumerable:!0,get:function(){return Ab.OutputFormat}});var Tb=ly();Object.defineProperty(v,"IntentRecognitionEventArgs",{enumerable:!0,get:function(){return Tb.IntentRecognitionEventArgs}});var Ob=hy();Object.defineProperty(v,"RecognitionResult",{enumerable:!0,get:function(){return Ob.RecognitionResult}});var kb=dy();Object.defineProperty(v,"SpeechRecognitionResult",{enumerable:!0,get:function(){return kb.SpeechRecognitionResult}});var Mb=vy();Object.defineProperty(v,"IntentRecognitionResult",{enumerable:!0,get:function(){return Mb.IntentRecognitionResult}});var Db=fy();Object.defineProperty(v,"LanguageUnderstandingModel",{enumerable:!0,get:function(){return Db.LanguageUnderstandingModel}});var Gd=my();Object.defineProperty(v,"SpeechRecognitionEventArgs",{enumerable:!0,get:function(){return Gd.SpeechRecognitionEventArgs}});Object.defineProperty(v,"ConversationTranscriptionEventArgs",{enumerable:!0,get:function(){return Gd.ConversationTranscriptionEventArgs}});Object.defineProperty(v,"MeetingTranscriptionEventArgs",{enumerable:!0,get:function(){return Gd.MeetingTranscriptionEventArgs}});var xb=yy();Object.defineProperty(v,"SpeechRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return xb.SpeechRecognitionCanceledEventArgs}});var Nb=Sy();Object.defineProperty(v,"TranslationRecognitionEventArgs",{enumerable:!0,get:function(){return Nb.TranslationRecognitionEventArgs}});var qb=Cy();Object.defineProperty(v,"TranslationSynthesisEventArgs",{enumerable:!0,get:function(){return qb.TranslationSynthesisEventArgs}});var jb=$l();Object.defineProperty(v,"TranslationRecognitionResult",{enumerable:!0,get:function(){return jb.TranslationRecognitionResult}});var zb=Py();Object.defineProperty(v,"TranslationSynthesisResult",{enumerable:!0,get:function(){return zb.TranslationSynthesisResult}});var Lb=Ry();Object.defineProperty(v,"ResultReason",{enumerable:!0,get:function(){return Lb.ResultReason}});var yC=Ey();Object.defineProperty(v,"SpeechConfig",{enumerable:!0,get:function(){return yC.SpeechConfig}});Object.defineProperty(v,"SpeechConfigImpl",{enumerable:!0,get:function(){return yC.SpeechConfigImpl}});var SC=_y();Object.defineProperty(v,"SpeechTranslationConfig",{enumerable:!0,get:function(){return SC.SpeechTranslationConfig}});Object.defineProperty(v,"SpeechTranslationConfigImpl",{enumerable:!0,get:function(){return SC.SpeechTranslationConfigImpl}});var Bb=Zl();Object.defineProperty(v,"PropertyCollection",{enumerable:!0,get:function(){return Bb.PropertyCollection}});var Fb=Lo();Object.defineProperty(v,"PropertyId",{enumerable:!0,get:function(){return Fb.PropertyId}});var Vb=by();Object.defineProperty(v,"Recognizer",{enumerable:!0,get:function(){return Vb.Recognizer}});var Ub=Ay();Object.defineProperty(v,"SpeechRecognizer",{enumerable:!0,get:function(){return Ub.SpeechRecognizer}});var Wb=Ty();Object.defineProperty(v,"IntentRecognizer",{enumerable:!0,get:function(){return Wb.IntentRecognizer}});var Hb=Oy();Object.defineProperty(v,"VoiceProfileType",{enumerable:!0,get:function(){return Hb.VoiceProfileType}});var Kb=xy();Object.defineProperty(v,"TranslationRecognizer",{enumerable:!0,get:function(){return Kb.TranslationRecognizer}});var Jb=Ny();Object.defineProperty(v,"Translations",{enumerable:!0,get:function(){return Jb.Translations}});var Gb=qy();Object.defineProperty(v,"NoMatchReason",{enumerable:!0,get:function(){return Gb.NoMatchReason}});var $b=jy();Object.defineProperty(v,"NoMatchDetails",{enumerable:!0,get:function(){return $b.NoMatchDetails}});var Qb=zy();Object.defineProperty(v,"TranslationRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return Qb.TranslationRecognitionCanceledEventArgs}});var Xb=Ly();Object.defineProperty(v,"IntentRecognitionCanceledEventArgs",{enumerable:!0,get:function(){return Xb.IntentRecognitionCanceledEventArgs}});var Zb=gh();Object.defineProperty(v,"CancellationDetailsBase",{enumerable:!0,get:function(){return Zb.CancellationDetailsBase}});var Yb=By();Object.defineProperty(v,"CancellationDetails",{enumerable:!0,get:function(){return Yb.CancellationDetails}});var eA=Fy();Object.defineProperty(v,"CancellationErrorCode",{enumerable:!0,get:function(){return eA.CancellationErrorCode}});var tA=Vy();Object.defineProperty(v,"ConnectionEventArgs",{enumerable:!0,get:function(){return tA.ConnectionEventArgs}});var rA=Uy();Object.defineProperty(v,"ServiceEventArgs",{enumerable:!0,get:function(){return rA.ServiceEventArgs}});var iA=ch();Object.defineProperty(v,"Connection",{enumerable:!0,get:function(){return iA.Connection}});var nA=Wy();Object.defineProperty(v,"PhraseListGrammar",{enumerable:!0,get:function(){return nA.PhraseListGrammar}});var sA=ca();Object.defineProperty(v,"DialogServiceConfig",{enumerable:!0,get:function(){return sA.DialogServiceConfig}});var oA=Hy();Object.defineProperty(v,"BotFrameworkConfig",{enumerable:!0,get:function(){return oA.BotFrameworkConfig}});var aA=Ky();Object.defineProperty(v,"CustomCommandsConfig",{enumerable:!0,get:function(){return aA.CustomCommandsConfig}});var cA=Xy();Object.defineProperty(v,"DialogServiceConnector",{enumerable:!0,get:function(){return cA.DialogServiceConnector}});var uA=Zy();Object.defineProperty(v,"ActivityReceivedEventArgs",{enumerable:!0,get:function(){return uA.ActivityReceivedEventArgs}});var pA=eS();Object.defineProperty(v,"TurnStatusReceivedEventArgs",{enumerable:!0,get:function(){return pA.TurnStatusReceivedEventArgs}});var lA=tS();Object.defineProperty(v,"ServicePropertyChannel",{enumerable:!0,get:function(){return lA.ServicePropertyChannel}});var hA=rS();Object.defineProperty(v,"ProfanityOption",{enumerable:!0,get:function(){return hA.ProfanityOption}});var dA=iS();Object.defineProperty(v,"BaseAudioPlayer",{enumerable:!0,get:function(){return dA.BaseAudioPlayer}});var vA=nS();Object.defineProperty(v,"ConnectionMessageEventArgs",{enumerable:!0,get:function(){return vA.ConnectionMessageEventArgs}});var fA=nh();Object.defineProperty(v,"ConnectionMessage",{enumerable:!0,get:function(){return fA.ConnectionMessage}});var gA=sS();Object.defineProperty(v,"VoiceProfile",{enumerable:!0,get:function(){return gA.VoiceProfile}});var CC=aS();Object.defineProperty(v,"VoiceProfileEnrollmentResult",{enumerable:!0,get:function(){return CC.VoiceProfileEnrollmentResult}});Object.defineProperty(v,"VoiceProfileEnrollmentCancellationDetails",{enumerable:!0,get:function(){return CC.VoiceProfileEnrollmentCancellationDetails}});var PC=uS();Object.defineProperty(v,"VoiceProfileResult",{enumerable:!0,get:function(){return PC.VoiceProfileResult}});Object.defineProperty(v,"VoiceProfileCancellationDetails",{enumerable:!0,get:function(){return PC.VoiceProfileCancellationDetails}});var mA=pS();Object.defineProperty(v,"VoiceProfilePhraseResult",{enumerable:!0,get:function(){return mA.VoiceProfilePhraseResult}});var yA=lS();Object.defineProperty(v,"VoiceProfileClient",{enumerable:!0,get:function(){return yA.VoiceProfileClient}});var SA=hS();Object.defineProperty(v,"SpeakerRecognizer",{enumerable:!0,get:function(){return SA.SpeakerRecognizer}});var CA=dS();Object.defineProperty(v,"SpeakerIdentificationModel",{enumerable:!0,get:function(){return CA.SpeakerIdentificationModel}});var PA=fS();Object.defineProperty(v,"SpeakerVerificationModel",{enumerable:!0,get:function(){return PA.SpeakerVerificationModel}});var RA=mS();Object.defineProperty(v,"AutoDetectSourceLanguageConfig",{enumerable:!0,get:function(){return RA.AutoDetectSourceLanguageConfig}});var EA=SS();Object.defineProperty(v,"AutoDetectSourceLanguageResult",{enumerable:!0,get:function(){return EA.AutoDetectSourceLanguageResult}});var _A=CS();Object.defineProperty(v,"SourceLanguageConfig",{enumerable:!0,get:function(){return _A.SourceLanguageConfig}});var $d=RS();Object.defineProperty(v,"SpeakerRecognitionResult",{enumerable:!0,get:function(){return $d.SpeakerRecognitionResult}});Object.defineProperty(v,"SpeakerRecognitionResultType",{enumerable:!0,get:function(){return $d.SpeakerRecognitionResultType}});Object.defineProperty(v,"SpeakerRecognitionCancellationDetails",{enumerable:!0,get:function(){return $d.SpeakerRecognitionCancellationDetails}});var ze=Ha();Object.defineProperty(v,"Conversation",{enumerable:!0,get:function(){return ze.Conversation}});Object.defineProperty(v,"ConversationExpirationEventArgs",{enumerable:!0,get:function(){return ze.ConversationExpirationEventArgs}});Object.defineProperty(v,"ConversationParticipantsChangedEventArgs",{enumerable:!0,get:function(){return ze.ConversationParticipantsChangedEventArgs}});Object.defineProperty(v,"ConversationTranslationCanceledEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationCanceledEventArgs}});Object.defineProperty(v,"ConversationTranslationEventArgs",{enumerable:!0,get:function(){return ze.ConversationTranslationEventArgs}});Object.defineProperty(v,"ConversationTranslationResult",{enumerable:!0,get:function(){return ze.ConversationTranslationResult}});Object.defineProperty(v,"ConversationTranslator",{enumerable:!0,get:function(){return ze.ConversationTranslator}});Object.defineProperty(v,"ConversationTranscriber",{enumerable:!0,get:function(){return ze.ConversationTranscriber}});Object.defineProperty(v,"ConversationTranscriptionResult",{enumerable:!0,get:function(){return ze.ConversationTranscriptionResult}});Object.defineProperty(v,"Meeting",{enumerable:!0,get:function(){return ze.Meeting}});Object.defineProperty(v,"MeetingTranscriber",{enumerable:!0,get:function(){return ze.MeetingTranscriber}});Object.defineProperty(v,"Participant",{enumerable:!0,get:function(){return ze.Participant}});Object.defineProperty(v,"ParticipantChangedReason",{enumerable:!0,get:function(){return ze.ParticipantChangedReason}});Object.defineProperty(v,"User",{enumerable:!0,get:function(){return ze.User}});var IA=Za();Object.defineProperty(v,"Synthesizer",{enumerable:!0,get:function(){return IA.Synthesizer}});var wA=Ol();Object.defineProperty(v,"SpeechSynthesisOutputFormat",{enumerable:!0,get:function(){return wA.SpeechSynthesisOutputFormat}});var bA=KS();Object.defineProperty(v,"SpeechSynthesizer",{enumerable:!0,get:function(){return bA.SpeechSynthesizer}});var AA=JS();Object.defineProperty(v,"SynthesisResult",{enumerable:!0,get:function(){return AA.SynthesisResult}});var TA=GS();Object.defineProperty(v,"SpeechSynthesisResult",{enumerable:!0,get:function(){return TA.SpeechSynthesisResult}});var OA=$S();Object.defineProperty(v,"SpeechSynthesisEventArgs",{enumerable:!0,get:function(){return OA.SpeechSynthesisEventArgs}});var kA=QS();Object.defineProperty(v,"SpeechSynthesisWordBoundaryEventArgs",{enumerable:!0,get:function(){return kA.SpeechSynthesisWordBoundaryEventArgs}});var MA=XS();Object.defineProperty(v,"SpeechSynthesisBookmarkEventArgs",{enumerable:!0,get:function(){return MA.SpeechSynthesisBookmarkEventArgs}});var DA=ZS();Object.defineProperty(v,"SpeechSynthesisVisemeEventArgs",{enumerable:!0,get:function(){return DA.SpeechSynthesisVisemeEventArgs}});var xA=YS();Object.defineProperty(v,"SpeechSynthesisBoundaryType",{enumerable:!0,get:function(){return xA.SpeechSynthesisBoundaryType}});var NA=eC();Object.defineProperty(v,"SynthesisVoicesResult",{enumerable:!0,get:function(){return NA.SynthesisVoicesResult}});var qA=tC();Object.defineProperty(v,"VoiceInfo",{enumerable:!0,get:function(){return qA.VoiceInfo}});var jA=iC();Object.defineProperty(v,"SpeakerAudioDestination",{enumerable:!0,get:function(){return jA.SpeakerAudioDestination}});var zA=nC();Object.defineProperty(v,"ConversationTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return zA.ConversationTranscriptionCanceledEventArgs}});var LA=sC();Object.defineProperty(v,"MeetingTranscriptionCanceledEventArgs",{enumerable:!0,get:function(){return LA.MeetingTranscriptionCanceledEventArgs}});var BA=oC();Object.defineProperty(v,"PronunciationAssessmentGradingSystem",{enumerable:!0,get:function(){return BA.PronunciationAssessmentGradingSystem}});var FA=aC();Object.defineProperty(v,"PronunciationAssessmentGranularity",{enumerable:!0,get:function(){return FA.PronunciationAssessmentGranularity}});var VA=cC();Object.defineProperty(v,"PronunciationAssessmentConfig",{enumerable:!0,get:function(){return VA.PronunciationAssessmentConfig}});var UA=uC();Object.defineProperty(v,"PronunciationAssessmentResult",{enumerable:!0,get:function(){return UA.PronunciationAssessmentResult}});var WA=Hh();Object.defineProperty(v,"LanguageIdMode",{enumerable:!0,get:function(){return WA.LanguageIdMode}});var HA=pC();Object.defineProperty(v,"AvatarConfig",{enumerable:!0,get:function(){return HA.AvatarConfig}});var KA=lC();Object.defineProperty(v,"AvatarEventArgs",{enumerable:!0,get:function(){return KA.AvatarEventArgs}});var JA=dC();Object.defineProperty(v,"AvatarSynthesizer",{enumerable:!0,get:function(){return JA.AvatarSynthesizer}});var RC=vC();Object.defineProperty(v,"AvatarVideoFormat",{enumerable:!0,get:function(){return RC.AvatarVideoFormat}});Object.defineProperty(v,"Coordinate",{enumerable:!0,get:function(){return RC.Coordinate}});var GA=fC();Object.defineProperty(v,"AvatarWebRTCConnectionResult",{enumerable:!0,get:function(){return GA.AvatarWebRTCConnectionResult}});var $A=gC();Object.defineProperty(v,"Diagnostics",{enumerable:!0,get:function(){return $A.Diagnostics}});var QA=fl();Object.defineProperty(v,"LogLevel",{enumerable:!0,get:function(){return QA.LogLevel}})});var EC=p(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ProxyInfo=void 0;var Pc=f(),Qd=class i{constructor(e,t,r,n){this.privProxyHostName=e,this.privProxyPort=t,this.privProxyUserName=r,this.privProxyPassword=n}static fromParameters(e){return new i(e.getProperty(Pc.PropertyId.SpeechServiceConnection_ProxyHostName),parseInt(e.getProperty(Pc.PropertyId.SpeechServiceConnection_ProxyPort),10),e.getProperty(Pc.PropertyId.SpeechServiceConnection_ProxyUserName),e.getProperty(Pc.PropertyId.SpeechServiceConnection_ProxyPassword))}static fromRecognizerConfig(e){return this.fromParameters(e.parameters)}get HostName(){return this.privProxyHostName}get Port(){return this.privProxyPort}get UserName(){return this.privProxyUserName}get Password(){return this.privProxyPassword}};Rc.ProxyInfo=Qd});var IC=p((l1,_C)=>{"use strict";var XA=new Set(["json","buffer","string"]);_C.exports=i=>(...e)=>{let t=new Set,r,n,s,o="";return e.forEach(a=>{if(typeof a=="string")if(a.toUpperCase()===a)if(r){let c=`Can't set method to ${a}, already set to ${r}.`;throw new Error(c)}else r=a;else if(a.startsWith("http:")||a.startsWith("https:"))o=a;else if(XA.has(a))n=a;else throw new Error(`Unknown encoding, ${a}`);else if(typeof a=="number")t.add(a);else if(typeof a=="object")if(Array.isArray(a)||a instanceof Set)a.forEach(c=>t.add(c));else{if(s)throw new Error("Cannot set headers twice.");s=a}else throw new Error(`Unknown type: ${typeof a}`)}),r||(r="GET"),t.size===0&&t.add(200),i(t,r,n,s,o)}});var bC=p((h1,wC)=>{"use strict";var ZA=IC(),Xd=class i extends Error{constructor(e,...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);let r;Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(let[s,o]of e.headers.entries())this.headers[s.toLowerCase()]=o}},YA=(i,e,t,r,n)=>async(s,o,a={})=>{s=n+(s||"");let c=new URL(s);if(r||(r={}),c.username&&(r.Authorization="Basic "+btoa(c.username+":"+c.password),c=new URL(c.protocol+"//"+c.host+c.pathname+c.search)),c.protocol!=="https:"&&c.protocol!=="http:")throw new Error(`Unknown protocol, ${c.protocol}`);if(o&&!(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="string"))if(typeof o=="object")o=JSON.stringify(o),r["Content-Type"]="application/json";else throw new Error("Unknown body type.");a=new Headers({...r||{},...a});let u=await fetch(c,{method:e,headers:a,body:o});if(u.statusCode=u.status,!i.has(u.status))throw new Xd(u);return t==="json"?u.json():t==="buffer"?u.arrayBuffer():t==="string"?u.text():u};wC.exports=ZA(YA)});var TC=p(Zt=>{"use strict";var eT=Zt&&Zt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.RestMessageAdapter=Zt.RestRequestType=void 0;var tT=eT(bC()),AC=P(),Ec;(function(i){i.Get="GET",i.Post="POST",i.Delete="DELETE",i.File="file"})(Ec=Zt.RestRequestType||(Zt.RestRequestType={}));var Zd=class{constructor(e){if(!e)throw new AC.ArgumentNullError("configParams");this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}static extractHeaderValue(e,t){let r="";try{let n=t.trim().split(/[\r\n]+/),s={};n.forEach(o=>{let a=o.split(": "),c=a.shift().toLowerCase(),u=a.join(": ");s[c]=u}),r=s[e.toLowerCase()]}catch{}return r}set options(e){this.privHeaders=e.headers,this.privIgnoreCache=e.ignoreCache}setHeaders(e,t){this.privHeaders[e]=t}request(e,t,r={},n=null){let s=new AC.Deferred,o=e===Ec.File?"POST":e,a=(u,l={})=>{let h=u;return{data:JSON.stringify(l),headers:JSON.stringify(u.headers),json:l,ok:u.statusCode>=200&&u.statusCode<300,status:u.statusCode,statusText:l.error?l.error.message:h.statusText?h.statusText:h.statusMessage}},c=u=>{let l=tT.default(t,o,this.privHeaders,200,201,202,204,400,401,402,403,404),h=this.queryParams(r)===""?"":`?${this.queryParams(r)}`;l(h,u).then(async d=>{if(e===Ec.Delete||d.statusCode===204)s.resolve(a(d));else try{let g=await d.json();s.resolve(a(d,g))}catch{s.resolve(a(d))}}).catch(d=>{s.reject(d)})};return this.privIgnoreCache&&(this.privHeaders["Cache-Control"]="no-cache"),e===Ec.Post&&n&&(this.privHeaders["content-type"]="application/json",this.privHeaders["Content-Type"]="application/json"),c(n),s.promise}queryParams(e={}){return Object.keys(e).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t])).join("&")}};Zt.RestMessageAdapter=Zd});var Yd=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.RestConfigBase=void 0;var Vi=class i{static get requestOptions(){return i.privDefaultRequestOptions}static get configParams(){return i.privDefaultParams}static get restErrors(){return i.privRestErrors}};_c.RestConfigBase=Vi;Vi.privDefaultRequestOptions={headers:{Accept:"application/json"},ignoreCache:!1,timeout:1e4};Vi.privRestErrors={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."};Vi.privDefaultParams={apiVersion:"api-version",authorization:"Authorization",clientAppId:"X-ClientAppId",contentTypeKey:"Content-Type",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"}});var ce=p(ge=>{"use strict";var rT=ge&&ge.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),gt=ge&&ge.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&rT(e,i,t)};Object.defineProperty(ge,"__esModule",{value:!0});gt(Lm(),ge);gt(Fm(),ge);gt(Wm(),ge);gt(Km(),ge);gt(Jm(),ge);gt(ey(),ge);gt(Pl(),ge);gt(ty(),ge);gt(EC(),ge);gt(TC(),ge);gt(Yd(),ge)});var MC=p(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});Ic.IntentConnectionFactory=void 0;var OC=ce(),ss=f(),kC=Ze(),iT=C(),nT=Ie(),ev=class extends kC.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(ss.PropertyId.SpeechServiceConnection_Endpoint);if(!n){let c=e.parameters.getProperty(ss.PropertyId.SpeechServiceConnection_IntentRegion),u=kC.ConnectionFactoryBase.getHostSuffix(c);n=e.parameters.getProperty(ss.PropertyId.SpeechServiceConnection_Host,"wss://"+c+".sr.speech"+u)+"/speech/recognition/interactive/cognitiveservices/v1"}let s={format:"simple",language:e.parameters.getProperty(ss.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,s,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[nT.HeaderNames.ConnectionId]=r,e.parameters.setProperty(ss.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new OC.WebsocketConnection(n,s,o,new iT.WebsocketMessageFormatter,OC.ProxyInfo.fromRecognizerConfig(e),a,r)}getSpeechRegionFromIntentRegion(e){switch(e){case"West US":case"US West":case"westus":return"uswest";case"West US 2":case"US West 2":case"westus2":return"uswest2";case"South Central US":case"US South Central":case"southcentralus":return"ussouthcentral";case"West Central US":case"US West Central":case"westcentralus":return"uswestcentral";case"East US":case"US East":case"eastus":return"useast";case"East US 2":case"US East 2":case"eastus2":return"useast2";case"West Europe":case"Europe West":case"westeurope":return"europewest";case"North Europe":case"Europe North":case"northeurope":return"europenorth";case"Brazil South":case"South Brazil":case"southbrazil":return"brazilsouth";case"Australia East":case"East Australia":case"eastaustralia":return"australiaeast";case"Southeast Asia":case"Asia Southeast":case"southeastasia":return"asiasoutheast";case"East Asia":case"Asia East":case"eastasia":return"asiaeast";default:return e}}};Ic.IntentConnectionFactory=ev});var qC=p(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.VoiceProfileConnectionFactory=Ui.SpeakerRecognitionConnectionFactory=void 0;var DC=ce(),ri=f(),xC=Ze(),sT=C(),NC=Ie(),wc=class extends xC.ConnectionFactoryBase{create(e,t,r,n){let s=e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_Endpoint);if(!s){let u=e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_Region),l=xC.ConnectionFactoryBase.getHostSuffix(u),h=e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_Host,`wss://${u}.spr-frontend.speech${l}`),d=e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_SpeakerIdMode,"TextIndependentIdentification");s=`${h}/speaker/ws/${this.scenarioToPath(d)}/${r}`}let o={format:"simple",language:e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_RecoLanguage)};this.setCommonUrlParams(e,o,s);let a={};t.token!==void 0&&t.token!==""&&(a[t.headerName]=t.token),a[NC.HeaderNames.ConnectionId]=n,a[NC.HeaderNames.SpIDAuthKey]=e.parameters.getProperty(ri.PropertyId.SpeechServiceConnection_Key),e.parameters.setProperty(ri.PropertyId.SpeechServiceConnection_Url,s);let c=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new DC.WebsocketConnection(s,o,a,new sT.WebsocketMessageFormatter,DC.ProxyInfo.fromRecognizerConfig(e),c,n)}scenarioToPath(e){switch(e){case"TextIndependentVerification":case"2":return"verification/text-independent";case"TextDependentVerification":case"1":return"verification/text-dependent";default:return"identification/text-independent"}}},tv=class extends wc{create(e,t,r){return super.create(e,t,"recognition",r)}};Ui.SpeakerRecognitionConnectionFactory=tv;var rv=class extends wc{create(e,t,r){return super.create(e,t,"profile",r)}};Ui.VoiceProfileConnectionFactory=rv});var Ac=p(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.RecognitionEndedEvent=me.RecognitionCompletionStatus=me.RecognitionStartedEvent=me.ConnectingToServiceEvent=me.ListeningStartedEvent=me.RecognitionTriggeredEvent=me.SpeechRecognitionEvent=void 0;var bc=P(),Sr=class extends bc.PlatformEvent{constructor(e,t,r,n=bc.EventType.Info){super(e,n),this.privRequestId=t,this.privSessionId=r}get requestId(){return this.privRequestId}get sessionId(){return this.privSessionId}};me.SpeechRecognitionEvent=Sr;var iv=class extends Sr{constructor(e,t,r,n){super("RecognitionTriggeredEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};me.RecognitionTriggeredEvent=iv;var nv=class extends Sr{constructor(e,t,r,n){super("ListeningStartedEvent",e,t),this.privAudioSourceId=r,this.privAudioNodeId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}};me.ListeningStartedEvent=nv;var sv=class extends Sr{constructor(e,t,r){super("ConnectingToServiceEvent",e,r),this.privAuthFetchEventid=t}get authFetchEventid(){return this.privAuthFetchEventid}};me.ConnectingToServiceEvent=sv;var ov=class extends Sr{constructor(e,t,r,n,s){super("RecognitionStartedEvent",e,s),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}};me.RecognitionStartedEvent=ov;var jC;(function(i){i[i.Success=0]="Success",i[i.AudioSourceError=1]="AudioSourceError",i[i.AudioSourceTimeout=2]="AudioSourceTimeout",i[i.AuthTokenFetchError=3]="AuthTokenFetchError",i[i.AuthTokenFetchTimeout=4]="AuthTokenFetchTimeout",i[i.UnAuthorized=5]="UnAuthorized",i[i.ConnectTimeout=6]="ConnectTimeout",i[i.ConnectError=7]="ConnectError",i[i.ClientRecognitionActivityTimeout=8]="ClientRecognitionActivityTimeout",i[i.UnknownError=9]="UnknownError"})(jC=me.RecognitionCompletionStatus||(me.RecognitionCompletionStatus={}));var av=class extends Sr{constructor(e,t,r,n,s,o,a,c){super("RecognitionEndedEvent",e,s,a===jC.Success?bc.EventType.Info:bc.EventType.Error),this.privAudioSourceId=t,this.privAudioNodeId=r,this.privAuthFetchEventId=n,this.privStatus=a,this.privError=c,this.privServiceTag=o}get audioSourceId(){return this.privAudioSourceId}get audioNodeId(){return this.privAudioNodeId}get authFetchEventId(){return this.privAuthFetchEventId}get serviceTag(){return this.privServiceTag}get status(){return this.privStatus}get error(){return this.privError}};me.RecognitionEndedEvent=av});var ii=p(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});Tc.SpeechConnectionMessage=void 0;var cv=P(),Yt=Ie(),uv=class i extends cv.ConnectionMessage{constructor(e,t,r,n,s,o,a,c){if(!t)throw new cv.ArgumentNullError("path");if(!r)throw new cv.ArgumentNullError("requestId");let u={};if(u[Yt.HeaderNames.Path]=t,u[Yt.HeaderNames.RequestId]=r,u[Yt.HeaderNames.RequestTimestamp]=new Date().toISOString(),n&&(u[Yt.HeaderNames.ContentType]=n),o&&(u[Yt.HeaderNames.RequestStreamId]=o),a)for(let l in a)l&&(u[l]=a[l]);c?super(e,s,u,c):super(e,s,u),this.privPath=t,this.privRequestId=r,this.privContentType=n,this.privStreamId=o,this.privAdditionalHeaders=a}get path(){return this.privPath}get requestId(){return this.privRequestId}get contentType(){return this.privContentType}get streamId(){return this.privStreamId}get additionalHeaders(){return this.privAdditionalHeaders}static fromConnectionMessage(e){let t=null,r=null,n=null,s=null,o={};if(e.headers)for(let a in e.headers)a&&(a.toLowerCase()===Yt.HeaderNames.Path.toLowerCase()?t=e.headers[a]:a.toLowerCase()===Yt.HeaderNames.RequestId.toLowerCase()?r=e.headers[a]:a.toLowerCase()===Yt.HeaderNames.ContentType.toLowerCase()?n=e.headers[a]:a.toLowerCase()===Yt.HeaderNames.RequestStreamId.toLowerCase()?s=e.headers[a]:o[a]=e.headers[a]);return new i(e.messageType,t,r,n,e.body,s,o,e.id)}};Tc.SpeechConnectionMessage=uv});var zC=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.ServiceRecognizerBase=void 0;var oT=ce(),Z=P(),B=f(),Ot=C(),Cr=ii(),Oc=class i{constructor(e,t,r,n,s){if(this.privConnectionConfigurationPromise=void 0,this.privConnectionPromise=void 0,this.privSetTimeout=setTimeout,this.privIsLiveAudio=!1,this.privAverageBytesPerMs=0,this.privEnableSpeakerId=!1,this.privExpectContentAssessmentResponse=!1,this.recognizeOverride=void 0,this.recognizeSpeaker=void 0,this.disconnectOverride=void 0,this.receiveMessageOverride=void 0,this.sendPrePayloadJSONOverride=void 0,this.postConnectImplOverride=void 0,this.configConnectionOverride=void 0,this.handleSpeechPhraseMessage=void 0,this.handleSpeechHypothesisMessage=void 0,!e)throw new Z.ArgumentNullError("authentication");if(!t)throw new Z.ArgumentNullError("connectionFactory");if(!r)throw new Z.ArgumentNullError("audioSource");if(!n)throw new Z.ArgumentNullError("recognizerConfig");this.privEnableSpeakerId=n.isSpeakerDiarizationEnabled,this.privMustReportEndOfStream=!1,this.privAuthentication=e,this.privConnectionFactory=t,this.privAudioSource=r,this.privRecognizerConfig=n,this.privIsDisposed=!1,this.privRecognizer=s,this.privRequestSession=new Ot.RequestSession(this.privAudioSource.id()),this.privConnectionEvents=new Z.EventSource,this.privServiceEvents=new Z.EventSource,this.privDynamicGrammar=new Ot.DynamicGrammarBuilder,this.privSpeechContext=new Ot.SpeechContext(this.privDynamicGrammar),this.privAgentConfig=new Ot.AgentConfig,this.privRecognizerConfig.parameters.getProperty(B.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?this.privSetTimeout=Z.Timeout.setTimeout:typeof window<"u"&&(this.privSetTimeout=window.setTimeout.bind(window)),this.connectionEvents.attach(a=>{if(a.name==="ConnectionClosedEvent"){let c=a;(c.statusCode===1003||c.statusCode===1007||c.statusCode===1002||c.statusCode===4e3||this.privRequestSession.numConnectionAttempts>this.privRecognizerConfig.maxRetryCount)&&this.cancelRecognitionLocal(B.CancellationReason.Error,c.statusCode===1007?B.CancellationErrorCode.BadRequestParameters:B.CancellationErrorCode.ConnectionFailure,`${c.reason} websocket error code: ${c.statusCode}`)}}),this.privEnableSpeakerId&&(this.privDiarizationSessionId=Z.createNoDashGuid()),this.setLanguageIdJson(),this.setOutputDetailLevelJson()}setTranslationJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0);if(e!==void 0){let t=e.split(","),r=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationVoice,void 0),n=r!==void 0?"Synthesize":"None";if(this.privSpeechContext.setSection("translation",{onSuccess:{action:n},output:{interimResults:{mode:"Always"}},targetLanguages:t}),r!==void 0){let s={};for(let o of t)s[o]=r;this.privSpeechContext.setSection("synthesis",{defaultVoices:s})}}}setSpeechSegmentationTimeoutJson(){let e=this.privRecognizerConfig.parameters.getProperty(B.PropertyId.Speech_SegmentationSilenceTimeoutMs,void 0);if(e!==void 0){let t=this.recognitionMode===Ot.RecognitionMode.Conversation?"CONVERSATION":this.recognitionMode===Ot.RecognitionMode.Dictation?"DICTATION":"INTERACTIVE",r=parseInt(e,10),n=this.privSpeechContext.getSection("phraseDetection");n.mode=t,n[t]={segmentation:{mode:"Custom",segmentationSilenceTimeoutMs:r}},this.privSpeechContext.setSection("phraseDetection",n)}}setLanguageIdJson(){let e=this.privSpeechContext.getSection("phraseDetection");if(this.privRecognizerConfig.autoDetectSourceLanguages!==void 0){let r=this.privRecognizerConfig.autoDetectSourceLanguages.split(","),n;this.privRecognizerConfig.languageIdMode==="Continuous"?n="DetectContinuous":n="DetectAtAudioStart",this.privSpeechContext.setSection("languageId",{Priority:"PrioritizeLatency",languages:r,mode:n,onSuccess:{action:"Recognize"},onUnknown:{action:"None"}}),this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"Auto"},phraseResults:{resultType:"Always"}});let s=this.privRecognizerConfig.sourceLanguageModels;s!==void 0&&(e.customModels=s,e.onInterim={action:"None"},e.onSuccess={action:"None"})}this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_TranslationToLanguages,void 0)!==void 0&&(e.onInterim={action:"Translate"},e.onSuccess={action:"Translate"},this.privSpeechContext.setSection("phraseOutput",{interimResults:{resultType:"None"},phraseResults:{resultType:"None"}})),this.privSpeechContext.setSection("phraseDetection",e)}setOutputDetailLevelJson(){this.privEnableSpeakerId&&(this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true"?this.privSpeechContext.setWordLevelTimings():this.privRecognizerConfig.parameters.getProperty(Ot.OutputFormatPropertyName,B.OutputFormat[B.OutputFormat.Simple]).toLowerCase()===B.OutputFormat[B.OutputFormat.Detailed].toLocaleLowerCase()&&this.privSpeechContext.setDetailedOutputFormat())}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}get audioSource(){return this.privAudioSource}get speechContext(){return this.privSpeechContext}get dynamicGrammar(){return this.privDynamicGrammar}get agentConfig(){return this.privAgentConfig}set conversationTranslatorToken(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.ConversationTranslator_Token,e)}set voiceProfileType(e){this.privRecognizerConfig.parameters.setProperty(B.PropertyId.SpeechServiceConnection_SpeakerIdMode,e)}set authentication(e){this.privAuthentication=e}isDisposed(){return this.privIsDisposed}async dispose(e){if(this.privIsDisposed=!0,this.privConnectionConfigurationPromise!==void 0)try{await(await this.privConnectionConfigurationPromise).dispose(e)}catch{return}}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}get recognitionMode(){return this.privRecognizerConfig.recognitionMode}async recognize(e,t,r){if(this.recognizeOverride!==void 0){await this.recognizeOverride(e,t,r);return}this.privConnectionConfigurationPromise=void 0,this.privRecognizerConfig.recognitionMode=e,this.setSpeechSegmentationTimeoutJson(),this.setTranslationJson(),this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);let n=this.connectImpl(),s;try{let c=await this.audioSource.attach(this.privRequestSession.audioNodeId),u=await this.audioSource.format,l=await this.audioSource.deviceInfo;this.privIsLiveAudio=l.type&&l.type===Ot.type.Microphones,s=new oT.ReplayableAudioNode(c,u.avgBytesPerSec),await this.privRequestSession.onAudioSourceAttachCompleted(s,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:l}}catch(c){throw await this.privRequestSession.onStopRecognizing(),c}try{await n}catch(c){await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.ConnectionFailure,c);return}let o=new B.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,o),this.receiveMessage(),this.sendAudio(s).catch(async c=>{await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.RuntimeError,c)})}async stopRecognizing(){if(this.privRequestSession.isRecognizing)try{await this.audioSource.turnOff(),await this.sendFinalAudio(),await this.privRequestSession.onStopRecognizing(),await this.privRequestSession.turnCompletionPromise}finally{await this.privRequestSession.dispose()}}async connect(){return await this.connectImpl(),Promise.resolve()}connectAsync(e,t){this.connectImpl().then(()=>{try{e&&e()}catch(r){t&&t(r)}},r=>{try{t&&t(r)}catch{}})}async disconnect(){if(await this.cancelRecognitionLocal(B.CancellationReason.Error,B.CancellationErrorCode.NoError,"Disconnecting"),this.disconnectOverride!==void 0&&await this.disconnectOverride(),this.privConnectionPromise!==void 0)try{await(await this.privConnectionPromise).dispose()}catch{}this.privConnectionPromise=void 0}sendMessage(e){}async sendNetworkMessage(e,t){let r=typeof t=="string"?Z.MessageType.Text:Z.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Cr.SpeechConnectionMessage(r,e,this.privRequestSession.requestId,n,t))}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set expectContentAssessmentResponse(e){this.privExpectContentAssessmentResponse=e}async sendTelemetryData(){let e=this.privRequestSession.getTelemetry();if(i.telemetryDataEnabled!==!0||this.privIsDisposed||e===null)return;if(i.telemetryData)try{i.telemetryData(e)}catch{}await(await this.fetchConnection()).send(new Cr.SpeechConnectionMessage(Z.MessageType.Text,"telemetry",this.privRequestSession.requestId,"application/json",e))}async cancelRecognitionLocal(e,t,r){this.privRequestSession.isRecognizing&&(await this.privRequestSession.onStopRecognizing(),this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,e,t,r))}async receiveMessage(){try{if(this.privIsDisposed)return;let e=await this.fetchConnection(),t=await e.read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(!t)return this.receiveMessage();this.privServiceHasSentMessage=!0;let r=Cr.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privRequestSession.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privMustReportEndOfStream=!0,this.privRequestSession.onServiceTurnStartResponse();break;case"speech.startdetected":let n=Ot.SpeechDetected.fromJSON(r.textBody),s=new B.RecognitionEventArgs(n.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,s);break;case"speech.enddetected":let o;r.textBody.length>0?o=r.textBody:o="{ Offset: 0 }";let a=Ot.SpeechDetected.fromJSON(o),c=new B.RecognitionEventArgs(a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,c);break;case"turn.end":await this.sendTelemetryData(),this.privRequestSession.isSpeechEnded&&this.privMustReportEndOfStream&&(this.privMustReportEndOfStream=!1,await this.cancelRecognitionLocal(B.CancellationReason.EndOfStream,B.CancellationErrorCode.NoError,void 0));let u=new B.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition),!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing){this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,u);return}else e=await this.fetchConnection(),await this.sendPrePayloadJSON(e);break;default:await this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new Z.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{return null}}updateSpeakerDiarizationAudioOffset(){let t=this.privRequestSession.recognitionBytesSent/this.privAverageBytesPerMs;this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(t)}sendSpeechContext(e,t){this.privEnableSpeakerId&&this.updateSpeakerDiarizationAudioOffset();let r=this.speechContext.toJSON();if(t&&this.privRequestSession.onSpeechContext(),r)return e.send(new Cr.SpeechConnectionMessage(Z.MessageType.Text,"speech.context",this.privRequestSession.requestId,"application/json",r))}noOp(){}async sendPrePayloadJSON(e,t=!0){if(this.sendPrePayloadJSONOverride!==void 0)return this.sendPrePayloadJSONOverride(e);await this.sendSpeechContext(e,t),await this.sendWaveHeader(e)}async sendWaveHeader(e){let t=await this.audioSource.format;return e.send(new Cr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,"audio/x-wav",t.header))}connectImpl(){return this.privConnectionPromise!==void 0?this.privConnectionPromise.then(e=>e.state()===Z.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=void 0,this.privServiceHasSentMessage=!1,this.connectImpl())):(this.privConnectionPromise=this.retryableConnect(),this.privConnectionPromise.catch(()=>{}),this.postConnectImplOverride!==void 0?this.postConnectImplOverride(this.privConnectionPromise):this.privConnectionPromise)}sendSpeechServiceConfig(e,t,r){if(t.onSpeechContext(),i.telemetryDataEnabled!==!0){let s={context:{system:JSON.parse(r).context.system}};r=JSON.stringify(s)}if(this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()==="true"){let n=JSON.parse(r);n.context.DisableReferenceChannel="True",n.context.MicSpec="1_0_0",r=JSON.stringify(n)}if(r)return e.send(new Cr.SpeechConnectionMessage(Z.MessageType.Text,"speech.config",t.requestId,"application/json",r))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Z.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.privServiceHasSentMessage=!1,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async sendAudio(e){let t=await this.audioSource.format;this.privAverageBytesPerMs=t.avgBytesPerSec/1e3;let r=Date.now(),n=this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs","5000"),s=t.avgBytesPerSec/1e3*parseInt(n,10),o=this.privRequestSession.recogNumber,a=async()=>{if(!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o){let c=await this.fetchConnection(),u=await e.read();if(this.privRequestSession.isSpeechEnded)return;let l,h;if(!u||u.isEnd?(l=null,h=0):(l=u.buffer,this.privRequestSession.onAudioSent(l.byteLength),s>=this.privRequestSession.bytesSent?h=0:h=Math.max(0,r-Date.now())),h!==0&&await this.delay(h),l!==null&&(r=Date.now()+l.byteLength*1e3/(t.avgBytesPerSec*2)),!this.privIsDisposed&&!this.privRequestSession.isSpeechEnded&&this.privRequestSession.isRecognizing&&this.privRequestSession.recogNumber===o)if(c.send(new Cr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,null,l)).catch(()=>{this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(()=>{})}),u?.isEnd)this.privIsLiveAudio||this.privRequestSession.onSpeechEnded();else return a()}};return a()}async retryableConnect(){let e=!1;this.privAuthFetchEventId=Z.createNoDashGuid();let t=this.privRequestSession.sessionId;this.privConnectionId=t!==void 0?t:Z.createNoDashGuid(),this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId,this.privConnectionId);let r=0,n="";for(;this.privRequestSession.numConnectionAttempts<=this.privRecognizerConfig.maxRetryCount;){let o=await(e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId));await this.privRequestSession.onAuthCompleted(!1);let a=this.privConnectionFactory.create(this.privRecognizerConfig,o,this.privConnectionId);this.privRequestSession.listenForServiceTelemetry(a.events),a.events.attach(u=>{this.connectionEvents.onEvent(u)});let c=await a.open();if(c.statusCode===200)return await this.privRequestSession.onConnectionEstablishCompleted(c.statusCode),Promise.resolve(a);c.statusCode===1006&&(e=!0),r=c.statusCode,n=c.reason,this.privRequestSession.onRetryConnection()}return await this.privRequestSession.onConnectionEstablishCompleted(r,n),Promise.reject(`Unable to contact server. StatusCode: ${r}, ${this.privRecognizerConfig.parameters.getProperty(B.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${n}`)}delay(e){return new Promise(t=>this.privSetTimeout(t,e))}writeBufferToConsole(e){let t="Buffer Size: ";if(e===null)t+="null";else{let r=new Uint8Array(e);t+=`${e.byteLength}\r
|
|
19
|
+
`;for(let n=0;n<e.byteLength;n++)t+=r[n].toString(16).padStart(2,"0")+" ",(n+1)%16===0&&(console.info(t),t="")}console.info(t)}async sendFinalAudio(){await(await this.fetchConnection()).send(new Cr.SpeechConnectionMessage(Z.MessageType.Binary,"audio",this.privRequestSession.requestId,null,null))}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendPrePayloadJSON(e,!1),e)}};kc.ServiceRecognizerBase=Oc;Oc.telemetryDataEnabled=!0});var LC=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.ConversationServiceRecognizer=void 0;var tt=f(),kt=C(),pv=class extends kt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.handleSpeechPhraseMessage=async o=>this.handleSpeechPhrase(o),this.handleSpeechHypothesisMessage=o=>this.handleSpeechHypothesis(o)}processTypeSpecificMessages(e){}handleRecognizedCallback(e,t,r){}handleRecognizingCallback(e,t,r){}async processSpeechMessages(e){let t=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":this.handleSpeechHypothesisMessage&&this.handleSpeechHypothesisMessage(e.textBody),t=!0;break;case"speech.phrase":this.handleSpeechPhraseMessage&&await this.handleSpeechPhraseMessage(e.textBody),t=!0;break;default:break}return t}cancelRecognition(e,t,r,n,s){}async handleSpeechPhrase(e){let t=kt.SimpleSpeechPhrase.fromJSON(e),r=kt.EnumTranslation.implTranslateRecognitionResult(t.RecognitionStatus),n,s=new tt.PropertyCollection;s.setProperty(tt.PropertyId.SpeechServiceResponse_JsonResult,e);let o=t.Offset+this.privRequestSession.currentTurnAudioOffset,a=o;if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+t.Offset+t.Duration),tt.ResultReason.Canceled===r){let c=kt.EnumTranslation.implTranslateCancelResult(t.RecognitionStatus),u=kt.EnumTranslation.implTranslateCancelErrorCode(t.RecognitionStatus);await this.cancelRecognitionLocal(c,u,kt.EnumTranslation.implTranslateErrorDetails(u))}else if(!(this.privRequestSession.isSpeechEnded&&r===tt.ResultReason.NoMatch&&t.RecognitionStatus!==kt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(kt.OutputFormatPropertyName)===tt.OutputFormat[tt.OutputFormat.Simple])n=new tt.SpeechRecognitionResult(this.privRequestSession.requestId,r,t.DisplayText,t.Duration,o,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,s);else{let c=kt.DetailedSpeechPhrase.fromJSON(e),u=c.Offset+this.privRequestSession.currentTurnAudioOffset,l=c.getJsonWithCorrectedOffsets(u);n=new tt.SpeechRecognitionResult(this.privRequestSession.requestId,r,c.Text,c.Duration,u,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,l,s),a=n.offset}this.handleRecognizedCallback(n,a,this.privRequestSession.sessionId)}}handleSpeechHypothesis(e){let t=kt.SpeechHypothesis.fromJSON(e),r=t.Offset+this.privRequestSession.currentTurnAudioOffset,n=new tt.PropertyCollection;n.setProperty(tt.PropertyId.SpeechServiceResponse_JsonResult,e);let s=new tt.SpeechRecognitionResult(this.privRequestSession.requestId,tt.ResultReason.RecognizingSpeech,t.Text,t.Duration,r,t.Language,t.LanguageDetectionConfidence,t.SpeakerId,void 0,e,n);this.privRequestSession.onHypothesis(r),this.handleRecognizingCallback(s,t.Duration,this.privRequestSession.sessionId)}};Mc.ConversationServiceRecognizer=pv});var FC=p(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.RecognizerConfig=Mt.SpeechResultFormat=Mt.RecognitionMode=void 0;var Dc=f(),BC=C(),xc;(function(i){i[i.Interactive=0]="Interactive",i[i.Conversation=1]="Conversation",i[i.Dictation=2]="Dictation"})(xc=Mt.RecognitionMode||(Mt.RecognitionMode={}));var aT;(function(i){i[i.Simple=0]="Simple",i[i.Detailed=1]="Detailed"})(aT=Mt.SpeechResultFormat||(Mt.SpeechResultFormat={}));var lv=class{constructor(e,t){this.privSpeechServiceConfig=e||new BC.SpeechServiceConfig(new BC.Context(null)),this.privParameters=t,this.privMaxRetryCount=parseInt(t.getProperty("SPEECH-Error-MaxRetryCount","4"),10),this.privLanguageIdMode=t.getProperty(Dc.PropertyId.SpeechServiceConnection_LanguageIdMode,void 0),this.privEnableSpeakerId=!1}get parameters(){return this.privParameters}get recognitionMode(){return this.privRecognitionMode}set recognitionMode(e){this.privRecognitionMode=e,this.privRecognitionActivityTimeout=e===xc.Interactive?8e3:25e3,this.privSpeechServiceConfig.Recognition=xc[e]}get SpeechServiceConfig(){return this.privSpeechServiceConfig}get recognitionActivityTimeout(){return this.privRecognitionActivityTimeout}get isContinuousRecognition(){return this.privRecognitionMode!==xc.Interactive}get languageIdMode(){return this.privLanguageIdMode}get autoDetectSourceLanguages(){return this.parameters.getProperty(Dc.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages,void 0)}get recognitionEndpointVersion(){return this.parameters.getProperty(Dc.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion,void 0)}get sourceLanguageModels(){let e=[],t=!1;if(this.autoDetectSourceLanguages!==void 0)for(let r of this.autoDetectSourceLanguages.split(",")){let n=r+Dc.PropertyId.SpeechServiceConnection_EndpointId.toString(),s=this.parameters.getProperty(n,void 0);s!==void 0?(e.push({language:r,endpoint:s}),t=!0):e.push({language:r,endpoint:""})}return t?e:void 0}get maxRetryCount(){return this.privMaxRetryCount}get isSpeakerDiarizationEnabled(){return this.privEnableSpeakerId}set isSpeakerDiarizationEnabled(e){this.privEnableSpeakerId=e}};Mt.RecognizerConfig=lv});var UC=p(VC=>{"use strict";Object.defineProperty(VC,"__esModule",{value:!0})});var HC=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.WebsocketMessageFormatter=void 0;var rt=P(),WC=`\r
|
|
20
|
+
`,hv=class{toConnectionMessage(e){let t=new rt.Deferred;try{if(e.messageType===rt.MessageType.Text){let r=e.textContent,n={},s=null;if(r){let o=r.split(`\r
|
|
21
21
|
\r
|
|
22
|
-
`);o&&o.length>0&&(n=this.parseHeaders(o[0]),o.length>1&&(s=o[1]))}t.resolve(new Ze.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===Ze.MessageType.Binary){let r=e.binaryContent,n={},s=null;if(!r||r.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");let o=new DataView(r),a=o.getInt16(0);if(r.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");let c="";for(let u=0;u<a;u++)c+=String.fromCharCode(o.getInt8(u+2));n=this.parseHeaders(c),r.byteLength>a+2&&(s=r.slice(2+a)),t.resolve(new Ze.ConnectionMessage(e.messageType,s,n,e.id))}}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new Ze.Deferred;try{if(e.messageType===Ze.MessageType.Text){let r=`${this.makeHeaders(e)}${CC}${e.textBody?e.textBody:""}`;t.resolve(new Ze.RawWebsocketMessage(Ze.MessageType.Text,r,e.id))}else if(e.messageType===Ze.MessageType.Binary){let r=this.makeHeaders(e),n=e.binaryBody,s=this.stringToArrayBuffer(r),o=new Int8Array(s),a=o.byteLength,c=new Int8Array(2+a+(n?n.byteLength:0));if(c[0]=a>>8&255,c[1]=a&255,c.set(o,2),n){let d=new Int8Array(n);c.set(d,2+a)}let u=c.buffer;t.resolve(new Ze.RawWebsocketMessage(Ze.MessageType.Binary,u,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}makeHeaders(e){let t="";if(e.headers)for(let r in e.headers)r&&(t+=`${r}: ${e.headers[r]}${CC}`);return t}parseHeaders(e){let t={};if(e){let r=e.match(/[^\r\n]+/g);if(t){for(let n of r)if(n){let s=n.indexOf(":"),o=s>0?n.substr(0,s).trim().toLowerCase():n,a=s>0&&n.length>s+1?n.substr(s+1).trim():"";t[o]=a}}}return t}stringToArrayBuffer(e){let t=new ArrayBuffer(e.length),r=new DataView(t);for(let n=0;n<e.length;n++)r.setUint8(n,e.charCodeAt(n));return t}};Tc.WebsocketMessageFormatter=ev});var IC=p(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.SpeechConnectionFactory=void 0;var RC=ae(),EC=C(),gr=f(),wC=$e(),tv=C(),DA=we(),Yr=Wt(),rv=class extends wC.ConnectionFactoryBase{constructor(){super(...arguments),this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.universalUri="/speech/universal/v"}create(e,t,r){let n=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_Region,void 0),o=wC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(gr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(Yr.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[Yr.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(Yr.QueryParameterNames.Language)===-1)&&(c[Yr.QueryParameterNames.Language]=d),(!n||n.search(Yr.QueryParameterNames.Format)===-1)&&(c[Yr.QueryParameterNames.Format]=e.parameters.getProperty(EC.OutputFormatPropertyName,gr.OutputFormat[gr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[Yr.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case tv.RecognitionMode.Conversation:e.parameters.getProperty(EC.ForceDictationPropertyName,"false")==="true"?n=a+this.dictationRelativeUri:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.conversationRelativeUri;break;case tv.RecognitionMode.Dictation:n=a+this.dictationRelativeUri;break;default:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.interactiveRelativeUri;break}let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[DA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new RC.WebsocketConnection(n,c,h,new tv.WebsocketMessageFormatter,RC.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(gr.PropertyId.SpeechServiceConnection_Url,_),g}};_c.SpeechConnectionFactory=rv});var AC=p(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});Ac.ConversationTranscriberConnectionFactory=void 0;var TC=ae(),Fe=f(),kA=C(),_C=$e(),NA=C(),xA=we(),et=Wt(),iv=class extends _C.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Region,void 0),o=_C.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_EndpointId,void 0),d=e.parameters.getProperty(Fe.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(et.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[et.QueryParameterNames.CustomSpeechDeploymentId]=u):d&&(!n||n.search(et.QueryParameterNames.Language)===-1)&&(c[et.QueryParameterNames.Language]=d),e.autoDetectSourceLanguages!==void 0&&(c[et.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[xA.HeaderNames.ConnectionId]=r;let l=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new TC.WebsocketConnection(n,c,h,new NA.WebsocketMessageFormatter,TC.ProxyInfo.fromRecognizerConfig(e),l,r),_=g.uri;return e.parameters.setProperty(Fe.PropertyId.SpeechServiceConnection_Url,_),g}setV2UrlParams(e,t,r){new Map([[Fe.PropertyId.Speech_SegmentationSilenceTimeoutMs,et.QueryParameterNames.SegmentationSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_EnableAudioLogging,et.QueryParameterNames.EnableAudioLogging],[Fe.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,et.QueryParameterNames.EndSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,et.QueryParameterNames.InitialSilenceTimeoutMs],[Fe.PropertyId.SpeechServiceResponse_PostProcessingOption,et.QueryParameterNames.Postprocessing],[Fe.PropertyId.SpeechServiceResponse_ProfanityOption,et.QueryParameterNames.Profanity],[Fe.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,et.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(kA.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};Ac.ConversationTranscriberConnectionFactory=iv});var DC=p(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.TranscriberConnectionFactory=void 0;var bC=ae(),Ve=f(),OC=$e(),MC=C(),qA=we(),Xn=Wt(),nv=class extends OC.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Region,"centralus"),o=OC.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let d={};t.token!==void 0&&t.token!==""&&(d[t.headerName]=t.token),d[qA.HeaderNames.ConnectionId]=r,e.parameters.setProperty(Ve.PropertyId.SpeechServiceConnection_Url,n);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new bC.WebsocketConnection(n,u,d,new MC.WebsocketMessageFormatter,bC.ProxyInfo.fromRecognizerConfig(e),h,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(Ve.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(Xn.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[Xn.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(Xn.QueryParameterNames.Language in e)&&(e[Xn.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(Ve.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty(MC.OutputFormatPropertyName,Ve.OutputFormat[Ve.OutputFormat.Simple])!==Ve.OutputFormat[Ve.OutputFormat.Simple];(o||a)&&(e[Xn.QueryParameterNames.Format]=Ve.OutputFormat[Ve.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};bc.TranscriberConnectionFactory=nv});var qC=p(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.TranslationConnectionFactory=void 0;var kC=ae(),zA=Jh(),$t=f(),NC=$e(),sv=C(),jA=we(),xC=Wt(),ov=class extends NC.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[xC.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[jA.HeaderNames.ConnectionId]=r,e.parameters.setProperty($t.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new kC.WebsocketConnection(n,s,o,new sv.WebsocketMessageFormatter,kC.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Region),n=NC.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty($t.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:zA.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===sv.RecognitionMode.Interactive?"interactive":t.recognitionMode===sv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter($t.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,xC.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty($t.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};Oc.TranslationConnectionFactory=ov});var zC=p(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});Mc.EnumTranslation=void 0;var ce=f(),ie=C(),av=class{static implTranslateRecognitionResult(e,t=!1){let r=ce.ResultReason.Canceled;switch(e){case ie.RecognitionStatus.Success:r=ce.ResultReason.RecognizedSpeech;break;case ie.RecognitionStatus.EndOfDictation:r=t?ce.ResultReason.RecognizedSpeech:ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.NoMatch:case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:r=ce.ResultReason.NoMatch;break;case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:r=ce.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ce.CancellationReason.EndOfStream;switch(e){case ie.RecognitionStatus.Success:case ie.RecognitionStatus.EndOfDictation:case ie.RecognitionStatus.NoMatch:t=ce.CancellationReason.EndOfStream;break;case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:t=ce.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ce.CancellationErrorCode.NoError;switch(e){case ie.RecognitionStatus.Error:t=ce.CancellationErrorCode.ServiceError;break;case ie.RecognitionStatus.TooManyRequests:t=ce.CancellationErrorCode.TooManyRequests;break;case ie.RecognitionStatus.BadRequest:t=ce.CancellationErrorCode.BadRequestParameters;break;case ie.RecognitionStatus.Forbidden:t=ce.CancellationErrorCode.Forbidden;break;default:t=ce.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ce.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ce.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ce.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};Mc.EnumTranslation=av});var jC=p(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.RecognitionStatus=mr.SynthesisStatus=void 0;var LA;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(LA=mr.SynthesisStatus||(mr.SynthesisStatus={}));var BA;(function(i){i[i.Success=0]="Success",i[i.NoMatch=1]="NoMatch",i[i.InitialSilenceTimeout=2]="InitialSilenceTimeout",i[i.BabbleTimeout=3]="BabbleTimeout",i[i.Error=4]="Error",i[i.EndOfDictation=5]="EndOfDictation",i[i.TooManyRequests=6]="TooManyRequests",i[i.BadRequest=7]="BadRequest",i[i.Forbidden=8]="Forbidden"})(BA=mr.RecognitionStatus||(mr.RecognitionStatus={}))});var BC=p(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.TranslationSynthesisEnd=void 0;var LC=C(),cv=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=LC.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=LC.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};Dc.TranslationSynthesisEnd=cv});var FC=p(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.TranslationHypothesis=void 0;var FA=w(),VA=qs(),pv=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=VA.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){FA.Contracts.throwIfNullOrUndefined(e,"translationHypothesis");let t=e.SpeechHypothesis;return e.SpeechHypothesis=void 0,t.Translation=e,new i(t)}get Duration(){return this.privTranslationHypothesis.Duration}get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){return this.privTranslationHypothesis.PrimaryLanguage?.Language}};kc.TranslationHypothesis=pv});var VC=p(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});Nc.TranslationPhrase=void 0;var UA=w(),WA=C(),HA=qs(),uv=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=WA.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=HA.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){UA.Contracts.throwIfNullOrUndefined(e,"translationResponse");let t=e.SpeechPhrase;return e.SpeechPhrase=void 0,t.Translation=e,t.Text=t.DisplayText,new i(t)}get RecognitionStatus(){return this.privTranslationPhrase.RecognitionStatus}get Offset(){return this.privTranslationPhrase.Offset}get Duration(){return this.privTranslationPhrase.Duration}get Text(){return this.privTranslationPhrase.Text}get Language(){return this.privTranslationPhrase.PrimaryLanguage?.Language}get Confidence(){return this.privTranslationPhrase.PrimaryLanguage?.Confidence}get Translation(){return this.privTranslationPhrase.Translation}};Nc.TranslationPhrase=uv});var WC=p(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});xc.TranslationServiceRecognizer=void 0;var UC=P(),z=f(),Te=C(),dv=class extends Te.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranslationRecognizer=s,this.connectionEvents.attach(o=>{o.name==="ConnectionEstablishedEvent"&&this.privTranslationRecognizer.onConnection()})}async processTypeSpecificMessages(e){let t=new z.PropertyCollection,r=await this.processSpeechMessages(e);if(r)return!0;let n=async o=>{if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus===Te.RecognitionStatus.Success){let a=this.fireEventForResult(o,t);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,a)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(a.result)}catch(c){this.privErrorCallback&&this.privErrorCallback(c)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{let a=Te.EnumTranslation.implTranslateRecognitionResult(o.RecognitionStatus),c=new z.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,a,o.Text,o.Duration,this.privRequestSession.currentTurnAudioOffset+o.Offset,o.Language,o.Confidence,void 0,e.textBody,t);if(a===z.ResultReason.Canceled){let u=Te.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus),d=Te.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,d,Te.EnumTranslation.implTranslateErrorDetails(d))}else{if(!(this.privRequestSession.isSpeechEnded&&a===z.ResultReason.NoMatch&&o.RecognitionStatus!==Te.RecognitionStatus.InitialSilenceTimeout)){let u=new z.TranslationRecognitionEventArgs(c,c.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,u)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(c)}catch(u){this.privErrorCallback&&this.privErrorCallback(u)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}r=!0}},s=(o,a)=>{let c=this.fireEventForResult(o,a);if(this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset+c.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,c)}catch{}r=!0};switch(e.messageType===UC.MessageType.Text&&t.setProperty(z.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":s(Te.TranslationHypothesis.fromJSON(e.textBody),t);break;case"translation.response":let o=JSON.parse(e.textBody);if(o.SpeechPhrase)await n(Te.TranslationPhrase.fromTranslationResponse(o));else{let c=JSON.parse(e.textBody);c.SpeechHypothesis&&s(Te.TranslationHypothesis.fromTranslationResponse(c),t)}break;case"translation.phrase":await n(Te.TranslationPhrase.fromJSON(e.textBody));break;case"translation.synthesis":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId),r=!0;break;case"audio.end":case"translation.synthesis.end":let a=Te.TranslationSynthesisEnd.fromJSON(e.textBody);switch(a.SynthesisStatus){case Te.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){let c=new z.TranslationSynthesisResult(z.ResultReason.Canceled,void 0),u=new z.TranslationSynthesisEventArgs(c,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,u)}catch{}}if(this.privTranslationRecognizer.canceled){let c=new z.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,z.CancellationReason.Error,a.FailureReason,z.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,c)}catch{}}break;case Te.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId);break;default:break}r=!0;break;default:break}return r}cancelRecognition(e,t,r,n,s){let o=new z.PropertyCollection;if(o.setProperty(Te.CancellationErrorCodePropertyName,z.CancellationErrorCode[n]),this.privTranslationRecognizer.canceled){let a=new z.TranslationRecognitionCanceledEventArgs(e,r,s,n,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new z.TranslationRecognitionResult(void 0,t,z.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,n)}catch{}}handleRecognizedCallback(e,t,r){try{let n=new z.TranslationRecognitionEventArgs(z.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,n)}catch{}}fireEventForResult(e,t){let r;if(e.Translation.Translations!==void 0){r=new z.Translations;for(let d of e.Translation.Translations)r.set(d.Language,d.Text||d.DisplayText)}let n,s;e instanceof Te.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===UC.TranslationStatus.Success?n=z.ResultReason.TranslatedSpeech:n=z.ResultReason.RecognizedSpeech,s=e.Confidence):n=z.ResultReason.TranslatingSpeech;let o=e.Language,a=e.Offset+this.privRequestSession.currentTurnAudioOffset,c=new z.TranslationRecognitionResult(r,this.privRequestSession.requestId,n,e.Text,e.Duration,a,o,s,e.Translation.FailureReason,JSON.stringify(e),t);return new z.TranslationRecognitionEventArgs(c,a,this.privRequestSession.sessionId)}sendSynthesisAudio(e,t){let r=e===void 0?z.ResultReason.SynthesizingAudioCompleted:z.ResultReason.SynthesizingAudio,n=new z.TranslationSynthesisResult(r,e),s=new z.TranslationSynthesisEventArgs(n,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,s)}catch{}}};xc.TranslationServiceRecognizer=dv});var HC=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.SpeechDetected=void 0;var hv=class i{constructor(e){this.privSpeechStartDetected=JSON.parse(e)}static fromJSON(e){return new i(e)}get Offset(){return this.privSpeechStartDetected.Offset}};qc.SpeechDetected=hv});var KC=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.SpeechHypothesis=void 0;var lv=class i{constructor(e){this.privSpeechHypothesis=JSON.parse(e)}static fromJSON(e){return new i(e)}get Text(){return this.privSpeechHypothesis.Text}get Offset(){return this.privSpeechHypothesis.Offset}get Duration(){return this.privSpeechHypothesis.Duration}get Language(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSpeechHypothesis.SpeakerId}};zc.SpeechHypothesis=lv});var JC=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.SpeechKeyword=void 0;var vv=class i{constructor(e){this.privSpeechKeyword=JSON.parse(e)}static fromJSON(e){return new i(e)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}};jc.SpeechKeyword=vv});var GC=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.SpeechServiceRecognizer=void 0;var me=f(),tt=C(),fv=class extends tt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new me.PropertyCollection;r.setProperty(me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=tt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,me.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new me.SpeechRecognitionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,a)}catch{}n=!0;break;case"speech.phrase":let c=tt.SimpleSpeechPhrase.fromJSON(e.textBody),u=tt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),me.ResultReason.Canceled===u){let d=tt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=tt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,tt.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&u===me.ResultReason.NoMatch&&c.RecognitionStatus!==tt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(tt.OutputFormatPropertyName)===me.OutputFormat[me.OutputFormat.Simple])t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,void 0,e.textBody,r);else{let h=tt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new me.SpeechRecognitionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===tt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,void 0,void 0,g,r)}let d=new me.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,d)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(d){this.privErrorCallback&&this.privErrorCallback(d)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new me.PropertyCollection;if(o.setProperty(tt.CancellationErrorCodePropertyName,me.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new me.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new me.SpeechRecognitionResult(t,me.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};Lc.SpeechServiceRecognizer=fv});var $C=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.ConversationTranscriptionServiceRecognizer=void 0;var Me=f(),rt=C(),gv=class extends rt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConversationTranscriber=s,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){let e=this.privSpeechContext.getSection("phraseDetection");e.mode="Conversation";let t={};t.mode="Anonymous",t.audioSessionId=this.privDiarizationSessionId,t.audioOffsetMs=0,e.speakerDiarization=t,this.privSpeechContext.setSection("phraseDetection",e)}}async processTypeSpecificMessages(e){let t,r=new Me.PropertyCollection;r.setProperty(Me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=rt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,Me.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new Me.ConversationTranscriptionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,a)}catch{}n=!0;break;case"speech.phrase":let c=rt.SimpleSpeechPhrase.fromJSON(e.textBody),u=rt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Me.ResultReason.Canceled===u){let d=rt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=rt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(d,h,rt.EnumTranslation.implTranslateErrorDetails(h))}else if(!(this.privRequestSession.isSpeechEnded&&u===Me.ResultReason.NoMatch&&c.RecognitionStatus!==rt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(rt.OutputFormatPropertyName)===Me.OutputFormat[Me.OutputFormat.Simple])t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,e.textBody,r);else{let h=rt.DetailedSpeechPhrase.fromJSON(e.textBody),l=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(l);t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===rt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,l,h.Language,h.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let d=new Me.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,d)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Me.PropertyCollection().setProperty(rt.CancellationErrorCodePropertyName,Me.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Me.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};Bc.ConversationTranscriptionServiceRecognizer=gv});var YC=p(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.TranscriptionServiceRecognizer=void 0;var KA=P(),Qt=f(),QC=C(),JA=Qr(),mv=class extends QC.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranscriberRecognizer=s,this.sendPrePayloadJSONOverride=o=>this.sendTranscriptionStartJSON(o),this.privRecognizerConfig.parameters.getProperty(Qt.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)==="true"&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createSpeechEventPayload(e,t))}}async sendMeetingSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createMeetingSpeechEventPayload(e,t))}}processTypeSpecificMessages(e){return this.processSpeechMessages(e)}handleRecognizedCallback(e,t,r){try{let n=new Qt.SpeechRecognitionEventArgs(e,t,r);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,n),this.privSuccessCallback){try{this.privSuccessCallback(e)}catch(s){this.privErrorCallback&&this.privErrorCallback(s)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch{}}handleRecognizingCallback(e,t,r){try{let n=new Qt.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new Qt.PropertyCollection;if(o.setProperty(QC.CancellationErrorCodePropertyName,Qt.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new Qt.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new Qt.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new Qt.SpeechRecognitionResult(t,Qt.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(e){if(await this.sendSpeechContext(e,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){let t=this.privTranscriberRecognizer.getMeetingInfo(),r=this.createMeetingSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}else{let t=this.privTranscriberRecognizer.getConversationInfo(),r=this.createSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}await this.sendWaveHeader(e)}sendSpeechEvent(e,t){let r=JSON.stringify(t);if(r)return e.send(new JA.SpeechConnectionMessage(KA.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",r))}createSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.conversationProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}createMeetingSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.meetingProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}};Fc.TranscriptionServiceRecognizer=mv});var XC=p(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});Vc.DetailedSpeechPhrase=void 0;var GA=C(),Sv=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=GA.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}getJsonWithCorrectedOffsets(e){if(this.privDetailedSpeechPhrase.NBest){let t;for(let r of this.privDetailedSpeechPhrase.NBest)if(r.Words&&r.Words[0]){t=r.Words[0].Offset;break}if(t&&t<e){let r=e-t;for(let n of this.privDetailedSpeechPhrase.NBest){if(n.Words)for(let s of n.Words)s.Offset+=r;if(n.DisplayWords)for(let s of n.DisplayWords)s.Offset+=r}}}return JSON.stringify(this.privDetailedSpeechPhrase)}get RecognitionStatus(){return this.privDetailedSpeechPhrase.RecognitionStatus}get NBest(){return this.privDetailedSpeechPhrase.NBest}get Duration(){return this.privDetailedSpeechPhrase.Duration}get Offset(){return this.privDetailedSpeechPhrase.Offset}get Language(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence}get Text(){return this.privDetailedSpeechPhrase.NBest&&this.privDetailedSpeechPhrase.NBest[0]?this.privDetailedSpeechPhrase.NBest[0].Display||this.privDetailedSpeechPhrase.NBest[0].DisplayText:this.privDetailedSpeechPhrase.DisplayText}get SpeakerId(){return this.privDetailedSpeechPhrase.SpeakerId}};Vc.DetailedSpeechPhrase=Sv});var ZC=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.SimpleSpeechPhrase=void 0;var $A=C(),yv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=$A.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}get RecognitionStatus(){return this.privSimpleSpeechPhrase.RecognitionStatus}get DisplayText(){return this.privSimpleSpeechPhrase.DisplayText}get Offset(){return this.privSimpleSpeechPhrase.Offset}get Duration(){return this.privSimpleSpeechPhrase.Duration}get Language(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSimpleSpeechPhrase.SpeakerId}};Uc.SimpleSpeechPhrase=yv});var eP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.AddedLmIntent=void 0;var Cv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};Wc.AddedLmIntent=Cv});var rP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.IntentServiceRecognizer=void 0;var tP=P(),ne=f(),qi=C(),Pv=class extends qi.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privIntentRecognizer=s,this.privIntentDataSent=!1}setIntents(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0}processTypeSpecificMessages(e){let t,r,n=!1,s=new ne.PropertyCollection;switch(e.messageType===tP.MessageType.Text&&s.setProperty(ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=qi.SpeechHypothesis.fromJSON(e.textBody);if(t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ne.ResultReason.RecognizingIntent,a.Text,a.Duration,a.Offset+this.privRequestSession.currentTurnAudioOffset,a.Language,a.LanguageDetectionConfidence,void 0,e.textBody,s),this.privRequestSession.onHypothesis(t.offset),r=new ne.IntentRecognitionEventArgs(t,a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,r)}catch{}n=!0;break;case"speech.phrase":let c=qi.SimpleSpeechPhrase.fromJSON(e.textBody);t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,qi.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new ne.IntentRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);let u=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||ne.ResultReason.NoMatch===r.result.reason?(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),u()):this.privPendingIntentArgs=r,n=!0;break;case"response":if(r=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,r===void 0){if(e.textBody==="")return;r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let d=qi.IntentResponse.fromJSON(e.textBody);if(d!==null&&d.topScoringIntent&&d.topScoringIntent.intent){let h=this.privAddedLmIntents[d.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(h=this.privUmbrellaIntent),h){let l=h===void 0||h.intentName===void 0?d.topScoringIntent.intent:h.intentName,g=r.result.reason;l!==void 0&&(g=ne.ResultReason.RecognizedIntent);let _=r.result.properties!==void 0?r.result.properties:new ne.PropertyCollection;_.setProperty(ne.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult(l,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,_),r.offset,r.sessionId)}}if(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new tP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new ne.PropertyCollection;if(o.setProperty(qi.CancellationErrorCodePropertyName,ne.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new ne.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ne.IntentRecognitionResult(void 0,t,ne.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};Hc.IntentServiceRecognizer=Pv});var iP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.IntentResponse=void 0;var Rv=class i{constructor(e){e===""?this.privIntentResponse={}:this.privIntentResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}};Kc.IntentResponse=Rv});var sP=p(nP=>{"use strict";Object.defineProperty(nP,"__esModule",{value:!0})});var aP=p(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.ServiceTelemetryListener=void 0;var Yt=P(),oP=yc(),Ev=class{constructor(e,t,r){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)}hypothesisReceived(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)}onEvent(e){this.privIsDisposed||(e instanceof oP.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof Yt.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof Yt.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Yt.AudioStreamNodeErrorEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof Yt.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof oP.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof Yt.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof Yt.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Yt.ConnectionEstablishErrorEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Error:this.getConnectionError(e.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof Yt.ConnectionMessageReceivedEvent&&e.connectionId===this.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path&&(this.privReceivedMessages[e.message.headers.path]||(this.privReceivedMessages[e.message.headers.path]=new Array),this.privReceivedMessages[e.message.headers.path].length<50&&this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)))}getTelemetry(){let e=new Array;this.privListeningTriggerMetric&&e.push(this.privListeningTriggerMetric),this.privMicMetric&&e.push(this.privMicMetric),this.privConnectionEstablishMetric&&e.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&e.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});let t={Metrics:e,ReceivedMessages:this.privReceivedMessages},r=JSON.stringify(t);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],r}get hasTelemetry(){return Object.keys(this.privReceivedMessages).length!==0||this.privListeningTriggerMetric!==null||this.privMicMetric!==null||this.privConnectionEstablishMetric!==null||this.privPhraseLatencies.length!==0||this.privHypothesisLatencies.length!==0}dispose(){this.privIsDisposed=!0}getConnectionError(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()}}};Jc.ServiceTelemetryListener=Ev});var cP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.RequestSession=void 0;var zi=P(),Gc=yc(),QA=aP(),wv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privHypothesisReceived=!1,this.privBytesSent=0,this.privRecognitionBytesSent=0,this.privRecogNumber=0,this.privInTurn=!1,this.privConnectionAttempts=0,this.privAudioSourceId=e,this.privRequestId=zi.createNoDashGuid(),this.privAudioNodeId=zi.createNoDashGuid(),this.privTurnDeferral=new zi.Deferred,this.privTurnDeferral.resolve()}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get audioNodeId(){return this.privAudioNodeId}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSpeechEnded(){return this.privIsSpeechEnded}get isRecognizing(){return this.privIsRecognizing}get currentTurnAudioOffset(){return this.privTurnStartAudioOffset}get recogNumber(){return this.privRecogNumber}get numConnectionAttempts(){return this.privConnectionAttempts}get bytesSent(){return this.privBytesSent}get recognitionBytesSent(){return this.privRecognitionBytesSent}listenForServiceTelemetry(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new QA.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new Gc.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(e,t){this.privAudioNode=e,this.privIsAudioNodeDetached=!1,t?await this.onComplete():this.onEvent(new Gc.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new Gc.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new Gc.RecognitionStartedEvent(this.requestId,this.privAudioSourceId,this.privAudioNodeId,this.privAuthFetchEventId,this.privSessionId)),this.privAudioNode&&this.privAudioNode.replay(),this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privBytesSent=0;return}else e===403&&await this.onComplete()}async onServiceTurnEndResponse(e){this.privTurnDeferral.resolve(),!e||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=zi.createNoDashGuid()}onServiceTurnStartResponse(){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new zi.Deferred}onHypothesis(e){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(e)))}onPhraseRecognized(e){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(e)),this.onServiceRecognized(e)}onServiceRecognized(e){this.privLastRecoOffset=e,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(e),this.privConnectionAttempts=0}onAudioSent(e){this.privBytesSent+=e,this.privRecognitionBytesSent+=e}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(e){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(e),zi.Events.instance.onEvent(e)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}};$c.RequestSession=wv});var pP=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.SpeechContext=void 0;var Iv=class{constructor(e){this.privContext={},this.privDynamicGrammar=e}getSection(e){return this.privContext[e]||{}}setSection(e,t){this.privContext[e]=t}setPronunciationAssessmentParams(e,t,r=!1){this.privContext.phraseDetection===void 0&&(this.privContext.phraseDetection={enrichment:{pronunciationAssessment:{}}}),this.privContext.phraseDetection.enrichment===void 0&&(this.privContext.phraseDetection.enrichment={pronunciationAssessment:{}}),this.privContext.phraseDetection.enrichment.pronunciationAssessment=JSON.parse(e),r&&(this.privContext.phraseDetection.mode="Conversation"),this.setWordLevelTimings(),this.privContext.phraseOutput.detailed.options.push("PronunciationAssessment"),this.privContext.phraseOutput.detailed.options.indexOf("SNR")===-1&&this.privContext.phraseOutput.detailed.options.push("SNR"),t&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:t},this.privContext.phraseOutput.detailed.options.push("ContentAssessment"))}setDetailedOutputFormat(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed"}setWordLevelTimings(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed",this.privContext.phraseOutput.detailed.options.indexOf("WordTimings")===-1&&this.privContext.phraseOutput.detailed.options.push("WordTimings")}setSpeakerDiarizationAudioOffsetMs(e){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=e}toJSON(){let e=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",e),JSON.stringify(this.privContext)}};Qc.SpeechContext=Iv});var uP=p(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.DynamicGrammarBuilder=void 0;var Tv=class{addPhrase(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(this.privGrammars===void 0&&this.privPhrases===void 0)return;let e={};if(e.ReferenceGrammars=this.privGrammars,this.privPhrases!==void 0&&this.privPhrases.length!==0){let t=[];this.privPhrases.forEach(r=>{t.push({Text:r})}),e.Groups=[{Type:"Generic",Items:t}]}return e}};Yc.DynamicGrammarBuilder=Tv});var hP=p(dP=>{"use strict";Object.defineProperty(dP,"__esModule",{value:!0})});var Av=p(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.MessageDataStreamType=Xr.ActivityPayloadResponse=void 0;var _v=class i{constructor(e){this.privActivityResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}};Xr.ActivityPayloadResponse=_v;var YA;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(YA=Xr.MessageDataStreamType||(Xr.MessageDataStreamType={}))});var lP=p(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});Xc.DialogServiceTurnState=void 0;var XA=li(),ZA=Dr(),eb=Av(),bv=class{constructor(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(e,t){return e.messageDataStreamType===eb.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=ZA.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:XA.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream}endAudioStream(){this.privAudioStream!==null&&!this.privAudioStream.isClosed&&this.privAudioStream.close()}complete(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.endAudioStream()}resetTurnEndTimeout(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout(()=>{this.privTurnManager.CompleteTurn(this.privRequestId)},2e3)}};Xc.DialogServiceTurnState=bv});var fP=p(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.DialogServiceTurnStateManager=void 0;var vP=ot(),tb=lP(),Ov=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new vP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new tb.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)}GetTurn(e){return this.privTurnMap.get(e)}CompleteTurn(e){if(!this.privTurnMap.has(e))throw new vP.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);let t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t}};Zc.DialogServiceTurnStateManager=Ov});var gP=p(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.DialogServiceAdapter=void 0;var rb=ae(),ib=Pu(),_e=P(),nb=li(),k=f(),sb=fP(),At=C(),ob=Av(),ep=Qr(),Mv=class extends At.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new _e.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new sb.DialogServiceTurnStateManager,this.recognizeOverride=(o,a,c)=>this.listenOnce(o,a,c),this.postConnectImplOverride=o=>this.dialogConnectImpl(o),this.configConnectionOverride=o=>this.configConnection(o),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=r,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach(o=>{o.name==="ConnectionClosedEvent"&&(this.terminateMessageLoop=!0)})}async sendMessage(e){let t=_e.createGuid(),r=_e.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new ep.SpeechConnectionMessage(_e.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new k.PropertyCollection;e.messageType===_e.MessageType.Text&&t.setProperty(k.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=At.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==At.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==At.RecognitionStatus.Error){let l=this.fireEventForResult(o,t);if(this.privLastResult=l.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,l)}catch{}}n=!0;break;case"speech.hypothesis":let a=At.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,k.ResultReason.RecognizingSpeech,a.Text,a.Duration,c,a.Language,a.LanguageDetectionConfidence,void 0,void 0,e.textBody,t),this.privRequestSession.onHypothesis(c);let u=new k.SpeechRecognitionEventArgs(r,a.Duration,this.privRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,u)}catch{}n=!0;break;case"speech.keyword":let d=At.SpeechKeyword.fromJSON(e.textBody);r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,d.Status==="Accepted"?k.ResultReason.RecognizedKeyword:k.ResultReason.NoMatch,d.Text,d.Duration,d.Offset,void 0,void 0,void 0,void 0,e.textBody,t),d.Status!=="Accepted"&&(this.privLastResult=r);let h=new k.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,h)}catch{}n=!0;break;case"audio":{let l=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(l);try{e.binaryBody?g.audioStream.write(e.binaryBody):g.endAudioStream()}catch{}}n=!0;break;case"response":this.handleResponseMessage(e),n=!0;break;default:break}let s=new _e.Deferred;return s.resolve(n),s.promise}async cancelRecognition(e,t,r,n,s){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){let o=new k.PropertyCollection;o.setProperty(At.CancellationErrorCodePropertyName,k.CancellationErrorCode[n]);let a=new k.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new k.SpeechRecognitionResult(void 0,k.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(c),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(e,t,r){this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(k.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let n=this.connectImpl(),s=this.sendPreAudioMessages(),o=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),a=await this.privDialogAudioSource.format,c=await this.privDialogAudioSource.deviceInfo,u=new rb.ReplayableAudioNode(o,a.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(u,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:c};try{await n,await s}catch(l){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.ConnectionFailure,l),Promise.resolve()}let d=new k.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,d),this.sendAudio(u).then(()=>{},async l=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,l)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new _e.Deferred,t=async()=>{try{let r=this.isDisposed(),n=!this.isDisposed()&&this.terminateMessageLoop;if(r||n){e.resolve(void 0);return}let o=await(await this.fetchConnection()).read();if(!o)return t();let a=ep.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();_!==M?this.privTurnStateManager.StartTurn(_):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=At.SpeechDetected.fromJSON(a.textBody),d=new k.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,d);break;case"speech.enddetected":let h;a.textBody.length>0?h=a.textBody:h="{ Offset: 0 }";let l=At.SpeechDetected.fromJSON(h);this.privRequestSession.onServiceRecognized(l.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new k.RecognitionEventArgs(l.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let _=a.requestId.toUpperCase(),M=this.privRequestSession.requestId.toUpperCase();if(_!==M)this.privTurnStateManager.CompleteTurn(_);else{let J=new k.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),(!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)&&this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,J),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(F){this.privErrorCallback&&this.privErrorCallback(F)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new _e.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{_e.Events.instance.onEvent(new _e.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,e)}return Promise.resolve()}async configConnection(e){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(e),e)}async sendPreAudioMessages(){let e=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(e,!0),await this.sendAgentContext(e),await this.sendWaveHeader(e)}sendAgentConfig(e){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(k.PropertyId.Conversation_DialogType)===k.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(k.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new ib.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new ep.SpeechConnectionMessage(_e.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=_e.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(k.PropertyId.Conversation_Speech_Activity_Template),s=JSON.stringify({channelData:"",context:{interactionId:t},messagePayload:typeof r===void 0?void 0:r,version:.5});return e.send(new ep.SpeechConnectionMessage(_e.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=At.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new k.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new k.SpeechRecognitionEventArgs(s,n,this.privRequestSession.sessionId)}handleResponseMessage(e){let t=JSON.parse(e.textBody);switch(t.messageType.toLowerCase()){case"message":let r=e.requestId.toUpperCase(),n=ob.ActivityPayloadResponse.fromJSON(e.textBody),s=this.privTurnStateManager.GetTurn(r);if(n.conversationId){let c=this.agentConfig.get();c.botInfo.conversationId=n.conversationId,this.agentConfig.set(c)}let o=s.processActivityPayload(n,nb.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(k.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new k.ActivityReceivedEventArgs(n.messagePayload,o);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,a)}catch{}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new k.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:_e.Events.instance.onEvent(new _e.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),_e.Events.instance.onEvent(e)}addKeywordContextData(){let e=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(e===void 0)return;let t=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),r=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),n=e.split(";"),s=t===void 0?[]:t.split(";"),o=r===void 0?[]:r.split(";"),a=[];for(let c=0;c<n.length;c++){let u={};u.text=n[c],c<s.length&&(u.offset=Number(s[c])),c<o.length&&(u.duration=Number(o[c])),a.push(u)}this.speechContext.setSection("invocationSource","VoiceActivationWithKeyword"),this.speechContext.setSection("keywordDetection",[{clientDetectedKeywords:a,onReject:{action:"EndOfTurn"},type:"startTrigger"}])}};tp.DialogServiceAdapter=Mv});var mP=p(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.AgentConfig=void 0;var Dv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};rp.AgentConfig=Dv});var np=p(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.ConversationConnectionConfig=void 0;var ab=Fl(),bt=class i extends ab.RestConfigBase{static get host(){return i.privHost}static get apiVersion(){return i.privApiVersion}static get clientAppId(){return i.privClientAppId}static get defaultLanguageCode(){return i.privDefaultLanguageCode}static get restPath(){return i.privRestPath}static get webSocketPath(){return i.privWebSocketPath}static get transcriptionEventKeys(){return i.privTranscriptionEventKeys}};ip.ConversationConnectionConfig=bt;bt.privHost="dev.microsofttranslator.com";bt.privRestPath="/capito/room";bt.privApiVersion="2.0";bt.privDefaultLanguageCode="en-US";bt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";bt.privWebSocketPath="/capito/translate";bt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var SP=p(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.ConversationManager=void 0;var sp=ae(),Sr=w(),Xt=f(),Zr=np(),kv=class{constructor(){this.privRequestParams=Zr.ConversationConnectionConfig.configParams,this.privErrors=Zr.ConversationConnectionConfig.restErrors,this.privHost=Zr.ConversationConnectionConfig.host,this.privApiVersion=Zr.ConversationConnectionConfig.apiVersion,this.privRestPath=Zr.ConversationConnectionConfig.restPath,this.privRestAdapter=new sp.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{Sr.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(Xt.PropertyId.SpeechServiceConnection_RecoLanguage,Zr.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(Xt.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(Xt.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Key),d=e.getProperty(Xt.PropertyId.SpeechServiceConnection_Region),h=e.getProperty(Xt.PropertyId.SpeechServiceAuthorization_Token);Sr.Contracts.throwIfNullOrWhitespace(s,"languageCode"),Sr.Contracts.throwIfNullOrWhitespace(o,"nickname"),Sr.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let l={};l[this.privRequestParams.apiVersion]=this.privApiVersion,l[this.privRequestParams.languageCode]=s,l[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=Zr.ConversationConnectionConfig.clientAppId,t!==void 0?l[this.privRequestParams.roomId]=t:(Sr.Contracts.throwIfNullOrUndefined(d,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=d,u?g[this.privRequestParams.subscriptionKey]=u:h?g[this.privRequestParams.authorization]=`Bearer ${h}`:Sr.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let _={};_.headers=g,this.privRestAdapter.options=_;let M=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(sp.RestRequestType.Post,M,l,null).then(J=>{let F=sp.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,J.headers);if(!J.ok){if(n){let ye=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",J.status.toString()),V;try{V=JSON.parse(J.data),ye+=` [${V.error.code}: ${V.error.message}]`}catch{ye+=` [${J.data}]`}F&&(ye+=` ${F}`),n(ye)}return}let ee=JSON.parse(J.data);if(ee&&(ee.requestId=F),r){try{r(ee)}catch(ye){n&&n(ye)}r=void 0}}).catch(()=>{})}catch(s){if(n)if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}}leave(e,t){return new Promise((r,n)=>{try{Sr.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),Sr.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(Xt.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(Xt.PropertyId.ConversationTranslator_CorrelationId),a={};a[this.privRequestParams.apiVersion]=this.privApiVersion,a[this.privRequestParams.sessionToken]=t;let c={};o&&(c[this.privRequestParams.correlationId]=o);let u={};u.headers=c,this.privRestAdapter.options=u;let d=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(sp.RestRequestType.Delete,d,a,null).then(h=>{h.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};op.ConversationManager=kv});var xv=p(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.ConversationConnectionMessage=void 0;var cb=P(),Nv=class extends cb.ConnectionMessage{constructor(e,t,r,n){super(e,t,r,n);let s=JSON.parse(this.textBody);s.type!==void 0&&(this.privConversationMessageType=s.type)}get conversationMessageType(){return this.privConversationMessageType}};ap.ConversationConnectionMessage=Nv});var CP=p(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.ConversationWebsocketMessageFormatter=void 0;var ei=P(),yP=xv(),qv=class{toConnectionMessage(e){let t=new ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=new yP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===ei.MessageType.Binary&&t.resolve(new yP.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new ei.Deferred;try{if(e.messageType===ei.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new ei.RawWebsocketMessage(ei.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};cp.ConversationWebsocketMessageFormatter=qv});var RP=p(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.ConversationConnectionFactory=void 0;var PP=ae(),pb=P(),ub=w(),zv=f(),db=$e(),ji=np(),hb=CP(),jv=class extends db.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Host,ji.ConversationConnectionConfig.host),s=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_CorrelationId,pb.createGuid()),o=`wss://${n}${ji.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty(zv.PropertyId.ConversationTranslator_Token,void 0);ub.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[ji.ConversationConnectionConfig.configParams.apiVersion]=ji.ConversationConnectionConfig.apiVersion,c[ji.ConversationConnectionConfig.configParams.token]=a,c[ji.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new PP.WebsocketConnection(o,c,{},new hb.ConversationWebsocketMessageFormatter,PP.ProxyInfo.fromRecognizerConfig(e),u,r)}};pp.ConversationConnectionFactory=jv});var EP=p(up=>{"use strict";Object.defineProperty(up,"__esModule",{value:!0});up.ConversationRequestSession=void 0;var Lv=P(),Bv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=Lv.createNoDashGuid(),this.privRequestCompletionDeferral=new Lv.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(e,t){this.privSessionId=t}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){e!==200&&e===403&&this.onComplete()}onServiceTurnEndResponse(e){e?this.privRequestId=Lv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};up.ConversationRequestSession=Bv});var Jv=p(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.ConversationReceivedTranslationEventArgs=je.ParticipantsListEventArgs=je.ParticipantAttributeEventArgs=je.ParticipantEventArgs=je.LockRoomEventArgs=je.MuteAllEventArgs=void 0;var Zn=f(),Fv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};je.MuteAllEventArgs=Fv;var Vv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};je.LockRoomEventArgs=Vv;var Uv=class extends Zn.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};je.ParticipantEventArgs=Uv;var Wv=class extends Zn.SessionEventArgs{constructor(e,t,r,n){super(n),this.privKey=t,this.privValue=r,this.privParticipantId=e}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}};je.ParticipantAttributeEventArgs=Wv;var Hv=class extends Zn.SessionEventArgs{constructor(e,t,r,n,s,o,a,c,u){super(u),this.privRoomId=e,this.privSessionToken=t,this.privTranslateTo=r,this.privProfanityFilter=n,this.privRoomProfanityFilter=s,this.privIsRoomLocked=o,this.privIsRoomLocked=a,this.privParticipants=c}get sessionToken(){return this.privSessionToken}get conversationId(){return this.privRoomId}get translateTo(){return this.privTranslateTo}get profanityFilter(){return this.privProfanityFilter}get roomProfanityFilter(){return this.privRoomProfanityFilter}get isRoomLocked(){return this.privIsRoomLocked}get isMuteAll(){return this.privIsMuteAll}get participants(){return this.privParticipants}};je.ParticipantsListEventArgs=Hv;var Kv=class{constructor(e,t,r){this.privPayload=t,this.privCommand=e,this.privSessionId=r}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}};je.ConversationReceivedTranslationEventArgs=Kv});var $v=p(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.ConversationTranslatorCommandTypes=yr.ConversationTranslatorMessageTypes=yr.InternalParticipants=void 0;var Gv=class{constructor(e=[],t){this.participants=e,this.meId=t}addOrUpdateParticipant(e){if(e===void 0)return;let t=this.getParticipantIndex(e.id);return t>-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}getParticipantIndex(e){return this.participants.findIndex(t=>t.id===e)}getParticipant(e){return this.participants.find(t=>t.id===e)}deleteParticipant(e){this.participants=this.participants.filter(t=>t.id!==e)}get host(){return this.participants.find(e=>e.isHost===!0)}get me(){return this.getParticipant(this.meId)}};yr.InternalParticipants=Gv;yr.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};yr.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"}});var wP=p(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.CommandResponsePayload=void 0;var lb=i=>JSON.parse(i),Qv=class i{constructor(e){this.privCommandResponse=lb(e)}get type(){return this.privCommandResponse.type}get command(){return this.privCommandResponse.command}get id(){return this.privCommandResponse.id}get nickname(){return this.privCommandResponse.nickname}get participantId(){return this.privCommandResponse.participantId}get roomid(){return this.privCommandResponse.roomid}get value(){return this.privCommandResponse.value}get token(){return this.privCommandResponse.token}static fromJSON(e){return new i(e)}};dp.CommandResponsePayload=Qv});var IP=p(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.ParticipantPayloadResponse=Li.ParticipantsListPayloadResponse=void 0;var vb=i=>JSON.parse(i),fb=i=>JSON.parse(i),Yv=class i{constructor(e){this.privParticipantsPayloadResponse=vb(e)}get roomid(){return this.privParticipantsPayloadResponse.roomid}get id(){return this.privParticipantsPayloadResponse.id}get command(){return this.privParticipantsPayloadResponse.command}get participants(){return this.privParticipantsPayloadResponse.participants}get token(){return this.privParticipantsPayloadResponse.token}get translateTo(){return this.privParticipantsPayloadResponse.translateTo}get profanityFilter(){return this.privParticipantsPayloadResponse.profanityFilter}get roomProfanityFilter(){return this.privParticipantsPayloadResponse.roomProfanityFilter}get roomLocked(){return this.privParticipantsPayloadResponse.roomLocked}get muteAll(){return this.privParticipantsPayloadResponse.muteAll}get type(){return this.privParticipantsPayloadResponse.type}static fromJSON(e){return new i(e)}};Li.ParticipantsListPayloadResponse=Yv;var Xv=class i{constructor(e){this.privParticipantPayloadResponse=fb(e)}get nickname(){return this.privParticipantPayloadResponse.nickname}get locale(){return this.privParticipantPayloadResponse.locale}get usetts(){return this.privParticipantPayloadResponse.usetts}get ismuted(){return this.privParticipantPayloadResponse.ismuted}get ishost(){return this.privParticipantPayloadResponse.ishost}get participantId(){return this.privParticipantPayloadResponse.participantId}get avatar(){return this.privParticipantPayloadResponse.avatar}static fromJSON(e){return new i(e)}};Li.ParticipantPayloadResponse=Xv});var TP=p(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.TextResponsePayload=Bi.SpeechResponsePayload=void 0;var gb=i=>JSON.parse(i),mb=i=>JSON.parse(i),Zv=class i{constructor(e){this.privSpeechResponse=gb(e)}get recognition(){return this.privSpeechResponse.recognition}get translations(){return this.privSpeechResponse.translations}get id(){return this.privSpeechResponse.id}get language(){return this.privSpeechResponse.language}get nickname(){return this.privSpeechResponse.nickname}get participantId(){return this.privSpeechResponse.participantId}get roomid(){return this.privSpeechResponse.roomid}get timestamp(){return this.privSpeechResponse.timestamp}get type(){return this.privSpeechResponse.type}get isFinal(){return this.privSpeechResponse.type==="final"}static fromJSON(e){return new i(e)}};Bi.SpeechResponsePayload=Zv;var ef=class i{constructor(e){this.privTextResponse=mb(e)}get originalText(){return this.privTextResponse.originalText}get translations(){return this.privTextResponse.translations}get id(){return this.privTextResponse.id}get language(){return this.privTextResponse.language}get nickname(){return this.privTextResponse.nickname}get participantId(){return this.privTextResponse.participantId}get roomid(){return this.privTextResponse.roomid}get timestamp(){return this.privTextResponse.timestamp}get type(){return this.privTextResponse.type}static fromJSON(e){return new i(e)}};Bi.TextResponsePayload=ef});var bP=p(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});var Sb=wP();Object.defineProperty(ti,"CommandResponsePayload",{enumerable:!0,get:function(){return Sb.CommandResponsePayload}});var _P=IP();Object.defineProperty(ti,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return _P.ParticipantsListPayloadResponse}});Object.defineProperty(ti,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return _P.ParticipantPayloadResponse}});var AP=TP();Object.defineProperty(ti,"SpeechResponsePayload",{enumerable:!0,get:function(){return AP.SpeechResponsePayload}});Object.defineProperty(ti,"TextResponsePayload",{enumerable:!0,get:function(){return AP.TextResponsePayload}})});var DP=p(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.ConversationServiceAdapter=void 0;var es=P(),lt=f(),OP=C(),MP=xv(),yb=EP(),Ue=Jv(),Cr=$v(),ts=bP(),tf=class extends OP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=s,this.privConversationAuthentication=e,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=o=>this.conversationConnectImpl(o),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new yb.ConversationRequestSession(es.createNoDashGuid()),this.privConversationConnectionFactory=t,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(e){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise!==void 0&&await(await this.privConnectionConfigPromise).dispose(e),await super.dispose(e)}async sendMessage(e){return(await this.fetchConnection()).send(new MP.ConversationConnectionMessage(es.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new MP.ConversationConnectionMessage(es.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,lt.CancellationReason.Error,lt.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new lt.ConversationTranslationCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch{}}async conversationConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();let e=new es.Deferred;try{let r=await(await this.fetchConnection()).read();if(this.isDisposed()||this.terminateMessageLoop)return e.resolve(),Promise.resolve();if(!r)return this.receiveConversationMessageOverride();let n=this.privConversationRequestSession.sessionId,s=r.conversationMessageType.toLowerCase(),o=!1;try{switch(s){case"info":case"participant_command":case"command":let a=ts.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=ts.ParticipantsListPayloadResponse.fromJSON(r.textBody),_=g.participants.map(V=>({avatar:V.avatar,displayName:V.nickname,id:V.participantId,isHost:V.ishost,isMuted:V.ismuted,isUsingTts:V.usetts,preferredLanguage:V.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ue.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,_,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ue.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new lt.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ue.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantAttributeEventArgs(a.participantId,Cr.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let M=ts.ParticipantPayloadResponse.fromJSON(r.textBody),J={avatar:M.avatar,displayName:M.nickname,id:M.participantId,isHost:M.ishost,isMuted:M.ismuted,isUsingTts:M.usetts,preferredLanguage:M.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(J,n));break;case"leavesession":let F={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ue.ParticipantEventArgs(F,n));break;case"disconnectsession":let ee={id:a.participantId};break;case"token":let ye=new OP.CognitiveTokenAuthentication(()=>{let V=a.token;return Promise.resolve(V)},()=>{let V=a.token;return Promise.resolve(V)});this.authentication=ye,this.privConversationServiceConnector.onToken(ye);break;default:break}break;case"partial":case"final":let c=ts.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?lt.ResultReason.TranslatedParticipantSpeech:lt.ResultReason.TranslatingParticipantSpeech,d=new lt.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((d.text!==void 0&&d.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.final,d,n))):d.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.partial,d,n)));break;case"translated_message":let h=ts.TextResponsePayload.fromJSON(r.textBody),l=new lt.ConversationTranslationResult(h.participantId,this.getTranslations(h.translations),h.language,void 0,void 0,h.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ue.ConversationReceivedTranslationEventArgs(Cr.ConversationTranslatorMessageTypes.instantMessage,l,n));break;default:break}}catch{}return this.receiveConversationMessageOverride()}catch{this.terminateMessageLoop=!0}return e.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;let e=this.receiveConversationMessageOverride();try{return await e}catch(t){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",lt.CancellationReason.Error,lt.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===es.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()):this.privConnectionConfigPromise,()=>(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection())):this.terminateMessageLoop?Promise.resolve(void 0):(this.privConnectionConfigPromise=this.connectImpl().then(e=>e),this.privConnectionConfigPromise)}getTranslations(e){let t;if(e!==void 0){t=new lt.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};hp.ConversationServiceAdapter=tf});var kP=p(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.ConversationTranslatorRecognizer=Ui.ConversationRecognizerFactory=void 0;var Cb=C(),Fi=P(),Vi=w(),rf=f(),Pb=RP(),Rb=DP(),nf=class{static fromConfig(e,t,r){return new lp(e,t,r)}};Ui.ConversationRecognizerFactory=nf;var lp=class extends rf.Recognizer{constructor(e,t,r){let n=t;Vi.Contracts.throwIfNull(n,"speechConfig");let s=e;Vi.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new Pb.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=rf.Connection.fromRecognizer(this),this.privProperties.getProperty(rf.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=Fi.Timeout.setTimeout,this.privClearTimeout=Fi.Timeout.clearTimeout):typeof window<"u"?(this.privSetTimeout=window.setTimeout.bind(window),this.privClearTimeout=window.clearTimeout.bind(window)):(this.privSetTimeout=setTimeout,this.privClearTimeout=clearTimeout)}set connected(e){this.privConnection.connected=e}set disconnected(e){this.privConnection.disconnected=e}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(e,t,r){try{Vi.Contracts.throwIfDisposed(this.privIsDisposed),Vi.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.resetConversationTimeout(),this.privReco.connectAsync(t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n)}}disconnect(e,t){try{Vi.Contracts.throwIfDisposed(this.privIsDisposed),this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then(()=>{e&&e()},r=>{t&&t(r)})}catch(r){if(t)if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r);this.dispose(!0).catch(n=>{Fi.Events.instance.onEvent(new Fi.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Vi.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(e,t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n);this.dispose(!0).catch(s=>{Fi.Events.instance.onEvent(new Fi.BackgroundEvent(s))})}}onToken(e){this.privConversation.onToken(e)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(e){this.privIsDisposed||e&&(this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privIsDisposed=!0,this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close(),this.privConnection=void 0),await super.dispose(e))}createRecognizerConfig(e){return new Cb.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new Rb.ConversationServiceAdapter(e,t,s,n,this)}sendMessage(e,t,r){let n=this.privReco;((o,a,c)=>{o!==void 0?o.then(()=>{try{a&&a()}catch(u){c&&c(`'Unhandled error on promise callback: ${u}'`)}},u=>{try{c&&c(u)}catch{}}):c&&c("Null promise")})(n.sendMessageAsync(e),t,r),this.resetConversationTimeout()}resetConversationTimeout(){this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout(()=>{this.sendRequest(this.privConversation.getKeepAlive())},6e4)}};Ui.ConversationTranslatorRecognizer=lp});var xP=p(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.TranscriberRecognizer=void 0;var NP=P(),vt=w(),Wi=f(),vp=C(),sf=class extends Wi.Recognizer{constructor(e,t){let r=e;vt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;vt.Contracts.throwIfNull(n,"audioConfigImpl"),vt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Wi.PropertyId[Wi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new vp.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return vt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Wi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Wi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){vt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Wi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){vt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){vt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return vt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){NP.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(vp.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){NP.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){let r=this.privReco;vt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;vt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendMeetingSpeechEventAsync(e,t)}async enforceAudioGating(){let r=(await this.audioConfig.format).channels;if(r===1){if(this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()!=="true")throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details")}else if(r!==8)throw new Error(`Unsupported audio configuration: Detected ${r}-channel audio`)}connectMeetingCallbacks(e){this.isMeetingRecognizer=!0,this.canceled=(t,r)=>{e.canceled&&e.canceled(e,r)},this.recognizing=(t,r)=>{e.transcribing&&e.transcribing(e,r)},this.recognized=(t,r)=>{e.transcribed&&e.transcribed(e,r)},this.sessionStarted=(t,r)=>{e.sessionStarted&&e.sessionStarted(e,r)},this.sessionStopped=(t,r)=>{e.sessionStopped&&e.sessionStopped(e,r)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new vp.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new vp.TranscriptionServiceRecognizer(e,t,s,n,this)}};fp.TranscriberRecognizer=sf});var qP=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});var Eb=SP();Object.defineProperty(De,"ConversationManager",{enumerable:!0,get:function(){return Eb.ConversationManager}});var wb=np();Object.defineProperty(De,"ConversationConnectionConfig",{enumerable:!0,get:function(){return wb.ConversationConnectionConfig}});var Ib=kP();Object.defineProperty(De,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return Ib.ConversationRecognizerFactory}});var Tb=xP();Object.defineProperty(De,"TranscriberRecognizer",{enumerable:!0,get:function(){return Tb.TranscriberRecognizer}});var Hi=Jv();Object.defineProperty(De,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Hi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(De,"LockRoomEventArgs",{enumerable:!0,get:function(){return Hi.LockRoomEventArgs}});Object.defineProperty(De,"MuteAllEventArgs",{enumerable:!0,get:function(){return Hi.MuteAllEventArgs}});Object.defineProperty(De,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantAttributeEventArgs}});Object.defineProperty(De,"ParticipantEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantEventArgs}});Object.defineProperty(De,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Hi.ParticipantsListEventArgs}});var of=$v();Object.defineProperty(De,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorCommandTypes}});Object.defineProperty(De,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return of.ConversationTranslatorMessageTypes}});Object.defineProperty(De,"InternalParticipants",{enumerable:!0,get:function(){return of.InternalParticipants}})});var cf=p(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.SynthesisAudioMetadata=ri.MetadataType=void 0;var _b;(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})(_b=ri.MetadataType||(ri.MetadataType={}));var af=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};ri.SynthesisAudioMetadata=af});var jP=p(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.SynthesisStartedEvent=Ot.ConnectingToSynthesisServiceEvent=Ot.SynthesisTriggeredEvent=Ot.SpeechSynthesisEvent=void 0;var zP=P(),Ki=class extends zP.PlatformEvent{constructor(e,t,r=zP.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};Ot.SpeechSynthesisEvent=Ki;var pf=class extends Ki{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};Ot.SynthesisTriggeredEvent=pf;var uf=class extends Ki{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.ConnectingToSynthesisServiceEvent=uf;var df=class extends Ki{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Ot.SynthesisStartedEvent=df});var LP=p(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.SynthesisTurn=void 0;var gp=P(),Ab=Dr(),mp=f(),bb=cf(),hf=jP(),lf=class i{constructor(){this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privInTurn=!1,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privRequestId=gp.createNoDashGuid(),this.privTurnDeferral=new gp.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){let e=new mp.PropertyCollection;return e.setProperty(mp.PropertyId.TalkingAvatarService_WebRTC_SDP,this.privWebRTCSDP),e}}async getAllReceivedAudio(){return this.privReceivedAudio?Promise.resolve(this.privReceivedAudio):this.privIsSynthesisEnded?(await this.readAllAudioFromStream(),Promise.resolve(this.privReceivedAudio)):null}async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){let e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}else return this.getAllReceivedAudio()}startNewSynthesis(e,t,r,n){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new Ab.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privPartialVisemeAnimation="",this.privWebRTCSDP="",n!==void 0&&(this.privTurnAudioDestination=n,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new hf.SynthesisTriggeredEvent(this.requestId,void 0,n===void 0?void 0:n.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new hf.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(e===200){this.onEvent(new hf.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),this.privBytesReceived=0;return}else e===403&&this.onComplete()}onServiceResponseMessage(e){let t=JSON.parse(e);this.streamId=t.audio.streamId}onServiceTurnEndResponse(){this.privInTurn=!1,this.privTurnDeferral.resolve(),this.onComplete()}onServiceTurnStartResponse(e){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new gp.Deferred;let t=JSON.parse(e);t.webrtc&&(this.privWebRTCSDP=t.webrtc.connectionString)}onAudioChunkReceived(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,this.privTurnAudioDestination!==void 0&&this.privTurnAudioDestination.write(e))}onTextBoundaryEvent(e){this.updateTextOffset(e.Data.text.Text,e.Type)}onVisemeMetadataReceived(e){e.Data.AnimationChunk!==void 0&&(this.privPartialVisemeAnimation+=e.Data.AnimationChunk)}onSessionEnd(e){this.privAudioDuration=e.Data.Offset}async constructSynthesisResult(){let e=await this.getAllReceivedAudioWithHeader();return new mp.SpeechSynthesisResult(this.requestId,mp.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){let e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){gp.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===bb.MetadataType.WordBoundary?(this.privTextOffset=this.privRawText.indexOf(e,this.privNextSearchTextIndex),this.privTextOffset>=0&&(this.privNextSearchTextIndex=this.privTextOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privTextOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t)))}onComplete(){this.privIsSynthesizing&&(this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!0,this.privAudioOutputStream.close(),this.privInTurn=!1,this.privTurnAudioDestination!==void 0&&(this.privTurnAudioDestination.close(),this.privTurnAudioDestination=void 0))}async readAllAudioFromStream(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{await this.privAudioOutputStream.read(this.privReceivedAudio)}catch{this.privReceivedAudio=new ArrayBuffer(0)}}}withinXmlTag(e){return this.privRawText.indexOf("<",e+1)>this.privRawText.indexOf(">",e+1)}};Sp.SynthesisTurn=lf});var BP=p(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.SynthesisAdapterBase=void 0;var Ae=P(),We=f(),it=C(),Ji=Qr(),yp=class{constructor(e,t,r,n){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!e)throw new Ae.ArgumentNullError("authentication");if(!t)throw new Ae.ArgumentNullError("connectionFactory");if(!r)throw new Ae.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new it.SynthesisTurn,this.privConnectionEvents=new Ae.EventSource,this.privServiceEvents=new Ae.EventSource,this.privSynthesisContext=new it.SynthesisContext,this.privAgentConfig=new it.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(We.CancellationReason.Error,o.statusCode===1007?We.CancellationErrorCode.BadRequestParameters:We.CancellationErrorCode.ConnectionFailure,`${o.reason} websocket error code: ${o.statusCode}`)}})}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(e){this.privAudioOutputFormat=e,this.privSynthesisTurn.audioOutputFormat=e,this.privSessionAudioDestination!==void 0&&(this.privSessionAudioDestination.format=e),this.synthesisContext!==void 0&&(this.synthesisContext.audioOutputFormat=e)}isDisposed(){return this.privIsDisposed}async dispose(e){this.privIsDisposed=!0,this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.close(),this.privConnectionConfigurationPromise!==void 0&&await(await this.privConnectionConfigurationPromise).dispose(e)}async connect(){await this.connectImpl()}async sendNetworkMessage(e,t){let r=typeof t=="string"?Ae.MessageType.Text:Ae.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new Ji.SpeechConnectionMessage(r,e,this.privSynthesisTurn.requestId,n,t))}async Speak(e,t,r,n,s,o){let a;if(t?a=e:a=this.privSynthesizer.buildSsml(e),this.speakOverride!==void 0)return this.speakOverride(a,r,n,s);this.privSuccessCallback=n,this.privErrorCallback=s,this.privSynthesisTurn.startNewSynthesis(r,e,t,o);try{await this.connectImpl();let c=await this.fetchConnection();await this.sendSynthesisContext(c),await this.sendSsmlMessage(c,a,r),this.onSynthesisStarted(r),this.receiveMessage()}catch(c){return this.cancelSynthesisLocal(We.CancellationReason.Error,We.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new We.PropertyCollection;s.setProperty(it.CancellationErrorCodePropertyName,We.CancellationErrorCode[r]);let o=new We.SpeechSynthesisResult(e,We.ResultReason.Canceled,void 0,n,s);if(this.onSynthesisCancelled(o),this.privSuccessCallback)try{this.privSuccessCallback(o)}catch{}}cancelSynthesisLocal(e,t,r){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,e,t,r))}processTypeSpecificMessages(e){return!0}async receiveMessage(){try{let t=await(await this.fetchConnection()).read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!t)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;let r=Ji.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(r.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),this.onSynthesizing(r.binaryBody),this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.write(r.binaryBody));break;case"audio.metadata":let n=it.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case it.MetadataType.WordBoundary:case it.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new We.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===it.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case it.MetadataType.Bookmark:let c=new We.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case it.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new We.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case it.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case it.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(o);break}break;case"turn.end":this.privSynthesisTurn.onServiceTurnEndResponse();let s;try{s=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(s)}catch(o){this.privErrorCallback&&this.privErrorCallback(o)}this.onSynthesisCompleted(s);break;default:this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new Ae.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{}}sendSynthesisContext(e){this.setSynthesisContextSynthesisSection();let t=this.synthesisContext.toJSON();if(t)return e.send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",t))}setSpeechConfigSynthesisSection(){}connectImpl(e=!1){if(this.privConnectionPromise!=null)return this.privConnectionPromise.then(r=>r.state()===Ae.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=Ae.createNoDashGuid(),this.privConnectionId=Ae.createNoDashGuid(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);let t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=t.then(async r=>{this.privSynthesisTurn.onAuthCompleted(!1);let n=this.privConnectionFactory.create(this.privSynthesizerConfig,r,this.privConnectionId);n.events.attach(o=>{this.connectionEvents.onEvent(o)});let s=await n.open();return s.statusCode===200?(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.resolve(n)):s.statusCode===403&&!e?this.connectImpl(!0):(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${s.statusCode},
|
|
23
|
-
${this.privSynthesizerConfig.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Url)} Reason: ${s.reason}`))},r=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(r)}),this.privConnectionPromise.catch(()=>{}),this.privConnectionPromise}sendSpeechServiceConfig(e,t){if(t)return e.send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new Ji.SpeechConnectionMessage(Ae.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Ae.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(e,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),e)}onAvatarEvent(e){}onSynthesisStarted(e){}onSynthesizing(e){}onSynthesisCancelled(e){}onSynthesisCompleted(e){}onWordBoundary(e){}onVisemeReceived(e){}onBookmarkReached(e){}};Cp.SynthesisAdapterBase=yp;yp.telemetryDataEnabled=!0});var VP=p(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.AvatarSynthesisAdapter=void 0;var FP=f(),Ob=C(),vf=class extends Ob.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,void 0),this.privAvatarSynthesizer=n,this.privSynthesizer=n,this.privAvatarConfig=s}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:this.privAvatarConfig.videoFormat?.bitrate,codec:this.privAvatarConfig.videoFormat?.codec,crop:{bottomRight:{x:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y},topLeft:{x:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y}},resolution:{height:this.privAvatarConfig.videoFormat?.height,width:this.privAvatarConfig.videoFormat?.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(FP.PropertyId.TalkingAvatarService_WebRTC_SDP)),iceServers:this.privAvatarSynthesizer.iceServers}},talkingAvatar:{background:{color:this.privAvatarConfig.backgroundColor},character:this.privAvatarConfig.character,customized:this.privAvatarConfig.customized,style:this.privAvatarConfig.style}}}onAvatarEvent(e){if(this.privAvatarSynthesizer.avatarEventReceived){let t=new FP.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};Pp.AvatarSynthesisAdapter=vf});var UP=p(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});Rp.SpeechSynthesisAdapter=void 0;var Pr=f(),Mb=C(),ff=class extends Mb.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,s),this.privSpeechSynthesizer=n,this.privSynthesizer=n}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(e){let t=new Pr.SpeechSynthesisEventArgs(new Pr.SpeechSynthesisResult(e,Pr.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,t)}onSynthesizing(e){if(this.privSpeechSynthesizer.synthesizing)try{let t=this.privSynthesisTurn.audioOutputFormat.addHeader(e),r=new Pr.SpeechSynthesisEventArgs(new Pr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,Pr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new Pr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new Pr.SpeechSynthesisEventArgs(e))}catch{}}onWordBoundary(e){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,e)}catch{}}onVisemeReceived(e){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,e)}catch{}}onBookmarkReached(e){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,e)}catch{}}};Rp.SpeechSynthesisAdapter=ff});var WP=p(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.SynthesisRestAdapter=void 0;var gf=ae(),mf=f(),Db=$e(),kb=we(),Sf=class{constructor(e,t){let r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Region,"westus"),o=Db.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(mf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=gf.RestConfigBase.requestOptions;this.privRestAdapter=new gf.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(kb.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(gf.RestRequestType.Get,this.privUri)))}};Ep.SynthesisRestAdapter=Sf});var JP=p(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.SynthesizerConfig=ii.SynthesisServiceType=void 0;var HP=C(),KP;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(KP=ii.SynthesisServiceType||(ii.SynthesisServiceType={}));var yf=class{constructor(e,t){this.privSynthesisServiceType=KP.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new HP.SpeechServiceConfig(new HP.Context(null)),this.privParameters=t}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(e){this.privSynthesisServiceType=e}set synthesisVideoSection(e){this.privSpeechServiceConfig.Context.synthesis={video:e}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}};ii.SynthesizerConfig=yf});var GP=p(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.SynthesisContext=void 0;var Cf=f(),Pf=class{constructor(){this.privContext={}}setSection(e,t){this.privContext[e]=t}set audioOutputFormat(e){this.privAudioOutputFormat=e}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(e){let t=this.buildSynthesisContext(e);this.setSection("synthesis",t)}buildSynthesisContext(e){return{audio:{metadataOptions:{bookmarkEnabled:!!e?.bookmarkReached,punctuationBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(Cf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};wp.SynthesisContext=Pf});var $P=p(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});Ip.SpeakerRecognitionConfig=void 0;var Nb=C(),Rf=class{constructor(e,t){this.privContext=e||new Nb.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};Ip.SpeakerRecognitionConfig=Rf});var YP=p(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});_p.SpeakerServiceRecognizer=void 0;var xb=ae(),Tp=P(),Se=f(),QP=C(),qb=Qr(),Ef=class extends QP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeakerRecognizer=s,this.privSpeakerAudioSource=r,this.recognizeSpeaker=o=>this.recognizeSpeakerOnce(o),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let t=!1,r=new Se.PropertyCollection;switch(e.messageType===Tp.MessageType.Text&&r.setProperty(Se.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.response":let s=JSON.parse(e.textBody),o;s.status.statusCode.toLowerCase()!=="success"?o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.Canceled,Se.CancellationErrorCode.ServiceError,s.status.reason):o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new Tp.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Se.PropertyCollection().setProperty(QP.CancellationErrorCodePropertyName,Se.CancellationErrorCode[n]),this.privResultDeferral){let a=new Se.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Se.ResultReason.Canceled,n,s);try{this.privResultDeferral.resolve(a)}catch(c){this.privResultDeferral.reject(c)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new Tp.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Se.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let t=this.connectImpl(),r=this.sendPreAudioMessages(this.extractSpeakerContext(e)),n=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),s=await this.privSpeakerAudioSource.format,o=await this.privSpeakerAudioSource.deviceInfo,a=new xb.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(d){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.ConnectionFailure,d)}let c=new Se.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},d=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.RuntimeError,d)}),this.privResultDeferral.promise}async sendPreAudioMessages(e){let t=await this.fetchConnection();await this.sendSpeakerRecognition(t,e)}async sendSpeakerRecognition(e,t){let r=JSON.stringify(t);return e.send(new qb.SpeechConnectionMessage(Tp.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",r))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}};_p.SpeakerServiceRecognizer=Ef});var ZP=p(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.VoiceServiceRecognizer=void 0;var zb=ae(),Mt=P(),L=f(),XP=C(),wf=Qr(),If=class extends XP.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new Mt.DeferralMap,this.privSpeakerAudioSource=r,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let t=!1,r=new L.PropertyCollection;switch(e.messageType===Mt.MessageType.Text&&r.setProperty(L.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":let s=JSON.parse(e.textBody);switch(s.operation.toLowerCase()){case"create":this.handleCreateResponse(s,e.requestId);break;case"delete":case"reset":this.handleResultResponse(s,e.requestId);break;case"fetch":let u=JSON.parse(e.textBody);this.handleFetchResponse(u,e.requestId);break;default:break}t=!0;break;case"speaker.phrases":let o=JSON.parse(e.textBody);this.handlePhrasesResponse(o,e.requestId),t=!0;break;case"speaker.profile.enrollment":let a=JSON.parse(e.textBody),c=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(a.enrollment?a.enrollment.enrollmentStatus:a.status.statusCode),a.enrollment?JSON.stringify(a.enrollment):void 0,a.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,c),this.privRequestSession.onSpeechEnded(),t=!0;break;default:break}let n=new Mt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(XP.CancellationErrorCodePropertyName,L.CancellationErrorCode[n]);let a=new L.VoiceProfileEnrollmentResult(L.ResultReason.Canceled,s,s);this.privDeferralMap.getId(t)&&this.privDeferralMap.complete(t,a)}async createProfile(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Mt.Deferred;return await r,await this.sendCreateProfile(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async resetProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("reset",e.profileType,e)}async deleteProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("delete",e.profileType,e)}async retrieveEnrollmentResult(e){return this.voiceProfileType=e.profileType.toString(),this.privExpectedProfileId=e.profileId,this.sendCommonRequest("fetch",e.profileType,e)}async getAllProfiles(e){return this.voiceProfileType=e.toString(),this.sendCommonRequest("fetch",e)}async getActivationPhrases(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new Mt.Deferred;return await r,await this.sendPhrasesRequest(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();let t=new Mt.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(L.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let r=this.connectImpl(),n=this.sendPreAudioMessages(e,t),s=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),o=await this.privSpeakerAudioSource.format,a=await this.privSpeakerAudioSource.deviceInfo,c=new zb.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,h)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,h)}),t.promise}async sendPreAudioMessages(e,t){let r=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,t),await this.sendBaseRequest(r,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=this.scenarioFrom(t),o={locale:r,scenario:s};return n.send(new wf.SpeechConnectionMessage(Mt.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCreateProfile(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=t===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":t===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification",o={locale:r,number:"1",scenario:s};return n.send(new wf.SpeechConnectionMessage(Mt.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCommonRequest(e,t,r=void 0){let n=this.connectImpl();try{let s=new Mt.Deferred;this.privRequestSession.onSpeechContext(),await n;let o=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest(o,e,this.scenarioFrom(t),r),this.receiveMessage(),s.promise}catch(s){throw s}}async sendBaseRequest(e,t,r,n){let s={scenario:r};return n?s.profileIds=[n.profileId]:s.maxPageSize=-1,e.send(new wf.SpeechConnectionMessage(Mt.MessageType.Text,`speaker.profile.${t}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,t){if(this.privDeferralMap.getId(t))if(e.status.statusCode.toLowerCase()!=="success"){let r=L.ResultReason.Canceled,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(t,n)}else if(e.phrases&&e.phrases.length>0){let r=L.ResultReason.EnrollingVoiceProfile,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(t,n)}else throw new Error("Voice Profile get activation phrases failed, no phrases received");else throw new Error(`Voice Profile get activation phrases request for requestID ${t} not found`)}handleCreateResponse(e,t){if(e.profiles&&e.profiles.length>0)if(this.privDeferralMap.getId(t)){let r=e.profiles.map(n=>n.profileId);this.privDeferralMap.complete(t,r)}else throw new Error(`Voice Profile create request for requestID ${t} not found`);else throw new Error("Voice Profile create failed, no profile id received")}handleResultResponse(e,t){if(this.privDeferralMap.getId(t)){let r=e.operation.toLowerCase()==="delete"?L.ResultReason.DeletedVoiceProfile:L.ResultReason.ResetVoiceProfile,n=e.status.statusCode.toLowerCase()==="success"?r:L.ResultReason.Canceled,s=new L.VoiceProfileResult(n,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(t,s)}else throw new Error(`Voice Profile create request for requestID ${t} not found`)}handleFetchResponse(e,t){if(this.privDeferralMap.getId(t)&&e.profiles[0]){if(this.privExpectedProfileId&&e.profiles.length===1&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;let r=e.profiles[0],n=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(r.enrollmentStatus),JSON.stringify(r),e.status.reason);this.privDeferralMap.complete(t,n)}else if(e.profiles.length>0){let r=e.profiles,n=[];for(let s of r)n.push(new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(s.enrollmentStatus),JSON.stringify(s),e.status.reason));this.privDeferralMap.complete(t,n)}}else throw new Error(`Voice Profile fetch request for requestID ${t} not found`)}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return L.ResultReason.EnrolledVoiceProfile;case"invalidlocale":case"invalidphrase":case"invalidaudioformat":case"invalidscenario":case"invalidprofilecount":case"invalidoperation":case"audiotooshort":case"audiotoolong":case"toomanyenrollments":case"storageconflict":case"profilenotfound":case"incompatibleprofiles":case"incompleteenrollment":return L.ResultReason.Canceled;default:return L.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}};Ap.VoiceServiceRecognizer=If});var eR=p(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.type=pe.connectivity=pe.Device=pe.OS=pe.System=pe.Context=pe.SpeechServiceConfig=void 0;var Tf=class{constructor(e){this.context=e}serialize(){return JSON.stringify(this,(e,t)=>{if(t&&typeof t=="object"&&!Array.isArray(t)){let r={};for(let n in t)Object.hasOwnProperty.call(t,n)&&(r[n&&n.charAt(0).toLowerCase()+n.substring(1)]=t[n]);return r}return t})}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}};pe.SpeechServiceConfig=Tf;var _f=class{constructor(e){this.system=new bp,this.os=e}};pe.Context=_f;var bp=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};pe.System=bp;var Af=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};pe.OS=Af;var bf=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};pe.Device=bf;var jb;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(jb=pe.connectivity||(pe.connectivity={}));var Lb;(function(i){i.Phone="Phone",i.Speaker="Speaker",i.Car="Car",i.Headset="Headset",i.Thermostat="Thermostat",i.Microphones="Microphones",i.Deskphone="Deskphone",i.RemoteControl="RemoteControl",i.Unknown="Unknown",i.File="File",i.Stream="Stream"})(Lb=pe.type||(pe.type={}))});var C=p(m=>{"use strict";var Bb=m&&m.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),R=m&&m.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&Bb(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(sm(),m);R(pm(),m);R(Vs(),m);R(dm(),m);R(lm(),m);R(cC(),m);R(hC(),m);R(yc(),m);R(vC(),m);R(fC(),m);R(mC(),m);R(yC(),m);R(PC(),m);R(IC(),m);R(AC(),m);R(DC(),m);R(qC(),m);R(bl(),m);R(zC(),m);R(jC(),m);R(BC(),m);R(FC(),m);R(VC(),m);R(WC(),m);R(HC(),m);R(KC(),m);R(JC(),m);R(GC(),m);R($C(),m);R(YC(),m);R(XC(),m);R(ZC(),m);R(eP(),m);R(rP(),m);R(iP(),m);R(sP(),m);R(cP(),m);R(pP(),m);R(uP(),m);R(hP(),m);R(gP(),m);R(mP(),m);R(qP(),m);R(cf(),m);R(LP(),m);R(BP(),m);var Fb=VP();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return Fb.AvatarSynthesisAdapter}});var Vb=UP();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return Vb.SpeechSynthesisAdapter}});R(WP(),m);R(JP(),m);R(GP(),m);R($P(),m);R(YP(),m);R(ZP(),m);R(eR(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var tR=p(ni=>{"use strict";var Ub=ni&&ni.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),Wb=ni&&ni.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&Ub(e,i,t)};Object.defineProperty(ni,"__esModule",{value:!0});var Hb=C();new Hb.AgentConfig;Wb(f(),ni)});function KR(i){return typeof i=="function"}function rn(i){return KR(i)?i():i}var eg=!0;function nn(i){let{audioConfig:e,authorizationToken:t,enableTelemetry:r,looseEvent:n,referenceGrammars:s,region:o="westus",speechRecognitionEndpointId:a,subscriptionKey:c,textNormalization:u}=i,{credentials:d,looseEvents:h}=i;if(typeof n<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),h=n),!d){if(!t&&!c)throw new Error("web-speech-cognitive-services: Credentials must be specified.");console.warn("web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14."),d=async()=>typeof i.authorizationToken<"u"?{authorizationToken:await rn(i.authorizationToken),region:o}:{region:o,subscriptionKey:await rn(i.subscriptionKey)}}return Object.freeze({audioConfig:e,enableTelemetry:r,fetchCredentials:async()=>{let{authorizationToken:l,customVoiceHostname:g,region:_,speechRecognitionHostname:M,speechSynthesisHostname:J,subscriptionKey:F}=await rn(d);if(!l&&!F||l&&F)throw new Error('web-speech-cognitive-services: Either "authorizationToken" or "subscriptionKey" must be provided.');if(!_&&!(M&&J))throw new Error('web-speech-cognitive-services: Either "region" or "speechRecognitionHostname" and "speechSynthesisHostname" must be set.');if(_&&(g||M||J))throw new Error('web-speech-cognitive-services: Only either "region" or "customVoiceHostname", "speechRecognitionHostname" and "speechSynthesisHostname" can be set.');if(l){if(typeof l!="string")throw new Error('web-speech-cognitive-services: "authorizationToken" must be a string.')}else if(typeof F!="string")throw new Error('web-speech-cognitive-services: "subscriptionKey" must be a string.');return eg&&F&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),eg=!1),{...typeof l<"u"?{authorizationToken:l}:{subscriptionKey:F},...typeof _<"u"?{region:_}:{customVoiceHostname:g,speechRecognitionHostname:M,speechSynthesisHostname:J}}},looseEvents:!!h,referenceGrammars:s&&Object.freeze([...s]),speechRecognitionEndpointId:a,textNormalization:u})}var Dt=Zf(tR()),Gi={AudioConfig:Dt.AudioConfig,OutputFormat:Dt.OutputFormat,ResultReason:Dt.ResultReason,SpeechConfig:Dt.SpeechConfig,SpeechRecognizer:Dt.SpeechRecognizer};function rs(){let i={};return i.promise=new Promise((e,t)=>{i.resolve=e,i.reject=t}),i}function rR(){let i,e=[];return{push:n=>{if(i){let{resolve:s}=i;i=null,s(n)}else e.push(n)},shift:()=>e.length?Promise.resolve(e.shift()):(i||(i=rs())).promise}}var $i=class{constructor({confidence:e,transcript:t}){this.#t=e,this.#e=t}#t;#e;get confidence(){return this.#t}get transcript(){return this.#e}};var si=class{constructor(e){if(!e)throw new Error("array must be set.");this.#t=e;for(let t in e)Object.defineProperty(this,t,{enumerable:!0,get(){return e[t]}})}#t;[Symbol.iterator](){return this.#t[Symbol.iterator]()}get length(){return this.#t.length}};var oi=class extends si{constructor(e){super(e.results),this.#t=e.isFinal}#t;get isFinal(){return this.#t}};var{ResultReason:{RecognizingSpeech:Kb,RecognizedSpeech:Of}}=Gi;function Mf(i,e){let{maxAlternatives:t=1/0,textNormalization:r="display"}=e||{},n=typeof i.json=="string"?JSON.parse(i.json):i.json;return i.reason===Kb||i.reason===Of&&!n.NBest?new oi({isFinal:i.reason===Of,results:[new $i({confidence:.5,transcript:i.text})]}):i.reason===Of?new oi({isFinal:!0,results:(n.NBest||[]).slice(0,t).map(({Confidence:s,Display:o,ITN:a,Lexical:c,MaskedITN:u})=>new $i({confidence:s,transcript:r==="itn"?a:r==="lexical"?c:r==="maskeditn"?u:o}))}):new oi({isFinal:!1,results:[]})}function Qi(i,e=void 0){return(...t)=>new Promise((r,n)=>i.apply(e,[...t,r,n]))}var is=class{constructor(e){this.#t=e,this.#e={}}#t;#e;getProperty(e){return this.#e[e]}setProperty(e,t){let r=this.#e[e];r&&this.#t.removeEventListener(e,r),t&&this.#t.addEventListener(e,t),this.#e[e]=t}};var iR=Zf(nu());function Df(i){let e=Array.from(new Int16Array(i));return e.reduce((t,r)=>t+Math.abs(r),0)/e.length}function kf(i){let e=i,t=e.attach,r=e.attach.bind(e),n=!1,s=!1;return e.attach=async()=>{let o=await r("");return{...o,read:async()=>{let a=await o.read();return!n&&Df(a.buffer)>150&&(e.events.onEvent(new iR.AudioSourceEvent("FirstAudibleChunk","")),n=!0),s?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:a}}},{audioConfig:i,pause:()=>{s=!0},unprepare:()=>{e.attach=t}}}function Op({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return Object.freeze({duration:i,errorDetails:e,json:t&&JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a})}var ai=class{constructor(){this.#t=[]}addFromString(){throw new Error("JSGF is not supported")}addFromURI(){throw new Error("JSGF is not supported")}item(){throw new Error("JSGF is not supported")}get length(){throw new Error("JSGF is not supported")}#t;get phrases(){return this.#t}set phrases(e){if(Array.isArray(e))this.#t=Object.freeze([...e]);else if(typeof e=="string")this.#t=Object.freeze([e]);else throw new Error("The provided value is not an array or of type 'string'")}};var kt=class extends Event{constructor(e,{error:t,message:r}){super(e),this.#t=t,this.#e=r}#t;#e;get error(){return this.#t}get message(){return this.#e}get type(){return"error"}};var Nt=class extends si{constructor(e){super(e)}};var W=class extends Event{constructor(e,{data:t,resultIndex:r,results:n}={}){super(e),this.#t=t,this.#e=r,this.#r=n||new Nt([])}#t;#e;#r;get data(){return this.#t}get resultIndex(){return this.#e}get results(){return this.#r}get type(){return super.type}};var{ResultReason:Jb,SpeechRecognizer:Gb}=Gi;function Rr({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){Gb.enableTelemetry(e!==!1);class s extends EventTarget{#t=!1;#e=new is(this);#r=new ai;#i=!1;#n=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US";#s=1;emitCognitiveServices(a,c){this.dispatchEvent(new W("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this.#t}set continuous(a){this.#t=a}get grammars(){return this.#r}set grammars(a){if(a instanceof ai)this.#r=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this.#i}set interimResults(a){this.#i=a}get maxAlternatives(){return this.#s}set maxAlternatives(a){this.#s=a}get lang(){return this.#n}set lang(a){this.#n=a}get onaudioend(){return this.#e.getProperty("audioend")}set onaudioend(a){this.#e.setProperty("audioend",a)}get onaudiostart(){return this.#e.getProperty("audiostart")}set onaudiostart(a){this.#e.setProperty("audiostart",a)}get oncognitiveservices(){return this.#e.getProperty("cognitiveservices")}set oncognitiveservices(a){this.#e.setProperty("cognitiveservices",a)}get onend(){return this.#e.getProperty("end")}set onend(a){this.#e.setProperty("end",a)}get onerror(){return this.#e.getProperty("error")}set onerror(a){this.#e.setProperty("error",a)}get onresult(){return this.#e.getProperty("result")}set onresult(a){this.#e.setProperty("result",a)}get onsoundend(){return this.#e.getProperty("soundend")}set onsoundend(a){this.#e.setProperty("soundend",a)}get onsoundstart(){return this.#e.getProperty("soundstart")}set onsoundstart(a){this.#e.setProperty("soundstart",a)}get onspeechend(){return this.#e.getProperty("speechend")}set onspeechend(a){this.#e.setProperty("speechend",a)}get onspeechstart(){return this.#e.getProperty("speechstart")}set onspeechstart(a){this.#e.setProperty("speechstart",a)}get onstart(){return this.#e.getProperty("start")}set onstart(a){this.#e.setProperty("start",a)}abort;stop;start(){this._startOnce().catch(a=>{this.dispatchEvent(new kt("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=kf(a.audioConfig);try{let d=rR(),h,l,g,{detach:_}=a.audioConfig.events.attach(V=>{let{name:G}=V;G==="AudioSourceReadyEvent"?d.push({audioSourceReady:{}}):G==="AudioSourceOffEvent"?d.push({audioSourceOff:{}}):G==="FirstAudibleChunk"&&d.push({firstAudibleChunk:{}})});a.canceled=(V,{errorDetails:G,offset:nt,reason:wr,sessionId:qp})=>{d.push({canceled:{errorDetails:G,offset:nt,reason:wr,sessionId:qp}})},a.recognized=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognized:{offset:G,result:Op(nt),sessionId:wr}})},a.recognizing=(V,{offset:G,result:nt,sessionId:wr})=>{d.push({recognizing:{offset:G,result:Op(nt),sessionId:wr}})},a.sessionStarted=(V,{sessionId:G})=>{d.push({sessionStarted:{sessionId:G}})},a.sessionStopped=(V,{sessionId:G})=>{d.push({sessionStopped:{sessionId:G}})},a.speechStartDetected=(V,{offset:G,sessionId:nt})=>{d.push({speechStartDetected:{offset:G,sessionId:nt}})},a.speechEndDetected=(V,{sessionId:G})=>{d.push({speechEndDetected:{sessionId:G}})};let{phrases:M}=this.grammars,{dynamicGrammar:J}=a.privReco;r&&r.length&&J.addReferenceGrammar([...r]),M&&M.length&&J.addPhrase([...M]),await Qi(a.startContinuousRecognitionAsync,a)(),typeof a.stopContinuousRecognitionAsync=="function"?(this.abort=()=>d.push({abort:{}}),this.stop=()=>d.push({stop:{}})):this.abort=this.stop=void 0;let F,ee,ye=[];for(let V=0;!g||F;V++){let G=await d.shift(),{abort:nt,audioSourceOff:wr,audioSourceReady:qp,canceled:Yf,firstAudibleChunk:jR,recognized:ci,recognizing:zp,stop:LR}=G;Object.keys(G).forEach(tn=>this.emitCognitiveServices(tn,G[tn]));let jp=Yf&&Yf.errorDetails;if(/Permission\sdenied/u.test(jp||"")){ee=new kt("error",{error:"not-allowed"});break}if(V||this.dispatchEvent(new W("start")),jp){/1006/u.test(jp)?(F||(this.dispatchEvent(new W("audiostart")),this.dispatchEvent(new W("audioend"))),ee=new kt("error",{error:"network"})):ee=new kt("error",{error:"unknown"});break}else if(nt||LR)nt?(ee=new kt("error",{error:"aborted"}),g="abort"):(c(),g="stop"),nt&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();else if(qp)this.dispatchEvent(new W("audiostart")),F=!0;else if(jR)this.dispatchEvent(new W("soundstart")),h=!0;else if(wr){l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),F=h=l=!1;break}else if(g!=="abort"){if(ci&&ci.result&&ci.result.reason===Jb.NoMatch){if(!this.continuous||g==="stop"){ee=new W("result",{results:new Nt(ye)}),a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)();break}}else if(ci||zp)if(F||(this.dispatchEvent(new W("audiostart")),F=!0),h||(this.dispatchEvent(new W("soundstart")),h=!0),l||(this.dispatchEvent(new W("speechstart")),l=!0),ci){let tn=Mf(ci.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Lp=!!tn[0]?.transcript;Lp&&(ye=[...ye,tn],this.continuous&&this.dispatchEvent(new W("result",{results:new Nt(ye)}))),this.continuous&&Lp?ee=void 0:ee=new W("result",{results:new Nt(ye)}),(!this.continuous||g==="stop")&&a.stopContinuousRecognitionAsync&&await Qi(a.stopContinuousRecognitionAsync,a)(),t&&ee&&Lp&&(this.dispatchEvent(ee),ee=void 0)}else zp&&this.interimResults&&this.dispatchEvent(new W("result",{results:new Nt([...ye,Mf(zp.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})])}))}}l&&this.dispatchEvent(new W("speechend")),h&&this.dispatchEvent(new W("soundend")),F&&this.dispatchEvent(new W("audioend")),ee&&(ee.type==="result"&&!ee.results.length&&(ee=new kt("error",{error:"no-speech"})),this.dispatchEvent(ee)),this.dispatchEvent(new W("end")),_()}catch(d){throw console.error(d),d}finally{u(),a.dispose(!1)}}}return{SpeechGrammarList:ai,SpeechRecognition:s,SpeechRecognitionEvent:W}}var{AudioConfig:$b,OutputFormat:Qb,SpeechConfig:Mp,SpeechRecognizer:Yb}=Gi;function ns(i){let{audioConfig:e=$b.fromDefaultMicrophoneInput(),enableTelemetry:t=!0,fetchCredentials:r,looseEvents:n,referenceGrammars:s,speechRecognitionEndpointId:o,textNormalization:a="display"}=nn(i);if(!e&&(!window.navigator.mediaDevices||!window.navigator.mediaDevices.getUserMedia))throw new Error("web-speech-cognitive-services: This browser does not support Media Capture and Streams API and it will not work with Cognitive Services Speech Services.");return Rr({createRecognizer:async u=>{let d=await r(),h;if(typeof d.speechRecognitionHostname<"u"){let l=new URL("wss://hostname:443");l.hostname=d.speechRecognitionHostname,d.authorizationToken?(h=Mp.fromHost(l),h.authorizationToken=d.authorizationToken):h=Mp.fromHost(l,d.subscriptionKey)}else h=typeof d.authorizationToken<"u"?Mp.fromAuthorizationToken(d.authorizationToken,d.region):Mp.fromSubscription(d.subscriptionKey,d.region);return o&&(h.endpointId=o),h.outputFormat=Qb.Detailed,h.speechRecognitionLanguage=u||"en-US",new Yb(h,e)},enableTelemetry:t,looseEvents:n,referenceGrammars:s,textNormalization:a})}function jf(i,e,...t){if(!i)throw new TypeError(vR(e,t))}function vR(i,e){let t=0;return i.replace(/%[os]/gu,()=>fR(e[t++]))}function fR(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var nR;function Xb(i){try{let e=i instanceof Error?i:new Error(fR(i));if(nR){nR(e);return}if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)}catch{}}var ft=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,sR;var gt=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(sR){sR({...this,args:e});return}let r=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
|
|
24
|
-
`);console.warn(this.message,...e,r)}catch{}}},Zb=new gt("W01","Unable to initialize event under dispatching."),eO=new gt("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),tO=new gt("W03","Assigning any truthy value to 'returnValue' property has no effect."),rO=new gt("W04","Unable to preventDefault on non-cancelable events."),iO=new gt("W05","Unable to preventDefault inside passive event listener invocation."),nO=new gt("W06","An event listener wasn't added because it has been added already: %o, %o"),Nf=new gt("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),oR=new gt("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),sO=new gt("W09","Event attribute handler must be a function: %o"),He=class{static get NONE(){return aR}static get CAPTURING_PHASE(){return cR}static get AT_TARGET(){return pR}static get BUBBLING_PHASE(){return uR}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};zf.set(this,{type:String(e),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return se(this).type}get target(){return se(this).target}get srcElement(){return se(this).target}get currentTarget(){return se(this).currentTarget}composedPath(){let e=se(this).currentTarget;return e?[e]:[]}get NONE(){return aR}get CAPTURING_PHASE(){return cR}get AT_TARGET(){return pR}get BUBBLING_PHASE(){return uR}get eventPhase(){return se(this).dispatchFlag?2:0}stopPropagation(){se(this).stopPropagationFlag=!0}get cancelBubble(){return se(this).stopPropagationFlag}set cancelBubble(e){e?se(this).stopPropagationFlag=!0:eO.warn()}stopImmediatePropagation(){let e=se(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return se(this).bubbles}get cancelable(){return se(this).cancelable}get returnValue(){return!se(this).canceledFlag}set returnValue(e){e?tO.warn():dR(se(this))}preventDefault(){dR(se(this))}get defaultPrevented(){return se(this).canceledFlag}get composed(){return se(this).composed}get isTrusted(){return!1}get timeStamp(){return se(this).timeStamp}initEvent(e,t=!1,r=!1){let n=se(this);if(n.dispatchFlag){Zb.warn();return}zf.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},aR=0,cR=1,pR=2,uR=3,zf=new WeakMap;function se(i,e="this"){let t=zf.get(i);return jf(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function dR(i){if(i.inPassiveListenerFlag){iO.warn();return}if(!i.cancelable){rO.warn();return}i.canceledFlag=!0}Object.defineProperty(He,"NONE",{enumerable:!0});Object.defineProperty(He,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(He,"AT_TARGET",{enumerable:!0});Object.defineProperty(He,"BUBBLING_PHASE",{enumerable:!0});var xf=Object.getOwnPropertyNames(He.prototype);for(let i=0;i<xf.length;++i)xf[i]!=="constructor"&&Object.defineProperty(He.prototype,xf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.Event<"u"&&Object.setPrototypeOf(He.prototype,ft.Event.prototype);function oO(i){return ft.DOMException?new ft.DOMException(i,"InvalidStateError"):(Yi==null&&(Yi=class gR extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,gR)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(Yi.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),lR(Yi),lR(Yi.prototype)),new Yi(i))}var Yi,hR={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function lR(i){let e=Object.keys(hR);for(let t=0;t<e.length;++t){let r=e[t],n=hR[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var Zi=class extends He{static wrap(e){return new(SR(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),mR.set(this,{original:e});let t=Object.keys(e);for(let r=0;r<t.length;++r){let n=t[r];n in this||Object.defineProperty(this,n,yR(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Er(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Er(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Er(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Er(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Er(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Er(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},mR=new WeakMap;function Er(i){let e=mR.get(i);return jf(e!=null,"'this' is expected an Event object, but got",i),e}var Dp=new WeakMap;Dp.set(Object.prototype,Zi);typeof ft<"u"&&typeof ft.Event<"u"&&Dp.set(ft.Event.prototype,Zi);function SR(i){let e=Object.getPrototypeOf(i);if(e==null)return Zi;let t=Dp.get(e);return t==null&&(t=aO(SR(e),e),Dp.set(e,t)),t}function aO(i,e){class t extends i{}let r=Object.keys(e);for(let n=0;n<r.length;++n)Object.defineProperty(t.prototype,r[n],yR(e,r[n]));return t}function yR(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Er(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Er(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function cO(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function pO(i){i.flags|=8}function CR(i){return(i.flags&1)===1}function PR(i){return(i.flags&2)===2}function RR(i){return(i.flags&4)===4}function uO(i){return(i.flags&8)===8}function dO({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){Xb(r)}}function ER({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&CR(i[r])===t)return r;return-1}function wR(i,e,t,r,n,s){let o;s&&(o=Lf.bind(null,i,e,t),s.addEventListener("abort",o));let a=cO(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function Lf(i,e,t){let r=ER(i,e,t);return r!==-1?IR(i,r):!1}function IR(i,e,t=!1){let r=i.listeners[e];return pO(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),i.cow&&!t?(i.cow=!1,i.listeners=i.listeners.filter((n,s)=>s!==e),!1):(i.listeners.splice(e,1),!0)}function hO(){return Object.create(null)}function TR(i,e){var t;return(t=i[e])!==null&&t!==void 0?t:i[e]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var Zt=class{constructor(){_R.set(this,hO())}addEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:d}=lO(e,t,r);if(s==null||u?.aborted)return;let h=TR(n,d),l=ER(h,s,o);if(l!==-1){fO(h.listeners[l],c,a,u);return}wR(h,s,o,c,a,u)}removeEventListener(e,t,r){let n=Xi(this),{callback:s,capture:o,type:a}=vO(e,t,r),c=n[a];s!=null&&c&&Lf(c,s,o)}dispatchEvent(e){let t=Xi(this)[String(e.type)];if(t==null)return!0;let r=e instanceof He?e:Zi.wrap(e),n=se(r,"event");if(n.dispatchFlag)throw oO("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:s,listeners:o}=t;t.cow=!0;for(let a=0;a<o.length;++a){let c=o[a];if(!uO(c)&&(RR(c)&&IR(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=PR(c),dO(c,this,r),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}s||(t.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},_R=new WeakMap;function Xi(i,e="this"){let t=_R.get(i);return jf(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function lO(i,e,t){var r;return AR(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture,passive:!!t.passive,once:!!t.once,signal:(r=t.signal)!==null&&r!==void 0?r:void 0}:{type:String(i),callback:e??void 0,capture:!!t,passive:!1,once:!1,signal:void 0}}function vO(i,e,t){return AR(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture}:{type:String(i),callback:e??void 0,capture:!!t}}function AR(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){oR.warn(i);return}throw new TypeError(vR(oR.message,[i]))}}function fO(i,e,t,r){nO.warn(CR(i)?"capture":"bubble",i.callback),PR(i)!==e&&Nf.warn("passive"),RR(i)!==t&&Nf.warn("once"),i.signal!==r&&Nf.warn("signal")}var qf=Object.getOwnPropertyNames(Zt.prototype);for(let i=0;i<qf.length;++i)qf[i]!=="constructor"&&Object.defineProperty(Zt.prototype,qf[i],{enumerable:!0});typeof ft<"u"&&typeof ft.EventTarget<"u"&&Object.setPrototypeOf(Zt.prototype,ft.EventTarget.prototype);function xt(i,e){var t,r;return(r=(t=Xi(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function qt(i,e,t){t!=null&&typeof t!="function"&&sO.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?gO(i,e,t):mO(i,e)}function gO(i,e,t){let r=TR(Xi(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=wR(r,SO(r),!1,!1,!1,void 0))}function mO(i,e){let r=Xi(i,"target")[String(e)];r&&r.attrListener&&(Lf(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function SO(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function bR(i){return!!((typeof i=="function"||typeof i=="object")&&i&&"then"in i&&typeof i.then=="function")}function Bf(i,e){return new Promise(t=>{try{let r=i.call(e);bR(r)?r.then(t,()=>t(void 0)):t(r)}catch{t(void 0)}})}var OR=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function yO(i,e){return!!(i===e||OR(i)&&OR(e))}function CO(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!yO(i[t],e[t]))return!1;return!0}function MR(i,e){e===void 0&&(e=CO);var t=null;function r(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var o=i.apply(this,n);return t={lastResult:o,lastArgs:n,lastThis:this},o}return r.clear=function(){t=null},r}var kp=class{constructor(i){this.audioContext=i}pause(){this.audioContext&&this.audioContext.suspend(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("pause"))}resume(){this.audioContext&&this.audioContext.resume(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("resume"))}async start(i){let e;for(;e=i.shift();)this.playingUtterance=e,await e.play(this.audioContext),this.playingUtterance=null}stop(){this.playingUtterance&&this.playingUtterance.stop(),this.audioContext.state==="suspended"&&this.audioContext.resume()}};var Np=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=MR(()=>i||new e.AudioContext)}pause(){this.paused=!0,this.consumer&&this.consumer.pause()}push(i){this.queue.push(i),this.startConsumer()}resume(){this.paused=!1,this.consumer?this.consumer.resume():this.startConsumer()}get speaking(){return!!this.consumer}async startConsumer(){for(;!this.paused&&this.queue.length&&!this.consumer;)this.consumer=new kp(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var er=class extends He{constructor(e){super(e)}};function DR(){let i={};return i.promise=new Promise((e,t)=>{i.reject=t,i.resolve=e}),i}var Ff=class{constructor(){this.#t=i=>{let e=this.#e.shift();e&&e.resolve(i),this.#r&&(this.#r.resolve(i),this.#r=void 0)}}#t;#e=[];#r=void 0;get eventListener(){return this.#t}[Symbol.iterator](){return{next:()=>({done:!1,value:this.upcoming()})}}one(){let i=DR();return this.#e.push(i),i.promise}upcoming(){return this.#r||(this.#r=DR()),this.#r.promise}};var kR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",os=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(ss=0;ss<kR.length;ss++)os[kR.charCodeAt(ss)]=ss;var ss;var NR=function(i){var e=i.length*.75,t=i.length,r,n=0,s,o,a,c;i[i.length-1]==="="&&(e--,i[i.length-2]==="="&&e--);var u=new ArrayBuffer(e),d=new Uint8Array(u);for(r=0;r<t;r+=4)s=os[i.charCodeAt(r)],o=os[i.charCodeAt(r+1)],a=os[i.charCodeAt(r+2)],c=os[i.charCodeAt(r+3)],d[n++]=s<<2|o>>4,d[n++]=(o&15)<<4|a>>2,d[n++]=(a&3)<<6|c&63;return u};function Vf(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function Uf({lang:i,pitch:e=1,rate:t=1,text:r,voice:n,volume:s}){return`<speak version="1.0" xml:lang="${i}">
|
|
22
|
+
`);o&&o.length>0&&(n=this.parseHeaders(o[0]),o.length>1&&(s=o[1]))}t.resolve(new rt.ConnectionMessage(e.messageType,s,n,e.id))}else if(e.messageType===rt.MessageType.Binary){let r=e.binaryContent,n={},s=null;if(!r||r.byteLength<2)throw new Error("Invalid binary message format. Header length missing.");let o=new DataView(r),a=o.getInt16(0);if(r.byteLength<a+2)throw new Error("Invalid binary message format. Header content missing.");let c="";for(let u=0;u<a;u++)c+=String.fromCharCode(o.getInt8(u+2));n=this.parseHeaders(c),r.byteLength>a+2&&(s=r.slice(2+a)),t.resolve(new rt.ConnectionMessage(e.messageType,s,n,e.id))}}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new rt.Deferred;try{if(e.messageType===rt.MessageType.Text){let r=`${this.makeHeaders(e)}${WC}${e.textBody?e.textBody:""}`;t.resolve(new rt.RawWebsocketMessage(rt.MessageType.Text,r,e.id))}else if(e.messageType===rt.MessageType.Binary){let r=this.makeHeaders(e),n=e.binaryBody,s=this.stringToArrayBuffer(r),o=new Int8Array(s),a=o.byteLength,c=new Int8Array(2+a+(n?n.byteLength:0));if(c[0]=a>>8&255,c[1]=a&255,c.set(o,2),n){let l=new Int8Array(n);c.set(l,2+a)}let u=c.buffer;t.resolve(new rt.RawWebsocketMessage(rt.MessageType.Binary,u,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}makeHeaders(e){let t="";if(e.headers)for(let r in e.headers)r&&(t+=`${r}: ${e.headers[r]}${WC}`);return t}parseHeaders(e){let t={};if(e){let r=e.match(/[^\r\n]+/g);if(t){for(let n of r)if(n){let s=n.indexOf(":"),o=s>0?n.substr(0,s).trim().toLowerCase():n,a=s>0&&n.length>s+1?n.substr(s+1).trim():"";t[o]=a}}}return t}stringToArrayBuffer(e){let t=new ArrayBuffer(e.length),r=new DataView(t);for(let n=0;n<e.length;n++)r.setUint8(n,e.charCodeAt(n));return t}};Nc.WebsocketMessageFormatter=hv});var $C=p(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});qc.SpeechConnectionFactory=void 0;var KC=ce(),JC=C(),Pr=f(),GC=Ze(),dv=C(),cT=Ie(),ni=$t(),vv=class extends GC.ConnectionFactoryBase{constructor(){super(...arguments),this.interactiveRelativeUri="/speech/recognition/interactive/cognitiveservices/v1",this.conversationRelativeUri="/speech/recognition/conversation/cognitiveservices/v1",this.dictationRelativeUri="/speech/recognition/dictation/cognitiveservices/v1",this.universalUri="/speech/universal/v"}create(e,t,r){let n=e.parameters.getProperty(Pr.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(Pr.PropertyId.SpeechServiceConnection_Region,void 0),o=GC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(Pr.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(Pr.PropertyId.SpeechServiceConnection_EndpointId,void 0),l=e.parameters.getProperty(Pr.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);if(u?(!n||n.search(ni.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[ni.QueryParameterNames.CustomSpeechDeploymentId]=u):l&&(!n||n.search(ni.QueryParameterNames.Language)===-1)&&(c[ni.QueryParameterNames.Language]=l),(!n||n.search(ni.QueryParameterNames.Format)===-1)&&(c[ni.QueryParameterNames.Format]=e.parameters.getProperty(JC.OutputFormatPropertyName,Pr.OutputFormat[Pr.OutputFormat.Simple]).toLowerCase()),e.autoDetectSourceLanguages!==void 0&&(c[ni.QueryParameterNames.EnableLanguageId]="true"),this.setCommonUrlParams(e,c,n),!n)switch(e.recognitionMode){case dv.RecognitionMode.Conversation:e.parameters.getProperty(JC.ForceDictationPropertyName,"false")==="true"?n=a+this.dictationRelativeUri:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.conversationRelativeUri;break;case dv.RecognitionMode.Dictation:n=a+this.dictationRelativeUri;break;default:e.recognitionEndpointVersion!==void 0&&parseInt(e.recognitionEndpointVersion,10)>1?n=`${a}${this.universalUri}${e.recognitionEndpointVersion}`:n=a+this.interactiveRelativeUri;break}let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[cT.HeaderNames.ConnectionId]=r;let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new KC.WebsocketConnection(n,c,h,new dv.WebsocketMessageFormatter,KC.ProxyInfo.fromRecognizerConfig(e),d,r),M=g.uri;return e.parameters.setProperty(Pr.PropertyId.SpeechServiceConnection_Url,M),g}};qc.SpeechConnectionFactory=vv});var ZC=p(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.ConversationTranscriberConnectionFactory=void 0;var QC=ce(),We=f(),uT=C(),XC=Ze(),pT=C(),lT=Ie(),it=$t(),fv=class extends XC.ConnectionFactoryBase{constructor(){super(...arguments),this.universalUri="/speech/universal/v2"}create(e,t,r){let n=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Region,void 0),o=XC.ConnectionFactoryBase.getHostSuffix(s),a=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_Host,"wss://"+s+".stt.speech"+o),c={},u=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_EndpointId,void 0),l=e.parameters.getProperty(We.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);u?(!n||n.search(it.QueryParameterNames.CustomSpeechDeploymentId)===-1)&&(c[it.QueryParameterNames.CustomSpeechDeploymentId]=u):l&&(!n||n.search(it.QueryParameterNames.Language)===-1)&&(c[it.QueryParameterNames.Language]=l),e.autoDetectSourceLanguages!==void 0&&(c[it.QueryParameterNames.EnableLanguageId]="true"),this.setV2UrlParams(e,c,n),n||(n=`${a}${this.universalUri}`);let h={};t.token!==void 0&&t.token!==""&&(h[t.headerName]=t.token),h[lT.HeaderNames.ConnectionId]=r;let d=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true",g=new QC.WebsocketConnection(n,c,h,new pT.WebsocketMessageFormatter,QC.ProxyInfo.fromRecognizerConfig(e),d,r),M=g.uri;return e.parameters.setProperty(We.PropertyId.SpeechServiceConnection_Url,M),g}setV2UrlParams(e,t,r){new Map([[We.PropertyId.Speech_SegmentationSilenceTimeoutMs,it.QueryParameterNames.SegmentationSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_EnableAudioLogging,it.QueryParameterNames.EnableAudioLogging],[We.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,it.QueryParameterNames.EndSilenceTimeoutMs],[We.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,it.QueryParameterNames.InitialSilenceTimeoutMs],[We.PropertyId.SpeechServiceResponse_PostProcessingOption,it.QueryParameterNames.Postprocessing],[We.PropertyId.SpeechServiceResponse_ProfanityOption,it.QueryParameterNames.Profanity],[We.PropertyId.SpeechServiceResponse_StablePartialResultThreshold,it.QueryParameterNames.StableIntermediateThreshold]]).forEach((o,a)=>{this.setUrlParameter(a,o,e,t,r)});let s=JSON.parse(e.parameters.getProperty(uT.ServicePropertiesPropertyName,"{}"));Object.keys(s).forEach(o=>{t[o]=s[o]})}};jc.ConversationTranscriberConnectionFactory=fv});var rP=p(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.TranscriberConnectionFactory=void 0;var YC=ce(),He=f(),eP=Ze(),tP=C(),hT=Ie(),os=$t(),gv=class extends eP.ConnectionFactoryBase{constructor(){super(...arguments),this.multiaudioRelativeUri="/speech/recognition/multiaudio"}create(e,t,r){let n=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Endpoint,void 0),s=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Region,"centralus"),o=eP.ConnectionFactoryBase.getHostSuffix(s),a="wss://transcribe."+s+".cts.speech"+o+this.multiaudioRelativeUri,c=e.parameters.getProperty(He.PropertyId.SpeechServiceConnection_Host,a),u={};this.setQueryParams(u,e,n),n||(n=c);let l={};t.token!==void 0&&t.token!==""&&(l[t.headerName]=t.token),l[hT.HeaderNames.ConnectionId]=r,e.parameters.setProperty(He.PropertyId.SpeechServiceConnection_Url,n);let h=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new YC.WebsocketConnection(n,u,l,new tP.WebsocketMessageFormatter,YC.ProxyInfo.fromRecognizerConfig(e),h,r)}setQueryParams(e,t,r){let n=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_EndpointId,void 0),s=t.parameters.getProperty(He.PropertyId.SpeechServiceConnection_RecoLanguage,void 0);n&&!(os.QueryParameterNames.CustomSpeechDeploymentId in e)&&(e[os.QueryParameterNames.CustomSpeechDeploymentId]=n),s&&!(os.QueryParameterNames.Language in e)&&(e[os.QueryParameterNames.Language]=s);let o=t.parameters.getProperty(He.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,"false").toLowerCase()==="true",a=t.parameters.getProperty(tP.OutputFormatPropertyName,He.OutputFormat[He.OutputFormat.Simple])!==He.OutputFormat[He.OutputFormat.Simple];(o||a)&&(e[os.QueryParameterNames.Format]=He.OutputFormat[He.OutputFormat.Detailed].toLowerCase()),this.setCommonUrlParams(t,e,r)}};zc.TranscriberConnectionFactory=gv});var oP=p(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});Lc.TranslationConnectionFactory=void 0;var iP=ce(),dT=sd(),er=f(),nP=Ze(),mv=C(),vT=Ie(),sP=$t(),yv=class extends nP.ConnectionFactoryBase{create(e,t,r){let n=this.getEndpointUrl(e),s={};e.autoDetectSourceLanguages!==void 0&&(s[sP.QueryParameterNames.EnableLanguageId]="true"),this.setQueryParams(s,e,n);let o={};t.token!==void 0&&t.token!==""&&(o[t.headerName]=t.token),o[vT.HeaderNames.ConnectionId]=r,e.parameters.setProperty(er.PropertyId.SpeechServiceConnection_Url,n);let a=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new iP.WebsocketConnection(n,s,o,new mv.WebsocketMessageFormatter,iP.ProxyInfo.fromRecognizerConfig(e),a,r)}getEndpointUrl(e,t){let r=e.parameters.getProperty(er.PropertyId.SpeechServiceConnection_Region),n=nP.ConnectionFactoryBase.getHostSuffix(r),s=e.parameters.getProperty(er.PropertyId.SpeechServiceConnection_Endpoint,void 0);return s||(e.autoDetectSourceLanguages!==void 0?s=e.parameters.getProperty(er.PropertyId.SpeechServiceConnection_Host,"wss://{region}.stt.speech"+n)+"/speech/universal/v2":s=e.parameters.getProperty(er.PropertyId.SpeechServiceConnection_Host,"wss://{region}.s2s.speech"+n)+"/speech/translation/cognitiveservices/v1"),t===!0?s:dT.StringUtils.formatString(s,{region:r})}setQueryParams(e,t,r){e.from=t.parameters.getProperty(er.PropertyId.SpeechServiceConnection_RecoLanguage),e.to=t.parameters.getProperty(er.PropertyId.SpeechServiceConnection_TranslationToLanguages),e.scenario=t.recognitionMode===mv.RecognitionMode.Interactive?"interactive":t.recognitionMode===mv.RecognitionMode.Conversation?"conversation":"",this.setCommonUrlParams(t,e,r),this.setUrlParameter(er.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,sP.QueryParameterNames.StableTranslation,t,e,r);let n=t.parameters.getProperty(er.PropertyId.SpeechServiceConnection_TranslationVoice,void 0);n!==void 0&&(e.voice=n,e.features="texttospeech")}};Lc.TranslationConnectionFactory=yv});var aP=p(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});Bc.EnumTranslation=void 0;var ue=f(),ie=C(),Sv=class{static implTranslateRecognitionResult(e,t=!1){let r=ue.ResultReason.Canceled;switch(e){case ie.RecognitionStatus.Success:r=ue.ResultReason.RecognizedSpeech;break;case ie.RecognitionStatus.EndOfDictation:r=t?ue.ResultReason.RecognizedSpeech:ue.ResultReason.NoMatch;break;case ie.RecognitionStatus.NoMatch:case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:r=ue.ResultReason.NoMatch;break;case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:r=ue.ResultReason.Canceled;break}return r}static implTranslateCancelResult(e){let t=ue.CancellationReason.EndOfStream;switch(e){case ie.RecognitionStatus.Success:case ie.RecognitionStatus.EndOfDictation:case ie.RecognitionStatus.NoMatch:t=ue.CancellationReason.EndOfStream;break;case ie.RecognitionStatus.InitialSilenceTimeout:case ie.RecognitionStatus.BabbleTimeout:case ie.RecognitionStatus.Error:case ie.RecognitionStatus.BadRequest:case ie.RecognitionStatus.Forbidden:default:t=ue.CancellationReason.Error;break}return t}static implTranslateCancelErrorCode(e){let t=ue.CancellationErrorCode.NoError;switch(e){case ie.RecognitionStatus.Error:t=ue.CancellationErrorCode.ServiceError;break;case ie.RecognitionStatus.TooManyRequests:t=ue.CancellationErrorCode.TooManyRequests;break;case ie.RecognitionStatus.BadRequest:t=ue.CancellationErrorCode.BadRequestParameters;break;case ie.RecognitionStatus.Forbidden:t=ue.CancellationErrorCode.Forbidden;break;default:t=ue.CancellationErrorCode.NoError;break}return t}static implTranslateErrorDetails(e){let t="The speech service encountered an internal error and could not continue.";switch(e){case ue.CancellationErrorCode.Forbidden:t="The recognizer is using a free subscription that ran out of quota.";break;case ue.CancellationErrorCode.BadRequestParameters:t="Invalid parameter or unsupported audio format in the request.";break;case ue.CancellationErrorCode.TooManyRequests:t="The number of parallel requests exceeded the number of allowed concurrent transcriptions.";break;default:break}return t}};Bc.EnumTranslation=Sv});var cP=p(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.RecognitionStatus=Rr.SynthesisStatus=void 0;var fT;(function(i){i[i.Success=0]="Success",i[i.SynthesisEnd=1]="SynthesisEnd",i[i.Error=2]="Error"})(fT=Rr.SynthesisStatus||(Rr.SynthesisStatus={}));var gT;(function(i){i[i.Success=0]="Success",i[i.NoMatch=1]="NoMatch",i[i.InitialSilenceTimeout=2]="InitialSilenceTimeout",i[i.BabbleTimeout=3]="BabbleTimeout",i[i.Error=4]="Error",i[i.EndOfDictation=5]="EndOfDictation",i[i.TooManyRequests=6]="TooManyRequests",i[i.BadRequest=7]="BadRequest",i[i.Forbidden=8]="Forbidden"})(gT=Rr.RecognitionStatus||(Rr.RecognitionStatus={}))});var pP=p(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});Fc.TranslationSynthesisEnd=void 0;var uP=C(),Cv=class i{constructor(e){this.privSynthesisEnd=JSON.parse(e),this.privSynthesisEnd.SynthesisStatus&&(this.privSynthesisEnd.SynthesisStatus=uP.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]),this.privSynthesisEnd.Status&&(this.privSynthesisEnd.SynthesisStatus=uP.SynthesisStatus[this.privSynthesisEnd.Status])}static fromJSON(e){return new i(e)}get SynthesisStatus(){return this.privSynthesisEnd.SynthesisStatus}get FailureReason(){return this.privSynthesisEnd.FailureReason}};Fc.TranslationSynthesisEnd=Cv});var lP=p(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});Vc.TranslationHypothesis=void 0;var mT=_(),yT=Hs(),Pv=class i{constructor(e){this.privTranslationHypothesis=e,this.privTranslationHypothesis.Translation.TranslationStatus=yT.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){mT.Contracts.throwIfNullOrUndefined(e,"translationHypothesis");let t=e.SpeechHypothesis;return e.SpeechHypothesis=void 0,t.Translation=e,new i(t)}get Duration(){return this.privTranslationHypothesis.Duration}get Offset(){return this.privTranslationHypothesis.Offset}get Text(){return this.privTranslationHypothesis.Text}get Translation(){return this.privTranslationHypothesis.Translation}get Language(){return this.privTranslationHypothesis.PrimaryLanguage?.Language}};Vc.TranslationHypothesis=Pv});var hP=p(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});Uc.TranslationPhrase=void 0;var ST=_(),CT=C(),PT=Hs(),Rv=class i{constructor(e){this.privTranslationPhrase=e,this.privTranslationPhrase.RecognitionStatus=CT.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus],this.privTranslationPhrase.Translation!==void 0&&(this.privTranslationPhrase.Translation.TranslationStatus=PT.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus])}static fromJSON(e){return new i(JSON.parse(e))}static fromTranslationResponse(e){ST.Contracts.throwIfNullOrUndefined(e,"translationResponse");let t=e.SpeechPhrase;return e.SpeechPhrase=void 0,t.Translation=e,t.Text=t.DisplayText,new i(t)}get RecognitionStatus(){return this.privTranslationPhrase.RecognitionStatus}get Offset(){return this.privTranslationPhrase.Offset}get Duration(){return this.privTranslationPhrase.Duration}get Text(){return this.privTranslationPhrase.Text}get Language(){return this.privTranslationPhrase.PrimaryLanguage?.Language}get Confidence(){return this.privTranslationPhrase.PrimaryLanguage?.Confidence}get Translation(){return this.privTranslationPhrase.Translation}};Uc.TranslationPhrase=Rv});var vP=p(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});Wc.TranslationServiceRecognizer=void 0;var dP=P(),j=f(),be=C(),Ev=class extends be.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranslationRecognizer=s,this.connectionEvents.attach(o=>{o.name==="ConnectionEstablishedEvent"&&this.privTranslationRecognizer.onConnection()})}async processTypeSpecificMessages(e){let t=new j.PropertyCollection,r=await this.processSpeechMessages(e);if(r)return!0;let n=async o=>{if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus===be.RecognitionStatus.Success){let a=this.fireEventForResult(o,t);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,a)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(a.result)}catch(c){this.privErrorCallback&&this.privErrorCallback(c)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}else{let a=be.EnumTranslation.implTranslateRecognitionResult(o.RecognitionStatus),c=new j.TranslationRecognitionResult(void 0,this.privRequestSession.requestId,a,o.Text,o.Duration,this.privRequestSession.currentTurnAudioOffset+o.Offset,o.Language,o.Confidence,void 0,e.textBody,t);if(a===j.ResultReason.Canceled){let u=be.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus),l=be.EnumTranslation.implTranslateCancelErrorCode(o.RecognitionStatus);await this.cancelRecognitionLocal(u,l,be.EnumTranslation.implTranslateErrorDetails(l))}else{if(!(this.privRequestSession.isSpeechEnded&&a===j.ResultReason.NoMatch&&o.RecognitionStatus!==be.RecognitionStatus.InitialSilenceTimeout)){let u=new j.TranslationRecognitionEventArgs(c,c.offset,this.privRequestSession.sessionId);if(this.privTranslationRecognizer.recognized)try{this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,u)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(c)}catch(u){this.privErrorCallback&&this.privErrorCallback(u)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}r=!0}},s=(o,a)=>{let c=this.fireEventForResult(o,a);if(this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset+c.offset),this.privTranslationRecognizer.recognizing)try{this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,c)}catch{}r=!0};switch(e.messageType===dP.MessageType.Text&&t.setProperty(j.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"translation.hypothesis":s(be.TranslationHypothesis.fromJSON(e.textBody),t);break;case"translation.response":let o=JSON.parse(e.textBody);if(o.SpeechPhrase)await n(be.TranslationPhrase.fromTranslationResponse(o));else{let c=JSON.parse(e.textBody);c.SpeechHypothesis&&s(be.TranslationHypothesis.fromTranslationResponse(c),t)}break;case"translation.phrase":await n(be.TranslationPhrase.fromJSON(e.textBody));break;case"translation.synthesis":this.sendSynthesisAudio(e.binaryBody,this.privRequestSession.sessionId),r=!0;break;case"audio.end":case"translation.synthesis.end":let a=be.TranslationSynthesisEnd.fromJSON(e.textBody);switch(a.SynthesisStatus){case be.SynthesisStatus.Error:if(this.privTranslationRecognizer.synthesizing){let c=new j.TranslationSynthesisResult(j.ResultReason.Canceled,void 0),u=new j.TranslationSynthesisEventArgs(c,this.privRequestSession.sessionId);try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,u)}catch{}}if(this.privTranslationRecognizer.canceled){let c=new j.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId,j.CancellationReason.Error,a.FailureReason,j.CancellationErrorCode.ServiceError,null);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,c)}catch{}}break;case be.SynthesisStatus.Success:this.sendSynthesisAudio(void 0,this.privRequestSession.sessionId);break;default:break}r=!0;break;default:break}return r}cancelRecognition(e,t,r,n,s){let o=new j.PropertyCollection;if(o.setProperty(be.CancellationErrorCodePropertyName,j.CancellationErrorCode[n]),this.privTranslationRecognizer.canceled){let a=new j.TranslationRecognitionCanceledEventArgs(e,r,s,n,void 0);try{this.privTranslationRecognizer.canceled(this.privTranslationRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new j.TranslationRecognitionResult(void 0,t,j.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}handleRecognizingCallback(e,t,r){try{let n=new j.TranslationRecognitionEventArgs(j.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer,n)}catch{}}handleRecognizedCallback(e,t,r){try{let n=new j.TranslationRecognitionEventArgs(j.TranslationRecognitionResult.fromSpeechRecognitionResult(e),t,r);this.privTranslationRecognizer.recognized(this.privTranslationRecognizer,n)}catch{}}fireEventForResult(e,t){let r;if(e.Translation.Translations!==void 0){r=new j.Translations;for(let l of e.Translation.Translations)r.set(l.Language,l.Text||l.DisplayText)}let n,s;e instanceof be.TranslationPhrase?(e.Translation&&e.Translation.TranslationStatus===dP.TranslationStatus.Success?n=j.ResultReason.TranslatedSpeech:n=j.ResultReason.RecognizedSpeech,s=e.Confidence):n=j.ResultReason.TranslatingSpeech;let o=e.Language,a=e.Offset+this.privRequestSession.currentTurnAudioOffset,c=new j.TranslationRecognitionResult(r,this.privRequestSession.requestId,n,e.Text,e.Duration,a,o,s,e.Translation.FailureReason,JSON.stringify(e),t);return new j.TranslationRecognitionEventArgs(c,a,this.privRequestSession.sessionId)}sendSynthesisAudio(e,t){let r=e===void 0?j.ResultReason.SynthesizingAudioCompleted:j.ResultReason.SynthesizingAudio,n=new j.TranslationSynthesisResult(r,e),s=new j.TranslationSynthesisEventArgs(n,t);if(this.privTranslationRecognizer.synthesizing)try{this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer,s)}catch{}}};Wc.TranslationServiceRecognizer=Ev});var fP=p(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.SpeechDetected=void 0;var _v=class i{constructor(e){this.privSpeechStartDetected=JSON.parse(e)}static fromJSON(e){return new i(e)}get Offset(){return this.privSpeechStartDetected.Offset}};Hc.SpeechDetected=_v});var gP=p(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.SpeechHypothesis=void 0;var Iv=class i{constructor(e){this.privSpeechHypothesis=JSON.parse(e)}static fromJSON(e){return new i(e)}get Text(){return this.privSpeechHypothesis.Text}get Offset(){return this.privSpeechHypothesis.Offset}get Duration(){return this.privSpeechHypothesis.Duration}get Language(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSpeechHypothesis.PrimaryLanguage===void 0?void 0:this.privSpeechHypothesis.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSpeechHypothesis.SpeakerId}};Kc.SpeechHypothesis=Iv});var mP=p(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.SpeechKeyword=void 0;var wv=class i{constructor(e){this.privSpeechKeyword=JSON.parse(e)}static fromJSON(e){return new i(e)}get Status(){return this.privSpeechKeyword.Status}get Text(){return this.privSpeechKeyword.Text}get Offset(){return this.privSpeechKeyword.Offset}get Duration(){return this.privSpeechKeyword.Duration}};Jc.SpeechKeyword=wv});var yP=p(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.SpeechServiceRecognizer=void 0;var ye=f(),nt=C(),bv=class extends nt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeechRecognizer=s}async processTypeSpecificMessages(e){let t,r=new ye.PropertyCollection;r.setProperty(ye.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=nt.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,ye.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new ye.SpeechRecognitionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognizing)try{this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer,a)}catch{}n=!0;break;case"speech.phrase":let c=nt.SimpleSpeechPhrase.fromJSON(e.textBody),u=nt.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus,this.privExpectContentAssessmentResponse);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),ye.ResultReason.Canceled===u){let l=nt.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=nt.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(l,h,nt.EnumTranslation.implTranslateErrorDetails(h))}else{if(!(this.privRequestSession.isSpeechEnded&&u===ye.ResultReason.NoMatch&&c.RecognitionStatus!==nt.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(nt.OutputFormatPropertyName)===ye.OutputFormat[ye.OutputFormat.Simple])t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,void 0,e.textBody,r);else{let h=nt.DetailedSpeechPhrase.fromJSON(e.textBody),d=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(d);t=new ye.SpeechRecognitionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===nt.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,d,h.Language,h.LanguageDetectionConfidence,void 0,void 0,g,r)}let l=new ye.SpeechRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privSpeechRecognizer.recognized)try{this.privSpeechRecognizer.recognized(this.privSpeechRecognizer,l)}catch{}}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(l){this.privErrorCallback&&this.privErrorCallback(l)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){let o=new ye.PropertyCollection;if(o.setProperty(nt.CancellationErrorCodePropertyName,ye.CancellationErrorCode[n]),this.privSpeechRecognizer.canceled){let a=new ye.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privSpeechRecognizer.canceled(this.privSpeechRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ye.SpeechRecognitionResult(t,ye.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};Gc.SpeechServiceRecognizer=bv});var SP=p($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.ConversationTranscriptionServiceRecognizer=void 0;var Me=f(),st=C(),Av=class extends st.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConversationTranscriber=s,this.setSpeakerDiarizationJson()}setSpeakerDiarizationJson(){if(this.privEnableSpeakerId){let e=this.privSpeechContext.getSection("phraseDetection");e.mode="Conversation";let t={};t.mode="Anonymous",t.audioSessionId=this.privDiarizationSessionId,t.audioOffsetMs=0,e.speakerDiarization=t,this.privSpeechContext.setSection("phraseDetection",e)}}async processTypeSpecificMessages(e){let t,r=new Me.PropertyCollection;r.setProperty(Me.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let n=!1;switch(e.path.toLowerCase()){case"speech.hypothesis":case"speech.fragment":let s=st.SpeechHypothesis.fromJSON(e.textBody),o=s.Offset+this.privRequestSession.currentTurnAudioOffset;t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,Me.ResultReason.RecognizingSpeech,s.Text,s.Duration,o,s.Language,s.LanguageDetectionConfidence,void 0,void 0,e.textBody,r),this.privRequestSession.onHypothesis(o);let a=new Me.ConversationTranscriptionEventArgs(t,s.Duration,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribing)try{this.privConversationTranscriber.transcribing(this.privConversationTranscriber,a)}catch{}n=!0;break;case"speech.phrase":let c=st.SimpleSpeechPhrase.fromJSON(e.textBody),u=st.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+c.Offset+c.Duration),Me.ResultReason.Canceled===u){let l=st.EnumTranslation.implTranslateCancelResult(c.RecognitionStatus),h=st.EnumTranslation.implTranslateCancelErrorCode(c.RecognitionStatus);await this.cancelRecognitionLocal(l,h,st.EnumTranslation.implTranslateErrorDetails(h))}else if(!(this.privRequestSession.isSpeechEnded&&u===Me.ResultReason.NoMatch&&c.RecognitionStatus!==st.RecognitionStatus.InitialSilenceTimeout)){if(this.privRecognizerConfig.parameters.getProperty(st.OutputFormatPropertyName)===Me.OutputFormat[Me.OutputFormat.Simple])t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,c.SpeakerId,void 0,e.textBody,r);else{let h=st.DetailedSpeechPhrase.fromJSON(e.textBody),d=h.Offset+this.privRequestSession.currentTurnAudioOffset,g=h.getJsonWithCorrectedOffsets(d);t=new Me.ConversationTranscriptionResult(this.privRequestSession.requestId,u,h.RecognitionStatus===st.RecognitionStatus.Success?h.NBest[0].Display:void 0,h.Duration,d,h.Language,h.LanguageDetectionConfidence,c.SpeakerId,void 0,g,r)}let l=new Me.ConversationTranscriptionEventArgs(t,t.offset,this.privRequestSession.sessionId);if(this.privConversationTranscriber.transcribed)try{this.privConversationTranscriber.transcribed(this.privConversationTranscriber,l)}catch{}}n=!0;break;default:break}return n}cancelRecognition(e,t,r,n,s){if(new Me.PropertyCollection().setProperty(st.CancellationErrorCodePropertyName,Me.CancellationErrorCode[n]),this.privConversationTranscriber.canceled){let a=new Me.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationTranscriber.canceled(this.privConversationTranscriber,a)}catch{}}}};$c.ConversationTranscriptionServiceRecognizer=Av});var PP=p(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});Qc.TranscriptionServiceRecognizer=void 0;var RT=P(),tr=f(),CP=C(),ET=ii(),Tv=class extends CP.ConversationServiceRecognizer{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privTranscriberRecognizer=s,this.sendPrePayloadJSONOverride=o=>this.sendTranscriptionStartJSON(o),this.privRecognizerConfig.parameters.getProperty(tr.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps)==="true"&&this.privSpeechContext.setWordLevelTimings()}async sendSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createSpeechEventPayload(e,t))}}async sendMeetingSpeechEventAsync(e,t){if(this.privRequestSession.isRecognizing){let r=await this.fetchConnection();await this.sendSpeechEvent(r,this.createMeetingSpeechEventPayload(e,t))}}processTypeSpecificMessages(e){return this.processSpeechMessages(e)}handleRecognizedCallback(e,t,r){try{let n=new tr.SpeechRecognitionEventArgs(e,t,r);if(this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer,n),this.privSuccessCallback){try{this.privSuccessCallback(e)}catch(s){this.privErrorCallback&&this.privErrorCallback(s)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}catch{}}handleRecognizingCallback(e,t,r){try{let n=new tr.SpeechRecognitionEventArgs(e,t,r);this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer,n)}catch{}}cancelRecognition(e,t,r,n,s){let o=new tr.PropertyCollection;if(o.setProperty(CP.CancellationErrorCodePropertyName,tr.CancellationErrorCode[n]),this.privTranscriberRecognizer.IsMeetingRecognizer()){if(this.privTranscriberRecognizer.canceled){let a=new tr.MeetingTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}}else if(this.privTranscriberRecognizer.canceled){let a=new tr.ConversationTranscriptionCanceledEventArgs(r,s,n,void 0,e);try{this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new tr.SpeechRecognitionResult(t,tr.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}async sendTranscriptionStartJSON(e){if(await this.sendSpeechContext(e,!0),this.privTranscriberRecognizer.IsMeetingRecognizer()){let t=this.privTranscriberRecognizer.getMeetingInfo(),r=this.createMeetingSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}else{let t=this.privTranscriberRecognizer.getConversationInfo(),r=this.createSpeechEventPayload(t,"start");await this.sendSpeechEvent(e,r)}await this.sendWaveHeader(e)}sendSpeechEvent(e,t){let r=JSON.stringify(t);if(r)return e.send(new ET.SpeechConnectionMessage(RT.MessageType.Text,"speech.event",this.privRequestSession.requestId,"application/json",r))}createSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.conversationProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}createMeetingSpeechEventPayload(e,t){let r={id:"meeting",name:t,meeting:e.meetingProperties};return r.meeting.id=e.id,r.meeting.attendees=e.participants,r}};Qc.TranscriptionServiceRecognizer=Tv});var RP=p(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});Xc.DetailedSpeechPhrase=void 0;var _T=C(),Ov=class i{constructor(e){this.privDetailedSpeechPhrase=JSON.parse(e),this.privDetailedSpeechPhrase.RecognitionStatus=_T.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}getJsonWithCorrectedOffsets(e){if(this.privDetailedSpeechPhrase.NBest){let t;for(let r of this.privDetailedSpeechPhrase.NBest)if(r.Words&&r.Words[0]){t=r.Words[0].Offset;break}if(t&&t<e){let r=e-t;for(let n of this.privDetailedSpeechPhrase.NBest){if(n.Words)for(let s of n.Words)s.Offset+=r;if(n.DisplayWords)for(let s of n.DisplayWords)s.Offset+=r}}}return JSON.stringify(this.privDetailedSpeechPhrase)}get RecognitionStatus(){return this.privDetailedSpeechPhrase.RecognitionStatus}get NBest(){return this.privDetailedSpeechPhrase.NBest}get Duration(){return this.privDetailedSpeechPhrase.Duration}get Offset(){return this.privDetailedSpeechPhrase.Offset}get Language(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privDetailedSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence}get Text(){return this.privDetailedSpeechPhrase.NBest&&this.privDetailedSpeechPhrase.NBest[0]?this.privDetailedSpeechPhrase.NBest[0].Display||this.privDetailedSpeechPhrase.NBest[0].DisplayText:this.privDetailedSpeechPhrase.DisplayText}get SpeakerId(){return this.privDetailedSpeechPhrase.SpeakerId}};Xc.DetailedSpeechPhrase=Ov});var EP=p(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.SimpleSpeechPhrase=void 0;var IT=C(),kv=class i{constructor(e){this.privSimpleSpeechPhrase=JSON.parse(e),this.privSimpleSpeechPhrase.RecognitionStatus=IT.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]}static fromJSON(e){return new i(e)}get RecognitionStatus(){return this.privSimpleSpeechPhrase.RecognitionStatus}get DisplayText(){return this.privSimpleSpeechPhrase.DisplayText}get Offset(){return this.privSimpleSpeechPhrase.Offset}get Duration(){return this.privSimpleSpeechPhrase.Duration}get Language(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Language}get LanguageDetectionConfidence(){return this.privSimpleSpeechPhrase.PrimaryLanguage===void 0?void 0:this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence}get SpeakerId(){return this.privSimpleSpeechPhrase.SpeakerId}};Zc.SimpleSpeechPhrase=kv});var _P=p(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});Yc.AddedLmIntent=void 0;var Mv=class{constructor(e,t){this.modelImpl=e,this.intentName=t}};Yc.AddedLmIntent=Mv});var wP=p(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});eu.IntentServiceRecognizer=void 0;var IP=P(),ne=f(),Wi=C(),Dv=class extends Wi.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privIntentRecognizer=s,this.privIntentDataSent=!1}setIntents(e,t){this.privAddedLmIntents=e,this.privUmbrellaIntent=t,this.privIntentDataSent=!0}processTypeSpecificMessages(e){let t,r,n=!1,s=new ne.PropertyCollection;switch(e.messageType===IP.MessageType.Text&&s.setProperty(ne.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speech.hypothesis":let a=Wi.SpeechHypothesis.fromJSON(e.textBody);if(t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,ne.ResultReason.RecognizingIntent,a.Text,a.Duration,a.Offset+this.privRequestSession.currentTurnAudioOffset,a.Language,a.LanguageDetectionConfidence,void 0,e.textBody,s),this.privRequestSession.onHypothesis(t.offset),r=new ne.IntentRecognitionEventArgs(t,a.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId),this.privIntentRecognizer.recognizing)try{this.privIntentRecognizer.recognizing(this.privIntentRecognizer,r)}catch{}n=!0;break;case"speech.phrase":let c=Wi.SimpleSpeechPhrase.fromJSON(e.textBody);t=new ne.IntentRecognitionResult(void 0,this.privRequestSession.requestId,Wi.EnumTranslation.implTranslateRecognitionResult(c.RecognitionStatus),c.DisplayText,c.Duration,c.Offset+this.privRequestSession.currentTurnAudioOffset,c.Language,c.LanguageDetectionConfidence,void 0,e.textBody,s),r=new ne.IntentRecognitionEventArgs(t,t.offset,this.privRequestSession.sessionId);let u=()=>{if(this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(t)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}};this.privIntentDataSent===!1||ne.ResultReason.NoMatch===r.result.reason?(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),u()):this.privPendingIntentArgs=r,n=!0;break;case"response":if(r=this.privPendingIntentArgs,this.privPendingIntentArgs=void 0,r===void 0){if(e.textBody==="")return;r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult,0,this.privRequestSession.sessionId)}let l=Wi.IntentResponse.fromJSON(e.textBody);if(l!==null&&l.topScoringIntent&&l.topScoringIntent.intent){let h=this.privAddedLmIntents[l.topScoringIntent.intent];if(this.privUmbrellaIntent!==void 0&&(h=this.privUmbrellaIntent),h){let d=h===void 0||h.intentName===void 0?l.topScoringIntent.intent:h.intentName,g=r.result.reason;d!==void 0&&(g=ne.ResultReason.RecognizedIntent);let M=r.result.properties!==void 0?r.result.properties:new ne.PropertyCollection;M.setProperty(ne.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,e.textBody),r=new ne.IntentRecognitionEventArgs(new ne.IntentRecognitionResult(d,r.result.resultId,g,r.result.text,r.result.duration,r.result.offset,void 0,void 0,r.result.errorDetails,r.result.json,M),r.offset,r.sessionId)}}if(this.privRequestSession.onPhraseRecognized(r.offset+r.result.duration),this.privIntentRecognizer.recognized)try{this.privIntentRecognizer.recognized(this.privIntentRecognizer,r)}catch{}if(this.privSuccessCallback){try{this.privSuccessCallback(r.result)}catch(h){this.privErrorCallback&&this.privErrorCallback(h)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}n=!0;break;default:break}let o=new IP.Deferred;return o.resolve(n),o.promise}cancelRecognition(e,t,r,n,s){let o=new ne.PropertyCollection;if(o.setProperty(Wi.CancellationErrorCodePropertyName,ne.CancellationErrorCode[n]),this.privIntentRecognizer.canceled){let a=new ne.IntentRecognitionCanceledEventArgs(r,s,n,void 0,void 0,e);try{this.privIntentRecognizer.canceled(this.privIntentRecognizer,a)}catch{}}if(this.privSuccessCallback){let a=new ne.IntentRecognitionResult(void 0,t,ne.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(a),this.privSuccessCallback=void 0}catch{}}}};eu.IntentServiceRecognizer=Dv});var bP=p(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});tu.IntentResponse=void 0;var xv=class i{constructor(e){e===""?this.privIntentResponse={}:this.privIntentResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get query(){return this.privIntentResponse.query}get topScoringIntent(){return this.privIntentResponse.topScoringIntent}get entities(){return this.privIntentResponse.entities}};tu.IntentResponse=xv});var TP=p(AP=>{"use strict";Object.defineProperty(AP,"__esModule",{value:!0})});var kP=p(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});ru.ServiceTelemetryListener=void 0;var rr=P(),OP=Ac(),Nv=class{constructor(e,t,r){this.privIsDisposed=!1,this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privRequestId=e,this.privAudioSourceId=t,this.privAudioNodeId=r,this.privReceivedMessages={},this.privPhraseLatencies=[],this.privHypothesisLatencies=[]}phraseReceived(e){e>0&&this.privPhraseLatencies.push(Date.now()-e)}hypothesisReceived(e){e>0&&this.privHypothesisLatencies.push(Date.now()-e)}onEvent(e){this.privIsDisposed||(e instanceof OP.RecognitionTriggeredEvent&&e.requestId===this.privRequestId&&(this.privListeningTriggerMetric={End:e.eventTime,Name:"ListeningTrigger",Start:e.eventTime}),e instanceof rr.AudioStreamNodeAttachingEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof rr.AudioStreamNodeAttachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicStartTime=e.eventTime),e instanceof rr.AudioSourceErrorEvent&&e.audioSourceId===this.privAudioSourceId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof rr.AudioStreamNodeErrorEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Error:e.error,Name:"Microphone",Start:this.privMicStartTime})),e instanceof rr.AudioStreamNodeDetachedEvent&&e.audioSourceId===this.privAudioSourceId&&e.audioNodeId===this.privAudioNodeId&&(this.privMicMetric||(this.privMicMetric={End:e.eventTime,Name:"Microphone",Start:this.privMicStartTime})),e instanceof OP.ConnectingToServiceEvent&&e.requestId===this.privRequestId&&(this.privConnectionId=e.sessionId),e instanceof rr.ConnectionStartEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionStartTime=e.eventTime),e instanceof rr.ConnectionEstablishedEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof rr.ConnectionEstablishErrorEvent&&e.connectionId===this.privConnectionId&&(this.privConnectionEstablishMetric||(this.privConnectionEstablishMetric={End:e.eventTime,Error:this.getConnectionError(e.statusCode),Id:this.privConnectionId,Name:"Connection",Start:this.privConnectionStartTime})),e instanceof rr.ConnectionMessageReceivedEvent&&e.connectionId===this.privConnectionId&&e.message&&e.message.headers&&e.message.headers.path&&(this.privReceivedMessages[e.message.headers.path]||(this.privReceivedMessages[e.message.headers.path]=new Array),this.privReceivedMessages[e.message.headers.path].length<50&&this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime)))}getTelemetry(){let e=new Array;this.privListeningTriggerMetric&&e.push(this.privListeningTriggerMetric),this.privMicMetric&&e.push(this.privMicMetric),this.privConnectionEstablishMetric&&e.push(this.privConnectionEstablishMetric),this.privPhraseLatencies.length>0&&e.push({PhraseLatencyMs:this.privPhraseLatencies}),this.privHypothesisLatencies.length>0&&e.push({FirstHypothesisLatencyMs:this.privHypothesisLatencies});let t={Metrics:e,ReceivedMessages:this.privReceivedMessages},r=JSON.stringify(t);return this.privReceivedMessages={},this.privListeningTriggerMetric=null,this.privMicMetric=null,this.privConnectionEstablishMetric=null,this.privPhraseLatencies=[],this.privHypothesisLatencies=[],r}get hasTelemetry(){return Object.keys(this.privReceivedMessages).length!==0||this.privListeningTriggerMetric!==null||this.privMicMetric!==null||this.privConnectionEstablishMetric!==null||this.privPhraseLatencies.length!==0||this.privHypothesisLatencies.length!==0}dispose(){this.privIsDisposed=!0}getConnectionError(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()}}};ru.ServiceTelemetryListener=Nv});var MP=p(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});nu.RequestSession=void 0;var Hi=P(),iu=Ac(),wT=kP(),qv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privIsAudioNodeDetached=!1,this.privIsRecognizing=!1,this.privIsSpeechEnded=!1,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privHypothesisReceived=!1,this.privBytesSent=0,this.privRecognitionBytesSent=0,this.privRecogNumber=0,this.privInTurn=!1,this.privConnectionAttempts=0,this.privAudioSourceId=e,this.privRequestId=Hi.createNoDashGuid(),this.privAudioNodeId=Hi.createNoDashGuid(),this.privTurnDeferral=new Hi.Deferred,this.privTurnDeferral.resolve()}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get audioNodeId(){return this.privAudioNodeId}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSpeechEnded(){return this.privIsSpeechEnded}get isRecognizing(){return this.privIsRecognizing}get currentTurnAudioOffset(){return this.privTurnStartAudioOffset}get recogNumber(){return this.privRecogNumber}get numConnectionAttempts(){return this.privConnectionAttempts}get bytesSent(){return this.privBytesSent}get recognitionBytesSent(){return this.privRecognitionBytesSent}listenForServiceTelemetry(e){this.privServiceTelemetryListener&&this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener))}startNewRecognition(){this.privRecognitionBytesSent=0,this.privIsSpeechEnded=!1,this.privIsRecognizing=!0,this.privTurnStartAudioOffset=0,this.privLastRecoOffset=0,this.privRecogNumber++,this.privServiceTelemetryListener=new wT.ServiceTelemetryListener(this.privRequestId,this.privAudioSourceId,this.privAudioNodeId),this.onEvent(new iu.RecognitionTriggeredEvent(this.requestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}async onAudioSourceAttachCompleted(e,t){this.privAudioNode=e,this.privIsAudioNodeDetached=!1,t?await this.onComplete():this.onEvent(new iu.ListeningStartedEvent(this.privRequestId,this.privSessionId,this.privAudioSourceId,this.privAudioNodeId))}onPreConnectionStart(e,t){this.privAuthFetchEventId=e,this.privSessionId=t,this.onEvent(new iu.ConnectingToServiceEvent(this.privRequestId,this.privAuthFetchEventId,this.privSessionId))}async onAuthCompleted(e){e&&await this.onComplete()}async onConnectionEstablishCompleted(e,t){if(e===200){this.onEvent(new iu.RecognitionStartedEvent(this.requestId,this.privAudioSourceId,this.privAudioNodeId,this.privAuthFetchEventId,this.privSessionId)),this.privAudioNode&&this.privAudioNode.replay(),this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privBytesSent=0;return}else e===403&&await this.onComplete()}async onServiceTurnEndResponse(e){this.privTurnDeferral.resolve(),!e||this.isSpeechEnded?(await this.onComplete(),this.privInTurn=!1):(this.privTurnStartAudioOffset=this.privLastRecoOffset,this.privAudioNode.replay())}onSpeechContext(){this.privRequestId=Hi.createNoDashGuid()}onServiceTurnStartResponse(){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new Hi.Deferred}onHypothesis(e){this.privHypothesisReceived||(this.privHypothesisReceived=!0,this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(e)))}onPhraseRecognized(e){this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(e)),this.onServiceRecognized(e)}onServiceRecognized(e){this.privLastRecoOffset=e,this.privHypothesisReceived=!1,this.privAudioNode.shrinkBuffers(e),this.privConnectionAttempts=0}onAudioSent(e){this.privBytesSent+=e,this.privRecognitionBytesSent+=e}onRetryConnection(){this.privConnectionAttempts++}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach();this.privServiceTelemetryListener&&this.privServiceTelemetryListener.dispose(),this.privIsRecognizing=!1}}getTelemetry(){return this.privServiceTelemetryListener.hasTelemetry?this.privServiceTelemetryListener.getTelemetry():null}async onStopRecognizing(){await this.onComplete()}onSpeechEnded(){this.privIsSpeechEnded=!0}onEvent(e){this.privServiceTelemetryListener&&this.privServiceTelemetryListener.onEvent(e),Hi.Events.instance.onEvent(e)}async onComplete(){this.privIsRecognizing&&(this.privIsRecognizing=!1,await this.detachAudioNode())}async detachAudioNode(){this.privIsAudioNodeDetached||(this.privIsAudioNodeDetached=!0,this.privAudioNode&&await this.privAudioNode.detach())}};nu.RequestSession=qv});var DP=p(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});su.SpeechContext=void 0;var jv=class{constructor(e){this.privContext={},this.privDynamicGrammar=e}getSection(e){return this.privContext[e]||{}}setSection(e,t){this.privContext[e]=t}setPronunciationAssessmentParams(e,t,r=!1){this.privContext.phraseDetection===void 0&&(this.privContext.phraseDetection={enrichment:{pronunciationAssessment:{}}}),this.privContext.phraseDetection.enrichment===void 0&&(this.privContext.phraseDetection.enrichment={pronunciationAssessment:{}}),this.privContext.phraseDetection.enrichment.pronunciationAssessment=JSON.parse(e),r&&(this.privContext.phraseDetection.mode="Conversation"),this.setWordLevelTimings(),this.privContext.phraseOutput.detailed.options.push("PronunciationAssessment"),this.privContext.phraseOutput.detailed.options.indexOf("SNR")===-1&&this.privContext.phraseOutput.detailed.options.push("SNR"),t&&(this.privContext.phraseDetection.enrichment.contentAssessment={topic:t},this.privContext.phraseOutput.detailed.options.push("ContentAssessment"))}setDetailedOutputFormat(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed"}setWordLevelTimings(){this.privContext.phraseOutput===void 0&&(this.privContext.phraseOutput={detailed:{options:[]},format:{}}),this.privContext.phraseOutput.detailed===void 0&&(this.privContext.phraseOutput.detailed={options:[]}),this.privContext.phraseOutput.format="Detailed",this.privContext.phraseOutput.detailed.options.indexOf("WordTimings")===-1&&this.privContext.phraseOutput.detailed.options.push("WordTimings")}setSpeakerDiarizationAudioOffsetMs(e){this.privContext.phraseDetection.speakerDiarization.audioOffsetMs=e}toJSON(){let e=this.privDynamicGrammar.generateGrammarObject();return this.setSection("dgi",e),JSON.stringify(this.privContext)}};su.SpeechContext=jv});var xP=p(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});ou.DynamicGrammarBuilder=void 0;var zv=class{addPhrase(e){this.privPhrases||(this.privPhrases=[]),e instanceof Array?this.privPhrases=this.privPhrases.concat(e):this.privPhrases.push(e)}clearPhrases(){this.privPhrases=void 0}addReferenceGrammar(e){this.privGrammars||(this.privGrammars=[]),e instanceof Array?this.privGrammars=this.privGrammars.concat(e):this.privGrammars.push(e)}clearGrammars(){this.privGrammars=void 0}generateGrammarObject(){if(this.privGrammars===void 0&&this.privPhrases===void 0)return;let e={};if(e.ReferenceGrammars=this.privGrammars,this.privPhrases!==void 0&&this.privPhrases.length!==0){let t=[];this.privPhrases.forEach(r=>{t.push({Text:r})}),e.Groups=[{Type:"Generic",Items:t}]}return e}};ou.DynamicGrammarBuilder=zv});var qP=p(NP=>{"use strict";Object.defineProperty(NP,"__esModule",{value:!0})});var Bv=p(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.MessageDataStreamType=si.ActivityPayloadResponse=void 0;var Lv=class i{constructor(e){this.privActivityResponse=JSON.parse(e)}static fromJSON(e){return new i(e)}get conversationId(){return this.privActivityResponse.conversationId}get messageDataStreamType(){return this.privActivityResponse.messageDataStreamType}get messagePayload(){return this.privActivityResponse.messagePayload}get version(){return this.privActivityResponse.version}};si.ActivityPayloadResponse=Lv;var bT;(function(i){i[i.None=0]="None",i[i.TextToSpeechAudio=1]="TextToSpeechAudio"})(bT=si.MessageDataStreamType||(si.MessageDataStreamType={}))});var jP=p(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});au.DialogServiceTurnState=void 0;var AT=Pi(),TT=Lr(),OT=Bv(),Fv=class{constructor(e,t){this.privRequestId=t,this.privIsCompleted=!1,this.privAudioStream=null,this.privTurnManager=e,this.resetTurnEndTimeout()}get audioStream(){return this.resetTurnEndTimeout(),this.privAudioStream}processActivityPayload(e,t){return e.messageDataStreamType===OT.MessageDataStreamType.TextToSpeechAudio&&(this.privAudioStream=TT.AudioOutputStream.createPullStream(),this.privAudioStream.format=t!==void 0?t:AT.AudioOutputFormatImpl.getDefaultOutputFormat()),this.privAudioStream}endAudioStream(){this.privAudioStream!==null&&!this.privAudioStream.isClosed&&this.privAudioStream.close()}complete(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.endAudioStream()}resetTurnEndTimeout(){this.privTimeoutToken!==void 0&&clearTimeout(this.privTimeoutToken),this.privTimeoutToken=setTimeout(()=>{this.privTurnManager.CompleteTurn(this.privRequestId)},2e3)}};au.DialogServiceTurnState=Fv});var LP=p(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});cu.DialogServiceTurnStateManager=void 0;var zP=pt(),kT=jP(),Vv=class{constructor(){this.privTurnMap=new Map}StartTurn(e){if(this.privTurnMap.has(e))throw new zP.InvalidOperationError("Service error: There is already a turn with id:"+e);let t=new kT.DialogServiceTurnState(this,e);return this.privTurnMap.set(e,t),this.privTurnMap.get(e)}GetTurn(e){return this.privTurnMap.get(e)}CompleteTurn(e){if(!this.privTurnMap.has(e))throw new zP.InvalidOperationError("Service error: Received turn end for an unknown turn id:"+e);let t=this.privTurnMap.get(e);return t.complete(),this.privTurnMap.delete(e),t}};cu.DialogServiceTurnStateManager=Vv});var BP=p(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.DialogServiceAdapter=void 0;var MT=ce(),DT=Dp(),Ae=P(),xT=Pi(),k=f(),NT=LP(),Dt=C(),qT=Bv(),uu=ii(),Uv=class extends Dt.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privEvents=new Ae.EventSource,this.privDialogServiceConnector=s,this.receiveMessageOverride=()=>this.receiveDialogMessageOverride(),this.privTurnStateManager=new NT.DialogServiceTurnStateManager,this.recognizeOverride=(o,a,c)=>this.listenOnce(o,a,c),this.postConnectImplOverride=o=>this.dialogConnectImpl(o),this.configConnectionOverride=o=>this.configConnection(o),this.disconnectOverride=()=>this.privDisconnect(),this.privDialogAudioSource=r,this.agentConfigSent=!1,this.privLastResult=null,this.connectionEvents.attach(o=>{o.name==="ConnectionClosedEvent"&&(this.terminateMessageLoop=!0)})}async sendMessage(e){let t=Ae.createGuid(),r=Ae.createNoDashGuid(),n={context:{interactionId:t},messagePayload:JSON.parse(e),version:.5},s=JSON.stringify(n);await(await this.fetchConnection()).send(new uu.SpeechConnectionMessage(Ae.MessageType.Text,"agent",r,"application/json",s))}async privDisconnect(){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,this.agentConfigSent=!1}processTypeSpecificMessages(e){let t=new k.PropertyCollection;e.messageType===Ae.MessageType.Text&&t.setProperty(k.PropertyId.SpeechServiceResponse_JsonResult,e.textBody);let r,n;switch(e.path.toLowerCase()){case"speech.phrase":let o=Dt.SimpleSpeechPhrase.fromJSON(e.textBody);if(this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset+o.Offset+o.Duration),o.RecognitionStatus!==Dt.RecognitionStatus.TooManyRequests&&o.RecognitionStatus!==Dt.RecognitionStatus.Error){let d=this.fireEventForResult(o,t);if(this.privLastResult=d.result,this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,d)}catch{}}n=!0;break;case"speech.hypothesis":let a=Dt.SpeechHypothesis.fromJSON(e.textBody),c=a.Offset+this.privRequestSession.currentTurnAudioOffset;r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,k.ResultReason.RecognizingSpeech,a.Text,a.Duration,c,a.Language,a.LanguageDetectionConfidence,void 0,void 0,e.textBody,t),this.privRequestSession.onHypothesis(c);let u=new k.SpeechRecognitionEventArgs(r,a.Duration,this.privRequestSession.sessionId);if(this.privDialogServiceConnector.recognizing)try{this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector,u)}catch{}n=!0;break;case"speech.keyword":let l=Dt.SpeechKeyword.fromJSON(e.textBody);r=new k.SpeechRecognitionResult(this.privRequestSession.requestId,l.Status==="Accepted"?k.ResultReason.RecognizedKeyword:k.ResultReason.NoMatch,l.Text,l.Duration,l.Offset,void 0,void 0,void 0,void 0,e.textBody,t),l.Status!=="Accepted"&&(this.privLastResult=r);let h=new k.SpeechRecognitionEventArgs(r,r.duration,r.resultId);if(this.privDialogServiceConnector.recognized)try{this.privDialogServiceConnector.recognized(this.privDialogServiceConnector,h)}catch{}n=!0;break;case"audio":{let d=e.requestId.toUpperCase(),g=this.privTurnStateManager.GetTurn(d);try{e.binaryBody?g.audioStream.write(e.binaryBody):g.endAudioStream()}catch{}}n=!0;break;case"response":this.handleResponseMessage(e),n=!0;break;default:break}let s=new Ae.Deferred;return s.resolve(n),s.promise}async cancelRecognition(e,t,r,n,s){if(this.terminateMessageLoop=!0,this.privRequestSession.isRecognizing&&await this.privRequestSession.onStopRecognizing(),this.privDialogServiceConnector.canceled){let o=new k.PropertyCollection;o.setProperty(Dt.CancellationErrorCodePropertyName,k.CancellationErrorCode[n]);let a=new k.SpeechRecognitionCanceledEventArgs(r,s,n,void 0,e);try{this.privDialogServiceConnector.canceled(this.privDialogServiceConnector,a)}catch{}if(this.privSuccessCallback){let c=new k.SpeechRecognitionResult(void 0,k.ResultReason.Canceled,void 0,void 0,void 0,void 0,void 0,void 0,s,void 0,o);try{this.privSuccessCallback(c),this.privSuccessCallback=void 0}catch{}}}}async listenOnce(e,t,r){this.privRecognizerConfig.recognitionMode=e,this.privSuccessCallback=t,this.privErrorCallback=r,this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events),this.privRecognizerConfig.parameters.setProperty(k.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let n=this.connectImpl(),s=this.sendPreAudioMessages(),o=await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId),a=await this.privDialogAudioSource.format,c=await this.privDialogAudioSource.deviceInfo,u=new MT.ReplayableAudioNode(o,a.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(u,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:c};try{await n,await s}catch(d){return await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.ConnectionFailure,d),Promise.resolve()}let l=new k.SessionEventArgs(this.privRequestSession.sessionId);this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,l),this.sendAudio(u).then(()=>{},async d=>{await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,d)})}dialogConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}receiveDialogMessageOverride(){let e=new Ae.Deferred,t=async()=>{try{let r=this.isDisposed(),n=!this.isDisposed()&&this.terminateMessageLoop;if(r||n){e.resolve(void 0);return}let o=await(await this.fetchConnection()).read();if(!o)return t();let a=uu.SpeechConnectionMessage.fromConnectionMessage(o);switch(a.path.toLowerCase()){case"turn.start":{let M=a.requestId.toUpperCase(),D=this.privRequestSession.requestId.toUpperCase();M!==D?this.privTurnStateManager.StartTurn(M):this.privRequestSession.onServiceTurnStartResponse()}break;case"speech.startdetected":let u=Dt.SpeechDetected.fromJSON(a.textBody),l=new k.RecognitionEventArgs(u.Offset,this.privRequestSession.sessionId);this.privRecognizer.speechStartDetected&&this.privRecognizer.speechStartDetected(this.privRecognizer,l);break;case"speech.enddetected":let h;a.textBody.length>0?h=a.textBody:h="{ Offset: 0 }";let d=Dt.SpeechDetected.fromJSON(h);this.privRequestSession.onServiceRecognized(d.Offset+this.privRequestSession.currentTurnAudioOffset);let g=new k.RecognitionEventArgs(d.Offset+this.privRequestSession.currentTurnAudioOffset,this.privRequestSession.sessionId);this.privRecognizer.speechEndDetected&&this.privRecognizer.speechEndDetected(this.privRecognizer,g);break;case"turn.end":{let M=a.requestId.toUpperCase(),D=this.privRequestSession.requestId.toUpperCase();if(M!==D)this.privTurnStateManager.CompleteTurn(M);else{let oe=new k.SessionEventArgs(this.privRequestSession.sessionId);if(await this.privRequestSession.onServiceTurnEndResponse(!1),(!this.privRecognizerConfig.isContinuousRecognition||this.privRequestSession.isSpeechEnded||!this.privRequestSession.isRecognizing)&&this.privRecognizer.sessionStopped&&this.privRecognizer.sessionStopped(this.privRecognizer,oe),this.privSuccessCallback&&this.privLastResult){try{this.privSuccessCallback(this.privLastResult),this.privLastResult=null}catch(Q){this.privErrorCallback&&this.privErrorCallback(Q)}this.privSuccessCallback=void 0,this.privErrorCallback=void 0}}}break;default:try{await this.processTypeSpecificMessages(a)||this.serviceEvents&&this.serviceEvents.onEvent(new Ae.ServiceEvent(a.path.toLowerCase(),a.textBody))}catch{}}return t()}catch{this.terminateMessageLoop=!0,e.resolve()}};return t().catch(r=>{Ae.Events.instance.onEvent(new Ae.BackgroundEvent(r))}),e.promise}async startMessageLoop(){this.terminateMessageLoop=!1;try{await this.receiveDialogMessageOverride()}catch(e){await this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,k.CancellationReason.Error,k.CancellationErrorCode.RuntimeError,e)}return Promise.resolve()}async configConnection(e){return this.terminateMessageLoop?(this.terminateMessageLoop=!1,Promise.reject("Connection to service terminated.")):(await this.sendSpeechServiceConfig(e,this.privRequestSession,this.privRecognizerConfig.SpeechServiceConfig.serialize()),await this.sendAgentConfig(e),e)}async sendPreAudioMessages(){let e=await this.fetchConnection();this.addKeywordContextData(),await this.sendSpeechContext(e,!0),await this.sendAgentContext(e),await this.sendWaveHeader(e)}sendAgentConfig(e){if(this.agentConfig&&!this.agentConfigSent){if(this.privRecognizerConfig.parameters.getProperty(k.PropertyId.Conversation_DialogType)===k.DialogServiceConfig.DialogTypes.CustomCommands){let r=this.agentConfig.get();r.botInfo.commandsCulture=this.privRecognizerConfig.parameters.getProperty(k.PropertyId.SpeechServiceConnection_RecoLanguage,"en-us"),this.agentConfig.set(r)}this.onEvent(new DT.SendingAgentContextMessageEvent(this.agentConfig));let t=this.agentConfig.toJsonString();return this.agentConfigSent=!0,e.send(new uu.SpeechConnectionMessage(Ae.MessageType.Text,"agent.config",this.privRequestSession.requestId,"application/json",t))}}sendAgentContext(e){let t=Ae.createGuid(),r=this.privDialogServiceConnector.properties.getProperty(k.PropertyId.Conversation_Speech_Activity_Template),s=JSON.stringify({channelData:"",context:{interactionId:t},messagePayload:typeof r===void 0?void 0:r,version:.5});return e.send(new uu.SpeechConnectionMessage(Ae.MessageType.Text,"speech.agent.context",this.privRequestSession.requestId,"application/json",s))}fireEventForResult(e,t){let r=Dt.EnumTranslation.implTranslateRecognitionResult(e.RecognitionStatus),n=e.Offset+this.privRequestSession.currentTurnAudioOffset,s=new k.SpeechRecognitionResult(this.privRequestSession.requestId,r,e.DisplayText,e.Duration,n,e.Language,e.LanguageDetectionConfidence,void 0,void 0,JSON.stringify(e),t);return new k.SpeechRecognitionEventArgs(s,n,this.privRequestSession.sessionId)}handleResponseMessage(e){let t=JSON.parse(e.textBody);switch(t.messageType.toLowerCase()){case"message":let r=e.requestId.toUpperCase(),n=qT.ActivityPayloadResponse.fromJSON(e.textBody),s=this.privTurnStateManager.GetTurn(r);if(n.conversationId){let c=this.agentConfig.get();c.botInfo.conversationId=n.conversationId,this.agentConfig.set(c)}let o=s.processActivityPayload(n,xT.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(k.PropertyId.SpeechServiceConnection_SynthOutputFormat,void 0))),a=new k.ActivityReceivedEventArgs(n.messagePayload,o);if(this.privDialogServiceConnector.activityReceived)try{this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector,a)}catch{}break;case"messagestatus":if(this.privDialogServiceConnector.turnStatusReceived)try{this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector,new k.TurnStatusReceivedEventArgs(e.textBody))}catch{}break;default:Ae.Events.instance.onEvent(new Ae.BackgroundEvent(`Unexpected response of type ${t.messageType}. Ignoring.`));break}}onEvent(e){this.privEvents.onEvent(e),Ae.Events.instance.onEvent(e)}addKeywordContextData(){let e=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect");if(e===void 0)return;let t=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"),r=this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"),n=e.split(";"),s=t===void 0?[]:t.split(";"),o=r===void 0?[]:r.split(";"),a=[];for(let c=0;c<n.length;c++){let u={};u.text=n[c],c<s.length&&(u.offset=Number(s[c])),c<o.length&&(u.duration=Number(o[c])),a.push(u)}this.speechContext.setSection("invocationSource","VoiceActivationWithKeyword"),this.speechContext.setSection("keywordDetection",[{clientDetectedKeywords:a,onReject:{action:"EndOfTurn"},type:"startTrigger"}])}};pu.DialogServiceAdapter=Uv});var FP=p(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});lu.AgentConfig=void 0;var Wv=class{toJsonString(){return JSON.stringify(this.iPrivConfig)}get(){return this.iPrivConfig}set(e){this.iPrivConfig=e}};lu.AgentConfig=Wv});var du=p(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});hu.ConversationConnectionConfig=void 0;var jT=Yd(),xt=class i extends jT.RestConfigBase{static get host(){return i.privHost}static get apiVersion(){return i.privApiVersion}static get clientAppId(){return i.privClientAppId}static get defaultLanguageCode(){return i.privDefaultLanguageCode}static get restPath(){return i.privRestPath}static get webSocketPath(){return i.privWebSocketPath}static get transcriptionEventKeys(){return i.privTranscriptionEventKeys}};hu.ConversationConnectionConfig=xt;xt.privHost="dev.microsofttranslator.com";xt.privRestPath="/capito/room";xt.privApiVersion="2.0";xt.privDefaultLanguageCode="en-US";xt.privClientAppId="FC539C22-1767-4F1F-84BC-B4D811114F15";xt.privWebSocketPath="/capito/translate";xt.privTranscriptionEventKeys=["iCalUid","callId","organizer","FLAC","MTUri","DifferentiateGuestSpeakers","audiorecording","Threadid","OrganizerMri","OrganizerTenantId","UserToken"]});var VP=p(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});fu.ConversationManager=void 0;var vu=ce(),Er=_(),ir=f(),oi=du(),Hv=class{constructor(){this.privRequestParams=oi.ConversationConnectionConfig.configParams,this.privErrors=oi.ConversationConnectionConfig.restErrors,this.privHost=oi.ConversationConnectionConfig.host,this.privApiVersion=oi.ConversationConnectionConfig.apiVersion,this.privRestPath=oi.ConversationConnectionConfig.restPath,this.privRestAdapter=new vu.RestMessageAdapter({})}createOrJoin(e,t,r,n){try{Er.Contracts.throwIfNullOrUndefined(e,"args");let s=e.getProperty(ir.PropertyId.SpeechServiceConnection_RecoLanguage,oi.ConversationConnectionConfig.defaultLanguageCode),o=e.getProperty(ir.PropertyId.ConversationTranslator_Name,"conversation_host"),a=e.getProperty(ir.PropertyId.ConversationTranslator_Host,this.privHost),c=e.getProperty(ir.PropertyId.ConversationTranslator_CorrelationId),u=e.getProperty(ir.PropertyId.SpeechServiceConnection_Key),l=e.getProperty(ir.PropertyId.SpeechServiceConnection_Region),h=e.getProperty(ir.PropertyId.SpeechServiceAuthorization_Token);Er.Contracts.throwIfNullOrWhitespace(s,"languageCode"),Er.Contracts.throwIfNullOrWhitespace(o,"nickname"),Er.Contracts.throwIfNullOrWhitespace(a,"endpointHost");let d={};d[this.privRequestParams.apiVersion]=this.privApiVersion,d[this.privRequestParams.languageCode]=s,d[this.privRequestParams.nickname]=o;let g={};c&&(g[this.privRequestParams.correlationId]=c),g[this.privRequestParams.clientAppId]=oi.ConversationConnectionConfig.clientAppId,t!==void 0?d[this.privRequestParams.roomId]=t:(Er.Contracts.throwIfNullOrUndefined(l,this.privErrors.authInvalidSubscriptionRegion),g[this.privRequestParams.subscriptionRegion]=l,u?g[this.privRequestParams.subscriptionKey]=u:h?g[this.privRequestParams.authorization]=`Bearer ${h}`:Er.Contracts.throwIfNullOrUndefined(u,this.privErrors.authInvalidSubscriptionKey));let M={};M.headers=g,this.privRestAdapter.options=M;let D=`https://${a}${this.privRestPath}`;this.privRestAdapter.request(vu.RestRequestType.Post,D,d,null).then(oe=>{let Q=vu.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId,oe.headers);if(!oe.ok){if(n){let Ce=this.privErrors.invalidCreateJoinConversationResponse.replace("{status}",oe.status.toString()),F;try{F=JSON.parse(oe.data),Ce+=` [${F.error.code}: ${F.error.message}]`}catch{Ce+=` [${oe.data}]`}Q&&(Ce+=` ${Q}`),n(Ce)}return}let ee=JSON.parse(oe.data);if(ee&&(ee.requestId=Q),r){try{r(ee)}catch(Ce){n&&n(Ce)}r=void 0}}).catch(()=>{})}catch(s){if(n)if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}}leave(e,t){return new Promise((r,n)=>{try{Er.Contracts.throwIfNullOrUndefined(e,this.privErrors.invalidArgs.replace("{arg}","config")),Er.Contracts.throwIfNullOrWhitespace(t,this.privErrors.invalidArgs.replace("{arg}","token"));let s=e.getProperty(ir.PropertyId.ConversationTranslator_Host,this.privHost),o=e.getProperty(ir.PropertyId.ConversationTranslator_CorrelationId),a={};a[this.privRequestParams.apiVersion]=this.privApiVersion,a[this.privRequestParams.sessionToken]=t;let c={};o&&(c[this.privRequestParams.correlationId]=o);let u={};u.headers=c,this.privRestAdapter.options=u;let l=`https://${s}${this.privRestPath}`;this.privRestAdapter.request(vu.RestRequestType.Delete,l,a,null).then(h=>{h.ok,r()}).catch(()=>{})}catch(s){if(s instanceof Error){let o=s;n(o.name+": "+o.message)}else n(s)}})}};fu.ConversationManager=Hv});var Jv=p(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});gu.ConversationConnectionMessage=void 0;var zT=P(),Kv=class extends zT.ConnectionMessage{constructor(e,t,r,n){super(e,t,r,n);let s=JSON.parse(this.textBody);s.type!==void 0&&(this.privConversationMessageType=s.type)}get conversationMessageType(){return this.privConversationMessageType}};gu.ConversationConnectionMessage=Kv});var WP=p(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});mu.ConversationWebsocketMessageFormatter=void 0;var ai=P(),UP=Jv(),Gv=class{toConnectionMessage(e){let t=new ai.Deferred;try{if(e.messageType===ai.MessageType.Text){let r=new UP.ConversationConnectionMessage(e.messageType,e.textContent,{},e.id);t.resolve(r)}else e.messageType===ai.MessageType.Binary&&t.resolve(new UP.ConversationConnectionMessage(e.messageType,e.binaryContent,void 0,e.id))}catch(r){t.reject(`Error formatting the message. Error: ${r}`)}return t.promise}fromConnectionMessage(e){let t=new ai.Deferred;try{if(e.messageType===ai.MessageType.Text){let r=`${e.textBody?e.textBody:""}`;t.resolve(new ai.RawWebsocketMessage(ai.MessageType.Text,r,e.id))}}catch(r){t.reject(`Error formatting the message. ${r}`)}return t.promise}};mu.ConversationWebsocketMessageFormatter=Gv});var KP=p(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});yu.ConversationConnectionFactory=void 0;var HP=ce(),LT=P(),BT=_(),$v=f(),FT=Ze(),Ki=du(),VT=WP(),Qv=class extends FT.ConnectionFactoryBase{create(e,t,r){let n=e.parameters.getProperty($v.PropertyId.ConversationTranslator_Host,Ki.ConversationConnectionConfig.host),s=e.parameters.getProperty($v.PropertyId.ConversationTranslator_CorrelationId,LT.createGuid()),o=`wss://${n}${Ki.ConversationConnectionConfig.webSocketPath}`,a=e.parameters.getProperty($v.PropertyId.ConversationTranslator_Token,void 0);BT.Contracts.throwIfNullOrUndefined(a,"token");let c={};c[Ki.ConversationConnectionConfig.configParams.apiVersion]=Ki.ConversationConnectionConfig.apiVersion,c[Ki.ConversationConnectionConfig.configParams.token]=a,c[Ki.ConversationConnectionConfig.configParams.correlationId]=s;let u=e.parameters.getProperty("SPEECH-EnableWebsocketCompression","false")==="true";return new HP.WebsocketConnection(o,c,{},new VT.ConversationWebsocketMessageFormatter,HP.ProxyInfo.fromRecognizerConfig(e),u,r)}};yu.ConversationConnectionFactory=Qv});var JP=p(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});Su.ConversationRequestSession=void 0;var Xv=P(),Zv=class{constructor(e){this.privIsDisposed=!1,this.privDetachables=new Array,this.privSessionId=e,this.privRequestId=Xv.createNoDashGuid(),this.privRequestCompletionDeferral=new Xv.Deferred}get sessionId(){return this.privSessionId}get requestId(){return this.privRequestId}get completionPromise(){return this.privRequestCompletionDeferral.promise}onPreConnectionStart(e,t){this.privSessionId=t}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){e!==200&&e===403&&this.onComplete()}onServiceTurnEndResponse(e){e?this.privRequestId=Xv.createNoDashGuid():this.onComplete()}async dispose(){if(!this.privIsDisposed){this.privIsDisposed=!0;for(let e of this.privDetachables)await e.detach()}}onComplete(){}};Su.ConversationRequestSession=Zv});var of=p(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ConversationReceivedTranslationEventArgs=Le.ParticipantsListEventArgs=Le.ParticipantAttributeEventArgs=Le.ParticipantEventArgs=Le.LockRoomEventArgs=Le.MuteAllEventArgs=void 0;var as=f(),Yv=class extends as.SessionEventArgs{constructor(e,t){super(t),this.privIsMuted=e}get isMuted(){return this.privIsMuted}};Le.MuteAllEventArgs=Yv;var ef=class extends as.SessionEventArgs{constructor(e,t){super(t),this.privIsLocked=e}get isMuted(){return this.privIsLocked}};Le.LockRoomEventArgs=ef;var tf=class extends as.SessionEventArgs{constructor(e,t){super(t),this.privParticipant=e}get participant(){return this.privParticipant}};Le.ParticipantEventArgs=tf;var rf=class extends as.SessionEventArgs{constructor(e,t,r,n){super(n),this.privKey=t,this.privValue=r,this.privParticipantId=e}get value(){return this.privValue}get key(){return this.privKey}get id(){return this.privParticipantId}};Le.ParticipantAttributeEventArgs=rf;var nf=class extends as.SessionEventArgs{constructor(e,t,r,n,s,o,a,c,u){super(u),this.privRoomId=e,this.privSessionToken=t,this.privTranslateTo=r,this.privProfanityFilter=n,this.privRoomProfanityFilter=s,this.privIsRoomLocked=o,this.privIsRoomLocked=a,this.privParticipants=c}get sessionToken(){return this.privSessionToken}get conversationId(){return this.privRoomId}get translateTo(){return this.privTranslateTo}get profanityFilter(){return this.privProfanityFilter}get roomProfanityFilter(){return this.privRoomProfanityFilter}get isRoomLocked(){return this.privIsRoomLocked}get isMuteAll(){return this.privIsMuteAll}get participants(){return this.privParticipants}};Le.ParticipantsListEventArgs=nf;var sf=class{constructor(e,t,r){this.privPayload=t,this.privCommand=e,this.privSessionId=r}get payload(){return this.privPayload}get command(){return this.privCommand}get sessionId(){return this.privSessionId}};Le.ConversationReceivedTranslationEventArgs=sf});var cf=p(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.ConversationTranslatorCommandTypes=_r.ConversationTranslatorMessageTypes=_r.InternalParticipants=void 0;var af=class{constructor(e=[],t){this.participants=e,this.meId=t}addOrUpdateParticipant(e){if(e===void 0)return;let t=this.getParticipantIndex(e.id);return t>-1?this.participants.splice(t,1,e):this.participants.push(e),this.getParticipant(e.id)}getParticipantIndex(e){return this.participants.findIndex(t=>t.id===e)}getParticipant(e){return this.participants.find(t=>t.id===e)}deleteParticipant(e){this.participants=this.participants.filter(t=>t.id!==e)}get host(){return this.participants.find(e=>e.isHost===!0)}get me(){return this.getParticipant(this.meId)}};_r.InternalParticipants=af;_r.ConversationTranslatorMessageTypes={command:"command",final:"final",info:"info",instantMessage:"instant_message",keepAlive:"keep_alive",partial:"partial",participantCommand:"participant_command",translatedMessage:"translated_message"};_r.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"}});var GP=p(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});Cu.CommandResponsePayload=void 0;var UT=i=>JSON.parse(i),uf=class i{constructor(e){this.privCommandResponse=UT(e)}get type(){return this.privCommandResponse.type}get command(){return this.privCommandResponse.command}get id(){return this.privCommandResponse.id}get nickname(){return this.privCommandResponse.nickname}get participantId(){return this.privCommandResponse.participantId}get roomid(){return this.privCommandResponse.roomid}get value(){return this.privCommandResponse.value}get token(){return this.privCommandResponse.token}static fromJSON(e){return new i(e)}};Cu.CommandResponsePayload=uf});var $P=p(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.ParticipantPayloadResponse=Ji.ParticipantsListPayloadResponse=void 0;var WT=i=>JSON.parse(i),HT=i=>JSON.parse(i),pf=class i{constructor(e){this.privParticipantsPayloadResponse=WT(e)}get roomid(){return this.privParticipantsPayloadResponse.roomid}get id(){return this.privParticipantsPayloadResponse.id}get command(){return this.privParticipantsPayloadResponse.command}get participants(){return this.privParticipantsPayloadResponse.participants}get token(){return this.privParticipantsPayloadResponse.token}get translateTo(){return this.privParticipantsPayloadResponse.translateTo}get profanityFilter(){return this.privParticipantsPayloadResponse.profanityFilter}get roomProfanityFilter(){return this.privParticipantsPayloadResponse.roomProfanityFilter}get roomLocked(){return this.privParticipantsPayloadResponse.roomLocked}get muteAll(){return this.privParticipantsPayloadResponse.muteAll}get type(){return this.privParticipantsPayloadResponse.type}static fromJSON(e){return new i(e)}};Ji.ParticipantsListPayloadResponse=pf;var lf=class i{constructor(e){this.privParticipantPayloadResponse=HT(e)}get nickname(){return this.privParticipantPayloadResponse.nickname}get locale(){return this.privParticipantPayloadResponse.locale}get usetts(){return this.privParticipantPayloadResponse.usetts}get ismuted(){return this.privParticipantPayloadResponse.ismuted}get ishost(){return this.privParticipantPayloadResponse.ishost}get participantId(){return this.privParticipantPayloadResponse.participantId}get avatar(){return this.privParticipantPayloadResponse.avatar}static fromJSON(e){return new i(e)}};Ji.ParticipantPayloadResponse=lf});var QP=p(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.TextResponsePayload=Gi.SpeechResponsePayload=void 0;var KT=i=>JSON.parse(i),JT=i=>JSON.parse(i),hf=class i{constructor(e){this.privSpeechResponse=KT(e)}get recognition(){return this.privSpeechResponse.recognition}get translations(){return this.privSpeechResponse.translations}get id(){return this.privSpeechResponse.id}get language(){return this.privSpeechResponse.language}get nickname(){return this.privSpeechResponse.nickname}get participantId(){return this.privSpeechResponse.participantId}get roomid(){return this.privSpeechResponse.roomid}get timestamp(){return this.privSpeechResponse.timestamp}get type(){return this.privSpeechResponse.type}get isFinal(){return this.privSpeechResponse.type==="final"}static fromJSON(e){return new i(e)}};Gi.SpeechResponsePayload=hf;var df=class i{constructor(e){this.privTextResponse=JT(e)}get originalText(){return this.privTextResponse.originalText}get translations(){return this.privTextResponse.translations}get id(){return this.privTextResponse.id}get language(){return this.privTextResponse.language}get nickname(){return this.privTextResponse.nickname}get participantId(){return this.privTextResponse.participantId}get roomid(){return this.privTextResponse.roomid}get timestamp(){return this.privTextResponse.timestamp}get type(){return this.privTextResponse.type}static fromJSON(e){return new i(e)}};Gi.TextResponsePayload=df});var YP=p(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});var GT=GP();Object.defineProperty(ci,"CommandResponsePayload",{enumerable:!0,get:function(){return GT.CommandResponsePayload}});var XP=$P();Object.defineProperty(ci,"ParticipantsListPayloadResponse",{enumerable:!0,get:function(){return XP.ParticipantsListPayloadResponse}});Object.defineProperty(ci,"ParticipantPayloadResponse",{enumerable:!0,get:function(){return XP.ParticipantPayloadResponse}});var ZP=QP();Object.defineProperty(ci,"SpeechResponsePayload",{enumerable:!0,get:function(){return ZP.SpeechResponsePayload}});Object.defineProperty(ci,"TextResponsePayload",{enumerable:!0,get:function(){return ZP.TextResponsePayload}})});var rR=p(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});Pu.ConversationServiceAdapter=void 0;var cs=P(),mt=f(),eR=C(),tR=Jv(),$T=JP(),Ke=of(),Ir=cf(),us=YP(),vf=class extends eR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privConnectionConfigPromise=void 0,this.privLastPartialUtteranceId="",this.privConversationServiceConnector=s,this.privConversationAuthentication=e,this.receiveMessageOverride=()=>this.receiveConversationMessageOverride(),this.recognizeOverride=()=>this.noOp(),this.postConnectImplOverride=o=>this.conversationConnectImpl(o),this.configConnectionOverride=()=>this.configConnection(),this.disconnectOverride=()=>this.privDisconnect(),this.privConversationRequestSession=new $T.ConversationRequestSession(cs.createNoDashGuid()),this.privConversationConnectionFactory=t,this.privConversationIsDisposed=!1}isDisposed(){return super.isDisposed()||this.privConversationIsDisposed}async dispose(e){this.privConversationIsDisposed=!0,this.privConnectionConfigPromise!==void 0&&await(await this.privConnectionConfigPromise).dispose(e),await super.dispose(e)}async sendMessage(e){return(await this.fetchConnection()).send(new tR.ConversationConnectionMessage(cs.MessageType.Text,e))}async sendMessageAsync(e){await(await this.fetchConnection()).send(new tR.ConversationConnectionMessage(cs.MessageType.Text,e))}privDisconnect(){if(!this.terminateMessageLoop)return this.cancelRecognition(this.privConversationRequestSession.sessionId,this.privConversationRequestSession.requestId,mt.CancellationReason.Error,mt.CancellationErrorCode.NoError,"Disconnecting"),this.terminateMessageLoop=!0,Promise.resolve()}async processTypeSpecificMessages(){return!0}cancelRecognition(e,t,r,n,s){this.terminateMessageLoop=!0;let o=new mt.ConversationTranslationCanceledEventArgs(r,s,n,void 0,e);try{this.privConversationServiceConnector.canceled&&this.privConversationServiceConnector.canceled(this.privConversationServiceConnector,o)}catch{}}async conversationConnectImpl(e){return this.privConnectionLoop=this.startMessageLoop(),e}async receiveConversationMessageOverride(){if(this.isDisposed()||this.terminateMessageLoop)return Promise.resolve();let e=new cs.Deferred;try{let r=await(await this.fetchConnection()).read();if(this.isDisposed()||this.terminateMessageLoop)return e.resolve(),Promise.resolve();if(!r)return this.receiveConversationMessageOverride();let n=this.privConversationRequestSession.sessionId,s=r.conversationMessageType.toLowerCase(),o=!1;try{switch(s){case"info":case"participant_command":case"command":let a=us.CommandResponsePayload.fromJSON(r.textBody);switch(a.command.toLowerCase()){case"participantlist":let g=us.ParticipantsListPayloadResponse.fromJSON(r.textBody),M=g.participants.map(F=>({avatar:F.avatar,displayName:F.nickname,id:F.participantId,isHost:F.ishost,isMuted:F.ismuted,isUsingTts:F.usetts,preferredLanguage:F.locale}));this.privConversationServiceConnector.participantsListReceived&&this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,new Ke.ParticipantsListEventArgs(g.roomid,g.token,g.translateTo,g.profanityFilter,g.roomProfanityFilter,g.roomLocked,g.muteAll,M,n));break;case"settranslatetolanguages":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,Ir.ConversationTranslatorCommandTypes.setTranslateToLanguages,a.value,n));break;case"setprofanityfiltering":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,Ir.ConversationTranslatorCommandTypes.setProfanityFiltering,a.value,n));break;case"setmute":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,Ir.ConversationTranslatorCommandTypes.setMute,a.value,n));break;case"setmuteall":this.privConversationServiceConnector.muteAllCommandReceived&&this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,new Ke.MuteAllEventArgs(a.value,n));break;case"roomexpirationwarning":this.privConversationServiceConnector.conversationExpiration&&this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,new mt.ConversationExpirationEventArgs(a.value,this.privConversationRequestSession.sessionId));break;case"setusetts":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,Ir.ConversationTranslatorCommandTypes.setUseTTS,a.value,n));break;case"setlockstate":this.privConversationServiceConnector.lockRoomCommandReceived&&this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,new Ke.LockRoomEventArgs(a.value,n));break;case"changenickname":this.privConversationServiceConnector.participantUpdateCommandReceived&&this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantAttributeEventArgs(a.participantId,Ir.ConversationTranslatorCommandTypes.changeNickname,a.value,n));break;case"joinsession":let D=us.ParticipantPayloadResponse.fromJSON(r.textBody),oe={avatar:D.avatar,displayName:D.nickname,id:D.participantId,isHost:D.ishost,isMuted:D.ismuted,isUsingTts:D.usetts,preferredLanguage:D.locale};this.privConversationServiceConnector.participantJoinCommandReceived&&this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(oe,n));break;case"leavesession":let Q={id:a.participantId};this.privConversationServiceConnector.participantLeaveCommandReceived&&this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,new Ke.ParticipantEventArgs(Q,n));break;case"disconnectsession":let ee={id:a.participantId};break;case"token":let Ce=new eR.CognitiveTokenAuthentication(()=>{let F=a.token;return Promise.resolve(F)},()=>{let F=a.token;return Promise.resolve(F)});this.authentication=Ce,this.privConversationServiceConnector.onToken(Ce);break;default:break}break;case"partial":case"final":let c=us.SpeechResponsePayload.fromJSON(r.textBody),u=s==="final"?mt.ResultReason.TranslatedParticipantSpeech:mt.ResultReason.TranslatingParticipantSpeech,l=new mt.ConversationTranslationResult(c.participantId,this.getTranslations(c.translations),c.language,c.id,u,c.recognition,void 0,void 0,r.textBody,void 0);c.isFinal?((l.text!==void 0&&l.text.length>0||c.id===this.privLastPartialUtteranceId)&&(o=!0),o&&this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(Ir.ConversationTranslatorMessageTypes.final,l,n))):l.text!==void 0&&(this.privLastPartialUtteranceId=c.id,this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(Ir.ConversationTranslatorMessageTypes.partial,l,n)));break;case"translated_message":let h=us.TextResponsePayload.fromJSON(r.textBody),d=new mt.ConversationTranslationResult(h.participantId,this.getTranslations(h.translations),h.language,void 0,void 0,h.originalText,void 0,void 0,void 0,r.textBody,void 0);this.privConversationServiceConnector.translationReceived&&this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,new Ke.ConversationReceivedTranslationEventArgs(Ir.ConversationTranslatorMessageTypes.instantMessage,d,n));break;default:break}}catch{}return this.receiveConversationMessageOverride()}catch{this.terminateMessageLoop=!0}return e.promise}async startMessageLoop(){if(this.isDisposed())return Promise.resolve();this.terminateMessageLoop=!1;let e=this.receiveConversationMessageOverride();try{return await e}catch(t){return this.cancelRecognition(this.privRequestSession?this.privRequestSession.sessionId:"",this.privRequestSession?this.privRequestSession.requestId:"",mt.CancellationReason.Error,mt.CancellationErrorCode.RuntimeError,t),null}}configConnection(){return this.isDisposed()?Promise.resolve(void 0):this.privConnectionConfigPromise!==void 0?this.privConnectionConfigPromise.then(e=>e.state()===cs.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection()):this.privConnectionConfigPromise,()=>(this.privConnectionId=null,this.privConnectionConfigPromise=void 0,this.configConnection())):this.terminateMessageLoop?Promise.resolve(void 0):(this.privConnectionConfigPromise=this.connectImpl().then(e=>e),this.privConnectionConfigPromise)}getTranslations(e){let t;if(e!==void 0){t=new mt.Translations;for(let r of e)t.set(r.lang,r.translation)}return t}};Pu.ConversationServiceAdapter=vf});var iR=p(Xi=>{"use strict";Object.defineProperty(Xi,"__esModule",{value:!0});Xi.ConversationTranslatorRecognizer=Xi.ConversationRecognizerFactory=void 0;var QT=C(),$i=P(),Qi=_(),ff=f(),XT=KP(),ZT=rR(),gf=class{static fromConfig(e,t,r){return new Ru(e,t,r)}};Xi.ConversationRecognizerFactory=gf;var Ru=class extends ff.Recognizer{constructor(e,t,r){let n=t;Qi.Contracts.throwIfNull(n,"speechConfig");let s=e;Qi.Contracts.throwIfNull(s,"conversationImpl"),super(r,n.properties,new XT.ConversationConnectionFactory),this.privConversation=s,this.privIsDisposed=!1,this.privProperties=n.properties.clone(),this.privConnection=ff.Connection.fromRecognizer(this),this.privProperties.getProperty(ff.PropertyId.WebWorkerLoadType,"on").toLowerCase()==="on"&&typeof Blob<"u"&&typeof Worker<"u"?(this.privSetTimeout=$i.Timeout.setTimeout,this.privClearTimeout=$i.Timeout.clearTimeout):typeof window<"u"?(this.privSetTimeout=window.setTimeout.bind(window),this.privClearTimeout=window.clearTimeout.bind(window)):(this.privSetTimeout=setTimeout,this.privClearTimeout=clearTimeout)}set connected(e){this.privConnection.connected=e}set disconnected(e){this.privConnection.disconnected=e}get speechRecognitionLanguage(){return this.privSpeechRecognitionLanguage}get properties(){return this.privProperties}isDisposed(){return this.privIsDisposed}connect(e,t,r){try{Qi.Contracts.throwIfDisposed(this.privIsDisposed),Qi.Contracts.throwIfNullOrWhitespace(e,"token"),this.privReco.conversationTranslatorToken=e,this.resetConversationTimeout(),this.privReco.connectAsync(t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n)}}disconnect(e,t){try{Qi.Contracts.throwIfDisposed(this.privIsDisposed),this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privReco.disconnect().then(()=>{e&&e()},r=>{t&&t(r)})}catch(r){if(t)if(r instanceof Error){let n=r;t(n.name+": "+n.message)}else t(r);this.dispose(!0).catch(n=>{$i.Events.instance.onEvent(new $i.BackgroundEvent(n))})}}sendRequest(e,t,r){try{Qi.Contracts.throwIfDisposed(this.privIsDisposed),this.sendMessage(e,t,r)}catch(n){if(r)if(n instanceof Error){let s=n;r(s.name+": "+s.message)}else r(n);this.dispose(!0).catch(s=>{$i.Events.instance.onEvent(new $i.BackgroundEvent(s))})}}onToken(e){this.privConversation.onToken(e)}async close(){this.privIsDisposed||(this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close()),this.privConnection=void 0,await this.dispose(!0))}async dispose(e){this.privIsDisposed||e&&(this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privIsDisposed=!0,this.privConnection&&(this.privConnection.closeConnection(),this.privConnection.close(),this.privConnection=void 0),await super.dispose(e))}createRecognizerConfig(e){return new QT.RecognizerConfig(e,this.privProperties)}createServiceRecognizer(e,t,r,n){let s=r;return new ZT.ConversationServiceAdapter(e,t,s,n,this)}sendMessage(e,t,r){let n=this.privReco;((o,a,c)=>{o!==void 0?o.then(()=>{try{a&&a()}catch(u){c&&c(`'Unhandled error on promise callback: ${u}'`)}},u=>{try{c&&c(u)}catch{}}):c&&c("Null promise")})(n.sendMessageAsync(e),t,r),this.resetConversationTimeout()}resetConversationTimeout(){this.privTimeoutToken!==void 0&&this.privClearTimeout(this.privTimeoutToken),this.privTimeoutToken=this.privSetTimeout(()=>{this.sendRequest(this.privConversation.getKeepAlive())},6e4)}};Xi.ConversationTranslatorRecognizer=Ru});var sR=p(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.TranscriberRecognizer=void 0;var nR=P(),yt=_(),Zi=f(),Eu=C(),mf=class extends Zi.Recognizer{constructor(e,t){let r=e;yt.Contracts.throwIfNull(r,"speechTranslationConfig");let n=t;yt.Contracts.throwIfNull(n,"audioConfigImpl"),yt.Contracts.throwIfNullOrWhitespace(r.speechRecognitionLanguage,Zi.PropertyId[Zi.PropertyId.SpeechServiceConnection_RecoLanguage]),super(t,r.properties,new Eu.TranscriberConnectionFactory),this.privDisposedRecognizer=!1,this.isMeetingRecognizer=!1}get speechRecognitionLanguage(){return yt.Contracts.throwIfDisposed(this.privDisposedRecognizer),this.properties.getProperty(Zi.PropertyId.SpeechServiceConnection_RecoLanguage)}get properties(){return this.privProperties}get authorizationToken(){return this.properties.getProperty(Zi.PropertyId.SpeechServiceAuthorization_Token)}set authorizationToken(e){yt.Contracts.throwIfNullOrWhitespace(e,"token"),this.properties.setProperty(Zi.PropertyId.SpeechServiceAuthorization_Token,e)}set conversation(e){yt.Contracts.throwIfNullOrUndefined(e,"Conversation"),this.isMeetingRecognizer=!1,this.privConversation=e}getConversationInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privConversation,"Conversation"),this.privConversation.conversationInfo}set meeting(e){yt.Contracts.throwIfNullOrUndefined(e,"Meeting"),this.isMeetingRecognizer=!0,this.privMeeting=e}getMeetingInfo(){return yt.Contracts.throwIfNullOrUndefined(this.privMeeting,"Meeting"),this.privMeeting.meetingInfo}IsMeetingRecognizer(){return this.isMeetingRecognizer}startContinuousRecognitionAsync(e,t){nR.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Eu.RecognitionMode.Conversation),e,t)}stopContinuousRecognitionAsync(e,t){nR.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(),e,t)}async close(){this.privDisposedRecognizer||await this.dispose(!0)}async pushConversationEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendSpeechEventAsync(e,t)}async pushMeetingEvent(e,t){let r=this.privReco;yt.Contracts.throwIfNullOrUndefined(r,"serviceRecognizer"),await r.sendMeetingSpeechEventAsync(e,t)}async enforceAudioGating(){let r=(await this.audioConfig.format).channels;if(r===1){if(this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2","false").toLowerCase()!=="true")throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details")}else if(r!==8)throw new Error(`Unsupported audio configuration: Detected ${r}-channel audio`)}connectMeetingCallbacks(e){this.isMeetingRecognizer=!0,this.canceled=(t,r)=>{e.canceled&&e.canceled(e,r)},this.recognizing=(t,r)=>{e.transcribing&&e.transcribing(e,r)},this.recognized=(t,r)=>{e.transcribed&&e.transcribed(e,r)},this.sessionStarted=(t,r)=>{e.sessionStarted&&e.sessionStarted(e,r)},this.sessionStopped=(t,r)=>{e.sessionStopped&&e.sessionStopped(e,r)}}disconnectCallbacks(){this.canceled=void 0,this.recognizing=void 0,this.recognized=void 0,this.sessionStarted=void 0,this.sessionStopped=void 0}async dispose(e){this.privDisposedRecognizer||(e&&(this.privDisposedRecognizer=!0,await this.implRecognizerStop()),await super.dispose(e))}createRecognizerConfig(e){return new Eu.RecognizerConfig(e,this.properties)}createServiceRecognizer(e,t,r,n){let s=r;return new Eu.TranscriptionServiceRecognizer(e,t,s,n,this)}};_u.TranscriberRecognizer=mf});var oR=p(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});var YT=VP();Object.defineProperty(De,"ConversationManager",{enumerable:!0,get:function(){return YT.ConversationManager}});var eO=du();Object.defineProperty(De,"ConversationConnectionConfig",{enumerable:!0,get:function(){return eO.ConversationConnectionConfig}});var tO=iR();Object.defineProperty(De,"ConversationRecognizerFactory",{enumerable:!0,get:function(){return tO.ConversationRecognizerFactory}});var rO=sR();Object.defineProperty(De,"TranscriberRecognizer",{enumerable:!0,get:function(){return rO.TranscriberRecognizer}});var Yi=of();Object.defineProperty(De,"ConversationReceivedTranslationEventArgs",{enumerable:!0,get:function(){return Yi.ConversationReceivedTranslationEventArgs}});Object.defineProperty(De,"LockRoomEventArgs",{enumerable:!0,get:function(){return Yi.LockRoomEventArgs}});Object.defineProperty(De,"MuteAllEventArgs",{enumerable:!0,get:function(){return Yi.MuteAllEventArgs}});Object.defineProperty(De,"ParticipantAttributeEventArgs",{enumerable:!0,get:function(){return Yi.ParticipantAttributeEventArgs}});Object.defineProperty(De,"ParticipantEventArgs",{enumerable:!0,get:function(){return Yi.ParticipantEventArgs}});Object.defineProperty(De,"ParticipantsListEventArgs",{enumerable:!0,get:function(){return Yi.ParticipantsListEventArgs}});var yf=cf();Object.defineProperty(De,"ConversationTranslatorCommandTypes",{enumerable:!0,get:function(){return yf.ConversationTranslatorCommandTypes}});Object.defineProperty(De,"ConversationTranslatorMessageTypes",{enumerable:!0,get:function(){return yf.ConversationTranslatorMessageTypes}});Object.defineProperty(De,"InternalParticipants",{enumerable:!0,get:function(){return yf.InternalParticipants}})});var Cf=p(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.SynthesisAudioMetadata=ui.MetadataType=void 0;var iO;(function(i){i.WordBoundary="WordBoundary",i.Bookmark="Bookmark",i.Viseme="Viseme",i.SentenceBoundary="SentenceBoundary",i.SessionEnd="SessionEnd",i.AvatarSignal="TalkingAvatarSignal"})(iO=ui.MetadataType||(ui.MetadataType={}));var Sf=class i{constructor(e){this.privSynthesisAudioMetadata=JSON.parse(e)}static fromJSON(e){return new i(e)}get Metadata(){return this.privSynthesisAudioMetadata.Metadata}};ui.SynthesisAudioMetadata=Sf});var cR=p(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.SynthesisStartedEvent=Nt.ConnectingToSynthesisServiceEvent=Nt.SynthesisTriggeredEvent=Nt.SpeechSynthesisEvent=void 0;var aR=P(),en=class extends aR.PlatformEvent{constructor(e,t,r=aR.EventType.Info){super(e,r),this.privRequestId=t}get requestId(){return this.privRequestId}};Nt.SpeechSynthesisEvent=en;var Pf=class extends en{constructor(e,t,r){super("SynthesisTriggeredEvent",e),this.privSessionAudioDestinationId=t,this.privTurnAudioDestinationId=r}get audioSessionDestinationId(){return this.privSessionAudioDestinationId}get audioTurnDestinationId(){return this.privTurnAudioDestinationId}};Nt.SynthesisTriggeredEvent=Pf;var Rf=class extends en{constructor(e,t){super("ConnectingToSynthesisServiceEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Nt.ConnectingToSynthesisServiceEvent=Rf;var Ef=class extends en{constructor(e,t){super("SynthesisStartedEvent",e),this.privAuthFetchEventId=t}get authFetchEventId(){return this.privAuthFetchEventId}};Nt.SynthesisStartedEvent=Ef});var uR=p(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});bu.SynthesisTurn=void 0;var Iu=P(),nO=Lr(),wu=f(),sO=Cf(),_f=cR(),If=class i{constructor(){this.privIsDisposed=!1,this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!1,this.privBytesReceived=0,this.privInTurn=!1,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privRequestId=Iu.createNoDashGuid(),this.privTurnDeferral=new Iu.Deferred,this.privTurnDeferral.resolve()}get requestId(){return this.privRequestId}get streamId(){return this.privStreamId}set streamId(e){this.privStreamId=e}get audioOutputFormat(){return this.privAudioOutputFormat}set audioOutputFormat(e){this.privAudioOutputFormat=e}get turnCompletionPromise(){return this.privTurnDeferral.promise}get isSynthesisEnded(){return this.privIsSynthesisEnded}get isSynthesizing(){return this.privIsSynthesizing}get currentTextOffset(){return this.privTextOffset}get currentSentenceOffset(){return this.privSentenceOffset}get bytesReceived(){return this.privBytesReceived}get audioDuration(){return this.privAudioDuration}get extraProperties(){if(this.privWebRTCSDP){let e=new wu.PropertyCollection;return e.setProperty(wu.PropertyId.TalkingAvatarService_WebRTC_SDP,this.privWebRTCSDP),e}}async getAllReceivedAudio(){return this.privReceivedAudio?Promise.resolve(this.privReceivedAudio):this.privIsSynthesisEnded?(await this.readAllAudioFromStream(),Promise.resolve(this.privReceivedAudio)):null}async getAllReceivedAudioWithHeader(){if(this.privReceivedAudioWithHeader)return this.privReceivedAudioWithHeader;if(!this.privIsSynthesisEnded)return null;if(this.audioOutputFormat.hasHeader){let e=await this.getAllReceivedAudio();return this.privReceivedAudioWithHeader=this.audioOutputFormat.addHeader(e),this.privReceivedAudioWithHeader}else return this.getAllReceivedAudio()}startNewSynthesis(e,t,r,n){this.privIsSynthesisEnded=!1,this.privIsSynthesizing=!0,this.privRequestId=e,this.privRawText=t,this.privIsSSML=r,this.privAudioOutputStream=new nO.PullAudioOutputStreamImpl,this.privAudioOutputStream.format=this.privAudioOutputFormat,this.privReceivedAudio=null,this.privReceivedAudioWithHeader=null,this.privBytesReceived=0,this.privTextOffset=0,this.privNextSearchTextIndex=0,this.privSentenceOffset=0,this.privNextSearchSentenceIndex=0,this.privPartialVisemeAnimation="",this.privWebRTCSDP="",n!==void 0&&(this.privTurnAudioDestination=n,this.privTurnAudioDestination.format=this.privAudioOutputFormat),this.onEvent(new _f.SynthesisTriggeredEvent(this.requestId,void 0,n===void 0?void 0:n.id()))}onPreConnectionStart(e){this.privAuthFetchEventId=e,this.onEvent(new _f.ConnectingToSynthesisServiceEvent(this.privRequestId,this.privAuthFetchEventId))}onAuthCompleted(e){e&&this.onComplete()}onConnectionEstablishCompleted(e){if(e===200){this.onEvent(new _f.SynthesisStartedEvent(this.requestId,this.privAuthFetchEventId)),this.privBytesReceived=0;return}else e===403&&this.onComplete()}onServiceResponseMessage(e){let t=JSON.parse(e);this.streamId=t.audio.streamId}onServiceTurnEndResponse(){this.privInTurn=!1,this.privTurnDeferral.resolve(),this.onComplete()}onServiceTurnStartResponse(e){this.privTurnDeferral&&this.privInTurn&&(this.privTurnDeferral.reject("Another turn started before current completed."),this.privTurnDeferral.promise.then().catch(()=>{})),this.privInTurn=!0,this.privTurnDeferral=new Iu.Deferred;let t=JSON.parse(e);t.webrtc&&(this.privWebRTCSDP=t.webrtc.connectionString)}onAudioChunkReceived(e){this.isSynthesizing&&(this.privAudioOutputStream.write(e),this.privBytesReceived+=e.byteLength,this.privTurnAudioDestination!==void 0&&this.privTurnAudioDestination.write(e))}onTextBoundaryEvent(e){this.updateTextOffset(e.Data.text.Text,e.Type)}onVisemeMetadataReceived(e){e.Data.AnimationChunk!==void 0&&(this.privPartialVisemeAnimation+=e.Data.AnimationChunk)}onSessionEnd(e){this.privAudioDuration=e.Data.Offset}async constructSynthesisResult(){let e=await this.getAllReceivedAudioWithHeader();return new wu.SpeechSynthesisResult(this.requestId,wu.ResultReason.SynthesizingAudioCompleted,e,void 0,this.extraProperties,this.audioDuration)}dispose(){this.privIsDisposed||(this.privIsDisposed=!0)}onStopSynthesizing(){this.onComplete()}getAndClearVisemeAnimation(){let e=this.privPartialVisemeAnimation;return this.privPartialVisemeAnimation="",e}onEvent(e){Iu.Events.instance.onEvent(e)}static isXmlTag(e){return e.length>=2&&e[0]==="<"&&e[e.length-1]===">"}updateTextOffset(e,t){t===sO.MetadataType.WordBoundary?(this.privTextOffset=this.privRawText.indexOf(e,this.privNextSearchTextIndex),this.privTextOffset>=0&&(this.privNextSearchTextIndex=this.privTextOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privTextOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t))):(this.privSentenceOffset=this.privRawText.indexOf(e,this.privNextSearchSentenceIndex),this.privSentenceOffset>=0&&(this.privNextSearchSentenceIndex=this.privSentenceOffset+e.length,this.privIsSSML&&this.withinXmlTag(this.privSentenceOffset)&&!i.isXmlTag(e)&&this.updateTextOffset(e,t)))}onComplete(){this.privIsSynthesizing&&(this.privIsSynthesizing=!1,this.privIsSynthesisEnded=!0,this.privAudioOutputStream.close(),this.privInTurn=!1,this.privTurnAudioDestination!==void 0&&(this.privTurnAudioDestination.close(),this.privTurnAudioDestination=void 0))}async readAllAudioFromStream(){if(this.privIsSynthesisEnded){this.privReceivedAudio=new ArrayBuffer(this.bytesReceived);try{await this.privAudioOutputStream.read(this.privReceivedAudio)}catch{this.privReceivedAudio=new ArrayBuffer(0)}}}withinXmlTag(e){return this.privRawText.indexOf("<",e+1)>this.privRawText.indexOf(">",e+1)}};bu.SynthesisTurn=If});var pR=p(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});Tu.SynthesisAdapterBase=void 0;var Te=P(),Je=f(),ot=C(),tn=ii(),Au=class{constructor(e,t,r,n){if(this.speakOverride=void 0,this.receiveMessageOverride=void 0,this.connectImplOverride=void 0,this.configConnectionOverride=void 0,this.privConnectionConfigurationPromise=void 0,!e)throw new Te.ArgumentNullError("authentication");if(!t)throw new Te.ArgumentNullError("connectionFactory");if(!r)throw new Te.ArgumentNullError("synthesizerConfig");this.privAuthentication=e,this.privConnectionFactory=t,this.privSynthesizerConfig=r,this.privIsDisposed=!1,this.privSessionAudioDestination=n,this.privSynthesisTurn=new ot.SynthesisTurn,this.privConnectionEvents=new Te.EventSource,this.privServiceEvents=new Te.EventSource,this.privSynthesisContext=new ot.SynthesisContext,this.privAgentConfig=new ot.AgentConfig,this.connectionEvents.attach(s=>{if(s.name==="ConnectionClosedEvent"){let o=s;o.statusCode!==1e3&&this.cancelSynthesisLocal(Je.CancellationReason.Error,o.statusCode===1007?Je.CancellationErrorCode.BadRequestParameters:Je.CancellationErrorCode.ConnectionFailure,`${o.reason} websocket error code: ${o.statusCode}`)}})}get synthesisContext(){return this.privSynthesisContext}get agentConfig(){return this.privAgentConfig}get connectionEvents(){return this.privConnectionEvents}get serviceEvents(){return this.privServiceEvents}set activityTemplate(e){this.privActivityTemplate=e}get activityTemplate(){return this.privActivityTemplate}set audioOutputFormat(e){this.privAudioOutputFormat=e,this.privSynthesisTurn.audioOutputFormat=e,this.privSessionAudioDestination!==void 0&&(this.privSessionAudioDestination.format=e),this.synthesisContext!==void 0&&(this.synthesisContext.audioOutputFormat=e)}isDisposed(){return this.privIsDisposed}async dispose(e){this.privIsDisposed=!0,this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.close(),this.privConnectionConfigurationPromise!==void 0&&await(await this.privConnectionConfigurationPromise).dispose(e)}async connect(){await this.connectImpl()}async sendNetworkMessage(e,t){let r=typeof t=="string"?Te.MessageType.Text:Te.MessageType.Binary,n=typeof t=="string"?"application/json":"";return(await this.fetchConnection()).send(new tn.SpeechConnectionMessage(r,e,this.privSynthesisTurn.requestId,n,t))}async Speak(e,t,r,n,s,o){let a;if(t?a=e:a=this.privSynthesizer.buildSsml(e),this.speakOverride!==void 0)return this.speakOverride(a,r,n,s);this.privSuccessCallback=n,this.privErrorCallback=s,this.privSynthesisTurn.startNewSynthesis(r,e,t,o);try{await this.connectImpl();let c=await this.fetchConnection();await this.sendSynthesisContext(c),await this.sendSsmlMessage(c,a,r),this.onSynthesisStarted(r),this.receiveMessage()}catch(c){return this.cancelSynthesisLocal(Je.CancellationReason.Error,Je.CancellationErrorCode.ConnectionFailure,c),Promise.reject(c)}}async stopSpeaking(){return await this.connectImpl(),(await this.fetchConnection()).send(new tn.SpeechConnectionMessage(Te.MessageType.Text,"synthesis.control",this.privSynthesisTurn.requestId,"application/json",JSON.stringify({action:"stop"})))}cancelSynthesis(e,t,r,n){let s=new Je.PropertyCollection;s.setProperty(ot.CancellationErrorCodePropertyName,Je.CancellationErrorCode[r]);let o=new Je.SpeechSynthesisResult(e,Je.ResultReason.Canceled,void 0,n,s);if(this.onSynthesisCancelled(o),this.privSuccessCallback)try{this.privSuccessCallback(o)}catch{}}cancelSynthesisLocal(e,t,r){this.privSynthesisTurn.isSynthesizing&&(this.privSynthesisTurn.onStopSynthesizing(),this.cancelSynthesis(this.privSynthesisTurn.requestId,e,t,r))}processTypeSpecificMessages(e){return!0}async receiveMessage(){try{let t=await(await this.fetchConnection()).read();if(this.receiveMessageOverride!==void 0)return this.receiveMessageOverride();if(this.privIsDisposed)return;if(!t)return this.privSynthesisTurn.isSynthesizing?this.receiveMessage():void 0;let r=tn.SpeechConnectionMessage.fromConnectionMessage(t);if(r.requestId.toLowerCase()===this.privSynthesisTurn.requestId.toLowerCase())switch(r.path.toLowerCase()){case"turn.start":this.privSynthesisTurn.onServiceTurnStartResponse(r.textBody);break;case"response":this.privSynthesisTurn.onServiceResponseMessage(r.textBody);break;case"audio":this.privSynthesisTurn.streamId.toLowerCase()===r.streamId.toLowerCase()&&r.binaryBody&&(this.privSynthesisTurn.onAudioChunkReceived(r.binaryBody),this.onSynthesizing(r.binaryBody),this.privSessionAudioDestination!==void 0&&this.privSessionAudioDestination.write(r.binaryBody));break;case"audio.metadata":let n=ot.SynthesisAudioMetadata.fromJSON(r.textBody).Metadata;for(let o of n)switch(o.Type){case ot.MetadataType.WordBoundary:case ot.MetadataType.SentenceBoundary:this.privSynthesisTurn.onTextBoundaryEvent(o);let a=new Je.SpeechSynthesisWordBoundaryEventArgs(o.Data.Offset,o.Data.Duration,o.Data.text.Text,o.Data.text.Length,o.Type===ot.MetadataType.WordBoundary?this.privSynthesisTurn.currentTextOffset:this.privSynthesisTurn.currentSentenceOffset,o.Data.text.BoundaryType);this.onWordBoundary(a);break;case ot.MetadataType.Bookmark:let c=new Je.SpeechSynthesisBookmarkEventArgs(o.Data.Offset,o.Data.Bookmark);this.onBookmarkReached(c);break;case ot.MetadataType.Viseme:if(this.privSynthesisTurn.onVisemeMetadataReceived(o),o.Data.IsLastAnimation){let u=new Je.SpeechSynthesisVisemeEventArgs(o.Data.Offset,o.Data.VisemeId,this.privSynthesisTurn.getAndClearVisemeAnimation());this.onVisemeReceived(u)}break;case ot.MetadataType.AvatarSignal:this.onAvatarEvent(o);break;case ot.MetadataType.SessionEnd:this.privSynthesisTurn.onSessionEnd(o);break}break;case"turn.end":this.privSynthesisTurn.onServiceTurnEndResponse();let s;try{s=await this.privSynthesisTurn.constructSynthesisResult(),this.privSuccessCallback&&this.privSuccessCallback(s)}catch(o){this.privErrorCallback&&this.privErrorCallback(o)}this.onSynthesisCompleted(s);break;default:this.processTypeSpecificMessages(r)||this.privServiceEvents&&this.serviceEvents.onEvent(new Te.ServiceEvent(r.path.toLowerCase(),r.textBody))}return this.receiveMessage()}catch{}}sendSynthesisContext(e){this.setSynthesisContextSynthesisSection();let t=this.synthesisContext.toJSON();if(t)return e.send(new tn.SpeechConnectionMessage(Te.MessageType.Text,"synthesis.context",this.privSynthesisTurn.requestId,"application/json",t))}setSpeechConfigSynthesisSection(){}connectImpl(e=!1){if(this.privConnectionPromise!=null)return this.privConnectionPromise.then(r=>r.state()===Te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()):this.privConnectionPromise,()=>(this.privConnectionId=null,this.privConnectionPromise=null,this.connectImpl()));this.privAuthFetchEventId=Te.createNoDashGuid(),this.privConnectionId=Te.createNoDashGuid(),this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);let t=e?this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId):this.privAuthentication.fetch(this.privAuthFetchEventId);return this.privConnectionPromise=t.then(async r=>{this.privSynthesisTurn.onAuthCompleted(!1);let n=this.privConnectionFactory.create(this.privSynthesizerConfig,r,this.privConnectionId);n.events.attach(o=>{this.connectionEvents.onEvent(o)});let s=await n.open();return s.statusCode===200?(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.resolve(n)):s.statusCode===403&&!e?this.connectImpl(!0):(this.privSynthesisTurn.onConnectionEstablishCompleted(s.statusCode),Promise.reject(`Unable to contact server. StatusCode: ${s.statusCode},
|
|
23
|
+
${this.privSynthesizerConfig.parameters.getProperty(Je.PropertyId.SpeechServiceConnection_Url)} Reason: ${s.reason}`))},r=>{throw this.privSynthesisTurn.onAuthCompleted(!0),new Error(r)}),this.privConnectionPromise.catch(()=>{}),this.privConnectionPromise}sendSpeechServiceConfig(e,t){if(t)return e.send(new tn.SpeechConnectionMessage(Te.MessageType.Text,"speech.config",this.privSynthesisTurn.requestId,"application/json",t))}sendSsmlMessage(e,t,r){return e.send(new tn.SpeechConnectionMessage(Te.MessageType.Text,"ssml",r,"application/ssml+xml",t))}async fetchConnection(){return this.privConnectionConfigurationPromise!==void 0?this.privConnectionConfigurationPromise.then(e=>e.state()===Te.ConnectionState.Disconnected?(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection()):this.privConnectionConfigurationPromise,()=>(this.privConnectionId=null,this.privConnectionConfigurationPromise=void 0,this.fetchConnection())):(this.privConnectionConfigurationPromise=this.configureConnection(),await this.privConnectionConfigurationPromise)}async configureConnection(){let e=await this.connectImpl();return this.configConnectionOverride!==void 0?this.configConnectionOverride(e):(this.setSpeechConfigSynthesisSection(),await this.sendSpeechServiceConfig(e,this.privSynthesizerConfig.SpeechServiceConfig.serialize()),e)}onAvatarEvent(e){}onSynthesisStarted(e){}onSynthesizing(e){}onSynthesisCancelled(e){}onSynthesisCompleted(e){}onWordBoundary(e){}onVisemeReceived(e){}onBookmarkReached(e){}};Tu.SynthesisAdapterBase=Au;Au.telemetryDataEnabled=!0});var hR=p(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});Ou.AvatarSynthesisAdapter=void 0;var lR=f(),oO=C(),wf=class extends oO.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,void 0),this.privAvatarSynthesizer=n,this.privSynthesizer=n,this.privAvatarConfig=s}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(void 0)}setSpeechConfigSynthesisSection(){this.privSynthesizerConfig.synthesisVideoSection={format:{bitrate:this.privAvatarConfig.videoFormat?.bitrate,codec:this.privAvatarConfig.videoFormat?.codec,crop:{bottomRight:{x:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y},topLeft:{x:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,y:this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y}},resolution:{height:this.privAvatarConfig.videoFormat?.height,width:this.privAvatarConfig.videoFormat?.width}},protocol:{name:"WebRTC",webrtcConfig:{clientDescription:btoa(this.privSynthesizerConfig.parameters.getProperty(lR.PropertyId.TalkingAvatarService_WebRTC_SDP)),iceServers:this.privAvatarSynthesizer.iceServers}},talkingAvatar:{background:{color:this.privAvatarConfig.backgroundColor},character:this.privAvatarConfig.character,customized:this.privAvatarConfig.customized,style:this.privAvatarConfig.style}}}onAvatarEvent(e){if(this.privAvatarSynthesizer.avatarEventReceived){let t=new lR.AvatarEventArgs(e.Data.Offset,e.Data.Name);try{this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer,t)}catch{}}}};Ou.AvatarSynthesisAdapter=wf});var dR=p(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});ku.SpeechSynthesisAdapter=void 0;var wr=f(),aO=C(),bf=class extends aO.SynthesisAdapterBase{constructor(e,t,r,n,s){super(e,t,r,s),this.privSpeechSynthesizer=n,this.privSynthesizer=n}setSynthesisContextSynthesisSection(){this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer)}onSynthesisStarted(e){let t=new wr.SpeechSynthesisEventArgs(new wr.SpeechSynthesisResult(e,wr.ResultReason.SynthesizingAudioStarted));this.privSpeechSynthesizer.synthesisStarted&&this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer,t)}onSynthesizing(e){if(this.privSpeechSynthesizer.synthesizing)try{let t=this.privSynthesisTurn.audioOutputFormat.addHeader(e),r=new wr.SpeechSynthesisEventArgs(new wr.SpeechSynthesisResult(this.privSynthesisTurn.requestId,wr.ResultReason.SynthesizingAudio,t));this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer,r)}catch{}}onSynthesisCancelled(e){if(this.privSpeechSynthesizer.SynthesisCanceled){let t=new wr.SpeechSynthesisEventArgs(e);try{this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer,t)}catch{}}}onSynthesisCompleted(e){if(this.privSpeechSynthesizer.synthesisCompleted)try{this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer,new wr.SpeechSynthesisEventArgs(e))}catch{}}onWordBoundary(e){if(this.privSpeechSynthesizer.wordBoundary)try{this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer,e)}catch{}}onVisemeReceived(e){if(this.privSpeechSynthesizer.visemeReceived)try{this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer,e)}catch{}}onBookmarkReached(e){if(this.privSpeechSynthesizer.bookmarkReached)try{this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer,e)}catch{}}};ku.SpeechSynthesisAdapter=bf});var vR=p(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});Mu.SynthesisRestAdapter=void 0;var Af=ce(),Tf=f(),cO=Ze(),uO=Ie(),Of=class{constructor(e,t){let r=e.parameters.getProperty(Tf.PropertyId.SpeechServiceConnection_Endpoint,void 0);if(!r){let s=e.parameters.getProperty(Tf.PropertyId.SpeechServiceConnection_Region,"westus"),o=cO.ConnectionFactoryBase.getHostSuffix(s);r=e.parameters.getProperty(Tf.PropertyId.SpeechServiceConnection_Host,`https://${s}.tts.speech${o}`)}this.privUri=`${r}/cognitiveservices/voices/list`;let n=Af.RestConfigBase.requestOptions;this.privRestAdapter=new Af.RestMessageAdapter(n),this.privAuthentication=t}getVoicesList(e){return this.privRestAdapter.setHeaders(uO.HeaderNames.ConnectionId,e),this.privAuthentication.fetch(e).then(t=>(this.privRestAdapter.setHeaders(t.headerName,t.token),this.privRestAdapter.request(Af.RestRequestType.Get,this.privUri)))}};Mu.SynthesisRestAdapter=Of});var mR=p(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.SynthesizerConfig=pi.SynthesisServiceType=void 0;var fR=C(),gR;(function(i){i[i.Standard=0]="Standard",i[i.Custom=1]="Custom"})(gR=pi.SynthesisServiceType||(pi.SynthesisServiceType={}));var kf=class{constructor(e,t){this.privSynthesisServiceType=gR.Standard,this.avatarEnabled=!1,this.privSpeechServiceConfig=e||new fR.SpeechServiceConfig(new fR.Context(null)),this.privParameters=t}get parameters(){return this.privParameters}get synthesisServiceType(){return this.privSynthesisServiceType}set synthesisServiceType(e){this.privSynthesisServiceType=e}set synthesisVideoSection(e){this.privSpeechServiceConfig.Context.synthesis={video:e}}get SpeechServiceConfig(){return this.privSpeechServiceConfig}};pi.SynthesizerConfig=kf});var yR=p(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});Du.SynthesisContext=void 0;var Mf=f(),Df=class{constructor(){this.privContext={}}setSection(e,t){this.privContext[e]=t}set audioOutputFormat(e){this.privAudioOutputFormat=e}toJSON(){return JSON.stringify(this.privContext)}setSynthesisSection(e){let t=this.buildSynthesisContext(e);this.setSection("synthesis",t)}buildSynthesisContext(e){return{audio:{metadataOptions:{bookmarkEnabled:!!e?.bookmarkReached,punctuationBoundaryEnabled:e?.properties.getProperty(Mf.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary,!!e?.wordBoundary),sentenceBoundaryEnabled:e?.properties.getProperty(Mf.PropertyId.SpeechServiceResponse_RequestSentenceBoundary,!1),sessionEndEnabled:!0,visemeEnabled:!!e?.visemeReceived,wordBoundaryEnabled:e?.properties.getProperty(Mf.PropertyId.SpeechServiceResponse_RequestWordBoundary,!!e?.wordBoundary)},outputFormat:this.privAudioOutputFormat.requestAudioFormatString},language:{autoDetection:e?.autoDetectSourceLanguage}}}};Du.SynthesisContext=Df});var SR=p(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.SpeakerRecognitionConfig=void 0;var pO=C(),xf=class{constructor(e,t){this.privContext=e||new pO.Context(null),this.privParameters=t}get parameters(){return this.privParameters}get Context(){return this.privContext}};xu.SpeakerRecognitionConfig=xf});var PR=p(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});qu.SpeakerServiceRecognizer=void 0;var lO=ce(),Nu=P(),Se=f(),CR=C(),hO=ii(),Nf=class extends CR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privSpeakerRecognizer=s,this.privSpeakerAudioSource=r,this.recognizeSpeaker=o=>this.recognizeSpeakerOnce(o),this.sendPrePayloadJSONOverride=()=>this.noOp()}processTypeSpecificMessages(e){let t=!1,r=new Se.PropertyCollection;switch(e.messageType===Nu.MessageType.Text&&r.setProperty(Se.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.response":let s=JSON.parse(e.textBody),o;s.status.statusCode.toLowerCase()!=="success"?o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.Canceled,Se.CancellationErrorCode.ServiceError,s.status.reason):o=new Se.SpeakerRecognitionResult(s,Se.ResultReason.RecognizedSpeaker),this.privResultDeferral&&this.privResultDeferral.resolve(o),t=!0;break;default:break}let n=new Nu.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){if(new Se.PropertyCollection().setProperty(CR.CancellationErrorCodePropertyName,Se.CancellationErrorCode[n]),this.privResultDeferral){let a=new Se.SpeakerRecognitionResult({scenario:this.privSpeakerModel.scenario,status:{statusCode:s,reason:s}},Se.ResultReason.Canceled,n,s);try{this.privResultDeferral.resolve(a)}catch(c){this.privResultDeferral.reject(c)}}}async recognizeSpeakerOnce(e){this.privSpeakerModel=e,this.voiceProfileType=e.scenario,this.privResultDeferral||(this.privResultDeferral=new Nu.Deferred),this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(Se.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let t=this.connectImpl(),r=this.sendPreAudioMessages(this.extractSpeakerContext(e)),n=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),s=await this.privSpeakerAudioSource.format,o=await this.privSpeakerAudioSource.deviceInfo,a=new lO.ReplayableAudioNode(n,s.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(a,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:o};try{await t,await r}catch(l){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.ConnectionFailure,l)}let c=new Se.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,c),this.receiveMessage(),this.sendAudio(a).then(()=>{},l=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,Se.CancellationReason.Error,Se.CancellationErrorCode.RuntimeError,l)}),this.privResultDeferral.promise}async sendPreAudioMessages(e){let t=await this.fetchConnection();await this.sendSpeakerRecognition(t,e)}async sendSpeakerRecognition(e,t){let r=JSON.stringify(t);return e.send(new hO.SpeechConnectionMessage(Nu.MessageType.Text,"speaker.context",this.privRequestSession.requestId,"application/json; charset=utf-8",r))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}};qu.SpeakerServiceRecognizer=Nf});var ER=p(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});ju.VoiceServiceRecognizer=void 0;var dO=ce(),qt=P(),L=f(),RR=C(),qf=ii(),jf=class extends RR.ServiceRecognizerBase{constructor(e,t,r,n,s){super(e,t,r,n,s),this.privDeferralMap=new qt.DeferralMap,this.privSpeakerAudioSource=r,this.sendPrePayloadJSONOverride=()=>this.noOp()}set SpeakerAudioSource(e){this.privSpeakerAudioSource=e}processTypeSpecificMessages(e){let t=!1,r=new L.PropertyCollection;switch(e.messageType===qt.MessageType.Text&&r.setProperty(L.PropertyId.SpeechServiceResponse_JsonResult,e.textBody),e.path.toLowerCase()){case"speaker.profiles":let s=JSON.parse(e.textBody);switch(s.operation.toLowerCase()){case"create":this.handleCreateResponse(s,e.requestId);break;case"delete":case"reset":this.handleResultResponse(s,e.requestId);break;case"fetch":let u=JSON.parse(e.textBody);this.handleFetchResponse(u,e.requestId);break;default:break}t=!0;break;case"speaker.phrases":let o=JSON.parse(e.textBody);this.handlePhrasesResponse(o,e.requestId),t=!0;break;case"speaker.profile.enrollment":let a=JSON.parse(e.textBody),c=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(a.enrollment?a.enrollment.enrollmentStatus:a.status.statusCode),a.enrollment?JSON.stringify(a.enrollment):void 0,a.status.reason);this.privDeferralMap.getId(e.requestId)&&this.privDeferralMap.complete(e.requestId,c),this.privRequestSession.onSpeechEnded(),t=!0;break;default:break}let n=new qt.Deferred;return n.resolve(t),n.promise}cancelRecognition(e,t,r,n,s){new L.PropertyCollection().setProperty(RR.CancellationErrorCodePropertyName,L.CancellationErrorCode[n]);let a=new L.VoiceProfileEnrollmentResult(L.ResultReason.Canceled,s,s);this.privDeferralMap.getId(t)&&this.privDeferralMap.complete(t,a)}async createProfile(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new qt.Deferred;return await r,await this.sendCreateProfile(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async resetProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("reset",e.profileType,e)}async deleteProfile(e){return this.voiceProfileType=e.profileType.toString(),this.sendCommonRequest("delete",e.profileType,e)}async retrieveEnrollmentResult(e){return this.voiceProfileType=e.profileType.toString(),this.privExpectedProfileId=e.profileId,this.sendCommonRequest("fetch",e.profileType,e)}async getAllProfiles(e){return this.voiceProfileType=e.toString(),this.sendCommonRequest("fetch",e)}async getActivationPhrases(e,t){this.voiceProfileType=e.toString();let r=this.connectImpl();try{let n=new qt.Deferred;return await r,await this.sendPhrasesRequest(n,e,t),this.receiveMessage(),n.promise}catch(n){throw n}}async enrollProfile(e){this.voiceProfileType=e.profileType.toString();let t=new qt.Deferred;this.privRequestSession.startNewRecognition(),this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events),this.privRecognizerConfig.parameters.setProperty(L.PropertyId.Speech_SessionId,this.privRequestSession.sessionId);let r=this.connectImpl(),n=this.sendPreAudioMessages(e,t),s=await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId),o=await this.privSpeakerAudioSource.format,a=await this.privSpeakerAudioSource.deviceInfo,c=new dO.ReplayableAudioNode(s,o.avgBytesPerSec);await this.privRequestSession.onAudioSourceAttachCompleted(c,!1),this.privRecognizerConfig.SpeechServiceConfig.Context.audio={source:a};try{await r,await n}catch(h){this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.ConnectionFailure,h)}let u=new L.SessionEventArgs(this.privRequestSession.sessionId);return this.privRecognizer.sessionStarted&&this.privRecognizer.sessionStarted(this.privRecognizer,u),this.receiveMessage(),this.sendAudio(c).then(()=>{},h=>{this.cancelRecognition(this.privRequestSession.sessionId,this.privRequestSession.requestId,L.CancellationReason.Error,L.CancellationErrorCode.RuntimeError,h)}),t.promise}async sendPreAudioMessages(e,t){let r=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,t),await this.sendBaseRequest(r,"enroll",this.scenarioFrom(e.profileType),e)}async sendPhrasesRequest(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=this.scenarioFrom(t),o={locale:r,scenario:s};return n.send(new qf.SpeechConnectionMessage(qt.MessageType.Text,"speaker.profile.phrases",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCreateProfile(e,t,r){let n=await this.fetchConnection();this.privRequestSession.onSpeechContext(),this.privDeferralMap.add(this.privRequestSession.requestId,e);let s=t===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":t===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification",o={locale:r,number:"1",scenario:s};return n.send(new qf.SpeechConnectionMessage(qt.MessageType.Text,"speaker.profile.create",this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(o)))}async sendCommonRequest(e,t,r=void 0){let n=this.connectImpl();try{let s=new qt.Deferred;this.privRequestSession.onSpeechContext(),await n;let o=await this.fetchConnection();return this.privDeferralMap.add(this.privRequestSession.requestId,s),await this.sendBaseRequest(o,e,this.scenarioFrom(t),r),this.receiveMessage(),s.promise}catch(s){throw s}}async sendBaseRequest(e,t,r,n){let s={scenario:r};return n?s.profileIds=[n.profileId]:s.maxPageSize=-1,e.send(new qf.SpeechConnectionMessage(qt.MessageType.Text,`speaker.profile.${t}`,this.privRequestSession.requestId,"application/json; charset=utf-8",JSON.stringify(s)))}extractSpeakerContext(e){return{features:{interimResult:"enabled",progressiveDetection:"disabled"},profileIds:e.profileIds,scenario:e.scenario}}handlePhrasesResponse(e,t){if(this.privDeferralMap.getId(t))if(e.status.statusCode.toLowerCase()!=="success"){let r=L.ResultReason.Canceled,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,[]);this.privDeferralMap.complete(t,n)}else if(e.phrases&&e.phrases.length>0){let r=L.ResultReason.EnrollingVoiceProfile,n=new L.VoiceProfilePhraseResult(r,e.status.statusCode,e.passPhraseType,e.phrases);this.privDeferralMap.complete(t,n)}else throw new Error("Voice Profile get activation phrases failed, no phrases received");else throw new Error(`Voice Profile get activation phrases request for requestID ${t} not found`)}handleCreateResponse(e,t){if(e.profiles&&e.profiles.length>0)if(this.privDeferralMap.getId(t)){let r=e.profiles.map(n=>n.profileId);this.privDeferralMap.complete(t,r)}else throw new Error(`Voice Profile create request for requestID ${t} not found`);else throw new Error("Voice Profile create failed, no profile id received")}handleResultResponse(e,t){if(this.privDeferralMap.getId(t)){let r=e.operation.toLowerCase()==="delete"?L.ResultReason.DeletedVoiceProfile:L.ResultReason.ResetVoiceProfile,n=e.status.statusCode.toLowerCase()==="success"?r:L.ResultReason.Canceled,s=new L.VoiceProfileResult(n,`statusCode: ${e.status.statusCode}, errorDetails: ${e.status.reason}`);this.privDeferralMap.complete(t,s)}else throw new Error(`Voice Profile create request for requestID ${t} not found`)}handleFetchResponse(e,t){if(this.privDeferralMap.getId(t)&&e.profiles[0]){if(this.privExpectedProfileId&&e.profiles.length===1&&e.profiles[0].profileId===this.privExpectedProfileId){this.privExpectedProfileId=void 0;let r=e.profiles[0],n=new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(r.enrollmentStatus),JSON.stringify(r),e.status.reason);this.privDeferralMap.complete(t,n)}else if(e.profiles.length>0){let r=e.profiles,n=[];for(let s of r)n.push(new L.VoiceProfileEnrollmentResult(this.enrollmentReasonFrom(s.enrollmentStatus),JSON.stringify(s),e.status.reason));this.privDeferralMap.complete(t,n)}}else throw new Error(`Voice Profile fetch request for requestID ${t} not found`)}enrollmentReasonFrom(e){switch(e.toLowerCase()){case"enrolled":return L.ResultReason.EnrolledVoiceProfile;case"invalidlocale":case"invalidphrase":case"invalidaudioformat":case"invalidscenario":case"invalidprofilecount":case"invalidoperation":case"audiotooshort":case"audiotoolong":case"toomanyenrollments":case"storageconflict":case"profilenotfound":case"incompatibleprofiles":case"incompleteenrollment":return L.ResultReason.Canceled;default:return L.ResultReason.EnrollingVoiceProfile}}scenarioFrom(e){return e===L.VoiceProfileType.TextIndependentIdentification?"TextIndependentIdentification":e===L.VoiceProfileType.TextIndependentVerification?"TextIndependentVerification":"TextDependentVerification"}};ju.VoiceServiceRecognizer=jf});var _R=p(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.type=pe.connectivity=pe.Device=pe.OS=pe.System=pe.Context=pe.SpeechServiceConfig=void 0;var zf=class{constructor(e){this.context=e}serialize(){return JSON.stringify(this,(e,t)=>{if(t&&typeof t=="object"&&!Array.isArray(t)){let r={};for(let n in t)Object.hasOwnProperty.call(t,n)&&(r[n&&n.charAt(0).toLowerCase()+n.substring(1)]=t[n]);return r}return t})}get Context(){return this.context}get Recognition(){return this.recognition}set Recognition(e){this.recognition=e.toLowerCase()}};pe.SpeechServiceConfig=zf;var Lf=class{constructor(e){this.system=new zu,this.os=e}};pe.Context=Lf;var zu=class{constructor(){let e="1.36.0";this.name="SpeechSDK",this.version=e,this.build="JavaScript",this.lang="JavaScript"}};pe.System=zu;var Bf=class{constructor(e,t,r){this.platform=e,this.name=t,this.version=r}};pe.OS=Bf;var Ff=class{constructor(e,t,r){this.manufacturer=e,this.model=t,this.version=r}};pe.Device=Ff;var vO;(function(i){i.Bluetooth="Bluetooth",i.Wired="Wired",i.WiFi="WiFi",i.Cellular="Cellular",i.InBuilt="InBuilt",i.Unknown="Unknown"})(vO=pe.connectivity||(pe.connectivity={}));var fO;(function(i){i.Phone="Phone",i.Speaker="Speaker",i.Car="Car",i.Headset="Headset",i.Thermostat="Thermostat",i.Microphones="Microphones",i.Deskphone="Deskphone",i.RemoteControl="RemoteControl",i.Unknown="Unknown",i.File="File",i.Stream="Stream"})(fO=pe.type||(pe.type={}))});var C=p(m=>{"use strict";var gO=m&&m.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),R=m&&m.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&gO(e,i,t)};Object.defineProperty(m,"__esModule",{value:!0});m.AutoDetectSourceLanguagesOpenRangeOptionName=m.ForceDictationPropertyName=m.ServicePropertiesPropertyName=m.CancellationErrorCodePropertyName=m.OutputFormatPropertyName=void 0;R(Tm(),m);R(Dm(),m);R(Xs(),m);R(Nm(),m);R(jm(),m);R(MC(),m);R(qC(),m);R(Ac(),m);R(zC(),m);R(LC(),m);R(FC(),m);R(UC(),m);R(HC(),m);R($C(),m);R(ZC(),m);R(rP(),m);R(oP(),m);R(Fd(),m);R(aP(),m);R(cP(),m);R(pP(),m);R(lP(),m);R(hP(),m);R(vP(),m);R(fP(),m);R(gP(),m);R(mP(),m);R(yP(),m);R(SP(),m);R(PP(),m);R(RP(),m);R(EP(),m);R(_P(),m);R(wP(),m);R(bP(),m);R(TP(),m);R(MP(),m);R(DP(),m);R(xP(),m);R(qP(),m);R(BP(),m);R(FP(),m);R(oR(),m);R(Cf(),m);R(uR(),m);R(pR(),m);var mO=hR();Object.defineProperty(m,"AvatarSynthesisAdapter",{enumerable:!0,get:function(){return mO.AvatarSynthesisAdapter}});var yO=dR();Object.defineProperty(m,"SpeechSynthesisAdapter",{enumerable:!0,get:function(){return yO.SpeechSynthesisAdapter}});R(vR(),m);R(mR(),m);R(yR(),m);R(SR(),m);R(PR(),m);R(ER(),m);R(_R(),m);m.OutputFormatPropertyName="OutputFormat";m.CancellationErrorCodePropertyName="CancellationErrorCode";m.ServicePropertiesPropertyName="ServiceProperties";m.ForceDictationPropertyName="ForceDictation";m.AutoDetectSourceLanguagesOpenRangeOptionName="OpenRange"});var Vf=p(li=>{"use strict";var SO=li&&li.__createBinding||(Object.create?function(i,e,t,r){r===void 0&&(r=t),Object.defineProperty(i,r,{enumerable:!0,get:function(){return e[t]}})}:function(i,e,t,r){r===void 0&&(r=t),i[r]=e[t]}),CO=li&&li.__exportStar||function(i,e){for(var t in i)t!=="default"&&!e.hasOwnProperty(t)&&SO(e,i,t)};Object.defineProperty(li,"__esModule",{value:!0});var PO=C();new PO.AgentConfig;CO(f(),li)});var xR=Xu(Vf());var xx=new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}))*)+$","u");var Uf;function RO(i){return{lang:i?.lang??Uf?.lang,message:i?.message,abortEarly:i?.abortEarly??Uf?.abortEarly,abortPipeEarly:i?.abortPipeEarly??Uf?.abortPipeEarly}}var EO;function _O(i){return EO?.get(i)}var IO;function wO(i){return IO?.get(i)}var bO;function AO(i,e){return bO?.get(i)?.get(e)}function rn(i){let e=typeof i;return e==="string"?`"${i}"`:e==="number"||e==="bigint"||e==="boolean"?`${i}`:e==="object"||e==="function"?(i&&Object.getPrototypeOf(i)?.constructor?.name)??"null":e}function Be(i,e,t,r,n){let s=n&&"input"in n?n.input:t.value,o=n?.expected??i.expects??null,a=n?.received??rn(s),c={kind:i.kind,type:i.type,input:s,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:i.requirement,path:n?.path,issues:n?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},u=i.kind==="schema",l=n?.message??i.message??AO(i.reference,c.lang)??(u?wO(c.lang):null)??r.message??_O(c.lang);l&&(c.message=typeof l=="function"?l(c):l),u&&(t.typed=!1),t.issues?t.issues.push(c):t.issues=[c]}function Hf(i,e){let t=[...new Set(i)];return t.length>1?`(${t.join(` ${e} `)})`:t[0]??"never"}var TO=class extends Error{issues;constructor(i){super(i[0].message),this.name="ValiError",this.issues=i}};function Kf(i,e){return{kind:"validation",type:"max_value",reference:Kf,async:!1,expects:`<=${i instanceof Date?i.toJSON():rn(i)}`,requirement:i,message:e,_run(t,r){return t.typed&&t.value>this.requirement&&Be(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():rn(t.value)}),t}}}function Jf(i,e){return{kind:"validation",type:"min_value",reference:Jf,async:!1,expects:`>=${i instanceof Date?i.toJSON():rn(i)}`,requirement:i,message:e,_run(t,r){return t.typed&&t.value<this.requirement&&Be(this,"value",t,r,{received:t.value instanceof Date?t.value.toJSON():rn(t.value)}),t}}}function Gf(){return{kind:"transformation",type:"readonly",reference:Gf,async:!1,_run(i){return i}}}function $f(i){return{kind:"transformation",type:"transform",reference:$f,async:!1,operation:i,_run(e){return e.value=this.operation(e.value),e}}}function OO(i,e,t){return typeof i.default=="function"?i.default(e,t):i.default}function Qf(i,e){return{kind:"schema",type:"array",reference:Qf,expects:"Array",async:!1,item:i,message:e,_run(t,r){let n=t.value;if(Array.isArray(n)){t.typed=!0,t.value=[];for(let s=0;s<n.length;s++){let o=n[s],a=this.item._run({typed:!1,value:o},r);if(a.issues){let c={type:"array",origin:"value",input:n,key:s,value:o};for(let u of a.issues)u.path?u.path.unshift(c):u.path=[c],t.issues?.push(u);if(t.issues||(t.issues=a.issues),r.abortEarly){t.typed=!1;break}}a.typed||(t.typed=!1),t.value.push(a.value)}}else Be(this,"type",t,r);return t}}}function br(i){return{kind:"schema",type:"boolean",reference:br,expects:"boolean",async:!1,message:i,_run(e,t){return typeof e.value=="boolean"?e.typed=!0:Be(this,"type",e,t),e}}}function Xf(i,e){let t=Object.entries(i).filter(([r])=>isNaN(+r)).map(([,r])=>r);return{kind:"schema",type:"enum",reference:Xf,expects:Hf(t.map(rn),"|"),async:!1,enum:i,options:t,message:e,_run(r,n){return this.options.includes(r.value)?r.typed=!0:Be(this,"type",r,n),r}}}function Zf(i){return{kind:"schema",type:"function",reference:Zf,expects:"Function",async:!1,message:i,_run(e,t){return typeof e.value=="function"?e.typed=!0:Be(this,"type",e,t),e}}}function Wf(i,e){if(typeof i==typeof e){if(i===e||i instanceof Date&&e instanceof Date&&+i==+e)return{value:i};if(i&&e&&i.constructor===Object&&e.constructor===Object){for(let t in e)if(t in i){let r=Wf(i[t],e[t]);if(r.issue)return r;i[t]=r.value}else i[t]=e[t];return{value:i}}if(Array.isArray(i)&&Array.isArray(e)&&i.length===e.length){for(let t=0;t<i.length;t++){let r=Wf(i[t],e[t]);if(r.issue)return r;i[t]=r.value}return{value:i}}}return{issue:!0}}function Yf(i,e){return{kind:"schema",type:"intersect",reference:Yf,expects:Hf(i.map(t=>t.expects),"&"),async:!1,options:i,message:e,_run(t,r){if(this.options.length){let n=t.value,s;t.typed=!0;for(let o of this.options){let a=o._run({typed:!1,value:n},r);if(a.issues&&(t.issues?t.issues.push(...a.issues):t.issues=a.issues,r.abortEarly)){t.typed=!1;break}a.typed||(t.typed=!1),t.typed&&(s?s.push(a.value):s=[a.value])}if(t.typed){t.value=s[0];for(let o=1;o<s.length;o++){let a=Wf(t.value,s[o]);if(a.issue){Be(this,"type",t,r,{received:"unknown"});break}t.value=a.value}}}else Be(this,"type",t,r);return t}}}function eg(i){return{kind:"schema",type:"number",reference:eg,expects:"number",async:!1,message:i,_run(e,t){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Be(this,"type",e,t),e}}}function nn(i,e){return{kind:"schema",type:"object",reference:nn,expects:"Object",async:!1,entries:i,message:e,_run(t,r){let n=t.value;if(n&&typeof n=="object"){t.typed=!0,t.value={};for(let s in this.entries){let o=n[s],a=this.entries[s]._run({typed:!1,value:o},r);if(a.issues){let c={type:"object",origin:"value",input:n,key:s,value:o};for(let u of a.issues)u.path?u.path.unshift(c):u.path=[c],t.issues?.push(u);if(t.issues||(t.issues=a.issues),r.abortEarly){t.typed=!1;break}}a.typed||(t.typed=!1),(a.value!==void 0||s in n)&&(t.value[s]=a.value)}}else Be(this,"type",t,r);return t}}}function Y(i,...e){let t={kind:"schema",type:"optional",reference:Y,expects:`(${i.expects} | undefined)`,async:!1,wrapped:i,_run(r,n){return r.value===void 0&&("default"in this&&(r.value=OO(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped._run(r,n)}};return 0 in e&&(t.default=e[0]),t}function at(i){return{kind:"schema",type:"string",reference:at,expects:"string",async:!1,message:i,_run(e,t){return typeof e.value=="string"?e.typed=!0:Be(this,"type",e,t),e}}}function St(i){return{kind:"schema",type:"undefined",reference:St,expects:"undefined",async:!1,message:i,_run(e,t){return e.value===void 0?e.typed=!0:Be(this,"type",e,t),e}}}function IR(i){let e;if(i)for(let t of i)e?e.push(...t.issues):e=t.issues;return e}function hi(i,e){return{kind:"schema",type:"union",reference:hi,expects:Hf(i.map(t=>t.expects),"|"),async:!1,options:i,message:e,_run(t,r){let n,s,o;for(let a of this.options){let c=a._run({typed:!1,value:t.value},r);if(c.typed)if(c.issues)s?s.push(c):s=[c];else{n=c;break}else o?o.push(c):o=[c]}if(n)return n;if(s){if(s.length===1)return s[0];Be(this,"type",t,r,{issues:IR(s)}),t.typed=!0}else{if(o?.length===1)return o[0];Be(this,"type",t,r,{issues:IR(o)})}return t}}}function Fe(i,e,t){let r=i._run({typed:!1,value:e},RO(t));if(r.issues)throw new TO(r.issues);return r.value}function sn(...i){return{...i[0],pipe:i,_run(e,t){for(let r of i)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r._run(e,t))}return e}}}function kO(i){return typeof i=="function"}function tg(i){return kO(i)?i():i}var jt=Xu(Vf()),Ar={AudioConfig:jt.AudioConfig,OutputFormat:jt.OutputFormat,ResultReason:jt.ResultReason,SpeechConfig:jt.SpeechConfig,SpeechRecognizer:jt.SpeechRecognizer};var MO=sn(Yf([hi([nn({authorizationToken:at(),subscriptionKey:Y(St('"subscriptionKey" must be unset when "authorizationToken" is set.'))}),nn({authorizationToken:Y(St('"authorizationToken" must be unset when "subscriptionKey" is set.')),subscriptionKey:at()})],'The object must either have either "authorizationToken" or "subscriptionKey" set, but not both.'),hi([nn({customVoiceHostname:Y(St('"customVoiceHostname" must be unest when "region" is set.')),region:at(),speechRecognitionHostname:Y(St('"speechRecognitionHostname" must be unest when "region" is set.')),speechSynthesisHostname:Y(St('"speechSynthesisHostname" must be unest when "region" is set.'))}),nn({customVoiceHostname:Y(hi([at(),St()])),region:Y(St('"region" must be unset when "*Hostname" is set.')),speechRecognitionHostname:at(),speechSynthesisHostname:at()})],'The object must either have either "region" or "*Hostname" set, but not both.')]),Gf()),wR=MO;var DO=Y(br()),bR=DO;var xO=Y(sn(eg(),Jf(1),Kf(6e4))),AR=xO;var NO=Y(br(),!1),TR=NO;var qO=sn(Y(Qf(at()),[]),$f(i=>Object.isFrozen(i)?i:Object.freeze([...i]))),Lu=qO;var jO=Y(at()),OR=jO;var zO=Y(Xf({display:"display",itn:"itn",lexical:"lexical",maskeditn:"maskeditn"}),"display"),Bu=zO;var{AudioConfig:LO}=Ar,kR=!0;function ps(i){let{audioConfig:e,credentials:t,enableTelemetry:r,initialSilenceTimeout:n,looseEvent:s,referenceGrammars:o,speechRecognitionEndpointId:a,textNormalization:c}=i,{looseEvents:u}=i;return typeof s<"u"&&(console.warn('web-speech-cognitive-services: The option "looseEvent" should be named as "looseEvents".'),u=s),Object.freeze({audioConfig:e||LO.fromDefaultMicrophoneInput(),enableTelemetry:Fe(bR,r),fetchCredentials:async()=>{let l=Fe(wR,await tg(t));return kR&&l.subscriptionKey&&(console.warn("web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead."),kR=!1),l},initialSilenceTimeout:Fe(AR,n),looseEvents:Fe(TR,u),referenceGrammars:Fe(Lu,o),speechRecognitionEndpointId:Fe(OR,a),textNormalization:Fe(Bu,c)})}function ls(){let i={};return i.promise=new Promise((e,t)=>{i.resolve=e,i.reject=t}),i}function MR(){let i,e=[];return{push:n=>{if(i){let{resolve:s}=i;i=null,s(n)}else e.push(n)},shift:()=>e.length?Promise.resolve(e.shift()):(i||(i=ls())).promise}}var on=class{constructor({confidence:e,transcript:t}){this.#t=e,this.#e=t}#t;#e;get confidence(){return this.#t}get transcript(){return this.#e}};var di=class{constructor(e){if(!e)throw new Error("array must be set.");this.#t=e;for(let t in e)Object.defineProperty(this,t,{enumerable:!0,get(){return e[t]}})}#t;[Symbol.iterator](){return this.#t[Symbol.iterator]()}get length(){return this.#t.length}};var vi=class extends di{constructor(e){super(e.results),this.#t=e.isFinal}#t;get isFinal(){return this.#t}};var{ResultReason:{RecognizingSpeech:BO,RecognizedSpeech:rg}}=Ar;function ig(i,e){let{maxAlternatives:t=1/0,textNormalization:r="display"}=e||{},n=typeof i.json=="string"?JSON.parse(i.json):i.json;return i.reason===BO||i.reason===rg&&!n.NBest?new vi({isFinal:i.reason===rg,results:[new on({confidence:.5,transcript:i.text})]}):i.reason===rg?new vi({isFinal:!0,results:(n.NBest||[]).slice(0,t).map(({Confidence:s,Display:o,ITN:a,Lexical:c,MaskedITN:u})=>new on({confidence:s,transcript:r==="itn"?a:r==="lexical"?c:r==="maskeditn"?u:o}))}):new vi({isFinal:!1,results:[]})}function an(i,e=void 0){return(...t)=>new Promise((r,n)=>i.apply(e,[...t,r,n]))}var hs=class{constructor(e){this.#t=e,this.#e={}}#t;#e;getProperty(e){return this.#e[e]}setProperty(e,t){let r=this.#e[e];r&&this.#t.removeEventListener(e,r),t&&this.#t.addEventListener(e,t),this.#e[e]=t}};var DR=Xu(gp());function ng(i){let e=Array.from(new Int16Array(i));return e.reduce((t,r)=>t+Math.abs(r),0)/e.length}function sg(i){let e=i,t=e.attach,r=e.attach.bind(e),n=!1,s=!1;return e.attach=async()=>{let o=await r("");return{...o,read:async()=>{let a=await o.read();return!n&&ng(a.buffer)>150&&(e.events.onEvent(new DR.AudioSourceEvent("FirstAudibleChunk","")),n=!0),s?{buffer:new ArrayBuffer(0),isEnd:!0,timeReceived:Date.now()}:a}}},{audioConfig:i,pause:()=>{s=!0},unprepare:()=>{e.attach=t}}}function Fu({duration:i,errorDetails:e,json:t,offset:r,properties:n,reason:s,resultId:o,text:a}){return Object.freeze({duration:i,errorDetails:e,json:t&&JSON.parse(t),offset:r,properties:n,reason:s,resultId:o,text:a})}var fi=class{constructor(){this.#t=[]}addFromString(){throw new Error("JSGF is not supported")}addFromURI(){throw new Error("JSGF is not supported")}item(){throw new Error("JSGF is not supported")}get length(){throw new Error("JSGF is not supported")}#t;get phrases(){return this.#t}set phrases(e){if(Array.isArray(e))this.#t=Object.freeze([...e]);else if(typeof e=="string")this.#t=Object.freeze([e]);else throw new Error("The provided value is not an array or of type 'string'")}};var zt=class extends Event{constructor(e,{error:t,message:r}){super(e),this.#t=t,this.#e=r}#t;#e;get error(){return this.#t}get message(){return this.#e}get type(){return"error"}};var Lt=class extends di{constructor(e){super(e)}};var U=class extends Event{constructor(e,{data:t,resultIndex:r,results:n}={}){super(e),this.#t=t,this.#e=r,this.#r=n||new Lt([])}#t;#e;#r;get data(){return this.#t}get resultIndex(){return this.#e}get results(){return this.#r}get type(){return super.type}};var{ResultReason:FO,SpeechRecognizer:VO}=Ar,UO=hi([br(),St()]);function Tr({createRecognizer:i,enableTelemetry:e,looseEvents:t,referenceGrammars:r,textNormalization:n}){i=Fe(Zf(),i),e=Fe(UO,e),t=Fe(br(),t),r=Fe(Lu,r),n=Fe(Bu,n),typeof e<"u"&&VO.enableTelemetry(e);class s extends EventTarget{#t=!1;#e=new hs(this);#r=new fi;#i=!1;#n=typeof window<"u"?window.document.documentElement.getAttribute("lang")||window.navigator.language:"en-US";#s=1;emitCognitiveServices(a,c){this.dispatchEvent(new U("cognitiveservices",{data:{...c,type:a}}))}get continuous(){return this.#t}set continuous(a){this.#t=a}get grammars(){return this.#r}set grammars(a){if(a instanceof fi)this.#r=a;else throw new Error("The provided value is not of type 'SpeechGrammarList'")}get interimResults(){return this.#i}set interimResults(a){this.#i=a}get maxAlternatives(){return this.#s}set maxAlternatives(a){this.#s=a}get lang(){return this.#n}set lang(a){this.#n=a}get onaudioend(){return this.#e.getProperty("audioend")}set onaudioend(a){this.#e.setProperty("audioend",a)}get onaudiostart(){return this.#e.getProperty("audiostart")}set onaudiostart(a){this.#e.setProperty("audiostart",a)}get oncognitiveservices(){return this.#e.getProperty("cognitiveservices")}set oncognitiveservices(a){this.#e.setProperty("cognitiveservices",a)}get onend(){return this.#e.getProperty("end")}set onend(a){this.#e.setProperty("end",a)}get onerror(){return this.#e.getProperty("error")}set onerror(a){this.#e.setProperty("error",a)}get onresult(){return this.#e.getProperty("result")}set onresult(a){this.#e.setProperty("result",a)}get onsoundend(){return this.#e.getProperty("soundend")}set onsoundend(a){this.#e.setProperty("soundend",a)}get onsoundstart(){return this.#e.getProperty("soundstart")}set onsoundstart(a){this.#e.setProperty("soundstart",a)}get onspeechend(){return this.#e.getProperty("speechend")}set onspeechend(a){this.#e.setProperty("speechend",a)}get onspeechstart(){return this.#e.getProperty("speechstart")}set onspeechstart(a){this.#e.setProperty("speechstart",a)}get onstart(){return this.#e.getProperty("start")}set onstart(a){this.#e.setProperty("start",a)}abort;stop;start(){this._startOnce().catch(a=>{this.dispatchEvent(new zt("error",{error:a,message:a&&(a.stack||a.message)}))})}async _startOnce(){let a=await i(this.lang),{pause:c,unprepare:u}=sg(a.audioConfig);try{let l=MR(),h,d,g,{detach:M}=a.audioConfig.events.attach(F=>{let{name:K}=F;K==="AudioSourceReadyEvent"?l.push({audioSourceReady:{}}):K==="AudioSourceOffEvent"?l.push({audioSourceOff:{}}):K==="FirstAudibleChunk"&&l.push({firstAudibleChunk:{}})});a.canceled=(F,{errorDetails:K,offset:ct,reason:kr,sessionId:Ju})=>{l.push({canceled:{errorDetails:K,offset:ct,reason:kr,sessionId:Ju}})},a.recognized=(F,{offset:K,result:ct,sessionId:kr})=>{l.push({recognized:{offset:K,result:Fu(ct),sessionId:kr}})},a.recognizing=(F,{offset:K,result:ct,sessionId:kr})=>{l.push({recognizing:{offset:K,result:Fu(ct),sessionId:kr}})},a.sessionStarted=(F,{sessionId:K})=>{l.push({sessionStarted:{sessionId:K}})},a.sessionStopped=(F,{sessionId:K})=>{l.push({sessionStopped:{sessionId:K}})},a.speechStartDetected=(F,{offset:K,sessionId:ct})=>{l.push({speechStartDetected:{offset:K,sessionId:ct}})},a.speechEndDetected=(F,{sessionId:K})=>{l.push({speechEndDetected:{sessionId:K}})};let{phrases:D}=this.grammars,{dynamicGrammar:oe}=a.privReco;r&&r.length&&oe.addReferenceGrammar([...r]),D&&D.length&&oe.addPhrase([...D]),await an(a.startContinuousRecognitionAsync,a)(),typeof a.stopContinuousRecognitionAsync=="function"?(this.abort=()=>l.push({abort:{}}),this.stop=()=>l.push({stop:{}})):this.abort=this.stop=void 0;let Q,ee,Ce=[];for(let F=0;!g||Q;F++){let K=await l.shift(),{abort:ct,audioSourceOff:kr,audioSourceReady:Ju,canceled:Eg,firstAudibleChunk:fE,recognized:gi,recognizing:Gu,stop:gE}=K;Object.keys(K).forEach(hn=>this.emitCognitiveServices(hn,K[hn]));let $u=Eg&&Eg.errorDetails;if(/Permission\sdenied/u.test($u||"")){ee=new zt("error",{error:"not-allowed"});break}if(F||this.dispatchEvent(new U("start")),$u){/1006/u.test($u)?(Q||(this.dispatchEvent(new U("audiostart")),this.dispatchEvent(new U("audioend"))),ee=new zt("error",{error:"network"})):ee=new zt("error",{error:"unknown"});break}else if(ct||gE)ct?(ee=new zt("error",{error:"aborted"}),g="abort"):(c(),g="stop"),ct&&a.stopContinuousRecognitionAsync&&await an(a.stopContinuousRecognitionAsync,a)();else if(Ju)this.dispatchEvent(new U("audiostart")),Q=!0;else if(fE)this.dispatchEvent(new U("soundstart")),h=!0;else if(kr){d&&this.dispatchEvent(new U("speechend")),h&&this.dispatchEvent(new U("soundend")),Q&&this.dispatchEvent(new U("audioend")),Q=h=d=!1;break}else if(g!=="abort"){if(gi&&gi.result&&gi.result.reason===FO.NoMatch){if(!this.continuous||g==="stop"){ee=new U("result",{results:new Lt(Ce)}),a.stopContinuousRecognitionAsync&&await an(a.stopContinuousRecognitionAsync,a)();break}}else if(gi||Gu)if(Q||(this.dispatchEvent(new U("audiostart")),Q=!0),h||(this.dispatchEvent(new U("soundstart")),h=!0),d||(this.dispatchEvent(new U("speechstart")),d=!0),gi){let hn=ig(gi.result,{maxAlternatives:this.maxAlternatives,textNormalization:n}),Qu=!!hn[0]?.transcript;Qu&&(Ce=[...Ce,hn],this.continuous&&this.dispatchEvent(new U("result",{results:new Lt(Ce)}))),this.continuous&&Qu?ee=void 0:ee=new U("result",{results:new Lt(Ce)}),(!this.continuous||g==="stop")&&a.stopContinuousRecognitionAsync&&await an(a.stopContinuousRecognitionAsync,a)(),t&&ee&&Qu&&(this.dispatchEvent(ee),ee=void 0)}else Gu&&this.interimResults&&this.dispatchEvent(new U("result",{results:new Lt([...Ce,ig(Gu.result,{maxAlternatives:this.maxAlternatives,textNormalization:n})])}))}}d&&this.dispatchEvent(new U("speechend")),h&&this.dispatchEvent(new U("soundend")),Q&&this.dispatchEvent(new U("audioend")),ee&&(ee.type==="result"&&!ee.results.length&&(ee=new zt("error",{error:"no-speech"})),this.dispatchEvent(ee)),this.dispatchEvent(new U("end")),M()}catch(l){throw console.error(l),l}finally{u(),a.dispose(!1)}}}return{SpeechGrammarList:fi,SpeechRecognition:s,SpeechRecognitionEvent:U}}var{OutputFormat:WO,SpeechConfig:Vu,SpeechRecognizer:HO}=Ar;function ds(i){let{audioConfig:e,enableTelemetry:t,fetchCredentials:r,initialSilenceTimeout:n,looseEvents:s,referenceGrammars:o,speechRecognitionEndpointId:a,textNormalization:c}=ps(i);if(!e&&(!window.navigator.mediaDevices||!window.navigator.mediaDevices.getUserMedia))throw new Error("web-speech-cognitive-services: This browser does not support Media Capture and Streams API and it will not work with Cognitive Services Speech Services.");return Tr({createRecognizer:async l=>{let h=await r(),d;if(typeof h.speechRecognitionHostname<"u"){let g=new URL("wss://localhost:443");g.hostname=h.speechRecognitionHostname,h.authorizationToken?(d=Vu.fromHost(g),d.authorizationToken=h.authorizationToken):d=Vu.fromHost(g,h.subscriptionKey)}else d=typeof h.authorizationToken<"u"?Vu.fromAuthorizationToken(h.authorizationToken,h.region):Vu.fromSubscription(h.subscriptionKey,h.region);return a&&(d.endpointId=a),d.outputFormat=WO.Detailed,d.speechRecognitionLanguage=l||"en-US",typeof n=="number"&&d.setProperty(xR.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,""+n),new HO(d,e)},enableTelemetry:t,looseEvents:s,referenceGrammars:o,textNormalization:c})}function pg(i,e,...t){if(!i)throw new TypeError(HR(e,t))}function HR(i,e){let t=0;return i.replace(/%[os]/gu,()=>KR(e[t++]))}function KR(i){return typeof i!="object"||i===null?String(i):Object.prototype.toString.call(i)}var NR;function KO(i){try{let e=i instanceof Error?i:new Error(KR(i));if(NR){NR(e);return}if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:e,message:e.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)}catch{}}var Ct=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,qR;var Pt=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(qR){qR({...this,args:e});return}let r=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
|
|
24
|
+
`);console.warn(this.message,...e,r)}catch{}}},JO=new Pt("W01","Unable to initialize event under dispatching."),GO=new Pt("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),$O=new Pt("W03","Assigning any truthy value to 'returnValue' property has no effect."),QO=new Pt("W04","Unable to preventDefault on non-cancelable events."),XO=new Pt("W05","Unable to preventDefault inside passive event listener invocation."),ZO=new Pt("W06","An event listener wasn't added because it has been added already: %o, %o"),og=new Pt("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),jR=new Pt("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),YO=new Pt("W09","Event attribute handler must be a function: %o"),Ge=class{static get NONE(){return zR}static get CAPTURING_PHASE(){return LR}static get AT_TARGET(){return BR}static get BUBBLING_PHASE(){return FR}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};ug.set(this,{type:String(e),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return se(this).type}get target(){return se(this).target}get srcElement(){return se(this).target}get currentTarget(){return se(this).currentTarget}composedPath(){let e=se(this).currentTarget;return e?[e]:[]}get NONE(){return zR}get CAPTURING_PHASE(){return LR}get AT_TARGET(){return BR}get BUBBLING_PHASE(){return FR}get eventPhase(){return se(this).dispatchFlag?2:0}stopPropagation(){se(this).stopPropagationFlag=!0}get cancelBubble(){return se(this).stopPropagationFlag}set cancelBubble(e){e?se(this).stopPropagationFlag=!0:GO.warn()}stopImmediatePropagation(){let e=se(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return se(this).bubbles}get cancelable(){return se(this).cancelable}get returnValue(){return!se(this).canceledFlag}set returnValue(e){e?$O.warn():VR(se(this))}preventDefault(){VR(se(this))}get defaultPrevented(){return se(this).canceledFlag}get composed(){return se(this).composed}get isTrusted(){return!1}get timeStamp(){return se(this).timeStamp}initEvent(e,t=!1,r=!1){let n=se(this);if(n.dispatchFlag){JO.warn();return}ug.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},zR=0,LR=1,BR=2,FR=3,ug=new WeakMap;function se(i,e="this"){let t=ug.get(i);return pg(t!=null,"'%s' must be an object that Event constructor created, but got another one: %o",e,i),t}function VR(i){if(i.inPassiveListenerFlag){XO.warn();return}if(!i.cancelable){QO.warn();return}i.canceledFlag=!0}Object.defineProperty(Ge,"NONE",{enumerable:!0});Object.defineProperty(Ge,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(Ge,"AT_TARGET",{enumerable:!0});Object.defineProperty(Ge,"BUBBLING_PHASE",{enumerable:!0});var ag=Object.getOwnPropertyNames(Ge.prototype);for(let i=0;i<ag.length;++i)ag[i]!=="constructor"&&Object.defineProperty(Ge.prototype,ag[i],{enumerable:!0});typeof Ct<"u"&&typeof Ct.Event<"u"&&Object.setPrototypeOf(Ge.prototype,Ct.Event.prototype);function ek(i){return Ct.DOMException?new Ct.DOMException(i,"InvalidStateError"):(cn==null&&(cn=class JR extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,JR)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(cn.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),WR(cn),WR(cn.prototype)),new cn(i))}var cn,UR={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function WR(i){let e=Object.keys(UR);for(let t=0;t<e.length;++t){let r=e[t],n=UR[r];Object.defineProperty(i,r,{get(){return n},configurable:!0,enumerable:!0})}}var pn=class extends Ge{static wrap(e){return new($R(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),GR.set(this,{original:e});let t=Object.keys(e);for(let r=0;r<t.length;++r){let n=t[r];n in this||Object.defineProperty(this,n,QR(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=Or(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=Or(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=Or(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=Or(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=Or(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=Or(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},GR=new WeakMap;function Or(i){let e=GR.get(i);return pg(e!=null,"'this' is expected an Event object, but got",i),e}var Uu=new WeakMap;Uu.set(Object.prototype,pn);typeof Ct<"u"&&typeof Ct.Event<"u"&&Uu.set(Ct.Event.prototype,pn);function $R(i){let e=Object.getPrototypeOf(i);if(e==null)return pn;let t=Uu.get(e);return t==null&&(t=tk($R(e),e),Uu.set(e,t)),t}function tk(i,e){class t extends i{}let r=Object.keys(e);for(let n=0;n<r.length;++n)Object.defineProperty(t.prototype,r[n],QR(e,r[n]));return t}function QR(i,e){let t=Object.getOwnPropertyDescriptor(i,e);return{get(){let r=Or(this).original,n=r[e];return typeof n=="function"?n.bind(r):n},set(r){let n=Or(this).original;n[e]=r},configurable:t.configurable,enumerable:t.enumerable}}function rk(i,e,t,r,n,s){return{callback:i,flags:(e?1:0)|(t?2:0)|(r?4:0),signal:n,signalListener:s}}function ik(i){i.flags|=8}function XR(i){return(i.flags&1)===1}function ZR(i){return(i.flags&2)===2}function YR(i){return(i.flags&4)===4}function nk(i){return(i.flags&8)===8}function sk({callback:i},e,t){try{typeof i=="function"?i.call(e,t):typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(r){KO(r)}}function eE({listeners:i},e,t){for(let r=0;r<i.length;++r)if(i[r].callback===e&&XR(i[r])===t)return r;return-1}function tE(i,e,t,r,n,s){let o;s&&(o=lg.bind(null,i,e,t),s.addEventListener("abort",o));let a=rk(e,t,r,n,s,o);return i.cow?(i.cow=!1,i.listeners=[...i.listeners,a]):i.listeners.push(a),a}function lg(i,e,t){let r=eE(i,e,t);return r!==-1?rE(i,r):!1}function rE(i,e,t=!1){let r=i.listeners[e];return ik(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),i.cow&&!t?(i.cow=!1,i.listeners=i.listeners.filter((n,s)=>s!==e),!1):(i.listeners.splice(e,1),!0)}function ok(){return Object.create(null)}function iE(i,e){var t;return(t=i[e])!==null&&t!==void 0?t:i[e]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var nr=class{constructor(){nE.set(this,ok())}addEventListener(e,t,r){let n=un(this),{callback:s,capture:o,once:a,passive:c,signal:u,type:l}=ak(e,t,r);if(s==null||u?.aborted)return;let h=iE(n,l),d=eE(h,s,o);if(d!==-1){uk(h.listeners[d],c,a,u);return}tE(h,s,o,c,a,u)}removeEventListener(e,t,r){let n=un(this),{callback:s,capture:o,type:a}=ck(e,t,r),c=n[a];s!=null&&c&&lg(c,s,o)}dispatchEvent(e){let t=un(this)[String(e.type)];if(t==null)return!0;let r=e instanceof Ge?e:pn.wrap(e),n=se(r,"event");if(n.dispatchFlag)throw ek("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:s,listeners:o}=t;t.cow=!0;for(let a=0;a<o.length;++a){let c=o[a];if(!nk(c)&&(YR(c)&&rE(t,a,!s)&&(a-=1),n.inPassiveListenerFlag=ZR(c),sk(c,this,r),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}s||(t.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},nE=new WeakMap;function un(i,e="this"){let t=nE.get(i);return pg(t!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",e,i),t}function ak(i,e,t){var r;return sE(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture,passive:!!t.passive,once:!!t.once,signal:(r=t.signal)!==null&&r!==void 0?r:void 0}:{type:String(i),callback:e??void 0,capture:!!t,passive:!1,once:!1,signal:void 0}}function ck(i,e,t){return sE(e),typeof t=="object"&&t!==null?{type:String(i),callback:e??void 0,capture:!!t.capture}:{type:String(i),callback:e??void 0,capture:!!t}}function sE(i){if(!(typeof i=="function"||typeof i=="object"&&i!==null&&typeof i.handleEvent=="function")){if(i==null||typeof i=="object"){jR.warn(i);return}throw new TypeError(HR(jR.message,[i]))}}function uk(i,e,t,r){ZO.warn(XR(i)?"capture":"bubble",i.callback),ZR(i)!==e&&og.warn("passive"),YR(i)!==t&&og.warn("once"),i.signal!==r&&og.warn("signal")}var cg=Object.getOwnPropertyNames(nr.prototype);for(let i=0;i<cg.length;++i)cg[i]!=="constructor"&&Object.defineProperty(nr.prototype,cg[i],{enumerable:!0});typeof Ct<"u"&&typeof Ct.EventTarget<"u"&&Object.setPrototypeOf(nr.prototype,Ct.EventTarget.prototype);function Bt(i,e){var t,r;return(r=(t=un(i,"target")[e])===null||t===void 0?void 0:t.attrCallback)!==null&&r!==void 0?r:null}function Ft(i,e,t){t!=null&&typeof t!="function"&&YO.warn(t),typeof t=="function"||typeof t=="object"&&t!==null?pk(i,e,t):lk(i,e)}function pk(i,e,t){let r=iE(un(i,"target"),String(e));r.attrCallback=t,r.attrListener==null&&(r.attrListener=tE(r,hk(r),!1,!1,!1,void 0))}function lk(i,e){let r=un(i,"target")[String(e)];r&&r.attrListener&&(lg(r,r.attrListener.callback,!1),r.attrCallback=r.attrListener=void 0)}function hk(i){return function(e){let t=i.attrCallback;typeof t=="function"&&t.call(this,e)}}function oE(i){return!!((typeof i=="function"||typeof i=="object")&&i&&"then"in i&&typeof i.then=="function")}function hg(i,e){return new Promise(t=>{try{let r=i.call(e);oE(r)?r.then(t,()=>t(void 0)):t(r)}catch{t(void 0)}})}var aE=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function dk(i,e){return!!(i===e||aE(i)&&aE(e))}function vk(i,e){if(i.length!==e.length)return!1;for(var t=0;t<i.length;t++)if(!dk(i[t],e[t]))return!1;return!0}function cE(i,e){e===void 0&&(e=vk);var t=null;function r(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var o=i.apply(this,n);return t={lastResult:o,lastArgs:n,lastThis:this},o}return r.clear=function(){t=null},r}var Wu=class{constructor(i){this.audioContext=i}pause(){this.audioContext&&this.audioContext.suspend(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("pause"))}resume(){this.audioContext&&this.audioContext.resume(),this.playingUtterance&&this.playingUtterance.dispatchEvent(new CustomEvent("resume"))}async start(i){let e;for(;e=i.shift();)this.playingUtterance=e,await e.play(this.audioContext),this.playingUtterance=null}stop(){this.playingUtterance&&this.playingUtterance.stop(),this.audioContext.state==="suspended"&&this.audioContext.resume()}};var Hu=class{constructor({audioContext:i,ponyfill:e}){this.consumer=null,this.paused=!1,this.queue=[],this.getAudioContext=cE(()=>i||new e.AudioContext)}pause(){this.paused=!0,this.consumer&&this.consumer.pause()}push(i){this.queue.push(i),this.startConsumer()}resume(){this.paused=!1,this.consumer?this.consumer.resume():this.startConsumer()}get speaking(){return!!this.consumer}async startConsumer(){for(;!this.paused&&this.queue.length&&!this.consumer;)this.consumer=new Wu(this.getAudioContext()),await this.consumer.start(this.queue),this.consumer=null}stop(){this.queue.splice(0),this.consumer&&this.consumer.stop()}};var sr=class extends Ge{constructor(e){super(e)}};function uE(){let i={};return i.promise=new Promise((e,t)=>{i.reject=t,i.resolve=e}),i}var dg=class{constructor(){this.#t=i=>{let e=this.#e.shift();e&&e.resolve(i),this.#r&&(this.#r.resolve(i),this.#r=void 0)}}#t;#e=[];#r=void 0;get eventListener(){return this.#t}[Symbol.iterator](){return{next:()=>({done:!1,value:this.upcoming()})}}one(){let i=uE();return this.#e.push(i),i.promise}upcoming(){return this.#r||(this.#r=uE()),this.#r.promise}};var pE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fs=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(vs=0;vs<pE.length;vs++)fs[pE.charCodeAt(vs)]=vs;var vs;var lE=function(i){var e=i.length*.75,t=i.length,r,n=0,s,o,a,c;i[i.length-1]==="="&&(e--,i[i.length-2]==="="&&e--);var u=new ArrayBuffer(e),l=new Uint8Array(u);for(r=0;r<t;r+=4)s=fs[i.charCodeAt(r)],o=fs[i.charCodeAt(r+1)],a=fs[i.charCodeAt(r+2)],c=fs[i.charCodeAt(r+3)],l[n++]=s<<2|o>>4,l[n++]=(o&15)<<4|a>>2,l[n++]=(a&3)<<6|c&63;return u};function vg(i){let e=Math.round((i-1)*100);return e>=0&&(e="+"+e),e+"%"}function fg({lang:i,pitch:e=1,rate:t=1,text:r,voice:n,volume:s}){return`<speak version="1.0" xml:lang="${i}">
|
|
25
25
|
<voice xml:lang="${i}" name="${n}">
|
|
26
|
-
<prosody pitch="${
|
|
26
|
+
<prosody pitch="${vg(e)}" rate="${vg(t)}" volume="${vg(s)}">
|
|
27
27
|
${r}
|
|
28
28
|
</prosody>
|
|
29
29
|
</voice>
|
|
30
|
-
</speak>`}var
|
|
30
|
+
</speak>`}var fk=/^\s*<speak(\s|\/?>)/u,gk=/^\s*<\?xml\s/u;function gg(i){return fk.test(i)||gk.test(i)}var mk="en-US",yk="riff-16khz-16bit-mono-pcm",Sk="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",Ck="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function hE({deploymentId:i,fetchCredentials:e,lang:t=mk,outputFormat:r=yk,pitch:n,rate:s,text:o,voice:a=Sk,volume:c}){if(!o)return lE(Ck);let{authorizationToken:u,region:l,speechSynthesisHostname:h,subscriptionKey:d}=await e();if(u&&d||!u&&!d)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(l&&h||!l&&!h)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=gg(o)?o:fg({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),M=h||(i?`${encodeURI(l)}.voice.speech.microsoft.com`:`${encodeURI(l)}.tts.speech.microsoft.com`),D=i?`?deploymentId=${encodeURI(i)}`:"",oe=`https://${M}/cognitiveservices/v1${D}`,Q=await fetch(oe,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":d}},method:"POST",body:g});if(!Q.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${Q.status}`);return Q.arrayBuffer()}function mg(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function Pk(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function Rk(i,e,t){return new Promise((r,n)=>{let s=new dg,o=new dg,a=mg(i,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(i.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(r)}catch(c){n(c)}finally{a()}})}var yg=class extends nr{constructor(e){super(),this._lang=null,this._pitch=1,this._rate=1,this._voice=null,this._volume=1,this.text=e,this.onboundary=null,this.onend=null,this.onerror=null,this.onmark=null,this.onpause=null,this.onresume=null,this.onstart=null}get lang(){return this._lang}set lang(e){this._lang=e}get onboundary(){return Bt(this,"boundary")}set onboundary(e){Ft(this,"boundary",e)}get onend(){return Bt(this,"end")}set onend(e){Ft(this,"end",e)}get onerror(){return Bt(this,"error")}set onerror(e){Ft(this,"error",e)}get onmark(){return Bt(this,"mark")}set onmark(e){Ft(this,"mark",e)}get onpause(){return Bt(this,"pause")}set onpause(e){Ft(this,"pause",e)}get onresume(){return Bt(this,"resume")}set onresume(e){Ft(this,"resume",e)}get onstart(){return Bt(this,"start")}set onstart(e){Ft(this,"start",e)}get pitch(){return this._pitch}set pitch(e){this._pitch=e}get rate(){return this._rate}set rate(e){this._rate=e}get voice(){return this._voice}set voice(e){this._voice=e}get volume(){return this._volume}set volume(e){this._volume=e}preload({deploymentId:e,fetchCredentials:t,outputFormat:r}){this.arrayBufferPromise=hE({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:r,pitch:this.pitch,rate:this.rate,text:this.text,voice:this.voice&&this.voice.voiceURI,volume:this.volume}),this.arrayBufferPromise.catch()}async play(e){try{this.dispatchEvent(new sr("start"));let t=e.createBufferSource(),r=await Pk(e,await this.arrayBufferPromise);this._playingSource=t,await Rk(e,r,t),this._playingSource=null,this.dispatchEvent(new sr("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Sg=yg;var ln=class{constructor({gender:i,lang:e,voiceURI:t}){this._default=!1,this._gender=i,this._lang=e,this._localService=!1,this._name=t,this._voiceURI=t}get default(){return this._default}get gender(){return this._gender}get lang(){return this._lang}get localService(){return this._localService}get name(){return this._name}get voiceURI(){return this._voiceURI}};async function Ek({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let n=i||`${t}.customvoice.api.speech.microsoft.com`,s=await fetch(`https://${encodeURI(n)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(e)}`,{headers:{accept:"application/json","ocp-apim-subscription-key":r}});if(!s.ok)throw new Error("Failed to fetch custom voices");return s.json()}async function dE({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r}){let{models:n}=await Ek({customVoiceHostname:i,deploymentId:e,region:t,subscriptionKey:r});return n.map(({properties:{Gender:s},locale:o,name:a})=>new ln({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function Cg({authorizationToken:i,region:e,speechSynthesisHostname:t,subscriptionKey:r}){let n=t||`${encodeURI(e)}.tts.speech.microsoft.com`,s=await fetch(`https://${n}/cognitiveservices/voices/list`,{headers:{"content-type":"application/json",...i?{authorization:`Bearer ${i}`}:{"Ocp-Apim-Subscription-Key":r}}});if(!s.ok)throw new Error("Failed to fetch voices");return(await s.json()).map(({Gender:a,Locale:c,Name:u})=>new ln({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var _k="audio-24khz-160kbitrate-mono-mp3",Ik=[],vE=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=_k}=ps(i);if(!e&&!r.AudioContext)return console.warn("web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services."),{};class o extends nr{constructor(){super(),this.queue=new Hu({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return Ik}get onvoiceschanged(){return Bt(this,"voiceschanged")}set onvoiceschanged(c){Ft(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Sg))throw new Error("invalid utterance");let{reject:u,resolve:l,promise:h}=ls(),d=({error:g,message:M})=>{let D=new Error(g);D.stack=M,u(D)};return c.addEventListener("end",l),c.addEventListener("error",d),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),h.finally(()=>{c.removeEventListener("end",l),c.removeEventListener("error",d)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:l,subscriptionKey:h}=await t();n?h&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await hg(async()=>{let d=await dE({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:l,subscriptionKey:h});this.getVoices=()=>d})):await hg(async()=>{let d=await Cg(await t());this.getVoices=()=>d}),this.dispatchEvent(new sr("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:sr,SpeechSynthesisUtterance:Sg}};var Pg=vE;function Ku(i={}){return{...ds(i),...Pg(i)}}var Rg=document.createElement("meta");Rg.setAttribute("name","web-speech-cognitive-services");Rg.setAttribute("content","version=8.1.1-main.65a0e14");document.head.appendChild(Rg);globalThis.WebSpeechCognitiveServices={create:Ku,createSpeechRecognitionPonyfillFromRecognizer:Tr};})();
|
|
31
31
|
//# sourceMappingURL=web-speech-cognitive-services.production.min.js.map
|