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 { d as defineCustomElement$2 } from './p-85587a5c.js';
import { d as defineCustomElement$1 } from './p-3e0452c4.js';

const rtkDialogCss = ":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{word-wrap:break-word;overflow-wrap:break-word}#dialog{position:relative;max-height:100%;max-width:100%;padding:var(--rtk-space-0, 0px);border-width:var(--rtk-border-width-none, 0);border-style:none;background-color:transparent;color:rgb(var(--rtk-colors-text-1000, 255 255 255))}#dialog::backdrop{background-color:rgba(var(--rtk-colors-background-600, 60 60 60) / 0.5);backdrop-filter:blur(12px) saturate(180%)}#dismiss-btn{position:absolute;top:var(--rtk-space-3, 12px);right:var(--rtk-space-3, 12px);z-index:50}::slotted(*){max-width:100%;height:auto;min-height:-moz-fit-content;min-height:fit-content}";
const RtkDialogStyle0 = rtkDialogCss;

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 RtkDialog = /*@__PURE__*/ proxyCustomElement(class RtkDialog extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.onClose = createEvent(this, "rtkDialogClose", 7);
        /** Whether to show the close button */
        this.hideCloseButton = false;
        /** Whether Escape key can close the modal */
        this.disableEscapeKey = false;
        /** UI Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** Whether a dialog is open or not */
        this.open = true;
        this.close = () => {
            this.open = false;
            this.onClose.emit();
        };
        this.keydownListener = (e) => {
            if (!this.disableEscapeKey && e.key === 'Escape' && this.open) {
                this.close();
            }
        };
    }
    connectedCallback() {
        document.addEventListener('keydown', this.keydownListener);
    }
    disconnectedCallback() {
        document.removeEventListener('keydown', this.keydownListener);
    }
    componentDidRender() {
        if (this.open && !this.dialogEl.open) {
            // we need to call showModal() to get the ::backdrop
            this.dialogEl.showModal();
        }
    }
    render() {
        if (!this.open) {
            return null;
        }
        return (h(Host, null, h("dialog", { ref: (el) => (this.dialogEl = el), id: "dialog", part: "container", onClose: this.close, onClick: (e) => {
                // clicked outside the children of dialog
                if (!this.disableEscapeKey && e.target === this.dialogEl) {
                    this.close();
                }
            }, onKeyDown: (e) => {
                if (this.disableEscapeKey && e.key === 'Escape') {
                    e.preventDefault();
                }
            } }, h("slot", null), !this.hideCloseButton && (h("rtk-button", { part: "close-button", id: "dismiss-btn", kind: "icon", variant: "ghost", onClick: () => this.close(), type: "button", "aria-label": this.t('dialog.close'), role: "button" }, h("rtk-icon", { icon: this.iconPack.dismiss }))))));
    }
    static get style() { return RtkDialogStyle0; }
}, [1, "rtk-dialog", {
        "hideCloseButton": [4, "hide-close-button"],
        "disableEscapeKey": [4, "disable-escape-key"],
        "meeting": [16],
        "config": [16],
        "states": [16],
        "size": [513],
        "iconPack": [16],
        "t": [16],
        "open": [1540]
    }]);
__decorate([
    SyncWithStore()
], RtkDialog.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkDialog.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkDialog.prototype, "states", void 0);
__decorate([
    SyncWithStore()
], RtkDialog.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkDialog.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-dialog", "rtk-button", "rtk-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-dialog":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkDialog);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkDialog as R, defineCustomElement as d };
