'use strict';

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

const spwTileCss = () => `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}.spw-tile{display:block;text-decoration:none;position:relative;transition:all 0.3s ease-in-out}.spw-tile--hoverable:hover{transform:translateY(-5px)}.spw-tile:focus-visible{outline:3px solid white;outline-offset:-1px;box-shadow:0 0 0 5px black;border-radius:5px}.spw-tile--icon{padding:16px 0}.spw-tile--big,.spw-tile--light{position:relative;padding-top:calc(70% - 12px);border-radius:6px;overflow:hidden}@media (min-width: 1024px){.spw-tile--big,.spw-tile--light{padding-top:calc(60% - 12px)}.spw-tile--big.spw-tile--height-landscape,.spw-tile--light.spw-tile--height-landscape{padding-top:calc(60% - 12px)}.spw-tile--big.spw-tile--height-square,.spw-tile--light.spw-tile--height-square{padding-top:100%}.spw-tile--big.spw-tile--height-portrait,.spw-tile--light.spw-tile--height-portrait{padding-top:150%}}.spw-tile--big:before,.spw-tile--light:before{content:"";background:black;opacity:0;transition:all linear 0.2s;border-radius:5px;position:absolute;top:0;left:0;width:100%;height:100%;z-index:2}.spw-tile--big:hover:before,.spw-tile--light:hover:before{opacity:0.3}.spw-tile__overlay,.spw-tile__image{position:absolute;width:100%;height:100%;left:0;top:0}.spw-tile__overlay{z-index:2;background:linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 65%, rgba(0, 0, 0, 0.75) 100%)}.spw-tile__image{z-index:1;object-fit:cover}.spw-tile__button{background:white;width:48px;height:48px;display:inline-flex;align-items:center;justify-content:center;color:var(--spw-ds-primary);border-radius:50%;transition:all 0.2s ease-in;border:2px solid transparent;font-size:20px;margin-top:12px}.spw-tile:hover .spw-tile__button{border-color:white;color:white;background:transparent}.spw-tile--icon .spw-tile__content{display:flex;flex-direction:column;gap:12px;padding:0 12px;text-align:center}.spw-tile--icon .spw-tile__content ::slotted(spw-icon){font-size:32px;color:var(--spw-ds-primary)}.spw-tile--light .spw-tile__content,.spw-tile--big .spw-tile__content{position:absolute;z-index:3;display:flex;flex-direction:column;gap:6px;padding:24px;bottom:0;left:0;width:100%}.spw-tile--light .spw-tile__content{text-align:center;padding-bottom:24px}`;

const SpwTile = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        /** Type de variante de tuile */
        this.variant = 'light';
        /** Variante de hauteur de la tuile (valable pour les variants big & light) */
        this.height = 'landscape';
        /** Attribut target, s'applique uniquement si href est rempli */
        this.target = '_self';
        /** Texte alternatif de l'image de fond */
        this.imageAlt = '';
        /** Opacité de l'overlay (valeur entre 0 et 100) */
        this.overlayOpacity = 100;
    }
    componentWillLoad() {
        this.applyVariantToChildren();
    }
    slotChanged() {
        this.applyVariantToChildren();
    }
    applyVariantToChildren() {
        requestAnimationFrame(() => {
            const variantClass = `--${this.variant}`;
            const titleElement = this.el.querySelector('spw-tile-title');
            const descriptionElement = this.el.querySelector('spw-tile-description');
            titleElement && titleElement.classList.add(variantClass);
            descriptionElement && descriptionElement.classList.add(variantClass);
        });
    }
    get elementClass() {
        return {
            'spw-tile': true,
            'spw-tile--hoverable': !!this.href,
            [`spw-tile--${this.variant}`]: true,
            [`spw-tile--height-${this.height}`]: true,
        };
    }
    onMouseEnter() {
        this.setHovered(true);
    }
    onMouseLeave() {
        this.setHovered(false);
    }
    setHovered(isHovered) {
        const titleElement = this.el.querySelector('spw-tile-title');
        if (titleElement && this.href) {
            titleElement.classList.toggle('--hovered', isHovered);
        }
    }
    render() {
        const { href, target } = this;
        const TagType = this.href === undefined ? 'div' : 'a';
        const attrs = TagType === 'div'
            ? {}
            : {
                href,
                target,
            };
        return (index.h(index.Host, { key: '16f734c527ff0ac336142d6cd6cdbb0339fc61a1' }, index.h(TagType, Object.assign({ key: 'a40105bb95a5c6e3c14f6b1fae4a1966b78c80c0' }, attrs, { class: this.elementClass }), this.imageSrc && (this.variant === 'big' || this.variant === 'light') && (index.h(index.Fragment, { key: '7b57b8f146aa6f46b7d99e02d91f330acacf07a0' }, index.h("div", { key: '3c49b89e8e5c0f6935b407a2b600aaca7584534f', class: "spw-tile__overlay", style: { opacity: `${this.overlayOpacity / 100}` } }), index.h("img", { key: '347f6823f45bdfb03036d9e7bc26d63b318fa740', src: this.imageSrc, alt: this.imageAlt, class: "spw-tile__image" }))), index.h("div", { key: 'f8005c3d3776645ced88dcc32f06a462fc4a3ed4', class: "spw-tile__content" }, index.h("slot", { key: '4c08160a9346aa3a0af50a8288de295f84987fbb' }), this.href && this.variant === 'big' && (index.h("span", { key: '47f15e799b4aad2da067032d270d5c3a0b34619a', class: "spw-tile__button" }, index.h("spw-icon", { key: '8fd5410c6ab909df39503655ec09ecfecab972c2', icon: "fa-chevron-right" })))))));
    }
    get el() { return index.getElement(this); }
};
SpwTile.style = spwTileCss();

exports.spw_tile = SpwTile;
