'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index$1 = require('./index-2e5758b6.js');
const uiStore = require('./ui-store-583d205a.js');
const index = require('./index-3f8e5441.js');

const rtkBreakoutRoomsToggleCss = ":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:block}";
const RtkBreakoutRoomsToggleStyle0 = rtkBreakoutRoomsToggleCss;

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 RtkBreakoutRoomsToggle = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        this.stateUpdate = index$1.createEvent(this, "rtkStateUpdate", 7);
        /** Variant */
        this.variant = 'button';
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** Language */
        this.t = uiStore.useLanguage();
        this.canToggle = false;
        this.permissionsUpdateListener = () => {
            this.canToggle = uiStore.canToggleBreakout(this.meeting);
        };
        this.breakoutRoomToggle = () => {
            var _a, _b;
            const mode = this.meeting.connectedMeetings.isActive ? 'view' : 'create';
            this.stateUpdate.emit({
                activeBreakoutRoomsManager: {
                    active: !((_b = (_a = this.states) === null || _a === void 0 ? void 0 : _a.activeBreakoutRoomsManager) === null || _b === void 0 ? void 0 : _b.active),
                    mode,
                },
            });
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a, _b, _c;
        (_c = (_b = (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.off('permissionsUpdate', this.permissionsUpdateListener);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.canToggle = uiStore.canToggleBreakout(meeting);
        meeting.self.permissions.on('permissionsUpdate', this.permissionsUpdateListener);
    }
    render() {
        if (!this.meeting)
            return null;
        if (!this.canToggle)
            return;
        return (index$1.h(index$1.Host, { title: this.t('breakout_rooms') }, index$1.h("rtk-controlbar-button", { part: "controlbar-button", size: this.size, iconPack: this.iconPack, onClick: this.breakoutRoomToggle, icon: this.iconPack.breakout_rooms, label: this.t('breakout_rooms'), variant: this.variant })));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate([
    index.SyncWithStore()
], RtkBreakoutRoomsToggle.prototype, "meeting", void 0);
__decorate([
    index.SyncWithStore()
], RtkBreakoutRoomsToggle.prototype, "states", void 0);
__decorate([
    index.SyncWithStore()
], RtkBreakoutRoomsToggle.prototype, "iconPack", void 0);
__decorate([
    index.SyncWithStore()
], RtkBreakoutRoomsToggle.prototype, "t", void 0);
RtkBreakoutRoomsToggle.style = RtkBreakoutRoomsToggleStyle0;

exports.rtk_breakout_rooms_toggle = RtkBreakoutRoomsToggle;
