import{ct as T,c as h,x as v,y as _,b as t,v as c,i as w,J as M,cn as x,t as y,o as L}from"./index-6Jqoo2rk.js";import{a0 as P,ao as R,ar as i,ap as d,aS as q,aT as z,as as E,aU as S,aV as C}from"./appDialogsManager-DnVhdlim.js";import"./emailSetup-CFcJlzt-.js";import"./iconTsx-Cr8T7ZIv.js";import"./bootstrapIm-BS8HLnlI.js";import"./transition-DuxZkCEv.js";import"./mediaHeader-B5k-4_FU.js";import"./animations-O3syBkMX.js";import"./accumulate-BydAFozl.js";import"./browser-BlRx6CLO.js";import"./_commonjsHelpers-DsqdWQfm.js";import"./putPreloader-WBjcuDFX.js";import"./htmlToSpan-DhAls8qz.js";import"./anchorCallback-DsA1XczG.js";import"./toast-B3QB1-N7.js";import"./paintQrCode-u2FNs0A8.js";import"./fastBlur-Co-79rP4.js";import"./space-DBcSn32d.js";import"./telInputField-Fj4gE689.js";import"./readBlobAsDataURL-DL2tTmc_.js";import"./tracking-CIK7NCFD.js";import"./getInputPasskeyResponse-RiY9Fe0r.js";import"./base64ToBytes-B7rMxzcy.js";import"./sha256-BMgYLqDy.js";import"./bytesCmp-DgkPox5J.js";const O=y("<div class=speakers-and-camera-meter-wrap>");function pe(){const[D]=P(),k=R(),[n,o]=T(),[I,g]=h([]),[l,p]=h(void 0),b=()=>!l()?.pFlags?.call_requests_disabled,u=()=>{navigator.mediaDevices.enumerateDevices().then(g).catch(()=>g([]))};k.collect(v.managers.appAccountManager.getAuthorizations().then(e=>{const r=e.authorizations.find(a=>a.pFlags?.current);p(r)}).catch(()=>{})),_(()=>{D.header.classList.add("with-border"),u(),navigator.mediaDevices.addEventListener?.("devicechange",u),L(()=>{navigator.mediaDevices.removeEventListener?.("devicechange",u)})});const m=(e,r)=>{if(!r)return c("CallSettings.DeviceDefault");const a=I().find(s=>s.kind===e&&s.deviceId===r);return a?x(a.label||a.deviceId):c("CallSettings.DeviceDefault")},A=()=>{S({kind:"audiooutput",currentId:n.callDevices?.speakerId||"",titleLangKey:"CallSettings.Speakers",onPick:e=>{o("callDevices","speakerId",e),C("speaker",e)},onStaleCurrentId:()=>{o("callDevices","speakerId","")}})},f=()=>{S({kind:"audioinput",currentId:n.callDevices?.microphoneId||"",titleLangKey:"CallSettings.Microphone",onPick:e=>{o("callDevices","microphoneId",e),C("microphone",e)},onStaleCurrentId:()=>{o("callDevices","microphoneId","")}})},F=e=>{const r=l();if(!r)return;const a=r.pFlags?.call_requests_disabled;p({...r,pFlags:{...r.pFlags,call_requests_disabled:e?void 0:!0}}),v.managers.appAccountManager.changeAuthorizationSettings(r.hash,{callRequestsDisabled:!e}).catch(s=>{p({...r,pFlags:{...r.pFlags,call_requests_disabled:a}}),console.error("changeAuthorizationSettings failed",s)})};return[t(d,{name:"CallSettings.OutputSection",get children(){return t(i,{clickable:A,get children(){return t(i.Title,{get titleRight(){return m("audiooutput",n.callDevices?.speakerId||"")},titleRightSecondary:!0,get children(){return c("CallSettings.OutputDevice")}})}})}}),t(d,{name:"CallSettings.InputSection",get children(){return[t(i,{clickable:f,get children(){return t(i.Title,{get titleRight(){return m("audioinput",n.callDevices?.microphoneId||"")},titleRightSecondary:!0,get children(){return c("CallSettings.InputDevice")}})}}),(()=>{const e=O();return w(e,t(q,{get deviceId(){return n.callDevices?.microphoneId}})),e})()]}}),t(z,{}),t(M,{get when(){return l()},get children(){return t(d,{caption:"CallSettings.AcceptCalls.Caption",get children(){return t(i,{get children(){return[t(i.CheckboxFieldToggle,{get children(){return t(E,{toggle:!0,get checked(){return b()},onChange:F})}}),t(i.Title,{get children(){return c("CallSettings.AcceptCalls")}})]}})}})}})]}export{pe as default};
//# sourceMappingURL=speakersAndCamera-BnIH_JJg.js.map
