import{E as o,S as r,f as b,i as g,e as w,d as A,B as k,k as l,l as S,F as v}from"./dom.min.js?5.3.2";const N="offcanvas",T="bs.offcanvas",n=`.${T}`,h=".data-api",D=`load${n}${h}`,O="Escape",d="show",_="showing",f="hiding",C="offcanvas-backdrop",u=".offcanvas.show",y=`show${n}`,I=`shown${n}`,L=`hide${n}`,E=`hidePrevented${n}`,p=`hidden${n}`,V=`resize${n}`,$=`click${n}${h}`,P=`keydown.dismiss${n}`,H='[data-bs-toggle="offcanvas"]',B={backdrop:!0,keyboard:!0,scroll:!1},K={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class i extends k{constructor(t,e){super(t,e),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return B}static get DefaultType(){return K}static get NAME(){return N}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){if(this._isShown||o.trigger(this._element,y,{relatedTarget:t}).defaultPrevented)return;this._isShown=!0,this._backdrop.show(),this._config.scroll||new l().hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(_);const a=()=>{(!this._config.scroll||this._config.backdrop)&&this._focustrap.activate(),this._element.classList.add(d),this._element.classList.remove(_),o.trigger(this._element,I,{relatedTarget:t})};this._queueCallback(a,this._element,!0)}hide(){if(!this._isShown||o.trigger(this._element,L).defaultPrevented)return;this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add(f),this._backdrop.hide();const e=()=>{this._element.classList.remove(d,f),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||new l().reset(),o.trigger(this._element,p)};this._queueCallback(e,this._element,!0)}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const t=()=>{if(this._config.backdrop==="static"){o.trigger(this._element,E);return}this.hide()},e=!!this._config.backdrop;return new S({className:C,isVisible:e,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:e?t:null})}_initializeFocusTrap(){return new v({trapElement:this._element})}_addEventListeners(){o.on(this._element,P,t=>{if(t.key===O){if(this._config.keyboard){this.hide();return}o.trigger(this._element,E)}})}static jQueryInterface(t){return this.each(function(){const e=i.getOrCreateInstance(this,t);if(typeof t=="string"){if(e[t]===void 0||t.startsWith("_")||t==="constructor")throw new TypeError(`No method named "${t}"`);e[t](this)}})}}if(o.on(document,$,H,function(s){const t=r.getElementFromSelector(this);if(["A","AREA"].includes(this.tagName)&&s.preventDefault(),b(this))return;o.one(t,p,()=>{g(this)&&this.focus()});const e=r.findOne(u);e&&e!==t&&i.getInstance(e).hide(),i.getOrCreateInstance(t).toggle(this)}),o.on(window,D,()=>{for(const s of r.find(u))i.getOrCreateInstance(s).show()}),o.on(window,V,()=>{for(const s of r.find("[aria-modal][class*=show][class*=offcanvas-]"))getComputedStyle(s).position!=="fixed"&&i.getOrCreateInstance(s).hide()}),w(i),A(i),window.bootstrap=window.bootstrap||{},window.bootstrap.Offcanvas=i,Joomla&&Joomla.getOptions){const s=Joomla.getOptions("bootstrap.offcanvas");typeof s=="object"&&s!==null&&Object.keys(s).forEach(t=>{const e=s[t],a={backdrop:e.backdrop?e.backdrop:!0,keyboard:e.keyboard?e.keyboard:!0,scroll:e.scroll?e.scroll:!0},c=Array.from(document.querySelectorAll(t));c.length&&c.map(m=>new window.bootstrap.Offcanvas(m,a))})}export{i as O};
