New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vivocha/client-interaction-core

Package Overview
Dependencies
Maintainers
10
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vivocha/client-interaction-core - npm Package Compare versions

Comparing version 6.1.2 to 6.1.3

2

bundles/vivocha-client-interaction-core.umd.min.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@ngrx/store"),require("@ngx-translate/core"),require("@vivocha/public-entities/dist/wrappers/data_collection"),require("rxjs/Subject"),require("@angular/common"),require("@angular/common/http"),require("@ngx-translate/http-loader"),require("@ngrx/store-devtools")):"function"==typeof define&&define.amd?define("@vivocha/client-interaction-core",["exports","@angular/core","@ngrx/store","@ngx-translate/core","@vivocha/public-entities/dist/wrappers/data_collection","rxjs/Subject","@angular/common","@angular/common/http","@ngx-translate/http-loader","@ngrx/store-devtools"],e):e((t.vivocha=t.vivocha||{},t.vivocha["client-interaction-core"]={}),t.ng.core,t.store,t.core$1,t.data_collection,t.Rx,t.ng.common,t.ng.common.http,t.httpLoader,t.storeDevtools)}(this,function(t,e,i,o,c,n,a,s,r,u){"use strict";function d(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var o,n,a=i.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(o=a.next()).done;)s.push(o.value)}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=a["return"])&&i.call(a)}finally{if(n)throw n.error}}return s}function A(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(d(arguments[e]));return t}var p="[Message] New message",l="[Message] Update message",h="[Message] Remove message",f=function(t){this.payload=t,this.type=p},g=function(t){this.payload=t,this.type=l},v=function(t){this.payload=t,this.type=h},m=function(){function t(t){this.store=t}return t.prototype.addChatMessage=function(t,e,i){var o=(new Date).getTime().toString(),n={id:o,text:t.body,type:"chat",isAgent:e,time:this.getChatTimestamp(t.ts)};return e&&(n.agent=e),t.meta&&(n.meta=t.meta),i&&(n.visitorNick=i),this.store.dispatch(new f(n)),o},t.prototype.addCustomMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,code:"message",type:"custom",body:Object.assign({},t)};return this.store.dispatch(new f(i)),e},t.prototype.addLocalMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,text:t,type:"chat",isAgent:!1,time:this.getChatTimestamp()};return this.store.dispatch(new f(i)),e},t.prototype.addQuickRepliesMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,code:"message",type:"quick-replies",body:t.body,quick_replies:t.quick_replies,quick_replies_orientation:t.quick_replies_orientation,time:this.getChatTimestamp()};return e&&(o.agent=e),this.store.dispatch(new f(o)),i},t.prototype.addTemplateMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,type:"template",template:t.template.type,elements:t.template.elements,buttons:t.template.buttons,time:this.getChatTimestamp()};return e&&(o.agent=e),this.store.dispatch(new f(o)),i},t.prototype.getChatTimestamp=function(t){var e;return e=t?new Date(t):new Date,(9<parseInt(e.getHours())?e.getHours():"0"+e.getHours())+":"+(9<parseInt(e.getMinutes())?e.getMinutes():"0"+e.getMinutes())},t.prototype.removeMessage=function(t){this.store.dispatch(new v(t))},t.prototype.sendRequestMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,type:"request",text:t.toUpperCase()};return this.store.dispatch(new f(i)),e},t.prototype.sendSystemMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,type:"system",text:t};return e&&(o.context=e),this.store.dispatch(new f(o)),i},t.prototype.updateQuickReply=function(t){this.store.dispatch(new g({id:t,patch:{replied:!0}}))},t}();m.decorators=[{type:e.Injectable}],m.ctorParameters=function(){return[{type:i.Store}]};var y="[Widget] Closed by Agent",S="[Widget] Closed by Visitor",C="[Widget] Contact Failed",b="[Widget] Incoming Media",x="[Widget] Init Chat",O="[Widget] Init Context",M="[Widget] Init Multimedia",w="[Widget] Init Protocol",T="[Widget] Is Offering",j="[Widget] Is Uploading",I="[Widget] Is Writing",R="[Widget] In Video Transit",V="[Widget] Mark as read",P="[Widget] Media Change",E="[Widget] Media Offer",q="[Widget] Mute in progress",k="[Widget] Mute Success",B="[Widget] New Message",W="[Widget] Offer Accepted",z="[Widget] Offer Rejected",D="[Widget] Set Agent",F="[Widget] Set Auto Chat",U="[Widget] Set Error",N="[Widget] Set Fullscreen",_="[Widget] Set Minimized",L="[Widget] Set Minimized Media",G="[Widget] Set Normal",Q="[Widget] Set Top Bar",H="[Widget] Fullscreen Chat",J="[Widget] Show Close Panel",Y="[Widget] Show Queue Panel",Z="[Widget] Show Upload Panel",$="[Widget] Toggle Emoji Panel",K="[Widget] Upload Completed",X=function(){this.type=y},tt=function(){this.type=S},et=function(){this.type=C},it=function(t){this.payload=t,this.type=b},ot=function(t){this.payload=t,this.type=x},nt=function(t){this.payload=t,this.type=O},at=function(t){this.payload=t,this.type=M},st=function(t){this.payload=t,this.type=w},ct=function(t){this.payload=t,this.type=T},rt=function(){this.type=j},ut=function(t){this.payload=t,this.type=I},dt=function(t){this.payload=t,this.type=R},pt=function(){this.type=V},lt=function(t){this.payload=t,this.type=P},ht=function(t){this.payload=t,this.type=E},ft=function(){this.type=q},gt=function(t){this.payload=t,this.type=k},vt=function(){this.type=B},mt=function(){this.type=W},yt=function(){this.type=z},St=function(t){this.payload=t,this.type=D},Ct=function(){this.type=F},bt=function(){this.type=U},xt=function(){this.type=N},Ot=function(){this.type=_},Mt=function(t){this.payload=t,this.type=L},wt=function(){this.type=G},Tt=function(t){this.payload=t,this.type=Q},jt=function(t){this.payload=t,this.type=H},At=function(t){this.payload=t,this.type=J},It=function(){this.type=Y},Rt=function(t){this.payload=t,this.type=Z},Vt=function(){this.type=$},Pt=function(){this.type=K},Et={context:{loaded:!1,translationLoaded:!1},media:{isMinimized:!0},topBar:{},protocol:{contactStarted:!1}};function qt(t,e){switch(void 0===t&&(t=Et),e.type){case y:var i=Object.assign({},t.context,{closedByAgent:!0,showClosePanel:!1});return Object.assign({},t,{context:i});case S:i=Object.assign({},t.context,{closedByVisitor:!0,showClosePanel:!1});return Object.assign({},t,{context:i});case C:i=Object.assign({},t.context,{contactCreationFailed:!0,hasError:!0});return Object.assign({},t,{context:i});case x:var o={isVisible:"chat"===t.protocol.requestedMedia,canUploadFiles:t.context.variables.showUploadButton,canSendEmoji:t.context.variables.showEmojiButton,uploadPanelOpened:!1,emojiPanelOpened:!1,notRead:0};return Object.assign({},t,{chat:o});case O:i=Object.assign({},t.context,Object.assign({},e.payload,{isUiLoaded:!0}));return Object.assign({},t,{context:i});case M:var n={isVisible:"video"===t.protocol.requestedMedia||"voice"===t.protocol.requestedMedia,isMinimized:!1};return Object.assign({},t,{media:n});case w:return Object.assign({},t,{protocol:e.payload});case j:i=Object.assign({},t.context,{isUploading:!0,uploadCompleted:!1});return Object.assign({},t,{context:i});case I:var a=Object.assign({},t.chat,{isWriting:e.payload});return Object.assign({},t,{chat:a});case V:a=Object.assign({},t.chat,{notRead:0});return Object.assign({},t,{chat:a});case P:n=Object.assign({},t.media,{media:e.payload});var s=Object.assign({},t.protocol,{incomingOffer:!1,isOffering:!1,offeringMedia:""});return Object.assign({},t,{media:n,protocol:s});case b:s=Object.assign({},t.protocol,{incomingMedia:e.payload,incomingOffer:!0}),n=Object.assign({},t.media,{isVisible:!0});return Object.assign({},t,{protocol:s,media:n});case E:s=Object.assign({},t.protocol,{offer:e.payload});return Object.assign({},t,{protocol:s});case T:s=Object.assign({},t.protocol,{offeringMedia:e.payload,isOffering:!0}),n=Object.assign({},t.media,{isVisible:!0});return Object.assign({},t,{protocol:s,media:n});case R:s=Object.assign({},t.protocol,{inVideoTransit:e.payload});return Object.assign({},t,{protocol:s});case q:n=Object.assign({},t.media,{muteInProgress:!0});return Object.assign({},t,{media:n});case k:n=Object.assign({},t.media,{muteInProgress:!1,isMuted:e.payload});return Object.assign({},t,{media:n});case B:if(t.context.isMinimized||!t.chat.isVisible||t.media.isVisible&&!t.media.isMinimized){a=Object.assign({},t.chat,{notRead:t.chat.notRead+1});return Object.assign({},t,{chat:a})}return t;case W:case z:s=Object.assign({},t.protocol,{incomingOffer:!1,isOffering:!1,offeringMedia:""});return Object.assign({},t,{protocol:s});case D:a=Object.assign({},t.chat,{isAutoChat:!1}),i=Object.assign({},t.context,{showQueuePanel:!1});return Object.assign({},t,{agent:e.payload,context:i,chat:a});case F:o={isVisible:!0,isAutoChat:!0,canUploadFiles:!1,canSendEmoji:!1,uploadPanelOpened:!1,emojiPanelOpened:!1,notRead:0};return Object.assign({},t,{chat:o});case U:i=Object.assign({},t.context,{hasError:!0,showQueuePanel:!0});return Object.assign({},t,{context:i});case N:i=Object.assign({},t.context,{isFullScreen:!0,isMinimized:!1});return Object.assign({},t,{context:i});case _:i=Object.assign({},t.context,{isMinimized:!0});return Object.assign({},t,{context:i});case L:n=Object.assign({},t.media,{isMinimized:e.payload});return Object.assign({},t,{media:n});case G:i=Object.assign({},t.context,{isMinimized:!1,isFullScreen:!1});return Object.assign({},t,{context:i});case Q:var c=Object.assign({},t.topBar,e.payload);return Object.assign({},t,{topBar:c});case H:a=Object.assign({},t.chat,{showOnFullScreen:e.payload});return Object.assign({},t,{chat:a});case J:i=Object.assign({},t.context,{showClosePanel:e.payload});return Object.assign({},t,{context:i});case Y:i=Object.assign({},t.context,{showQueuePanel:!0});return Object.assign({},t,{context:i});case Z:a=Object.assign({},t.chat,{uploadPanelOpened:e.payload});return Object.assign({},t,{chat:a});case $:a=Object.assign({},t.chat,{emojiPanelOpened:!t.chat.emojiPanelOpened});return Object.assign({},t,{chat:a});case K:i=Object.assign({},t.context,{isUploading:!1,uploadCompleted:!0}),a=Object.assign({},t.chat,{uploadPanelOpened:!1});return Object.assign({},t,{context:i,chat:a});default:return t}}var kt={list:[]};function Bt(t,e){switch(void 0===t&&(t=kt),e.type){case l:var i=t.list.map(function(t){if(t.id===e.payload.id){Object.assign({},t,e.payload.patch);return Object.assign({},t,e.payload.patch)}return t});return Object.assign({},t,{list:A(i)});case p:return Object.assign({},t,{list:A(t.list,[e.payload])});case h:return Object.assign({},t,{list:t.list.filter(function(t){return t.id!==e.payload})});default:return t}}var Wt="[Data Collection] Loaded",zt="[Data Collection] Completed",Dt="[Data Collection] Selected",Ft=function(t){this.payload=t,this.type=Wt},Ut=function(t){this.payload=t,this.type=zt},Nt=function(t){this.payload=t,this.type=Dt},_t={completed:!1};function Lt(t,e){switch(void 0===t&&(t=_t),e.type){case Wt:return Object.assign({},t,{items:A(e.payload)});case zt:return Object.assign({},t,{completed:!0,creationOptions:e.payload});case Dt:return Object.assign({},t,{selectedItem:e.payload});default:return t}}var Gt="[Survey] Completed",Qt="[Survey] Selected",Ht=function(t){this.payload=t,this.type=Gt},Jt=function(t){this.payload=t,this.type=Qt},Yt={completed:!1};function Zt(t,e){switch(void 0===t&&(t=Yt),e.type){case Gt:return Object.assign({},t,{completed:!0,surveyToSend:e.payload});case Qt:return Object.assign({},t,{item:e.payload});default:return t}}var $t="[Context] Load Success",Kt=function(t){this.payload=t,this.type=$t},Xt={loaded:!1};function te(t,e){switch(void 0===t&&(t=Xt),e.type){case $t:return Object.assign({},t,e.payload);default:return t}}var ee={widget:qt,messages:Bt,dataCollection:Lt,survey:Zt,context:te},ie=i.createFeatureSelector("widget"),oe=i.createFeatureSelector("messages"),ne=i.createFeatureSelector("dataCollection"),ae=i.createFeatureSelector("survey"),se=i.createFeatureSelector("context"),ce=i.createSelector(oe,function(s){return{list:A(s.list.map(function(t,e){var i=!1,o=!1,n=s.list[e+1],a=s.list[e-1];return o=!a||!!(t.type!==a.type||t.isAgent!=a.isAgent||t.agent&&a.agent&&t.agent.id!=a.agent.id),i=!n||!!(t.type!==n.type||t.isAgent!=n.isAgent||a&&t.agent&&a.agent&&t.agent.id!=a.agent.id),Object.assign({},t,{isLast:i,isFirst:o})}))}}),re=i.createSelector(ie,ce,ne,ae,function(t,e,i,o){var n=t.media.media,a=n&&t.media.media.Voice&&(t.media.media.Voice.rx||t.media.media.Voice.tx),s=n&&t.media.media.Video,c=s&&t.media.media.Video.tx,r=s&&t.media.media.Video.rx,u=c&&t.media.media.Video.data&&t.media.media.Video.data.tx_stream&&!!t.media.media.Video.data.tx_stream.url,d=!!u&&t.media.media.Video.data.tx_stream.url,p=r&&t.media.media.Video.data&&t.media.media.Video.data.rx_stream&&!!t.media.media.Video.data.rx_stream.url,l=!!p&&t.media.media.Video.data.rx_stream.url,h=a&&t.media.media.Voice.data&&t.media.media.Voice.data.rx_stream&&!!t.media.media.Voice.data.rx_stream.url,f=!!h&&t.media.media.Voice.data.rx_stream.url,g=a&&!h,v=c&&u,m=r&&p,y=c&&!u||r&&!p,S=v||m,C=a&&h||v||m,b=g||y,x=t.chat&&!t.chat.uploadPanelOpened&&(t.protocol.incomingOffer||t.protocol.isOffering||b||C),O=t.protocol.canStartAudio&&!a&&!g&&t.agent&&t.agent.is_agent&&"Voice"!==t.protocol.offeringMedia,M=t.protocol.canStartVideo&&t.agent&&t.agent.is_agent&&!c&&!y,w=t.context.showQueuePanel&&i.completed||x&&!t.media.isMinimized&&!t.context.isFullScreen||t.protocol.isOffering||t.protocol.incomingOffer,T=t.context.closedByAgent||t.context.closedByVisitor,j=t.chat&&!t.context.showQueuePanel&&!t.context.showDataCollectionPanel&&!o.item&&!t.protocol.isOffering&&!t.protocol.incomingOffer&&!b&&(!C||C&&t.media.isMinimized)||t.context.isFullScreen;return{agent:t.agent,messages:A(e.list),variables:t.context.variables||{},canMaximize:S,canMinimize:!0,canRemoveApp:t.context.closedByAgent||t.context.closedByVisitor||t.context.showQueuePanel||!t.context.isUiLoaded,canStartAudio:O,canStartVideo:M,connectedWithAgent:t.agent&&t.agent.is_agent,connectedWithBot:t.agent&&t.agent.is_bot,contactCreationFailed:t.context.contactCreationFailed,hasError:t.context.hasError,hasSurvey:!!t.context.survey&&t.protocol.contactStarted&&!t.context.hasError&&!t.context.showQueuePanel,incomingOffer:t.protocol.incomingOffer,incomingMedia:t.protocol.incomingMedia,inVideoTransit:t.protocol.inVideoTransit,isAutoChat:t.chat&&t.chat.isAutoChat,isLoading:!t.context.isUiLoaded,isInQueue:t.context.showQueuePanel&&i.completed,isChatVisible:j,isClosed:T,isClosedByAgent:t.context.closedByAgent,isClosedByVisitor:t.context.closedByVisitor,isMediaConnected:C,isMediaConnecting:b,isMediaVisible:x,isMediaMinimized:t.media.isMinimized&&!t.protocol.isOffering&&!t.protocol.incomingOffer,isMinimized:t.context.isMinimized,isMobile:t.context.isMobile,isMuted:t.media.isMuted,isOffering:t.protocol.isOffering,isFullScreen:t.context.isFullScreen&&!T,isSendAreaVisible:j&&!t.chat.uploadPanelOpened,isUploading:t.context.isUploading,isWriting:t.chat&&t.chat.isWriting,notRead:t.chat?t.chat.notRead:0,offeringMedia:t.protocol.offeringMedia,selectedDataCollection:i.selectedItem,selectedSurvey:o.item,showCloseModal:t.context.showClosePanel,showChatOnFullScreen:t.chat&&t.chat.showOnFullScreen,showDataCollectionPanel:!i.completed&&i.selectedItem,showEmojiPanel:t.chat&&t.chat.emojiPanelOpened,showUploadPanel:t.chat&&t.chat.uploadPanelOpened,showSurveyPanel:!!o.item,surveyCompleted:o.completed,topBarTitle:w?"":t.topBar.title,topBarSubtitle:w?"":t.topBar.subtitle,topBarAvatar:w?"":t.topBar.avatar,translationLoaded:t.context.translationLoaded,uploadCompleted:t.context.uploadCompleted,voiceRxStream:f,videoRxStream:l,videoTxStream:d}});var ue=function(){function t(){}return Object.defineProperty(t.prototype,"nativeWindow",{get:function(){return window},enumerable:!0,configurable:!0}),t}();ue.decorators=[{type:e.Injectable}];var de=function(){function t(t){var e=this;this.store=t,this.store.select(ie).subscribe(function(t){e.currentState=t})}return t.prototype.hideChat=function(){this.store.dispatch(new Mt(!1))},t.prototype.initializeChat=function(t){console.log("initializing chat",t),this.store.dispatch(new ot(t))},t.prototype.initializeContext=function(t){this.store.dispatch(new Kt(t)),this.store.dispatch(new nt(t))},t.prototype.initializeMedia=function(t){this.initializeChat(t),this.initializeMultimedia(t),this.setMediaState(t)},t.prototype.initializeMultimedia=function(t){this.store.dispatch(new at(t))},t.prototype.initializeProtocol=function(t,e){this.store.dispatch(new st({requestedMedia:t.requestedMedia,canStartAudio:"both"===t.media.voice||"visitor"===t.media.voice,canStartVideo:"both"===t.media.video||"visitor"===t.media.video,initialOffer:e.initialOffer,contactStarted:!0}))},t.prototype.loadDataCollections=function(t){this.store.dispatch(new Ft(t))},t.prototype.newMessageReceived=function(){this.store.dispatch(new vt)},t.prototype.resetTopBar=function(){this.store.dispatch(new Tt({title:"",subtitle:"",avatar:""}))},t.prototype.selectDataCollection=function(t){this.store.dispatch(new Nt(t)),this.store.dispatch(new Tt({title:"STRINGS.QUEUE.TOPBAR.TITLE",subtitle:t.labelId,avatar:""}))},t.prototype.setOfferAccepted=function(){this.store.dispatch(new mt)},t.prototype.setAgent=function(t){this.store.dispatch(new St(t))},t.prototype.setAutoChat=function(){this.store.dispatch(new Ct)},t.prototype.setClosedByAgent=function(){this.store.dispatch(new X)},t.prototype.setClosedByVisitor=function(){this.store.dispatch(new tt)},t.prototype.setCloseModal=function(t){this.store.dispatch(new At(t))},t.prototype.setCreationFailed=function(){this.store.dispatch(new et)},t.prototype.setDataCollectionCompleted=function(t){this.store.dispatch(new Ut(t))},t.prototype.setDissuasion=function(){this.store.dispatch(new bt)},t.prototype.setFullScreenChat=function(t){this.store.dispatch(new jt(t)),this.store.dispatch(new pt)},t.prototype.setFullScreen=function(){this.store.dispatch(new xt)},t.prototype.setHangUpState=function(){this.store.dispatch(new wt)},t.prototype.setNormalScreen=function(){this.store.dispatch(new wt),this.store.dispatch(new jt(!1))},t.prototype.setIncomingMedia=function(t){this.store.dispatch(new it(t))},t.prototype.setInTransit=function(t){this.store.dispatch(new dt(t))},t.prototype.setIsOffering=function(t){this.store.dispatch(new ct(t))},t.prototype.setIsWriting=function(t){this.store.dispatch(new ut(t))},t.prototype.setMediaOffer=function(t){this.store.dispatch(new ht(t))},t.prototype.setMediaState=function(t){console.log("setting media state",t),this.store.dispatch(new lt(t))},t.prototype.setMinimizedState=function(){this.store.dispatch(new Ot)},t.prototype.setMinimizedMedia=function(){this.store.dispatch(new Mt(!0)),this.store.dispatch(new pt)},t.prototype.setMuted=function(t){this.store.dispatch(new gt(t))},t.prototype.setMuteInProgress=function(){this.store.dispatch(new ft)},t.prototype.setNormalState=function(){this.store.dispatch(new wt),this.store.dispatch(new pt)},t.prototype.setOfferRejected=function(){this.store.dispatch(new yt)},t.prototype.setTopBar=function(t){this.store.dispatch(new Tt({title:t.title,subtitle:t.subtitle}))},t.prototype.setTopBarAvatar=function(t){this.store.dispatch(new Tt({avatar:t}))},t.prototype.setTopBarSubtitle=function(t){this.store.dispatch(new Tt({subtitle:t}))},t.prototype.setTopBarTitle=function(t){this.store.dispatch(new Tt({title:t}))},t.prototype.setTopBarWithAvatar=function(t,e,i){this.store.dispatch(new Tt({title:e,subtitle:i,avatar:t}))},t.prototype.setTopBarWithAgentInfo=function(t){this.store.dispatch(new Tt({title:t.nick,subtitle:"STRINGS.QUEUE.TOPBAR.CONNECTED",avatar:t.avatar}))},t.prototype.setSurveyPanel=function(){this.store.dispatch(new Tt({title:"STRINGS.SURVEY.TITLE",subtitle:"STRINGS.SURVEY.SUBTITLE"}))},t.prototype.setUploadPanel=function(t){this.store.dispatch(new Rt(t))},t.prototype.setUploading=function(){this.store.dispatch(new rt)},t.prototype.setUploaded=function(){this.store.dispatch(new Pt)},t.prototype.showQueuePanel=function(){this.store.dispatch(new It)},t.prototype.toggleEmojiPanel=function(){this.store.dispatch(new Vt)},t}();de.decorators=[{type:e.Injectable}],de.ctorParameters=function(){return[{type:i.Store}]};var pe=function(){function t(t,e,i,o,n){this.store=t,this.uiService=e,this.wref=i,this.ts=o,this.zone=n,this.isMobile=!1,this.window=i.nativeWindow,this.parseIframeUrl(),this.checkForVivocha()}return t.prototype.checkForVivocha=function(){var e=this;this.window.vivocha&&this.window.vivocha.ready?this.window.vivocha.ready(this.busId).then(function(){e.window.vivocha.pageRequest("getContext").then(function(t){e.zone.run(function(){e.vivocha=e.window.vivocha,e.isMobile=e.window.vivocha.isMobile(),e.context=t,e.dispatchContext(t)})})}):setTimeout(function(){return e.checkForVivocha()},200)},t.prototype.dispatchContext=function(e){var i=this;this.ts.use(e.language),this.ts.getTranslation(e.language).toPromise().then(function(t){i.uiService.initializeContext(Object.assign({loaded:!0,translationLoaded:!0,isMobile:i.isMobile,busId:i.busId,acct:i.acct,world:i.world,variables:e.campaign.channels.web.interaction.variables},e))})},t.prototype.getVivocha=function(){return this.vivocha},t.prototype.parseIframeUrl=function(){if(-1!==this.window.location.hash.indexOf(";")){var t=this.window.location.hash.substr(2).split(";");this.busId=t[0],this.acct=t[1],this.world=t[2]}},t.prototype.ready=function(){return this.store.select(se)},t}();pe.decorators=[{type:e.Injectable}],pe.ctorParameters=function(){return[{type:i.Store},{type:de},{type:ue},{type:o.TranslateService},{type:e.NgZone}]};var le=function(){function t(t,e){this.store=t,this.uiService=e,this.contactOptions={data:[]},this.selectedIdx=0}return t.prototype.setInitialContext=function(t){this.context=t},t.prototype.onDataCollectionCompleted=function(){return this.store.select(ne)},t.prototype.onSurveyCompleted=function(){return this.store.select(ae)},t.prototype.processDataCollections=function(){this.hasDataCollection()?this.processDcByIdx(0):this.uiService.setDataCollectionCompleted({})},t.prototype.processDcByIdx=function(t){this.selectedIdx=t,this.hasVisibleFields(this.context.dataCollections[t])?this.uiService.selectDataCollection(this.context.dataCollections[t]):this.submitHiddenDataCollection(this.context.dataCollections[t])},t.prototype.hasDataCollection=function(){return!!(this.context.dataCollections&&0<this.context.dataCollections.length)&&(this.uiService.loadDataCollections(this.context.dataCollections),!0)},t.prototype.hasSurvey=function(){return this.context&&!!this.context.survey},t.prototype.hasVisibleFields=function(t){var i=!1;return t.fields&&t.fields.forEach(function(t){var e="undefined"!=typeof t.defaultConstant;-1===["visitor","both"].indexOf(t.hidden)&&(!e||e&&t.editIfDefault)&&(i=!0)}),i},t.prototype.showSurvey=function(){this.hasSurvey()&&(this.store.dispatch(new Jt(this.context.survey)),this.uiService.setSurveyPanel())},t.prototype.submitDataCollection=function(t){for(var e=t.dcDefinition,i=t.dcData,o=0;o<e.fields.length;o++)if("nickname"===e.fields[o].format&&i[e.fields[o].id]){this.contactOptions.nick=i[e.fields[o].id];break}this.contactOptions.data.push(c.objectToDataCollection(i,e.id,e)),this.context.dataCollections[this.selectedIdx+1]?this.processDcByIdx(this.selectedIdx+1):this.uiService.setDataCollectionCompleted(this.contactOptions)},t.prototype.submitHiddenDataCollection=function(t){var i={};t.fields&&t.fields.forEach(function(t){var e="undefined"!=typeof t.defaultConstant;i[t.id]=e?t.defaultConstant.toString():t.defaultConstant});var e={dcDefinition:t,dcData:i};this.submitDataCollection(e)},t.prototype.submitSurvey=function(t){this.store.dispatch(new Ht(t))},t}();le.decorators=[{type:e.Injectable}],le.ctorParameters=function(){return[{type:i.Store},{type:de}]};var he=function(){function t(t){this.store=t,this.previousChannels=[],this.currentChannels=[]}return t.prototype.confirmNeeded=function(t){var e={askForConfirmation:!1,offer:{},media:""};for(var i in t)switch(i){case"Voice":this.isAlreadyConnectedWith("Voice")||"off"===t[i].tx||"off"===t[i].rx||(e.askForConfirmation=!0,e.offer[i]=t[i]);break;case"Video":(!this.isAlreadyConnectedWith("Video")&&"off"!==t[i].tx||"off"!==t[i].rx)&&(this.isAlreadyConnectedWith("Voice")||(e.askForConfirmation=!0,e.offer[i]=t[i]))}return e.offer.Voice&&(e.media="Voice"),e.offer.Video&&(e.media="Video"),e},t.prototype.getChannels=function(e){var i=[];return Object.keys(e).forEach(function(t){(e[t].tx||e[t].rx)&&i.push(t)}),i},t.prototype.getInitialOffer=function(t){switch(t){case"voice":return{Voice:{rx:"required",tx:"required",engine:"WebRTC"},Sharing:{rx:"required",tx:"required"}};case"video":return{Video:{rx:"required",tx:"required",engine:"WebRTC"},Voice:{rx:"required",tx:"required",engine:"WebRTC"},Sharing:{rx:"required",tx:"required"}};default:return{Chat:{rx:"required",tx:"required"},Sharing:{rx:"required",tx:"required"}}}},t.prototype.isAlreadyConnectedWith=function(t){return this.lastMediaChange[t]&&this.lastMediaChange[t].tx&&this.lastMediaChange[t].rx},t.prototype.mergeOffer=function(t){for(var e in t)"Video"===e&&"optional"===t[e].tx&&(t[e].tx="off"),t[e].rx="off"!==t[e].rx,t[e].tx="off"!==t[e].tx;return t},t.prototype.setMediaChange=function(t){this.lastMediaChange=t},t}();he.decorators=[{type:e.Injectable}],he.ctorParameters=function(){return[{type:i.Store}]};var fe=function(){function t(t,e,i,o,n,a){this.store=t,this.dcService=e,this.protocolService=i,this.messageService=o,this.uiService=n,this.zone=a,this.hasReceivedMsgs=!1,this.isClosed=!1,this.isWritingTimeout=3e4,this.autoChat=!1,this.messageArchive=[],this.customActions={}}return t.prototype.acceptAgentRequest=function(t){this.agentRequestCallback(null,!0),this.messageService.removeMessage(this.lastSystemMessageId),this.messageService.sendSystemMessage("STRINGS.MESSAGES."+t.toUpperCase()+"_ACCEPTED")},t.prototype.acceptOffer=function(){this.mergeOffer(this.incomingOffer,this.incomingCallback)},t.prototype.addChatToFullScreen=function(t){this.uiService.setFullScreenChat(t),"chat"!==this.context.requestedMedia&&this.askForUpgrade("Chat")},t.prototype.askForUpgrade=function(e){var i=this;"Chat"!==e&&this.uiService.setIsOffering(e),this.contact.getMediaOffer().then(function(t){t[e]="Chat"===e?{tx:"required",rx:"required"}:{tx:"required",rx:"required",via:"net",engine:"WebRTC"},"Video"===e&&(t.Voice={tx:"required",rx:"required",via:"net",engine:"WebRTC"}),i.contact.offerMedia(t).then(function(){i.zone.run(function(){})},function(t){i.zone.run(function(){i.uiService.setOfferRejected()})})})},t.prototype.attachDataAndCreateContact=function(t){for(var e={data:[]},i=t.dataCollections[0],o={},n=0;n<i.fields.length;n++){var a=i.fields[n];"nickname"===a.format&&a.id&&(e.nick=o[a.id]);var s="undefined"!=typeof a.defaultConstant;a.value=s?a.defaultConstant.toString():a.defaultConstant,o[a.id]=a.value}e.data.push(c.objectToDataCollection(o,i.id,i)),this.createContact(e)},t.prototype.checkForTranscript=function(){var t=this.contact.contact.transcript;for(var e in t){var i=t[e];switch(i.type){case"text":var o=!!i.agent&&this.agent;i.quick_replies?this.messageService.addQuickRepliesMessage(i,this.agent):i.template?this.messageService.addTemplateMessage(i,this.agent):this.messageService.addChatMessage(i,o,this.visitorNick);break;case"attachment":var n=i.meta;n.url=n.originalUrl?n.originalUrl:i.url;var a={body:n.desc||n.originalName,type:"chat",meta:n,from_nick:i.from_nick,from_id:i.from_id};i.agent?this.messageService.addChatMessage(a,this.agent,this.visitorNick):this.messageService.addChatMessage(a,null,this.visitorNick);break;default:console.log("transcript",i.type,i)}}},t.prototype.closeApp=function(){var e=this;this.leave().then(function(t){"failed"===t||e.vivocha.pageRequest("interactionClosed",t),e.vivocha.pageRequest("interactionClosed","destroy")})},t.prototype.closeContact=function(){var e=this;this.leave().then(function(t){e.zone.run(function(){e.uiService.setClosedByVisitor(),e.messageService.sendSystemMessage("STRINGS.MESSAGES.LOCAL_CLOSE"),e.vivocha.setNormalScreen(),e.isClosed=!0,e.context.variables.stayInAppAfterClose||e.dcService.hasSurvey()||(e.vivocha.pageRequest("interactionClosed",t),e.vivocha.pageRequest("interactionClosed","destroy"))})})},t.prototype.closeUploadPanel=function(){this.uiService.setUploadPanel(!1)},t.prototype.createAutoContact=function(t){this.autoChat=!0,this.autoChatInitialData=t,this.uiService.setAutoChat(),this.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"})},t.prototype.createContact=function(t){var i=this,o=this.getContactOptions(t);o&&o.nick&&(this.visitorNick=o.nick),this.vivocha.pageRequest("interactionCreation",o,function(t){void 0===t&&(t=o),console.log("pre-routing callback",t),i.interactionStart=+new Date;var e=1e3*(i.context.routing.dissuasionTimeout||60);i.dissuasionTimer=setTimeout(function(){i.leave("dissuasion").then(function(){i.zone.run(function(){i.uiService.setDissuasion()})})},e),i.uiService.initializeProtocol(i.context,t),i.vivocha.createContact(t).then(function(t){i.zone.run(function(){i.contact=t,i.mapContact()})},function(t){console.log("Failed to create contact",t),i.vivocha.pageRequest("interactionFailed",t.message),i.zone.run(function(){i.uiService.setCreationFailed()})})})},t.prototype.getContactOptions=function(t){var e={campaignId:this.context.campaign.id,version:this.context.campaign.version,channelId:"web",entryPointId:this.context.entryPointId,engagementId:this.context.engagementId,initialOffer:this.protocolService.getInitialOffer(this.context.requestedMedia),lang:this.context.language,vvcu:this.context.page.vvcu,vvct:this.context.page.vvct,first_uri:this.context.page.first_uri,first_title:this.context.page.first_title};return this.context.page.first_uri&&(e.first_uri=this.context.page.first_uri),this.context.page.first_title&&(e.first_title=this.context.page.first_title),t?Object.assign({},e,t):Object.assign({},e)},t.prototype.hangUp=function(){var e=this;this.contact.getMediaOffer().then(function(t){t.Voice&&(t.Voice.tx="off",t.Voice.rx="off"),t.Video&&(t.Video.tx="off",t.Video.rx="off"),e.zone.run(function(){e.vivocha.setNormalScreen(),e.uiService.setHangUpState()}),e.contact.offerMedia(t).then(function(){e.zone.run(function(){"chat"!=e.context.requestedMedia&&e.askForUpgrade("Chat")})})})},t.prototype.hasRecallForNoAgent=function(){return!1},t.prototype.hideChat=function(){this.uiService.hideChat()},t.prototype.initializeContact=function(t,e){var i=this;this.vivocha=t,this.context=e,this.dcService.setInitialContext(e),this.isInPersistence()?(this.resumeContact(e),this.dcService.hasSurvey()&&this.dcService.onSurveyCompleted().subscribe(function(t){t&&t.completed&&i.contact.storeSurvey(t.item)})):(this.dcService.onDataCollectionCompleted().subscribe(function(t){t&&t.completed&&(i.isAutoChat()?i.createAutoContact(t.creationOptions):(i.uiService.showQueuePanel(),i.createContact(t.creationOptions)))}),this.dcService.hasSurvey()&&this.dcService.onSurveyCompleted().subscribe(function(t){t&&t.completed&&i.contact.storeSurvey(t.item)}),this.dcService.processDataCollections())},t.prototype.isAutoChat=function(){return"chat"===this.context.requestedMedia&&this.context.variables.autoChat},t.prototype.isChatEmulationContact=function(){return!1},t.prototype.isOfflineMessage=function(e){return!!this.messageArchive.filter(function(t){return t===e})[0]&&(this.messageArchive=A(this.messageArchive.filter(function(t){return t!==e})),!0)},t.prototype.isRecallContact=function(){return!1},t.prototype.isInPersistence=function(){return!!this.context.persistenceId},t.prototype.leave=function(n){var a=this;return new Promise(function(t,e){if(a.contact){var i=+new Date-a.interactionStart,o=n||(a.hasReceivedMsgs?"closed":1e4<i?"abandoned":"cancelled");a.contact.leave(o,function(){a.contact.release(),a.contact.channel.isConnected()&&a.contact.channel.disconnect(),t(o)})}else t("failed")})},t.prototype.mapContact=function(){var s=this;this.vivocha.pageRequest("interactionCreated",this.contact),this.contact.on("agentrequest",function(t,e){s.zone.run(function(){s.onAgentRequest(t,e)})}),this.contact.on("attachment",function(e,i,o,n,a){s.zone.run(function(){i.url=i.originalUrl?i.originalUrl:e;var t={body:i.desc||i.originalName,type:"chat",meta:i,from_nick:n,from_id:o};a?s.messageService.addChatMessage(t,s.agent,s.visitorNick):s.messageService.addChatMessage(t,null,s.visitorNick)})}),this.contact.on("joined",function(t){t.user?(s.dissuasionTimer&&(clearTimeout(s.dissuasionTimer),delete s.dissuasionTimer),s.onAgentJoin(t)):s.onLocalJoin(t)}),this.contact.on("rawmessage",function(t){s.zone.run(function(){"text"==t.type&&(t.quick_replies?s.messageService.addQuickRepliesMessage(t,s.agent):t.template?s.messageService.addTemplateMessage(t,s.agent):s.messageService.addChatMessage(t,s.agent,s.visitorNick),t.agent&&s.uiService.setIsWriting(!1),s.uiService.newMessageReceived(),s.context.variables.playAudioNotification&&s.playAudioNotification(),s.hasReceivedMsgs=!0)})}),this.contact.on("iswriting",function(t,e,i){s.zone.run(function(){i&&s.setIsWriting()})}),this.contact.on("localtext",function(t){s.zone.run(function(){s.agent&&s.agent.is_bot&&s.setIsWriting(),s.isOfflineMessage(t)||s.messageService.addLocalMessage(t)})}),this.contact.on("left",function(t){s.zone.run(function(){console.log("LEFT",t),t.channels&&t.channels.user!==undefined&&0===t.channels.user&&(s.uiService.setClosedByAgent(),s.vivocha.setNormalScreen(),s.messageService.sendSystemMessage("STRINGS.MESSAGES.REMOTE_CLOSE"),s.isClosed=!0)})}),this.contact.on("localcapabilities",function(t){}),this.contact.on("capabilities",function(t){}),this.contact.on("mediachange",function(t,e){console.log("MEDIACHANGE",JSON.stringify(t,null,2)),s.zone.run(function(){s.protocolService.setMediaChange(t),s.uiService.setMediaState(t)})}),this.contact.on("mediaoffer",function(t,e){s.zone.run(function(){s.onMediaOffer(t,e)})}),this.contact.on("transferred",function(){s.zone.run(function(){s.messageService.sendSystemMessage("STRINGS.MESSAGES.TRANSFERRED")})}),Object.keys(this.customActions).forEach(function(i){s.contact.on(i,function(t,e){s.zone.run(function(){s.customActions[i].callback=e,s.customActions[i].stream.next(t)})})})},t.prototype.mergeOffer=function(t,e){var i=this;this.contact.mergeMedia(t).then(function(t){i.zone.run(function(){e(undefined,t)})})},t.prototype.muteToggle=function(e){var i=this;this.uiService.setMuteInProgress(),this.contact.getMediaEngine("WebRTC").then(function(t){e?t.muteLocalAudio():t.unmuteLocalAudio(),i.zone.run(function(){i.uiService.setMuted(e)})})},t.prototype.minimize=function(t,e,i,o){t?(this.vivocha.minimize({bottom:i&&i.bottom?i.bottom:"10px",right:i&&i.right?i.right:"10px"},{width:o&&o.width?o.width:"70px",height:o&&o.height?o.height:"70px"}),this.uiService.setMinimizedState()):e?this.setFullScreen():(this.vivocha.maximize(),this.uiService.setNormalState())},t.prototype.minimizeMedia=function(){this.protocolService.isAlreadyConnectedWith("Chat")||this.askForUpgrade("Chat"),this.uiService.setMinimizedMedia()},t.prototype.noAgents=function(){return!1},t.prototype.onAgentJoin=function(i){var o=this;this.contact.getMedia().then(function(e){o.zone.run(function(){var t={id:i.user,nick:i.nick,is_bot:!!i.is_bot,is_agent:!i.is_bot};i.avatar&&(t.avatar=i.avatar),o.agent=t,o.vivocha.pageRequest("interactionAnswered",t),o.protocolService.setMediaChange(e),o.uiService.initializeMedia(e),o.setAnsweredState(t)})})},t.prototype.onAgentRequest=function(t,e){this.agentRequestCallback=e,this.lastSystemMessageId=this.messageService.sendRequestMessage(t)},t.prototype.onLocalJoin=function(t){var o=this;t.reason&&"resume"===t.reason&&this.contact.getMedia().then(function(i){o.zone.run(function(){var t=o.contact.contact.agentInfo,e={id:t.id,nick:t.nick,is_bot:!!t.bot,is_agent:!t.bot};t.avatar&&(e.avatar=t.avatar),console.log("LOCAL JOIN",e,o.contact),o.agent=e,o.uiService.setAgent(e),o.context.variables.showAgentInfoOnTopBar?o.uiService.setTopBarWithAgentInfo(e):o.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"}),o.protocolService.setMediaChange(i),o.uiService.initializeMedia(i),o.checkForTranscript()})}),this.autoChat&&(this.messageArchive.map(function(t){return o.contact.sendText(t)}),this.autoChat=!1)},t.prototype.onMediaOffer=function(t,e){this.uiService.setMediaOffer(t);var i=this.protocolService.confirmNeeded(t);if(i.askForConfirmation)this.incomingMedia=i.media,this.uiService.setIncomingMedia(i.media),this.incomingCallback=e,this.incomingOffer=i.offer;else{var o=this.protocolService.mergeOffer(t);this.mergeOffer(o,e)}},t.prototype.openAttachment=function(t){var e={type:"web_url",url:t};this.vivocha.pageRequest("interactionEvent",e.type,e)},t.prototype.playAudioNotification=function(){var t=new Audio;t.src=window.beepmp3,t.load(),t.play()},t.prototype.processQuickReply=function(t){this.messageService.updateQuickReply(t.msgId);var e={code:"message",type:"text",body:t.action.title};t.action.payload!==undefined&&(e.payload=t.action.payload),this.contact.send(e),this.messageService.addLocalMessage(t.action.title)},t.prototype.registerCustomAction=function(t){return this.customActions[t.id]={stream:new n.Subject},this.customActions[t.id].stream},t.prototype.rejectAgentRequest=function(t){this.agentRequestCallback(null,!1),this.messageService.removeMessage(this.lastSystemMessageId),this.messageService.sendSystemMessage("STRINGS.MESSAGES."+t.toUpperCase()+"_REJECTED")},t.prototype.rejectOffer=function(){this.incomingCallback("error",{}),this.messageService.sendSystemMessage("STRINGS.CALL_REJECTED"),this.uiService.setOfferRejected()},t.prototype.resumeContact=function(e){var i=this;this.vivocha.dataRequest("getData","persistence.contact").then(function(t){i.vivocha.resumeContact(t).then(function(t){i.zone.run(function(){i.uiService.initializeProtocol(e,{initialOffer:i.protocolService.getInitialOffer(e.requestedMedia)}),i.contact=t,i.mapContact()})},function(t){console.log("Failed to resume contact",t),i.vivocha.pageRequest("interactionFailed",t.message)})})},t.prototype.sendAttachment=function(t){var e=this;this.uiService.setUploading(),this.contact.attach(t.file,t.text).then(function(){e.zone.run(function(){e.uiService.setUploaded()})})},t.prototype.sendIsWriting=function(){this.autoChat||this.contact.sendIsWriting()},t.prototype.sendPostBack=function(t){var e={code:"message",type:"postback",body:t.title};t.payload!==undefined&&(e.payload=t.payload),"postback"===t.type?this.contact.send(e):this.vivocha.pageRequest("interactionEvent",t.type,t)},t.prototype.sendRequest=function(t,e){return this.contact.request(t,e)},t.prototype.sendText=function(t){this.autoChat?(this.messageArchive.push(t),this.messageService.addChatMessage({body:t,ts:+(new Date).getTime()}),1===this.messageArchive.length&&this.createContact(this.autoChatInitialData)):this.contact.sendText(t)},t.prototype.setAnsweredState=function(t){this.messageService.removeMessage(this.lastSystemMessageId),this.uiService.setAgent(t),this.context.variables.showAgentInfoOnTopBar?this.uiService.setTopBarWithAgentInfo(t):this.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"}),this.context.variables.showWelcomeMessage&&(this.lastSystemMessageId=this.messageService.sendSystemMessage("STRINGS.CHAT.WELCOME_MESSAGE",{nickname:t.nick}))},t.prototype.setIsWriting=function(){var t=this;clearTimeout(this.isWritingTimer),this.uiService.setIsWriting(!0),this.isWritingTimer=setTimeout(function(){t.uiService.setIsWriting(!1)},this.isWritingTimeout)},t.prototype.setQueueState=function(){this.lastSystemMessageId=this.messageService.sendSystemMessage("STRINGS.QUEUE.CONNECTING")},t.prototype.setFullScreen=function(){this.uiService.setFullScreen(),this.vivocha.setFullScreen()},t.prototype.setNormalScreen=function(){this.uiService.setNormalScreen(),this.vivocha.setNormalScreen()},t.prototype.setTopBar=function(t,e,i){this.uiService.setTopBarWithAvatar(t,e,i)},t.prototype.setTopBarAvatar=function(t){this.uiService.setTopBarAvatar(t)},t.prototype.setTopBarSubtitle=function(t){this.uiService.setTopBarSubtitle(t)},t.prototype.setTopBarTitle=function(t){this.uiService.setTopBarTitle(t)},t.prototype.showCloseModal=function(t){this.uiService.setCloseModal(t)},t.prototype.showUploadPanel=function(){this.uiService.setUploadPanel(!0)},t.prototype.showSurvey=function(){this.dcService.showSurvey()},t.prototype.submitDataCollection=function(t){this.dcService.submitDataCollection(t)},t.prototype.submitSurvey=function(t){this.dcService.submitSurvey(t)},t.prototype.toggleEmojiPanel=function(){this.uiService.toggleEmojiPanel()},t.prototype.toggleVideo=function(i){var o=this;this.contact.getMediaOffer().then(function(t){if(t.Video){var e=t.Video.tx;t.Video.tx="required"===e?"off":"required"}o.zone.run(function(){o.uiService.setInTransit(!0)}),console.log("TOGGLE VIDEO",i,JSON.stringify(t,null,2)),o.contact.offerMedia(t).then(function(){o.zone.run(function(){o.uiService.setInTransit(!1)})})})},t}();fe.decorators=[{type:e.Injectable}],fe.ctorParameters=function(){return[{type:i.Store},{type:le},{type:he},{type:m},{type:de},{type:e.NgZone}]};var ge=function(){function t(t,e,i){this.store=t,this.contextService=e,this.contactService=i}return t.prototype.acceptAgentRequest=function(t){this.contactService.acceptAgentRequest(t)},t.prototype.acceptOffer=function(){this.contactService.acceptOffer()},t.prototype.addChatToFullScreen=function(t){this.contactService.addChatToFullScreen(t)},t.prototype.askForVideoUpgrade=function(){this.contactService.askForUpgrade("Video")},t.prototype.askForVoiceUpgrade=function(){this.contactService.askForUpgrade("Voice")},t.prototype.closeApp=function(){this.contactService.closeApp()},t.prototype.closeContact=function(){this.contactService.closeContact()},t.prototype.closeUploadPanel=function(){this.contactService.closeUploadPanel()},t.prototype.dismissCloseModal=function(){this.contactService.showCloseModal(!1)},t.prototype.getState=function(){return this.store.select(re)},t.prototype.hangUp=function(){this.contactService.hangUp()},t.prototype.hideChat=function(){this.contactService.hideChat()},t.prototype.init=function(){var e=this;this.contextService.ready().subscribe(function(t){t.loaded&&(e.vivocha=e.contextService.getVivocha(),e.context=t,e.contactService.initializeContact(e.vivocha,e.context))})},t.prototype.minimize=function(t,e,i,o){this.contactService.minimize(t,e,i,o)},t.prototype.minimizeMedia=function(){this.contactService.minimizeMedia()},t.prototype.muteToggle=function(t){this.contactService.muteToggle(t)},t.prototype.openAttachment=function(t){this.contactService.openAttachment(t)},t.prototype.processQuickReply=function(t){this.contactService.processQuickReply(t)},t.prototype.registerCustomAction=function(t){return this.contactService.registerCustomAction(t)},t.prototype.rejectAgentRequest=function(t){this.contactService.rejectAgentRequest(t)},t.prototype.rejectOffer=function(){this.contactService.rejectOffer()},t.prototype.sendAttachment=function(t){this.contactService.sendAttachment(t)},t.prototype.sendIsWriting=function(){this.contactService.sendIsWriting()},t.prototype.sendPostBack=function(t){this.contactService.sendPostBack(t)},t.prototype.sendRequest=function(t,e){return this.contactService.sendRequest(t,e)},t.prototype.sendText=function(t){this.contactService.sendText(t)},t.prototype.setFullScreen=function(){this.contactService.setFullScreen()},t.prototype.setNormalScreen=function(){this.contactService.setNormalScreen()},t.prototype.setTopBar=function(t,e,i){this.contactService.setTopBar(t,e,i)},t.prototype.setTopBarAvatar=function(t){this.contactService.setTopBarAvatar(t)},t.prototype.setTopBarSubtitle=function(t){this.contactService.setTopBarSubtitle(t)},t.prototype.setTopBarTitle=function(t){this.contactService.setTopBarTitle(t)},t.prototype.showCloseModal=function(){this.contactService.showCloseModal(!0)},t.prototype.showUploadPanel=function(){this.contactService.showUploadPanel()},t.prototype.showSurvey=function(){this.contactService.showSurvey()},t.prototype.submitDataCollection=function(t){this.contactService.submitDataCollection(t)},t.prototype.submitSurvey=function(t){this.contactService.submitSurvey(t)},t.prototype.toggleEmojiPanel=function(){this.contactService.toggleEmojiPanel()},t.prototype.toggleVideo=function(t){this.contactService.toggleVideo(t)},t}();function ve(t){var e=location.pathname.match(/(.*\/api\/v2\/public\/campaigns\/\w+\/\w+\/interaction\/)\w+(\/[^\/]+\/[^\/]+)\/main\.html/),i=location.origin+e[1];return new r.TranslateHttpLoader(t,i,e[2]+"/strings.json")}ge.decorators=[{type:e.Injectable}],ge.ctorParameters=function(){return[{type:i.Store},{type:pe},{type:fe}]};var me=ve,ye=function(){};function Se(t){var e=location.pathname.match(/(.*\/api\/v2\/public\/campaigns\/\w+\/\w+\/interaction\/)\w+(\/[^\/]+\/[^\/]+)\/main\.html/),i=location.origin+e[1];return new r.TranslateHttpLoader(t,i,e[2]+"/strings.json")}ye.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,s.HttpClientModule,i.StoreModule.forRoot(ee,{}),o.TranslateModule.forRoot({loader:{provide:o.TranslateLoader,useFactory:me,deps:[s.HttpClient]}})],providers:[ge,m,pe,fe,de,he,le,ue]}]}];var Ce=Se,be=function(){};be.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,s.HttpClientModule,i.StoreModule.forRoot(ee,{}),o.TranslateModule.forRoot({loader:{provide:o.TranslateLoader,useFactory:Ce,deps:[s.HttpClient]}}),u.StoreDevtoolsModule.instrument({maxAge:50})],providers:[ge,m,pe,fe,de,he,le,ue]}]}],t.VvcMessageService=m,t.VvcInteractionService=ge,t.InteractionCoreModule=ye,t.InteractionCoreDebugModule=be,t.ɵb=Se,t.ɵa=ve,t.ɵh=fe,t.ɵe=pe,t.ɵi=le,t.ɵj=he,t.ɵf=de,t.ɵg=ue,t.ɵo=te,t.ɵm=Lt,t.ɵd=ee,t.ɵl=Bt,t.ɵn=Zt,t.ɵk=qt,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@ngrx/store"),require("@ngx-translate/core"),require("@vivocha/public-entities/dist/wrappers/data_collection"),require("rxjs/Subject"),require("@angular/common"),require("@angular/common/http"),require("@ngx-translate/http-loader"),require("@ngrx/store-devtools")):"function"==typeof define&&define.amd?define("@vivocha/client-interaction-core",["exports","@angular/core","@ngrx/store","@ngx-translate/core","@vivocha/public-entities/dist/wrappers/data_collection","rxjs/Subject","@angular/common","@angular/common/http","@ngx-translate/http-loader","@ngrx/store-devtools"],e):e((t.vivocha=t.vivocha||{},t.vivocha["client-interaction-core"]={}),t.ng.core,t.store,t.core$1,t.data_collection,t.Rx,t.ng.common,t.ng.common.http,t.httpLoader,t.storeDevtools)}(this,function(t,e,i,o,c,n,a,s,r,u){"use strict";function d(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var o,n,a=i.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(o=a.next()).done;)s.push(o.value)}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=a["return"])&&i.call(a)}finally{if(n)throw n.error}}return s}function A(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(d(arguments[e]));return t}var p="[Message] New message",l="[Message] Update message",h="[Message] Remove message",f=function(t){this.payload=t,this.type=p},g=function(t){this.payload=t,this.type=l},v=function(t){this.payload=t,this.type=h},m=function(){function t(t){this.store=t}return t.prototype.addChatMessage=function(t,e,i){var o=(new Date).getTime().toString(),n={id:o,text:t.body,type:"chat",isAgent:e,time:this.getChatTimestamp(t.ts)};return e&&(n.agent=e),t.meta&&(n.meta=t.meta),i&&(n.visitorNick=i),this.store.dispatch(new f(n)),o},t.prototype.addCustomMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,code:"message",type:"custom",body:Object.assign({},t)};return this.store.dispatch(new f(i)),e},t.prototype.addLocalMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,text:t,type:"chat",isAgent:!1,time:this.getChatTimestamp()};return this.store.dispatch(new f(i)),e},t.prototype.addQuickRepliesMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,code:"message",type:"quick-replies",body:t.body,quick_replies:t.quick_replies,quick_replies_orientation:t.quick_replies_orientation,time:this.getChatTimestamp()};return e&&(o.agent=e),this.store.dispatch(new f(o)),i},t.prototype.addTemplateMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,type:"template",template:t.template.type,elements:t.template.elements,buttons:t.template.buttons,time:this.getChatTimestamp()};return e&&(o.agent=e),this.store.dispatch(new f(o)),i},t.prototype.getChatTimestamp=function(t){var e;return e=t?new Date(t):new Date,(9<parseInt(e.getHours())?e.getHours():"0"+e.getHours())+":"+(9<parseInt(e.getMinutes())?e.getMinutes():"0"+e.getMinutes())},t.prototype.removeMessage=function(t){this.store.dispatch(new v(t))},t.prototype.sendRequestMessage=function(t){var e=(new Date).getTime().toString(),i={id:e,type:"request",text:t.toUpperCase()};return this.store.dispatch(new f(i)),e},t.prototype.sendSystemMessage=function(t,e){var i=(new Date).getTime().toString(),o={id:i,type:"system",text:t};return e&&(o.context=e),this.store.dispatch(new f(o)),i},t.prototype.updateQuickReply=function(t){this.store.dispatch(new g({id:t,patch:{replied:!0}}))},t}();m.decorators=[{type:e.Injectable}],m.ctorParameters=function(){return[{type:i.Store}]};var y="[Widget] Closed by Agent",S="[Widget] Closed by Visitor",C="[Widget] Contact Failed",b="[Widget] Incoming Media",x="[Widget] Init Chat",O="[Widget] Init Context",M="[Widget] Init Multimedia",w="[Widget] Init Protocol",T="[Widget] Is Offering",j="[Widget] Is Uploading",I="[Widget] Is Writing",R="[Widget] In Video Transit",V="[Widget] Mark as read",P="[Widget] Media Change",E="[Widget] Media Offer",q="[Widget] Mute in progress",k="[Widget] Mute Success",B="[Widget] New Message",D="[Widget] Offer Accepted",W="[Widget] Offer Rejected",z="[Widget] Set Agent",F="[Widget] Set Auto Chat",U="[Widget] Set Error",N="[Widget] Set Fullscreen",_="[Widget] Set Minimized",L="[Widget] Set Minimized Media",G="[Widget] Set Normal",Q="[Widget] Set Top Bar",H="[Widget] Fullscreen Chat",J="[Widget] Show Close Panel",Y="[Widget] Show Queue Panel",Z="[Widget] Show Upload Panel",$="[Widget] Toggle Emoji Panel",K="[Widget] Upload Completed",X=function(){this.type=y},tt=function(){this.type=S},et=function(){this.type=C},it=function(t){this.payload=t,this.type=b},ot=function(t){this.payload=t,this.type=x},nt=function(t){this.payload=t,this.type=O},at=function(t){this.payload=t,this.type=M},st=function(t){this.payload=t,this.type=w},ct=function(t){this.payload=t,this.type=T},rt=function(){this.type=j},ut=function(t){this.payload=t,this.type=I},dt=function(t){this.payload=t,this.type=R},pt=function(){this.type=V},lt=function(t){this.payload=t,this.type=P},ht=function(t){this.payload=t,this.type=E},ft=function(){this.type=q},gt=function(t){this.payload=t,this.type=k},vt=function(){this.type=B},mt=function(){this.type=D},yt=function(){this.type=W},St=function(t){this.payload=t,this.type=z},Ct=function(){this.type=F},bt=function(){this.type=U},xt=function(){this.type=N},Ot=function(){this.type=_},Mt=function(t){this.payload=t,this.type=L},wt=function(){this.type=G},Tt=function(t){this.payload=t,this.type=Q},jt=function(t){this.payload=t,this.type=H},At=function(t){this.payload=t,this.type=J},It=function(){this.type=Y},Rt=function(t){this.payload=t,this.type=Z},Vt=function(){this.type=$},Pt=function(){this.type=K},Et={context:{loaded:!1,translationLoaded:!1},media:{isMinimized:!0},topBar:{},protocol:{contactStarted:!1}};function qt(t,e){switch(void 0===t&&(t=Et),e.type){case y:var i=Object.assign({},t.context,{closedByAgent:!0,showClosePanel:!1});return Object.assign({},t,{context:i});case S:i=Object.assign({},t.context,{closedByVisitor:!0,showClosePanel:!1});return Object.assign({},t,{context:i});case C:i=Object.assign({},t.context,{contactCreationFailed:!0,hasError:!0});return Object.assign({},t,{context:i});case x:var o={isVisible:"chat"===t.protocol.requestedMedia,canUploadFiles:t.context.variables.showUploadButton,canSendEmoji:t.context.variables.showEmojiButton,uploadPanelOpened:!1,emojiPanelOpened:!1,notRead:0};return Object.assign({},t,{chat:o});case O:i=Object.assign({},t.context,Object.assign({},e.payload,{isUiLoaded:!0}));return Object.assign({},t,{context:i});case M:var n={isVisible:"video"===t.protocol.requestedMedia||"voice"===t.protocol.requestedMedia,isMinimized:!1};return Object.assign({},t,{media:n});case w:return Object.assign({},t,{protocol:e.payload});case j:i=Object.assign({},t.context,{isUploading:!0,uploadCompleted:!1});return Object.assign({},t,{context:i});case I:var a=Object.assign({},t.chat,{isWriting:e.payload});return Object.assign({},t,{chat:a});case V:a=Object.assign({},t.chat,{notRead:0});return Object.assign({},t,{chat:a});case P:n=Object.assign({},t.media,{media:e.payload});var s=Object.assign({},t.protocol,{incomingOffer:!1,isOffering:!1,offeringMedia:""});return Object.assign({},t,{media:n,protocol:s});case b:s=Object.assign({},t.protocol,{incomingMedia:e.payload,incomingOffer:!0}),n=Object.assign({},t.media,{isVisible:!0});return Object.assign({},t,{protocol:s,media:n});case E:s=Object.assign({},t.protocol,{offer:e.payload});return Object.assign({},t,{protocol:s});case T:s=Object.assign({},t.protocol,{offeringMedia:e.payload,isOffering:!0}),n=Object.assign({},t.media,{isVisible:!0});return Object.assign({},t,{protocol:s,media:n});case R:s=Object.assign({},t.protocol,{inVideoTransit:e.payload});return Object.assign({},t,{protocol:s});case q:n=Object.assign({},t.media,{muteInProgress:!0});return Object.assign({},t,{media:n});case k:n=Object.assign({},t.media,{muteInProgress:!1,isMuted:e.payload});return Object.assign({},t,{media:n});case B:if(t.context.isMinimized||!t.chat.isVisible||t.media.isVisible&&!t.media.isMinimized){a=Object.assign({},t.chat,{notRead:t.chat.notRead+1});return Object.assign({},t,{chat:a})}return t;case D:case W:s=Object.assign({},t.protocol,{incomingOffer:!1,isOffering:!1,offeringMedia:""});return Object.assign({},t,{protocol:s});case z:a=Object.assign({},t.chat,{isAutoChat:!1}),i=Object.assign({},t.context,{showQueuePanel:!1});return Object.assign({},t,{agent:e.payload,context:i,chat:a});case F:o={isVisible:!0,isAutoChat:!0,canUploadFiles:!1,canSendEmoji:!1,uploadPanelOpened:!1,emojiPanelOpened:!1,notRead:0};return Object.assign({},t,{chat:o});case U:i=Object.assign({},t.context,{hasError:!0,showQueuePanel:!0});return Object.assign({},t,{context:i});case N:i=Object.assign({},t.context,{isFullScreen:!0,isMinimized:!1});return Object.assign({},t,{context:i});case _:i=Object.assign({},t.context,{isMinimized:!0});return Object.assign({},t,{context:i});case L:n=Object.assign({},t.media,{isMinimized:e.payload});return Object.assign({},t,{media:n});case G:i=Object.assign({},t.context,{isMinimized:!1,isFullScreen:!1});return Object.assign({},t,{context:i});case Q:var c=Object.assign({},t.topBar,e.payload);return Object.assign({},t,{topBar:c});case H:a=Object.assign({},t.chat,{showOnFullScreen:e.payload});return Object.assign({},t,{chat:a});case J:i=Object.assign({},t.context,{showClosePanel:e.payload});return Object.assign({},t,{context:i});case Y:i=Object.assign({},t.context,{showQueuePanel:!0});return Object.assign({},t,{context:i});case Z:a=Object.assign({},t.chat,{uploadPanelOpened:e.payload});return Object.assign({},t,{chat:a});case $:a=Object.assign({},t.chat,{emojiPanelOpened:!t.chat.emojiPanelOpened});return Object.assign({},t,{chat:a});case K:i=Object.assign({},t.context,{isUploading:!1,uploadCompleted:!0}),a=Object.assign({},t.chat,{uploadPanelOpened:!1});return Object.assign({},t,{context:i,chat:a});default:return t}}var kt={list:[]};function Bt(t,e){switch(void 0===t&&(t=kt),e.type){case l:var i=t.list.map(function(t){if(t.id===e.payload.id){Object.assign({},t,e.payload.patch);return Object.assign({},t,e.payload.patch)}return t});return Object.assign({},t,{list:A(i)});case p:return Object.assign({},t,{list:A(t.list,[e.payload])});case h:return Object.assign({},t,{list:t.list.filter(function(t){return t.id!==e.payload})});default:return t}}var Dt="[Data Collection] Loaded",Wt="[Data Collection] Completed",zt="[Data Collection] Selected",Ft=function(t){this.payload=t,this.type=Dt},Ut=function(t){this.payload=t,this.type=Wt},Nt=function(t){this.payload=t,this.type=zt},_t={completed:!1};function Lt(t,e){switch(void 0===t&&(t=_t),e.type){case Dt:return Object.assign({},t,{items:A(e.payload)});case Wt:return Object.assign({},t,{completed:!0,creationOptions:e.payload});case zt:return Object.assign({},t,{selectedItem:e.payload});default:return t}}var Gt="[Survey] Completed",Qt="[Survey] Selected",Ht=function(t){this.payload=t,this.type=Gt},Jt=function(t){this.payload=t,this.type=Qt},Yt={completed:!1};function Zt(t,e){switch(void 0===t&&(t=Yt),e.type){case Gt:return Object.assign({},t,{completed:!0,surveyToSend:e.payload});case Qt:return Object.assign({},t,{item:e.payload});default:return t}}var $t="[Context] Load Success",Kt=function(t){this.payload=t,this.type=$t},Xt={loaded:!1};function te(t,e){switch(void 0===t&&(t=Xt),e.type){case $t:return Object.assign({},t,e.payload);default:return t}}var ee={widget:qt,messages:Bt,dataCollection:Lt,survey:Zt,context:te},ie=i.createFeatureSelector("widget"),oe=i.createFeatureSelector("messages"),ne=i.createFeatureSelector("dataCollection"),ae=i.createFeatureSelector("survey"),se=i.createFeatureSelector("context"),ce=i.createSelector(oe,function(s){return{list:A(s.list.map(function(t,e){var i=!1,o=!1,n=s.list[e+1],a=s.list[e-1];return o=!a||!!(t.type!==a.type||t.isAgent!=a.isAgent||t.agent&&a.agent&&t.agent.id!=a.agent.id),i=!n||!!(t.type!==n.type||t.isAgent!=n.isAgent||a&&t.agent&&a.agent&&t.agent.id!=a.agent.id),Object.assign({},t,{isLast:i,isFirst:o})}))}}),re=i.createSelector(ie,ce,ne,ae,function(t,e,i,o){var n=t.media.media,a=n&&t.media.media.Voice&&(t.media.media.Voice.rx||t.media.media.Voice.tx),s=n&&t.media.media.Video,c=s&&t.media.media.Video.tx,r=s&&t.media.media.Video.rx,u=c&&t.media.media.Video.data&&t.media.media.Video.data.tx_stream&&!!t.media.media.Video.data.tx_stream.url,d=!!u&&t.media.media.Video.data.tx_stream.url,p=r&&t.media.media.Video.data&&t.media.media.Video.data.rx_stream&&!!t.media.media.Video.data.rx_stream.url,l=!!p&&t.media.media.Video.data.rx_stream.url,h=a&&t.media.media.Voice.data&&t.media.media.Voice.data.rx_stream&&!!t.media.media.Voice.data.rx_stream.url,f=!!h&&t.media.media.Voice.data.rx_stream.url,g=a&&!h,v=c&&u,m=r&&p,y=c&&!u||r&&!p,S=v||m,C=a&&h||v||m,b=g||y,x=t.chat&&!t.chat.uploadPanelOpened&&(t.protocol.incomingOffer||t.protocol.isOffering||b||C),O=t.protocol.canStartAudio&&!a&&!g&&t.agent&&t.agent.is_agent&&"Voice"!==t.protocol.offeringMedia,M=t.protocol.canStartVideo&&t.agent&&t.agent.is_agent&&!c&&!y,w=t.context.showQueuePanel&&i.completed||x&&!t.media.isMinimized&&!t.context.isFullScreen||t.protocol.isOffering||t.protocol.incomingOffer,T=t.context.closedByAgent||t.context.closedByVisitor,j=t.chat&&!t.context.showQueuePanel&&!t.context.showDataCollectionPanel&&!o.item&&!t.protocol.isOffering&&!t.protocol.incomingOffer&&!b&&(!C||C&&t.media.isMinimized)||t.context.isFullScreen;return{agent:t.agent,messages:A(e.list),variables:t.context.variables||{},canMaximize:S,canMinimize:!0,canRemoveApp:t.context.closedByAgent||t.context.closedByVisitor||t.context.showQueuePanel||!t.context.isUiLoaded,canStartAudio:O,canStartVideo:M,connectedWithAgent:t.agent&&t.agent.is_agent,connectedWithBot:t.agent&&t.agent.is_bot,contactCreationFailed:t.context.contactCreationFailed,hasError:t.context.hasError,hasSurvey:!!t.context.survey&&t.protocol.contactStarted&&!t.context.hasError&&!t.context.showQueuePanel,incomingOffer:t.protocol.incomingOffer,incomingMedia:t.protocol.incomingMedia,inVideoTransit:t.protocol.inVideoTransit,isAutoChat:t.chat&&t.chat.isAutoChat,isLoading:!t.context.isUiLoaded,isInQueue:t.context.showQueuePanel&&i.completed,isChatVisible:j,isClosed:T,isClosedByAgent:t.context.closedByAgent,isClosedByVisitor:t.context.closedByVisitor,isMediaConnected:C,isMediaConnecting:b,isMediaVisible:x,isMediaMinimized:t.media.isMinimized&&!t.protocol.isOffering&&!t.protocol.incomingOffer,isMinimized:t.context.isMinimized,isMobile:t.context.isMobile,isMuted:t.media.isMuted,isOffering:t.protocol.isOffering,isFullScreen:t.context.isFullScreen&&!T,isSendAreaVisible:j&&!t.chat.uploadPanelOpened,isUploading:t.context.isUploading,isWriting:t.chat&&t.chat.isWriting,notRead:t.chat?t.chat.notRead:0,offeringMedia:t.protocol.offeringMedia,selectedDataCollection:i.selectedItem,selectedSurvey:o.item,showCloseModal:t.context.showClosePanel,showChatOnFullScreen:t.chat&&t.chat.showOnFullScreen,showDataCollectionPanel:!i.completed&&i.selectedItem,showEmojiPanel:t.chat&&t.chat.emojiPanelOpened,showUploadPanel:t.chat&&t.chat.uploadPanelOpened,showSurveyPanel:!!o.item,surveyCompleted:o.completed,topBarTitle:w?"":t.topBar.title,topBarSubtitle:w?"":t.topBar.subtitle,topBarAvatar:w?"":t.topBar.avatar,translationLoaded:t.context.translationLoaded,uploadCompleted:t.context.uploadCompleted,voiceRxStream:f,videoRxStream:l,videoTxStream:d}});var ue=function(){function t(){}return Object.defineProperty(t.prototype,"nativeWindow",{get:function(){return window},enumerable:!0,configurable:!0}),t}();ue.decorators=[{type:e.Injectable}];var de=function(){function t(t){var e=this;this.store=t,this.store.select(ie).subscribe(function(t){e.currentState=t})}return t.prototype.hideChat=function(){this.store.dispatch(new Mt(!1))},t.prototype.initializeChat=function(t){console.log("initializing chat",t),this.store.dispatch(new ot(t))},t.prototype.initializeContext=function(t){this.store.dispatch(new Kt(t)),this.store.dispatch(new nt(t))},t.prototype.initializeMedia=function(t){this.initializeChat(t),this.initializeMultimedia(t),this.setMediaState(t)},t.prototype.initializeMultimedia=function(t){this.store.dispatch(new at(t))},t.prototype.initializeProtocol=function(t,e){this.store.dispatch(new st({requestedMedia:t.requestedMedia,canStartAudio:"both"===t.media.voice||"visitor"===t.media.voice,canStartVideo:"both"===t.media.video||"visitor"===t.media.video,initialOffer:e.initialOffer,contactStarted:!0}))},t.prototype.loadDataCollections=function(t){this.store.dispatch(new Ft(t))},t.prototype.newMessageReceived=function(){this.store.dispatch(new vt)},t.prototype.resetTopBar=function(){this.store.dispatch(new Tt({title:"",subtitle:"",avatar:""}))},t.prototype.selectDataCollection=function(t){this.store.dispatch(new Nt(t)),this.store.dispatch(new Tt({title:"STRINGS.QUEUE.TOPBAR.TITLE",subtitle:t.labelId,avatar:""}))},t.prototype.setOfferAccepted=function(){this.store.dispatch(new mt)},t.prototype.setAgent=function(t){this.store.dispatch(new St(t))},t.prototype.setAutoChat=function(){this.store.dispatch(new Ct)},t.prototype.setClosedByAgent=function(){this.store.dispatch(new X)},t.prototype.setClosedByVisitor=function(){this.store.dispatch(new tt)},t.prototype.setCloseModal=function(t){this.store.dispatch(new At(t))},t.prototype.setCreationFailed=function(){this.store.dispatch(new et)},t.prototype.setDataCollectionCompleted=function(t){this.store.dispatch(new Ut(t))},t.prototype.setDissuasion=function(){this.store.dispatch(new bt)},t.prototype.setFullScreenChat=function(t){this.store.dispatch(new jt(t)),this.store.dispatch(new pt)},t.prototype.setFullScreen=function(){this.store.dispatch(new xt)},t.prototype.setHangUpState=function(){this.store.dispatch(new wt)},t.prototype.setNormalScreen=function(){this.store.dispatch(new wt),this.store.dispatch(new jt(!1))},t.prototype.setIncomingMedia=function(t){this.store.dispatch(new it(t))},t.prototype.setInTransit=function(t){this.store.dispatch(new dt(t))},t.prototype.setIsOffering=function(t){this.store.dispatch(new ct(t))},t.prototype.setIsWriting=function(t){this.store.dispatch(new ut(t))},t.prototype.setMediaOffer=function(t){this.store.dispatch(new ht(t))},t.prototype.setMediaState=function(t){console.log("setting media state",t),this.store.dispatch(new lt(t))},t.prototype.setMinimizedState=function(){this.store.dispatch(new Ot)},t.prototype.setMinimizedMedia=function(){this.store.dispatch(new Mt(!0)),this.store.dispatch(new pt)},t.prototype.setMuted=function(t){this.store.dispatch(new gt(t))},t.prototype.setMuteInProgress=function(){this.store.dispatch(new ft)},t.prototype.setNormalState=function(){this.store.dispatch(new wt),this.store.dispatch(new pt)},t.prototype.setOfferRejected=function(){this.store.dispatch(new yt)},t.prototype.setTopBar=function(t){this.store.dispatch(new Tt({title:t.title,subtitle:t.subtitle}))},t.prototype.setTopBarAvatar=function(t){this.store.dispatch(new Tt({avatar:t}))},t.prototype.setTopBarSubtitle=function(t){this.store.dispatch(new Tt({subtitle:t}))},t.prototype.setTopBarTitle=function(t){this.store.dispatch(new Tt({title:t}))},t.prototype.setTopBarWithAvatar=function(t,e,i){this.store.dispatch(new Tt({title:e,subtitle:i,avatar:t}))},t.prototype.setTopBarWithAgentInfo=function(t){this.store.dispatch(new Tt({title:t.nick,subtitle:"STRINGS.QUEUE.TOPBAR.CONNECTED",avatar:t.avatar}))},t.prototype.setSurveyPanel=function(){this.store.dispatch(new Tt({title:"STRINGS.SURVEY.TITLE",subtitle:"STRINGS.SURVEY.SUBTITLE"}))},t.prototype.setUploadPanel=function(t){this.store.dispatch(new Rt(t))},t.prototype.setUploading=function(){this.store.dispatch(new rt)},t.prototype.setUploaded=function(){this.store.dispatch(new Pt)},t.prototype.showQueuePanel=function(){this.store.dispatch(new It)},t.prototype.toggleEmojiPanel=function(){this.store.dispatch(new Vt)},t}();de.decorators=[{type:e.Injectable}],de.ctorParameters=function(){return[{type:i.Store}]};var pe=function(){function t(t,e,i,o,n){this.store=t,this.uiService=e,this.wref=i,this.ts=o,this.zone=n,this.isMobile=!1,this.window=i.nativeWindow,this.parseIframeUrl(),this.checkForVivocha()}return t.prototype.checkForVivocha=function(){var e=this;this.window.vivocha&&this.window.vivocha.ready?this.window.vivocha.ready(this.busId).then(function(){e.window.vivocha.pageRequest("getContext").then(function(t){e.zone.run(function(){e.vivocha=e.window.vivocha,e.isMobile=e.window.vivocha.isMobile(),e.context=t,e.dispatchContext(t)})})}):setTimeout(function(){return e.checkForVivocha()},200)},t.prototype.dispatchContext=function(e){var i=this;this.ts.use(e.language),this.ts.getTranslation(e.language).toPromise().then(function(t){i.uiService.initializeContext(Object.assign({loaded:!0,translationLoaded:!0,isMobile:i.isMobile,busId:i.busId,acct:i.acct,world:i.world,variables:e.campaign.channels.web.interaction.variables},e))})},t.prototype.getVivocha=function(){return this.vivocha},t.prototype.parseIframeUrl=function(){if(-1!==this.window.location.hash.indexOf(";")){var t=this.window.location.hash.substr(2).split(";");this.busId=t[0],this.acct=t[1],this.world=t[2]}},t.prototype.ready=function(){return this.store.select(se)},t}();pe.decorators=[{type:e.Injectable}],pe.ctorParameters=function(){return[{type:i.Store},{type:de},{type:ue},{type:o.TranslateService},{type:e.NgZone}]};var le=function(){function t(t,e){this.store=t,this.uiService=e,this.contactOptions={data:[]},this.selectedIdx=0}return t.prototype.setInitialContext=function(t){this.context=t},t.prototype.onDataCollectionCompleted=function(){return this.store.select(ne)},t.prototype.onSurveyCompleted=function(){return this.store.select(ae)},t.prototype.processDataCollections=function(){this.hasDataCollection()?this.processDcByIdx(0):this.uiService.setDataCollectionCompleted({})},t.prototype.processDcByIdx=function(t){this.selectedIdx=t,this.hasVisibleFields(this.context.dataCollections[t])?this.uiService.selectDataCollection(this.context.dataCollections[t]):this.submitHiddenDataCollection(this.context.dataCollections[t])},t.prototype.hasDataCollection=function(){return!!(this.context.dataCollections&&0<this.context.dataCollections.length)&&(this.uiService.loadDataCollections(this.context.dataCollections),!0)},t.prototype.hasSurvey=function(){return this.context&&!!this.context.survey},t.prototype.hasVisibleFields=function(t){var i=!1;return t.fields&&t.fields.forEach(function(t){var e="undefined"!=typeof t.defaultConstant;-1===["visitor","both"].indexOf(t.hidden)&&(!e||e&&t.editIfDefault)&&(i=!0)}),i},t.prototype.showSurvey=function(){this.hasSurvey()&&(this.store.dispatch(new Jt(this.context.survey)),this.uiService.setSurveyPanel())},t.prototype.submitDataCollection=function(t){for(var e=t.dcDefinition,i=t.dcData,o=0;o<e.fields.length;o++)if("nickname"===e.fields[o].format&&i[e.fields[o].id]){this.contactOptions.nick=i[e.fields[o].id];break}this.contactOptions.data.push(c.objectToDataCollection(i,e.id,e)),this.context.dataCollections[this.selectedIdx+1]?this.processDcByIdx(this.selectedIdx+1):this.uiService.setDataCollectionCompleted(this.contactOptions)},t.prototype.submitHiddenDataCollection=function(t){var i={};t.fields&&t.fields.forEach(function(t){var e="undefined"!=typeof t.defaultConstant;i[t.id]=e?t.defaultConstant.toString():t.defaultConstant});var e={dcDefinition:t,dcData:i};this.submitDataCollection(e)},t.prototype.submitSurvey=function(t){var e=c.objectToDataCollection(t.surveyData,t.surveyDefinition.id,t.surveyDefinition);this.store.dispatch(new Ht(e))},t}();le.decorators=[{type:e.Injectable}],le.ctorParameters=function(){return[{type:i.Store},{type:de}]};var he=function(){function t(t){this.store=t,this.previousChannels=[],this.currentChannels=[]}return t.prototype.confirmNeeded=function(t){var e={askForConfirmation:!1,offer:{},media:""};for(var i in t)switch(i){case"Voice":this.isAlreadyConnectedWith("Voice")||"off"===t[i].tx||"off"===t[i].rx||(e.askForConfirmation=!0,e.offer[i]=t[i]);break;case"Video":(!this.isAlreadyConnectedWith("Video")&&"off"!==t[i].tx||"off"!==t[i].rx)&&(this.isAlreadyConnectedWith("Voice")||(e.askForConfirmation=!0,e.offer[i]=t[i]))}return e.offer.Voice&&(e.media="Voice"),e.offer.Video&&(e.media="Video"),e},t.prototype.getChannels=function(e){var i=[];return Object.keys(e).forEach(function(t){(e[t].tx||e[t].rx)&&i.push(t)}),i},t.prototype.getInitialOffer=function(t){switch(t){case"voice":return{Voice:{rx:"required",tx:"required",engine:"WebRTC"},Sharing:{rx:"required",tx:"required"}};case"video":return{Video:{rx:"required",tx:"required",engine:"WebRTC"},Voice:{rx:"required",tx:"required",engine:"WebRTC"},Sharing:{rx:"required",tx:"required"}};default:return{Chat:{rx:"required",tx:"required"},Sharing:{rx:"required",tx:"required"}}}},t.prototype.isAlreadyConnectedWith=function(t){return this.lastMediaChange[t]&&this.lastMediaChange[t].tx&&this.lastMediaChange[t].rx},t.prototype.mergeOffer=function(t){for(var e in t)"Video"===e&&"optional"===t[e].tx&&(t[e].tx="off"),t[e].rx="off"!==t[e].rx,t[e].tx="off"!==t[e].tx;return t},t.prototype.setMediaChange=function(t){this.lastMediaChange=t},t}();he.decorators=[{type:e.Injectable}],he.ctorParameters=function(){return[{type:i.Store}]};var fe=function(){function t(t,e,i,o,n,a){this.store=t,this.dcService=e,this.protocolService=i,this.messageService=o,this.uiService=n,this.zone=a,this.hasReceivedMsgs=!1,this.isClosed=!1,this.isWritingTimeout=3e4,this.autoChat=!1,this.messageArchive=[],this.customActions={}}return t.prototype.acceptAgentRequest=function(t){this.agentRequestCallback(null,!0),this.messageService.removeMessage(this.lastSystemMessageId),this.messageService.sendSystemMessage("STRINGS.MESSAGES."+t.toUpperCase()+"_ACCEPTED")},t.prototype.acceptOffer=function(){this.mergeOffer(this.incomingOffer,this.incomingCallback)},t.prototype.addChatToFullScreen=function(t){this.uiService.setFullScreenChat(t),"chat"!==this.context.requestedMedia&&this.askForUpgrade("Chat")},t.prototype.askForUpgrade=function(e){var i=this;"Chat"!==e&&this.uiService.setIsOffering(e),this.contact.getMediaOffer().then(function(t){t[e]="Chat"===e?{tx:"required",rx:"required"}:{tx:"required",rx:"required",via:"net",engine:"WebRTC"},"Video"===e&&(t.Voice={tx:"required",rx:"required",via:"net",engine:"WebRTC"}),i.contact.offerMedia(t).then(function(){i.zone.run(function(){})},function(t){i.zone.run(function(){i.uiService.setOfferRejected()})})})},t.prototype.attachDataAndCreateContact=function(t){for(var e={data:[]},i=t.dataCollections[0],o={},n=0;n<i.fields.length;n++){var a=i.fields[n];"nickname"===a.format&&a.id&&(e.nick=o[a.id]);var s="undefined"!=typeof a.defaultConstant;a.value=s?a.defaultConstant.toString():a.defaultConstant,o[a.id]=a.value}e.data.push(c.objectToDataCollection(o,i.id,i)),this.createContact(e)},t.prototype.checkForTranscript=function(){var t=this.contact.contact.transcript;for(var e in t){var i=t[e];switch(i.type){case"text":var o=!!i.agent&&this.agent;i.quick_replies?this.messageService.addQuickRepliesMessage(i,this.agent):i.template?this.messageService.addTemplateMessage(i,this.agent):this.messageService.addChatMessage(i,o,this.visitorNick);break;case"attachment":var n=i.meta;n.url=n.originalUrl?n.originalUrl:i.url;var a={body:n.desc||n.originalName,type:"chat",meta:n,from_nick:i.from_nick,from_id:i.from_id};i.agent?this.messageService.addChatMessage(a,this.agent,this.visitorNick):this.messageService.addChatMessage(a,null,this.visitorNick);break;default:console.log("transcript",i.type,i)}}},t.prototype.closeApp=function(){var e=this;this.leave().then(function(t){"failed"===t||e.vivocha.pageRequest("interactionClosed",t),e.vivocha.pageRequest("interactionClosed","destroy")})},t.prototype.closeContact=function(){var e=this;this.leave().then(function(t){e.zone.run(function(){e.uiService.setClosedByVisitor(),e.messageService.sendSystemMessage("STRINGS.MESSAGES.LOCAL_CLOSE"),e.vivocha.setNormalScreen(),e.isClosed=!0,e.context.variables.stayInAppAfterClose||e.dcService.hasSurvey()||(e.vivocha.pageRequest("interactionClosed",t),e.vivocha.pageRequest("interactionClosed","destroy"))})})},t.prototype.closeUploadPanel=function(){this.uiService.setUploadPanel(!1)},t.prototype.createAutoContact=function(t){this.autoChat=!0,this.autoChatInitialData=t,this.uiService.setAutoChat(),this.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"})},t.prototype.createContact=function(t){var i=this,o=this.getContactOptions(t);o&&o.nick&&(this.visitorNick=o.nick),this.vivocha.pageRequest("interactionCreation",o,function(t){void 0===t&&(t=o),console.log("pre-routing callback",t),i.interactionStart=+new Date;var e=1e3*(i.context.routing.dissuasionTimeout||60);i.dissuasionTimer=setTimeout(function(){i.leave("dissuasion").then(function(){i.zone.run(function(){i.uiService.setDissuasion()})})},e),i.uiService.initializeProtocol(i.context,t),i.vivocha.createContact(t).then(function(t){i.zone.run(function(){i.contact=t,i.mapContact()})},function(t){console.log("Failed to create contact",t),i.vivocha.pageRequest("interactionFailed",t.message),i.zone.run(function(){i.uiService.setCreationFailed()})})})},t.prototype.getContactOptions=function(t){var e={campaignId:this.context.campaign.id,version:this.context.campaign.version,channelId:"web",entryPointId:this.context.entryPointId,engagementId:this.context.engagementId,initialOffer:this.protocolService.getInitialOffer(this.context.requestedMedia),lang:this.context.language,vvcu:this.context.page.vvcu,vvct:this.context.page.vvct,first_uri:this.context.page.first_uri,first_title:this.context.page.first_title};return this.context.page.first_uri&&(e.first_uri=this.context.page.first_uri),this.context.page.first_title&&(e.first_title=this.context.page.first_title),t?Object.assign({},e,t):Object.assign({},e)},t.prototype.hangUp=function(){var e=this;this.contact.getMediaOffer().then(function(t){t.Voice&&(t.Voice.tx="off",t.Voice.rx="off"),t.Video&&(t.Video.tx="off",t.Video.rx="off"),e.zone.run(function(){e.vivocha.setNormalScreen(),e.uiService.setHangUpState()}),e.contact.offerMedia(t).then(function(){e.zone.run(function(){"chat"!=e.context.requestedMedia&&e.askForUpgrade("Chat")})})})},t.prototype.hasRecallForNoAgent=function(){return!1},t.prototype.hideChat=function(){this.uiService.hideChat()},t.prototype.initializeContact=function(t,e){var i=this;this.vivocha=t,this.context=e,this.dcService.setInitialContext(e),this.isInPersistence()?(this.resumeContact(e),this.dcService.hasSurvey()&&this.dcService.onSurveyCompleted().subscribe(function(t){t&&t.completed&&i.contact.storeSurvey(t.surveyToSend)})):(this.dcService.onDataCollectionCompleted().subscribe(function(t){t&&t.completed&&(i.isAutoChat()?i.createAutoContact(t.creationOptions):(i.uiService.showQueuePanel(),i.createContact(t.creationOptions)))}),this.dcService.hasSurvey()&&this.dcService.onSurveyCompleted().subscribe(function(t){t&&t.completed&&i.contact.storeSurvey(t.surveyToSend)}),this.dcService.processDataCollections())},t.prototype.isAutoChat=function(){return"chat"===this.context.requestedMedia&&this.context.variables.autoChat},t.prototype.isChatEmulationContact=function(){return!1},t.prototype.isOfflineMessage=function(e){return!!this.messageArchive.filter(function(t){return t===e})[0]&&(this.messageArchive=A(this.messageArchive.filter(function(t){return t!==e})),!0)},t.prototype.isRecallContact=function(){return!1},t.prototype.isInPersistence=function(){return!!this.context.persistenceId},t.prototype.leave=function(n){var a=this;return new Promise(function(t,e){if(a.contact){var i=+new Date-a.interactionStart,o=n||(a.hasReceivedMsgs?"closed":1e4<i?"abandoned":"cancelled");a.contact.leave(o,function(){a.contact.release(),a.contact.channel.isConnected()&&a.contact.channel.disconnect(),t(o)})}else t("failed")})},t.prototype.mapContact=function(){var s=this;this.vivocha.pageRequest("interactionCreated",this.contact),this.contact.on("agentrequest",function(t,e){s.zone.run(function(){s.onAgentRequest(t,e)})}),this.contact.on("attachment",function(e,i,o,n,a){s.zone.run(function(){i.url=i.originalUrl?i.originalUrl:e;var t={body:i.desc||i.originalName,type:"chat",meta:i,from_nick:n,from_id:o};a?s.messageService.addChatMessage(t,s.agent,s.visitorNick):s.messageService.addChatMessage(t,null,s.visitorNick)})}),this.contact.on("joined",function(t){t.user?(s.dissuasionTimer&&(clearTimeout(s.dissuasionTimer),delete s.dissuasionTimer),s.onAgentJoin(t)):s.onLocalJoin(t)}),this.contact.on("rawmessage",function(t){s.zone.run(function(){"text"==t.type&&(t.quick_replies?s.messageService.addQuickRepliesMessage(t,s.agent):t.template?s.messageService.addTemplateMessage(t,s.agent):s.messageService.addChatMessage(t,s.agent,s.visitorNick),t.agent&&s.uiService.setIsWriting(!1),s.uiService.newMessageReceived(),s.context.variables.playAudioNotification&&s.playAudioNotification(),s.hasReceivedMsgs=!0)})}),this.contact.on("iswriting",function(t,e,i){s.zone.run(function(){i&&s.setIsWriting()})}),this.contact.on("localtext",function(t){s.zone.run(function(){s.agent&&s.agent.is_bot&&s.setIsWriting(),s.isOfflineMessage(t)||s.messageService.addLocalMessage(t)})}),this.contact.on("left",function(t){s.zone.run(function(){console.log("LEFT",t),t.channels&&t.channels.user!==undefined&&0===t.channels.user&&(s.uiService.setClosedByAgent(),s.vivocha.setNormalScreen(),s.messageService.sendSystemMessage("STRINGS.MESSAGES.REMOTE_CLOSE"),s.isClosed=!0)})}),this.contact.on("localcapabilities",function(t){}),this.contact.on("capabilities",function(t){}),this.contact.on("mediachange",function(t,e){console.log("MEDIACHANGE",JSON.stringify(t,null,2)),s.zone.run(function(){s.protocolService.setMediaChange(t),s.uiService.setMediaState(t)})}),this.contact.on("mediaoffer",function(t,e){s.zone.run(function(){s.onMediaOffer(t,e)})}),this.contact.on("transferred",function(){s.zone.run(function(){s.messageService.sendSystemMessage("STRINGS.MESSAGES.TRANSFERRED")})}),Object.keys(this.customActions).forEach(function(i){s.contact.on(i,function(t,e){s.zone.run(function(){s.customActions[i].callback=e,s.customActions[i].stream.next(t)})})})},t.prototype.mergeOffer=function(t,e){var i=this;this.contact.mergeMedia(t).then(function(t){i.zone.run(function(){e(undefined,t)})})},t.prototype.muteToggle=function(e){var i=this;this.uiService.setMuteInProgress(),this.contact.getMediaEngine("WebRTC").then(function(t){e?t.muteLocalAudio():t.unmuteLocalAudio(),i.zone.run(function(){i.uiService.setMuted(e)})})},t.prototype.minimize=function(t,e,i,o){t?(this.vivocha.minimize({bottom:i&&i.bottom?i.bottom:"10px",right:i&&i.right?i.right:"10px"},{width:o&&o.width?o.width:"70px",height:o&&o.height?o.height:"70px"}),this.uiService.setMinimizedState()):e?this.setFullScreen():(this.vivocha.maximize(),this.uiService.setNormalState())},t.prototype.minimizeMedia=function(){this.protocolService.isAlreadyConnectedWith("Chat")||this.askForUpgrade("Chat"),this.uiService.setMinimizedMedia()},t.prototype.noAgents=function(){return!1},t.prototype.onAgentJoin=function(i){var o=this;this.contact.getMedia().then(function(e){o.zone.run(function(){var t={id:i.user,nick:i.nick,is_bot:!!i.is_bot,is_agent:!i.is_bot};i.avatar&&(t.avatar=i.avatar),o.agent=t,o.vivocha.pageRequest("interactionAnswered",t),o.protocolService.setMediaChange(e),o.uiService.initializeMedia(e),o.setAnsweredState(t)})})},t.prototype.onAgentRequest=function(t,e){this.agentRequestCallback=e,this.lastSystemMessageId=this.messageService.sendRequestMessage(t)},t.prototype.onLocalJoin=function(t){var o=this;t.reason&&"resume"===t.reason&&this.contact.getMedia().then(function(i){o.zone.run(function(){var t=o.contact.contact.agentInfo,e={id:t.id,nick:t.nick,is_bot:!!t.bot,is_agent:!t.bot};t.avatar&&(e.avatar=t.avatar),console.log("LOCAL JOIN",e,o.contact),o.agent=e,o.uiService.setAgent(e),o.context.variables.showAgentInfoOnTopBar?o.uiService.setTopBarWithAgentInfo(e):o.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"}),o.protocolService.setMediaChange(i),o.uiService.initializeMedia(i),o.checkForTranscript()})}),this.autoChat&&(this.messageArchive.map(function(t){return o.contact.sendText(t)}),this.autoChat=!1)},t.prototype.onMediaOffer=function(t,e){this.uiService.setMediaOffer(t);var i=this.protocolService.confirmNeeded(t);if(i.askForConfirmation)this.incomingMedia=i.media,this.uiService.setIncomingMedia(i.media),this.incomingCallback=e,this.incomingOffer=i.offer;else{var o=this.protocolService.mergeOffer(t);this.mergeOffer(o,e)}},t.prototype.openAttachment=function(t){var e={type:"web_url",url:t};this.vivocha.pageRequest("interactionEvent",e.type,e)},t.prototype.playAudioNotification=function(){var t=new Audio;t.src=window.beepmp3,t.load(),t.play()},t.prototype.processQuickReply=function(t){this.messageService.updateQuickReply(t.msgId);var e={code:"message",type:"text",body:t.action.title};t.action.payload!==undefined&&(e.payload=t.action.payload),this.contact.send(e),this.messageService.addLocalMessage(t.action.title)},t.prototype.registerCustomAction=function(t){return this.customActions[t.id]={stream:new n.Subject},this.customActions[t.id].stream},t.prototype.rejectAgentRequest=function(t){this.agentRequestCallback(null,!1),this.messageService.removeMessage(this.lastSystemMessageId),this.messageService.sendSystemMessage("STRINGS.MESSAGES."+t.toUpperCase()+"_REJECTED")},t.prototype.rejectOffer=function(){this.incomingCallback("error",{}),this.messageService.sendSystemMessage("STRINGS.CALL_REJECTED"),this.uiService.setOfferRejected()},t.prototype.resumeContact=function(e){var i=this;this.vivocha.dataRequest("getData","persistence.contact").then(function(t){i.vivocha.resumeContact(t).then(function(t){i.zone.run(function(){i.uiService.initializeProtocol(e,{initialOffer:i.protocolService.getInitialOffer(e.requestedMedia)}),i.contact=t,i.mapContact()})},function(t){console.log("Failed to resume contact",t),i.vivocha.pageRequest("interactionFailed",t.message)})})},t.prototype.sendAttachment=function(t){var e=this;this.uiService.setUploading(),this.contact.attach(t.file,t.text).then(function(){e.zone.run(function(){e.uiService.setUploaded()})})},t.prototype.sendIsWriting=function(){this.autoChat||this.contact.sendIsWriting()},t.prototype.sendPostBack=function(t){var e={code:"message",type:"postback",body:t.title};t.payload!==undefined&&(e.payload=t.payload),"postback"===t.type?this.contact.send(e):this.vivocha.pageRequest("interactionEvent",t.type,t)},t.prototype.sendRequest=function(t,e){return this.contact.request(t,e)},t.prototype.sendText=function(t){this.autoChat?(this.messageArchive.push(t),this.messageService.addChatMessage({body:t,ts:+(new Date).getTime()}),1===this.messageArchive.length&&this.createContact(this.autoChatInitialData)):this.contact.sendText(t)},t.prototype.setAnsweredState=function(t){this.messageService.removeMessage(this.lastSystemMessageId),this.uiService.setAgent(t),this.context.variables.showAgentInfoOnTopBar?this.uiService.setTopBarWithAgentInfo(t):this.uiService.setTopBar({title:"STRINGS.TOPBAR.TITLE_DEFAULT",subtitle:"STRINGS.TOPBAR.SUBTITLE_DEFAULT"}),this.context.variables.showWelcomeMessage&&(this.lastSystemMessageId=this.messageService.sendSystemMessage("STRINGS.CHAT.WELCOME_MESSAGE",{nickname:t.nick}))},t.prototype.setIsWriting=function(){var t=this;clearTimeout(this.isWritingTimer),this.uiService.setIsWriting(!0),this.isWritingTimer=setTimeout(function(){t.uiService.setIsWriting(!1)},this.isWritingTimeout)},t.prototype.setQueueState=function(){this.lastSystemMessageId=this.messageService.sendSystemMessage("STRINGS.QUEUE.CONNECTING")},t.prototype.setFullScreen=function(){this.uiService.setFullScreen(),this.vivocha.setFullScreen()},t.prototype.setNormalScreen=function(){this.uiService.setNormalScreen(),this.vivocha.setNormalScreen()},t.prototype.setTopBar=function(t,e,i){this.uiService.setTopBarWithAvatar(t,e,i)},t.prototype.setTopBarAvatar=function(t){this.uiService.setTopBarAvatar(t)},t.prototype.setTopBarSubtitle=function(t){this.uiService.setTopBarSubtitle(t)},t.prototype.setTopBarTitle=function(t){this.uiService.setTopBarTitle(t)},t.prototype.showCloseModal=function(t){this.uiService.setCloseModal(t)},t.prototype.showUploadPanel=function(){this.uiService.setUploadPanel(!0)},t.prototype.showSurvey=function(){this.dcService.showSurvey()},t.prototype.submitDataCollection=function(t){this.dcService.submitDataCollection(t)},t.prototype.submitSurvey=function(t){this.dcService.submitSurvey(t)},t.prototype.toggleEmojiPanel=function(){this.uiService.toggleEmojiPanel()},t.prototype.toggleVideo=function(i){var o=this;this.contact.getMediaOffer().then(function(t){if(t.Video){var e=t.Video.tx;t.Video.tx="required"===e?"off":"required"}o.zone.run(function(){o.uiService.setInTransit(!0)}),console.log("TOGGLE VIDEO",i,JSON.stringify(t,null,2)),o.contact.offerMedia(t).then(function(){o.zone.run(function(){o.uiService.setInTransit(!1)})})})},t}();fe.decorators=[{type:e.Injectable}],fe.ctorParameters=function(){return[{type:i.Store},{type:le},{type:he},{type:m},{type:de},{type:e.NgZone}]};var ge=function(){function t(t,e,i){this.store=t,this.contextService=e,this.contactService=i}return t.prototype.acceptAgentRequest=function(t){this.contactService.acceptAgentRequest(t)},t.prototype.acceptOffer=function(){this.contactService.acceptOffer()},t.prototype.addChatToFullScreen=function(t){this.contactService.addChatToFullScreen(t)},t.prototype.askForVideoUpgrade=function(){this.contactService.askForUpgrade("Video")},t.prototype.askForVoiceUpgrade=function(){this.contactService.askForUpgrade("Voice")},t.prototype.closeApp=function(){this.contactService.closeApp()},t.prototype.closeContact=function(){this.contactService.closeContact()},t.prototype.closeUploadPanel=function(){this.contactService.closeUploadPanel()},t.prototype.dismissCloseModal=function(){this.contactService.showCloseModal(!1)},t.prototype.getState=function(){return this.store.select(re)},t.prototype.hangUp=function(){this.contactService.hangUp()},t.prototype.hideChat=function(){this.contactService.hideChat()},t.prototype.init=function(){var e=this;this.contextService.ready().subscribe(function(t){t.loaded&&(e.vivocha=e.contextService.getVivocha(),e.context=t,e.contactService.initializeContact(e.vivocha,e.context))})},t.prototype.minimize=function(t,e,i,o){this.contactService.minimize(t,e,i,o)},t.prototype.minimizeMedia=function(){this.contactService.minimizeMedia()},t.prototype.muteToggle=function(t){this.contactService.muteToggle(t)},t.prototype.openAttachment=function(t){this.contactService.openAttachment(t)},t.prototype.processQuickReply=function(t){this.contactService.processQuickReply(t)},t.prototype.registerCustomAction=function(t){return this.contactService.registerCustomAction(t)},t.prototype.rejectAgentRequest=function(t){this.contactService.rejectAgentRequest(t)},t.prototype.rejectOffer=function(){this.contactService.rejectOffer()},t.prototype.sendAttachment=function(t){this.contactService.sendAttachment(t)},t.prototype.sendIsWriting=function(){this.contactService.sendIsWriting()},t.prototype.sendPostBack=function(t){this.contactService.sendPostBack(t)},t.prototype.sendRequest=function(t,e){return this.contactService.sendRequest(t,e)},t.prototype.sendText=function(t){this.contactService.sendText(t)},t.prototype.setFullScreen=function(){this.contactService.setFullScreen()},t.prototype.setNormalScreen=function(){this.contactService.setNormalScreen()},t.prototype.setTopBar=function(t,e,i){this.contactService.setTopBar(t,e,i)},t.prototype.setTopBarAvatar=function(t){this.contactService.setTopBarAvatar(t)},t.prototype.setTopBarSubtitle=function(t){this.contactService.setTopBarSubtitle(t)},t.prototype.setTopBarTitle=function(t){this.contactService.setTopBarTitle(t)},t.prototype.showCloseModal=function(){this.contactService.showCloseModal(!0)},t.prototype.showUploadPanel=function(){this.contactService.showUploadPanel()},t.prototype.showSurvey=function(){this.contactService.showSurvey()},t.prototype.submitDataCollection=function(t){this.contactService.submitDataCollection(t)},t.prototype.submitSurvey=function(t){this.contactService.submitSurvey(t)},t.prototype.toggleEmojiPanel=function(){this.contactService.toggleEmojiPanel()},t.prototype.toggleVideo=function(t){this.contactService.toggleVideo(t)},t}();function ve(t){var e=location.pathname.match(/(.*\/api\/v2\/public\/campaigns\/\w+\/\w+\/interaction\/)\w+(\/[^\/]+\/[^\/]+)\/main\.html/),i=location.origin+e[1];return new r.TranslateHttpLoader(t,i,e[2]+"/strings.json")}ge.decorators=[{type:e.Injectable}],ge.ctorParameters=function(){return[{type:i.Store},{type:pe},{type:fe}]};var me=ve,ye=function(){};function Se(t){var e=location.pathname.match(/(.*\/api\/v2\/public\/campaigns\/\w+\/\w+\/interaction\/)\w+(\/[^\/]+\/[^\/]+)\/main\.html/),i=location.origin+e[1];return new r.TranslateHttpLoader(t,i,e[2]+"/strings.json")}ye.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,s.HttpClientModule,i.StoreModule.forRoot(ee,{}),o.TranslateModule.forRoot({loader:{provide:o.TranslateLoader,useFactory:me,deps:[s.HttpClient]}})],providers:[ge,m,pe,fe,de,he,le,ue]}]}];var Ce=Se,be=function(){};be.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,s.HttpClientModule,i.StoreModule.forRoot(ee,{}),o.TranslateModule.forRoot({loader:{provide:o.TranslateLoader,useFactory:Ce,deps:[s.HttpClient]}}),u.StoreDevtoolsModule.instrument({maxAge:50})],providers:[ge,m,pe,fe,de,he,le,ue]}]}],t.VvcMessageService=m,t.VvcInteractionService=ge,t.InteractionCoreModule=ye,t.InteractionCoreDebugModule=be,t.ɵb=Se,t.ɵa=ve,t.ɵh=fe,t.ɵe=pe,t.ɵi=le,t.ɵj=he,t.ɵf=de,t.ɵg=ue,t.ɵo=te,t.ɵm=Lt,t.ɵd=ee,t.ɵl=Bt,t.ɵn=Zt,t.ɵk=qt,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=vivocha-client-interaction-core.umd.min.js.map
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"name": "@vivocha/client-interaction-core",
"version": "6.1.2",
"version": "6.1.3",
"license": "SEE LICENSE IN LICENSE",

@@ -6,0 +6,0 @@ "repository": {

@@ -67,2 +67,3 @@ export interface ContextState {

completed?: boolean;
surveyToSend?: any;
}

@@ -69,0 +70,0 @@ export interface TopBarState {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc