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 './p-a83ccdbd.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { d as defineCustomElement$2 } from './p-3e0452c4.js';

const rtkNetworkIndicatorCss = ":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{position:relative;display:block;height:var(--rtk-space-7, 28px);width:var(--rtk-space-7, 28px)}rtk-icon{position:absolute;top:var(--rtk-space-0, 0px);right:var(--rtk-space-0, 0px);bottom:var(--rtk-space-0, 0px);left:var(--rtk-space-0, 0px);z-index:10;height:100%;width:100%;--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}rtk-icon.good{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}rtk-icon.poor{--tw-text-opacity:1;color:rgba(var(--rtk-colors-warning, 255 205 7) / var(--tw-text-opacity))}rtk-icon.poorest{--tw-text-opacity:1;color:rgba(var(--rtk-colors-danger, 255 45 45) / var(--tw-text-opacity))}:host([size='md']){height:var(--rtk-space-6, 24px);width:var(--rtk-space-6, 24px)}:host([size='sm']){height:var(--rtk-space-5, 20px);width:var(--rtk-space-5, 20px)}.bg-signal{position:absolute;top:var(--rtk-space-0, 0px);right:var(--rtk-space-0, 0px);bottom:var(--rtk-space-0, 0px);left:var(--rtk-space-0, 0px);z-index:0;color:rgb(var(--rtk-colors-text-600, 255 255 255 / 0.52))}";
const RtkNetworkIndicatorStyle0 = rtkNetworkIndicatorCss;

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 RtkNetworkIndicator$1 = /*@__PURE__*/ proxyCustomElement(class RtkNetworkIndicator extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** Is for screenshare */
        this.isScreenShare = false;
        this.score = 10;
        this.onMediaScoreUpdate = ({ kind, isScreenshare, score }) => {
            if (kind === 'video' || (this.isScreenShare && isScreenshare)) {
                this.score = score;
            }
        };
    }
    connectedCallback() {
        this.participantChanged(this.participant);
    }
    participantChanged(participant) {
        if (!participant)
            return;
        participant.addListener('mediaScoreUpdate', this.onMediaScoreUpdate);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.participant) === null || _a === void 0 ? void 0 : _a.removeListener('mediaScoreUpdate', this.onMediaScoreUpdate);
    }
    render() {
        let signal_strength = Math.round(this.score / 2);
        let signal_status = 'good';
        // make sure signal strength is within bounds [1,3]
        // do not show if it is good
        if (signal_strength > 3) {
            return null;
        }
        else if (signal_strength < 1) {
            signal_strength = 1;
        }
        switch (signal_strength) {
            case 3:
            case 2:
                signal_status = 'poor';
                break;
            case 1:
                signal_status = 'poorest';
        }
        return (h(Host, null, h("rtk-icon", { icon: this.iconPack[`signal_${signal_strength}`], class: signal_status }), h("rtk-icon", { icon: this.iconPack.signal_5, class: "bg-signal" })));
    }
    static get watchers() { return {
        "participant": ["participantChanged"]
    }; }
    static get style() { return RtkNetworkIndicatorStyle0; }
}, [1, "rtk-network-indicator", {
        "participant": [16],
        "meeting": [16],
        "iconPack": [16],
        "t": [16],
        "isScreenShare": [4, "is-screen-share"],
        "score": [32]
    }, undefined, {
        "participant": ["participantChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkNetworkIndicator$1.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkNetworkIndicator$1.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkNetworkIndicator$1.prototype, "t", void 0);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-network-indicator", "rtk-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-network-indicator":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkNetworkIndicator$1);
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const RtkNetworkIndicator = RtkNetworkIndicator$1;
const defineCustomElement = defineCustomElement$1;

export { RtkNetworkIndicator, defineCustomElement };
