import { h } from "@stencil/core";
import { Operator, } from "@limetech/lime-web-components";
/**
 * Lime Query Filter Expression Router
 *
 * Router component for rendering Lime Query filter expressions.
 * Routes to the appropriate sub-component based on expression structure:
 * - Has `key` property → limebb-lime-query-filter-comparison
 * - `op: Operator.AND | Operator.OR` → limebb-lime-query-filter-group
 * - `op: Operator.NOT` → limebb-lime-query-filter-not
 *
 * @private
 */
export class LimeQueryFilterExpressionComponent {
    constructor() {
        this.handleExpressionChange = (event) => {
            event.stopPropagation();
            this.expressionChange.emit(event.detail);
        };
    }
    render() {
        if (!this.expression) {
            return;
        }
        const props = {
            platform: this.platform,
            context: this.context,
            label: this.label,
            limetype: this.limetype,
            activeLimetype: this.activeLimetype,
        };
        if ('key' in this.expression) {
            return (h("limebb-lime-query-filter-comparison", Object.assign({}, props, { expression: this.expression, onExpressionChange: this.handleExpressionChange })));
        }
        if (this.expression.op === Operator.AND ||
            this.expression.op === Operator.OR) {
            return (h("limebb-lime-query-filter-group", Object.assign({}, props, { expression: this.expression, onExpressionChange: this.handleExpressionChange })));
        }
        if (this.expression.op === Operator.NOT) {
            return (h("limebb-lime-query-filter-not", Object.assign({}, props, { expression: this.expression, onExpressionChange: this.handleExpressionChange })));
        }
    }
    static get is() { return "limebb-lime-query-filter-expression"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["lime-query-filter-expression.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["lime-query-filter-expression.css"]
        };
    }
    static get properties() {
        return {
            "platform": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LimeWebComponentPlatform",
                    "resolved": "LimeWebComponentPlatform",
                    "references": {
                        "LimeWebComponentPlatform": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::LimeWebComponentPlatform",
                            "referenceLocation": "LimeWebComponentPlatform"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Platform service provider"
                },
                "getter": false,
                "setter": false
            },
            "context": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "LimeWebComponentContext",
                    "resolved": "LimeWebComponentContext",
                    "references": {
                        "LimeWebComponentContext": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::LimeWebComponentContext",
                            "referenceLocation": "LimeWebComponentContext"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Component context"
                },
                "getter": false,
                "setter": false
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Optional label for the expression"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label"
            },
            "limetype": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The limetype being queried (e.g., \"deal\", \"company\")\nUsed for property validation and type-aware inputs"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "limetype"
            },
            "activeLimetype": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The limetype of the active object (for %activeObject% placeholders)\nOptional - used for validation and property suggestions"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "active-limetype"
            },
            "expression": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "Expression",
                    "resolved": "{ key: string; op: BasicOperator; exp: ExpressionValue; } | { key: string; op: Operator.IN; exp: ExpressionValue[]; } | { op: Operator.AND | Operator.OR; exp: Expression[]; } | { op: Operator.NOT; exp: Expression; } | { type: \"filter\"; key: string; op: Operator.IN; exp: string; }",
                    "references": {
                        "Expression": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::Expression",
                            "referenceLocation": "Expression"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The filter expression to render"
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get events() {
        return [{
                "method": "expressionChange",
                "name": "expressionChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emitted when the filter expression changes\nEmits undefined when expression should be removed"
                },
                "complexType": {
                    "original": "Expression | undefined",
                    "resolved": "undefined | { key: string; op: BasicOperator; exp: ExpressionValue; } | { key: string; op: Operator.IN; exp: ExpressionValue[]; } | { op: Operator.AND | Operator.OR; exp: Expression[]; } | { op: Operator.NOT; exp: Expression; } | { type: \"filter\"; key: string; op: Operator.IN; exp: string; }",
                    "references": {
                        "Expression": {
                            "location": "import",
                            "path": "@limetech/lime-web-components",
                            "id": "node_modules::Expression",
                            "referenceLocation": "Expression"
                        }
                    }
                }
            }];
    }
}
