import{c as isRTL,d as defineJQueryPlugin,B as BaseComponent,E as EventHandler,o as findShadowRoot,n as noop,p as getUID,T as TemplateFactory,M as Manipulator,h as getElement,D as DefaultAllowlist}from"./dom.min.js?5.2.3";import{P as Popper,c as createPopper}from"./popper.min.js?5.2.3";const NAME$1="tooltip",DISALLOWED_ATTRIBUTES=new Set(["sanitize","allowList","sanitizeFn"]),CLASS_NAME_FADE="fade",CLASS_NAME_MODAL="modal",CLASS_NAME_SHOW="show",SELECTOR_TOOLTIP_INNER=".tooltip-inner",SELECTOR_MODAL=".modal",EVENT_MODAL_HIDE="hide.bs.modal",TRIGGER_HOVER="hover",TRIGGER_FOCUS="focus",TRIGGER_CLICK="click",TRIGGER_MANUAL="manual",EVENT_HIDE="hide",EVENT_HIDDEN="hidden",EVENT_SHOW="show",EVENT_SHOWN="shown",EVENT_INSERTED="inserted",EVENT_CLICK="click",EVENT_FOCUSIN="focusin",EVENT_FOCUSOUT="focusout",EVENT_MOUSEENTER="mouseenter",EVENT_MOUSELEAVE="mouseleave",AttachmentMap={AUTO:"auto",TOP:"top",RIGHT:isRTL()?"left":"right",BOTTOM:"bottom",LEFT:isRTL()?"right":"left"},Default$1={allowList:DefaultAllowlist,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,0],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'',title:"",trigger:"hover focus"},DefaultType$1={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class Tooltip extends BaseComponent{constructor(t,e){if(void 0===Popper)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(t,e),this._isEnabled=!0,this._timeout=0,this._isHovered=null,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners(),this._config.selector||this._fixTitle()}static get Default(){return Default$1}static get DefaultType(){return DefaultType$1}static get NAME(){return NAME$1}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(){this._isEnabled&&(this._activeTrigger.click=!this._activeTrigger.click,this._isShown()?this._leave():this._enter())}dispose(){clearTimeout(this._timeout),EventHandler.off(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler),this._element.getAttribute("data-bs-original-title")&&this._element.setAttribute("title",this._element.getAttribute("data-bs-original-title")),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const t=EventHandler.trigger(this._element,this.constructor.eventName("show")),e=(findShadowRoot(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(t.defaultPrevented||!e)return;this._disposePopper();const i=this._getTipElement();this._element.setAttribute("aria-describedby",i.getAttribute("id"));const{container:o}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(o.append(i),EventHandler.trigger(this._element,this.constructor.eventName("inserted"))),this._popper=this._createPopper(i),i.classList.add("show"),"ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))EventHandler.on(t,"mouseover",noop);this._queueCallback((()=>{EventHandler.trigger(this._element,this.constructor.eventName("shown")),!1===this._isHovered&&this._leave(),this._isHovered=!1}),this.tip,this._isAnimated())}hide(){if(!this._isShown())return;if(EventHandler.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented)return;if(this._getTipElement().classList.remove("show"),"ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))EventHandler.off(t,"mouseover",noop);this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this._isHovered=null;this._queueCallback((()=>{this._isWithActiveTrigger()||(this._isHovered||this._disposePopper(),this._element.removeAttribute("aria-describedby"),EventHandler.trigger(this._element,this.constructor.eventName("hidden")))}),this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(t){const e=this._getTemplateFactory(t).toHtml();if(!e)return null;e.classList.remove("fade","show"),e.classList.add(`bs-${this.constructor.NAME}-auto`);const i=getUID(this.constructor.NAME).toString();return e.setAttribute("id",i),this._isAnimated()&&e.classList.add("fade"),e}setContent(t){this._newContent=t,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(t){return this._templateFactory?this._templateFactory.changeContent(t):this._templateFactory=new TemplateFactory({...this._config,content:t,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{".tooltip-inner":this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._element.getAttribute("data-bs-original-title")}_initializeOnDelegatedTarget(t){return this.constructor.getOrCreateInstance(t.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains("fade")}_isShown(){return this.tip&&this.tip.classList.contains("show")}_createPopper(t){const e="function"==typeof this._config.placement?this._config.placement.call(this,t,this._element):this._config.placement,i=AttachmentMap[e.toUpperCase()];return createPopper(this._element,t,this._getPopperConfig(i))}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map((t=>Number.parseInt(t,10))):"function"==typeof t?e=>t(e,this._element):t}_resolvePossibleFunction(t){return"function"==typeof t?t.call(this._element):t}_getPopperConfig(t){const e={placement:t,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:t=>{this._getTipElement().setAttribute("data-popper-placement",t.state.placement)}}]};return{...e,..."function"==typeof this._config.popperConfig?this._config.popperConfig(e):this._config.popperConfig}}_setListeners(){const t=this._config.trigger.split(" ");for(const e of t)if("click"===e)EventHandler.on(this._element,this.constructor.eventName("click"),this._config.selector,(t=>{this._initializeOnDelegatedTarget(t).toggle()}));else if("manual"!==e){const t="hover"===e?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),i="hover"===e?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");EventHandler.on(this._element,t,this._config.selector,(t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusin"===t.type?"focus":"hover"]=!0,e._enter()})),EventHandler.on(this._element,i,this._config.selector,(t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusout"===t.type?"focus":"hover"]=e._element.contains(t.relatedTarget),e._leave()}))}this._hideModalHandler=()=>{this._element&&this.hide()},EventHandler.on(this._element.closest(".modal"),"hide.bs.modal",this._hideModalHandler)}_fixTitle(){const t=this._element.getAttribute("title");t&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",t),this._element.setAttribute("data-bs-original-title",t),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout((()=>{this._isHovered&&this.show()}),this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout((()=>{this._isHovered||this.hide()}),this._config.delay.hide))}_setTimeout(t,e){clearTimeout(this._timeout),this._timeout=setTimeout(t,e)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(t){const e=Manipulator.getDataAttributes(this._element);for(const t of Object.keys(e))DISALLOWED_ATTRIBUTES.has(t)&&delete e[t];return t={...e,..."object"==typeof t&&t?t:{}},t=this._mergeConfigObj(t),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}_configAfterMerge(t){return t.container=!1===t.container?document.body:getElement(t.container),"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),t}_getDelegateConfig(){const t={};for(const e in this._config)this.constructor.Default[e]!==this._config[e]&&(t[e]=this._config[e]);return t.selector=!1,t.trigger="manual",t}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null),this.tip&&(this.tip.remove(),this.tip=null)}static jQueryInterface(t){return this.each((function(){const e=Tooltip.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}defineJQueryPlugin(Tooltip);const NAME="popover",SELECTOR_TITLE=".popover-header",SELECTOR_CONTENT=".popover-body",Default={...Tooltip.Default,content:"",offset:[0,8],placement:"right",template:'',trigger:"click"},DefaultType={...Tooltip.DefaultType,content:"(null|string|element|function)"};class Popover extends Tooltip{static get Default(){return Default}static get DefaultType(){return DefaultType}static get NAME(){return NAME}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{[SELECTOR_TITLE]:this._getTitle(),".popover-body":this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(t){return this.each((function(){const e=Popover.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}if(defineJQueryPlugin(Popover),window.bootstrap=window.bootstrap||{},window.bootstrap.Popover=Popover,window.bootstrap.Tooltip=Tooltip,Joomla&&Joomla.getOptions){const t=Joomla.getOptions("bootstrap.tooltip"),e=Joomla.getOptions("bootstrap.popover");"object"==typeof e&&null!==e&&Object.keys(e).forEach((t=>{const i=e[t],o={animation:!i.animation||i.animation,container:!!i.container&&i.container,delay:i.delay?i.delay:0,html:!!i.html&&i.html,placement:i.placement?i.placement:"top",selector:!!i.selector&&i.selector,title:i.title?i.title:"",trigger:i.trigger?i.trigger:"click",offset:i.offset?i.offset:0,fallbackPlacement:i.fallbackPlacement?i.fallbackPlacement:"flip",boundary:i.boundary?i.boundary:"scrollParent",customClass:i.customClass?i.customClass:"",sanitize:!i.sanitize||i.sanitize,sanitizeFn:i.sanitizeFn?i.sanitizeFn:null,popperConfig:i.popperConfig?i.popperConfig:null};i.content&&(o.content=i.content),i.template&&(o.template=i.template),i.allowList&&(o.allowList=i.allowList);const n=Array.from(document.querySelectorAll(t));n.length&&n.map((t=>new window.bootstrap.Popover(t,o)))})),"object"==typeof t&&null!==t&&Object.keys(t).forEach((e=>{const i=t[e],o={animation:!i.animation||i.animation,container:!!i.container&&i.container,delay:i.delay?i.delay:0,html:!!i.html&&i.html,selector:!!i.selector&&i.selector,trigger:i.trigger?i.trigger:"hover focus",fallbackPlacement:i.fallbackPlacement?i.fallbackPlacement:null,boundary:i.boundary?i.boundary:"clippingParents",title:i.title?i.title:"",customClass:i.customClass?i.customClass:"",sanitize:!i.sanitize||i.sanitize,sanitizeFn:i.sanitizeFn?i.sanitizeFn:null,popperConfig:i.popperConfig?i.popperConfig:null};i.placement&&(o.placement=i.placement),i.template&&(o.template=i.template),i.allowList&&(o.allowList=i.allowList);const n=Array.from(document.querySelectorAll(e));n.length&&n.map((t=>new window.bootstrap.Tooltip(t,o)))}))}export{Popover as P};