import { r as registerInstance, h, H as Host, g as getElement } from './index-BIwHMk6j.js';
import { b as n } from './index.esm-CMeGYws2.js';

const ruleGateCss = () => `:host{display:contents}:host([hidden]){display:none}`;

const RuleGate = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.shouldRender = false;
    }
    componentWillLoad() {
        this.compileAndEvaluate();
    }
    onRuleChange() {
        this.compileAndEvaluate();
    }
    onScopeChange() {
        this.compileAndEvaluate();
    }
    render() {
        return (h(Host, { key: '365df6908301371b8b964671382ad936971b6624', hidden: !this.shouldRender }, h("slot", { key: 'ca7c2a9febf0189dfae882a2ae894d1d0262a213' })));
    }
    get ruleRegistry() {
        return this.platform.get(n.RuleRegistry);
    }
    compileAndEvaluate() {
        var _a;
        if (!this.rule) {
            this.shouldRender = true;
            return;
        }
        try {
            const compiled = this.ruleRegistry.compile(this.rule);
            const scope = (_a = this.scope) !== null && _a !== void 0 ? _a : this.ruleRegistry.scope({ host: this.host });
            this.shouldRender = compiled(scope);
        }
        catch (error) {
            console.warn('rule-gate failed to compile rule; hiding slot', {
                rule: this.rule,
                error,
            });
            this.shouldRender = false;
        }
    }
    get host() { return getElement(this); }
    static get watchers() { return {
        "rule": [{
                "onRuleChange": 0
            }],
        "scope": [{
                "onScopeChange": 0
            }]
    }; }
};
RuleGate.style = ruleGateCss();

export { RuleGate as limebb_rule_gate };
