'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index$1 = require('./index-2e5758b6.js');
const uiStore = require('./ui-store-583d205a.js');
const file = require('./file-0b9afa34.js');
const index = require('./index-3f8e5441.js');
const string = require('./string-9bce3253.js');

const rtkImageViewerCss = ":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)}.scrollbar{scrollbar-width:thin;scrollbar-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))\n    var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar{height:var(--rtk-space-1\\.5, 6px);width:var(--rtk-space-1\\.5, 6px);border-radius:9999px;background-color:var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar-thumb{border-radius:9999px;background-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))}:host{width:1140px;max-width:100%;box-sizing:border-box;display:flex;flex-direction:column;padding:var(--rtk-space-6, 24px);padding-top:var(--rtk-space-5, 20px);overflow-y:auto;color:rgb(var(--rtk-colors-text-1000, 255 255 255));z-index:40;border-radius:var(--rtk-border-radius-md, 8px);--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-900, 26 26 26) / var(--tw-bg-opacity))}.displayName{font-weight:700}.image-ctr{margin-top:var(--rtk-space-2, 8px);box-sizing:border-box;display:flex;justify-content:center;overflow:hidden}.actions{display:flex;align-items:center;justify-content:flex-end;gap:var(--rtk-space-2, 8px)}img{box-sizing:border-box;display:block;max-height:100%;max-width:100%;-o-object-fit:contain;object-fit:contain}.header{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--rtk-space-4, 16px)}.shared-by-user{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}:host([size='sm']) .header{flex-direction:column}:host([size='sm']) .header .actions{margin-top:var(--rtk-space-4, 16px)}";
const RtkImageViewerStyle0 = rtkImageViewerCss;

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 RtkImageViewer = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        this.close = index$1.createEvent(this, "close", 7);
        /** Language */
        this.t = uiStore.useLanguage();
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        this.keypressListener = (e) => {
            if (e.key === 'Escape') {
                this.close.emit();
            }
        };
        this.handleOutsideClick = () => this.close.emit();
    }
    connectedCallback() {
        document.addEventListener('keydown', this.keypressListener);
        document.addEventListener('click', this.handleOutsideClick);
    }
    disconnectedCallback() {
        document.removeEventListener('keydown', this.keypressListener);
        document.removeEventListener('click', this.handleOutsideClick);
    }
    render() {
        return (index$1.h(index$1.Host, { key: '09122e4d61355092a9c82bc337ea002a6c2acd58', class: "scrollbar", onClick: (e) => e.stopPropagation() }, index$1.h("div", { key: '2c6c3f705abf067d866e02b81c4b3d610f09fede', class: "header" }, index$1.h("div", { key: '66cd4c200a2e8704acdf75d8830c94ac2abdc6be', class: "shared-by-user" }, this.t('chat.img.shared_by'), ' ', index$1.h("span", { key: '3b4a866b673f35a454e7115fdc5c915d68966b1d', class: "displayName" }, string.formatName(string.shorten(this.image.displayName)))), index$1.h("div", { key: '29e0e95e3e3d3b36917745a8f0a47beb9b5e3f02', class: "actions" }, index$1.h("rtk-button", { key: '5cd7383e265a02c8b57a0f712e9e445495498c32', onClick: () => file.downloadFile(this.image.link, { fallbackName: 'image' }) }, index$1.h("rtk-icon", { key: 'b098e89f707cc4cf413a620319e0eb2fd10b729a', icon: this.iconPack.download, slot: "start" }), "Download"), index$1.h("rtk-button", { key: '2cd6b7c21f0357d3104618d96d853d8bd8fcc542', kind: "icon", variant: "secondary", onClick: () => this.close.emit() }, index$1.h("rtk-icon", { key: '891428595d7a61c5400dc884bf8e1a501009eed5', icon: this.iconPack.dismiss })))), index$1.h("div", { key: '6194a26ac1357b93776b1c77ff72d1502151d619', class: "image-ctr" }, index$1.h("img", { key: '24f21e7fff100bea8e79d261f180a57dc14fa5f4', src: this.image.link }))));
    }
};
__decorate([
    index.SyncWithStore()
], RtkImageViewer.prototype, "t", void 0);
__decorate([
    index.SyncWithStore()
], RtkImageViewer.prototype, "iconPack", void 0);
RtkImageViewer.style = RtkImageViewerStyle0;

exports.rtk_image_viewer = RtkImageViewer;
