import React from "react";
import { Actions } from "../stores/ProcessMonitorStore";
/**
 * This file is the react component for an individual window beneath a process. It allows the user
 * to close the window.
 */
const ChildWindow = ({ cw }) => {
    // identify the window by making it flash.
    const clickHandler = () => {
        Actions.getFlashingState((err, flashState) => {
            if (err) {
                console.error("Error getting current flashing state of window.", err);
            }
            // Only begin flashing if not already started
            if (!flashState) {
                Actions.identifyWindow(cw);
            }
        });
    };
    const childWindowClasses = `child-window`;
    const { windowName, type, webContentsName } = cw;
    return (React.createElement("div", { className: childWindowClasses },
        React.createElement("div", { className: "child-window-actions" }, type === "window" && (React.createElement("i", { className: "close-window ff-close", onClick: () => {
                Actions.closeWindow(windowName);
            }, tabIndex: 0, role: "button", onKeyDown: (e) => {
                if (e.key === "Enter" || e.key === " ") {
                    Actions.closeWindow(windowName);
                }
            } }))),
        React.createElement("div", { className: "child-window-name", onClick: clickHandler }, webContentsName)));
};
export default ChildWindow;
//# sourceMappingURL=ChildWindow.js.map