import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import styled from "styled-components";
export class BaseRule {
    constructor() {
        // this is the ID of the value rule
        this.name = "";
        // this is what is shown in the UI
        this.displayName = "";
    }
    renderListValue(values) {
        let requiredLength = false;
        let renderValue = values.reduce((s, current, index) => {
            if (index === 0)
                return `${current}`;
            if (`${s}, ${current}`.length > 15) {
                requiredLength = true;
                return s;
            }
            s = `${s}, ${current}`;
            return s;
        }, "");
        return (_jsxs(ValueTableCellLine, { children: [renderValue, " ", requiredLength ? `... (${values.length})` : ``] }, void 0));
    }
    renderOneLineValue(value) {
        let content = `${value}`;
        if (content.length > 15) {
            content = `${content.slice(0, 12)}...`;
        }
        return _jsx(ValueTableCellLine, { children: content }, void 0);
    }
    renderValue(cell) {
        return Array.isArray(cell.values) ? this.renderListValue(cell.values) : this.renderOneLineValue(cell.values);
    }
    renderListEditor(cell) {
        throw new Error("Not Implemented");
    }
    renderOneLineEditor(cell) {
        throw new Error("Not Implemented");
    }
    renderEditor(cell) {
        return Array.isArray(cell.values) ? this.renderListEditor(cell) : this.renderOneLineEditor(cell);
    }
    renderCell(column, cell, focused) {
        let content;
        if (Array.isArray(cell.values) && typeof cell.values !== "string") {
            const lengths = cell.values.map((a) => a.length);
            content = cell.values[lengths.indexOf(Math.max(...lengths))];
        }
        else {
            content = cell.values;
        }
        return (_jsx(ValueTableCellWrapper, Object.assign({ focused: focused, content: content }, { children: focused ? (_jsx(ValueTableCellEditor, { children: this.renderEditor(cell) }, void 0)) : (this.renderValue(cell)) }), void 0));
    }
    evaluate(cell) {
        // return cell.values;
        return true;
    }
}
export const ValueTableCellLine = styled.div `
    font-family: Inter;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 17px;
    letter-spacing: 0px;

    color: rgba(39, 41, 50, 0.8);
    height: 100%;
`;
export const ValueTableCellWrapper = styled.div `
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 44px;

    ${(props) => props.focused
    ? `
            &:before {
                display: block;
                content: "${props.content}";
                opacity: 0;
                height: 0;
                visibility: hidden;
                padding: 0 3px;
            }
        `
    : ``}

    .TextList-TextBox {
        border-radius: 0 !important;
        background: rgb(64, 80, 166, 0.05);
        border: none !important;
    }

    .TextList-TextBox::before {
        border: none !important;
    }

    .TextList-TextBox .MuiInputBase-input,
    .MuiInputBase-input,
    .MuiOutlinedInput-input {
        font-family: Inter !important;
        font-size: 12px !important;
        font-style: normal;
        font-weight: 400 !important;
        line-height: 17px !important;
        letter-spacing: 0px;
        text-align: left;
        color: rgba(39, 41, 50, 0.8);
    }

    .MuiOutlinedInput-input {
        padding: 6px 12px;
        background: rgba(64, 80, 166, 0.05);
        height: 20px;
    }

    .MuiOutlinedInput-notchedOutline {
        border: none;
        border-bottom: solid 1px rgba(64, 80, 166, 0.35);
        border-radius: 0;
    }

    .MuiSwitch-root {
        height: 25px !important;
        width: 40px !important;
        padding: 0;
    }

    .MuiSwitch-switchBase {
        padding: 2px !important;

        &.Mui-checked {
            transform: translateX(15px) !important;
        }
    }
`;
export const ValueTableCellEditor = styled.div `
    border: 1px solid #3e9bde;
    border-radius: 2px;

    position: absolute;
    top: 0;
    left: 0;

    width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    background: #fff;

    padding: 6px;
`;
//# sourceMappingURL=BaseRule.js.map