var __decorate = (this && this.__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;
};
import { UmbMediaDetailRepository } from '../../repository/index.js';
import { UmbMediaUrlRepository } from '../../url/index.js';
import { css, html, customElement } from '../../../../../external/lit/index.js';
import { UmbModalBaseElement } from '../../../../core/modal/index.js';
let UmbMediaCaptionAltTextModalElement = class UmbMediaCaptionAltTextModalElement extends UmbModalBaseElement {
    #mediaUnique;
    #mediaDetailRepository = new UmbMediaDetailRepository(this);
    #mediaUrlRepository = new UmbMediaUrlRepository(this);
    connectedCallback() {
        super.connectedCallback();
        this.#mediaUnique = this.data?.mediaUnique;
        this.#getMediaDetail();
    }
    async #getMediaDetail() {
        if (!this.#mediaUnique)
            return;
        const { data: mediaData } = await this.#mediaDetailRepository.requestByUnique(this.#mediaUnique);
        if (!mediaData)
            return;
        const { data: mediaUrlData } = await this.#mediaUrlRepository.requestItems([this.#mediaUnique]);
        this.value = {
            ...this.value,
            altText: this.value?.altText ?? mediaData.variants[0].name,
            url: mediaUrlData?.[0].url ?? '',
        };
    }
    render() {
        return html `
			<umb-body-layout .headline=${this.localize.term('defaultdialogs_editSelectedMedia')}>
				<div id="wrapper">
					<uui-label for="alt-text">${this.localize.term('content_altTextOptional')}</uui-label>
					<uui-input
						id="alt-text"
						label="alt text"
						.value=${this.value?.altText ?? ''}
						@input=${(e) => (this.value = { ...this.value, altText: e.target.value })}></uui-input>

					<uui-label for="caption">${this.localize.term('content_captionTextOptional')}</uui-label>
					<uui-input
						id="caption"
						label="caption"
						.value=${this.value?.caption ?? ''}
						@input=${(e) => (this.value = { ...this.value, caption: e.target.value })}></uui-input>

					<figure id="mainobject">
						<img src=${this.value?.url ?? ''} alt=${this.value?.altText ?? ''} />
						<figcaption>${this.value?.caption ?? ''}</figcaption>
					</figure>
				</div>
				<div slot="actions">
					<uui-button label=${this.localize.term('general_close')} @click=${this._rejectModal}></uui-button>
					<uui-button
						label=${this.localize.term('general_submit')}
						look="primary"
						color="positive"
						@click=${this._submitModal}></uui-button>
				</div>
			</umb-body-layout>
		`;
    }
    static { this.styles = [
        css `
			uui-input {
				margin-bottom: var(--uui-size-layout-1);
			}

			#wrapper {
				display: flex;
				flex-direction: column;
			}

			#mainobject {
				display: flex;
				flex-direction: column;
				max-width: 100%;

				img {
					max-width: 100%;
					height: auto;
				}
			}
		`,
    ]; }
};
UmbMediaCaptionAltTextModalElement = __decorate([
    customElement('umb-media-caption-alt-text-modal')
], UmbMediaCaptionAltTextModalElement);
export { UmbMediaCaptionAltTextModalElement };
export default UmbMediaCaptionAltTextModalElement;
