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

const rtkParticipantsWaitingListCss = ":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-top:var(--rtk-space-4, 16px);margin-bottom:calc(var(--rtk-space-2, 8px) * -1);display:flex;width:100%;flex-direction:column;font-size:14px}.waiting-participants{margin-bottom:var(--rtk-space-8, 32px)}.waiting-participants .accept-all-button{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}h3,.heading-count{margin:var(--rtk-space-0, 0px);display:flex;align-items:center;justify-content:center;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}.heading-count{font-size:14px}.participants{margin-top:var(--rtk-space-2, 8px);padding:var(--rtk-space-0, 0px)}.waiting-participant{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);display:flex;align-items:center}.waiting-participant .participant-details{margin-right:auto;display:flex;align-items:center}.waiting-participant .participant-details rtk-avatar{margin-right:var(--rtk-space-2, 8px);height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);flex-shrink:0;font-size:14px}.waiting-participant .participant-details .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media (min-width: 1080px){.waiting-participant .participant-details .name{max-width:var(--rtk-space-40, 160px)}}.waiting-participant .waitlist-controls{display:flex}.waiting-participant .waitlist-controls rtk-button{margin-left:var(--rtk-space-2, 8px);cursor:pointer;border-radius:var(--rtk-border-radius-sm, 4px)}.waiting-participant .waitlist-controls rtk-icon.accept{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}.waiting-participant .waitlist-controls rtk-icon.deny{--tw-text-opacity:1;color:rgba(var(--rtk-colors-danger, 255 45 45) / var(--tw-text-opacity))}";
const RtkParticipantsWaitingListStyle0 = rtkParticipantsWaitingListCss;

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 RtkParticipantsWaitlisted = /*@__PURE__*/ proxyCustomElement(class RtkParticipantsWaitlisted extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** View mode for participants list */
        this.view = 'sidebar';
        /** Language */
        this.t = useLanguage();
        this.acceptWaitingRoomRequest = async (id) => {
            await this.meeting.participants.acceptWaitingRoomRequest(id);
        };
        this.waitlistedParticipants = [];
        this.acceptAllWaitingRoomRequests = async () => {
            await this.meeting.participants.acceptAllWaitingRoomRequest(this.waitlistedParticipants.map((p) => p.id));
        };
        this.rejectWaitingRoomRequest = async (id) => {
            await this.meeting.participants.rejectWaitingRoomRequest(id);
        };
        this.shouldShowWaitlist = () => {
            if (this.meeting.meta.viewType === 'LIVESTREAM')
                return false;
            return (this.meeting.self.permissions.acceptWaitingRequests &&
                this.waitlistedParticipants.length !== 0);
        };
    }
    disconnectedCallback() {
        const { participants } = this.meeting;
        this.waitlistedParticipantJoinedListener &&
            participants.waitlisted.removeListener('participantJoined', this.waitlistedParticipantJoinedListener);
        this.waitlistedParticipantLeftListener &&
            participants.waitlisted.removeListener('participantLeft', this.waitlistedParticipantLeftListener);
        this.waitlistedParticipantsClearedListener &&
            participants.waitlisted.removeListener('participantsCleared', this.waitlistedParticipantsClearedListener);
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.waitlistedParticipants = meeting.participants.waitlisted.toArray();
        this.waitlistedParticipantJoinedListener = (participant) => {
            if (!this.waitlistedParticipants.some((p) => p.id === participant.id)) {
                this.waitlistedParticipants = [...this.waitlistedParticipants, participant];
            }
        };
        this.waitlistedParticipantLeftListener = (participant) => {
            this.waitlistedParticipants = this.waitlistedParticipants.filter((p) => p.id !== participant.id);
        };
        this.waitlistedParticipantsClearedListener = () => {
            this.waitlistedParticipants = [];
        };
        meeting.participants.waitlisted.addListener('participantJoined', this.waitlistedParticipantJoinedListener);
        meeting.participants.waitlisted.addListener('participantLeft', this.waitlistedParticipantLeftListener);
        meeting.participants.waitlisted.addListener('participantsCleared', this.waitlistedParticipantsClearedListener);
    }
    render() {
        if (this.view !== 'sidebar' || !this.shouldShowWaitlist())
            return;
        return (h("div", { class: "waiting-participants" }, h("div", { class: "heading-count", part: "waitlisted-heading-count" }, this.t('waitlist.header_title'), " (", this.waitlistedParticipants.length, ")"), h("ul", { class: "participants", part: "waitlisted-participants" }, this.waitlistedParticipants.map((participant) => (h("li", { class: "waiting-participant", key: participant.id }, h("div", { class: "participant-details" }, h("rtk-avatar", { participant: participant, size: "sm", iconPack: this.iconPack, t: this.t }), h("p", { class: "name", title: participant.name }, participant.name)), h("div", { class: "waitlist-controls" }, h("rtk-tooltip", { label: this.t('waitlist.deny_request'), variant: "secondary" }, h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.rejectWaitingRoomRequest(participant.id) }, h("rtk-icon", { class: "deny", icon: this.iconPack.dismiss }))), h("rtk-tooltip", { label: this.t('waitlist.accept_request'), variant: "secondary" }, h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.acceptWaitingRoomRequest(participant.id) }, h("rtk-icon", { class: "accept", icon: this.iconPack.checkmark })))))))), h("rtk-button", { class: "accept-all-button", variant: "secondary", kind: "wide", onClick: this.acceptAllWaitingRoomRequests }, this.t('waitlist.accept_all'))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
    static get style() { return RtkParticipantsWaitingListStyle0; }
}, [1, "rtk-participants-waiting-list", {
        "meeting": [16],
        "config": [16],
        "size": [513],
        "iconPack": [16],
        "view": [1],
        "t": [16],
        "waitlistedParticipants": [32]
    }, undefined, {
        "meeting": ["meetingChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-participants-waiting-list", "rtk-avatar", "rtk-button", "rtk-icon", "rtk-spinner", "rtk-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-participants-waiting-list":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkParticipantsWaitlisted);
            }
            break;
        case "rtk-avatar":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "rtk-spinner":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkParticipantsWaitlisted as R, defineCustomElement as d };
