/*!
 * Copyright 2020 by ChartIQ, Inc.
 * All rights reserved.
 *
 * This is a deprecated version of LinkerMenu which uses the linkerClient. It is not compatible with FDC3 interop.
 */
import * as React from "react";
import { useLinker } from "../../hooks/useLinker";
import { FinsembleProvider } from "../FinsembleProvider";
import { FEAGlobals } from "../../../common/Globals";
import "../../assets/css/linkerWindow.css";
const MAXIMUM_CHANNEL_SELECTIONS = 20;
const HIT_MAXIMUM_CHANNEL_SELECTIONS_ERROR_MESSAGE = `Attempted to render more channels than allowed. UI may look bad displaying more than ${MAXIMUM_CHANNEL_SELECTIONS} channels`;
export const LinkerElement = () => {
    FEAGlobals.FSBL.Clients.Logger.deprecated("This is a deprecated version of LinkerMenu which uses the linkerClient.  It will be removed in a future Finsemble version. It is not compatible with FDC3 interop.");
    const { state, toggleChannel } = useLinker();
    const allChannels = Object.values(state.channels);
    const channelElements = allChannels.map(({ color, border, name, active, id }, index) => {
        if (index > MAXIMUM_CHANNEL_SELECTIONS - 1) {
            FEAGlobals.FSBL.Clients.Logger.error(HIT_MAXIMUM_CHANNEL_SELECTIONS_ERROR_MESSAGE);
            return;
        }
        const groupClass = `linkerGroup ${color}`;
        const style = {
            backgroundColor: color,
            border: `1px solid ${border !== null && border !== void 0 ? border : color}`,
        };
        return (React.createElement("div", { key: id, className: "channel-wrapper", onClick: () => toggleChannel(id) },
            state.isAccessibleLinker ? React.createElement("div", { className: "channel-label" }, name) : null,
            React.createElement("div", { className: groupClass, style: style }, active ? React.createElement("i", { className: "active-linker-group ff-check-mark" }) : null)));
    });
    return React.createElement("div", { className: "linkerContainer" }, channelElements);
};
/**
 * The Linker icon on the window titlebar that launches the linker menu.
 */
export const LinkerMenu = () => (React.createElement(FinsembleProvider, null,
    React.createElement(LinkerElement, null)));
//# sourceMappingURL=LinkerMenuDeprecated.js.map