import{r as o,h as i,a as t,c as e}from"./p-PqnYwNKt.js";import{d as n,t as s}from"./p-DcmcuUOA.js";import{i as c}from"./p-Bw2fh5LT.js";const a=':root{--ifx-font-family:"Source Sans 3", "Arial, sans-serif"}:host{display:block}.accordion-wrapper{display:flex;flex-direction:column;gap:8px;font-family:var(--ifx-font-family)}';const r=class{constructor(i){o(this,i);this.autoCollapse=false}async componentDidLoad(){if(!c(this.el)){const o=n();s("ifx-accordion",await o)}}async onItemOpen(o){if(this.autoCollapse){const i=Array.from(this.el.querySelectorAll("ifx-accordion-item"));for(const t of i){const i=t;if(i!==o.target&&await i.open){i.open=false}}}}render(){return i("div",{key:"903cc44b4886b77e59e66ab2a5cdf681dafeb9bc",class:"accordion-wrapper"},i("slot",{key:"e0abec42188606e8c80fc3db44fba19a7aa69ed8"}))}static get delegatesFocus(){return true}get el(){return t(this)}};r.style=a;const d=':root{--ifx-font-family:"Source Sans 3", "Arial, sans-serif"}.accordion-item{border-radius:3px;transition:all 0.3s;font-family:var(--ifx-font-family)}.accordion-title:focus{outline:none}.accordion-title:focus::after{content:"";display:block;position:absolute;top:-4px;bottom:-4px;left:-4px;right:-4px;border-radius:5px;border:2px solid #0A8276;box-sizing:border-box}.accordion-title:hover{border:1px solid #EEEDED;color:#08665C}.accordion-title{display:flex;align-items:center;position:relative;padding:12px 16px;gap:12px;color:#0A8276;background-color:#FFFFFF;border:1px solid #EEEDED;cursor:pointer;margin:4px 4px 0px}.accordion-caption{font-weight:600;font-size:1.125rem}.accordion-content{gap:8px;line-height:24px;font-size:1rem;font-weight:400}.inner-content{background-color:#FFFFFF;padding:16px;word-wrap:break-word;overflow-wrap:anywhere;align-self:stretch;}.accordion-icon{font-weight:bold;display:flex;transition:transform 0.3s}.accordion-icon:hover{color:#08665C}.accordion-item.open .accordion-icon{transform:rotate(-180deg)}.accordion-item.open .inner-content{border:1px solid #EEEDED;border-top:none;margin:0 4px 4px}.inner-content.no-content{border:none;padding:0}';const f=class{constructor(i){o(this,i);this.ifxOpen=e(this,"ifxOpen",7);this.ifxClose=e(this,"ifxClose",7);this.open=false;this.AriaLevel=3;this.internalOpen=false}componentWillLoad(){this.internalOpen=this.open}componentDidLoad(){this.checkSlotContent();this.openAccordionItem();this.contentEl=this.el.shadowRoot.querySelector("#accordion-content");if(this.contentEl){this.attachResizeObserver()}}componentDidUpdate(){this.checkSlotContent();this.openAccordionItem()}openChanged(o){this.internalOpen=o}toggleOpen(){this.internalOpen=!this.internalOpen;this.open=this.internalOpen;if(this.internalOpen){this.ifxOpen.emit({isOpen:this.internalOpen})}else{this.ifxClose.emit({isClosed:!this.internalOpen})}}openAccordionItem(){if(this.contentEl){if(this.internalOpen){this.contentEl.style.height="auto";const o=this.contentEl.scrollHeight;this.contentEl.style.height=`${o}px`;this.contentEl.style.overflow="visible"}else{this.contentEl.style.height="0";this.contentEl.style.overflow="hidden"}}}getInnerContentWrapper(){const o=this.el.shadowRoot.querySelector(".inner-content");return o}attachResizeObserver(){const o=this.getInnerContentWrapper();if(o){this.resizeObserver=new ResizeObserver((()=>{if(this.internalOpen){this.openAccordionItem()}}));this.resizeObserver.observe(o)}}handleKeydown(o){const i=o.composedPath();if(!i.includes(this.titleEl)){return}switch(o.key){case"Enter":case" ":o.preventDefault();this.toggleOpen();break}}checkSlotContent(){const o=this.el.shadowRoot.querySelector("slot");const i=o.assignedNodes().length>0;const t=this.getInnerContentWrapper();if(!i){t.classList.add("no-content")}else if(t.classList.contains("no-content")){t.classList.remove("no-content")}}render(){return i("div",{key:"ac0d35621b7f06c3dd0bcde1b400dd173a1fcabd",class:`accordion-item ${this.internalOpen?"open":""}`},i("div",{key:"88eaf8e286c71444636256f3b8d249912624dbd5",role:"button","aria-expanded":this.internalOpen,"aria-controls":"accordion-content",class:"accordion-title",onClick:()=>this.toggleOpen(),tabindex:"0",ref:o=>this.titleEl=o},i("span",{key:"4dee92a98b178f371592b69723fc24b7606e916f","aria-hidden":"true",role:"heading","aria-level":String(this.AriaLevel),class:"accordion-icon"},i("ifx-icon",{key:"cfab69fc24b3c7e442379701612827d8564a1572",icon:"chevron-down-16"})),i("span",{key:"e3f2864b2987b47e4f4f80e033198dda06f25805",id:"accordion-caption",class:"accordion-caption"},this.caption)),i("div",{key:"8a5c24c39e6366f1bdbbe4360113f4bda340fa19",id:"accordion-content",class:"accordion-content",ref:o=>this.contentEl=o,role:"region","aria-labelledby":"accordion-caption"},i("div",{key:"2d9585a6958af61c60b98d4b1dc2763bfdddf603",class:"inner-content"},i("slot",{key:"2fe3539eb389112be66e8bfe729b6b2bbadec2df"}))))}get el(){return t(this)}static get watchers(){return{open:["openChanged"]}}};f.style=d;export{r as ifx_accordion,f as ifx_accordion_item};
//# sourceMappingURL=p-3244fc8c.entry.js.map