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 { c as canViewChat, d as canViewPolls, a as canViewParticipants, b as canViewPlugins, e as canViewAI } from './p-27d6399a.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { R as Render } from './p-88bd1053.js';
import { d as defineCustomElement$b } from './p-8564f93d.js';
import { d as defineCustomElement$a } from './p-4f889007.js';
import { d as defineCustomElement$9 } from './p-85587a5c.js';
import { d as defineCustomElement$8 } from './p-3e0452c4.js';
import { d as defineCustomElement$7 } from './p-1804e307.js';
import { d as defineCustomElement$6 } from './p-3ff755e5.js';
import { d as defineCustomElement$5 } from './p-73901fd8.js';
import { d as defineCustomElement$4 } from './p-42aa9cd9.js';
import { d as defineCustomElement$3 } from './p-20612910.js';
import { d as defineCustomElement$2 } from './p-bece0226.js';

const rtkSidebarCss = ":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{margin-right:var(--rtk-space-0, 0px);height:100%;width:100%;max-width:var(--rtk-space-96, 384px);box-sizing:border-box;display:flex;flex-direction:column;--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-1000, 8 8 8) / var(--tw-bg-opacity));border-width:var(--rtk-border-width-sm, 1px);border-style:solid;--tw-border-opacity:1;border-color:rgba(var(--rtk-colors-background-700, 44 44 44) / var(--tw-border-opacity))}:host([view='sidebar']){right:var(--rtk-space-2, 8px);margin-right:var(--rtk-space-4, 16px);overflow:clip;border-radius:var(--rtk-border-radius-lg, 12px);--tw-shadow:0 25px 50px -12px rgb(0 0 0 / 0.25);--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-shadow-color:rgb(var(--rtk-colors-background-900, 26 26 26));--tw-shadow:var(--tw-shadow-colored)}:host([view='full-screen']){top:var(--rtk-space-0, 0px);right:var(--rtk-space-0, 0px);bottom:var(--rtk-space-0, 0px);left:var(--rtk-space-0, 0px);max-width:100%}:host(.floating){position:absolute !important;top:var(--rtk-space-0, 0px);right:var(--rtk-space-0, 0px);bottom:var(--rtk-space-0, 0px);left:var(--rtk-space-0, 0px);left:auto;z-index:50}.pinned-state{position:absolute;right:var(--rtk-space-1, 4px);display:inline-flex;width:var(--rtk-space-2, 8px);justify-content:flex-end}";
const RtkSidebarStyle0 = rtkSidebarCss;

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 RtkSidebar$1 = /*@__PURE__*/ proxyCustomElement(class RtkSidebar extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        /** Enabled sections in sidebar */
        this.enabledSections = [];
        /** Default section */
        this.defaultSection = 'chat';
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** View type */
        this.view = 'sidebar';
        this.currentTab = this.defaultSection;
        this.isFloating = false;
        this.enablePinning = true;
        this.getTabs = () => {
            if (!this.meeting.self.config) {
                return this.enabledSections;
            }
            return this.enabledSections.filter((section) => !(section.id in this.meeting.self.config.controlBar.elements) ||
                this.meeting.self.config.controlBar.elements[section.id]);
        };
        this.close = () => {
            this.stateUpdate.emit({ activeSidebar: false, sidebar: this.defaultSection });
        };
        this.toggleFloating = () => {
            this.isFloating = !this.isFloating;
        };
    }
    connectedCallback() {
        var _a;
        this.viewChanged(this.view);
        this.statesChanged(this.states);
        this.meetingChanged(this.meeting);
        this.isFloating = ((_a = this.states) === null || _a === void 0 ? void 0 : _a.sidebarFloating) || false;
    }
    disconnectedCallback() {
        var _a, _b;
        (_b = (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.stage) === null || _b === void 0 ? void 0 : _b.removeListener('stageStatusUpdate', this.onStageStatusUpdate);
        this.onStageStatusUpdate = null;
    }
    meetingChanged(meeting) {
        var _a, _b;
        if (!meeting) {
            return;
        }
        this.updateEnabledSections(meeting);
        this.onStageStatusUpdate = (_status) => {
            this.updateEnabledSections(this.meeting);
        };
        (_b = (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.stage) === null || _b === void 0 ? void 0 : _b.on('stageStatusUpdate', this.onStageStatusUpdate);
    }
    statesChanged(s) {
        const states = s;
        if (states === null || states === void 0 ? void 0 : states.sidebar) {
            this.currentTab = states.sidebar;
        }
    }
    viewChanged(view) {
        if (view === 'full-screen') {
            this.enablePinning = false;
        }
        else {
            this.enablePinning = true;
        }
    }
    viewSection(section) {
        this.currentTab = section;
        this.stateUpdate.emit({ activeSidebar: true, sidebar: this.currentTab });
    }
    updateEnabledSections(meeting = this.meeting) {
        const list = [];
        if (canViewChat(meeting)) {
            list.push({ id: 'chat', name: this.t('chat') });
        }
        if (canViewPolls(meeting)) {
            list.push({ id: 'polls', name: this.t('polls') });
        }
        if (canViewParticipants(meeting)) {
            list.push({ id: 'participants', name: this.t('participants') });
        }
        if (canViewPlugins(meeting)) {
            list.push({ id: 'plugins', name: this.t('plugins') });
        }
        if (canViewAI(meeting)) {
            list.push({ id: 'ai', name: this.t('ai.meeting_ai') });
        }
        this.enabledSections = list;
    }
    render() {
        var _a;
        if (!this.meeting) {
            return null;
        }
        const defaults = {
            meeting: this.meeting,
            config: this.config,
            states: this.states,
            size: this.size,
            t: this.t,
            iconPack: this.iconPack,
        };
        // NOTE(ishita1805): This makes it easier to use the sidebar component in isolation.
        if (((_a = defaults.states) === null || _a === void 0 ? void 0 : _a.activeSidebar) === false || !this.currentTab) {
            return null;
        }
        return (h(Host, { class: this.enablePinning ? (this.isFloating ? 'floating' : '') : 'floating' }, h("rtk-sidebar-ui", { tabs: this.getTabs(), currentTab: this.currentTab, view: this.view, onTabChange: (e) => {
                this.viewSection(e.detail);
            }, onSidebarClose: this.close }, this.enablePinning && (h("div", { class: "pinned-state", slot: "pinned-state" }, h("rtk-button", { variant: "ghost", kind: "icon", onClick: this.toggleFloating, "aria-label": this.isFloating ? this.t('pin') : this.t('unpin') }, h("rtk-icon", { icon: this.isFloating ? this.iconPack.pin : this.iconPack.pin_off })))), defaults.states.sidebar === 'chat' && (h(Render, { element: "rtk-chat", defaults: defaults, props: { slot: 'chat' } })), defaults.states.sidebar === 'polls' && h("rtk-polls", Object.assign({}, defaults, { slot: "polls" })), defaults.states.sidebar === 'participants' && (h(Render, { element: "rtk-participants", defaults: defaults, props: { slot: 'participants' } })), defaults.states.sidebar === 'plugins' && h("rtk-plugins", Object.assign({}, defaults, { slot: "plugins" })), defaults.states.sidebar === 'ai' && h("rtk-ai", Object.assign({}, defaults, { slot: "ai" })))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"],
        "states": ["statesChanged"],
        "view": ["viewChanged"]
    }; }
    static get style() { return RtkSidebarStyle0; }
}, [1, "rtk-sidebar", {
        "enabledSections": [1040],
        "defaultSection": [1, "default-section"],
        "meeting": [16],
        "states": [16],
        "config": [16],
        "iconPack": [16],
        "t": [16],
        "size": [513],
        "view": [513],
        "currentTab": [32],
        "isFloating": [32],
        "enablePinning": [32]
    }, undefined, {
        "meeting": ["meetingChanged"],
        "states": ["statesChanged"],
        "view": ["viewChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkSidebar$1.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkSidebar$1.prototype, "states", void 0);
__decorate([
    SyncWithStore()
], RtkSidebar$1.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkSidebar$1.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkSidebar$1.prototype, "t", void 0);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-sidebar", "rtk-ai", "rtk-ai-transcriptions", "rtk-button", "rtk-icon", "rtk-plugins", "rtk-poll", "rtk-poll-form", "rtk-polls", "rtk-sidebar-ui", "rtk-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-sidebar":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkSidebar$1);
            }
            break;
        case "rtk-ai":
            if (!customElements.get(tagName)) {
                defineCustomElement$b();
            }
            break;
        case "rtk-ai-transcriptions":
            if (!customElements.get(tagName)) {
                defineCustomElement$a();
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$9();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$8();
            }
            break;
        case "rtk-plugins":
            if (!customElements.get(tagName)) {
                defineCustomElement$7();
            }
            break;
        case "rtk-poll":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "rtk-poll-form":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "rtk-polls":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "rtk-sidebar-ui":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "rtk-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const RtkSidebar = RtkSidebar$1;
const defineCustomElement = defineCustomElement$1;

export { RtkSidebar, defineCustomElement };
