import { r as registerInstance, h, H as Host, a as getElement } from './index-Co4V4Zk-.js';

const spwTimelineCss = () => `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-timeline{display:flex;gap:6px}.spw-timeline--horizontal{flex-direction:row}.spw-timeline--vertical{flex-direction:column;align-items:flex-start}.spw-timeline__toggle{margin-top:8px;padding-left:32px;margin-left:7px;border-left:3px dashed #d1d5db}.spw-timeline__toggle--less{border-left-color:transparent}.spw-timeline__toggle-btn{background:none;border:none;color:var(--spw-ds-primary);font-size:14px;font-weight:700;text-decoration:underline;cursor:pointer;padding:0}.spw-timeline__toggle-btn:hover{text-decoration:none}`;

const SpwTimeline = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /** Orientation de la timeline */
        // @Prop() variant?: 'horizontal' | 'vertical' = 'vertical';
        /** Nombre d'items visibles initialement (0 = tous visibles) */
        this.visibleItems = 0;
        /** Texte du bouton "voir plus" */
        this.showMoreText = 'Voir plus';
        /** Texte du bouton "voir moins" */
        this.showLessText = 'Voir moins';
        /** État indiquant si tous les items sont affichés */
        this.showAll = false;
        this.handleToggle = () => {
            this.showAll = !this.showAll;
            this.updateItemsState();
        };
    }
    componentWillLoad() {
        this.updateItemsState();
    }
    slotChanged() {
        this.updateItemsState();
    }
    updateItemsState() {
        requestAnimationFrame(() => {
            const items = this.el.querySelectorAll('spw-timeline-item');
            items.forEach((item, index) => {
                item.setAttribute('variant', 'vertical');
                item.setAttribute('is-last', (index === items.length - 1).toString());
                if (this.visibleItems > 0 && !this.showAll) {
                    if (index >= this.visibleItems) {
                        item.style.display = 'none';
                    }
                    else {
                        item.style.display = '';
                    }
                }
                else {
                    item.style.display = '';
                }
            });
        });
    }
    get elementClass() {
        return {
            'spw-timeline': true,
            [`spw-timeline--vertical`]: true,
        };
    }
    shouldShowToggleButton() {
        const items = this.el.querySelectorAll('spw-timeline-item');
        return this.visibleItems > 0 && items.length > this.visibleItems;
    }
    render() {
        return (h(Host, { key: '5a946a9f72eaf694c95a6e389cd05e7c035d447e' }, h("div", { key: 'b77053be46bbefbe1e7b683d37e09b29697491ba', class: this.elementClass }, h("slot", { key: 'bef7bec9265481d21bd8bbb31ba7f4f6536685e1' })), this.shouldShowToggleButton() && (h("div", { key: 'e55bf4fcce24e65a7d4da053c3bb2c72da20b8cf', class: {
                'spw-timeline__toggle': true,
                'spw-timeline__toggle--more': !this.showAll,
                'spw-timeline__toggle--less': this.showAll,
            } }, h("span", { key: 'a04f13df12d839d923038a1472b54fb1057b2294', class: "spw-timeline__toggle-btn", onClick: this.handleToggle }, this.showAll ? this.showLessText : this.showMoreText)))));
    }
    get el() { return getElement(this); }
};
SpwTimeline.style = spwTimelineCss();

export { SpwTimeline as spw_timeline };
