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

const rtkPluginsCss = ":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)}.scrollbar{scrollbar-width:thin;scrollbar-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))\n    var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar{height:var(--rtk-space-1\\.5, 6px);width:var(--rtk-space-1\\.5, 6px);border-radius:9999px;background-color:var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar-thumb{border-radius:9999px;background-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))}:host{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);display:flex;height:100%;width:100%;flex-direction:column;font-size:14px;color:rgb(var(--rtk-colors-text-1000, 255 255 255))}h3{margin-left:var(--rtk-space-0, 0px);margin-right:var(--rtk-space-0, 0px);margin-top:var(--rtk-space-4, 16px);margin-bottom:var(--rtk-space-4, 16px);display:block;padding:var(--rtk-space-0, 0px);font-size:16px;font-weight:400;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));text-align:center}ul{overflow-y:auto;padding:var(--rtk-space-0, 0px);flex-grow:1;flex-basis:0}.metadata{display:flex;align-items:center}.metadata img{height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);border-radius:var(--rtk-border-radius-sm, 4px)}.metadata .name{margin-left:var(--rtk-space-2, 8px);font-weight:500}.plugin{display:flex;align-items:center;justify-content:space-between;padding-left:var(--rtk-space-4, 16px);padding-right:var(--rtk-space-4, 16px);padding-top:var(--rtk-space-2, 8px);padding-bottom:var(--rtk-space-2, 8px)}.plugin .buttons{display:flex;align-items:center}.empty-plugins{display:flex;height:100%;width:100%;align-items:center;justify-content:center;padding-left:var(--rtk-space-4, 16px);padding-right:var(--rtk-space-4, 16px);color:rgb(var(--rtk-colors-text-700, 255 255 255 / 0.64))}rtk-button:hover{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);--tw-ring-opacity:1;--tw-ring-color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-ring-opacity));--tw-ring-offset-width:2px;--tw-ring-offset-color:rgb(var(--rtk-colors-background-1000, 8 8 8))}";
const RtkPluginsStyle0 = rtkPluginsCss;

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 RtkPlugins = /*@__PURE__*/ proxyCustomElement(class RtkPlugins extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        this.updateActivePlugins = () => {
            if (!this.meeting)
                return;
            this.activatedPluginsId = this.meeting.plugins.active.toArray().map((p) => p.id);
        };
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.plugins = [];
        this.activatedPluginsId = [];
        this.close = () => {
            this.stateUpdate.emit({ activeSidebar: false, sidebar: undefined });
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.plugins.all.removeListener('stateUpdate', this.updateActivePlugins);
    }
    meetingChanged(meeting, oldMeeting) {
        if (oldMeeting) {
            oldMeeting.plugins.all.removeListener('stateUpdate', this.updateActivePlugins);
        }
        if (meeting != null) {
            this.plugins = meeting.plugins.all.toArray();
            this.updateActivePlugins();
            meeting.plugins.all.addListener('stateUpdate', this.updateActivePlugins);
        }
    }
    render() {
        return (h(Host, { key: '9a0c98a1c3313bae757ecdc7c2c6932456c2d924' }, this.plugins.length === 0 && h("div", { key: 'ea6629a4739c87842bb0fa7cb0c73d0dc9511f51', class: "empty-plugins" }, this.t('plugins.empty')), h("ul", { key: '9632e9183e3c1dbbaa5adb80b81cb66096b6742f', class: "scrollbar" }, this.plugins.map((plugin) => {
            var _a, _b;
            return (h("li", { key: plugin.name, class: "plugin" }, h("div", { class: "metadata" }, h("img", { src: plugin.icon, alt: plugin.name }), h("div", { class: "name" }, plugin.name)), !this.activatedPluginsId.includes(plugin.id) && ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.permissions) === null || _a === void 0 ? void 0 : _a.canActivate) && (h("div", { class: "buttons" }, h("rtk-button", { kind: "icon", size: "lg", onClick: () => {
                    plugin.activate();
                    this.close();
                }, "aria-label": `${this.t('activate')} ${plugin.name}` }, h("rtk-icon", { icon: this.iconPack.rocket, tabIndex: -1, "aria-hidden": true })))), this.activatedPluginsId.includes(plugin.id) &&
                ((_b = plugin === null || plugin === void 0 ? void 0 : plugin.permissions) === null || _b === void 0 ? void 0 : _b.canDeactivate) && (h("div", { class: "buttons" }, h("rtk-button", { kind: "icon", size: "lg", onClick: () => {
                    plugin.deactivate();
                }, "aria-label": `${this.t('close')} ${plugin.name}` }, h("rtk-icon", { icon: this.iconPack.dismiss, tabIndex: -1, "aria-hidden": true }))))));
        }))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
    static get style() { return RtkPluginsStyle0; }
}, [1, "rtk-plugins", {
        "meeting": [16],
        "config": [16],
        "size": [513],
        "iconPack": [16],
        "t": [16],
        "plugins": [32],
        "activatedPluginsId": [32]
    }, undefined, {
        "meeting": ["meetingChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkPlugins.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkPlugins.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkPlugins.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkPlugins.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-plugins", "rtk-button", "rtk-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-plugins":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkPlugins);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkPlugins as R, defineCustomElement as d };
