"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("../../node_modules/react-redux/es/index.js");var t=require("../../store/index.js"),i=require("../../node_modules/@fortawesome/react-fontawesome/index.es.js"),r=require("../../node_modules/@fortawesome/free-solid-svg-icons/index.mjs.js"),n=require("../../node_modules/i18next/dist/esm/i18next.js"),a=require("../../utils/customHooks/useEventListener.js"),s=require("../../utils/genericFunctions/eventDispatch.js"),l=require("../../utils/genericFunctions/localStorage.js");require("../../node_modules/tslib/tslib.es6.js");var o=require("./SettingsHeader.js"),c=require("../../lib/devices/devices.js"),d=require("../../node_modules/react-redux/es/hooks/useSelector.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=u(e);exports.default=function(){var u=d.useSelector((function(e){return e.webrtc})).sipcall,v=e.useState(c.getCurrentVideoInputDeviceId()||null),m=v[0],f=v[1],g=t.store.select.mediaDevices.videoInputDevices(t.store.getState()),b=function(e){f(e),u.webrtcStuff.myStream?null==u||u.replaceTracks({tracks:[{type:"video",mid:"1",capture:{deviceId:{exact:e}}}],success:function(){console.info("Video input device switch success"),l.setJSONItem("phone-island-video-input-device",{deviceId:e}),s.eventDispatch("phone-island-call-video-input-switched",{})},error:function(e){console.error("Video input device switch error:",e)}}):(l.setJSONItem("phone-island-video-input-device",{deviceId:e}),s.eventDispatch("phone-island-call-video-input-switched",{}))};a.useEventListener("phone-island-call-video-input-switch",(function(e){b(e.deviceId)}));var x=e.useState(null),y=x[0],h=x[1];return p.default.createElement("div",{className:"pi-flex pi-flex-col pi-w-full"},p.default.createElement(o.SettingsHeader,{title:n.t("Settings.Cameras"),tooltipPrefix:"video"}),p.default.createElement("div",{className:"pi-flex pi-flex-col pi-mt-2 pi-space-y-1 pi-max-h-48 pi-overflow-y-auto pi-scrollbar-thin pi-scrollbar-thumb-gray-400 pi-dark:scrollbar-thumb-gray-400 pi-scrollbar-thumb-rounded-full pi-scrollbar-thumb-opacity-50 dark:pi-scrollbar-track-gray-900 pi-scrollbar-track-gray-200 pi-dark:scrollbar-track-gray-900 pi-scrollbar-track-rounded-full pi-scrollbar-track-opacity-25"},g.map((function(e,t){return p.default.createElement("div",{key:t,className:"pi-flex pi-items-center pi-justify-between pi-px-4 pi-py-3 pi-text-base pi-font-normal pi-leading-6 dark:pi-text-gray-200 pi-text-gray-700 hover:pi-bg-gray-200 dark:hover:pi-bg-gray-700 dark:pi-bg-gray-950 pi-bg-gray-50 pi-rounded-md pi-cursor-pointer",onClick:function(){return b(null==e?void 0:e.deviceId)},onMouseEnter:function(){return h(null==e?void 0:e.deviceId)},onMouseLeave:function(){return h(null)}},p.default.createElement("div",{className:"pi-flex pi-items-center"},p.default.createElement(i.FontAwesomeIcon,{icon:r.faVideo,className:" pi-mr-2"}),p.default.createElement("span",null,(null==e?void 0:e.label)||"Input device ".concat(t+1))),p.default.createElement("div",{className:"pi-flex pi-items-center"},m===(null==e?void 0:e.deviceId)&&p.default.createElement(i.FontAwesomeIcon,{icon:r.faCheck,className:"".concat(y===(null==e?void 0:e.deviceId)?"pi-text-gray-500 dark:pi-text-gray-200":"pi-text-green-600 dark:pi-text-green-400")})))}))))};
//# sourceMappingURL=VideoInputView.js.map
