/* ===================== AUTOGENERATED SOURCE IMPORT ===================== */

import GlobalStyle from "/emcJS/util/html/template/CSSTemplate.js";

const STYLE = new GlobalStyle(`
    :host {
        --logic-color-back: repeating-linear-gradient(145deg, #fbd9bc, #fbd9bc 20px, #ffdfe4 20px, #ffdfe4 40px);
        --logic-color-border: #ff9d37;
    }
    
`);

/* ======================================================================= */

import AbstractElement from "../abstract/AbstractElement.js";
import AbstractTwoChildrenElement from "../abstract/AbstractTwoChildrenElement.js";

const TPL_CAPTION = "NEQ (!=)";
const REFERENCE = "neq";

export default class ComparatorNotEqual extends AbstractTwoChildrenElement {

    constructor() {
        super(REFERENCE, TPL_CAPTION);
        STYLE.apply(this.shadowRoot);
    }

    calculate(state = {}) {
        let value;
        const ch = this.childList;
        if (ch[0] != null) {
            const val = ch[0].calculate(state);
            value = val;
        }
        if (ch[1] != null) {
            const val = ch[1].calculate(state);
            value = value != val;
        }
        value = +!!value;
        this.shadowRoot.getElementById("header").setAttribute("value", value);
        return value;
    }

}

AbstractElement.registerReference(REFERENCE, ComparatorNotEqual);
customElements.define(`emc-logic-${REFERENCE}`, ComparatorNotEqual);
