// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { _isInCall, _isPreviewOn } from "../../../../../calling-component-bindings/src";
import * as reselect from 'reselect';
import { getDeviceManager, getLocalVideoStreams } from './baseSelectors';
import { callStatusSelector } from './callStatusSelector';
/**
 * @private
 */
export const localVideoSelector = reselect.createSelector([callStatusSelector, getDeviceManager, getLocalVideoStreams], (callStatus, deviceManager, localVideoStreams) => {
    var _a, _b;
    let localVideoStream;
    if (_isInCall(callStatus.callStatus)) {
        localVideoStream = localVideoStreams === null || localVideoStreams === void 0 ? void 0 : localVideoStreams.find(i => i.mediaStreamType === 'Video');
    }
    else if (_isPreviewOn(deviceManager)) {
        // TODO: we should take in a LocalVideoStream that developer wants to use as their 'Preview' view. We should also
        // handle cases where 'Preview' view is in progress and not necessary completed.
        localVideoStream = deviceManager.unparentedViews[0];
    }
    return {
        isAvailable: !!localVideoStream,
        isMirrored: (_a = localVideoStream === null || localVideoStream === void 0 ? void 0 : localVideoStream.view) === null || _a === void 0 ? void 0 : _a.isMirrored,
        renderElement: (_b = localVideoStream === null || localVideoStream === void 0 ? void 0 : localVideoStream.view) === null || _b === void 0 ? void 0 : _b.target,
        activeVideoEffects: localVideoStream === null || localVideoStream === void 0 ? void 0 : localVideoStream.videoEffects
    };
});
//# sourceMappingURL=localVideoStreamSelector.js.map