import { p as proxyCustomElement, H, h, c as Host } from './p-ae373651.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { d as defineCustomElement$2 } from './p-85587a5c.js';
import { d as defineCustomElement$1 } from './p-3e0452c4.js';

const rtkPluginMainCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{display:flex;height:100%;width:100%;flex-direction:column;overflow:hidden;border-radius:var(--rtk-border-radius-lg, 12px);color:rgb(var(--rtk-colors-text-1000, 255 255 255))}header{display:flex;height:var(--rtk-space-8, 32px);align-items:center;justify-content:space-between;padding-left:var(--rtk-space-3, 12px);padding-right:var(--rtk-space-3, 12px);--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-900, 26 26 26) / var(--tw-bg-opacity))}header>div{display:flex;align-items:center}rtk-button{display:flex;height:var(--rtk-space-5, 20px);width:var(--rtk-space-5, 20px);flex-direction:column;align-items:center;border-radius:9999px}rtk-button rtk-icon{height:var(--rtk-space-3, 12px);width:var(--rtk-space-3, 12px)}.view-container{position:relative;height:100%;width:100%;overflow:hidden;--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-video-bg, 24 24 24) / var(--tw-bg-opacity))}.view-container ::slotted(*){width:100%;height:100%;display:block}";
const RtkPluginMainStyle0 = rtkPluginMainCss;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkPluginMain = /*@__PURE__*/ proxyCustomElement(class RtkPluginMain extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.canDeactivatePlugin = false;
    }
    connectedCallback() {
        this.pluginChanged(this.plugin);
    }
    pluginChanged(plugin) {
        var _a, _b;
        if (plugin == null)
            return;
        this.canDeactivatePlugin = (_b = (_a = plugin.permissions) === null || _a === void 0 ? void 0 : _a.canDeactivate) !== null && _b !== void 0 ? _b : false;
        this.attachView(plugin);
    }
    attachView(plugin) {
        const component = plugin.component;
        if (!(component instanceof H))
            return;
        // Avoid unnecessary DOM churn if the same element is already mounted
        if (this.host.firstElementChild === component)
            return;
        // Clear any existing light DOM children
        while (this.host.firstChild) {
            this.host.removeChild(this.host.firstChild);
        }
        // Place in light DOM — the <slot> projects it into the shadow DOM layout
        this.host.appendChild(component);
    }
    disconnectedCallback() {
        while (this.host.firstChild) {
            this.host.removeChild(this.host.firstChild);
        }
    }
    render() {
        if (this.plugin == null)
            return null;
        return (h(Host, null, h("header", { part: "header" }, h("div", null, this.plugin.name), this.canDeactivatePlugin && (h("div", null, h("rtk-button", { kind: "icon", onClick: () => this.plugin.deactivate(), part: "button" }, h("rtk-icon", { icon: this.iconPack.dismiss }))))), h("div", { class: "view-container" }, h("slot", null))));
    }
    get host() { return this; }
    static get watchers() { return {
        "plugin": ["pluginChanged"]
    }; }
    static get style() { return RtkPluginMainStyle0; }
}, [1, "rtk-plugin-main", {
        "meeting": [16],
        "plugin": [16],
        "iconPack": [16],
        "t": [16],
        "canDeactivatePlugin": [32]
    }, undefined, {
        "plugin": ["pluginChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkPluginMain.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkPluginMain.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkPluginMain.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-plugin-main", "rtk-button", "rtk-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-plugin-main":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkPluginMain);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkPluginMain as R, defineCustomElement as d };
