"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TrackToggle = exports.getSourceIcon = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const livekit_client_1 = require("livekit-client");
const components_react_1 = require("@livekit/components-react");
function getSourceIcon(source, enabled) {
    switch (source) {
        case livekit_client_1.Track.Source.Microphone:
            return enabled ? (0, jsx_runtime_1.jsx)(components_react_1.MicIcon, {}) : (0, jsx_runtime_1.jsx)(components_react_1.MicDisabledIcon, {});
        case livekit_client_1.Track.Source.Camera:
            return enabled ? (0, jsx_runtime_1.jsx)(components_react_1.CameraIcon, {}) : (0, jsx_runtime_1.jsx)(components_react_1.CameraDisabledIcon, {});
        case livekit_client_1.Track.Source.ScreenShare:
            return enabled ? (0, jsx_runtime_1.jsx)(components_react_1.ScreenShareStopIcon, {}) : (0, jsx_runtime_1.jsx)(components_react_1.ScreenShareIcon, {});
        default:
            return undefined;
    }
}
exports.getSourceIcon = getSourceIcon;
/**
 * With the `TrackToggle` component it is possible to mute and unmute your camera and microphone.
 * The component uses an html button element under the hood so you can treat it like a button.
 */
exports.TrackToggle = 
/* @__PURE__ */ React.forwardRef(function TrackToggle(_a, ref) {
    var { showIcon, disabled } = _a, props = tslib_1.__rest(_a, ["showIcon", "disabled"]);
    const { buttonProps, enabled } = (0, components_react_1.useTrackToggle)(props);
    return ((0, jsx_runtime_1.jsxs)("button", Object.assign({ ref: ref }, buttonProps, { disabled: disabled }, { children: [(showIcon !== null && showIcon !== void 0 ? showIcon : true) && getSourceIcon(props.source, enabled && !disabled), props.children] })));
});
