"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("../../node_modules/react-redux/es/index.js"),require("../../node_modules/@babel/runtime/helpers/defineProperty.js"),require("../../node_modules/@babel/runtime/helpers/objectWithoutProperties.js"),require("../../node_modules/@babel/runtime/helpers/typeof.js"),require("../../node_modules/html-parse-stringify/dist/html-parse-stringify.js"),require("../../node_modules/react-i18next/dist/es/context.js");var t=require("../../node_modules/react-i18next/dist/es/useTranslation.js");require("../../node_modules/@babel/runtime/helpers/slicedToArray.js");var r=require("../Button.js"),l=require("../../node_modules/@fortawesome/react-fontawesome/index.es.js"),u=require("../../node_modules/@fortawesome/free-solid-svg-icons/index.mjs.js"),n=require("../GenericAvatar.js"),i=require("../CustomThemedTooltip.js"),o=require("../../node_modules/react-redux/es/hooks/useSelector.js"),a=require("../../node_modules/react-redux/es/hooks/useDispatch.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(e);exports.OperatorBusyView=function(){var s=o.useSelector((function(e){return e.island})),d=s.operatorBusy,m=s.previousView,f=o.useSelector((function(e){return e.avatars})).avatars,p=o.useSelector((function(e){return e.users})).extensions,v=t.useTranslation().t,b=a.useDispatch(),x=o.useSelector((function(e){return e.conference})),y=x.isActive,j=x.conferenceStartedFrom,N=o.useSelector((function(e){return e.currentUser})).username,q=o.useSelector((function(e){return e.currentCall})),w=q.accepted,h=q.incoming,_=q.outgoing,E=e.useCallback((function(){return y&&j===N?"waitingConference":w||h||_?m||"call":null}),[w,j,h,y,_,m,N]),C=e.useCallback((function(){b.player.stopAudioPlayer(),b.island.resetOperatorBusyCompletely(),b.island.setIslandView(E())}),[b,E]),g=e.useMemo((function(){if((null==d?void 0:d.calledNumber)&&p){var e=Object.values(p).find((function(e){return e.exten===(null==d?void 0:d.calledNumber)}));return e?null==e?void 0:e.username:null}return null}),[p,null==d?void 0:d.calledNumber]),k=e.useMemo((function(){return g&&f&&f[g]?f[g]:null}),[f,g]),T=e.useMemo((function(){return null!==g}),[g]),S=e.useMemo((function(){if(p&&(null==d?void 0:d.calledNumber)&&""!==(null==d?void 0:d.calledNumber)){var e=Object.values(p).find((function(e){return(null==e?void 0:e.exten)===(null==d?void 0:d.calledNumber)}));return e&&(null==e?void 0:e.name)&&""!==(null==e?void 0:e.name)?null==e?void 0:e.name:null==d?void 0:d.calledNumber}return"-"}),[null==d?void 0:d.calledNumber,p]),A=e.useMemo((function(){return v(T?"Call.User busy":"Call.Number busy")}),[v,T]);return e.useEffect((function(){return function(){b.player.stopAudioPlayer()}}),[b]),e.useEffect((function(){var e=window.setTimeout((function(){C()}),4e3);return function(){window.clearTimeout(e)}}),[C]),c.default.createElement(c.default.Fragment,null,c.default.createElement("div",{className:"pi-flex pi-items-center pi-justify-between pi-w-full"},c.default.createElement("div",{className:"pi-flex pi-items-center pi-space-x-3"},c.default.createElement(n.GenericAvatar,{avatarUrl:k,size:"open",showPulseEffect:!1}),c.default.createElement("div",{className:"pi-flex pi-flex-col"},c.default.createElement("div",{className:"pi-text-lg pi-font-medium pi-text-primaryNeutral dark:pi-text-primaryNeutralDark"},S),c.default.createElement("div",{className:"pi-text-sm pi-font-regular pi-text-primaryNeutral dark:pi-text-primaryNeutralDark"},A))),c.default.createElement(r.Button,{variant:"default",onClick:C,className:"pi-p-2","data-tooltip-id":"tooltip-close-busy-call","data-tooltip-content":v("Tooltip.Close")||"Close"},c.default.createElement(l.FontAwesomeIcon,{icon:u.faXmark,className:"pi-w-5 pi-h-5"}))),c.default.createElement(i.CustomThemedTooltip,{className:"pi-z-20",id:"tooltip-close-busy-call",place:"left"}))};
//# sourceMappingURL=index.js.map
