-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path154.d18bbf84e9e1e9b55db3.js
1 lines (1 loc) · 53.1 KB
/
154.d18bbf84e9e1e9b55db3.js
1
"use strict";(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[154],{32154:function(Gt,le,p){p.r(le),p.d(le,{amplify_chatbot:function(){return sn}});var ye,xe,_e,Se,Ee,Ae,Ce,Te,Ie,ze,Le,Ne,Re,G,Pe,H,Je,ke,Be,Fe,Me,Y,$e,K,Oe,Ue,ee,De,ne,Ve,Ge,He,We,Ze,te,Xe,je,on=p(43085),N=p(8239),de=p(75134),ce=p(47289),ln=p(88774),A=p.n(ln),_=p(65513),V=p(45013),ue=p(77),Q=p(53799),k=p(30031),dn=p(84665),cn=p(96638),B=function(){return(B=Object.assign||function(a){for(var e,t=1,n=arguments.length;t<n;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i]);return a}).apply(this,arguments)},un=new V.k("AbstractInteractionsProvider"),fn=function(){function a(e){void 0===e&&(e={}),this._config=e}return a.prototype.configure=function(e){return void 0===e&&(e={}),this._config=B(B({},this._config),e),un.debug("configure "+this.getProviderName(),this._config),this.options},a.prototype.getCategory=function(){return"Interactions"},Object.defineProperty(a.prototype,"options",{get:function(){return B({},this._config)},enumerable:!0,configurable:!0}),a}(),o=p(64762),vn=p(81055),fe=p(6128),hn=p(67102),q=p(12602),me=p(7884),pn=p(35926),gn=p(22936),ve="runtime.lex.{region}.amazonaws.com",In=new Set(["af-south-1","ap-east-1","ap-northeast-1","ap-northeast-2","ap-south-1","ap-southeast-1","ap-southeast-2","ca-central-1","eu-central-1","eu-north-1","eu-south-1","eu-west-1","eu-west-2","eu-west-3","me-south-1","sa-east-1","us-east-1","us-east-2","us-west-1","us-west-2"]),zn=new Set(["cn-north-1","cn-northwest-1"]),Ln=new Set(["us-iso-east-1"]),Nn=new Set(["us-isob-east-1"]),Rn=new Set(["us-gov-east-1","us-gov-west-1"]),he={apiVersion:"2016-11-28",disableHostPrefix:!1,logger:{},regionInfoProvider:function(e,t){var n=void 0;switch(e){case"ap-northeast-1":n={hostname:"runtime.lex.ap-northeast-1.amazonaws.com",partition:"aws",signingService:"lex"};break;case"ap-southeast-1":n={hostname:"runtime.lex.ap-southeast-1.amazonaws.com",partition:"aws",signingService:"lex"};break;case"ap-southeast-2":n={hostname:"runtime.lex.ap-southeast-2.amazonaws.com",partition:"aws",signingService:"lex"};break;case"eu-central-1":n={hostname:"runtime.lex.eu-central-1.amazonaws.com",partition:"aws",signingService:"lex"};break;case"eu-west-1":n={hostname:"runtime.lex.eu-west-1.amazonaws.com",partition:"aws",signingService:"lex"};break;case"eu-west-2":n={hostname:"runtime.lex.eu-west-2.amazonaws.com",partition:"aws",signingService:"lex"};break;case"us-east-1":n={hostname:"runtime.lex.us-east-1.amazonaws.com",partition:"aws",signingService:"lex"};break;case"us-west-2":n={hostname:"runtime.lex.us-west-2.amazonaws.com",partition:"aws",signingService:"lex"};break;default:In.has(e)&&(n={hostname:ve.replace("{region}",e),partition:"aws",signingService:"lex"}),zn.has(e)&&(n={hostname:"runtime.lex.{region}.amazonaws.com.cn".replace("{region}",e),partition:"aws-cn"}),Ln.has(e)&&(n={hostname:"runtime.lex.{region}.c2s.ic.gov".replace("{region}",e),partition:"aws-iso"}),Nn.has(e)&&(n={hostname:"runtime.lex.{region}.sc2s.sgov.gov".replace("{region}",e),partition:"aws-iso-b"}),Rn.has(e)&&(n={hostname:"runtime.lex.{region}.amazonaws.com".replace("{region}",e),partition:"aws-us-gov"}),void 0===n&&(n={hostname:ve.replace("{region}",e),partition:"aws",signingService:"lex"})}return Promise.resolve((0,o.pi)({signingService:"lex"},n))},serviceId:"Lex Runtime Service",urlParser:p(2047).e},kn=(0,o.pi)((0,o.pi)({},he),{runtime:"browser",base64Decoder:me.G,base64Encoder:me.s,bodyLengthChecker:pn.W,credentialDefaultProvider:function(e){return function(){return Promise.reject(new Error("Credential is missing"))}},defaultUserAgentProvider:(0,gn.f)({serviceId:he.serviceId,clientVersion:"3.6.1"}),maxAttempts:q.J,region:(0,hn.n)("Region is missing"),requestHandler:new fe.B,sha256:vn.Sha256,streamCollector:fe.C,utf8Decoder:function(e){return"function"==typeof TextEncoder?(a=e,(new TextEncoder).encode(a)):function(e){for(var t=[],n=0,i=e.length;n<i;n++){var r=e.charCodeAt(n);if(r<128)t.push(r);else if(r<2048)t.push(r>>6|192,63&r|128);else if(n+1<e.length&&55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))){var s=65536+((1023&r)<<10)+(1023&e.charCodeAt(++n));t.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}else t.push(r>>12|224,r>>6&63|128,63&r|128)}return Uint8Array.from(t)}(e);var a},utf8Encoder:function(e){return"function"==typeof TextDecoder?(a=e,new TextDecoder("utf-8").decode(a)):function(e){for(var t="",n=0,i=e.length;n<i;n++){var r=e[n];if(r<128)t+=String.fromCharCode(r);else if(192<=r&&r<224){var s=e[++n];t+=String.fromCharCode((31&r)<<6|63&s)}else if(240<=r&&r<365){var c="%"+[r,e[++n],e[++n],e[++n]].map(function(d){return d.toString(16)}).join("%");t+=decodeURIComponent(c)}else t+=String.fromCharCode((15&r)<<12|(63&e[++n])<<6|63&e[++n])}return t}(e);var a}}),pe=p(76841),Bn=p(5031),ge=p(46983),Fn=p(22547),be=p(19826),we=p(53536),h=p(74118),Mn=function(a){function e(t){var n=this,i=(0,o.pi)((0,o.pi)({},kn),t),r=(0,pe.Xb)(i),s=(0,pe.g4)(r),l=(0,be.A$)(s),c=(0,q.BC)(l),d=(0,ge.S8)(c),u=(0,we.er)(d);return(n=a.call(this,u)||this).config=u,n.middlewareStack.use((0,be.yt)(n.config)),n.middlewareStack.use((0,q.NQ)(n.config)),n.middlewareStack.use((0,Bn.VG)(n.config)),n.middlewareStack.use((0,ge.G2)(n.config)),n.middlewareStack.use((0,Fn.cV)(n.config)),n.middlewareStack.use((0,we.XJ)(n.config)),n}return(0,o.ZT)(e,a),e.prototype.destroy=function(){a.prototype.destroy.call(this)},e}(h.KU);(ye||(ye={})).filterSensitiveLog=function(e){return(0,o.pi)({},e)},(xe||(xe={})).filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)({},e),e.parameters&&{parameters:h.oc})},function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(_e||(_e={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Se||(Se={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ee||(Ee={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ae||(Ae={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ce||(Ce={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Te||(Te={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ie||(Ie={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(ze||(ze={})),function(a){a.FAILED="Failed",a.FULFILLED="Fulfilled",a.READY_FOR_FULFILLMENT="ReadyForFulfillment"}(Le||(Le={})),function(a){a.COMPOSITE="Composite",a.CUSTOM_PAYLOAD="CustomPayload",a.PLAIN_TEXT="PlainText",a.SSML="SSML"}(Ne||(Ne={})),function(a){a.CLOSE="Close",a.CONFIRM_INTENT="ConfirmIntent",a.DELEGATE="Delegate",a.ELICIT_INTENT="ElicitIntent",a.ELICIT_SLOT="ElicitSlot"}(Re||(Re={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)({},e),e.slots&&{slots:h.oc}),e.message&&{message:h.oc})}}(G||(G={})),function(a){a.CONFIRMED="Confirmed",a.DENIED="Denied",a.NONE="None"}(Pe||(Pe={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)({},e),e.slots&&{slots:h.oc})}}(H||(H={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},e),e.recentIntentSummaryView&&{recentIntentSummaryView:e.recentIntentSummaryView.map(function(t){return H.filterSensitiveLog(t)})}),e.sessionAttributes&&{sessionAttributes:h.oc}),e.dialogAction&&{dialogAction:G.filterSensitiveLog(e.dialogAction)}),e.activeContexts&&{activeContexts:h.oc})}}(Je||(Je={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(ke||(ke={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Be||(Be={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Fe||(Fe={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Me||(Me={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},e),e.sessionAttributes&&{sessionAttributes:h.oc}),e.requestAttributes&&{requestAttributes:h.oc}),e.activeContexts&&{activeContexts:h.oc})}}(Y||(Y={})),function(a){a.CONFIRM_INTENT="ConfirmIntent",a.ELICIT_INTENT="ElicitIntent",a.ELICIT_SLOT="ElicitSlot",a.FAILED="Failed",a.FULFILLED="Fulfilled",a.READY_FOR_FULFILLMENT="ReadyForFulfillment"}($e||($e={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)({},e),e.message&&{message:h.oc}),e.activeContexts&&{activeContexts:h.oc})}}(K||(K={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Oe||(Oe={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ue||(Ue={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},e),e.sessionAttributes&&{sessionAttributes:h.oc}),e.requestAttributes&&{requestAttributes:h.oc}),e.inputText&&{inputText:h.oc}),e.activeContexts&&{activeContexts:h.oc})}}(ee||(ee={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(De||(De={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)({},e),e.slots&&{slots:h.oc})}}(ne||(ne={})),function(a){a.GENERIC="application/vnd.amazonaws.card.generic"}(Ve||(Ve={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ge||(Ge={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(He||(He={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(We||(We={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)({},e)}}(Ze||(Ze={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},e),e.alternativeIntents&&{alternativeIntents:e.alternativeIntents.map(function(t){return ne.filterSensitiveLog(t)})}),e.slots&&{slots:h.oc}),e.sessionAttributes&&{sessionAttributes:h.oc}),e.message&&{message:h.oc}),e.activeContexts&&{activeContexts:h.oc})}}(te||(te={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},e),e.sessionAttributes&&{sessionAttributes:h.oc}),e.dialogAction&&{dialogAction:G.filterSensitiveLog(e.dialogAction)}),e.recentIntentSummaryView&&{recentIntentSummaryView:e.recentIntentSummaryView.map(function(t){return H.filterSensitiveLog(t)})}),e.activeContexts&&{activeContexts:h.oc})}}(Xe||(Xe={})),function(a){a.filterSensitiveLog=function(e){return(0,o.pi)((0,o.pi)((0,o.pi)({},e),e.message&&{message:h.oc}),e.activeContexts&&{activeContexts:h.oc})}}(je||(je={}));var Qe=p(78739),Gn=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i,r,s,c,d,u,m,v,g,b,S,x,I,z,w,se,oe;return(0,o.Jh)(this,function(E){switch(E.label){case 0:return i=[(0,o.pi)({},e)],oe={},[4,L(e.body,t)];case 1:switch(n=o.pi.apply(void 0,i.concat([(oe.body=E.sent(),oe)])),s="UnknownError",s=D(e,n.body)){case"BadGatewayException":case"com.amazonaws.lexruntimeservice#BadGatewayException":return[3,2];case"BadRequestException":case"com.amazonaws.lexruntimeservice#BadRequestException":return[3,4];case"ConflictException":case"com.amazonaws.lexruntimeservice#ConflictException":return[3,6];case"DependencyFailedException":case"com.amazonaws.lexruntimeservice#DependencyFailedException":return[3,8];case"InternalFailureException":case"com.amazonaws.lexruntimeservice#InternalFailureException":return[3,10];case"LimitExceededException":case"com.amazonaws.lexruntimeservice#LimitExceededException":return[3,12];case"LoopDetectedException":case"com.amazonaws.lexruntimeservice#LoopDetectedException":return[3,14];case"NotAcceptableException":case"com.amazonaws.lexruntimeservice#NotAcceptableException":return[3,16];case"NotFoundException":case"com.amazonaws.lexruntimeservice#NotFoundException":return[3,18];case"RequestTimeoutException":case"com.amazonaws.lexruntimeservice#RequestTimeoutException":return[3,20];case"UnsupportedMediaTypeException":case"com.amazonaws.lexruntimeservice#UnsupportedMediaTypeException":return[3,22]}return[3,24];case 2:return c=[{}],[4,ie(n,t)];case 3:return r=o.pi.apply(void 0,[o.pi.apply(void 0,c.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 4:return d=[{}],[4,F(n,t)];case 5:return r=o.pi.apply(void 0,[o.pi.apply(void 0,d.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 6:return u=[{}],[4,W(n,t)];case 7:return r=o.pi.apply(void 0,[o.pi.apply(void 0,u.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 8:return m=[{}],[4,re(n,t)];case 9:return r=o.pi.apply(void 0,[o.pi.apply(void 0,m.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 10:return v=[{}],[4,M(n,t)];case 11:return r=o.pi.apply(void 0,[o.pi.apply(void 0,v.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 12:return g=[{}],[4,$(n,t)];case 13:return r=o.pi.apply(void 0,[o.pi.apply(void 0,g.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 14:return b=[{}],[4,qe(n,t)];case 15:return r=o.pi.apply(void 0,[o.pi.apply(void 0,b.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 16:return S=[{}],[4,Ye(n,t)];case 17:return r=o.pi.apply(void 0,[o.pi.apply(void 0,S.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 18:return x=[{}],[4,O(n,t)];case 19:return r=o.pi.apply(void 0,[o.pi.apply(void 0,x.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 20:return I=[{}],[4,Xn(n,t)];case 21:return r=o.pi.apply(void 0,[o.pi.apply(void 0,I.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 22:return z=[{}],[4,jn(n,t)];case 23:return r=o.pi.apply(void 0,[o.pi.apply(void 0,z.concat([E.sent()])),{name:s,$metadata:f(e)}]),[3,25];case 24:s=(w=n.body).code||w.Code||s,r=(0,o.pi)((0,o.pi)({},w),{name:""+s,message:w.message||w.Message||s,$fault:"client",$metadata:f(e)}),E.label=25;case 25:return r.message=se=r.message||r.Message||s,delete r.Message,[2,Promise.reject(Object.assign(new Error(se),r))]}})})},Wn=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i,r,s,c,d,u,m,v,g,b,S,x,I,z;return(0,o.Jh)(this,function(w){switch(w.label){case 0:return i=[(0,o.pi)({},e)],z={},[4,L(e.body,t)];case 1:switch(n=o.pi.apply(void 0,i.concat([(z.body=w.sent(),z)])),s="UnknownError",s=D(e,n.body)){case"BadGatewayException":case"com.amazonaws.lexruntimeservice#BadGatewayException":return[3,2];case"BadRequestException":case"com.amazonaws.lexruntimeservice#BadRequestException":return[3,4];case"ConflictException":case"com.amazonaws.lexruntimeservice#ConflictException":return[3,6];case"DependencyFailedException":case"com.amazonaws.lexruntimeservice#DependencyFailedException":return[3,8];case"InternalFailureException":case"com.amazonaws.lexruntimeservice#InternalFailureException":return[3,10];case"LimitExceededException":case"com.amazonaws.lexruntimeservice#LimitExceededException":return[3,12];case"LoopDetectedException":case"com.amazonaws.lexruntimeservice#LoopDetectedException":return[3,14];case"NotFoundException":case"com.amazonaws.lexruntimeservice#NotFoundException":return[3,16]}return[3,18];case 2:return c=[{}],[4,ie(n,t)];case 3:return r=o.pi.apply(void 0,[o.pi.apply(void 0,c.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 4:return d=[{}],[4,F(n,t)];case 5:return r=o.pi.apply(void 0,[o.pi.apply(void 0,d.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 6:return u=[{}],[4,W(n,t)];case 7:return r=o.pi.apply(void 0,[o.pi.apply(void 0,u.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 8:return m=[{}],[4,re(n,t)];case 9:return r=o.pi.apply(void 0,[o.pi.apply(void 0,m.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 10:return v=[{}],[4,M(n,t)];case 11:return r=o.pi.apply(void 0,[o.pi.apply(void 0,v.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 12:return g=[{}],[4,$(n,t)];case 13:return r=o.pi.apply(void 0,[o.pi.apply(void 0,g.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 14:return b=[{}],[4,qe(n,t)];case 15:return r=o.pi.apply(void 0,[o.pi.apply(void 0,b.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 16:return S=[{}],[4,O(n,t)];case 17:return r=o.pi.apply(void 0,[o.pi.apply(void 0,S.concat([w.sent()])),{name:s,$metadata:f(e)}]),[3,19];case 18:s=(x=n.body).code||x.Code||s,r=(0,o.pi)((0,o.pi)({},x),{name:""+s,message:x.message||x.Message||s,$fault:"client",$metadata:f(e)}),w.label=19;case 19:return r.message=I=r.message||r.Message||s,delete r.Message,[2,Promise.reject(Object.assign(new Error(I),r))]}})})},ie=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"BadGatewayException",$fault:"server",$metadata:f(e),Message:void 0},null!=(i=e.body).Message&&(n.Message=i.Message),[2,n]})})},F=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"BadRequestException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},W=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"ConflictException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},re=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"DependencyFailedException",$fault:"client",$metadata:f(e),Message:void 0},null!=(i=e.body).Message&&(n.Message=i.Message),[2,n]})})},M=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"InternalFailureException",$fault:"server",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},$=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"LimitExceededException",$fault:"client",$metadata:f(e),message:void 0,retryAfterSeconds:void 0},void 0!==e.headers["retry-after"]&&(n.retryAfterSeconds=e.headers["retry-after"]),null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},qe=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"LoopDetectedException",$fault:"server",$metadata:f(e),Message:void 0},null!=(i=e.body).Message&&(n.Message=i.Message),[2,n]})})},Ye=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"NotAcceptableException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},O=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"NotFoundException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},Xn=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"RequestTimeoutException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},jn=function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){return n={name:"UnsupportedMediaTypeException",$fault:"client",$metadata:f(e),message:void 0},null!=(i=e.body).message&&(n.message=i.message),[2,n]})})},qn=function(e,t){return Object.entries(e).reduce(function(n,i){var r,s=(0,o.CR)(i,2),l=s[0],c=s[1];return null===c?n:(0,o.pi)((0,o.pi)({},n),((r={})[l]=c,r))},{})},Ke=function(e,t){return e.filter(function(n){return null!=n}).map(function(n){return null===n?null:function(e,t){return(0,o.pi)((0,o.pi)((0,o.pi)({},null!=e.name&&{name:e.name}),null!=e.parameters&&{parameters:qn(e.parameters)}),null!=e.timeToLive&&{timeToLive:Yn(e.timeToLive,t)})}(n,t)})},Yn=function(e,t){return(0,o.pi)((0,o.pi)({},null!=e.timeToLiveInSeconds&&{timeToLiveInSeconds:e.timeToLiveInSeconds}),null!=e.turnsToLive&&{turnsToLive:e.turnsToLive})},U=function(e,t){return Object.entries(e).reduce(function(n,i){var r,s=(0,o.CR)(i,2),l=s[0],c=s[1];return null===c?n:(0,o.pi)((0,o.pi)({},n),((r={})[l]=c,r))},{})},it=function(e,t){return Object.entries(e).reduce(function(n,i){var r,s=(0,o.CR)(i,2),l=s[0],c=s[1];return null===c?n:(0,o.pi)((0,o.pi)({},n),((r={})[l]=c,r))},{})},rt=function(e,t){return{timeToLiveInSeconds:null!=e.timeToLiveInSeconds?e.timeToLiveInSeconds:void 0,turnsToLive:null!=e.turnsToLive?e.turnsToLive:void 0}},lt=function(e,t){return(e||[]).filter(function(n){return null!=n}).map(function(n){return null===n?null:function(e,t){return{attachmentLinkUrl:null!=e.attachmentLinkUrl?e.attachmentLinkUrl:void 0,buttons:null!=e.buttons?ft(e.buttons,t):void 0,imageUrl:null!=e.imageUrl?e.imageUrl:void 0,subTitle:null!=e.subTitle?e.subTitle:void 0,title:null!=e.title?e.title:void 0}}(n,t)})},nn=function(e,t){return{score:null!=e.score?e.score:void 0}},ft=function(e,t){return(e||[]).filter(function(n){return null!=n}).map(function(n){return null===n?null:function(e,t){return{text:null!=e.text?e.text:void 0,value:null!=e.value?e.value:void 0}}(n)})},mt=function(e,t){return{intentName:null!=e.intentName?e.intentName:void 0,nluIntentConfidence:null!=e.nluIntentConfidence?nn(e.nluIntentConfidence):void 0,slots:null!=e.slots?R(e.slots,t):void 0}},R=function(e,t){return Object.entries(e).reduce(function(n,i){var r,s=(0,o.CR)(i,2),l=s[0],c=s[1];return null===c?n:(0,o.pi)((0,o.pi)({},n),((r={})[l]=c,r))},{})},f=function(e){var t;return{httpStatusCode:e.statusCode,requestId:null!==(t=e.headers["x-amzn-requestid"])&&void 0!==t?t:e.headers["x-amzn-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]}},P=function(e){return!(null==e||""===e||Object.getOwnPropertyNames(e).includes("length")&&0==e.length||Object.getOwnPropertyNames(e).includes("size")&&0==e.size)},L=function(e,t){return function(e,t){return function(e,t){return void 0===e&&(e=new Uint8Array),e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array)}(e,t).then(function(n){return t.utf8Encoder(n)})}(e,t).then(function(n){return n.length?JSON.parse(n):{}})},D=function(e,t){var i=function(l){var c=l;return c.indexOf(":")>=0&&(c=c.split(":")[0]),c.indexOf("#")>=0&&(c=c.split("#")[1]),c},r=("x-amzn-errortype",Object.keys(e.headers).find(function(d){return d.toLowerCase()==="x-amzn-errortype".toLowerCase()}));return void 0!==r?i(e.headers[r]):void 0!==t.code?i(t.code):void 0!==t.__type?i(t.__type):""},tn=p(73961),bt=function(a){function e(t){var n=a.call(this)||this;return n.input=t,n}return(0,o.ZT)(e,a),e.prototype.resolveMiddleware=function(t,n,i){this.middlewareStack.use((0,tn.p2)(n,this.serialize,this.deserialize));var r=t.concat(this.middlewareStack),u=n.requestHandler;return r.resolve(function(m){return u.handle(m.request,i||{})},{logger:n.logger,clientName:"LexRuntimeServiceClient",commandName:"PostTextCommand",inputFilterSensitiveLog:ee.filterSensitiveLog,outputFilterSensitiveLog:te.filterSensitiveLog})},e.prototype.serialize=function(t,n){return function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i,r,s,l,d;return(0,o.Jh)(this,function(v){switch(v.label){case 0:if(n={"content-type":"application/json"},i="/bot/{botName}/alias/{botAlias}/user/{userId}/text",void 0===e.botName)throw new Error("No value provided for input HTTP label: botName.");if((r=e.botName).length<=0)throw new Error("Empty value provided for input HTTP label: botName.");if(i=i.replace("{botName}",(0,h.jc)(r)),void 0===e.botAlias)throw new Error("No value provided for input HTTP label: botAlias.");if((r=e.botAlias).length<=0)throw new Error("Empty value provided for input HTTP label: botAlias.");if(i=i.replace("{botAlias}",(0,h.jc)(r)),void 0===e.userId)throw new Error("No value provided for input HTTP label: userId.");if((r=e.userId).length<=0)throw new Error("Empty value provided for input HTTP label: userId.");return i=i.replace("{userId}",(0,h.jc)(r)),s=JSON.stringify((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({},null!=e.activeContexts&&{activeContexts:Ke(e.activeContexts,t)}),null!=e.inputText&&{inputText:e.inputText}),null!=e.requestAttributes&&{requestAttributes:U(e.requestAttributes)}),null!=e.sessionAttributes&&{sessionAttributes:U(e.sessionAttributes)})),[4,t.endpoint()];case 1:return l=v.sent(),[2,new Qe.aW({protocol:void 0===(d=l.protocol)?"https":d,hostname:l.hostname,port:l.port,method:"POST",headers:n,path:i,body:s})]}})})}(t,n)},e.prototype.deserialize=function(t,n){return function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i;return(0,o.Jh)(this,function(r){switch(r.label){case 0:return 200!==e.statusCode&&e.statusCode>=300?[2,Wn(e,t)]:(n={$metadata:f(e),activeContexts:void 0,alternativeIntents:void 0,botVersion:void 0,dialogState:void 0,intentName:void 0,message:void 0,messageFormat:void 0,nluIntentConfidence:void 0,responseCard:void 0,sentimentResponse:void 0,sessionAttributes:void 0,sessionId:void 0,slotToElicit:void 0,slots:void 0},[4,L(e.body,t)]);case 1:return null!=(i=r.sent()).activeContexts&&(n.activeContexts=function(e,t){return(e||[]).filter(function(n){return null!=n}).map(function(n){return null===n?null:function(e,t){return{name:null!=e.name?e.name:void 0,parameters:null!=e.parameters?it(e.parameters):void 0,timeToLive:null!=e.timeToLive?rt(e.timeToLive,t):void 0}}(n,t)})}(i.activeContexts,t)),null!=i.alternativeIntents&&(n.alternativeIntents=function(e,t){return(e||[]).filter(function(n){return null!=n}).map(function(n){return null===n?null:mt(n,t)})}(i.alternativeIntents,t)),null!=i.botVersion&&(n.botVersion=i.botVersion),null!=i.dialogState&&(n.dialogState=i.dialogState),null!=i.intentName&&(n.intentName=i.intentName),null!=i.message&&(n.message=i.message),null!=i.messageFormat&&(n.messageFormat=i.messageFormat),null!=i.nluIntentConfidence&&(n.nluIntentConfidence=nn(i.nluIntentConfidence)),null!=i.responseCard&&(n.responseCard=function(e,t){return{contentType:null!=e.contentType?e.contentType:void 0,genericAttachments:null!=e.genericAttachments?lt(e.genericAttachments,t):void 0,version:null!=e.version?e.version:void 0}}(i.responseCard,t)),null!=i.sentimentResponse&&(n.sentimentResponse=function(e,t){return{sentimentLabel:null!=e.sentimentLabel?e.sentimentLabel:void 0,sentimentScore:null!=e.sentimentScore?e.sentimentScore:void 0}}(i.sentimentResponse)),null!=i.sessionAttributes&&(n.sessionAttributes=R(i.sessionAttributes,t)),null!=i.sessionId&&(n.sessionId=i.sessionId),null!=i.slotToElicit&&(n.slotToElicit=i.slotToElicit),null!=i.slots&&(n.slots=R(i.slots,t)),[2,Promise.resolve(n)]}})})}(t,n)},e}(h.mY),wt=function(a){function e(t){var n=a.call(this)||this;return n.input=t,n}return(0,o.ZT)(e,a),e.prototype.resolveMiddleware=function(t,n,i){this.middlewareStack.use((0,tn.p2)(n,this.serialize,this.deserialize));var r=t.concat(this.middlewareStack),u=n.requestHandler;return r.resolve(function(m){return u.handle(m.request,i||{})},{logger:n.logger,clientName:"LexRuntimeServiceClient",commandName:"PostContentCommand",inputFilterSensitiveLog:Y.filterSensitiveLog,outputFilterSensitiveLog:K.filterSensitiveLog})},e.prototype.serialize=function(t,n){return function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n,i,r,s,l,d;return(0,o.Jh)(this,function(v){switch(v.label){case 0:if(n=(0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)((0,o.pi)({"content-type":"application/octet-stream","x-amz-content-sha256":"UNSIGNED-PAYLOAD"},P(e.sessionAttributes)&&{"x-amz-lex-session-attributes":Buffer.from(h.QT.fromObject(e.sessionAttributes)).toString("base64")}),P(e.requestAttributes)&&{"x-amz-lex-request-attributes":Buffer.from(h.QT.fromObject(e.requestAttributes)).toString("base64")}),P(e.contentType)&&{"content-type":e.contentType}),P(e.accept)&&{accept:e.accept}),P(e.activeContexts)&&{"x-amz-lex-active-contexts":Buffer.from(h.QT.fromObject(e.activeContexts)).toString("base64")}),i="/bot/{botName}/alias/{botAlias}/user/{userId}/content",void 0===e.botName)throw new Error("No value provided for input HTTP label: botName.");if((r=e.botName).length<=0)throw new Error("Empty value provided for input HTTP label: botName.");if(i=i.replace("{botName}",(0,h.jc)(r)),void 0===e.botAlias)throw new Error("No value provided for input HTTP label: botAlias.");if((r=e.botAlias).length<=0)throw new Error("Empty value provided for input HTTP label: botAlias.");if(i=i.replace("{botAlias}",(0,h.jc)(r)),void 0===e.userId)throw new Error("No value provided for input HTTP label: userId.");if((r=e.userId).length<=0)throw new Error("Empty value provided for input HTTP label: userId.");return i=i.replace("{userId}",(0,h.jc)(r)),void 0!==e.inputStream&&(s=e.inputStream),[4,t.endpoint()];case 1:return l=v.sent(),[2,new Qe.aW({protocol:void 0===(d=l.protocol)?"https":d,hostname:l.hostname,port:l.port,method:"POST",headers:n,path:i,body:s})]}})})}(t,n)},e.prototype.deserialize=function(t,n){return function(e,t){return(0,o.mG)(void 0,void 0,void 0,function(){var n;return(0,o.Jh)(this,function(r){return 200!==e.statusCode&&e.statusCode>=300?[2,Gn(e,t)]:(n={$metadata:f(e),activeContexts:void 0,alternativeIntents:void 0,audioStream:void 0,botVersion:void 0,contentType:void 0,dialogState:void 0,inputTranscript:void 0,intentName:void 0,message:void 0,messageFormat:void 0,nluIntentConfidence:void 0,sentimentResponse:void 0,sessionAttributes:void 0,sessionId:void 0,slotToElicit:void 0,slots:void 0},void 0!==e.headers["content-type"]&&(n.contentType=e.headers["content-type"]),void 0!==e.headers["x-amz-lex-intent-name"]&&(n.intentName=e.headers["x-amz-lex-intent-name"]),void 0!==e.headers["x-amz-lex-nlu-intent-confidence"]&&(n.nluIntentConfidence=new h.QT(Buffer.from(e.headers["x-amz-lex-nlu-intent-confidence"],"base64").toString("ascii"))),void 0!==e.headers["x-amz-lex-alternative-intents"]&&(n.alternativeIntents=new h.QT(Buffer.from(e.headers["x-amz-lex-alternative-intents"],"base64").toString("ascii"))),void 0!==e.headers["x-amz-lex-slots"]&&(n.slots=new h.QT(Buffer.from(e.headers["x-amz-lex-slots"],"base64").toString("ascii"))),void 0!==e.headers["x-amz-lex-session-attributes"]&&(n.sessionAttributes=new h.QT(Buffer.from(e.headers["x-amz-lex-session-attributes"],"base64").toString("ascii"))),void 0!==e.headers["x-amz-lex-sentiment"]&&(n.sentimentResponse=e.headers["x-amz-lex-sentiment"]),void 0!==e.headers["x-amz-lex-message"]&&(n.message=e.headers["x-amz-lex-message"]),void 0!==e.headers["x-amz-lex-message-format"]&&(n.messageFormat=e.headers["x-amz-lex-message-format"]),void 0!==e.headers["x-amz-lex-dialog-state"]&&(n.dialogState=e.headers["x-amz-lex-dialog-state"]),void 0!==e.headers["x-amz-lex-slot-to-elicit"]&&(n.slotToElicit=e.headers["x-amz-lex-slot-to-elicit"]),void 0!==e.headers["x-amz-lex-input-transcript"]&&(n.inputTranscript=e.headers["x-amz-lex-input-transcript"]),void 0!==e.headers["x-amz-lex-bot-version"]&&(n.botVersion=e.headers["x-amz-lex-bot-version"]),void 0!==e.headers["x-amz-lex-session-id"]&&(n.sessionId=e.headers["x-amz-lex-session-id"]),void 0!==e.headers["x-amz-lex-active-contexts"]&&(n.activeContexts=new h.QT(Buffer.from(e.headers["x-amz-lex-active-contexts"],"base64").toString("ascii"))),n.audioStream=e.body,[2,Promise.resolve(n)])})})}(t,n)},e}(h.mY),yt=p(88477),xt=p(44497),_t=function(e){if(e instanceof Blob||e instanceof ReadableStream)return new Response(e).arrayBuffer().then(function(t){return new Uint8Array(t)});throw new Error("Readable is not supported.")},St=function(){var a=function(t,n){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)r.hasOwnProperty(s)&&(i[s]=r[s])})(t,n)};return function(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),Z=function(){return(Z=Object.assign||function(a){for(var e,t=1,n=arguments.length;t<n;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i]);return a}).apply(this,arguments)},ae=new V.k("AWSLexProvider"),Ct=function(a){function e(t){void 0===t&&(t={});var n=a.call(this,t)||this;return n._botsCompleteCallback={},n}return St(e,a),e.prototype.getProviderName=function(){return"AWSLexProvider"},e.prototype.reportBotStatus=function(t,n){var i=this;ae.debug("postContent state",t.dialogState),("ReadyForFulfillment"===t.dialogState||"Fulfilled"===t.dialogState)&&("function"==typeof this._botsCompleteCallback[n]&&setTimeout(function(){return i._botsCompleteCallback[n](null,{slots:t.slots})},0),this._config&&"function"==typeof this._config[n].onComplete&&setTimeout(function(){return i._config[n].onComplete(null,{slots:t.slots})},0)),"Failed"===t.dialogState&&("function"==typeof this._botsCompleteCallback[n]&&setTimeout(function(){return i._botsCompleteCallback[n]("Bot conversation failed")},0),this._config&&"function"==typeof this._config[n].onComplete&&setTimeout(function(){return i._config[n].onComplete("Bot conversation failed")},0))},e.prototype.sendMessage=function(t,n){return function(a,e,t,n){return new(t||(t=Promise))(function(r,s){function l(u){try{d(n.next(u))}catch(m){s(m)}}function c(u){try{d(n.throw(u))}catch(m){s(m)}}function d(u){u.done?r(u.value):function(r){return r instanceof t?r:new t(function(s){s(r)})}(u.value).then(l,c)}d((n=n.apply(a,e||[])).next())})}(this,void 0,void 0,function(){var i,r,s,c,d,m,l,v,g;return function(a,e){var n,i,r,s,t={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(u){return function(d){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(r=2&d[0]?i.return:d[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,d[1])).done)return r;switch(i=0,r&&(d=[2&d[0],r.value]),d[0]){case 0:case 1:r=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,i=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(!(r=(r=t.trys).length>0&&r[r.length-1])&&(6===d[0]||2===d[0])){t=0;continue}if(3===d[0]&&(!r||d[1]>r[0]&&d[1]<r[3])){t.label=d[1];break}if(6===d[0]&&t.label<r[1]){t.label=r[1],r=d;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(d);break}r[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(a,t)}catch(u){d=[6,u],i=0}finally{n=r=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}([d,u])}}}(this,function(b){switch(b.label){case 0:return this._config[t]?[4,yt.cN.get()]:[2,Promise.reject("Bot "+t+" does not exist")];case 1:if(!(i=b.sent()))return[2,Promise.reject("No credentials")];if(this.lexRuntimeServiceClient=new Mn({region:this._config[t].region,credentials:i,customUserAgent:(0,xt.Zm)()}),"string"!=typeof n)return[3,6];r={botAlias:this._config[t].alias,botName:t,inputText:n,userId:i.identityId},ae.debug("postText to lex",n),b.label=2;case 2:return b.trys.push([2,4,,5]),s=new bt(r),[4,this.lexRuntimeServiceClient.send(s)];case 3:return l=b.sent(),this.reportBotStatus(l,t),[2,l];case 4:return c=b.sent(),[2,Promise.reject(c)];case 5:return[3,11];case 6:d=n.content,r="voice"===n.options.messageType?{botAlias:this._config[t].alias,botName:t,contentType:"audio/x-l16; sample-rate=16000",inputStream:d,userId:i.identityId,accept:"audio/mpeg"}:{botAlias:this._config[t].alias,botName:t,contentType:"text/plain; charset=utf-8",inputStream:d,userId:i.identityId,accept:"audio/mpeg"},ae.debug("postContent to lex",n),b.label=7;case 7:return b.trys.push([7,10,,11]),m=new wt(r),[4,this.lexRuntimeServiceClient.send(m)];case 8:return l=b.sent(),[4,_t(l.audioStream)];case 9:return v=b.sent(),this.reportBotStatus(l,t),[2,Z(Z({},l),{audioStream:v})];case 10:return g=b.sent(),[2,Promise.reject(g)];case 11:return[2]}})})},e.prototype.onComplete=function(t,n){if(!this._config[t])throw new ErrorEvent("Bot "+t+" does not exist");this._botsCompleteCallback[t]=n},e}(fn),X=function(){return(X=Object.assign||function(a){for(var e,t=1,n=arguments.length;t<n;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i]);return a}).apply(this,arguments)},rn=new V.k("Interactions"),J=new(function(){function a(e){this._options=e,rn.debug("Interactions Options",this._options),this._pluggables={}}return a.prototype.getModuleName=function(){return"Interactions"},a.prototype.configure=function(e){var t=this,n=e?e.Interactions||e:{};rn.debug("configure Interactions",{opt:n}),this._options=X(X({bots:{}},n),n.Interactions);var i=this._options.aws_bots_config,r=this._options.bots;return!Object.keys(r).length&&i&&Array.isArray(i)&&i.forEach(function(s){t._options.bots[s.name]=s}),!this._pluggables.AWSLexProvider&&r&&Object.keys(r).map(function(s){return r[s]}).find(function(s){return!s.providerName||"AWSLexProvider"===s.providerName})&&(this._pluggables.AWSLexProvider=new Ct),Object.keys(this._pluggables).map(function(s){t._pluggables[s].configure(t._options.bots)}),this._options},a.prototype.addPluggable=function(e){if(e&&"Interactions"===e.getCategory()){if(this._pluggables[e.getProviderName()])throw new Error("Bot "+e.getProviderName()+" already plugged");return e.configure(this._options.bots),void(this._pluggables[e.getProviderName()]=e)}},a.prototype.send=function(e,t){return function(a,e,t,n){return new(t||(t=Promise))(function(r,s){function l(u){try{d(n.next(u))}catch(m){s(m)}}function c(u){try{d(n.throw(u))}catch(m){s(m)}}function d(u){u.done?r(u.value):function(r){return r instanceof t?r:new t(function(s){s(r)})}(u.value).then(l,c)}d((n=n.apply(a,e||[])).next())})}(this,void 0,void 0,function(){var n;return function(a,e){var n,i,r,s,t={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(u){return function(d){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(r=2&d[0]?i.return:d[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,d[1])).done)return r;switch(i=0,r&&(d=[2&d[0],r.value]),d[0]){case 0:case 1:r=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,i=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(!(r=(r=t.trys).length>0&&r[r.length-1])&&(6===d[0]||2===d[0])){t=0;continue}if(3===d[0]&&(!r||d[1]>r[0]&&d[1]<r[3])){t.label=d[1];break}if(6===d[0]&&t.label<r[1]){t.label=r[1],r=d;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(d);break}r[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(a,t)}catch(u){d=[6,u],i=0}finally{n=r=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}([d,u])}}}(this,function(i){switch(i.label){case 0:if(!this._options.bots||!this._options.bots[e])throw new Error("Bot "+e+" does not exist");if(!this._pluggables[n=this._options.bots[e].providerName||"AWSLexProvider"])throw new Error("Bot "+n+" does not have valid pluggin did you try addPluggable first?");return[4,this._pluggables[n].sendMessage(e,t)];case 1:return[2,i.sent()]}})})},a.prototype.onComplete=function(e,t){if(!this._options.bots||!this._options.bots[e])throw new Error("Bot "+e+" does not exist");var n=this._options.bots[e].providerName||"AWSLexProvider";if(!this._pluggables[n])throw new Error("Bot "+n+" does not have valid pluggin did you try addPluggable first?");this._pluggables[n].onComplete(e,t)},a}())(null);cn.dQ.register(J);var y,C,T,j=function(e,t,n){for(var i=0;i<n.length;i++)e.setUint8(t+i,n.charCodeAt(i))},Ot=function(e,t,n,i){var l=function(e,t){var n=2*e.length,r=8+n,l=new ArrayBuffer(36+r),c=new DataView(l);return j(c,0,"RIFF"),c.setUint32(4,24+r,!0),j(c,8,"WAVE"),j(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,1,!0),c.setUint32(24,t,!0),c.setUint32(28,2*t,!0),c.setUint16(32,2,!0),c.setUint16(34,16,!0),j(c,36,"data"),c.setUint32(40,n,!0),function(e,t,n){for(var i=44,r=0;r<n.length;r++,i+=2){var s=Math.max(-1,Math.min(1,n[r]));e.setInt16(i,s<0?32768*s:32767*s,!0)}}(c,0,e),c}(function(e,t,n){if(n===t)return e;for(var i=t/n,r=Math.round(e.length/i),s=new Float32Array(r),l=0,c=0;l<s.length;){for(var d=Math.round((l+1)*i),u=0,m=0,v=c;v<d&&v<e.length;v++)u+=e[v],m++;s[l]=u/m,l++,c=d}return s}(function(e,t){for(var n=new Float32Array(t),i=0,r=0;r<e.length;r++)n.set(e[r],i),i+=e[r].length;return n}(e,t),n,i),i);return new Blob([l],{type:"application/octet-stream"})},an=new V.k("AudioRecorder"),Ut=function(){function a(e){(0,de.Z)(this,a),this.streamBuffer=[],this.streamBufferLength=0,this.recording=!1,this.options=e}return(0,ce.Z)(a,[{key:"init",value:(e=(0,N.Z)(A().mark(function n(){var i=this;return A().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(0,ue.lC)().isBrowser){s.next=7;break}return window.AudioContext=window.AudioContext||window.webkitAudioContext,this.audioContext=new AudioContext,s.next=5,navigator.mediaDevices.getUserMedia({audio:!0}).then(function(l){i.audioSupported=!0,i.setupAudioNodes(l)}).catch(function(){return i.audioSupported=!1,Promise.reject("Audio is not supported")});case 5:s.next=9;break;case 7:return this.audioSupported=!1,s.abrupt("return",Promise.reject("Audio is not supported"));case 9:case"end":return s.stop()}},n,this)})),function(){return e.apply(this,arguments)})},{key:"setupAudioNodes",value:function(){var e=(0,N.Z)(A().mark(function n(i){var s,l,c,r=this;return A().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.prev=0,u.next=3,this.audioContext.resume();case 3:u.next=8;break;case 5:u.prev=5,u.t0=u.catch(0),an.error(u.t0);case 8:s=this.audioContext.createMediaStreamSource(i),(l=this.audioContext.createScriptProcessor(4096,1,1)).onaudioprocess=function(m){if(r.recording){var v=m.inputBuffer.getChannelData(0);r.streamBuffer.push(new Float32Array(v)),r.streamBufferLength+=v.length,r.analyse()}},(c=this.audioContext.createAnalyser()).minDecibels=-90,c.maxDecibels=-10,c.smoothingTimeConstant=.85,s.connect(c),c.connect(l),l.connect(s.context.destination),this.analyserNode=c;case 19:case"end":return u.stop()}},n,this,[[0,5]])}));return function(n){return e.apply(this,arguments)}}()},{key:"startRecording",value:function(){var e=(0,N.Z)(A().mark(function n(i,r){var s;return A().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.recording&&this.audioSupported){c.next=2;break}return c.abrupt("return");case 2:return this.onSilence=i||function(){},this.visualizer=r||function(){},s=this.audioContext,c.prev=5,c.next=8,s.resume();case 8:c.next=13;break;case 10:c.prev=10,c.t0=c.catch(5),an.error(c.t0);case 13:this.start=Date.now(),this.recording=!0;case 15:case"end":return c.stop()}},n,this,[[5,10]])}));return function(n,i){return e.apply(this,arguments)}}()},{key:"stopRecording",value:function(){!this.audioSupported||(this.recording=!1)}},{key:"clear",value:function(){this.stopRecording(),this.streamBufferLength=0,this.streamBuffer=[]}},{key:"play",value:function(t){var n=this;if(t&&this.audioSupported){var i=new Blob([t]);return new Promise(function(r,s){var l=new FileReader;l.onload=function(){n.playbackSource&&n.playbackSource.disconnect(),n.playbackSource=n.audioContext.createBufferSource(),n.audioContext.decodeAudioData(l.result,function(m){n.playbackSource.buffer=m,n.playbackSource.connect(n.audioContext.destination),n.playbackSource.onended=function(){return r()},n.playbackSource.start(0)},function(m){return s(m)})},l.onerror=function(){return s()},l.readAsArrayBuffer(i)})}}},{key:"stop",value:function(){this.playbackSource&&this.playbackSource.stop()}},{key:"analyse",value:function(){if(this.audioSupported){var t=this.analyserNode;t.fftSize=2048;var n=t.fftSize,i=new Uint8Array(n),r=this.options.amplitude,s=this.options.time;t.getByteTimeDomainData(i),this.visualizer(i,n);for(var l=0;l<n;l++){var c=i[l]/128-1;(c>r||c<-1*r)&&(this.start=Date.now())}Date.now()-this.start>s&&this.onSilence()}}},{key:"exportWAV",value:function(){var e=(0,N.Z)(A().mark(function n(){var i,s,l=arguments;return A().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(i=l.length>0&&void 0!==l[0]?l[0]:16e3,this.audioSupported){d.next=3;break}return d.abrupt("return");case 3:return s=Ot(this.streamBuffer,this.streamBufferLength,this.audioContext.sampleRate,i),this.clear(),d.abrupt("return",s);case 7:case"end":return d.stop()}},n,this)}));return function(){return e.apply(this,arguments)}}()}]),a;var e}();!function(a){a[a.Initial=0]="Initial",a[a.Listening=1]="Listening",a[a.SendingText=2]="SendingText",a[a.SendingVoice=3]="SendingVoice",a[a.Error=4]="Error"}(y||(y={})),function(a){a.Bot="bot",a.User="user"}(C||(C={})),function(a){a[a.Recoverable=0]="Recoverable",a[a.Unrecoverable=1]="Unrecoverable"}(T||(T={}));var sn=function(){function a(e){var t=this;(0,de.Z)(this,a),(0,_.r)(this,e),this.clearOnComplete=!1,this.conversationModeOn=!1,this.botTitle=k.T.CHATBOT_TITLE,this.voiceEnabled=!1,this.textEnabled=!0,this.silenceTime=1500,this.silenceThreshold=.2,this.messages=[],this.text="",this.chatState=y.Initial,this.messageJSX=function(n){var i=n.map(function(s){return(0,_.h)("div",{class:"bubble ".concat(s.from)},s.content)});if(t.chatState===y.SendingText||t.chatState===y.SendingVoice){var r=t.chatState===y.SendingText?C.Bot:C.User;i.push((0,_.h)("div",{class:"bubble ".concat(r)},(0,_.h)("div",{class:"dot-flashing ".concat(r)},(0,_.h)("span",{class:"dot left"}),(0,_.h)("span",{class:"dot middle"}),(0,_.h)("span",{class:"dot right"}))))}return i},this.chatCompleted=(0,_.c)(this,"chatCompleted",7)}return(0,ce.Z)(a,[{key:"submitHandler",value:function(t){this.sendTextMessage()}},{key:"componentWillLoad",value:function(){if(!J||"function"!=typeof J.onComplete)throw new Error(dn.c);this.validateProps()}},{key:"componentDidRender",value:function(){var t=this.element.shadowRoot.querySelector(".body");t.scrollTop=t.scrollHeight}},{key:"validateProps",value:function(){var t=this;if(this.voiceEnabled||this.textEnabled)if(this.botName){this.welcomeMessage&&this.appendToChat(this.welcomeMessage,C.Bot),this.voiceEnabled&&(this.audioRecorder=new Ut({time:this.silenceTime,amplitude:this.silenceThreshold}),this.audioRecorder.init().catch(function(i){t.setError(i,T.Recoverable)}));try{J.onComplete(this.botName,function(r,s){t.chatCompleted.emit({data:s,err:r}),t.clearOnComplete?t.reset():t.chatState=y.Initial})}catch(i){this.setError(i,T.Unrecoverable)}}else this.setError(k.T.NO_BOT_NAME_ERROR,T.Unrecoverable);else this.setError(k.T.CHAT_DISABLED_ERROR,T.Unrecoverable)}},{key:"handleSubmit",value:function(t){t.preventDefault(),this.sendTextMessage()}},{key:"handleMicButton",value:function(){var t=this;this.chatState===y.Initial&&(this.audioRecorder.stop(),this.chatState=y.Listening,this.audioRecorder.startRecording(function(){return t.handleSilence()},function(n,i){return t.visualizer(n,i)}))}},{key:"handleSilence",value:function(){var t=this;this.chatState=y.SendingVoice,this.audioRecorder.stopRecording(),this.audioRecorder.exportWAV().then(function(n){t.sendVoiceMessage(n)})}},{key:"handleTextChange",value:function(t){this.text=t.target.value}},{key:"handleCancelButton",value:function(){this.audioRecorder.clear(),this.chatState=y.Initial}},{key:"handleToastClose",value:function(t){this.error=void 0,t===T.Recoverable&&(this.chatState=y.Initial)}},{key:"visualizer",value:function(t,n){!function(e,t,n){if(n){if(!(0,ue.lC)().isBrowser)throw new Error("Visualization is not supported on non-browsers.");var i=n.getBoundingClientRect(),r=i.width,s=i.height;n.width=r,n.height=s;var l=n.getContext("2d");l.fillStyle="white",l.clearRect(0,0,r,s),requestAnimationFrame(function(){l.fillRect(0,0,r,s),l.lineWidth=1;var u=getComputedStyle(document.documentElement).getPropertyValue("--amplify-primary-color");l.strokeStyle=u&&""!==u?u:"#ff9900",l.beginPath();for(var m=1*r/t,v=0,g=0;g<t||g%3==0;g++){var S=e[g]/128*s/2;0===g?l.moveTo(v,S):l.lineTo(v,S),v+=m}l.lineTo(n.width,n.height/2),l.stroke()})}}(t,n,this.element.shadowRoot.querySelector("canvas"))}},{key:"sendTextMessage",value:(e=(0,N.Z)(A().mark(function n(){var i,r;return A().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(0!==this.text.length&&this.chatState===y.Initial){l.next=2;break}return l.abrupt("return");case 2:return i=this.text,this.text="",this.appendToChat(i,C.User),this.chatState=y.SendingText,l.prev=6,l.next=9,J.send(this.botName,i);case 9:r=l.sent,l.next=16;break;case 12:return l.prev=12,l.t0=l.catch(6),this.setError(l.t0,T.Recoverable),l.abrupt("return");case 16:r.message&&this.appendToChat(r.message,C.Bot),this.chatState=y.Initial;case 18:case"end":return l.stop()}},n,this,[[6,12]])})),function(){return e.apply(this,arguments)})},{key:"sendVoiceMessage",value:function(){var e=(0,N.Z)(A().mark(function n(i){var s,l,c,r=this;return A().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s={content:i,options:{messageType:"voice"}},u.prev=1,u.next=4,J.send(this.botName,s);case 4:l=u.sent,u.next=11;break;case 7:return u.prev=7,u.t0=u.catch(1),this.setError(u.t0,T.Recoverable),u.abrupt("return");case 11:return this.chatState=y.Initial,c=l.dialogState,l.inputTranscript&&this.appendToChat(l.inputTranscript,C.User),this.appendToChat(l.message,C.Bot),u.next=17,this.audioRecorder.play(l.audioStream).then(function(){r.conversationModeOn&&"Fulfilled"!==c&&"Failed"!==c&&r.chatState===y.Initial&&r.handleMicButton()}).catch(function(m){return r.setError(m,T.Recoverable)});case 17:case"end":return u.stop()}},n,this,[[1,7]])}));return function(n){return e.apply(this,arguments)}}()},{key:"appendToChat",value:function(t,n){this.messages=[].concat((0,on.Z)(this.messages),[{content:t,from:n}])}},{key:"setError",value:function(t,n){var i="string"==typeof t?t:t.message;this.chatState=y.Error,this.error={message:i,errorType:n}}},{key:"reset",value:function(){this.chatState=y.Initial,this.text="",this.error=void 0,this.messages=[],this.welcomeMessage&&this.appendToChat(this.welcomeMessage,C.Bot),this.audioRecorder&&this.audioRecorder.clear()}},{key:"listeningFooterJSX",value:function(){var t=this;return[(0,_.h)("canvas",{height:"50"}),(0,_.h)("amplify-button",{"data-test":"chatbot-cancel-button",handleButtonClick:function(){return t.handleCancelButton()},class:"icon-button",variant:"icon",icon:"ban"})]}},{key:"footerJSX",value:function(){var t=this;return this.chatState===y.Listening?this.listeningFooterJSX():[(0,_.h)("amplify-input",{placeholder:Q.o.get(this.textEnabled?k.T.TEXT_INPUT_PLACEHOLDER:k.T.VOICE_INPUT_PLACEHOLDER),description:"text",handleInputChange:function(c){return t.handleTextChange(c)},value:this.text,disabled:this.chatState===y.Error||!this.textEnabled}),this.voiceEnabled&&(0,_.h)("amplify-button",{"data-test":"chatbot-mic-button",handleButtonClick:function(){return t.handleMicButton()},class:"icon-button",variant:"icon",icon:"microphone",disabled:this.chatState===y.Error||this.chatState!==y.Initial}),this.textEnabled&&(0,_.h)("amplify-button",{"data-test":"chatbot-send-button",class:"icon-button",variant:"icon",icon:"send",handleButtonClick:function(){return t.sendTextMessage()},disabled:this.chatState===y.Error||this.chatState!==y.Initial})]}},{key:"errorToast",value:function(){var t=this;if(this.error){var n=this.error,r=n.errorType;return(0,_.h)("amplify-toast",{message:Q.o.get(n.message),handleClose:function(){return t.handleToastClose(r)}})}}},{key:"render",value:function(){var t=this;return(0,_.h)(_.H,null,(0,_.h)("div",{class:"amplify-chatbot"},(0,_.h)("slot",{name:"header"},(0,_.h)("div",{class:"header","data-test":"chatbot-header"},Q.o.get(this.botTitle))),(0,_.h)("div",{class:"body","data-test":"chatbot-body"},this.messageJSX(this.messages)),(0,_.h)("form",{onSubmit:function(i){return t.handleSubmit(i)}},(0,_.h)("div",{class:"footer","data-test":"chatbot-footer"},this.footerJSX())),this.errorToast()))}},{key:"element",get:function(){return(0,_.g)(this)}}]),a;var e}();sn.style=".bot .dot{background-color:var(--bot-dot-color)}.user .dot{background-color:var(--user-dot-color)}.dot-flashing{width:2.625rem}.dot-flashing .dot{display:inline-block;width:0.625rem;height:0.625rem;border-radius:10rem;opacity:0.65}.dot-flashing .left{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:0s;animation-delay:0s}.dot-flashing .middle{margin-left:0.375rem;margin-right:0.375rem;-webkit-animation:dot-flashing 1s infinite linear alternate;animation:dot-flashing 1s infinite linear alternate;-webkit-animation-delay:0.5s;animation-delay:0.5s}.dot-flashing .right{-webkit-animation:dot-flashing 1s infinite alternate;animation:dot-flashing 1s infinite alternate;-webkit-animation-delay:1s;animation-delay:1s}@-webkit-keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}@keyframes dot-flashing{0%{opacity:0.65}50%,100%{opacity:0.1}}:host{--width:28.75rem;--height:37.5rem;--header-color:var(--amplify-secondary-color);--header-size:var(--amplify-text-lg);--bot-background-color:rgb(230, 230, 230);--bot-text-color:black;--bot-dot-color:var(--bot-text-color);--user-background-color:var(--amplify-blue);--user-text-color:var(--amplify-white);--user-dot-color:var(--user-text-color)}.amplify-chatbot{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-direction:column;flex-direction:column;background-color:var(--background-color);border-radius:0.375rem;-webkit-box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);box-shadow:0.0625rem 0rem 0.25rem 0 rgba(0, 0, 0, 0.15);-webkit-box-sizing:border-box;box-sizing:border-box;font-family:var(--amplify-font-family);margin-bottom:1rem;width:100%;height:var(--height);max-width:var(--width)}@media (min-width: 672px){.amplify-chatbot{width:var(--width)}}.header{padding:1.25rem 0.375rem 1.25rem 0.375rem;color:var(--header-color);font-size:var(--header-size);font-weight:bold;text-align:center;word-wrap:break-word}.body{border-top:0.0625rem solid rgba(0, 0, 0, 0.05);padding:1.5rem 1rem 0 1rem;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;overflow:auto}.bubble{max-width:100%;padding:0.8em 1.4em;text-align:left;word-wrap:break-word;margin-bottom:0.625rem}.bot{margin-right:auto;background-color:var(--bot-background-color);color:var(--bot-text-color);border-radius:1.5rem 1.5rem 1.5rem 0}.user{margin-left:auto;background-color:var(--user-background-color);color:var(--user-text-color);border-radius:1.5rem 1.5rem 0 1.5rem}.footer{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top:0.062rem solid rgba(0, 0, 0, 0.05);padding-right:0.625rem;min-height:3.125rem}.footer amplify-input{--border:none;--margin:0;-ms-flex-positive:1;flex-grow:1}canvas{margin-left:0.625rem;margin-right:0.625rem;-ms-flex-positive:1;flex-grow:1;height:3.125rem}.icon-button{--icon-height:1.25rem;--icon-fill:var(--amplify-primary-color);--padding:0.625rem;--width:auto}"}}]);