import{E as h,S as o,d as p,B as E,r as u,g as A}from"./dom.min.js?5.3.8";const C="collapse",S="bs.collapse",g=`.${S}`,L=".data-api",T=`show${g}`,w=`shown${g}`,N=`hide${g}`,D=`hidden${g}`,y=`click${g}${L}`,m="show",c="collapse",_="collapsing",O="collapsed",I=`:scope .${c} .${c}`,v="collapse-horizontal",b="width",$="height",H=".collapse.show, .collapse.collapsing",f='[data-bs-toggle="collapse"]',M={parent:null,toggle:!0},P={parent:"(null|element)",toggle:"boolean"};class a extends E{constructor(t,s){super(t,s),this._isTransitioning=!1,this._triggerArray=[];const e=o.find(f);for(const n of e){const i=o.getSelectorFromElement(n),d=o.find(i).filter(r=>r===this._element);i!==null&&d.length&&this._triggerArray.push(n)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return M}static get DefaultType(){return P}static get NAME(){return C}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let t=[];if(this._config.parent&&(t=this._getFirstLevelChildren(H).filter(r=>r!==this._element).map(r=>a.getOrCreateInstance(r,{toggle:!1}))),t.length&&t[0]._isTransitioning||h.trigger(this._element,T).defaultPrevented)return;for(const r of t)r.hide();const e=this._getDimension();this._element.classList.remove(c),this._element.classList.add(_),this._element.style[e]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const n=()=>{this._isTransitioning=!1,this._element.classList.remove(_),this._element.classList.add(c,m),this._element.style[e]="",h.trigger(this._element,w)},d=`scroll${e[0].toUpperCase()+e.slice(1)}`;this._queueCallback(n,this._element,!0),this._element.style[e]=`${this._element[d]}px`}hide(){if(this._isTransitioning||!this._isShown()||h.trigger(this._element,N).defaultPrevented)return;const s=this._getDimension();this._element.style[s]=`${this._element.getBoundingClientRect()[s]}px`,u(this._element),this._element.classList.add(_),this._element.classList.remove(c,m);for(const n of this._triggerArray){const i=o.getElementFromSelector(n);i&&!this._isShown(i)&&this._addAriaAndCollapsedClass([n],!1)}this._isTransitioning=!0;const e=()=>{this._isTransitioning=!1,this._element.classList.remove(_),this._element.classList.add(c),h.trigger(this._element,D)};this._element.style[s]="",this._queueCallback(e,this._element,!0)}_isShown(t=this._element){return t.classList.contains(m)}_configAfterMerge(t){return t.toggle=!!t.toggle,t.parent=A(t.parent),t}_getDimension(){return this._element.classList.contains(v)?b:$}_initializeChildren(){if(!this._config.parent)return;const t=this._getFirstLevelChildren(f);for(const s of t){const e=o.getElementFromSelector(s);e&&this._addAriaAndCollapsedClass([s],this._isShown(e))}}_getFirstLevelChildren(t){const s=o.find(I,this._config.parent);return o.find(t,this._config.parent).filter(e=>!s.includes(e))}_addAriaAndCollapsedClass(t,s){if(t.length)for(const e of t)e.classList.toggle(O,!s),e.setAttribute("aria-expanded",s)}static jQueryInterface(t){const s={};return typeof t=="string"&&/show|hide/.test(t)&&(s.toggle=!1),this.each(function(){const e=a.getOrCreateInstance(this,s);if(typeof t=="string"){if(typeof e[t]>"u")throw new TypeError(`No method named "${t}"`);e[t]()}})}}if(h.on(document,y,f,function(l){(l.target.tagName==="A"||l.delegateTarget&&l.delegateTarget.tagName==="A")&&l.preventDefault();for(const t of o.getMultipleElementsFromSelector(this))a.getOrCreateInstance(t,{toggle:!1}).toggle()}),p(a),window.bootstrap=window.bootstrap||{},window.bootstrap.Collapse=a,Joomla&&Joomla.getOptions){const l={...Joomla.getOptions("bootstrap.collapse"),...Joomla.getOptions("bootstrap.accordion")};Object.keys(l).forEach(t=>{const s=l[t],e={toggle:s.toggle?s.toggle:!0};s.parent&&(e.parent=s.parent);const n=Array.from(document.querySelectorAll(t));n.length&&n.map(i=>new window.bootstrap.Collapse(i,e))})}export{a as C};
