Loading
function(e,t,n){n.d(t,{V:()=>N,A:()=>P});var i,l=n(477900),r=n(582128),s=n(503698),a=n.n(s),o=n(435558),u=n.n(o),d=n(17928),c=n(205693),h=n(451988),f=n(834730),g=n(452027),C=n(821609),A=n(866665),p=n(827343),m=n(765671),E=n(661531),I=n(953727);function S(e){let{width:t=80,height:n=28,color:i="currentColor",foreground:s,...a}=e,o=`pill-frame-pattern-${n}`,u=r.useMemo(()=>{let e;return e=n-8,`m0 0h8v${n}h-8zm4 2c-1.1045695 0-2 .8954305-2 2v${e}c0 1.1045695.8954305 2 2 2s2-.8954305 2-2v-${e}c0-1.1045695-.8954305-2-2-2z`},[n]);return(0,l.jsxs)("svg",{...(0,I.A)(a),width:t,height:n,viewBox:`0 0 ${t} ${n}`,children:[(0,l.jsx)("pattern",{id:o,width:8/t,height:"1",children:(0,l.jsx)("path",{d:u,fillRule:"evenodd",fill:i,className:s})}),(0,l.jsx)("rect",{fill:`url(#${o})`,height:"100%",width:"100%"})]})}var _=n(838949),N=((i={}).BLACK="BLACK",i.GRAY="GRAY",i);let T={BLACK:_.Ql,GRAY:_.wm},M={sm:20,md:28};function v(e){return 8*Math.round(e/8)}function y(e){let{notchBackground:t,progress:n,size:i="md",gradientStart:s=E.A.unsafe_rawColors.YELLOW_260.css,gradientEnd:o=E.A.unsafe_rawColors.GREEN_360.css,className:u,notchClassName:d,children:c}=e,h=M[i],{ref:f,width:g}=(0,m.Ay)(),C=r.useMemo(()=>null!=g?v(g):0,[g]),A=r.useMemo(()=>{let e=Math.abs(v(C*(100-Math.max(0,Math.min(100,n)))/100)-C);return{transform:`translateX(${e}px)`}},[n,C]),p=r.useMemo(()=>({width:`${C}px`,background:n<=0?"none":`linear-gradient(to right, ${s}, ${o})`}),[o,s,n,C]);return(0,l.jsxs)("div",{className:_.iE,ref:f,style:{height:h},children:[(0,l.jsxs)("div",{className:a()(_.kL,u),style:p,children:[(0,l.jsx)("div",{className:_.qB,style:A}),0!==C&&(0,l.jsx)(S,{width:C,height:h,className:a()(_.DR,T[t],d)})]}),c]})}var L=n(360906),x=n(763827),D=n(174459),R=n(652215),O=n(105292),w=n(193221);class U extends r.PureComponent{_initTimeout=new h.Ep;_silenceTimeout=new h.Ep;_messageTimeout=new h.Ep;_micTestStartTime;state={volume:-100,isMicTesting:!1,isDetectingInput:!0,didDeafenUser:!1};componentDidMount(){this._initTimeout.start(1e3,this.setupVoiceActivity)}setupVoiceActivity=()=>{L.Ay.getMediaEngine().on(c.bg.VoiceActivity,this.handleVoiceActivity)};componentWillUnmount(){this._initTimeout.stop(),this._silenceTimeout.stop(),this._micTestStop(),L.Ay.getMediaEngine().removeListener(c.bg.VoiceActivity,this.handleVoiceActivity)}handleVoiceActivity=e=>{let{isMicTesting:t}=this.state;if(t&&e<=-100){this._silenceTimeout.isStarted()||this._silenceTimeout.start(2e3,()=>{this.setState({isDetectingInput:!1})}),this.setState({volume:-100});return}this._silenceTimeout.stop(),this.setState({volume:e,isDetectingInput:!0})};_micTestStart(){let{isVoiceConnected:e,inputDeviceName:t,inputVolume:n,outputDeviceName:i,outputVolume:l,inputMode:r,vadAutoThreshold:s,vadThreshold:a,location:o,isDeafened:u}=this.props,d=!1;e&&!u&&(p.default.toggleSelfDeaf(),d=!0),p.default.setLoopback("mic_test",!0),this._micTestStartTime=Date.now(),this.setState({isMicTesting:!0,isDetectingInput:!0,didDeafenUser:d}),D.default.track(R.HAw.MIC_TESTING_STARTED,{input_device_name:t,input_device_volume:n,output_device_name:i,output_device_volume:l,input_mode:r,input_sensitivity_is_automatic:s,input_sensitivity_threshold:Math.round(a),location:o})}_micTestStop(){let{didDeafenUser:e,isMicTesting:t}=this.state,{isVoiceConnected:n,isDeafened:i}=this.props;t&&(n&&i&&e&&p.default.toggleSelfDeaf(),p.default.setLoopback("mic_test",!1),this.setState({isMicTesting:!1,didDeafenUser:!1}),null!=this._micTestStartTime&&D.default.track(R.HAw.MIC_TESTING_STOPPED,{testing_duration:Math.round((Date.now()-this._micTestStartTime)/1e3)}))}handleToggleMicTest=()=>{this.state.isMicTesting?this._micTestStop():this._micTestStart()};renderCaption(){let{captionVoice:e,captionNoVoice:t}=this.props,{isMicTesting:n,isDetectingInput:i}=this.state;return null==e&&null==t?null:(0,l.jsx)("span",{"aria-live":"polite","aria-atomic":"true",className:w.b_,children:(0,l.jsx)(f.E,{variant:"text-xs/normal",color:"text-subtle",className:w.Qe,children:n?i?e:t:void 0})})}render(){let{isVoiceConnected:e,title:t,description:n,notchBackground:i,buttonTest:r="",buttonStop:s="",buttonVariant:o="secondary",size:u="sm",isDeafened:d,buttonMinWidth:c,measureButtonRef:h,meterOnly:p=!1,containerClassName:m,helpText:E}=this.props,{isMicTesting:I,volume:S,isDetectingInput:_}=this.state,N=e&&!I?O.intl.string(O.t["9viE2A"]):null;I&&e&&!d&&this._micTestStop();let T=s.length>=r.length?s:r;return(0,l.jsxs)("div",{className:a()(w.kL,m),children:[(0,l.jsx)(g.D,{label:t??void 0,hideLabel:p,description:p?null:n,children:(0,l.jsxs)("div",{className:a()(w.ak,{[w.mi]:p,[w.EX]:"sm"===u}),children:[!p&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:w.km,"aria-hidden":!0,children:(0,l.jsx)(C.$,{buttonRef:h,size:u,variant:o,text:T,tabIndex:-1})}),(0,l.jsx)(A.m,{text:N,children:(0,l.jsx)("div",{style:null!=c?{minWidth:c}:{opacity:0},children:(0,l.jsx)(C.$,{size:u,variant:o,text:I?s:r,onClick:this.handleToggleMicTest,fullWidth:!0})})})]}),(0,l.jsx)(y,{progress:I||p?S+100:0,notchBackground:i,notchClassName:this.props.notchClassName,size:u}),this.renderCaption()]})}),null!=E&&(0,l.jsx)(f.E,{variant:"text-sm/normal",color:"text-subtle",style:{visibility:I&&!_?"hidden":"visible"},children:E})]})}}function P(e){let{inputDevice:t,outputDevice:n,threshold:i,autoThreshold:r,inputVolume:s,outputVolume:a,inputMode:o,isDeafened:c}=(0,d.cf)([L.Ay],()=>{let e=L.Ay.getInputDeviceId(),t=L.Ay.getInputDevices(),n=u().find(t,t=>{let{id:n}=t;return n===e}),i=L.Ay.getOutputDeviceId(),l=L.Ay.getOutputDevices(),r=u().find(l,e=>{let{id:t}=e;return t===i}),{threshold:s,autoThreshold:a}=L.Ay.getModeOptions(),o=L.Ay.getInputVolume(),d=L.Ay.getOutputVolume();return{inputDevice:n,outputDevice:r,threshold:s,autoThreshold:a,inputVolume:o,outputVolume:d,inputMode:L.Ay.getMode(),isDeafened:L.Ay.isSelfDeaf()}}),h=(0,d.bG)([x.A],()=>x.A.isConnected()),{ref:f,width:g}=(0,m.Ay)();return(0,l.jsx)(U,{isVoiceConnected:h,inputVolume:s,outputVolume:a,inputMode:o,isDeafened:c,vadThreshold:i,vadAutoThreshold:r,inputDeviceName:t?.name??"",outputDeviceName:n?.name??"",measureButtonRef:f,buttonMinWidth:g,...e})}}