/*!
 * EdGEL: The University of Edinburgh Design System v5.1.6-rc.2 (https://design-system.ed.ac.uk/)
 * Copyright 2014-2024 The University of Edinburgh
 *
 * Bootstrap  v5.3.3 (https://getbootstrap.com/)
 * Copyright 2011-2024 The Bootstrap Authors
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 */
import{E as e,S as t,d as s,B as i,r as n,g as l}from"./selector-engine-CW-6rw1H.js";const r=".bs.collapse",o=`show${r}`,a=`shown${r}`,h=`hide${r}`,g=`hidden${r}`,c=`click${r}.data-api`,_="show",d="collapse",m="collapsing",f=`:scope .${d} .${d}`,p='[data-bs-toggle="collapse"]',u={parent:null,toggle:!0},C={parent:"(null|element)",toggle:"boolean"};class A extends i{constructor(e,s){super(e,s),this._isTransitioning=!1,this._triggerArray=[];const i=t.find(p);for(const e of i){const s=t.getSelectorFromElement(e),i=t.find(s).filter((e=>e===this._element));null!==s&&i.length&&this._triggerArray.push(e)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return u}static get DefaultType(){return C}static get NAME(){return"collapse"}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let t=[];if(this._config.parent&&(t=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter((e=>e!==this._element)).map((e=>A.getOrCreateInstance(e,{toggle:!1})))),t.length&&t[0]._isTransitioning)return;if(e.trigger(this._element,o).defaultPrevented)return;for(const e of t)e.hide();const s=this._getDimension();this._element.classList.remove(d),this._element.classList.add(m),this._element.style[s]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const i=`scroll${s[0].toUpperCase()+s.slice(1)}`;this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(m),this._element.classList.add(d,_),this._element.style[s]="",e.trigger(this._element,a)}),this._element,!0),this._element.style[s]=`${this._element[i]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if(e.trigger(this._element,h).defaultPrevented)return;const s=this._getDimension();this._element.style[s]=`${this._element.getBoundingClientRect()[s]}px`,n(this._element),this._element.classList.add(m),this._element.classList.remove(d,_);for(const e of this._triggerArray){const s=t.getElementFromSelector(e);s&&!this._isShown(s)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0;this._element.style[s]="",this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(m),this._element.classList.add(d),e.trigger(this._element,g)}),this._element,!0)}_isShown(e=this._element){return e.classList.contains(_)}_configAfterMerge(e){return e.toggle=Boolean(e.toggle),e.parent=l(e.parent),e}_getDimension(){return this._element.classList.contains("collapse-horizontal")?"width":"height"}_initializeChildren(){if(!this._config.parent)return;const e=this._getFirstLevelChildren(p);for(const s of e){const e=t.getElementFromSelector(s);e&&this._addAriaAndCollapsedClass([s],this._isShown(e))}}_getFirstLevelChildren(e){const s=t.find(f,this._config.parent);return t.find(e,this._config.parent).filter((e=>!s.includes(e)))}_addAriaAndCollapsedClass(e,t){if(e.length)for(const s of e)s.classList.toggle("collapsed",!t),s.setAttribute("aria-expanded",t)}static jQueryInterface(e){const t={};return"string"==typeof e&&/show|hide/.test(e)&&(t.toggle=!1),this.each((function(){const s=A.getOrCreateInstance(this,t);if("string"==typeof e){if(void 0===s[e])throw new TypeError(`No method named "${e}"`);s[e]()}}))}}e.on(document,c,p,(function(e){("A"===e.target.tagName||e.delegateTarget&&"A"===e.delegateTarget.tagName)&&e.preventDefault();for(const e of t.getMultipleElementsFromSelector(this))A.getOrCreateInstance(e,{toggle:!1}).toggle()})),s(A);export{A as C};
