'use strict';

var index = require('./index-DuCXzb-X.js');

const spwLightboxItemCss = () => `html{line-height:1.3;-webkit-text-size-adjust:100%;}h1,h2,h3,h4,h5,h6,p,ul,li{padding:0;margin:0}ul{list-style:none}:host{box-sizing:border-box;line-height:1.3;-webkit-text-size-adjust:100%;font-size:100%}:host *,:host *::before,:host *::after{box-sizing:inherit;font-family:var(--spw-ds-font-main)}body{margin:0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0;}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px;}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}:root{--spw-ds-container-xl:1232px;--spw-ds-container-lg:1024px;--spw-ds-container-md:768px;--spw-ds-container-sm:640px}.spw-ds-container{width:100%;padding-left:16px;padding-right:16px;margin-left:auto;margin-right:auto}@media (min-width: 460px){.spw-ds-container{max-width:var(--spw-ds-container-sm)}}@media (min-width: 768px){.spw-ds-container{max-width:var(--spw-ds-container-md)}}@media (min-width: 1024px){.spw-ds-container{max-width:var(--spw-ds-container-lg)}}@media (min-width: 1350px){.spw-ds-container{max-width:var(--spw-ds-container-xl)}}:host{display:block;cursor:pointer;border-radius:4px;outline:none;height:100%}.spw-lightbox-item__wrapper{position:relative;width:100%;height:100%;overflow:hidden;border-radius:4px}.spw-lightbox-item__wrapper:focus-visible{outline:3px solid #fff;outline-offset:-1px;box-shadow:0 0 0 5px #000}.spw-lightbox-item__img{display:block;width:100%;height:100%;object-fit:cover;transition:opacity 0.15s}::slotted(img){display:block;width:100%;height:100%;object-fit:cover}.spw-lightbox-item__wrapper--hoverable{transition:box-shadow 0.3s ease-in-out, transform 0.3s ease-in-out}.spw-lightbox-item__wrapper--hoverable:hover{box-shadow:var(--spw-effect-elevation-4);transform:translateY(-5px)}.spw-lightbox-item__hover-overlay{position:absolute;z-index:2;display:flex;visibility:hidden;top:0;left:0;width:100%;height:100%;color:white;justify-content:center;align-items:center;opacity:0;transition:all 0.3s ease}.spw-lightbox-item__hover-overlay:before{content:"";position:absolute;top:0;left:0;width:100%;height:100%;background:black;opacity:0.4}.spw-lightbox-item__hover-overlay spw-icon{position:relative;z-index:1;font-size:30px;font-weight:300;transform:scale(1.5);transition:all 0.3s ease}:host(:hover) .spw-lightbox-item__hover-overlay{visibility:visible;opacity:1}:host(:hover) .spw-lightbox-item__hover-overlay spw-icon{transform:scale(1)}`;

const SpwLightboxItem = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.spwLightboxItemClick = index.createEvent(this, "spwLightboxItemClick", 7);
        /** Texte alternatif de l'image */
        this.alt = '';
        /** Icône Font Awesome du copyright */
        this.copyrightIcon = 'fa-copyright';
        /** Permet de spécifier une variante de Font Awesome pour l'icône de copyright */
        this.copyrightIconVariant = 'fa-light';
        /** Target du lien du copyright */
        this.copyrightTarget = '_blank';
        /** Texte du label aria du bouton déclencheur */
        this.textOpenImage = "Ouvrir l'image";
        /** Affiche une icône de loupe en superposition au survol */
        this.isHover = true;
        /** Icône affichée au survol de l'image (référence Font Awesome) */
        this.hoverIcon = 'fa-magnifying-glass';
    }
    getIndex() {
        const parent = this.hostElement.closest('spw-lightbox');
        if (!parent)
            return 0;
        const siblings = Array.from(parent.querySelectorAll('spw-lightbox-item'));
        return siblings.indexOf(this.hostElement);
    }
    handleClick() {
        this.spwLightboxItemClick.emit({
            src: this.src,
            alt: this.alt,
            captionTitle: this.captionTitle || '',
            captionText: this.captionText || '',
            index: this.getIndex(),
        });
    }
    handleKeydown(event) {
        if (event.key === 'Enter' || event.key === ' ') {
            event.preventDefault();
            this.handleClick();
        }
    }
    render() {
        return (index.h(index.Host, { key: 'e0a1b9ba9e2a4c33e939eb44ad70d5b9474b7f98' }, index.h("div", { key: '8fa6be30d88c4ad0985b21699eca9b1733c95002', class: { 'spw-lightbox-item__wrapper': true, 'spw-lightbox-item__wrapper--hoverable': this.isHover }, role: "button", tabindex: "0", "aria-label": this.alt || this.textOpenImage, onClick: () => this.handleClick(), onKeyDown: (e) => this.handleKeydown(e) }, index.h("slot", { key: '780cc51e40ecd7509c618a3610168f9742f274ef' }, index.h("img", { key: '230ce5be541a1bb669576f3fab40bda4332cb16f', class: "spw-lightbox-item__img", src: this.src, alt: this.alt, loading: "lazy" })), this.isHover && (index.h("div", { key: '7b02bc0d790df3f55a31ec9cb51cdd47241ba17f', class: "spw-lightbox-item__hover-overlay" }, index.h("spw-icon", { key: '8a3398b30350959fedc6babd7d36cf102e7c31be', icon: this.hoverIcon }))))));
    }
    get hostElement() { return index.getElement(this); }
};
SpwLightboxItem.style = spwLightboxItemCss();

exports.spw_lightbox_item = SpwLightboxItem;
