import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import styled from "styled-components";
import Tooltip from "@material-ui/core/Tooltip";
import { FlowStepOutputInstructionType } from "../../Structure/FlowStepOutputInstructions";
import { ErrorFlowIcon } from "../../../CommonUI/Icon/ErrorFlowIcon";
import { ErrorIcon } from "../../../CommonUI/Icon/ErrorIcon";
import { NoDataIcon } from "../../../CommonUI/Icon/NoDataIcon";
import { EndFlowIcon } from "../../../CommonUI/Icon/EndFlowIcon";
import { EndIcon } from "../../../CommonUI/Icon/EndIcon";
import { FlowConstants } from "../../CommonUI/FlowConstants";
export const FlowSummaryDiv = styled.div `
	display: flex;
	flex-direction: row;
	align-items: center;
	${props => !props.notEndAlign && `justify-content: flex-end;`}
	cursor: pointer;
	position: relative;

	label {
		position: absolute;
		top: 0;
		right: 100%;
		white-space: pre;
	}

	.step-path-name-error {
		font-family: Inter;
		font-style: normal;
		font-weight: 500;
		font-size: 10px;
		line-height: 140%;
		color: ${FlowConstants.STEP_PATH_ERROR_COLOR};
		margin-left: 0px;

		text-transform: capitalize;

	}

	.step-path-error-message {
		display: flex;
		margin-left: 4px;
	}

	.step-path-name-end {
		font-family: Inter;
		font-style: normal;
		font-weight: 500;
		font-size: 10px;
		line-height: 140%;
		color: ${FlowConstants.STEP_PATH_END_COLOR};
		margin-left: 0px;

		text-transform: capitalize;

		cursor: pointer;
	}
`;
const ExtraIconDiv = styled.div `
	position: absolute;
	left: 100%;
	top: 0;
	display: flex;
`;
export const RegularStepInstruction = (props) => {
    const step = props.step ? props.step : props.editContext.flow.find(props.instruction.stepId);
    const onClick = (event) => {
        if (step) {
            props.editContext.setSelectedStepStrategy(event.currentTarget, step);
        }
    };
    if (!step)
        return null;
    let tooltipLabel = props.hiddenStepName && Reflect.get(step, 'hidden') ? props.hiddenStepName : props.instruction.pathName;
    let label = `${tooltipLabel.slice(0, FlowConstants.MAX_CHARS_STEP_PATH_LABEL)}${tooltipLabel.length > FlowConstants.MAX_CHARS_STEP_PATH_LABEL ? '...' : ''}`;
    if (props.instruction.strategy === FlowStepOutputInstructionType.THROW_EXCEPTION) {
        return _jsx(Tooltip, Object.assign({ title: tooltipLabel }, { children: _jsxs(FlowSummaryDiv, Object.assign({ onClick: onClick }, { children: [!props.hideLabel &&
                        _jsx("label", Object.assign({ className: "step-path-name-error" }, { children: label }), void 0),
                    _jsx(NoDataIcon, {}, void 0),
                    _jsxs(ExtraIconDiv, Object.assign({ id: props.instruction.getElementId() }, { children: [_jsx(ErrorFlowIcon, {}, void 0),
                            _jsx("div", Object.assign({ className: "step-path-error-message" }, { children: _jsx(ErrorIcon, {}, void 0) }), void 0)] }), void 0)] }), void 0) }), void 0);
    }
    if (props.instruction.strategy === FlowStepOutputInstructionType.END_FLOW) {
        return _jsx(Tooltip, Object.assign({ title: tooltipLabel }, { children: _jsxs(FlowSummaryDiv, Object.assign({ onClick: onClick }, { children: [!props.hideLabel &&
                        _jsx("label", Object.assign({ className: "step-path-name-end" }, { children: label }), void 0),
                    _jsx(EndIcon, {}, void 0),
                    _jsx(ExtraIconDiv, Object.assign({ id: props.instruction.getElementId() }, { children: _jsx(EndFlowIcon, {}, void 0) }), void 0)] }), void 0) }), void 0);
    }
    if (props.instruction.strategy === FlowStepOutputInstructionType.BRANCH) {
        if (Reflect.get(step, 'hidden') && !props.showHiddenBranch) {
            return null;
        }
        return _jsx(Tooltip, Object.assign({ title: tooltipLabel }, { children: _jsxs(FlowSummaryDiv, Object.assign({ notEndAlign: true, onClick: onClick }, { children: [!props.hideLabel &&
                        _jsx("label", Object.assign({ className: "step-path-name-end" }, { children: label }), void 0),
                    _jsx("div", { id: props.instruction.getElementId() }, void 0)] }), void 0) }), void 0);
    }
    return null;
};
//# sourceMappingURL=StepInstruction.js.map