import { p as proxyCustomElement, H, h, c as Host } from './p-ae373651.js';
import { C as ChatHead } from './p-38d22d57.js';
import { a as sanitizeLink } from './p-efabd2ce.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import { g as getExtension, a as getFileSize, d as downloadFile } from './p-47314bc7.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';

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 RtkFileMessage = /*@__PURE__*/ proxyCustomElement(class RtkFileMessage extends H {
    constructor() {
        super();
        this.__registerHost();
        /** Date object of now, to calculate distance between dates */
        this.now = new Date();
        /** Whether the message is continued by same user */
        this.isContinued = false;
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** show message in bubble */
        this.showBubble = false;
    }
    render() {
        const link = sanitizeLink(this.message.link);
        return (h(Host, { key: 'b10da5fd1c4c6d80a1e5bf5f35f4956abde0ed5d' }, !this.isContinued && (h(ChatHead, { key: 'fb1384ad8bfc73219b28c4500f78e6c6421ee848', name: this.message.displayName, time: this.message.time, now: this.now })), h("div", { key: '81a067a5567ad160e4398a6f16b21309f81a0c9b', class: {
                body: true,
                bubble: this.showBubble,
            }, part: "body" }, h("div", { key: 'c6eb4b26b0090b7f9fd6af9e79d04c8b4e76a6d1', class: "file" }, h("div", { key: '10e9b854fa0c1f311bb1bc76c90223220c9a10f3', class: "file-data" }, h("div", { key: 'ace6eeb050ad6c656cd215456b69f8b6e9529aec', class: "name" }, this.message.name), h("div", { key: '562de08ebd242e92aeca1fae0aa4823612a60c1c', class: "file-data-split" }, h("div", { key: '968eee3032f98a59da43c0b4604dc597c4bfd94c', class: "ext" }, getExtension(this.message.name)), h("span", { key: '2cb436ffed86b9c3a73ff5feab9d3ec7c8e0ef3b', class: "divider" }), h("div", { key: '9cc1d37edf60fbd3d3538512539a79244ffd74de', class: "size" }, getFileSize(this.message.size)))), h("rtk-button", { key: 'e4eb744391b8fe61bd4d58e3ac3d7d10ee748976', variant: "secondary", kind: "icon", onClick: () => downloadFile(link, { name: this.message.name, fallbackName: 'file' }), part: "button" }, h("rtk-icon", { key: '79efeb36257d970f243d1730d0ac4ad84bc6993d', icon: this.iconPack.download }))))));
    }
}, [0, "rtk-file-message", {
        "message": [16],
        "now": [16],
        "isContinued": [516, "is-continued"],
        "iconPack": [16],
        "t": [16],
        "showBubble": [4, "show-bubble"]
    }]);
__decorate([
    SyncWithStore()
], RtkFileMessage.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkFileMessage.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-file-message", "rtk-button", "rtk-icon"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-file-message":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkFileMessage);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkFileMessage as R, defineCustomElement as d };
