import { p as proxyCustomElement, H, e as createEvent, h } from './p-ae373651.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import './p-a83ccdbd.js';
import { a as sanitizeLink } from './p-efabd2ce.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { d as downloadFile } from './p-47314bc7.js';
import { d as defineCustomElement$3 } from './p-85587a5c.js';
import { d as defineCustomElement$2 } from './p-3e0452c4.js';
import { d as defineCustomElement$1 } from './p-e6245534.js';

const rtkImageMessageViewCss = ":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)}.image-spinner{cursor:wait}.image-errored{cursor:not-allowed}.image{display:block;font-family:var(--rtk-font-family, sans-serif);color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));position:relative;height:var(--rtk-space-40, 160px);max-width:var(--rtk-space-64, 256px);cursor:pointer}.image img{display:none;height:100%;width:100%;border-radius:var(--rtk-border-radius-sm, 4px);-o-object-fit:cover;object-fit:cover}.image .image-spinner{display:flex;height:100%;width:100%;flex-direction:column;align-items:center;justify-content:center;border-radius:var(--rtk-border-radius-sm, 4px);--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-800, 30 30 30) / var(--tw-bg-opacity))}.image .image-spinner rtk-spinner{--tw-text-opacity:1;color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-text-opacity))}.image .image-errored{display:flex;height:100%;width:100%;flex-direction:column;align-items:center;justify-content:center;border-radius:var(--rtk-border-radius-sm, 4px);background-color:rgba(var(--rtk-colors-danger, 255 45 45) / 0.1);--tw-text-opacity:1;color:rgba(var(--rtk-colors-danger, 255 45 45) / var(--tw-text-opacity))}.image .actions{display:none;height:var(--rtk-space-8, 32px);align-items:center;position:absolute;top:var(--rtk-space-2, 8px);right:var(--rtk-space-2, 8px);border-radius:var(--rtk-border-radius-sm, 4px);--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-900, 26 26 26) / var(--tw-bg-opacity));color:rgb(var(--rtk-colors-text-1000, 255 255 255));overflow:hidden;--tw-shadow:0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.image .actions .action{height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);border-radius:var(--rtk-border-radius-none, 0);border-width:var(--rtk-border-width-none, 0);border-style:none;background-color:transparent;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.image .actions .action:hover{--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-600, 60 60 60) / var(--tw-bg-opacity))}.image.loaded img{display:block}.image.loaded .image-spinner{display:none}.image:hover .actions,.image:focus .actions{display:flex}";
const RtkImageMessageViewStyle0 = rtkImageMessageViewCss;

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 RtkImageMessageView = /*@__PURE__*/ proxyCustomElement(class RtkImageMessageView extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.onPreview = createEvent(this, "preview", 7);
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.status = 'loading';
    }
    render() {
        return (h("div", { key: '4f52d3d7ff948d02832cf5f53ae9b483c8502b84', class: { image: true, loaded: this.status === 'loaded' } }, h("img", { key: '06efe7798b2d59ee6b3acde68418763c89fc285f', src: sanitizeLink(this.url), onLoad: () => {
                this.status = 'loaded';
            }, onError: () => {
                this.status = 'errored';
            }, onClick: () => {
                if (this.status === 'loaded') {
                    this.onPreview.emit(this.url);
                }
            } }), this.status === 'loading' && (h("div", { key: '366f02c0b48cf06e527cc0b3c42ef1ac5ff0ac36', class: "image-spinner", title: this.t('chat.img.loading'), "aria-label": this.t('chat.img.loading') }, h("rtk-spinner", { key: '90cd7d607487b8016ab838a31bcee39aacec0ba2', iconPack: this.iconPack }))), this.status === 'errored' && (h("div", { key: 'd7b1fe803153799855aa8220af81f6b973b9117d', class: "image-errored", title: this.t('chat.error.img_not_found'), "aria-label": this.t('chat.error.img_not_found') }, h("rtk-icon", { key: '83060f609b0df333aa91d3b21a4634d943d2352f', icon: this.iconPack.image_off }))), this.status === 'loaded' && (h("div", { key: '1db7dc269511f477c60faa681fb39cfa09a517ab', class: "actions" }, h("rtk-button", { key: 'a45138b3cfeeae245d28d3493396e5c5ea102b49', class: "action", variant: "secondary", kind: "icon", onClick: () => {
                this.onPreview.emit(this.url);
            } }, h("rtk-icon", { key: 'b44a303fa4ed28a2a39ef372dfa5b58908698a2c', icon: this.iconPack.full_screen_maximize })), h("rtk-button", { key: '0e687d5c92264a8d2fa28e1921ccbd4797bfd2e3', class: "action", variant: "secondary", kind: "icon", onClick: () => downloadFile(this.url, { fallbackName: 'image' }) }, h("rtk-icon", { key: '1f2d01d576a2faa7483ada2e82f5cbf4cb8534b5', icon: this.iconPack.download }))))));
    }
    static get style() { return RtkImageMessageViewStyle0; }
}, [1, "rtk-image-message-view", {
        "url": [1],
        "iconPack": [16],
        "t": [16],
        "status": [32]
    }]);
__decorate([
    SyncWithStore()
], RtkImageMessageView.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkImageMessageView.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-image-message-view", "rtk-button", "rtk-icon", "rtk-spinner"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-image-message-view":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkImageMessageView);
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "rtk-spinner":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { RtkImageMessageView as R, defineCustomElement as d };
