From d35042719b56aab9517603a418d36f491139c470 Mon Sep 17 00:00:00 2001 From: thednp Date: Thu, 3 Feb 2022 17:28:44 +0200 Subject: [PATCH] V4.1.0alpha4 Changes: * added the new EventListener to all V5 components * code clean-up * version bump --- dist/bootstrap-native-v4-esm.js | 4 +- dist/bootstrap-native-v4-esm.min.js | 4 +- dist/bootstrap-native-v4.js | 4 +- dist/bootstrap-native-v4.min.js | 4 +- dist/bootstrap-native.esm.js | 194 +++++++++++++++++++----- dist/bootstrap-native.esm.min.js | 4 +- dist/bootstrap-native.js | 194 +++++++++++++++++++----- dist/bootstrap-native.min.js | 4 +- dist/components/alert-native.esm.js | 121 ++++++++++++++- dist/components/alert-native.js | 121 ++++++++++++++- dist/components/button-native.esm.js | 121 ++++++++++++--- dist/components/button-native.js | 121 ++++++++++++--- dist/components/carousel-native.esm.js | 174 +++++++++++++++++---- dist/components/carousel-native.js | 174 +++++++++++++++++---- dist/components/collapse-native.esm.js | 121 ++++++++++++++- dist/components/collapse-native.js | 121 ++++++++++++++- dist/components/dropdown-native.esm.js | 139 +++++++++++++---- dist/components/dropdown-native.js | 139 +++++++++++++---- dist/components/modal-native.esm.js | 169 +++++++++++++++++---- dist/components/modal-native.js | 169 +++++++++++++++++---- dist/components/offcanvas-native.esm.js | 169 +++++++++++++++++---- dist/components/offcanvas-native.js | 169 +++++++++++++++++---- dist/components/popover-native.esm.js | 187 ++++++++++++++++++----- dist/components/popover-native.js | 187 ++++++++++++++++++----- dist/components/scrollspy-native.esm.js | 139 +++++++++++++---- dist/components/scrollspy-native.js | 139 +++++++++++++---- dist/components/tab-native.esm.js | 169 +++++++++++++++++---- dist/components/tab-native.js | 169 +++++++++++++++++---- dist/components/toast-native.esm.js | 169 +++++++++++++++++---- dist/components/toast-native.js | 169 +++++++++++++++++---- dist/components/tooltip-native.esm.js | 187 ++++++++++++++++++----- dist/components/tooltip-native.js | 187 ++++++++++++++++++----- package.json | 5 +- rollup.config.js | 2 +- rollup.module.js | 2 +- src/components/alert-native.js | 6 +- src/components/button-native.js | 6 +- src/components/carousel-native.js | 12 +- src/components/collapse-native.js | 7 +- src/components/dropdown-native.js | 7 +- src/components/modal-native.js | 7 +- src/components/offcanvas-native.js | 7 +- src/components/scrollspy-native.js | 7 +- src/components/tab-native.js | 7 +- src/components/toast-native.js | 7 +- src/components/tooltip-native.js | 7 +- types/index.d.ts | 1 + 47 files changed, 3496 insertions(+), 736 deletions(-) diff --git a/dist/bootstrap-native-v4-esm.js b/dist/bootstrap-native-v4-esm.js index bf316369..78af2ba2 100644 --- a/dist/bootstrap-native-v4-esm.js +++ b/dist/bootstrap-native-v4-esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -2579,7 +2579,7 @@ function removeDataAPI(context) { }); } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; var Version = version; diff --git a/dist/bootstrap-native-v4-esm.min.js b/dist/bootstrap-native-v4-esm.min.js index b86efcb2..cb7e491b 100644 --- a/dist/bootstrap-native-v4-esm.min.js +++ b/dist/bootstrap-native-v4-esm.min.js @@ -1,2 +1,2 @@ -// Native JavaScript for Bootstrap v4.1.0alpha3 | 2022 © dnp_theme | MIT-License -var t=document.head,e="webkitTransition"in t.style||"transition"in t.style,i="webkitTransition"in t.style?"webkitTransitionEnd":"transitionend",n="webkitTransition"in t.style?"webkitTransitionDelay":"transitionDelay",a="webkitTransition"in t.style?"webkitTransitionProperty":"transitionProperty";function o(t,e){var i=getComputedStyle(t);return e in i?i[e]:""}var s="webkitTransition"in t.style?"webkitTransitionDuration":"transitionDuration";function l(t){var i=o(t,a),n=o(t,s),l=n.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(n)*l:0;return Number.isNaN(r)?0:r}function r(t,s){var r=0,c=new Event(i),d=l(t),u=function(t){var i=o(t,a),s=o(t,n),l=s.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(s)*l:0;return Number.isNaN(r)?0:r}(t);if(e&&d){var m=function(e){e.target===t&&(s.apply(t,[e]),t.removeEventListener(i,m),r=1)};t.addEventListener(i,m),setTimeout((function(){r||t.dispatchEvent(c)}),d+u+17)}else s.apply(t,[c])}function c(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}var d=[Document,Node,Element,HTMLElement],u=[Element,HTMLElement];function m(t,e){var i="string"==typeof t,n=e&&d.some((function(t){return e instanceof t}))?e:c();return!i&&u.some((function(e){return t instanceof e}))?t:i?n.querySelector(t):null}function f(t,e,i){var n=new CustomEvent(t+".bs."+e,{cancelable:!0});return void 0!==i&&Object.keys(i).forEach((function(t){Object.defineProperty(n,t,{value:i[t]})})),n}function h(t){this&&this.dispatchEvent(t)}function g(t){var e,i,n=this,a=f("close","alert"),o=f("closed","alert");function s(t){e[t?"addEventListener":"removeEventListener"]("click",l,!1)}function l(t){i=t&&t.target.closest(".alert"),(e=m('[data-dismiss="alert"]',i))&&i&&(e===t.target||e.contains(t.target))&&n.close()}function c(){s(),i.parentNode.removeChild(i),h.call(i,o)}n.close=function(){if(i&&e&&i.classList.contains("show")){if(h.call(i,a),a.defaultPrevented)return;n.dispose(),i.classList.remove("show"),i.classList.contains("fade")?r(i,c):c()}},n.dispose=function(){s(),delete e.Alert},e=m(t),i=e.closest(".alert"),e.Alert&&e.Alert.dispose(),e.Alert||s(1),n.element=e,e.Alert=n}function p(t){var e,i,n=f("change","button");function a(t){var a=t.target,o=a.closest("LABEL"),s=null;"LABEL"===a.tagName?s=a:o&&(s=o);var l=s&&s.getElementsByTagName("INPUT")[0];if(l){if(h.call(l,n),h.call(e,n),"checkbox"===l.type){if(n.defaultPrevented)return;l.checked?(s.classList.remove("active"),l.getAttribute("checked"),l.removeAttribute("checked"),l.checked=!1):(s.classList.add("active"),l.getAttribute("checked"),l.setAttribute("checked","checked"),l.checked=!0),e.toggled||(e.toggled=!0)}if("radio"===l.type&&!e.toggled){if(n.defaultPrevented)return;(!l.checked||0===t.screenX&&0===t.screenY)&&(s.classList.add("active"),s.classList.add("focus"),l.setAttribute("checked","checked"),l.checked=!0,e.toggled=!0,Array.from(i).forEach((function(t){var e=t.getElementsByTagName("INPUT")[0];t!==s&&t.classList.contains("active")&&(h.call(e,n),t.classList.remove("active"),e.removeAttribute("checked"),e.checked=!1)})))}setTimeout((function(){e.toggled=!1}),50)}}function o(t){32===(t.which||t.keyCode)&&t.target===document.activeElement&&a(t)}function s(t){32===(t.which||t.keyCode)&&t.preventDefault()}function l(t){if("INPUT"===t.target.tagName){var e="focusin"===t.type?"add":"remove";t.target.closest(".btn").classList[e]("focus")}}function r(t){var i=t?"addEventListener":"removeEventListener";e[i]("click",a,!1),e[i]("keyup",o,!1),e[i]("keydown",s,!1),e[i]("focusin",l,!1),e[i]("focusout",l,!1)}this.dispose=function(){r(),delete e.Button},(e=m(t)).Button&&e.Button.dispose(),(i=e.getElementsByClassName("btn")).length&&(e.Button||r(1),e.toggled=!1,e.Button=this,Array.from(i).forEach((function(t){var e=m("input:checked",t);!t.classList.contains("active")&&e&&t.classList.add("active"),t.classList.contains("active")&&!e&&t.classList.remove("active")})))}var v="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],L={passive:!0};var b=function(t){var e=function(t,e){var i=t.getBoundingClientRect(),n=i.width,a=i.height,o=i.top,s=i.right,l=i.bottom,r=i.left,c=1,d=1;if(e&&t instanceof HTMLElement){var u=t.offsetWidth,m=t.offsetHeight;c=u>0&&Math.round(n)/u||1,d=m>0&&Math.round(a)/m||1}return{width:n/c,height:a/d,top:o/d,right:s/c,bottom:l/d,left:r/c,x:r/c,y:o/d}}(t),i=e.top,n=e.bottom;return i<=c(t).documentElement.clientHeight&&n>=0},y=function(t){return t.offsetHeight};function w(t,e){var i,n,a,o,s,c,d,u,g,p,w,A,T,E=e||{},k=this;function x(){!1===c.interval||o.classList.contains("paused")||(o.classList.add("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null))}function N(){!1!==c.interval&&o.classList.contains("paused")&&(o.classList.remove("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null,k.cycle()))}function C(t){if(t.preventDefault(),!s.isSliding){var e=t.target;e&&!e.classList.contains("active")&&e.getAttribute("data-slide-to")&&(s.index=+e.getAttribute("data-slide-to"),k.slideTo(s.index))}}function P(t){if(t.preventDefault(),!s.isSliding){var e=t.currentTarget||t.srcElement;e===w?s.index+=1:e===p&&(s.index-=1),k.slideTo(s.index)}}function H(t){var e=t.which;if(!s.isSliding){switch(e){case 39:s.index+=1;break;case 37:s.index-=1;break;default:return}k.slideTo(s.index)}}function M(t){var e=t?"addEventListener":"removeEventListener";c.pause&&c.interval&&(o[e](v[0],x,!1),o[e](v[1],N,!1),o[e]("touchstart",x,L),o[e]("touchend",N,L)),c.touch&&g.length>1&&o[e]("touchstart",B,L),w&&w[e]("click",P,!1),p&&p[e]("click",P,!1),A&&A[e]("click",C,!1),c.keyboard&&window[e]("keydown",H,!1)}function S(t){var e=t?"addEventListener":"removeEventListener";o[e]("touchmove",I,L),o[e]("touchend",D,L)}function B(t){s.isTouch||(s.touchPosition.startX=t.changedTouches[0].pageX,o.contains(t.target)&&(s.isTouch=!0,S(1)))}function I(t){s.isTouch?(s.touchPosition.currentX=t.changedTouches[0].pageX,"touchmove"===t.type&&t.changedTouches.length>1&&t.preventDefault()):t.preventDefault()}function D(t){if(s.isTouch&&!s.isSliding&&(s.touchPosition.endX=s.touchPosition.currentX||t.changedTouches[0].pageX,s.isTouch)){if((!o.contains(t.target)||!o.contains(t.relatedTarget))&&Math.abs(s.touchPosition.startX-s.touchPosition.endX)<75)return;s.touchPosition.currentXs.touchPosition.startX&&(s.index-=1),s.isTouch=!1,k.slideTo(s.index),S()}}function X(t){Array.from(T).forEach((function(t){return t.classList.remove("active")})),T[t]&&T[t].classList.add("active")}function R(t){if(s.touchPosition){var e=s.index,i=t&&t.target!==g[e]?1e3*t.elapsedTime+100:20,n=k.getActiveIndex(),a="left"===s.direction?"next":"prev";s.isSliding&&setTimeout((function(){s.touchPosition&&(s.isSliding=!1,g[e].classList.add("active"),g[n].classList.remove("active"),g[e].classList.remove("carousel-item-"+a),g[e].classList.remove("carousel-item-"+s.direction),g[n].classList.remove("carousel-item-"+s.direction),h.call(o,u),document.hidden||!c.interval||o.classList.contains("paused")||k.cycle())}),i)}}if(k.cycle=function(){s.timer&&(clearInterval(s.timer),s.timer=null),s.timer=setInterval((function(){var t=s.index||k.getActiveIndex();b(o)&&(t+=1,k.slideTo(t))}),c.interval)},k.slideTo=function(t){if(!s.isSliding){var e=k.getActiveIndex(),i=t;if(e!==i){ei||e===g.length-1&&0===i)&&(s.direction="right"),i<0?i=g.length-1:i>=g.length&&(i=0);var n="left"===s.direction?"next":"prev",a={relatedTarget:g[i],direction:s.direction,from:e,to:i};d=f("slide","carousel",a),u=f("slid","carousel",a),h.call(o,d),d.defaultPrevented||(s.index=i,s.isSliding=!0,clearInterval(s.timer),s.timer=null,X(i),l(g[i])&&o.classList.contains("slide")?(g[i].classList.add("carousel-item-"+n),y(g[i]),g[i].classList.add("carousel-item-"+s.direction),g[e].classList.add("carousel-item-"+s.direction),r(g[i],R)):(g[i].classList.add("active"),y(g[i]),g[e].classList.remove("active"),setTimeout((function(){s.isSliding=!1,c.interval&&o&&!o.classList.contains("paused")&&k.cycle(),h.call(o,u)}),100)))}}},k.getActiveIndex=function(){return Array.from(g).indexOf(o.getElementsByClassName("carousel-item active")[0])||0},k.dispose=function(){var t=["left","right","prev","next"];Array.from(g).forEach((function(e,i){e.classList.contains("active")&&X(i),t.forEach((function(t){return e.classList.remove("carousel-item-"+t)}))})),clearInterval(s.timer),M(),s={},c={},delete o.Carousel},(o=m(t)).Carousel&&o.Carousel.dispose(),g=o.getElementsByClassName("carousel-item"),i=o.getElementsByClassName("carousel-control-prev"),p=i[0],n=o.getElementsByClassName("carousel-control-next"),w=n[0],a=o.getElementsByClassName("carousel-indicators"),A=a[0],T=A&&A.getElementsByTagName("LI")||[],!(g.length<2)){var W=o.getAttribute("data-interval"),O="false"===W?0:+W,j="false"===o.getAttribute("data-touch")?0:1,z="hover"===o.getAttribute("data-pause")||!1,U="true"===o.getAttribute("data-keyboard")||!1,q=E.interval,F=E.touch;(c={}).keyboard=!0===E.keyboard||U,c.pause=!("hover"!==E.pause&&!z)&&"hover",c.touch=F||j,c.interval=5e3,"number"==typeof q?c.interval=q:!1===q||0===O||!1===O?c.interval=0:Number.isNaN(O)||(c.interval=O),k.getActiveIndex()<0&&(g.length&&g[0].classList.add("active"),T.length&&X(0)),(s={}).direction="left",s.index=0,s.timer=null,s.isSliding=!1,s.isTouch=!1,s.touchPosition={startX:0,currentX:0,endX:0},M(1),c.interval&&k.cycle(),o.Carousel=k}}function A(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=null;function v(t,e){h.call(t,l),l.defaultPrevented||(t.isAnimating=!0,t.style.height=t.scrollHeight+"px",t.classList.remove("collapse"),t.classList.remove("show"),t.classList.add("collapsing"),y(t),t.style.height="0px",r(t,(function(){t.isAnimating=!1,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),t.classList.remove("collapsing"),t.classList.add("collapse"),t.style.height="",h.call(t,c)})))}u.toggle=function(t){(t&&"A"===t.target.tagName||"A"===i.tagName)&&t.preventDefault(),(i.contains(t.target)||t.target===i)&&(p.classList.contains("show")?u.hide():u.show())},u.hide=function(){p.isAnimating||(v(p,i),i.classList.add("collapsed"))},u.show=function(){var t,e,l;g&&(t=g.getElementsByClassName("collapse show"),n=t[0],a=n&&(m('[data-target="#'+n.id+'"]',g)||m('[href="#'+n.id+'"]',g))),p.isAnimating||(a&&n!==p&&(v(n,a),a.classList.add("collapsed")),e=p,l=i,h.call(e,o),o.defaultPrevented||(e.isAnimating=!0,e.classList.add("collapsing"),e.classList.remove("collapse"),e.style.height=e.scrollHeight+"px",r(e,(function(){e.isAnimating=!1,e.setAttribute("aria-expanded","true"),l.setAttribute("aria-expanded","true"),e.classList.remove("collapsing"),e.classList.add("collapse"),e.classList.add("show"),e.style.height="",h.call(e,s)}))),i.classList.remove("collapsed"))},u.dispose=function(){i.removeEventListener("click",u.toggle,!1),delete i.Collapse},(i=m(t)).Collapse&&i.Collapse.dispose();var L=i.getAttribute("data-parent");o=f("show","collapse"),s=f("shown","collapse"),l=f("hide","collapse"),c=f("hidden","collapse"),null!==(p=m(d.target||i.getAttribute("data-target")||i.getAttribute("href")))&&(p.isAnimating=!1);var b=d.parent||L;g=b?i.closest(b):null,i.Collapse||i.addEventListener("click",u.toggle,!1),i.Collapse=u}var T=function(t){return t.focus()};function E(t,e){var i,n,a,o,s,l,r,c,d=this,u=null,g=[];function p(t){(t.hasAttribute("href")&&"#"===t.href.slice(-1)||t.parentNode&&t.parentNode.hasAttribute("href")&&"#"===t.parentNode.href.slice(-1))&&this.preventDefault()}function v(){var t=i.open?"addEventListener":"removeEventListener";document[t]("click",L,!1),document[t]("keydown",y,!1),document[t]("keyup",w,!1),document[t]("focus",L,!1)}function L(t){var e=t.target;if(e.getAttribute){var n=e&&e.getAttribute("data-toggle")||e.parentNode&&e.parentNode.getAttribute&&e.parentNode.getAttribute("data-toggle");("focus"!==t.type||e!==i&&e!==r&&!r.contains(e))&&(e!==r&&!r.contains(e)||!c&&!n)&&(u=e===i||i.contains(e)?i:null,d.hide(),p.call(t,e))}}function b(t){u=i,d.show(),p.call(t,t.target)}function y(t){var e=t.which||t.keyCode;38!==e&&40!==e||t.preventDefault()}function w(t){var e=t.which||t.keyCode,n=document.activeElement,a=n===i,o=r.contains(n),s=n.parentNode===r||n.parentNode.parentNode===r,l=g.indexOf(n);s&&(a?l=0:38===e?l=l>1?l-1:0:40===e&&(l=l=d,w=m.top+c/2+g/2>=u,A=m.top-c<0,T=m.left-r<0,E=m.top+c+g>=u,k=m.left+r+h>=d,x=i;x="right"===(x="left"===(x="bottom"===(x="top"===(x=("left"===x||"right"===x)&&T&&k?"top":x)&&A?"bottom":x)&&E?"top":x)&&T?"right":x)&&k?"left":x,-1===e.className.indexOf(x)&&(e.className=e.className.replace(/\b(top|bottom|left|right)+/,x));var C=v.offsetWidth,P=v.offsetHeight;"left"===x||"right"===x?(o="left"===x?m.left+f.x-r-(p?C:0):m.left+f.x+h,L?(a=m.top+f.y,s=g/2-C):w?(a=m.top+f.y-c+g,s=c-g/2-C):(a=m.top+f.y-c/2+g/2,s=c/2-(p?.9*P:P/2))):"top"!==x&&"bottom"!==x||(a="top"===x?m.top+f.y-c-(p?P:0):m.top+f.y+g,b?(o=0,l=m.left+h/2-C):y?(o=d-1.01*r,l=r-(d-m.left)+h/2-C/2):(o=m.left+f.x-r/2+h/2,l=r/2-(p?C:C/2))),e.style.top=a+"px",e.style.left=o+"px",s&&(v.style.top=s+"px"),l&&(v.style.left=l+"px")}function P(t,e){var i,n,a,o,s,l,c,d,u,g=e||{},p=this,b=null,y=0,w=/(iPhone|iPod|iPad)/.test(navigator.userAgent),A={};function T(t){null!==b&&t.target===m(".close",b)&&p.hide()}function E(t){return g[t]||i.dataset[t]||null}function k(){return E("title")}function N(){return E("content")}function P(){null===b&&i.focus()}function H(t){var e=t?"addEventListener":"removeEventListener";"hover"===A.trigger?(i[e](x,p.show),i[e](v[0],p.show),A.dismissible||i[e](v[1],p.hide)):"click"===A.trigger?i[e](A.trigger,p.toggle):"focus"===A.trigger&&(w&&i[e]("click",P,!1),i[e](A.trigger,p.toggle))}function M(t){b&&b.contains(t.target)||t.target===i||i.contains(t.target)||p.hide()}function S(t){var e=t?"addEventListener":"removeEventListener";A.dismissible?document[e]("click",T,!1):("focus"===A.trigger&&i[e]("blur",p.hide),"hover"===A.trigger&&document[e]("touchstart",M,L)),window[e]("resize",p.hide,L)}function B(){S(1),h.call(i,c)}function I(){S(),A.container.removeChild(b),y=null,b=null,h.call(i,u)}p.toggle=function(){null===b?p.show():p.hide()},p.show=function(){clearTimeout(y),y=setTimeout((function(){if(null===b){if(h.call(i,l),l.defaultPrevented)return;!function(){n=k(),a=(a=N())?a.trim():null,b=document.createElement("div");var t=document.createElement("div");if(t.classList.add("arrow"),b.appendChild(t),null!==a&&null===A.template){if(b.setAttribute("role","tooltip"),null!==n){var e=document.createElement("h3");e.classList.add("popover-header"),e.innerHTML=A.dismissible?n+s:n,b.appendChild(e)}var i=document.createElement("div");i.classList.add("popover-body"),i.innerHTML=A.dismissible&&null===n?a+s:a,b.appendChild(i)}else{var l=document.createElement("div");l.innerHTML=A.template.trim(),b.className=l.firstChild.className,b.innerHTML=l.firstChild.innerHTML;var r=m(".popover-header",b),c=m(".popover-body",b);n&&r&&(r.innerHTML=n.trim()),a&&c&&(c.innerHTML=a.trim())}A.container.appendChild(b),b.style.display="block",b.classList.contains("popover")||b.classList.add("popover"),b.classList.contains(A.animation)||b.classList.add(A.animation),b.classList.contains(o)||b.classList.add(o)}(),C(i,b,A.placement,A.container),b.classList.contains("show")||b.classList.add("show"),A.animation?r(b,B):B()}}),20)},p.hide=function(){clearTimeout(y),y=setTimeout((function(){if(b&&null!==b&&b.classList.contains("show")){if(h.call(i,d),d.defaultPrevented)return;b.classList.remove("show"),A.animation?r(b,I):I()}}),A.delay)},p.dispose=function(){p.hide(),H(),delete i.Popover},(i=m(t)).Popover&&i.Popover.dispose();var D=i.getAttribute("data-trigger"),X=i.getAttribute("data-animation"),R=i.getAttribute("data-placement"),W=i.getAttribute("data-dismissible"),O=i.getAttribute("data-delay"),j=i.getAttribute("data-container");s='',l=f("show","popover"),c=f("shown","popover"),d=f("hide","popover"),u=f("hidden","popover");var z=m(g.container),U=m(j),q=i.closest(".modal"),F=i.closest(".fixed-top"),Y=i.closest(".fixed-bottom");A.template=g.template?g.template:null,A.trigger=g.trigger?g.trigger:D||"hover",A.animation=g.animation&&"fade"!==g.animation?g.animation:X||"fade",A.placement=g.placement?g.placement:R||"top",A.delay=parseInt(g.delay||O,10)||200,A.dismissible=!(!g.dismissible&&"true"!==W),A.container=z||U||F||Y||q||document.body,o="bs-popover-"+A.placement,n=k(),((a=N())||A.template)&&(i.Popover||H(1),i.Popover=p)}function H(t,e){var i,n,a,o,s,l=e||{},r=this,c={};function d(){var t,e,s;(a=o.getElementsByTagName("A"),n.scrollTop=n.isWindow?N().y:i.scrollTop,n.length!==a.length||g()!==n.scrollHeight)&&(n.items=[],n.offsets=[],n.scrollHeight=g(),n.maxScroll=n.scrollHeight-(n.isWindow?window.innerHeight:i.getBoundingClientRect().height),Array.from(a).forEach((function(i){t=i.getAttribute("href"),(e=t&&"#"===t.charAt(0)&&"#"!==t.slice(-1)&&m(t))&&(n.items.push(i),s=e.getBoundingClientRect(),n.offsets.push((n.isWindow?s.top+n.scrollTop:e.offsetTop)-c.offset))})),n.length=n.items.length)}function u(t){var e=t?"addEventListener":"removeEventListener";s[e]("scroll",r.refresh,L),window[e]("resize",r.refresh,L)}function g(){return s.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}function p(){Array.from(a).map((function(t){return t.classList.contains("active")&&t.classList.remove("active")}))}function v(t){var e,a=t;p(),n.activeItem=a,a.classList.add("active");for(var o=[];a.parentNode!==document.body;)((e=(a=a.parentNode).classList).contains("dropdown-menu")||e.contains("nav"))&&o.push(a);o.forEach((function(t){var e=t.previousElementSibling;e&&!e.classList.contains("active")&&e.classList.add("active")})),h.call(i,f("activate","scrollspy",{relatedTarget:n.activeItem}))}r.refresh=function(){if(d(),n.scrollTop>=n.maxScroll){var t=n.items[n.length-1];n.activeItem!==t&&v(t)}else{if(n.activeItem&&n.scrollTop0)return n.activeItem=null,void p();for(var e=n.length;e>-1;)n.activeItem!==n.items[e]&&n.scrollTop>=n.offsets[e]&&(void 0===n.offsets[e+1]||n.scrollTop1&&(g=t[t.length-1]):g=t[0],g}function P(){return m(C().getAttribute("href"))}function H(t){t.preventDefault(),u=t.currentTarget,a.isAnimating||T.show()}T.show=function(){if(!(u=u||n).classList.contains("active")){if(v=m(u.getAttribute("href")),g=C(),p=P(),c=f("hide","tab",{relatedTarget:u}),h.call(g,c),c.defaultPrevented)return;a.isAnimating=!0,g.classList.remove("active"),g.setAttribute("aria-selected","false"),u.classList.add("active"),u.setAttribute("aria-selected","true"),o&&(n.parentNode.classList.contains("dropdown-menu")?o.classList.contains("active")||o.classList.add("active"):o.classList.contains("active")&&o.classList.remove("active")),p.classList.contains("fade")?(p.classList.remove("show"),r(p,N)):N()}},T.dispose=function(){n.removeEventListener("click",H,!1),delete n.Tab},(n=m(t)).Tab&&n.Tab.dispose();var M=n.getAttribute("data-height");a=n.closest(".nav"),o=a&&m(".dropdown-toggle",a);var S=!(!e||!1===A.height||"false"===M);a.isAnimating=!1,n.Tab||n.addEventListener("click",H,!1),S&&(E=P().parentNode),n.Tab=T}function S(t,e){var i,n,a,o,s,l,c=e||{},d=this,u=0,g={};function p(){n.classList.remove("showing"),n.classList.add("show"),h.call(n,s),g.autohide&&d.hide()}function v(){n.classList.add("hide"),h.call(n,l)}function L(){n.classList.remove("show"),g.animation?r(n,v):v()}function b(){clearTimeout(u),i.removeEventListener("click",d.hide,!1),delete i.Toast}d.show=function(){if(n&&!n.classList.contains("show")){if(h.call(n,a),a.defaultPrevented)return;g.animation&&n.classList.add("fade"),n.classList.remove("hide"),y(n),n.classList.add("showing"),g.animation?r(n,p):p()}},d.hide=function(t){if(n&&n.classList.contains("show")){if(h.call(n,o),o.defaultPrevented)return;t?L():u=setTimeout(L,g.delay)}},d.dispose=function(){g.animation?r(n,b):b()},(i=m(t)).Toast&&i.Toast.dispose(),n=i.closest(".toast");var w=i.getAttribute("data-animation"),A=i.getAttribute("data-autohide"),T=i.getAttribute("data-delay");a=f("show","toast"),o=f("hide","toast"),s=f("shown","toast"),l=f("hidden","toast"),g.animation=!1===c.animation||"false"===w?0:1,g.autohide=!1===c.autohide||"false"===A?0:1,g.delay=parseInt(c.delay||T,10)||500,i.Toast||i.addEventListener("click",d.hide,!1),i.Toast=d}function B(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=0,b={};function y(){return i.getAttribute("title")||i.getAttribute("data-title")||i.getAttribute("data-original-title")}function w(t){g&&g.contains(t.target)||t.target===i||i.contains(t.target)||u.hide()}function A(t){var e=t?"addEventListener":"removeEventListener";document[e]("touchstart",w,L),window[e]("resize",u.hide,L)}function T(){A(1),h.call(i,s)}function E(){A(),b.container.removeChild(g),g=null,p=null,h.call(i,c)}function k(t){var e=t?"addEventListener":"removeEventListener";i[e](x,u.show,!1),i[e](v[0],u.show,!1),i[e](v[1],u.hide,!1)}u.show=function(){clearTimeout(p),p=setTimeout((function(){if(null===g){if(h.call(i,o),o.defaultPrevented)return;!1!==function(){if(n=y()){if(g=document.createElement("div"),b.template){var t=document.createElement("div");t.innerHTML=b.template.trim(),g.className=t.firstChild.className,g.innerHTML=t.firstChild.innerHTML,m(".tooltip-inner",g).innerHTML=n.trim()}else{var e=document.createElement("div");e.classList.add("arrow"),g.appendChild(e);var i=document.createElement("div");i.classList.add("tooltip-inner"),g.appendChild(i),i.innerHTML=n}g.style.left="0",g.style.top="0",g.setAttribute("role","tooltip"),g.classList.contains("tooltip")||g.classList.add("tooltip"),g.classList.contains(b.animation)||g.classList.add(b.animation),g.classList.contains(a)||g.classList.add(a),b.container.appendChild(g)}}()&&(C(i,g,b.placement,b.container),g.classList.contains("show")||g.classList.add("show"),b.animation?r(g,T):T())}}),20)},u.hide=function(){clearTimeout(p),p=setTimeout((function(){if(g&&g.classList.contains("show")){if(h.call(i,l),l.defaultPrevented)return;g.classList.remove("show"),b.animation?r(g,E):E()}}),b.delay)},u.toggle=function(){g?u.hide():u.show()},u.dispose=function(){k(),u.hide(),i.setAttribute("title",i.getAttribute("data-original-title")),i.removeAttribute("data-original-title"),delete i.Tooltip},(i=m(t)).Tooltip&&i.Tooltip.dispose();var N=i.getAttribute("data-animation"),P=i.getAttribute("data-placement"),H=i.getAttribute("data-delay"),M=i.getAttribute("data-container"),S=m(d.container),B=m(M),I=i.closest(".modal");o=f("show","tooltip"),s=f("shown","tooltip"),l=f("hide","tooltip"),c=f("hidden","tooltip");var D=i.closest(".fixed-top"),X=i.closest(".fixed-bottom");b.animation=d.animation&&"fade"!==d.animation?d.animation:N||"fade",b.placement=d.placement?d.placement:P||"top",b.template=d.template?d.template:null,b.delay=parseInt(d.delay||H,10)||200,b.container=S||B||D||X||I||document.body,a="bs-tooltip-"+b.placement,(n=y())&&(i.Tooltip||(i.setAttribute("data-original-title",n),i.removeAttribute("title"),k(1)),i.Tooltip=u)}var I={};function D(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=I[t][0],n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return new i(t)}))}))}I.Alert=[g,'[data-dismiss="alert"]'],I.Button=[p,'[data-toggle="buttons"]'],I.Carousel=[w,'[data-ride="carousel"]'],I.Collapse=[A,'[data-toggle="collapse"]'],I.Dropdown=[E,'[data-toggle="dropdown"]'],I.Modal=[k,'[data-toggle="modal"]'],I.Popover=[P,'[data-toggle="popover"],[data-tip="popover"]'],I.ScrollSpy=[H,'[data-spy="scroll"]'],I.Tab=[M,'[data-toggle="tab"]'],I.Toast=[S,'[data-dismiss="toast"]'],I.Tooltip=[B,'[data-toggle="tooltip"],[data-tip="tooltip"]'],document.body?D():document.addEventListener("DOMContentLoaded",(function t(){D(),document.removeEventListener("DOMContentLoaded",t,!1)}),!1);var X={Alert:g,Button:p,Carousel:w,Collapse:A,Dropdown:E,Modal:k,Popover:P,ScrollSpy:H,Tab:M,Toast:S,Tooltip:B,initCallback:D,removeDataAPI:function(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=t,n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return t[i].dispose()}))}))},componentsInit:I,Version:"4.1.0alpha3"};export{X as default}; +// Native JavaScript for Bootstrap v4.1.0alpha4 | 2022 © dnp_theme | MIT-License +var t=document.head,e="webkitTransition"in t.style||"transition"in t.style,i="webkitTransition"in t.style?"webkitTransitionEnd":"transitionend",n="webkitTransition"in t.style?"webkitTransitionDelay":"transitionDelay",a="webkitTransition"in t.style?"webkitTransitionProperty":"transitionProperty";function o(t,e){var i=getComputedStyle(t);return e in i?i[e]:""}var s="webkitTransition"in t.style?"webkitTransitionDuration":"transitionDuration";function l(t){var i=o(t,a),n=o(t,s),l=n.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(n)*l:0;return Number.isNaN(r)?0:r}function r(t,s){var r=0,c=new Event(i),d=l(t),u=function(t){var i=o(t,a),s=o(t,n),l=s.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(s)*l:0;return Number.isNaN(r)?0:r}(t);if(e&&d){var m=function(e){e.target===t&&(s.apply(t,[e]),t.removeEventListener(i,m),r=1)};t.addEventListener(i,m),setTimeout((function(){r||t.dispatchEvent(c)}),d+u+17)}else s.apply(t,[c])}function c(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}var d=[Document,Node,Element,HTMLElement],u=[Element,HTMLElement];function m(t,e){var i="string"==typeof t,n=e&&d.some((function(t){return e instanceof t}))?e:c();return!i&&u.some((function(e){return t instanceof e}))?t:i?n.querySelector(t):null}function f(t,e,i){var n=new CustomEvent(t+".bs."+e,{cancelable:!0});return void 0!==i&&Object.keys(i).forEach((function(t){Object.defineProperty(n,t,{value:i[t]})})),n}function h(t){this&&this.dispatchEvent(t)}function g(t){var e,i,n=this,a=f("close","alert"),o=f("closed","alert");function s(t){e[t?"addEventListener":"removeEventListener"]("click",l,!1)}function l(t){i=t&&t.target.closest(".alert"),(e=m('[data-dismiss="alert"]',i))&&i&&(e===t.target||e.contains(t.target))&&n.close()}function c(){s(),i.parentNode.removeChild(i),h.call(i,o)}n.close=function(){if(i&&e&&i.classList.contains("show")){if(h.call(i,a),a.defaultPrevented)return;n.dispose(),i.classList.remove("show"),i.classList.contains("fade")?r(i,c):c()}},n.dispose=function(){s(),delete e.Alert},e=m(t),i=e.closest(".alert"),e.Alert&&e.Alert.dispose(),e.Alert||s(1),n.element=e,e.Alert=n}function p(t){var e,i,n=f("change","button");function a(t){var a=t.target,o=a.closest("LABEL"),s=null;"LABEL"===a.tagName?s=a:o&&(s=o);var l=s&&s.getElementsByTagName("INPUT")[0];if(l){if(h.call(l,n),h.call(e,n),"checkbox"===l.type){if(n.defaultPrevented)return;l.checked?(s.classList.remove("active"),l.getAttribute("checked"),l.removeAttribute("checked"),l.checked=!1):(s.classList.add("active"),l.getAttribute("checked"),l.setAttribute("checked","checked"),l.checked=!0),e.toggled||(e.toggled=!0)}if("radio"===l.type&&!e.toggled){if(n.defaultPrevented)return;(!l.checked||0===t.screenX&&0===t.screenY)&&(s.classList.add("active"),s.classList.add("focus"),l.setAttribute("checked","checked"),l.checked=!0,e.toggled=!0,Array.from(i).forEach((function(t){var e=t.getElementsByTagName("INPUT")[0];t!==s&&t.classList.contains("active")&&(h.call(e,n),t.classList.remove("active"),e.removeAttribute("checked"),e.checked=!1)})))}setTimeout((function(){e.toggled=!1}),50)}}function o(t){32===(t.which||t.keyCode)&&t.target===document.activeElement&&a(t)}function s(t){32===(t.which||t.keyCode)&&t.preventDefault()}function l(t){if("INPUT"===t.target.tagName){var e="focusin"===t.type?"add":"remove";t.target.closest(".btn").classList[e]("focus")}}function r(t){var i=t?"addEventListener":"removeEventListener";e[i]("click",a,!1),e[i]("keyup",o,!1),e[i]("keydown",s,!1),e[i]("focusin",l,!1),e[i]("focusout",l,!1)}this.dispose=function(){r(),delete e.Button},(e=m(t)).Button&&e.Button.dispose(),(i=e.getElementsByClassName("btn")).length&&(e.Button||r(1),e.toggled=!1,e.Button=this,Array.from(i).forEach((function(t){var e=m("input:checked",t);!t.classList.contains("active")&&e&&t.classList.add("active"),t.classList.contains("active")&&!e&&t.classList.remove("active")})))}var v="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],L={passive:!0};var b=function(t){var e=function(t,e){var i=t.getBoundingClientRect(),n=i.width,a=i.height,o=i.top,s=i.right,l=i.bottom,r=i.left,c=1,d=1;if(e&&t instanceof HTMLElement){var u=t.offsetWidth,m=t.offsetHeight;c=u>0&&Math.round(n)/u||1,d=m>0&&Math.round(a)/m||1}return{width:n/c,height:a/d,top:o/d,right:s/c,bottom:l/d,left:r/c,x:r/c,y:o/d}}(t),i=e.top,n=e.bottom;return i<=c(t).documentElement.clientHeight&&n>=0},y=function(t){return t.offsetHeight};function w(t,e){var i,n,a,o,s,c,d,u,g,p,w,A,T,E=e||{},k=this;function x(){!1===c.interval||o.classList.contains("paused")||(o.classList.add("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null))}function N(){!1!==c.interval&&o.classList.contains("paused")&&(o.classList.remove("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null,k.cycle()))}function C(t){if(t.preventDefault(),!s.isSliding){var e=t.target;e&&!e.classList.contains("active")&&e.getAttribute("data-slide-to")&&(s.index=+e.getAttribute("data-slide-to"),k.slideTo(s.index))}}function P(t){if(t.preventDefault(),!s.isSliding){var e=t.currentTarget||t.srcElement;e===w?s.index+=1:e===p&&(s.index-=1),k.slideTo(s.index)}}function H(t){var e=t.which;if(!s.isSliding){switch(e){case 39:s.index+=1;break;case 37:s.index-=1;break;default:return}k.slideTo(s.index)}}function M(t){var e=t?"addEventListener":"removeEventListener";c.pause&&c.interval&&(o[e](v[0],x,!1),o[e](v[1],N,!1),o[e]("touchstart",x,L),o[e]("touchend",N,L)),c.touch&&g.length>1&&o[e]("touchstart",B,L),w&&w[e]("click",P,!1),p&&p[e]("click",P,!1),A&&A[e]("click",C,!1),c.keyboard&&window[e]("keydown",H,!1)}function S(t){var e=t?"addEventListener":"removeEventListener";o[e]("touchmove",I,L),o[e]("touchend",D,L)}function B(t){s.isTouch||(s.touchPosition.startX=t.changedTouches[0].pageX,o.contains(t.target)&&(s.isTouch=!0,S(1)))}function I(t){s.isTouch?(s.touchPosition.currentX=t.changedTouches[0].pageX,"touchmove"===t.type&&t.changedTouches.length>1&&t.preventDefault()):t.preventDefault()}function D(t){if(s.isTouch&&!s.isSliding&&(s.touchPosition.endX=s.touchPosition.currentX||t.changedTouches[0].pageX,s.isTouch)){if((!o.contains(t.target)||!o.contains(t.relatedTarget))&&Math.abs(s.touchPosition.startX-s.touchPosition.endX)<75)return;s.touchPosition.currentXs.touchPosition.startX&&(s.index-=1),s.isTouch=!1,k.slideTo(s.index),S()}}function X(t){Array.from(T).forEach((function(t){return t.classList.remove("active")})),T[t]&&T[t].classList.add("active")}function R(t){if(s.touchPosition){var e=s.index,i=t&&t.target!==g[e]?1e3*t.elapsedTime+100:20,n=k.getActiveIndex(),a="left"===s.direction?"next":"prev";s.isSliding&&setTimeout((function(){s.touchPosition&&(s.isSliding=!1,g[e].classList.add("active"),g[n].classList.remove("active"),g[e].classList.remove("carousel-item-"+a),g[e].classList.remove("carousel-item-"+s.direction),g[n].classList.remove("carousel-item-"+s.direction),h.call(o,u),document.hidden||!c.interval||o.classList.contains("paused")||k.cycle())}),i)}}if(k.cycle=function(){s.timer&&(clearInterval(s.timer),s.timer=null),s.timer=setInterval((function(){var t=s.index||k.getActiveIndex();b(o)&&(t+=1,k.slideTo(t))}),c.interval)},k.slideTo=function(t){if(!s.isSliding){var e=k.getActiveIndex(),i=t;if(e!==i){ei||e===g.length-1&&0===i)&&(s.direction="right"),i<0?i=g.length-1:i>=g.length&&(i=0);var n="left"===s.direction?"next":"prev",a={relatedTarget:g[i],direction:s.direction,from:e,to:i};d=f("slide","carousel",a),u=f("slid","carousel",a),h.call(o,d),d.defaultPrevented||(s.index=i,s.isSliding=!0,clearInterval(s.timer),s.timer=null,X(i),l(g[i])&&o.classList.contains("slide")?(g[i].classList.add("carousel-item-"+n),y(g[i]),g[i].classList.add("carousel-item-"+s.direction),g[e].classList.add("carousel-item-"+s.direction),r(g[i],R)):(g[i].classList.add("active"),y(g[i]),g[e].classList.remove("active"),setTimeout((function(){s.isSliding=!1,c.interval&&o&&!o.classList.contains("paused")&&k.cycle(),h.call(o,u)}),100)))}}},k.getActiveIndex=function(){return Array.from(g).indexOf(o.getElementsByClassName("carousel-item active")[0])||0},k.dispose=function(){var t=["left","right","prev","next"];Array.from(g).forEach((function(e,i){e.classList.contains("active")&&X(i),t.forEach((function(t){return e.classList.remove("carousel-item-"+t)}))})),clearInterval(s.timer),M(),s={},c={},delete o.Carousel},(o=m(t)).Carousel&&o.Carousel.dispose(),g=o.getElementsByClassName("carousel-item"),i=o.getElementsByClassName("carousel-control-prev"),p=i[0],n=o.getElementsByClassName("carousel-control-next"),w=n[0],a=o.getElementsByClassName("carousel-indicators"),A=a[0],T=A&&A.getElementsByTagName("LI")||[],!(g.length<2)){var W=o.getAttribute("data-interval"),O="false"===W?0:+W,j="false"===o.getAttribute("data-touch")?0:1,z="hover"===o.getAttribute("data-pause")||!1,U="true"===o.getAttribute("data-keyboard")||!1,q=E.interval,F=E.touch;(c={}).keyboard=!0===E.keyboard||U,c.pause=!("hover"!==E.pause&&!z)&&"hover",c.touch=F||j,c.interval=5e3,"number"==typeof q?c.interval=q:!1===q||0===O||!1===O?c.interval=0:Number.isNaN(O)||(c.interval=O),k.getActiveIndex()<0&&(g.length&&g[0].classList.add("active"),T.length&&X(0)),(s={}).direction="left",s.index=0,s.timer=null,s.isSliding=!1,s.isTouch=!1,s.touchPosition={startX:0,currentX:0,endX:0},M(1),c.interval&&k.cycle(),o.Carousel=k}}function A(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=null;function v(t,e){h.call(t,l),l.defaultPrevented||(t.isAnimating=!0,t.style.height=t.scrollHeight+"px",t.classList.remove("collapse"),t.classList.remove("show"),t.classList.add("collapsing"),y(t),t.style.height="0px",r(t,(function(){t.isAnimating=!1,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),t.classList.remove("collapsing"),t.classList.add("collapse"),t.style.height="",h.call(t,c)})))}u.toggle=function(t){(t&&"A"===t.target.tagName||"A"===i.tagName)&&t.preventDefault(),(i.contains(t.target)||t.target===i)&&(p.classList.contains("show")?u.hide():u.show())},u.hide=function(){p.isAnimating||(v(p,i),i.classList.add("collapsed"))},u.show=function(){var t,e,l;g&&(t=g.getElementsByClassName("collapse show"),n=t[0],a=n&&(m('[data-target="#'+n.id+'"]',g)||m('[href="#'+n.id+'"]',g))),p.isAnimating||(a&&n!==p&&(v(n,a),a.classList.add("collapsed")),e=p,l=i,h.call(e,o),o.defaultPrevented||(e.isAnimating=!0,e.classList.add("collapsing"),e.classList.remove("collapse"),e.style.height=e.scrollHeight+"px",r(e,(function(){e.isAnimating=!1,e.setAttribute("aria-expanded","true"),l.setAttribute("aria-expanded","true"),e.classList.remove("collapsing"),e.classList.add("collapse"),e.classList.add("show"),e.style.height="",h.call(e,s)}))),i.classList.remove("collapsed"))},u.dispose=function(){i.removeEventListener("click",u.toggle,!1),delete i.Collapse},(i=m(t)).Collapse&&i.Collapse.dispose();var L=i.getAttribute("data-parent");o=f("show","collapse"),s=f("shown","collapse"),l=f("hide","collapse"),c=f("hidden","collapse"),null!==(p=m(d.target||i.getAttribute("data-target")||i.getAttribute("href")))&&(p.isAnimating=!1);var b=d.parent||L;g=b?i.closest(b):null,i.Collapse||i.addEventListener("click",u.toggle,!1),i.Collapse=u}var T=function(t){return t.focus()};function E(t,e){var i,n,a,o,s,l,r,c,d=this,u=null,g=[];function p(t){(t.hasAttribute("href")&&"#"===t.href.slice(-1)||t.parentNode&&t.parentNode.hasAttribute("href")&&"#"===t.parentNode.href.slice(-1))&&this.preventDefault()}function v(){var t=i.open?"addEventListener":"removeEventListener";document[t]("click",L,!1),document[t]("keydown",y,!1),document[t]("keyup",w,!1),document[t]("focus",L,!1)}function L(t){var e=t.target;if(e.getAttribute){var n=e&&e.getAttribute("data-toggle")||e.parentNode&&e.parentNode.getAttribute&&e.parentNode.getAttribute("data-toggle");("focus"!==t.type||e!==i&&e!==r&&!r.contains(e))&&(e!==r&&!r.contains(e)||!c&&!n)&&(u=e===i||i.contains(e)?i:null,d.hide(),p.call(t,e))}}function b(t){u=i,d.show(),p.call(t,t.target)}function y(t){var e=t.which||t.keyCode;38!==e&&40!==e||t.preventDefault()}function w(t){var e=t.which||t.keyCode,n=document.activeElement,a=n===i,o=r.contains(n),s=n.parentNode===r||n.parentNode.parentNode===r,l=g.indexOf(n);s&&(a?l=0:38===e?l=l>1?l-1:0:40===e&&(l=l=d,w=m.top+c/2+g/2>=u,A=m.top-c<0,T=m.left-r<0,E=m.top+c+g>=u,k=m.left+r+h>=d,x=i;x="right"===(x="left"===(x="bottom"===(x="top"===(x=("left"===x||"right"===x)&&T&&k?"top":x)&&A?"bottom":x)&&E?"top":x)&&T?"right":x)&&k?"left":x,-1===e.className.indexOf(x)&&(e.className=e.className.replace(/\b(top|bottom|left|right)+/,x));var C=v.offsetWidth,P=v.offsetHeight;"left"===x||"right"===x?(o="left"===x?m.left+f.x-r-(p?C:0):m.left+f.x+h,L?(a=m.top+f.y,s=g/2-C):w?(a=m.top+f.y-c+g,s=c-g/2-C):(a=m.top+f.y-c/2+g/2,s=c/2-(p?.9*P:P/2))):"top"!==x&&"bottom"!==x||(a="top"===x?m.top+f.y-c-(p?P:0):m.top+f.y+g,b?(o=0,l=m.left+h/2-C):y?(o=d-1.01*r,l=r-(d-m.left)+h/2-C/2):(o=m.left+f.x-r/2+h/2,l=r/2-(p?C:C/2))),e.style.top=a+"px",e.style.left=o+"px",s&&(v.style.top=s+"px"),l&&(v.style.left=l+"px")}function P(t,e){var i,n,a,o,s,l,c,d,u,g=e||{},p=this,b=null,y=0,w=/(iPhone|iPod|iPad)/.test(navigator.userAgent),A={};function T(t){null!==b&&t.target===m(".close",b)&&p.hide()}function E(t){return g[t]||i.dataset[t]||null}function k(){return E("title")}function N(){return E("content")}function P(){null===b&&i.focus()}function H(t){var e=t?"addEventListener":"removeEventListener";"hover"===A.trigger?(i[e](x,p.show),i[e](v[0],p.show),A.dismissible||i[e](v[1],p.hide)):"click"===A.trigger?i[e](A.trigger,p.toggle):"focus"===A.trigger&&(w&&i[e]("click",P,!1),i[e](A.trigger,p.toggle))}function M(t){b&&b.contains(t.target)||t.target===i||i.contains(t.target)||p.hide()}function S(t){var e=t?"addEventListener":"removeEventListener";A.dismissible?document[e]("click",T,!1):("focus"===A.trigger&&i[e]("blur",p.hide),"hover"===A.trigger&&document[e]("touchstart",M,L)),window[e]("resize",p.hide,L)}function B(){S(1),h.call(i,c)}function I(){S(),A.container.removeChild(b),y=null,b=null,h.call(i,u)}p.toggle=function(){null===b?p.show():p.hide()},p.show=function(){clearTimeout(y),y=setTimeout((function(){if(null===b){if(h.call(i,l),l.defaultPrevented)return;!function(){n=k(),a=(a=N())?a.trim():null,b=document.createElement("div");var t=document.createElement("div");if(t.classList.add("arrow"),b.appendChild(t),null!==a&&null===A.template){if(b.setAttribute("role","tooltip"),null!==n){var e=document.createElement("h3");e.classList.add("popover-header"),e.innerHTML=A.dismissible?n+s:n,b.appendChild(e)}var i=document.createElement("div");i.classList.add("popover-body"),i.innerHTML=A.dismissible&&null===n?a+s:a,b.appendChild(i)}else{var l=document.createElement("div");l.innerHTML=A.template.trim(),b.className=l.firstChild.className,b.innerHTML=l.firstChild.innerHTML;var r=m(".popover-header",b),c=m(".popover-body",b);n&&r&&(r.innerHTML=n.trim()),a&&c&&(c.innerHTML=a.trim())}A.container.appendChild(b),b.style.display="block",b.classList.contains("popover")||b.classList.add("popover"),b.classList.contains(A.animation)||b.classList.add(A.animation),b.classList.contains(o)||b.classList.add(o)}(),C(i,b,A.placement,A.container),b.classList.contains("show")||b.classList.add("show"),A.animation?r(b,B):B()}}),20)},p.hide=function(){clearTimeout(y),y=setTimeout((function(){if(b&&null!==b&&b.classList.contains("show")){if(h.call(i,d),d.defaultPrevented)return;b.classList.remove("show"),A.animation?r(b,I):I()}}),A.delay)},p.dispose=function(){p.hide(),H(),delete i.Popover},(i=m(t)).Popover&&i.Popover.dispose();var D=i.getAttribute("data-trigger"),X=i.getAttribute("data-animation"),R=i.getAttribute("data-placement"),W=i.getAttribute("data-dismissible"),O=i.getAttribute("data-delay"),j=i.getAttribute("data-container");s='',l=f("show","popover"),c=f("shown","popover"),d=f("hide","popover"),u=f("hidden","popover");var z=m(g.container),U=m(j),q=i.closest(".modal"),F=i.closest(".fixed-top"),Y=i.closest(".fixed-bottom");A.template=g.template?g.template:null,A.trigger=g.trigger?g.trigger:D||"hover",A.animation=g.animation&&"fade"!==g.animation?g.animation:X||"fade",A.placement=g.placement?g.placement:R||"top",A.delay=parseInt(g.delay||O,10)||200,A.dismissible=!(!g.dismissible&&"true"!==W),A.container=z||U||F||Y||q||document.body,o="bs-popover-"+A.placement,n=k(),((a=N())||A.template)&&(i.Popover||H(1),i.Popover=p)}function H(t,e){var i,n,a,o,s,l=e||{},r=this,c={};function d(){var t,e,s;(a=o.getElementsByTagName("A"),n.scrollTop=n.isWindow?N().y:i.scrollTop,n.length!==a.length||g()!==n.scrollHeight)&&(n.items=[],n.offsets=[],n.scrollHeight=g(),n.maxScroll=n.scrollHeight-(n.isWindow?window.innerHeight:i.getBoundingClientRect().height),Array.from(a).forEach((function(i){t=i.getAttribute("href"),(e=t&&"#"===t.charAt(0)&&"#"!==t.slice(-1)&&m(t))&&(n.items.push(i),s=e.getBoundingClientRect(),n.offsets.push((n.isWindow?s.top+n.scrollTop:e.offsetTop)-c.offset))})),n.length=n.items.length)}function u(t){var e=t?"addEventListener":"removeEventListener";s[e]("scroll",r.refresh,L),window[e]("resize",r.refresh,L)}function g(){return s.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}function p(){Array.from(a).map((function(t){return t.classList.contains("active")&&t.classList.remove("active")}))}function v(t){var e,a=t;p(),n.activeItem=a,a.classList.add("active");for(var o=[];a.parentNode!==document.body;)((e=(a=a.parentNode).classList).contains("dropdown-menu")||e.contains("nav"))&&o.push(a);o.forEach((function(t){var e=t.previousElementSibling;e&&!e.classList.contains("active")&&e.classList.add("active")})),h.call(i,f("activate","scrollspy",{relatedTarget:n.activeItem}))}r.refresh=function(){if(d(),n.scrollTop>=n.maxScroll){var t=n.items[n.length-1];n.activeItem!==t&&v(t)}else{if(n.activeItem&&n.scrollTop0)return n.activeItem=null,void p();for(var e=n.length;e>-1;)n.activeItem!==n.items[e]&&n.scrollTop>=n.offsets[e]&&(void 0===n.offsets[e+1]||n.scrollTop1&&(g=t[t.length-1]):g=t[0],g}function P(){return m(C().getAttribute("href"))}function H(t){t.preventDefault(),u=t.currentTarget,a.isAnimating||T.show()}T.show=function(){if(!(u=u||n).classList.contains("active")){if(v=m(u.getAttribute("href")),g=C(),p=P(),c=f("hide","tab",{relatedTarget:u}),h.call(g,c),c.defaultPrevented)return;a.isAnimating=!0,g.classList.remove("active"),g.setAttribute("aria-selected","false"),u.classList.add("active"),u.setAttribute("aria-selected","true"),o&&(n.parentNode.classList.contains("dropdown-menu")?o.classList.contains("active")||o.classList.add("active"):o.classList.contains("active")&&o.classList.remove("active")),p.classList.contains("fade")?(p.classList.remove("show"),r(p,N)):N()}},T.dispose=function(){n.removeEventListener("click",H,!1),delete n.Tab},(n=m(t)).Tab&&n.Tab.dispose();var M=n.getAttribute("data-height");a=n.closest(".nav"),o=a&&m(".dropdown-toggle",a);var S=!(!e||!1===A.height||"false"===M);a.isAnimating=!1,n.Tab||n.addEventListener("click",H,!1),S&&(E=P().parentNode),n.Tab=T}function S(t,e){var i,n,a,o,s,l,c=e||{},d=this,u=0,g={};function p(){n.classList.remove("showing"),n.classList.add("show"),h.call(n,s),g.autohide&&d.hide()}function v(){n.classList.add("hide"),h.call(n,l)}function L(){n.classList.remove("show"),g.animation?r(n,v):v()}function b(){clearTimeout(u),i.removeEventListener("click",d.hide,!1),delete i.Toast}d.show=function(){if(n&&!n.classList.contains("show")){if(h.call(n,a),a.defaultPrevented)return;g.animation&&n.classList.add("fade"),n.classList.remove("hide"),y(n),n.classList.add("showing"),g.animation?r(n,p):p()}},d.hide=function(t){if(n&&n.classList.contains("show")){if(h.call(n,o),o.defaultPrevented)return;t?L():u=setTimeout(L,g.delay)}},d.dispose=function(){g.animation?r(n,b):b()},(i=m(t)).Toast&&i.Toast.dispose(),n=i.closest(".toast");var w=i.getAttribute("data-animation"),A=i.getAttribute("data-autohide"),T=i.getAttribute("data-delay");a=f("show","toast"),o=f("hide","toast"),s=f("shown","toast"),l=f("hidden","toast"),g.animation=!1===c.animation||"false"===w?0:1,g.autohide=!1===c.autohide||"false"===A?0:1,g.delay=parseInt(c.delay||T,10)||500,i.Toast||i.addEventListener("click",d.hide,!1),i.Toast=d}function B(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=0,b={};function y(){return i.getAttribute("title")||i.getAttribute("data-title")||i.getAttribute("data-original-title")}function w(t){g&&g.contains(t.target)||t.target===i||i.contains(t.target)||u.hide()}function A(t){var e=t?"addEventListener":"removeEventListener";document[e]("touchstart",w,L),window[e]("resize",u.hide,L)}function T(){A(1),h.call(i,s)}function E(){A(),b.container.removeChild(g),g=null,p=null,h.call(i,c)}function k(t){var e=t?"addEventListener":"removeEventListener";i[e](x,u.show,!1),i[e](v[0],u.show,!1),i[e](v[1],u.hide,!1)}u.show=function(){clearTimeout(p),p=setTimeout((function(){if(null===g){if(h.call(i,o),o.defaultPrevented)return;!1!==function(){if(n=y()){if(g=document.createElement("div"),b.template){var t=document.createElement("div");t.innerHTML=b.template.trim(),g.className=t.firstChild.className,g.innerHTML=t.firstChild.innerHTML,m(".tooltip-inner",g).innerHTML=n.trim()}else{var e=document.createElement("div");e.classList.add("arrow"),g.appendChild(e);var i=document.createElement("div");i.classList.add("tooltip-inner"),g.appendChild(i),i.innerHTML=n}g.style.left="0",g.style.top="0",g.setAttribute("role","tooltip"),g.classList.contains("tooltip")||g.classList.add("tooltip"),g.classList.contains(b.animation)||g.classList.add(b.animation),g.classList.contains(a)||g.classList.add(a),b.container.appendChild(g)}}()&&(C(i,g,b.placement,b.container),g.classList.contains("show")||g.classList.add("show"),b.animation?r(g,T):T())}}),20)},u.hide=function(){clearTimeout(p),p=setTimeout((function(){if(g&&g.classList.contains("show")){if(h.call(i,l),l.defaultPrevented)return;g.classList.remove("show"),b.animation?r(g,E):E()}}),b.delay)},u.toggle=function(){g?u.hide():u.show()},u.dispose=function(){k(),u.hide(),i.setAttribute("title",i.getAttribute("data-original-title")),i.removeAttribute("data-original-title"),delete i.Tooltip},(i=m(t)).Tooltip&&i.Tooltip.dispose();var N=i.getAttribute("data-animation"),P=i.getAttribute("data-placement"),H=i.getAttribute("data-delay"),M=i.getAttribute("data-container"),S=m(d.container),B=m(M),I=i.closest(".modal");o=f("show","tooltip"),s=f("shown","tooltip"),l=f("hide","tooltip"),c=f("hidden","tooltip");var D=i.closest(".fixed-top"),X=i.closest(".fixed-bottom");b.animation=d.animation&&"fade"!==d.animation?d.animation:N||"fade",b.placement=d.placement?d.placement:P||"top",b.template=d.template?d.template:null,b.delay=parseInt(d.delay||H,10)||200,b.container=S||B||D||X||I||document.body,a="bs-tooltip-"+b.placement,(n=y())&&(i.Tooltip||(i.setAttribute("data-original-title",n),i.removeAttribute("title"),k(1)),i.Tooltip=u)}var I={};function D(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=I[t][0],n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return new i(t)}))}))}I.Alert=[g,'[data-dismiss="alert"]'],I.Button=[p,'[data-toggle="buttons"]'],I.Carousel=[w,'[data-ride="carousel"]'],I.Collapse=[A,'[data-toggle="collapse"]'],I.Dropdown=[E,'[data-toggle="dropdown"]'],I.Modal=[k,'[data-toggle="modal"]'],I.Popover=[P,'[data-toggle="popover"],[data-tip="popover"]'],I.ScrollSpy=[H,'[data-spy="scroll"]'],I.Tab=[M,'[data-toggle="tab"]'],I.Toast=[S,'[data-dismiss="toast"]'],I.Tooltip=[B,'[data-toggle="tooltip"],[data-tip="tooltip"]'],document.body?D():document.addEventListener("DOMContentLoaded",(function t(){D(),document.removeEventListener("DOMContentLoaded",t,!1)}),!1);var X={Alert:g,Button:p,Carousel:w,Collapse:A,Dropdown:E,Modal:k,Popover:P,ScrollSpy:H,Tab:M,Toast:S,Tooltip:B,initCallback:D,removeDataAPI:function(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=t,n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return t[i].dispose()}))}))},componentsInit:I,Version:"4.1.0alpha4"};export{X as default}; diff --git a/dist/bootstrap-native-v4.js b/dist/bootstrap-native-v4.js index 082da61d..e23af749 100644 --- a/dist/bootstrap-native-v4.js +++ b/dist/bootstrap-native-v4.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -2585,7 +2585,7 @@ }); } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; var Version = version; diff --git a/dist/bootstrap-native-v4.min.js b/dist/bootstrap-native-v4.min.js index 70bb2e00..07de262d 100644 --- a/dist/bootstrap-native-v4.min.js +++ b/dist/bootstrap-native-v4.min.js @@ -1,2 +1,2 @@ -// Native JavaScript for Bootstrap v4.1.0alpha3 | 2022 © dnp_theme | MIT-License -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BSN=e()}(this,(function(){"use strict";var t=document.head,e="webkitTransition"in t.style||"transition"in t.style,i="webkitTransition"in t.style?"webkitTransitionEnd":"transitionend",n="webkitTransition"in t.style?"webkitTransitionDelay":"transitionDelay",a="webkitTransition"in t.style?"webkitTransitionProperty":"transitionProperty";function o(t,e){var i=getComputedStyle(t);return e in i?i[e]:""}var s="webkitTransition"in t.style?"webkitTransitionDuration":"transitionDuration";function l(t){var i=o(t,a),n=o(t,s),l=n.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(n)*l:0;return Number.isNaN(r)?0:r}function r(t,s){var r=0,c=new Event(i),d=l(t),u=function(t){var i=o(t,a),s=o(t,n),l=s.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(s)*l:0;return Number.isNaN(r)?0:r}(t);if(e&&d){var m=function(e){e.target===t&&(s.apply(t,[e]),t.removeEventListener(i,m),r=1)};t.addEventListener(i,m),setTimeout((function(){r||t.dispatchEvent(c)}),d+u+17)}else s.apply(t,[c])}function c(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}var d=[Document,Node,Element,HTMLElement],u=[Element,HTMLElement];function m(t,e){var i="string"==typeof t,n=e&&d.some((function(t){return e instanceof t}))?e:c();return!i&&u.some((function(e){return t instanceof e}))?t:i?n.querySelector(t):null}function f(t,e,i){var n=new CustomEvent(t+".bs."+e,{cancelable:!0});return void 0!==i&&Object.keys(i).forEach((function(t){Object.defineProperty(n,t,{value:i[t]})})),n}function h(t){this&&this.dispatchEvent(t)}function g(t){var e,i,n=this,a=f("close","alert"),o=f("closed","alert");function s(t){e[t?"addEventListener":"removeEventListener"]("click",l,!1)}function l(t){i=t&&t.target.closest(".alert"),(e=m('[data-dismiss="alert"]',i))&&i&&(e===t.target||e.contains(t.target))&&n.close()}function c(){s(),i.parentNode.removeChild(i),h.call(i,o)}n.close=function(){if(i&&e&&i.classList.contains("show")){if(h.call(i,a),a.defaultPrevented)return;n.dispose(),i.classList.remove("show"),i.classList.contains("fade")?r(i,c):c()}},n.dispose=function(){s(),delete e.Alert},e=m(t),i=e.closest(".alert"),e.Alert&&e.Alert.dispose(),e.Alert||s(1),n.element=e,e.Alert=n}function p(t){var e,i,n=f("change","button");function a(t){var a=t.target,o=a.closest("LABEL"),s=null;"LABEL"===a.tagName?s=a:o&&(s=o);var l=s&&s.getElementsByTagName("INPUT")[0];if(l){if(h.call(l,n),h.call(e,n),"checkbox"===l.type){if(n.defaultPrevented)return;l.checked?(s.classList.remove("active"),l.getAttribute("checked"),l.removeAttribute("checked"),l.checked=!1):(s.classList.add("active"),l.getAttribute("checked"),l.setAttribute("checked","checked"),l.checked=!0),e.toggled||(e.toggled=!0)}if("radio"===l.type&&!e.toggled){if(n.defaultPrevented)return;(!l.checked||0===t.screenX&&0===t.screenY)&&(s.classList.add("active"),s.classList.add("focus"),l.setAttribute("checked","checked"),l.checked=!0,e.toggled=!0,Array.from(i).forEach((function(t){var e=t.getElementsByTagName("INPUT")[0];t!==s&&t.classList.contains("active")&&(h.call(e,n),t.classList.remove("active"),e.removeAttribute("checked"),e.checked=!1)})))}setTimeout((function(){e.toggled=!1}),50)}}function o(t){32===(t.which||t.keyCode)&&t.target===document.activeElement&&a(t)}function s(t){32===(t.which||t.keyCode)&&t.preventDefault()}function l(t){if("INPUT"===t.target.tagName){var e="focusin"===t.type?"add":"remove";t.target.closest(".btn").classList[e]("focus")}}function r(t){var i=t?"addEventListener":"removeEventListener";e[i]("click",a,!1),e[i]("keyup",o,!1),e[i]("keydown",s,!1),e[i]("focusin",l,!1),e[i]("focusout",l,!1)}this.dispose=function(){r(),delete e.Button},(e=m(t)).Button&&e.Button.dispose(),(i=e.getElementsByClassName("btn")).length&&(e.Button||r(1),e.toggled=!1,e.Button=this,Array.from(i).forEach((function(t){var e=m("input:checked",t);!t.classList.contains("active")&&e&&t.classList.add("active"),t.classList.contains("active")&&!e&&t.classList.remove("active")})))}var v="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],L={passive:!0};var b=function(t){var e=function(t,e){var i=t.getBoundingClientRect(),n=i.width,a=i.height,o=i.top,s=i.right,l=i.bottom,r=i.left,c=1,d=1;if(e&&t instanceof HTMLElement){var u=t.offsetWidth,m=t.offsetHeight;c=u>0&&Math.round(n)/u||1,d=m>0&&Math.round(a)/m||1}return{width:n/c,height:a/d,top:o/d,right:s/c,bottom:l/d,left:r/c,x:r/c,y:o/d}}(t),i=e.top,n=e.bottom;return i<=c(t).documentElement.clientHeight&&n>=0},y=function(t){return t.offsetHeight};function w(t,e){var i,n,a,o,s,c,d,u,g,p,w,A,T,E=e||{},k=this;function x(){!1===c.interval||o.classList.contains("paused")||(o.classList.add("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null))}function N(){!1!==c.interval&&o.classList.contains("paused")&&(o.classList.remove("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null,k.cycle()))}function C(t){if(t.preventDefault(),!s.isSliding){var e=t.target;e&&!e.classList.contains("active")&&e.getAttribute("data-slide-to")&&(s.index=+e.getAttribute("data-slide-to"),k.slideTo(s.index))}}function P(t){if(t.preventDefault(),!s.isSliding){var e=t.currentTarget||t.srcElement;e===w?s.index+=1:e===p&&(s.index-=1),k.slideTo(s.index)}}function H(t){var e=t.which;if(!s.isSliding){switch(e){case 39:s.index+=1;break;case 37:s.index-=1;break;default:return}k.slideTo(s.index)}}function M(t){var e=t?"addEventListener":"removeEventListener";c.pause&&c.interval&&(o[e](v[0],x,!1),o[e](v[1],N,!1),o[e]("touchstart",x,L),o[e]("touchend",N,L)),c.touch&&g.length>1&&o[e]("touchstart",B,L),w&&w[e]("click",P,!1),p&&p[e]("click",P,!1),A&&A[e]("click",C,!1),c.keyboard&&window[e]("keydown",H,!1)}function S(t){var e=t?"addEventListener":"removeEventListener";o[e]("touchmove",I,L),o[e]("touchend",D,L)}function B(t){s.isTouch||(s.touchPosition.startX=t.changedTouches[0].pageX,o.contains(t.target)&&(s.isTouch=!0,S(1)))}function I(t){s.isTouch?(s.touchPosition.currentX=t.changedTouches[0].pageX,"touchmove"===t.type&&t.changedTouches.length>1&&t.preventDefault()):t.preventDefault()}function D(t){if(s.isTouch&&!s.isSliding&&(s.touchPosition.endX=s.touchPosition.currentX||t.changedTouches[0].pageX,s.isTouch)){if((!o.contains(t.target)||!o.contains(t.relatedTarget))&&Math.abs(s.touchPosition.startX-s.touchPosition.endX)<75)return;s.touchPosition.currentXs.touchPosition.startX&&(s.index-=1),s.isTouch=!1,k.slideTo(s.index),S()}}function X(t){Array.from(T).forEach((function(t){return t.classList.remove("active")})),T[t]&&T[t].classList.add("active")}function R(t){if(s.touchPosition){var e=s.index,i=t&&t.target!==g[e]?1e3*t.elapsedTime+100:20,n=k.getActiveIndex(),a="left"===s.direction?"next":"prev";s.isSliding&&setTimeout((function(){s.touchPosition&&(s.isSliding=!1,g[e].classList.add("active"),g[n].classList.remove("active"),g[e].classList.remove("carousel-item-"+a),g[e].classList.remove("carousel-item-"+s.direction),g[n].classList.remove("carousel-item-"+s.direction),h.call(o,u),document.hidden||!c.interval||o.classList.contains("paused")||k.cycle())}),i)}}if(k.cycle=function(){s.timer&&(clearInterval(s.timer),s.timer=null),s.timer=setInterval((function(){var t=s.index||k.getActiveIndex();b(o)&&(t+=1,k.slideTo(t))}),c.interval)},k.slideTo=function(t){if(!s.isSliding){var e=k.getActiveIndex(),i=t;if(e!==i){ei||e===g.length-1&&0===i)&&(s.direction="right"),i<0?i=g.length-1:i>=g.length&&(i=0);var n="left"===s.direction?"next":"prev",a={relatedTarget:g[i],direction:s.direction,from:e,to:i};d=f("slide","carousel",a),u=f("slid","carousel",a),h.call(o,d),d.defaultPrevented||(s.index=i,s.isSliding=!0,clearInterval(s.timer),s.timer=null,X(i),l(g[i])&&o.classList.contains("slide")?(g[i].classList.add("carousel-item-"+n),y(g[i]),g[i].classList.add("carousel-item-"+s.direction),g[e].classList.add("carousel-item-"+s.direction),r(g[i],R)):(g[i].classList.add("active"),y(g[i]),g[e].classList.remove("active"),setTimeout((function(){s.isSliding=!1,c.interval&&o&&!o.classList.contains("paused")&&k.cycle(),h.call(o,u)}),100)))}}},k.getActiveIndex=function(){return Array.from(g).indexOf(o.getElementsByClassName("carousel-item active")[0])||0},k.dispose=function(){var t=["left","right","prev","next"];Array.from(g).forEach((function(e,i){e.classList.contains("active")&&X(i),t.forEach((function(t){return e.classList.remove("carousel-item-"+t)}))})),clearInterval(s.timer),M(),s={},c={},delete o.Carousel},(o=m(t)).Carousel&&o.Carousel.dispose(),g=o.getElementsByClassName("carousel-item"),i=o.getElementsByClassName("carousel-control-prev"),p=i[0],n=o.getElementsByClassName("carousel-control-next"),w=n[0],a=o.getElementsByClassName("carousel-indicators"),A=a[0],T=A&&A.getElementsByTagName("LI")||[],!(g.length<2)){var W=o.getAttribute("data-interval"),O="false"===W?0:+W,j="false"===o.getAttribute("data-touch")?0:1,z="hover"===o.getAttribute("data-pause")||!1,U="true"===o.getAttribute("data-keyboard")||!1,q=E.interval,F=E.touch;(c={}).keyboard=!0===E.keyboard||U,c.pause=!("hover"!==E.pause&&!z)&&"hover",c.touch=F||j,c.interval=5e3,"number"==typeof q?c.interval=q:!1===q||0===O||!1===O?c.interval=0:Number.isNaN(O)||(c.interval=O),k.getActiveIndex()<0&&(g.length&&g[0].classList.add("active"),T.length&&X(0)),(s={}).direction="left",s.index=0,s.timer=null,s.isSliding=!1,s.isTouch=!1,s.touchPosition={startX:0,currentX:0,endX:0},M(1),c.interval&&k.cycle(),o.Carousel=k}}function A(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=null;function v(t,e){h.call(t,l),l.defaultPrevented||(t.isAnimating=!0,t.style.height=t.scrollHeight+"px",t.classList.remove("collapse"),t.classList.remove("show"),t.classList.add("collapsing"),y(t),t.style.height="0px",r(t,(function(){t.isAnimating=!1,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),t.classList.remove("collapsing"),t.classList.add("collapse"),t.style.height="",h.call(t,c)})))}u.toggle=function(t){(t&&"A"===t.target.tagName||"A"===i.tagName)&&t.preventDefault(),(i.contains(t.target)||t.target===i)&&(p.classList.contains("show")?u.hide():u.show())},u.hide=function(){p.isAnimating||(v(p,i),i.classList.add("collapsed"))},u.show=function(){var t,e,l;g&&(t=g.getElementsByClassName("collapse show"),n=t[0],a=n&&(m('[data-target="#'+n.id+'"]',g)||m('[href="#'+n.id+'"]',g))),p.isAnimating||(a&&n!==p&&(v(n,a),a.classList.add("collapsed")),e=p,l=i,h.call(e,o),o.defaultPrevented||(e.isAnimating=!0,e.classList.add("collapsing"),e.classList.remove("collapse"),e.style.height=e.scrollHeight+"px",r(e,(function(){e.isAnimating=!1,e.setAttribute("aria-expanded","true"),l.setAttribute("aria-expanded","true"),e.classList.remove("collapsing"),e.classList.add("collapse"),e.classList.add("show"),e.style.height="",h.call(e,s)}))),i.classList.remove("collapsed"))},u.dispose=function(){i.removeEventListener("click",u.toggle,!1),delete i.Collapse},(i=m(t)).Collapse&&i.Collapse.dispose();var L=i.getAttribute("data-parent");o=f("show","collapse"),s=f("shown","collapse"),l=f("hide","collapse"),c=f("hidden","collapse"),null!==(p=m(d.target||i.getAttribute("data-target")||i.getAttribute("href")))&&(p.isAnimating=!1);var b=d.parent||L;g=b?i.closest(b):null,i.Collapse||i.addEventListener("click",u.toggle,!1),i.Collapse=u}var T=function(t){return t.focus()};function E(t,e){var i,n,a,o,s,l,r,c,d=this,u=null,g=[];function p(t){(t.hasAttribute("href")&&"#"===t.href.slice(-1)||t.parentNode&&t.parentNode.hasAttribute("href")&&"#"===t.parentNode.href.slice(-1))&&this.preventDefault()}function v(){var t=i.open?"addEventListener":"removeEventListener";document[t]("click",L,!1),document[t]("keydown",y,!1),document[t]("keyup",w,!1),document[t]("focus",L,!1)}function L(t){var e=t.target;if(e.getAttribute){var n=e&&e.getAttribute("data-toggle")||e.parentNode&&e.parentNode.getAttribute&&e.parentNode.getAttribute("data-toggle");("focus"!==t.type||e!==i&&e!==r&&!r.contains(e))&&(e!==r&&!r.contains(e)||!c&&!n)&&(u=e===i||i.contains(e)?i:null,d.hide(),p.call(t,e))}}function b(t){u=i,d.show(),p.call(t,t.target)}function y(t){var e=t.which||t.keyCode;38!==e&&40!==e||t.preventDefault()}function w(t){var e=t.which||t.keyCode,n=document.activeElement,a=n===i,o=r.contains(n),s=n.parentNode===r||n.parentNode.parentNode===r,l=g.indexOf(n);s&&(a?l=0:38===e?l=l>1?l-1:0:40===e&&(l=l=d,w=m.top+c/2+g/2>=u,A=m.top-c<0,T=m.left-r<0,E=m.top+c+g>=u,k=m.left+r+h>=d,x=i;x="right"===(x="left"===(x="bottom"===(x="top"===(x=("left"===x||"right"===x)&&T&&k?"top":x)&&A?"bottom":x)&&E?"top":x)&&T?"right":x)&&k?"left":x,-1===e.className.indexOf(x)&&(e.className=e.className.replace(/\b(top|bottom|left|right)+/,x));var C=v.offsetWidth,P=v.offsetHeight;"left"===x||"right"===x?(o="left"===x?m.left+f.x-r-(p?C:0):m.left+f.x+h,L?(a=m.top+f.y,s=g/2-C):w?(a=m.top+f.y-c+g,s=c-g/2-C):(a=m.top+f.y-c/2+g/2,s=c/2-(p?.9*P:P/2))):"top"!==x&&"bottom"!==x||(a="top"===x?m.top+f.y-c-(p?P:0):m.top+f.y+g,b?(o=0,l=m.left+h/2-C):y?(o=d-1.01*r,l=r-(d-m.left)+h/2-C/2):(o=m.left+f.x-r/2+h/2,l=r/2-(p?C:C/2))),e.style.top=a+"px",e.style.left=o+"px",s&&(v.style.top=s+"px"),l&&(v.style.left=l+"px")}function P(t,e){var i,n,a,o,s,l,c,d,u,g=e||{},p=this,b=null,y=0,w=/(iPhone|iPod|iPad)/.test(navigator.userAgent),A={};function T(t){null!==b&&t.target===m(".close",b)&&p.hide()}function E(t){return g[t]||i.dataset[t]||null}function k(){return E("title")}function N(){return E("content")}function P(){null===b&&i.focus()}function H(t){var e=t?"addEventListener":"removeEventListener";"hover"===A.trigger?(i[e](x,p.show),i[e](v[0],p.show),A.dismissible||i[e](v[1],p.hide)):"click"===A.trigger?i[e](A.trigger,p.toggle):"focus"===A.trigger&&(w&&i[e]("click",P,!1),i[e](A.trigger,p.toggle))}function M(t){b&&b.contains(t.target)||t.target===i||i.contains(t.target)||p.hide()}function S(t){var e=t?"addEventListener":"removeEventListener";A.dismissible?document[e]("click",T,!1):("focus"===A.trigger&&i[e]("blur",p.hide),"hover"===A.trigger&&document[e]("touchstart",M,L)),window[e]("resize",p.hide,L)}function B(){S(1),h.call(i,c)}function I(){S(),A.container.removeChild(b),y=null,b=null,h.call(i,u)}p.toggle=function(){null===b?p.show():p.hide()},p.show=function(){clearTimeout(y),y=setTimeout((function(){if(null===b){if(h.call(i,l),l.defaultPrevented)return;!function(){n=k(),a=(a=N())?a.trim():null,b=document.createElement("div");var t=document.createElement("div");if(t.classList.add("arrow"),b.appendChild(t),null!==a&&null===A.template){if(b.setAttribute("role","tooltip"),null!==n){var e=document.createElement("h3");e.classList.add("popover-header"),e.innerHTML=A.dismissible?n+s:n,b.appendChild(e)}var i=document.createElement("div");i.classList.add("popover-body"),i.innerHTML=A.dismissible&&null===n?a+s:a,b.appendChild(i)}else{var l=document.createElement("div");l.innerHTML=A.template.trim(),b.className=l.firstChild.className,b.innerHTML=l.firstChild.innerHTML;var r=m(".popover-header",b),c=m(".popover-body",b);n&&r&&(r.innerHTML=n.trim()),a&&c&&(c.innerHTML=a.trim())}A.container.appendChild(b),b.style.display="block",b.classList.contains("popover")||b.classList.add("popover"),b.classList.contains(A.animation)||b.classList.add(A.animation),b.classList.contains(o)||b.classList.add(o)}(),C(i,b,A.placement,A.container),b.classList.contains("show")||b.classList.add("show"),A.animation?r(b,B):B()}}),20)},p.hide=function(){clearTimeout(y),y=setTimeout((function(){if(b&&null!==b&&b.classList.contains("show")){if(h.call(i,d),d.defaultPrevented)return;b.classList.remove("show"),A.animation?r(b,I):I()}}),A.delay)},p.dispose=function(){p.hide(),H(),delete i.Popover},(i=m(t)).Popover&&i.Popover.dispose();var D=i.getAttribute("data-trigger"),X=i.getAttribute("data-animation"),R=i.getAttribute("data-placement"),W=i.getAttribute("data-dismissible"),O=i.getAttribute("data-delay"),j=i.getAttribute("data-container");s='',l=f("show","popover"),c=f("shown","popover"),d=f("hide","popover"),u=f("hidden","popover");var z=m(g.container),U=m(j),q=i.closest(".modal"),F=i.closest(".fixed-top"),Y=i.closest(".fixed-bottom");A.template=g.template?g.template:null,A.trigger=g.trigger?g.trigger:D||"hover",A.animation=g.animation&&"fade"!==g.animation?g.animation:X||"fade",A.placement=g.placement?g.placement:R||"top",A.delay=parseInt(g.delay||O,10)||200,A.dismissible=!(!g.dismissible&&"true"!==W),A.container=z||U||F||Y||q||document.body,o="bs-popover-"+A.placement,n=k(),((a=N())||A.template)&&(i.Popover||H(1),i.Popover=p)}function H(t,e){var i,n,a,o,s,l=e||{},r=this,c={};function d(){var t,e,s;(a=o.getElementsByTagName("A"),n.scrollTop=n.isWindow?N().y:i.scrollTop,n.length!==a.length||g()!==n.scrollHeight)&&(n.items=[],n.offsets=[],n.scrollHeight=g(),n.maxScroll=n.scrollHeight-(n.isWindow?window.innerHeight:i.getBoundingClientRect().height),Array.from(a).forEach((function(i){t=i.getAttribute("href"),(e=t&&"#"===t.charAt(0)&&"#"!==t.slice(-1)&&m(t))&&(n.items.push(i),s=e.getBoundingClientRect(),n.offsets.push((n.isWindow?s.top+n.scrollTop:e.offsetTop)-c.offset))})),n.length=n.items.length)}function u(t){var e=t?"addEventListener":"removeEventListener";s[e]("scroll",r.refresh,L),window[e]("resize",r.refresh,L)}function g(){return s.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}function p(){Array.from(a).map((function(t){return t.classList.contains("active")&&t.classList.remove("active")}))}function v(t){var e,a=t;p(),n.activeItem=a,a.classList.add("active");for(var o=[];a.parentNode!==document.body;)((e=(a=a.parentNode).classList).contains("dropdown-menu")||e.contains("nav"))&&o.push(a);o.forEach((function(t){var e=t.previousElementSibling;e&&!e.classList.contains("active")&&e.classList.add("active")})),h.call(i,f("activate","scrollspy",{relatedTarget:n.activeItem}))}r.refresh=function(){if(d(),n.scrollTop>=n.maxScroll){var t=n.items[n.length-1];n.activeItem!==t&&v(t)}else{if(n.activeItem&&n.scrollTop0)return n.activeItem=null,void p();for(var e=n.length;e>-1;)n.activeItem!==n.items[e]&&n.scrollTop>=n.offsets[e]&&(void 0===n.offsets[e+1]||n.scrollTop1&&(g=t[t.length-1]):g=t[0],g}function P(){return m(C().getAttribute("href"))}function H(t){t.preventDefault(),u=t.currentTarget,a.isAnimating||T.show()}T.show=function(){if(!(u=u||n).classList.contains("active")){if(v=m(u.getAttribute("href")),g=C(),p=P(),c=f("hide","tab",{relatedTarget:u}),h.call(g,c),c.defaultPrevented)return;a.isAnimating=!0,g.classList.remove("active"),g.setAttribute("aria-selected","false"),u.classList.add("active"),u.setAttribute("aria-selected","true"),o&&(n.parentNode.classList.contains("dropdown-menu")?o.classList.contains("active")||o.classList.add("active"):o.classList.contains("active")&&o.classList.remove("active")),p.classList.contains("fade")?(p.classList.remove("show"),r(p,N)):N()}},T.dispose=function(){n.removeEventListener("click",H,!1),delete n.Tab},(n=m(t)).Tab&&n.Tab.dispose();var M=n.getAttribute("data-height");a=n.closest(".nav"),o=a&&m(".dropdown-toggle",a);var S=!(!e||!1===A.height||"false"===M);a.isAnimating=!1,n.Tab||n.addEventListener("click",H,!1),S&&(E=P().parentNode),n.Tab=T}function S(t,e){var i,n,a,o,s,l,c=e||{},d=this,u=0,g={};function p(){n.classList.remove("showing"),n.classList.add("show"),h.call(n,s),g.autohide&&d.hide()}function v(){n.classList.add("hide"),h.call(n,l)}function L(){n.classList.remove("show"),g.animation?r(n,v):v()}function b(){clearTimeout(u),i.removeEventListener("click",d.hide,!1),delete i.Toast}d.show=function(){if(n&&!n.classList.contains("show")){if(h.call(n,a),a.defaultPrevented)return;g.animation&&n.classList.add("fade"),n.classList.remove("hide"),y(n),n.classList.add("showing"),g.animation?r(n,p):p()}},d.hide=function(t){if(n&&n.classList.contains("show")){if(h.call(n,o),o.defaultPrevented)return;t?L():u=setTimeout(L,g.delay)}},d.dispose=function(){g.animation?r(n,b):b()},(i=m(t)).Toast&&i.Toast.dispose(),n=i.closest(".toast");var w=i.getAttribute("data-animation"),A=i.getAttribute("data-autohide"),T=i.getAttribute("data-delay");a=f("show","toast"),o=f("hide","toast"),s=f("shown","toast"),l=f("hidden","toast"),g.animation=!1===c.animation||"false"===w?0:1,g.autohide=!1===c.autohide||"false"===A?0:1,g.delay=parseInt(c.delay||T,10)||500,i.Toast||i.addEventListener("click",d.hide,!1),i.Toast=d}function B(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=0,b={};function y(){return i.getAttribute("title")||i.getAttribute("data-title")||i.getAttribute("data-original-title")}function w(t){g&&g.contains(t.target)||t.target===i||i.contains(t.target)||u.hide()}function A(t){var e=t?"addEventListener":"removeEventListener";document[e]("touchstart",w,L),window[e]("resize",u.hide,L)}function T(){A(1),h.call(i,s)}function E(){A(),b.container.removeChild(g),g=null,p=null,h.call(i,c)}function k(t){var e=t?"addEventListener":"removeEventListener";i[e](x,u.show,!1),i[e](v[0],u.show,!1),i[e](v[1],u.hide,!1)}u.show=function(){clearTimeout(p),p=setTimeout((function(){if(null===g){if(h.call(i,o),o.defaultPrevented)return;!1!==function(){if(n=y()){if(g=document.createElement("div"),b.template){var t=document.createElement("div");t.innerHTML=b.template.trim(),g.className=t.firstChild.className,g.innerHTML=t.firstChild.innerHTML,m(".tooltip-inner",g).innerHTML=n.trim()}else{var e=document.createElement("div");e.classList.add("arrow"),g.appendChild(e);var i=document.createElement("div");i.classList.add("tooltip-inner"),g.appendChild(i),i.innerHTML=n}g.style.left="0",g.style.top="0",g.setAttribute("role","tooltip"),g.classList.contains("tooltip")||g.classList.add("tooltip"),g.classList.contains(b.animation)||g.classList.add(b.animation),g.classList.contains(a)||g.classList.add(a),b.container.appendChild(g)}}()&&(C(i,g,b.placement,b.container),g.classList.contains("show")||g.classList.add("show"),b.animation?r(g,T):T())}}),20)},u.hide=function(){clearTimeout(p),p=setTimeout((function(){if(g&&g.classList.contains("show")){if(h.call(i,l),l.defaultPrevented)return;g.classList.remove("show"),b.animation?r(g,E):E()}}),b.delay)},u.toggle=function(){g?u.hide():u.show()},u.dispose=function(){k(),u.hide(),i.setAttribute("title",i.getAttribute("data-original-title")),i.removeAttribute("data-original-title"),delete i.Tooltip},(i=m(t)).Tooltip&&i.Tooltip.dispose();var N=i.getAttribute("data-animation"),P=i.getAttribute("data-placement"),H=i.getAttribute("data-delay"),M=i.getAttribute("data-container"),S=m(d.container),B=m(M),I=i.closest(".modal");o=f("show","tooltip"),s=f("shown","tooltip"),l=f("hide","tooltip"),c=f("hidden","tooltip");var D=i.closest(".fixed-top"),X=i.closest(".fixed-bottom");b.animation=d.animation&&"fade"!==d.animation?d.animation:N||"fade",b.placement=d.placement?d.placement:P||"top",b.template=d.template?d.template:null,b.delay=parseInt(d.delay||H,10)||200,b.container=S||B||D||X||I||document.body,a="bs-tooltip-"+b.placement,(n=y())&&(i.Tooltip||(i.setAttribute("data-original-title",n),i.removeAttribute("title"),k(1)),i.Tooltip=u)}var I={};function D(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=I[t][0],n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return new i(t)}))}))}I.Alert=[g,'[data-dismiss="alert"]'],I.Button=[p,'[data-toggle="buttons"]'],I.Carousel=[w,'[data-ride="carousel"]'],I.Collapse=[A,'[data-toggle="collapse"]'],I.Dropdown=[E,'[data-toggle="dropdown"]'],I.Modal=[k,'[data-toggle="modal"]'],I.Popover=[P,'[data-toggle="popover"],[data-tip="popover"]'],I.ScrollSpy=[H,'[data-spy="scroll"]'],I.Tab=[M,'[data-toggle="tab"]'],I.Toast=[S,'[data-dismiss="toast"]'],I.Tooltip=[B,'[data-toggle="tooltip"],[data-tip="tooltip"]'],document.body?D():document.addEventListener("DOMContentLoaded",(function t(){D(),document.removeEventListener("DOMContentLoaded",t,!1)}),!1);return{Alert:g,Button:p,Carousel:w,Collapse:A,Dropdown:E,Modal:k,Popover:P,ScrollSpy:H,Tab:M,Toast:S,Tooltip:B,initCallback:D,removeDataAPI:function(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=t,n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return t[i].dispose()}))}))},componentsInit:I,Version:"4.1.0alpha3"}})); +// Native JavaScript for Bootstrap v4.1.0alpha4 | 2022 © dnp_theme | MIT-License +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BSN=e()}(this,(function(){"use strict";var t=document.head,e="webkitTransition"in t.style||"transition"in t.style,i="webkitTransition"in t.style?"webkitTransitionEnd":"transitionend",n="webkitTransition"in t.style?"webkitTransitionDelay":"transitionDelay",a="webkitTransition"in t.style?"webkitTransitionProperty":"transitionProperty";function o(t,e){var i=getComputedStyle(t);return e in i?i[e]:""}var s="webkitTransition"in t.style?"webkitTransitionDuration":"transitionDuration";function l(t){var i=o(t,a),n=o(t,s),l=n.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(n)*l:0;return Number.isNaN(r)?0:r}function r(t,s){var r=0,c=new Event(i),d=l(t),u=function(t){var i=o(t,a),s=o(t,n),l=s.includes("ms")?1:1e3,r=e&&i&&"none"!==i?parseFloat(s)*l:0;return Number.isNaN(r)?0:r}(t);if(e&&d){var m=function(e){e.target===t&&(s.apply(t,[e]),t.removeEventListener(i,m),r=1)};t.addEventListener(i,m),setTimeout((function(){r||t.dispatchEvent(c)}),d+u+17)}else s.apply(t,[c])}function c(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}var d=[Document,Node,Element,HTMLElement],u=[Element,HTMLElement];function m(t,e){var i="string"==typeof t,n=e&&d.some((function(t){return e instanceof t}))?e:c();return!i&&u.some((function(e){return t instanceof e}))?t:i?n.querySelector(t):null}function f(t,e,i){var n=new CustomEvent(t+".bs."+e,{cancelable:!0});return void 0!==i&&Object.keys(i).forEach((function(t){Object.defineProperty(n,t,{value:i[t]})})),n}function h(t){this&&this.dispatchEvent(t)}function g(t){var e,i,n=this,a=f("close","alert"),o=f("closed","alert");function s(t){e[t?"addEventListener":"removeEventListener"]("click",l,!1)}function l(t){i=t&&t.target.closest(".alert"),(e=m('[data-dismiss="alert"]',i))&&i&&(e===t.target||e.contains(t.target))&&n.close()}function c(){s(),i.parentNode.removeChild(i),h.call(i,o)}n.close=function(){if(i&&e&&i.classList.contains("show")){if(h.call(i,a),a.defaultPrevented)return;n.dispose(),i.classList.remove("show"),i.classList.contains("fade")?r(i,c):c()}},n.dispose=function(){s(),delete e.Alert},e=m(t),i=e.closest(".alert"),e.Alert&&e.Alert.dispose(),e.Alert||s(1),n.element=e,e.Alert=n}function p(t){var e,i,n=f("change","button");function a(t){var a=t.target,o=a.closest("LABEL"),s=null;"LABEL"===a.tagName?s=a:o&&(s=o);var l=s&&s.getElementsByTagName("INPUT")[0];if(l){if(h.call(l,n),h.call(e,n),"checkbox"===l.type){if(n.defaultPrevented)return;l.checked?(s.classList.remove("active"),l.getAttribute("checked"),l.removeAttribute("checked"),l.checked=!1):(s.classList.add("active"),l.getAttribute("checked"),l.setAttribute("checked","checked"),l.checked=!0),e.toggled||(e.toggled=!0)}if("radio"===l.type&&!e.toggled){if(n.defaultPrevented)return;(!l.checked||0===t.screenX&&0===t.screenY)&&(s.classList.add("active"),s.classList.add("focus"),l.setAttribute("checked","checked"),l.checked=!0,e.toggled=!0,Array.from(i).forEach((function(t){var e=t.getElementsByTagName("INPUT")[0];t!==s&&t.classList.contains("active")&&(h.call(e,n),t.classList.remove("active"),e.removeAttribute("checked"),e.checked=!1)})))}setTimeout((function(){e.toggled=!1}),50)}}function o(t){32===(t.which||t.keyCode)&&t.target===document.activeElement&&a(t)}function s(t){32===(t.which||t.keyCode)&&t.preventDefault()}function l(t){if("INPUT"===t.target.tagName){var e="focusin"===t.type?"add":"remove";t.target.closest(".btn").classList[e]("focus")}}function r(t){var i=t?"addEventListener":"removeEventListener";e[i]("click",a,!1),e[i]("keyup",o,!1),e[i]("keydown",s,!1),e[i]("focusin",l,!1),e[i]("focusout",l,!1)}this.dispose=function(){r(),delete e.Button},(e=m(t)).Button&&e.Button.dispose(),(i=e.getElementsByClassName("btn")).length&&(e.Button||r(1),e.toggled=!1,e.Button=this,Array.from(i).forEach((function(t){var e=m("input:checked",t);!t.classList.contains("active")&&e&&t.classList.add("active"),t.classList.contains("active")&&!e&&t.classList.remove("active")})))}var v="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],L={passive:!0};var b=function(t){var e=function(t,e){var i=t.getBoundingClientRect(),n=i.width,a=i.height,o=i.top,s=i.right,l=i.bottom,r=i.left,c=1,d=1;if(e&&t instanceof HTMLElement){var u=t.offsetWidth,m=t.offsetHeight;c=u>0&&Math.round(n)/u||1,d=m>0&&Math.round(a)/m||1}return{width:n/c,height:a/d,top:o/d,right:s/c,bottom:l/d,left:r/c,x:r/c,y:o/d}}(t),i=e.top,n=e.bottom;return i<=c(t).documentElement.clientHeight&&n>=0},y=function(t){return t.offsetHeight};function w(t,e){var i,n,a,o,s,c,d,u,g,p,w,A,T,E=e||{},k=this;function x(){!1===c.interval||o.classList.contains("paused")||(o.classList.add("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null))}function N(){!1!==c.interval&&o.classList.contains("paused")&&(o.classList.remove("paused"),s.isSliding||(clearInterval(s.timer),s.timer=null,k.cycle()))}function C(t){if(t.preventDefault(),!s.isSliding){var e=t.target;e&&!e.classList.contains("active")&&e.getAttribute("data-slide-to")&&(s.index=+e.getAttribute("data-slide-to"),k.slideTo(s.index))}}function P(t){if(t.preventDefault(),!s.isSliding){var e=t.currentTarget||t.srcElement;e===w?s.index+=1:e===p&&(s.index-=1),k.slideTo(s.index)}}function H(t){var e=t.which;if(!s.isSliding){switch(e){case 39:s.index+=1;break;case 37:s.index-=1;break;default:return}k.slideTo(s.index)}}function M(t){var e=t?"addEventListener":"removeEventListener";c.pause&&c.interval&&(o[e](v[0],x,!1),o[e](v[1],N,!1),o[e]("touchstart",x,L),o[e]("touchend",N,L)),c.touch&&g.length>1&&o[e]("touchstart",B,L),w&&w[e]("click",P,!1),p&&p[e]("click",P,!1),A&&A[e]("click",C,!1),c.keyboard&&window[e]("keydown",H,!1)}function S(t){var e=t?"addEventListener":"removeEventListener";o[e]("touchmove",I,L),o[e]("touchend",D,L)}function B(t){s.isTouch||(s.touchPosition.startX=t.changedTouches[0].pageX,o.contains(t.target)&&(s.isTouch=!0,S(1)))}function I(t){s.isTouch?(s.touchPosition.currentX=t.changedTouches[0].pageX,"touchmove"===t.type&&t.changedTouches.length>1&&t.preventDefault()):t.preventDefault()}function D(t){if(s.isTouch&&!s.isSliding&&(s.touchPosition.endX=s.touchPosition.currentX||t.changedTouches[0].pageX,s.isTouch)){if((!o.contains(t.target)||!o.contains(t.relatedTarget))&&Math.abs(s.touchPosition.startX-s.touchPosition.endX)<75)return;s.touchPosition.currentXs.touchPosition.startX&&(s.index-=1),s.isTouch=!1,k.slideTo(s.index),S()}}function X(t){Array.from(T).forEach((function(t){return t.classList.remove("active")})),T[t]&&T[t].classList.add("active")}function R(t){if(s.touchPosition){var e=s.index,i=t&&t.target!==g[e]?1e3*t.elapsedTime+100:20,n=k.getActiveIndex(),a="left"===s.direction?"next":"prev";s.isSliding&&setTimeout((function(){s.touchPosition&&(s.isSliding=!1,g[e].classList.add("active"),g[n].classList.remove("active"),g[e].classList.remove("carousel-item-"+a),g[e].classList.remove("carousel-item-"+s.direction),g[n].classList.remove("carousel-item-"+s.direction),h.call(o,u),document.hidden||!c.interval||o.classList.contains("paused")||k.cycle())}),i)}}if(k.cycle=function(){s.timer&&(clearInterval(s.timer),s.timer=null),s.timer=setInterval((function(){var t=s.index||k.getActiveIndex();b(o)&&(t+=1,k.slideTo(t))}),c.interval)},k.slideTo=function(t){if(!s.isSliding){var e=k.getActiveIndex(),i=t;if(e!==i){ei||e===g.length-1&&0===i)&&(s.direction="right"),i<0?i=g.length-1:i>=g.length&&(i=0);var n="left"===s.direction?"next":"prev",a={relatedTarget:g[i],direction:s.direction,from:e,to:i};d=f("slide","carousel",a),u=f("slid","carousel",a),h.call(o,d),d.defaultPrevented||(s.index=i,s.isSliding=!0,clearInterval(s.timer),s.timer=null,X(i),l(g[i])&&o.classList.contains("slide")?(g[i].classList.add("carousel-item-"+n),y(g[i]),g[i].classList.add("carousel-item-"+s.direction),g[e].classList.add("carousel-item-"+s.direction),r(g[i],R)):(g[i].classList.add("active"),y(g[i]),g[e].classList.remove("active"),setTimeout((function(){s.isSliding=!1,c.interval&&o&&!o.classList.contains("paused")&&k.cycle(),h.call(o,u)}),100)))}}},k.getActiveIndex=function(){return Array.from(g).indexOf(o.getElementsByClassName("carousel-item active")[0])||0},k.dispose=function(){var t=["left","right","prev","next"];Array.from(g).forEach((function(e,i){e.classList.contains("active")&&X(i),t.forEach((function(t){return e.classList.remove("carousel-item-"+t)}))})),clearInterval(s.timer),M(),s={},c={},delete o.Carousel},(o=m(t)).Carousel&&o.Carousel.dispose(),g=o.getElementsByClassName("carousel-item"),i=o.getElementsByClassName("carousel-control-prev"),p=i[0],n=o.getElementsByClassName("carousel-control-next"),w=n[0],a=o.getElementsByClassName("carousel-indicators"),A=a[0],T=A&&A.getElementsByTagName("LI")||[],!(g.length<2)){var W=o.getAttribute("data-interval"),O="false"===W?0:+W,j="false"===o.getAttribute("data-touch")?0:1,z="hover"===o.getAttribute("data-pause")||!1,U="true"===o.getAttribute("data-keyboard")||!1,q=E.interval,F=E.touch;(c={}).keyboard=!0===E.keyboard||U,c.pause=!("hover"!==E.pause&&!z)&&"hover",c.touch=F||j,c.interval=5e3,"number"==typeof q?c.interval=q:!1===q||0===O||!1===O?c.interval=0:Number.isNaN(O)||(c.interval=O),k.getActiveIndex()<0&&(g.length&&g[0].classList.add("active"),T.length&&X(0)),(s={}).direction="left",s.index=0,s.timer=null,s.isSliding=!1,s.isTouch=!1,s.touchPosition={startX:0,currentX:0,endX:0},M(1),c.interval&&k.cycle(),o.Carousel=k}}function A(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=null;function v(t,e){h.call(t,l),l.defaultPrevented||(t.isAnimating=!0,t.style.height=t.scrollHeight+"px",t.classList.remove("collapse"),t.classList.remove("show"),t.classList.add("collapsing"),y(t),t.style.height="0px",r(t,(function(){t.isAnimating=!1,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),t.classList.remove("collapsing"),t.classList.add("collapse"),t.style.height="",h.call(t,c)})))}u.toggle=function(t){(t&&"A"===t.target.tagName||"A"===i.tagName)&&t.preventDefault(),(i.contains(t.target)||t.target===i)&&(p.classList.contains("show")?u.hide():u.show())},u.hide=function(){p.isAnimating||(v(p,i),i.classList.add("collapsed"))},u.show=function(){var t,e,l;g&&(t=g.getElementsByClassName("collapse show"),n=t[0],a=n&&(m('[data-target="#'+n.id+'"]',g)||m('[href="#'+n.id+'"]',g))),p.isAnimating||(a&&n!==p&&(v(n,a),a.classList.add("collapsed")),e=p,l=i,h.call(e,o),o.defaultPrevented||(e.isAnimating=!0,e.classList.add("collapsing"),e.classList.remove("collapse"),e.style.height=e.scrollHeight+"px",r(e,(function(){e.isAnimating=!1,e.setAttribute("aria-expanded","true"),l.setAttribute("aria-expanded","true"),e.classList.remove("collapsing"),e.classList.add("collapse"),e.classList.add("show"),e.style.height="",h.call(e,s)}))),i.classList.remove("collapsed"))},u.dispose=function(){i.removeEventListener("click",u.toggle,!1),delete i.Collapse},(i=m(t)).Collapse&&i.Collapse.dispose();var L=i.getAttribute("data-parent");o=f("show","collapse"),s=f("shown","collapse"),l=f("hide","collapse"),c=f("hidden","collapse"),null!==(p=m(d.target||i.getAttribute("data-target")||i.getAttribute("href")))&&(p.isAnimating=!1);var b=d.parent||L;g=b?i.closest(b):null,i.Collapse||i.addEventListener("click",u.toggle,!1),i.Collapse=u}var T=function(t){return t.focus()};function E(t,e){var i,n,a,o,s,l,r,c,d=this,u=null,g=[];function p(t){(t.hasAttribute("href")&&"#"===t.href.slice(-1)||t.parentNode&&t.parentNode.hasAttribute("href")&&"#"===t.parentNode.href.slice(-1))&&this.preventDefault()}function v(){var t=i.open?"addEventListener":"removeEventListener";document[t]("click",L,!1),document[t]("keydown",y,!1),document[t]("keyup",w,!1),document[t]("focus",L,!1)}function L(t){var e=t.target;if(e.getAttribute){var n=e&&e.getAttribute("data-toggle")||e.parentNode&&e.parentNode.getAttribute&&e.parentNode.getAttribute("data-toggle");("focus"!==t.type||e!==i&&e!==r&&!r.contains(e))&&(e!==r&&!r.contains(e)||!c&&!n)&&(u=e===i||i.contains(e)?i:null,d.hide(),p.call(t,e))}}function b(t){u=i,d.show(),p.call(t,t.target)}function y(t){var e=t.which||t.keyCode;38!==e&&40!==e||t.preventDefault()}function w(t){var e=t.which||t.keyCode,n=document.activeElement,a=n===i,o=r.contains(n),s=n.parentNode===r||n.parentNode.parentNode===r,l=g.indexOf(n);s&&(a?l=0:38===e?l=l>1?l-1:0:40===e&&(l=l=d,w=m.top+c/2+g/2>=u,A=m.top-c<0,T=m.left-r<0,E=m.top+c+g>=u,k=m.left+r+h>=d,x=i;x="right"===(x="left"===(x="bottom"===(x="top"===(x=("left"===x||"right"===x)&&T&&k?"top":x)&&A?"bottom":x)&&E?"top":x)&&T?"right":x)&&k?"left":x,-1===e.className.indexOf(x)&&(e.className=e.className.replace(/\b(top|bottom|left|right)+/,x));var C=v.offsetWidth,P=v.offsetHeight;"left"===x||"right"===x?(o="left"===x?m.left+f.x-r-(p?C:0):m.left+f.x+h,L?(a=m.top+f.y,s=g/2-C):w?(a=m.top+f.y-c+g,s=c-g/2-C):(a=m.top+f.y-c/2+g/2,s=c/2-(p?.9*P:P/2))):"top"!==x&&"bottom"!==x||(a="top"===x?m.top+f.y-c-(p?P:0):m.top+f.y+g,b?(o=0,l=m.left+h/2-C):y?(o=d-1.01*r,l=r-(d-m.left)+h/2-C/2):(o=m.left+f.x-r/2+h/2,l=r/2-(p?C:C/2))),e.style.top=a+"px",e.style.left=o+"px",s&&(v.style.top=s+"px"),l&&(v.style.left=l+"px")}function P(t,e){var i,n,a,o,s,l,c,d,u,g=e||{},p=this,b=null,y=0,w=/(iPhone|iPod|iPad)/.test(navigator.userAgent),A={};function T(t){null!==b&&t.target===m(".close",b)&&p.hide()}function E(t){return g[t]||i.dataset[t]||null}function k(){return E("title")}function N(){return E("content")}function P(){null===b&&i.focus()}function H(t){var e=t?"addEventListener":"removeEventListener";"hover"===A.trigger?(i[e](x,p.show),i[e](v[0],p.show),A.dismissible||i[e](v[1],p.hide)):"click"===A.trigger?i[e](A.trigger,p.toggle):"focus"===A.trigger&&(w&&i[e]("click",P,!1),i[e](A.trigger,p.toggle))}function M(t){b&&b.contains(t.target)||t.target===i||i.contains(t.target)||p.hide()}function S(t){var e=t?"addEventListener":"removeEventListener";A.dismissible?document[e]("click",T,!1):("focus"===A.trigger&&i[e]("blur",p.hide),"hover"===A.trigger&&document[e]("touchstart",M,L)),window[e]("resize",p.hide,L)}function B(){S(1),h.call(i,c)}function I(){S(),A.container.removeChild(b),y=null,b=null,h.call(i,u)}p.toggle=function(){null===b?p.show():p.hide()},p.show=function(){clearTimeout(y),y=setTimeout((function(){if(null===b){if(h.call(i,l),l.defaultPrevented)return;!function(){n=k(),a=(a=N())?a.trim():null,b=document.createElement("div");var t=document.createElement("div");if(t.classList.add("arrow"),b.appendChild(t),null!==a&&null===A.template){if(b.setAttribute("role","tooltip"),null!==n){var e=document.createElement("h3");e.classList.add("popover-header"),e.innerHTML=A.dismissible?n+s:n,b.appendChild(e)}var i=document.createElement("div");i.classList.add("popover-body"),i.innerHTML=A.dismissible&&null===n?a+s:a,b.appendChild(i)}else{var l=document.createElement("div");l.innerHTML=A.template.trim(),b.className=l.firstChild.className,b.innerHTML=l.firstChild.innerHTML;var r=m(".popover-header",b),c=m(".popover-body",b);n&&r&&(r.innerHTML=n.trim()),a&&c&&(c.innerHTML=a.trim())}A.container.appendChild(b),b.style.display="block",b.classList.contains("popover")||b.classList.add("popover"),b.classList.contains(A.animation)||b.classList.add(A.animation),b.classList.contains(o)||b.classList.add(o)}(),C(i,b,A.placement,A.container),b.classList.contains("show")||b.classList.add("show"),A.animation?r(b,B):B()}}),20)},p.hide=function(){clearTimeout(y),y=setTimeout((function(){if(b&&null!==b&&b.classList.contains("show")){if(h.call(i,d),d.defaultPrevented)return;b.classList.remove("show"),A.animation?r(b,I):I()}}),A.delay)},p.dispose=function(){p.hide(),H(),delete i.Popover},(i=m(t)).Popover&&i.Popover.dispose();var D=i.getAttribute("data-trigger"),X=i.getAttribute("data-animation"),R=i.getAttribute("data-placement"),W=i.getAttribute("data-dismissible"),O=i.getAttribute("data-delay"),j=i.getAttribute("data-container");s='',l=f("show","popover"),c=f("shown","popover"),d=f("hide","popover"),u=f("hidden","popover");var z=m(g.container),U=m(j),q=i.closest(".modal"),F=i.closest(".fixed-top"),Y=i.closest(".fixed-bottom");A.template=g.template?g.template:null,A.trigger=g.trigger?g.trigger:D||"hover",A.animation=g.animation&&"fade"!==g.animation?g.animation:X||"fade",A.placement=g.placement?g.placement:R||"top",A.delay=parseInt(g.delay||O,10)||200,A.dismissible=!(!g.dismissible&&"true"!==W),A.container=z||U||F||Y||q||document.body,o="bs-popover-"+A.placement,n=k(),((a=N())||A.template)&&(i.Popover||H(1),i.Popover=p)}function H(t,e){var i,n,a,o,s,l=e||{},r=this,c={};function d(){var t,e,s;(a=o.getElementsByTagName("A"),n.scrollTop=n.isWindow?N().y:i.scrollTop,n.length!==a.length||g()!==n.scrollHeight)&&(n.items=[],n.offsets=[],n.scrollHeight=g(),n.maxScroll=n.scrollHeight-(n.isWindow?window.innerHeight:i.getBoundingClientRect().height),Array.from(a).forEach((function(i){t=i.getAttribute("href"),(e=t&&"#"===t.charAt(0)&&"#"!==t.slice(-1)&&m(t))&&(n.items.push(i),s=e.getBoundingClientRect(),n.offsets.push((n.isWindow?s.top+n.scrollTop:e.offsetTop)-c.offset))})),n.length=n.items.length)}function u(t){var e=t?"addEventListener":"removeEventListener";s[e]("scroll",r.refresh,L),window[e]("resize",r.refresh,L)}function g(){return s.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}function p(){Array.from(a).map((function(t){return t.classList.contains("active")&&t.classList.remove("active")}))}function v(t){var e,a=t;p(),n.activeItem=a,a.classList.add("active");for(var o=[];a.parentNode!==document.body;)((e=(a=a.parentNode).classList).contains("dropdown-menu")||e.contains("nav"))&&o.push(a);o.forEach((function(t){var e=t.previousElementSibling;e&&!e.classList.contains("active")&&e.classList.add("active")})),h.call(i,f("activate","scrollspy",{relatedTarget:n.activeItem}))}r.refresh=function(){if(d(),n.scrollTop>=n.maxScroll){var t=n.items[n.length-1];n.activeItem!==t&&v(t)}else{if(n.activeItem&&n.scrollTop0)return n.activeItem=null,void p();for(var e=n.length;e>-1;)n.activeItem!==n.items[e]&&n.scrollTop>=n.offsets[e]&&(void 0===n.offsets[e+1]||n.scrollTop1&&(g=t[t.length-1]):g=t[0],g}function P(){return m(C().getAttribute("href"))}function H(t){t.preventDefault(),u=t.currentTarget,a.isAnimating||T.show()}T.show=function(){if(!(u=u||n).classList.contains("active")){if(v=m(u.getAttribute("href")),g=C(),p=P(),c=f("hide","tab",{relatedTarget:u}),h.call(g,c),c.defaultPrevented)return;a.isAnimating=!0,g.classList.remove("active"),g.setAttribute("aria-selected","false"),u.classList.add("active"),u.setAttribute("aria-selected","true"),o&&(n.parentNode.classList.contains("dropdown-menu")?o.classList.contains("active")||o.classList.add("active"):o.classList.contains("active")&&o.classList.remove("active")),p.classList.contains("fade")?(p.classList.remove("show"),r(p,N)):N()}},T.dispose=function(){n.removeEventListener("click",H,!1),delete n.Tab},(n=m(t)).Tab&&n.Tab.dispose();var M=n.getAttribute("data-height");a=n.closest(".nav"),o=a&&m(".dropdown-toggle",a);var S=!(!e||!1===A.height||"false"===M);a.isAnimating=!1,n.Tab||n.addEventListener("click",H,!1),S&&(E=P().parentNode),n.Tab=T}function S(t,e){var i,n,a,o,s,l,c=e||{},d=this,u=0,g={};function p(){n.classList.remove("showing"),n.classList.add("show"),h.call(n,s),g.autohide&&d.hide()}function v(){n.classList.add("hide"),h.call(n,l)}function L(){n.classList.remove("show"),g.animation?r(n,v):v()}function b(){clearTimeout(u),i.removeEventListener("click",d.hide,!1),delete i.Toast}d.show=function(){if(n&&!n.classList.contains("show")){if(h.call(n,a),a.defaultPrevented)return;g.animation&&n.classList.add("fade"),n.classList.remove("hide"),y(n),n.classList.add("showing"),g.animation?r(n,p):p()}},d.hide=function(t){if(n&&n.classList.contains("show")){if(h.call(n,o),o.defaultPrevented)return;t?L():u=setTimeout(L,g.delay)}},d.dispose=function(){g.animation?r(n,b):b()},(i=m(t)).Toast&&i.Toast.dispose(),n=i.closest(".toast");var w=i.getAttribute("data-animation"),A=i.getAttribute("data-autohide"),T=i.getAttribute("data-delay");a=f("show","toast"),o=f("hide","toast"),s=f("shown","toast"),l=f("hidden","toast"),g.animation=!1===c.animation||"false"===w?0:1,g.autohide=!1===c.autohide||"false"===A?0:1,g.delay=parseInt(c.delay||T,10)||500,i.Toast||i.addEventListener("click",d.hide,!1),i.Toast=d}function B(t,e){var i,n,a,o,s,l,c,d=e||{},u=this,g=null,p=0,b={};function y(){return i.getAttribute("title")||i.getAttribute("data-title")||i.getAttribute("data-original-title")}function w(t){g&&g.contains(t.target)||t.target===i||i.contains(t.target)||u.hide()}function A(t){var e=t?"addEventListener":"removeEventListener";document[e]("touchstart",w,L),window[e]("resize",u.hide,L)}function T(){A(1),h.call(i,s)}function E(){A(),b.container.removeChild(g),g=null,p=null,h.call(i,c)}function k(t){var e=t?"addEventListener":"removeEventListener";i[e](x,u.show,!1),i[e](v[0],u.show,!1),i[e](v[1],u.hide,!1)}u.show=function(){clearTimeout(p),p=setTimeout((function(){if(null===g){if(h.call(i,o),o.defaultPrevented)return;!1!==function(){if(n=y()){if(g=document.createElement("div"),b.template){var t=document.createElement("div");t.innerHTML=b.template.trim(),g.className=t.firstChild.className,g.innerHTML=t.firstChild.innerHTML,m(".tooltip-inner",g).innerHTML=n.trim()}else{var e=document.createElement("div");e.classList.add("arrow"),g.appendChild(e);var i=document.createElement("div");i.classList.add("tooltip-inner"),g.appendChild(i),i.innerHTML=n}g.style.left="0",g.style.top="0",g.setAttribute("role","tooltip"),g.classList.contains("tooltip")||g.classList.add("tooltip"),g.classList.contains(b.animation)||g.classList.add(b.animation),g.classList.contains(a)||g.classList.add(a),b.container.appendChild(g)}}()&&(C(i,g,b.placement,b.container),g.classList.contains("show")||g.classList.add("show"),b.animation?r(g,T):T())}}),20)},u.hide=function(){clearTimeout(p),p=setTimeout((function(){if(g&&g.classList.contains("show")){if(h.call(i,l),l.defaultPrevented)return;g.classList.remove("show"),b.animation?r(g,E):E()}}),b.delay)},u.toggle=function(){g?u.hide():u.show()},u.dispose=function(){k(),u.hide(),i.setAttribute("title",i.getAttribute("data-original-title")),i.removeAttribute("data-original-title"),delete i.Tooltip},(i=m(t)).Tooltip&&i.Tooltip.dispose();var N=i.getAttribute("data-animation"),P=i.getAttribute("data-placement"),H=i.getAttribute("data-delay"),M=i.getAttribute("data-container"),S=m(d.container),B=m(M),I=i.closest(".modal");o=f("show","tooltip"),s=f("shown","tooltip"),l=f("hide","tooltip"),c=f("hidden","tooltip");var D=i.closest(".fixed-top"),X=i.closest(".fixed-bottom");b.animation=d.animation&&"fade"!==d.animation?d.animation:N||"fade",b.placement=d.placement?d.placement:P||"top",b.template=d.template?d.template:null,b.delay=parseInt(d.delay||H,10)||200,b.container=S||B||D||X||I||document.body,a="bs-tooltip-"+b.placement,(n=y())&&(i.Tooltip||(i.setAttribute("data-original-title",n),i.removeAttribute("title"),k(1)),i.Tooltip=u)}var I={};function D(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=I[t][0],n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return new i(t)}))}))}I.Alert=[g,'[data-dismiss="alert"]'],I.Button=[p,'[data-toggle="buttons"]'],I.Carousel=[w,'[data-ride="carousel"]'],I.Collapse=[A,'[data-toggle="collapse"]'],I.Dropdown=[E,'[data-toggle="dropdown"]'],I.Modal=[k,'[data-toggle="modal"]'],I.Popover=[P,'[data-toggle="popover"],[data-tip="popover"]'],I.ScrollSpy=[H,'[data-spy="scroll"]'],I.Tab=[M,'[data-toggle="tab"]'],I.Toast=[S,'[data-dismiss="toast"]'],I.Tooltip=[B,'[data-toggle="tooltip"],[data-tip="tooltip"]'],document.body?D():document.addEventListener("DOMContentLoaded",(function t(){D(),document.removeEventListener("DOMContentLoaded",t,!1)}),!1);return{Alert:g,Button:p,Carousel:w,Collapse:A,Dropdown:E,Modal:k,Popover:P,ScrollSpy:H,Tab:M,Toast:S,Tooltip:B,initCallback:D,removeDataAPI:function(t){var e=t instanceof Element?t:document;Object.keys(I).forEach((function(t){var i,n;i=t,n=e.querySelectorAll(I[t][1]),Array.from(n).map((function(t){return t[i].dispose()}))}))},componentsInit:I,Version:"4.1.0alpha4"}})); diff --git a/dist/bootstrap-native.esm.js b/dist/bootstrap-native.esm.js index 05c4a8ed..558e8158 100644 --- a/dist/bootstrap-native.esm.js +++ b/dist/bootstrap-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -98,7 +98,7 @@ function getElementTransitionDuration(element) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function on(element, eventName, handler, options) { +function on$b(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -111,7 +111,7 @@ function on(element, eventName, handler, options) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function off(element, eventName, handler, options) { +function off$b(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -137,11 +137,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$b(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$b(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -337,6 +337,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `fade` class. */ @@ -458,7 +566,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -525,6 +633,7 @@ class BaseComponent { // ================ const alertSelector = `.${alertString}`; const alertDismissSelector = `[${dataBsDismiss}="${alertString}"]`; +const { on: on$a, off: off$a } = EventListener; /** * Static method which returns an existing `Alert` instance associated @@ -569,7 +678,7 @@ function alertTransitionEnd(self) { * @param {boolean=} add when `true`, event listener is added */ function toggleAlertHandler(self, add) { - const action = add ? on : off; + const action = add ? on$a : off$a; const { dismiss } = self; if (dismiss) action(dismiss, mouseclickEvent, self.close); } @@ -690,6 +799,7 @@ const buttonComponent = 'Button'; // BUTTON PRIVATE GC // ================= const buttonSelector = `[${dataBsToggle}="${buttonString}"]`; +const { on: on$9, off: off$9 } = EventListener; /** * Static method which returns an existing `Button` instance associated @@ -713,7 +823,7 @@ const buttonInitCallback = (element) => new Button(element); * @param {boolean=} add when `true`, event listener is added */ function toggleButtonHandler(self, add) { - const action = add ? on : off; + const action = add ? on$9 : off$9; action(self.element, mouseclickEvent, self.toggle); } @@ -1086,7 +1196,7 @@ const carouselSelector = `[data-bs-ride="${carouselString}"]`; const carouselItem = `${carouselString}-item`; const dataBsSlideTo = 'data-bs-slide-to'; const dataBsSlide = 'data-bs-slide'; - +const { on: on$8, off: off$8 } = EventListener; const pausedClass = 'paused'; const carouselDefaults = { @@ -1137,10 +1247,10 @@ function carouselTransitionEndHandler(self) { const directionClass = direction === 'left' ? 'start' : 'end'; addClass(slides[index], activeClass); - removeClass(slides[activeItem], activeClass); - removeClass(slides[index], `${carouselItem}-${orientation}`); removeClass(slides[index], `${carouselItem}-${directionClass}`); + + removeClass(slides[activeItem], activeClass); removeClass(slides[activeItem], `${carouselItem}-${directionClass}`); dispatchEvent(element, carouselSlidEvent); @@ -1348,7 +1458,7 @@ function activateCarouselIndicator(self, pageIndex) { */ function toggleCarouselTouchHandlers(self, add) { const { element } = self; - const action = add ? on : off; + const action = add ? on$8 : off$8; action(element, touchmoveEvent, carouselTouchMoveHandler, passiveHandler); action(element, touchendEvent, carouselTouchEndHandler, passiveHandler); } @@ -1365,7 +1475,7 @@ function toggleCarouselHandlers(self, add) { const { touch, pause, interval, keyboard, } = options; - const action = add ? on : off; + const action = add ? on$8 : off$8; if (pause && interval) { action(element, mouseenterEvent, carouselPauseHandler); @@ -1669,6 +1779,7 @@ const collapseComponent = 'Collapse'; const collapseSelector = `.${collapseString}`; const collapseToggleSelector = `[${dataBsToggle}="${collapseString}"]`; const collapseDefaults = { parent: null }; +const { on: on$7, off: off$7 } = EventListener; /** * Static method which returns an existing `Collapse` instance associated @@ -1781,7 +1892,7 @@ function collapseContent(self) { * @param {boolean=} add when `true`, the event listener is added */ function toggleCollapseHandler(self, add) { - const action = add ? on : off; + const action = add ? on$7 : off$7; const { triggers } = self; if (triggers.length) { @@ -2021,6 +2132,7 @@ const [ dropendString, ] = dropdownMenuClasses; const dropdownSelector = `[${dataBsToggle}="${dropdownString}"]`; +const { on: on$6, off: off$6 } = EventListener; /** * Static method which returns an existing `Dropdown` instance associated @@ -2196,7 +2308,7 @@ function getMenuItems(menu) { */ function toggleDropdownDismiss(self) { const { element } = self; - const action = self.open ? on : off; + const action = self.open ? on$6 : off$6; const doc = getDocument(element); action(doc, mouseclickEvent, dropdownDismissHandler); @@ -2219,7 +2331,7 @@ function toggleDropdownDismiss(self) { * @param {boolean=} add when `true`, it will add the event listener */ function toggleDropdownHandler(self, add) { - const action = add ? on : off; + const action = add ? on$6 : off$6; action(self.element, mouseclickEvent, dropdownClickHandler); } @@ -2815,6 +2927,7 @@ const modalSelector = `.${modalString}`; const modalToggleSelector = `[${dataBsToggle}="${modalString}"]`; const modalDismissSelector = `[${dataBsDismiss}="${modalString}"]`; const modalStaticClass = `${modalString}-static`; +const { on: on$5, off: off$5 } = EventListener; const modalDefaults = { backdrop: true, // boolean|string @@ -2872,7 +2985,7 @@ function setModalScrollbar(self) { * @param {boolean=} add when `true`, event listeners are added */ function toggleModalDismiss(self, add) { - const action = add ? on : off; + const action = add ? on$5 : off$5; const { element } = self; action(element, mouseclickEvent, modalDismissHandler); // @ts-ignore @@ -2886,7 +2999,7 @@ function toggleModalDismiss(self, add) { * @param {boolean=} add when `true`, event listener is added */ function toggleModalHandler(self, add) { - const action = add ? on : off; + const action = add ? on$5 : off$5; const { triggers } = self; if (triggers.length) { @@ -3232,6 +3345,7 @@ const offcanvasSelector = `.${offcanvasString}`; const offcanvasToggleSelector = `[${dataBsToggle}="${offcanvasString}"]`; const offcanvasDismissSelector = `[${dataBsDismiss}="${offcanvasString}"]`; const offcanvasTogglingClass = `${offcanvasString}-toggling`; +const { on: on$4, off: off$4 } = EventListener; const offcanvasDefaults = { backdrop: true, // boolean @@ -3281,7 +3395,7 @@ function setOffCanvasScrollbar(self) { * @param {boolean=} add when *true*, listeners are added */ function toggleOffcanvasEvents(self, add) { - const action = add ? on : off; + const action = add ? on$4 : off$4; self.triggers.forEach((btn) => action(btn, mouseclickEvent, offcanvasTriggerHandler)); } @@ -3292,7 +3406,7 @@ function toggleOffcanvasEvents(self, add) { * @param {boolean=} add when *true* listeners are added */ function toggleOffCanvasDismiss(self, add) { - const action = add ? on : off; + const action = add ? on$4 : off$4; const doc = getDocument(self.element); action(doc, keydownEvent, offcanvasKeyDismissHandler); action(doc, mouseclickEvent, offcanvasDismissHandler); @@ -4004,15 +4118,21 @@ function getUID(element, key) { let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -4150,6 +4270,7 @@ function isVisibleTip(tip, container) { // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; +const { on: on$3, off: off$3 } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated @@ -4199,7 +4320,7 @@ function disposeTooltipComplete(self) { * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipAction(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; const { element } = self; action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler); @@ -4248,7 +4369,7 @@ function tooltipHiddenAction(self) { * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; // @ts-ignore -- btn is only for dismissible popover const { element, options, btn } = self; const { trigger, dismissible } = options; @@ -4293,7 +4414,7 @@ function toggleTooltipHandlers(self, add) { * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipOpenHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; const { element, options, offsetParent } = self; const { container } = options; const { offsetHeight, scrollHeight } = container; @@ -4310,8 +4431,8 @@ function toggleTooltipOpenHandlers(self, add) { } // dismiss tooltips inside modal / offcanvas - if (parentModal) on(parentModal, `hide.bs.${modalString}`, self.hide); - if (parentOffcanvas) on(parentOffcanvas, `hide.bs.${offcanvasString}`, self.hide); + if (parentModal) on$3(parentModal, `hide.bs.${modalString}`, self.hide); + if (parentOffcanvas) on$3(parentOffcanvas, `hide.bs.${offcanvasString}`, self.hide); } /** @@ -4690,6 +4811,7 @@ const scrollspyComponent = 'ScrollSpy'; // SCROLLSPY PRIVATE GC // ==================== const scrollspySelector = '[data-bs-spy="scroll"]'; +const { on: on$2, off: off$2 } = EventListener; const scrollspyDefaults = { offset: 10, @@ -4835,7 +4957,7 @@ function activate(self, item) { * @param {boolean=} add when `true`, listener is added */ function toggleSpyHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$2 : off$2; // @ts-ignore action(self.scrollTarget, scrollEvent, self.refresh, passiveHandler); } @@ -4979,6 +5101,7 @@ const tabComponent = 'Tab'; // TAB PRIVATE GC // ================ const tabSelector = `[${dataBsToggle}="${tabString}"]`; +const { on: on$1, off: off$1 } = EventListener; /** * Static method which returns an existing `Tab` instance associated @@ -5127,7 +5250,7 @@ function getActiveTab(self) { * @param {boolean=} add when `true`, event listener is added */ function toggleTabHandler(self, add) { - const action = add ? on : off; + const action = add ? on$1 : off$1; action(self.element, mouseclickEvent, tabClickHandler); } @@ -5259,6 +5382,7 @@ const toastDismissSelector = `[${dataBsDismiss}="${toastString}"]`; const showingClass = 'showing'; /** @deprecated */ const hideClass = 'hide'; +const { on, off } = EventListener; const toastDefaults = { animation: true, @@ -5508,10 +5632,10 @@ function one(element, eventName, handler, options) { const handlerWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, eventName, handlerWrapper, options); + off$b(element, eventName, handlerWrapper, options); } }; - on(element, eventName, handlerWrapper, options); + on$b(element, eventName, handlerWrapper, options); } /** diff --git a/dist/bootstrap-native.esm.min.js b/dist/bootstrap-native.esm.min.js index cd1ae937..69f4cc49 100644 --- a/dist/bootstrap-native.esm.min.js +++ b/dist/bootstrap-native.esm.min.js @@ -1,2 +1,2 @@ -// Native JavaScript for Bootstrap v4.1.0alpha3 | 2022 © dnp_theme | MIT-License -function t(t,e){const n=getComputedStyle(t);return e in n?n[e]:""}function e(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDuration"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}function n(t,e,n,o){const s=o||!1;t.addEventListener(e,n,s)}function o(t,e,n,o){const s=o||!1;t.removeEventListener(e,n,s)}function s(s,i){let a=0;const l=new Event("transitionend"),r=e(s),c=function(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDelay"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}(s);if(r){const t=e=>{e.target===s&&(i.apply(s,[e]),o(s,"transitionend",t),a=1)};n(s,"transitionend",t),setTimeout(()=>{a||s.dispatchEvent(l)},r+c+17)}else i.apply(s,[l])}function i(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}const a=[Document,Node,Element,HTMLElement],l=[Element,HTMLElement];function r(t,e){const n="string"==typeof t,o=e&&a.some(t=>e instanceof t)?e:i();return!n&&l.some(e=>t instanceof e)?t:n?o.querySelector(t):null}function c(t,e){return t?t.closest(e)||c(t.getRootNode().host,e):null}const d=(t,e)=>Object.assign(t,e);function h(t,e){return t.classList.contains(e)}function u(t,e){t.classList.remove(e)}const f=(t,e)=>t.dispatchEvent(e),p=new Map,g={set:(t,e,n)=>{const o=r(t);if(!o)return;p.has(e)||p.set(e,new Map);p.get(e).set(o,n)},getAllFor:t=>p.get(t)||null,get:(t,e)=>{const n=r(t),o=g.getAllFor(e);return n&&o&&o.get(n)||null},remove:(t,e)=>{const n=r(t),o=p.get(e);o&&n&&(o.delete(n),0===o.size&&p.delete(e))}},m=(t,e)=>g.get(t,e);function b(t,e){const n=new CustomEvent(t,{cancelable:!0,bubbles:!0});return e instanceof Object&&d(n,e),n}const v=(t,e)=>t.getAttribute(e);function w(t){return"true"===t||"false"!==t&&(Number.isNaN(+t)?""===t||"null"===t?null:t:+t)}const y=t=>Object.keys(t),T=t=>t.toLowerCase();class E{constructor(t,e){const n=this,o=r(t);if(!o)throw Error(`${n.name} Error: "${t}" is not a valid selector.`);n.options={};const s=g.get(o,n.name);s&&s.dispose(),n.element=o,n.defaults&&Object.keys(n.defaults).length&&(n.options=function(t,e,n,o){const s={...t.dataset},i={},a={};return y(s).forEach(t=>{const e=o&&t.includes(o)?t.replace(o,"").replace(/[A-Z]/,t=>T(t)):t;a[e]=w(s[t])}),y(n).forEach(t=>{n[t]=w(n[t])}),y(e).forEach(o=>{i[o]=o in n?n[o]:o in a?a[o]:"title"===o?v(t,"title"):e[o]}),i}(o,n.defaults,e||{},"bs")),g.set(o,n.name,n)}get version(){return"4.1.0alpha3"}get name(){return this.constructor.name}get defaults(){return this.constructor.defaults}dispose(){const t=this;g.remove(t.element,t.name),y(t).forEach(e=>{t[e]=null})}}const x=t=>m(t,"Alert"),H=b("close.bs.alert"),k=b("closed.bs.alert");function A(t){const{element:e}=t;P(t),f(e,k),t.dispose(),e.remove()}function P(t,e){const s=e?n:o,{dismiss:i}=t;i&&s(i,"click",t.close)}class M extends E{constructor(t){super(t);const{element:e}=this;this.dismiss=r('[data-bs-dismiss="alert"]',e),P(this,!0)}get name(){return"Alert"}close(t){const e=t?x(c(this,".alert")):this;if(!e)return;const{element:n}=e;if(h(n,"show")){if(f(n,H),H.defaultPrevented)return;u(n,"show"),h(n,"fade")?s(n,()=>A(e)):A(e)}}dispose(){P(this),super.dispose()}}d(M,{selector:".alert",init:t=>new M(t),getInstance:x});const L=(t,e,n)=>t.setAttribute(e,n);function N(t,e){t.classList.add(e)}const D="data-bs-toggle",C=t=>m(t,"Button");function S(t,e){(e?n:o)(t.element,"click",t.toggle)}class I extends E{constructor(t){super(t);const{element:e}=this;this.isActive=h(e,"active"),L(e,"aria-pressed",""+!!this.isActive),S(this,!0)}get name(){return"Button"}toggle(t){t&&t.preventDefault();const e=t?C(this):this;if(!e)return;const{element:n}=e;if(h(n,"disabled"))return;e.isActive=h(n,"active");const{isActive:o}=e;(o?u:N)(n,"active"),L(n,"aria-pressed",o?"false":"true")}dispose(){S(this),super.dispose()}}d(I,{selector:'[data-bs-toggle="button"]',init:t=>new I(t),getInstance:C});const R="mouseenter",$="mouseleave";function O(t){if(null==t)return window;if(!(t instanceof Window)){const{ownerDocument:e}=t;return e&&e.defaultView||window}return t}function W(t,e){const{width:n,height:o,top:s,right:i,bottom:a,left:l}=t.getBoundingClientRect();let r=1,c=1;if(e&&t instanceof HTMLElement){const{offsetWidth:e,offsetHeight:s}=t;r=e>0&&Math.round(n)/e||1,c=s>0&&Math.round(o)/s||1}return{width:n/r,height:o/c,top:s/c,right:i/r,bottom:a/c,left:l/r,x:l/r,y:s/c}}function F(t){return i(t).documentElement}const B=t=>{const{top:e,bottom:n}=W(t),{clientHeight:o}=F(t);return e<=o&&n>=0},X=t=>"rtl"===F(t).dir;function j(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).querySelectorAll(t)}function z(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByClassName(t)}const Y=new Map,V=(t,e,n,o)=>{const s=r(t);if(s)if(o&&o.length){Y.has(s)||Y.set(s,new Map);Y.get(s).set(o,setTimeout(e,n))}else Y.set(s,setTimeout(e,n))},q=(t,e)=>{const n=r(t);if(!n)return null;const o=Y.get(n);return e&&e.length&&o&&o.get?o.get(e)||null:o||null},U=(t,e)=>{const n=r(t);if(n)if(e&&e.length){const t=Y.get(n);t&&t.get&&(clearTimeout(t.get(e)),t.delete(e),0===t.size&&Y.delete(n))}else clearTimeout(Y.get(n)),Y.delete(n)},G=t=>t.offsetHeight,Z={passive:!0};function J(t){const e=["data-bs-target","data-bs-parent","data-bs-container","href"],n=i(t);return e.map(e=>{const o=v(t,e);return o?"data-bs-parent"===e?c(t,o):r(o,n):null}).filter(t=>t)[0]}const K="carousel-item",Q={pause:"hover",keyboard:!1,touch:!0,interval:5e3},_=t=>m(t,"Carousel");let tt=0,et=0,nt=0;const ot=b("slide.bs.carousel"),st=b("slid.bs.carousel");function it(){const t=this,e=_(t);!e||e.isPaused||q(t,"paused")||N(t,"paused")}function at(){const t=_(this);t&&t.isPaused&&!q(this,"paused")&&t.cycle()}function lt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||J(this);if(!e)return;const n=_(e);if(!n||n.isAnimating)return;const o=+v(this,"data-bs-slide-to");!this||h(this,"active")||Number.isNaN(o)||n.to(o)}function rt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||J(this),n=e&&_(e);if(!n||n.isAnimating)return;const o=v(this,"data-bs-slide");"next"===o?n.next():"prev"===o&&n.prev()}function ct({code:t}){const[e]=[...j('[data-bs-ride="carousel"]')].filter(t=>B(t)),n=_(e);if(!n)return;const o=X(),s=o?"ArrowLeft":"ArrowRight";t===(o?"ArrowRight":"ArrowLeft")?n.prev():t===s&&n.next()}function dt(t){const e=_(this);e&&!e.isTouch&&(tt=t.changedTouches[0].pageX,this.contains(t.target)&&(e.isTouch=!0,pt(e,!0)))}function ht(t){const{changedTouches:e,type:n}=t,o=_(this);o&&o.isTouch&&(et=e[0].pageX,"touchmove"===n&&e.length>1&&t.preventDefault())}function ut(t){const e=this,n=_(e);if(n&&n.isTouch&&(nt=et||t.changedTouches[0].pageX,n.isTouch)){if((!e.contains(t.target)||!e.contains(t.relatedTarget))&&Math.abs(tt-nt)<75)return;ettt&&(n.index-=1),n.isTouch=!1,n.to(n.index),pt(n)}}function ft(t,e){const{indicators:n}=t;[...n].forEach(t=>u(t,"active")),t.indicators[e]&&N(n[e],"active")}function pt(t,e){const{element:s}=t,i=e?n:o;i(s,"touchmove",ht,Z),i(s,"touchend",ut,Z)}function gt(t,e){const{element:s,options:i,slides:a,controls:l,indicators:r}=t,{touch:c,pause:d,interval:h,keyboard:u}=i,f=e?n:o;d&&h&&(f(s,R,it),f(s,$,at),f(s,"touchstart",it,Z),f(s,"touchend",at,Z)),c&&a.length>1&&f(s,"touchstart",dt,Z),l.length&&l.forEach(t=>{t&&f(t,"click",rt)}),r.length&&r.forEach(t=>{f(t,"click",lt)}),u&&f(O(s),"keydown",ct)}function mt(t){const{slides:e,element:n}=t,o=r(".carousel-item.active",n);return[...e].indexOf(o)}class bt extends E{constructor(t,e){super(t,e);const n=this;n.direction=X()?"right":"left",n.index=0,n.isTouch=!1;const{element:o}=n;n.slides=z(K,o);const{slides:s}=n;if(s.length<2)return;n.controls=[...j("[data-bs-slide]",o),...j(`[data-bs-slide][data-bs-target="#${o.id}"]`)],n.indicator=r(".carousel-indicators",o),n.indicators=[...n.indicator?j("[data-bs-slide-to]",n.indicator):[],...j(`[data-bs-slide-to][data-bs-target="#${o.id}"]`)];const{options:i}=n;n.options.interval=!0===i.interval?Q.interval:i.interval,mt(n)<0&&(s.length&&N(s[0],"active"),n.indicators.length&&ft(n,0)),gt(n,!0),i.interval&&n.cycle()}get name(){return"Carousel"}get defaults(){return Q}get isPaused(){return h(this.element,"paused")}get isAnimating(){return null!==r(".carousel-item-next,.carousel-item-prev",this.element)}cycle(){const t=this,{element:e,options:n,isPaused:o}=t;U(e,"carousel"),o&&(U(e,"paused"),u(e,"paused")),V(e,()=>{!t.isPaused&&B(e)&&(t.index+=1,t.to(t.index))},n.interval,"carousel")}pause(){const{element:t,options:e}=this;!this.isPaused&&e.interval&&(N(t,"paused"),V(t,()=>{},1,"paused"))}next(){const t=this;t.isAnimating||(t.index+=1,t.to(t.index))}prev(){const t=this;t.isAnimating||(t.index-=1,t.to(t.index))}to(t){const n=this,{element:o,slides:a,options:l}=n,r=mt(n),c=X();let p=t;if(n.isAnimating||r===p)return;rp||r===a.length-1&&0===p)&&(n.direction=c?"left":"right");const{direction:g}=n;p<0?p=a.length-1:p>=a.length&&(p=0);const m="left"===g?"next":"prev",b="left"===g?"start":"end",v={relatedTarget:a[p],from:r,to:p,direction:g};d(ot,v),d(st,v),f(o,ot),ot.defaultPrevented||(n.index=p,ft(n,p),e(a[p])&&h(o,"slide")?V(o,()=>{N(a[p],"carousel-item-"+m),G(a[p]),N(a[p],"carousel-item-"+b),N(a[r],"carousel-item-"+b),s(a[p],()=>function(t){const{index:e,direction:n,element:o,slides:s,options:a}=t;if(t.isAnimating&&_(o)){const l=mt(t),r="left"===n?"next":"prev",c="left"===n?"start":"end";N(s[e],"active"),u(s[l],"active"),u(s[e],"carousel-item-"+r),u(s[e],"carousel-item-"+c),u(s[l],"carousel-item-"+c),f(o,st),U(o,"data-bs-slide"),i(o).hidden||!a.interval||t.isPaused||t.cycle()}}(n))},17,"data-bs-slide"):(N(a[p],"active"),u(a[r],"active"),V(o,()=>{U(o,"data-bs-slide"),o&&l.interval&&!n.isPaused&&n.cycle(),f(o,st)},17,"data-bs-slide")))}dispose(){const t=this,{slides:e}=t,n=["start","end","prev","next"];[...e].forEach((e,o)=>{h(e,"active")&&ft(t,o),n.forEach(t=>u(e,"carousel-item-"+t))}),gt(t),super.dispose()}}d(bt,{selector:'[data-bs-ride="carousel"]',init:t=>new bt(t),getInstance:_});const vt={parent:null},wt=t=>m(t,"Collapse"),yt=b("show.bs.collapse"),Tt=b("shown.bs.collapse"),Et=b("hide.bs.collapse"),xt=b("hidden.bs.collapse");function Ht(t){const{element:e,parent:n,triggers:o}=t;f(e,Et),Et.defaultPrevented||(V(e,()=>{},17),n&&V(n,()=>{},17),e.style.height=e.scrollHeight+"px",u(e,"collapse"),u(e,"show"),N(e,"collapsing"),G(e),e.style.height="0px",s(e,()=>{U(e),n&&U(n),o.forEach(t=>L(t,"aria-expanded","false")),u(e,"collapsing"),N(e,"collapse"),e.style.height="",f(e,xt)}))}function kt(t,e){const s=e?n:o,{triggers:i}=t;i.length&&i.forEach(t=>s(t,"click",At))}function At(t){const{target:e}=t,n=e&&c(e,'[data-bs-toggle="collapse"]'),o=n&&J(n),s=o&&wt(o);s&&s.toggle(),n&&"A"===n.tagName&&t.preventDefault()}class Pt extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;this.triggers=[...j('[data-bs-toggle="collapse"]')].filter(t=>J(t)===n),this.parent=r(o.parent),kt(this,!0)}get name(){return"Collapse"}get defaults(){return vt}toggle(){h(this.element,"show")?this.hide():this.show()}hide(){const{triggers:t,element:e}=this;q(e)||(Ht(this),t.length&&t.forEach(t=>N(t,"collapsed")))}show(){const t=this,{element:e,parent:n,triggers:o}=t;let i,a;n&&(i=[...j(".collapse.show",n)].find(t=>wt(t)),a=i&&wt(i)),n&&(!n||q(n))||q(e)||(a&&i!==e&&(Ht(a),a.triggers.forEach(t=>{N(t,"collapsed")})),function(t){const{element:e,parent:n,triggers:o}=t;f(e,yt),yt.defaultPrevented||(V(e,()=>{},17),n&&V(n,()=>{},17),N(e,"collapsing"),u(e,"collapse"),e.style.height=e.scrollHeight+"px",s(e,()=>{U(e),n&&U(n),o.forEach(t=>L(t,"aria-expanded","true")),u(e,"collapsing"),N(e,"collapse"),N(e,"show"),e.style.height="",f(e,Tt)}))}(t),o.length&&o.forEach(t=>u(t,"collapsed")))}dispose(){kt(this),super.dispose()}}d(Pt,{selector:".collapse",init:t=>new Pt(t),getInstance:wt});const Mt="scroll",Lt="resize",Nt="ArrowUp",Dt="ArrowDown",Ct=(t,e)=>t.hasAttribute(e),St=(t,e)=>{d(t.style,e)},It=t=>t.focus(),Rt=["dropdown","dropup","dropstart","dropend"];function $t(t){const e=c(t,"A");return t&&(Ct(t,"href")&&"#"===t.href.slice(-1)||e&&Ct(e,"href")&&"#"===e.href.slice(-1))}const[Ot,Wt,Ft,Bt]=Rt,Xt=`[data-bs-toggle="${Ot}"]`,jt=t=>m(t,"Dropdown"),zt=[Ot,Wt],Yt=[Ft,Bt],Vt=["A","BUTTON"],qt={offset:5,display:"dynamic"},Ut=b("show.bs."+Ot),Gt=b("shown.bs."+Ot),Zt=b("hide.bs."+Ot),Jt=b("hidden.bs."+Ot);function Kt(e){const{element:n,menu:o,parentElement:s,options:i}=e,{offset:a}=i;if("static"===t(o,"position"))return;const l=X(n),r=h(s,"dropdown-menu-end");["margin","top","bottom","left","right"].forEach(t=>{o.style[t]=""});let c=Rt.find(t=>h(s,t))||Ot,u={dropdown:[a,0,0],dropup:[0,0,a],dropstart:l?[-1,0,0,a]:[-1,a,0],dropend:l?[-1,a,0]:[-1,0,0,a]};const f={dropdown:{top:"100%"},dropup:{top:"auto",bottom:"100%"},dropstart:l?{left:"100%",right:"auto"}:{left:"auto",right:"100%"},dropend:l?{left:"auto",right:"100%"}:{left:"100%",right:"auto"},menuEnd:l?{right:"auto",left:0}:{right:0,left:"auto"}},{offsetWidth:p,offsetHeight:g}=o,{clientWidth:m,clientHeight:b}=F(n),{left:v,top:w,width:y,height:T}=W(n),E=v-p-a<0,x=v+p+y+a>=m,H=w+g+a>=b,k=w+g+T+a>=b,A=w-g-a<0,P=(!l&&r||l&&!r)&&v+y-p<0,M=(l&&r||!l&&!r)&&v+p>=m;Yt.includes(c)&&E&&x&&(c=Ot),c===Ft&&(l?x:E)&&(c=Bt),c===Bt&&(l?E:x)&&(c=Ft),c===Wt&&A&&!k&&(c=Ot),c===Ot&&k&&!A&&(c=Wt),Yt.includes(c)&&H&&d(f[c],{top:"auto",bottom:0}),zt.includes(c)&&(P||M)&&v+y+Math.abs(p-y)+at?t+"px":t).join(" "),St(o,f[c]),h(o,"dropdown-menu-end")&&St(o,f.menuEnd)}function Qt(t){const{element:e}=t,s=t.open?n:o,a=i(e);s(a,"click",ee),s(a,"focus",ee),s(a,"keydown",oe),s(a,"keyup",se),"dynamic"===t.options.display&&[Mt,Lt].forEach(t=>{s(O(e),t,ie,Z)})}function _t(t,e){(e?n:o)(t.element,"click",ne)}function te(t){const e=[...Rt,"btn-group","input-group"].map(t=>z(t+" show"),i(t)).find(t=>t.length);return e&&e.length?[...e[0].children].find(t=>Ct(t,D)):null}function ee(t){const{target:e,type:n}=t;if(!e||!e.closest)return;const o=te(e);if(!o)return;const s=jt(o);if(!s)return;const{parentElement:i,menu:a}=s,l=null!==c(e,Xt),r=i&&i.contains(e)&&("form"===e.tagName||null!==c(e,"form"));"click"===n&&$t(e)&&t.preventDefault(),("focus"!==n||e!==o&&e!==a&&!a.contains(e))&&(r||l||s&&s.hide())}function ne(t){const{target:e}=t,n=jt(this);n&&(n.toggle(),e&&$t(e)&&t.preventDefault())}function oe(t){[Dt,Nt].includes(t.code)&&t.preventDefault()}function se(t){const{code:e}=t,n=te(this),o=n&&jt(n),s=n&&i(n).activeElement;if(!o||!s)return;const{menu:a,open:l}=o,r=function(t){return[...t.children].map(t=>{if(t&&Vt.includes(t.tagName))return t;const{firstElementChild:e}=t;return e&&Vt.includes(e.tagName)?e:null}).filter(t=>t)}(a);if(r&&r.length&&[Dt,Nt].includes(e)){let t=r.indexOf(s);s===n?t=0:e===Nt?t=t>1?t-1:0:e===Dt&&(t=t{t.relatedTarget=e}),f(s,Ut),Ut.defaultPrevented||(N(o,"show"),N(s,"show"),L(e,"aria-expanded","true"),Kt(t),t.open=!n,setTimeout(()=>{It(e),Qt(t),f(s,Gt)},1))}hide(){const t=this,{element:e,open:n,menu:o,parentElement:s}=t;[Zt,Jt].forEach(t=>{t.relatedTarget=e}),f(s,Zt),Zt.defaultPrevented||(u(o,"show"),u(s,"show"),L(e,"aria-expanded","false"),t.open=!n,setTimeout(()=>Qt(t),1),f(s,Jt))}dispose(){const{parentElement:t}=this;h(t,"show")&&this.open&&this.hide(),_t(this),super.dispose()}}d(ae,{selector:Xt,init:t=>new ae(t),getInstance:jt});const le=(t,e)=>t.removeAttribute(e);function re(t){return i(t).body}const ce=t=>t instanceof O(t).ShadowRoot||t instanceof ShadowRoot;const de=t=>["TABLE","TD","TH"].includes(t.tagName),he=t=>t instanceof HTMLElement;function ue(e,n){const o=["HTML","BODY"];if(n){let{offsetParent:n}=e;const s=O(e);for(;n&&(de(n)||he(n)&&!["sticky","fixed"].includes(t(n,"position")));)n=n.offsetParent;return(!n||n&&(o.includes(n.tagName)||"static"===t(n,"position")))&&(n=s),n}const s=[];let{parentNode:i}=e;for(;i&&!o.includes(i.nodeName);)i="HTML"===(a=i).nodeName?a:a.assignedSlot||a.parentNode||(ce(a)?a.host:null)||F(a),ce(i)||i.shadowRoot||de(i)||s.push(i);var a;return s.find((e,n)=>"relative"!==t(e,"position")&&s.slice(n+1).every(e=>"static"===t(e,"position"))?e:null)||re(e)}const fe="sticky-top",pe="position-sticky",ge=t=>[...z("fixed-top",t),...z("fixed-bottom",t),...z(fe,t),...z(pe,t),...z("is-fixed",t)];function me(t){const{clientWidth:e}=F(t),{innerWidth:n}=O(t);return Math.abs(n-e)}function be(e,n){const o=re(e),s=parseInt(t(o,"paddingRight"),10),i="hidden"===t(o,"overflow")&&s?0:me(e),a=ge(o);n&&(St(o,{overflow:"hidden",paddingRight:s+i+"px"}),a.length&&a.forEach(e=>{const n=t(e,"paddingRight");if(e.style.paddingRight=parseInt(n,10)+i+"px",[fe,pe].some(t=>h(e,t))){const n=t(e,"marginRight");e.style.marginRight=parseInt(n,10)-i+"px"}}))}const ve="modal-backdrop",we="offcanvas-backdrop",ye=i().createElement("div");function Te(t){return r(".modal.show,.offcanvas.show",i(t))}function Ee(t){const e=t?ve:we;[ve,we].forEach(t=>{u(ye,t)}),N(ye,e)}function xe(t,e,n){Ee(n),t.append(ye),e&&N(ye,"fade")}function He(){N(ye,"show"),G(ye)}function ke(){u(ye,"show")}function Ae(t){Te(t)||(u(ye,"fade"),ye.remove(),function(t){const e=re(t);St(e,{paddingRight:"",overflow:""});const n=ge(e);n.length&&n.forEach(t=>{St(t,{paddingRight:"",marginRight:""})})}(t))}function Pe(e){return e&&"hidden"!==t(e,"visibility")&&null!==e.offsetParent}const Me={backdrop:!0,keyboard:!0},Le=t=>m(t,"Modal"),Ne=b("show.bs.modal"),De=b("shown.bs.modal"),Ce=b("hide.bs.modal"),Se=b("hidden.bs.modal");function Ie(t){const{element:e}=t,n=me(e),{clientHeight:o,scrollHeight:s}=F(e),{clientHeight:i,scrollHeight:a}=e,l=i!==a;if(!l&&n){const t=X(e)?"paddingLeft":"paddingRight";e.style[t]=n+"px"}be(e,l||o!==s)}function Re(t,e){const s=e?n:o,{element:a}=t;s(a,"click",ze),s(O(a),Lt,t.update,Z),s(i(a),"keydown",je)}function $e(t,e){const s=e?n:o,{triggers:i}=t;i.length&&i.forEach(t=>s(t,"click",Xe))}function Oe(t){const{triggers:e,element:n}=t;if(Ae(n),n.style.paddingRight="",e.length){const t=e.find(t=>Pe(t));t&&It(t)}}function We(t){const{element:e,relatedTarget:n}=t;It(e),Re(t,!0),De.relatedTarget=n,f(e,De)}function Fe(t){const{element:e,hasFade:n}=t;e.style.display="block",Ie(t),Te(e)||(re(e).style.overflow="hidden"),N(e,"show"),le(e,"aria-hidden"),L(e,"aria-modal","true"),n?s(e,()=>We(t)):We(t)}function Be(t,e){const{element:n,options:o,relatedTarget:i,hasFade:a}=t;n.style.display="",o.backdrop&&!e&&a&&h(ye,"show")&&!Te(n)?(ke(),s(ye,()=>Oe(t))):Oe(t),Re(t),Se.relatedTarget=i,f(n,Se)}function Xe(t){const{target:e}=t,n=e&&c(this,'[data-bs-toggle="modal"]'),o=n&&J(n),s=o&&Le(o);s&&(n&&"A"===n.tagName&&t.preventDefault(),s.relatedTarget=n,s.toggle())}function je({code:t}){const e=r(".modal.show"),n=e&&Le(e);if(!n)return;const{options:o}=n;o.keyboard&&"Escape"===t&&h(e,"show")&&(n.relatedTarget=null,n.hide())}function ze(t){const n=this,o=Le(n);if(!o||q(n))return;const{options:a,isStatic:l,modalDialog:r}=o,{backdrop:d}=a,{target:h}=t,f=i(n).getSelection().toString().length,p=r.contains(h),g=h&&c(h,'[data-bs-dismiss="modal"]');l&&!p?V(n,()=>{N(n,"modal-static"),s(r,()=>function(t){const{element:n,modalDialog:o}=t,s=e(o)+17;u(n,"modal-static"),V(n,()=>U(n),s)}(o))},17):(g||!f&&!l&&!p&&d)&&(o.relatedTarget=g||null,o.hide(),t.preventDefault())}class Ye extends E{constructor(t,e){super(t,e);const{element:n}=this;this.modalDialog=r(".modal-dialog",n),this.triggers=[...j('[data-bs-toggle="modal"]')].filter(t=>J(t)===n),this.isStatic="static"===this.options.backdrop,this.hasFade=h(n,"fade"),this.relatedTarget=null,this.container=ue(n),$e(this,!0),this.update=this.update.bind(this)}get name(){return"Modal"}get defaults(){return Me}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,hasFade:s,relatedTarget:i,container:a}=t,{backdrop:l}=o;let r=0;if(h(n,"show"))return;if(Ne.relatedTarget=i||null,f(n,Ne),Ne.defaultPrevented)return;const c=Te(n);if(c&&c!==n){(Le(c)||m(c,"Offcanvas")).hide()}l?(c||h(ye,"show")?Ee(!0):xe(a,s,!0),r=e(ye),h(ye,"show")||He(),setTimeout(()=>Fe(t),r)):(Fe(t),c&&h(ye,"show")&&ke())}hide(t){const e=this,{element:n,hasFade:o,relatedTarget:i}=e;h(n,"show")&&(Ce.relatedTarget=i||null,f(n,Ce),Ce.defaultPrevented||(u(n,"show"),L(n,"aria-hidden","true"),le(n,"aria-modal"),o&&!1!==t?s(n,()=>Be(e)):Be(e,t)))}update(){h(this.element,"show")&&Ie(this)}dispose(){this.hide(!0),$e(this),super.dispose()}}d(Ye,{selector:".modal",init:t=>new Ye(t),getInstance:Le});const Ve={backdrop:!0,keyboard:!0,scroll:!1},qe=t=>m(t,"Offcanvas"),Ue=b("show.bs.offcanvas"),Ge=b("shown.bs.offcanvas"),Ze=b("hide.bs.offcanvas"),Je=b("hidden.bs.offcanvas");function Ke(t,e){const s=e?n:o;t.triggers.forEach(t=>s(t,"click",en))}function Qe(t,e){const s=e?n:o,a=i(t.element);s(a,"keydown",on),s(a,"click",nn)}function _e(t){const{element:e,options:n}=t;n.scroll||(!function(t){const{element:e}=t,{clientHeight:n,scrollHeight:o}=F(e);be(e,n!==o)}(t),re(e).style.overflow="hidden"),N(e,"offcanvas-toggling"),N(e,"show"),e.style.visibility="visible",s(e,()=>function(t){const{element:e,triggers:n}=t;u(e,"offcanvas-toggling"),le(e,"aria-hidden"),L(e,"aria-modal","true"),L(e,"role","dialog"),n.length&&n.forEach(t=>L(t,"aria-expanded","true"));f(e,Ge),Qe(t,!0),It(e)}(t))}function tn(t){const{element:e,options:n}=t,o=Te(e);e.blur(),!o&&n.backdrop&&h(ye,"show")?(ke(),s(ye,()=>sn(t))):sn(t)}function en(t){const e=c(this,'[data-bs-toggle="offcanvas"]'),n=e&&J(e),o=n&&qe(n);o&&(o.relatedTarget=e,o.toggle(),e&&"A"===e.tagName&&t.preventDefault())}function nn(t){const e=r(".offcanvas.show",this);if(!e)return;const n=r('[data-bs-dismiss="offcanvas"]',e),o=qe(e);if(!o)return;const{options:s,triggers:a}=o,{target:l}=t,d=c(l,'[data-bs-toggle="offcanvas"]'),h=i(e).getSelection();h&&h.toString().length||!(!e.contains(l)&&s.backdrop&&(!d||d&&!a.includes(d))||n&&n.contains(l))||(o.relatedTarget=n&&n.contains(l)?n:null,o.hide()),d&&"A"===d.tagName&&t.preventDefault()}function on({code:t}){const e=r(".offcanvas.show",this);if(!e)return;const n=qe(e);n&&n.options.keyboard&&"Escape"===t&&(n.relatedTarget=null,n.hide())}function sn(t){const{element:e,triggers:n}=t;if(L(e,"aria-hidden","true"),le(e,"aria-modal"),le(e,"role"),e.style.visibility="",n.length){n.forEach(t=>L(t,"aria-expanded","false"));const t=n.find(t=>Pe(t));t&&It(t)}Ae(e),f(e,Je),u(e,"offcanvas-toggling"),Te(e)||Qe(t)}class an extends E{constructor(t,e){super(t,e);const{element:n}=this;this.triggers=[...j('[data-bs-toggle="offcanvas"]')].filter(t=>J(t)===n),this.container=ue(n),this.relatedTarget=null,Ke(this,!0)}get name(){return"Offcanvas"}get defaults(){return Ve}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,container:s,relatedTarget:i}=t;let a=0;if(h(n,"show"))return;if(Ue.relatedTarget=i,Ge.relatedTarget=i,f(n,Ue),Ue.defaultPrevented)return;const l=Te(n);if(l&&l!==n){(qe(l)||m(l,"Modal")).hide()}o.backdrop?(l?Ee():xe(s,!0),a=e(ye),h(ye,"show")||He(),setTimeout(()=>_e(t),a)):(_e(t),l&&h(ye,"show")&&ke())}hide(t){const e=this,{element:n,relatedTarget:o}=e;h(n,"show")&&(Ze.relatedTarget=o,Je.relatedTarget=o,f(n,Ze),Ze.defaultPrevented||(N(n,"offcanvas-toggling"),u(n,"show"),t?tn(e):s(n,()=>tn(e))))}dispose(){this.hide(!0),Ke(this),super.dispose()}}d(an,{selector:".offcanvas",init:t=>new an(t),getInstance:qe});function ln(t){const e="tooltip"===t;return``}const rn=t=>t&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(e=>t instanceof e);function cn(t,e,n){const o=e instanceof HTMLElement,s=W(t,o&&function(t){const{width:e,height:n}=W(t),{offsetWidth:o,offsetHeight:s}=t;return Math.round(e)!==o||Math.round(n)!==s}(e)),i={x:0,y:0};if(o){const t=W(e,!0);i.x=t.x+e.clientLeft,i.y=t.y+e.clientTop}return{x:s.left+n.x-i.x,y:s.top+n.y-i.y,width:s.width,height:s.height}}var dn={top:"top",bottom:"bottom",left:"start",right:"end"};function hn(e,n){const o=/\b(top|bottom|start|end)+/,{element:s,tooltip:i,options:a,arrow:l,offsetParent:r}=e,c={...dn};St(i,{top:"0px",left:"0px",right:""});const d="Popover"===e.name,h=i.offsetWidth,u=i.offsetHeight,f=X(s);f&&(c.left="end",c.right="start");const p=F(s),g=p.clientWidth,m=p.clientHeight,{container:b}=a;let{placement:v}=a;const{left:w,right:y,top:T}=W(b,!0),E=b.clientWidth,x=Math.abs(E-b.offsetWidth),H=t(b,"position"),k="fixed"===H,A="static"===H,P="sticky"===H&&T===parseFloat(t(b,"top")),M=f&&k?x:0,L=k?E+w+(f?x:0):E+w+(g-y)-1,{width:N,height:D,left:C,right:S,top:I}=W(s,!0),R=function(t){const e="scrollX"in t;return{x:e?t.scrollX:t.scrollLeft,y:e?t.scrollY:t.scrollTop}}(r),{x:$,y:O}=cn(s,r,R);let B,j,z,Y,V,q;St(l,{top:"",left:"",right:""});const U=l.offsetWidth||0,G=l.offsetHeight||0,Z=U/2;let J=I-u-G<0,K=I+u+D+G>=m,Q=C-h-U=L;const tt=["left","right"],et=["top","bottom"];if(J=tt.includes(v)?I+D/2-u/2-G<0:J,K=tt.includes(v)?I+u/2+D/2+G>=m:K,Q=et.includes(v)?C+N/2-h/2=L:_,v=tt.includes(v)&&Q&&_?"top":v,v="top"===v&&J?"bottom":v,v="bottom"===v&&K?"top":v,v="left"===v&&Q?"right":v,v="right"===v&&_?"left":v,i.className.includes(v)||(i.className=i.className.replace(o,c[v])),tt.includes(v))j="left"===v?$-h-(d?U:0):$+N+(d?U:0),J?(B=O,B+=P?-T-R.y:0,Y=D/2-U):K?(B=O-u+D,B+=P?-T-R.y:0,Y=u-D/2-U):(B=O-u/2+D/2,B+=P?-T-R.y:0,Y=u/2-G/2);else if(et.includes(v))if(n&&rn(s)){let t=0,e=0;A?(t=n.pageX,e=n.pageY):(t=n.clientX-w+(k?R.x:0),e=n.clientY-T+(k?R.y:0)),t-=f&&k&&x?x:0,B="top"===v?e-u-U:e+U,n.clientX-h/2L?(j="auto",z=0,q=L-t-Z,q-=k?w+(f?x:0):0):(j=t-h/2,V=h/2-Z)}else B="top"===v?O-u-(d?G:0):O+D+(d?G:0),Q?(j=0,V=$+N/2-Z):_?(j="auto",z=0,q=N/2+L-S-Z):(j=$-h/2+N/2,V=h/2-Z);St(i,{top:B+"px",left:"auto"===j?j:j+"px",right:void 0!==z?z+"px":""}),l instanceof HTMLElement&&(void 0!==Y&&(l.style.top=Y+"px"),void 0!==V?l.style.left=V+"px":void 0!==q&&(l.style.right=q+"px"))}const un={template:ln("tooltip"),title:null,customClass:null,trigger:"hover focus",placement:"top",sanitizeFn:null,animation:!0,delay:200,container:null},fn="focusin",pn="focusout",{userAgentData:gn}=navigator,mn=gn,{userAgent:bn}=navigator,vn=bn,wn=/(iPhone|iPod|iPad)/,yn=mn?mn.brands.some(t=>wn.test(t.brand)):wn.test(vn);let Tn=1;const En=new Map;function xn(t,e,n){if("string"!=typeof e||e.length)if("string"==typeof e){let o=e.trim();"function"==typeof n&&(o=n(o));const s=(new DOMParser).parseFromString(o,"text/html"),{body:i}=s,a=i.children.length?"innerHTML":"innerText";t[a]=i[a]}else e instanceof HTMLElement&&t.append(e)}function Hn(t,e){return t instanceof HTMLElement&&e.contains(t)}let kn=t=>m(t,"Tooltip");function An(t){const{element:e}=t;Nn(t),e.hasAttribute("data-original-title")&&"tooltip"===t.name&&Cn(t)}function Pn(t,e){const s=e?n:o,{element:a}=t;s(i(a),"touchstart",Sn,Z),rn(a)||[Mt,Lt].forEach(e=>{s(O(a),e,t.update,Z)})}function Mn(t){const{element:e}=t,n=b("shown.bs."+T(t.name));Pn(t,!0),f(e,n),U(e,"in")}function Ln(t){const{element:e}=t,n=b("hidden.bs."+T(t.name));Pn(t),function(t){const{element:e,tooltip:n}=t;le(e,"aria-describedby"),n.remove()}(t),f(e,n),U(e,"out")}function Nn(t,e){const s=e?n:o,{element:a,options:l,btn:r}=t,{trigger:c,dismissible:d}=l;if(c.includes("manual"))return;t.enabled=!!e;const h=c.split(" "),u=rn(a);u&&s(a,"mousemove",t.update,Z),h.forEach(e=>{u||"hover"===e?(s(a,"mousedown",t.show),s(a,R,t.show),d&&r?s(r,"click",t.hide):(s(a,$,t.hide),s(i(a),"touchstart",Sn,Z))):"click"===e?s(a,e,d?t.show:t.toggle):"focus"===e&&(s(a,fn,t.show),d||s(a,pn,t.hide),yn&&s(a,"click",()=>It(a)))})}function Dn(t,e){const s=e?n:o,{element:i,options:a,offsetParent:l}=t,{container:r}=a,{offsetHeight:d,scrollHeight:h}=r,u=c(i,".modal"),f=c(i,".offcanvas");if(!rn(i)){const e=O(i),n=d!==h||l!==e?r:e;s(e,Lt,t.update,Z),s(n,Mt,t.update,Z)}u&&n(u,"hide.bs.modal",t.hide),f&&n(f,"hide.bs.offcanvas",t.hide)}function Cn(t,e){const n=["data-original-title","title"],{element:o}=t;L(o,n[e?0:1],e||v(o,n[0])),le(o,n[e?1:0])}function Sn({target:t}){const{tooltip:e,element:n}=this;e.contains(t)||t===n||n.contains(t)||this.hide()}class In extends E{constructor(e,n){super(e,n);const o=this,{element:s}=o,a="Tooltip"===o.name,l=a?"tooltip":"popover",c=a?"Tooltip":"Popover";kn=t=>m(t,c),o.tooltip={},a||(o.btn=null),o.arrow={},o.offsetParent={},o.enabled=!0,o.id=`${l}-${function(t,e){Tn+=1;let n=En.get(t),o=Tn;return n?o=e&&e.length&&n.get&&n.get(e)?n.get(e):n:e&&e.length?(n||(En.set(t,new Map),n=En.get(t)),n.set(e,o)):En.set(t,o),o}(s,l)}`;const{options:d}=o;if(!d.title&&a||!a&&!d.content)return;const u=r(d.container),f=ue(s);o.options.container=!u||u&&["static","relative"].includes(t(u,"position"))?f:u||re(s),un.title=null,Sn.bind(o),o.update=o.update.bind(o),o.show=o.show.bind(o),o.hide=o.hide.bind(o),o.toggle=o.toggle.bind(o),s.hasAttribute("title")&&a&&Cn(o,d.title),function(t){const{id:e,element:n,options:o}=t,{animation:s,customClass:a,sanitizeFn:l,placement:c,dismissible:d}=o;let{title:u,content:f}=o;const p="Tooltip"===t.name,g=p?"tooltip":"popover",{template:m,btnClose:b}=o,v={...dn};X(n)&&(v.left="end",v.right="start");const w=`bs-${g}-${v[c]}`;let y;if([Element,HTMLElement].some(t=>m instanceof t))y=m;else{const t=i(n).createElement("div");xn(t,m,l),y=t.firstElementChild}t.tooltip=y&&y.cloneNode(!0);const{tooltip:T}=t;L(T,"id",e),L(T,"role","tooltip");const E=p?"tooltip-inner":"popover-body",x=p?null:r(".popover-header",T),H=r("."+E,T);t.arrow=r(`.${g}-arrow`,T),d&&(u?u instanceof HTMLElement?xn(u,b,l):u+=b:(x&&x.remove(),f instanceof HTMLElement?xn(f,b,l):f+=b)),p?u&&H&&xn(H,u,l):(u&&x&&xn(x,u,l),f&&H&&xn(H,f,l),t.btn=r(".btn-close",T)),h(T,g)||N(T,g),s&&!h(T,"fade")&&N(T,"fade"),a&&!h(T,a)&&N(T,a),h(T,w)||N(T,w)}(o),Nn(o,!0)}get name(){return"Tooltip"}get defaults(){return un}show(t){const e=this,{options:n,tooltip:o,element:i,id:a}=e,{container:l,animation:r}=n,c=q(i,"out");U(i,"out"),!o||c||Hn(o,l)||V(i,()=>{const n=b("show.bs."+T(e.name));f(i,n),n.defaultPrevented||(l.append(o),L(i,"aria-describedby","#"+a),e.offsetParent=ue(o,!0),e.update(t),Dn(e,!0),h(o,"show")||N(o,"show"),r?s(o,()=>Mn(e)):Mn(e))},17,"in")}hide(){const t=this,{options:e,tooltip:n,element:o}=t,{container:i,animation:a,delay:l}=e;U(o,"in"),n&&Hn(n,i)&&V(o,()=>{const e=b("hide.bs."+T(t.name));f(o,e),e.defaultPrevented||(u(n,"show"),Dn(t),a?s(n,()=>Ln(t)):Ln(t))},l+17,"out")}update(t){hn(this,t)}toggle(t){const{tooltip:e,options:n}=this;Hn(e,n.container)?this.hide():this.show(t)}enable(){const t=this,{enabled:e}=t;e||(Nn(t,!0),t.enabled=!e)}disable(){const t=this,{element:n,tooltip:o,options:s,enabled:i}=t,{animation:a,container:l,delay:r}=s;i&&(Hn(o,l)&&a?(t.hide(),V(n,()=>{Nn(t),U(n,"tooltip")},e(o)+r+17,"tooltip")):Nn(t),t.enabled=!i)}toggleEnabled(){this.enabled?this.disable():this.enable()}dispose(){const t=this,{tooltip:e,options:n}=t;n.animation&&Hn(e,n.container)?(n.delay=0,t.hide(),s(e,()=>An(t))):An(t),super.dispose()}}d(In,{selector:'[data-bs-toggle="tooltip"],[data-tip="tooltip"]',init:t=>new In(t),getInstance:kn,styleTip:hn});const Rn={...un,template:ln("popover"),btnClose:'',dismissible:!1,content:null};class $n extends In{constructor(t,e){super(t,e)}get name(){return"Popover"}get defaults(){return Rn}show(){super.show();const{options:t,btn:e}=this;t.dismissible&&e&&setTimeout(()=>It(e),17)}}function On(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByTagName(t)}d($n,{selector:'[data-bs-toggle="popover"],[data-tip="popover"]',init:t=>new $n(t),getInstance:t=>m(t,"Popover"),styleTip:hn});const Wn={offset:10,target:null},Fn=b("activate.bs.scrollspy");function Bn(t){const{target:e,scrollTarget:n,options:o,itemsLength:s,scrollHeight:a,element:l}=t,{offset:c}=o,d=n instanceof Window,h=e&&On("A",e),u=n&&function(t){return t instanceof HTMLElement?t.scrollHeight:F(t).scrollHeight}(n);if(t.scrollTop=d?n.scrollY:n.scrollTop,h&&(s!==h.length||u!==a)){let e,n,o;t.items=[],t.offsets=[],t.scrollHeight=u,t.maxScroll=t.scrollHeight-function({element:t,scrollTarget:e}){return e instanceof Window?e.innerHeight:W(t).height}(t),[...h].forEach(s=>{e=v(s,"href"),n=e&&"#"===e.charAt(0)&&"#"!==e.slice(-1)&&r(e,i(l)),n&&(t.items.push(s),o=W(n),t.offsets.push((d?o.top+t.scrollTop:n.offsetTop)-c))}),t.itemsLength=t.items.length}}function Xn(t){[...On("A",t)].forEach(t=>{h(t,"active")&&u(t,"active")})}function jn(t,e){const{target:n,element:o}=t;Xn(n),t.activeItem=e,N(e,"active");const s=[];let i=e;for(;i!==re(o);)i=i.parentElement,(h(i,"nav")||h(i,"dropdown-menu"))&&s.push(i);s.forEach(t=>{const e=t.previousElementSibling;e&&!h(e,"active")&&N(e,"active")}),Fn.relatedTarget=e,f(o,Fn)}function zn(t,e){(e?n:o)(t.scrollTarget,Mt,t.refresh,Z)}class Yn extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;if(this.target=r(o.target,i(n)),!this.target)return;const s=O(n);this.scrollTarget=n.clientHeight=o){const e=i[s-1];return void(a!==e&&jn(t,e))}const{offsets:l}=t;if(a&&n0)return t.activeItem=null,void Xn(e);i.forEach((e,o)=>{a!==e&&n>=l[o]&&(void 0===l[o+1]||nnew Yn(t),getInstance:t=>m(t,"ScrollSpy")});const Vn=t=>m(t,"Tab"),qn=b("show.bs.tab"),Un=b("shown.bs.tab"),Gn=b("hide.bs.tab"),Zn=b("hidden.bs.tab"),Jn=new Map;function Kn(t){const{tabContent:e,nav:n}=t;e&&(e.style.height="",u(e,"collapsing")),n&&U(n)}function Qn(t){const{element:e,tabContent:n,nav:o}=t,{currentHeight:i,nextHeight:a}=Jn.get(e),{tab:l}=o&&Jn.get(o);n?i===a?Kn(t):setTimeout(()=>{n.style.height=a+"px",G(n),s(n,()=>Kn(t))},50):o&&U(o),Un.relatedTarget=l,f(e,Un)}function _n(t){const{element:e,content:n,tabContent:o,nav:i}=t,{tab:a,content:l}=i&&Jn.get(i);let r=0;if(o&&([l,n].forEach(t=>N(t,"overflow-hidden")),r=l.scrollHeight),qn.relatedTarget=a,Zn.relatedTarget=e,f(e,qn),!qn.defaultPrevented){if(N(n,"active"),u(l,"active"),o){const t=n.scrollHeight;Jn.set(e,{currentHeight:r,nextHeight:t}),N(o,"collapsing"),o.style.height=r+"px",G(o),[l,n].forEach(t=>u(t,"overflow-hidden"))}n&&h(n,"fade")?setTimeout(()=>{N(n,"show"),s(n,()=>{Qn(t)})},17):Qn(t),f(a,Zn)}}function to(t,e){(e?n:o)(t.element,"click",eo)}function eo(t){const e=Vn(this);e&&(t.preventDefault(),e.show())}class no extends E{constructor(t){super(t);const{element:e}=this,n=J(e);if(!n)return;const o=c(e,".nav"),s=c(n,".tab-content");this.nav=o,this.content=n,this.tabContent=s,this.dropdown=o&&r(`.${Rt[0]}-toggle`,o),to(this,!0)}get name(){return"Tab"}show(){const t=this,{element:e,nav:n,dropdown:o}=t;if(!(n&&q(n)||h(e,"active"))){const{tab:i,content:a}=function(t){const{nav:e}=t,n=z("active",e);let o;return 1!==n.length||Rt.some(t=>h(n[0].parentElement,t))?n.length>1&&(o=n[n.length-1]):[o]=n,{tab:o,content:o?J(o):null}}(t);if(n&&Jn.set(n,{tab:i,content:a}),Gn.relatedTarget=e,f(i,Gn),Gn.defaultPrevented)return;n&&V(n,()=>{},17),u(i,"active"),L(i,"aria-selected","false"),N(e,"active"),L(e,"aria-selected","true"),o&&(h(e.parentNode,"dropdown-menu")?h(o,"active")||N(o,"active"):h(o,"active")&&u(o,"active")),h(a,"fade")?(u(a,"show"),s(a,()=>_n(t))):_n(t)}}dispose(){to(this),super.dispose()}}d(no,{selector:'[data-bs-toggle="tab"]',init:t=>new no(t),getInstance:Vn});const oo={animation:!0,autohide:!0,delay:5e3},so=t=>m(t,"Toast"),io=b("show.bs.toast"),ao=b("shown.bs.toast"),lo=b("hide.bs.toast"),ro=b("hidden.bs.toast");function co(t){const{element:e,options:n}=t;u(e,"showing"),U(e,"showing"),f(e,ao),n.autohide&&V(e,()=>t.hide(),n.delay,"toast")}function ho(t){const{element:e}=t;u(e,"showing"),u(e,"show"),N(e,"hide"),U(e,"toast"),f(e,ro)}function uo(t,e){const s=e?n:o,{element:i,dismiss:a,options:l}=t;a&&s(a,"click",t.hide),l.autohide&&[fn,pn,R,$].forEach(t=>s(i,t,fo))}function fo(t){const e=this,n=so(e),{type:o,relatedTarget:s}=t;n&&e!==s&&!e.contains(s)&&([R,fn].includes(o)?U(e,"toast"):V(e,()=>n.hide(),n.options.delay,"toast"))}class po extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;o.animation&&!h(n,"fade")?N(n,"fade"):!o.animation&&h(n,"fade")&&u(n,"fade"),this.dismiss=r('[data-bs-dismiss="toast"]',n),this.show=this.show.bind(this),this.hide=this.hide.bind(this),uo(this,!0)}get name(){return"Toast"}get defaults(){return oo}show(){const t=this,{element:e}=t;if(e&&!h(e,"show")){if(f(e,io),io.defaultPrevented)return;!function(t){const{element:e,options:n}=t;V(e,()=>{u(e,"hide"),G(e),N(e,"show"),N(e,"showing"),n.animation?s(e,()=>co(t)):co(t)},17,"showing")}(t)}}hide(){const t=this,{element:e}=t;if(e&&h(e,"show")){if(f(e,lo),lo.defaultPrevented)return;!function(t){const{element:e,options:n}=t;N(e,"showing"),n.animation?(G(e),s(e,()=>ho(t))):ho(t)}(t)}}dispose(){const{element:t}=this;h(t,"show")&&u(t,"show"),function(t){U(t.element,"toast"),uo(t)}(this),super.dispose()}}d(po,{selector:".toast",init:t=>new po(t),getInstance:so});const go={Alert:M,Button:I,Carousel:bt,Collapse:Pt,Dropdown:ae,Modal:Ye,Offcanvas:an,Popover:$n,ScrollSpy:Yn,Tab:no,Toast:po,Tooltip:In};function mo(t){const e=[...On("*",t&&a.some(e=>t instanceof e)?t:void 0)];y(go).forEach(t=>{const{init:n,selector:o}=go[t];var s,i;s=n,i=e.filter(t=>function(t,e){return t.matches(e)}(t,o)),[...i].forEach(t=>s(t))})}document.body?mo():function(t,e,s,i){const a=n=>{n.target===t&&(s.apply(t,[n]),o(t,e,a,i))};n(t,e,a,i)}(document,"DOMContentLoaded",()=>mo());const bo={Alert:M,Button:I,Carousel:bt,Collapse:Pt,Dropdown:ae,Modal:Ye,Offcanvas:an,Popover:$n,ScrollSpy:Yn,Tab:no,Toast:po,Tooltip:In,initCallback:mo,removeDataAPI:function(t){const e=t&&a.some(e=>t instanceof e)?t:void 0;y(go).forEach(t=>{!function(t,e){const n=g.getAllFor(t);n&&[...n].forEach(t=>{const[n,o]=t;e&&e.contains(n)&&o.dispose()})}(t,e)})},Version:"4.1.0alpha3"};export{bo as default}; +// Native JavaScript for Bootstrap v4.1.0alpha4 | 2022 © dnp_theme | MIT-License +function t(t,e){const n=getComputedStyle(t);return e in n?n[e]:""}function e(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDuration"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}function n(t,e,n,o){const s=o||!1;t.addEventListener(e,n,s)}function o(t,e,n,o){const s=o||!1;t.removeEventListener(e,n,s)}function s(s,i){let a=0;const l=new Event("transitionend"),r=e(s),c=function(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDelay"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}(s);if(r){const t=e=>{e.target===s&&(i.apply(s,[e]),o(s,"transitionend",t),a=1)};n(s,"transitionend",t),setTimeout(()=>{a||s.dispatchEvent(l)},r+c+17)}else i.apply(s,[l])}function i(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}const a=[Document,Node,Element,HTMLElement],l=[Element,HTMLElement];function r(t,e){const n="string"==typeof t,o=e&&a.some(t=>e instanceof t)?e:i();return!n&&l.some(e=>t instanceof e)?t:n?o.querySelector(t):null}function c(t,e){return t?t.closest(e)||c(t.getRootNode().host,e):null}const d=(t,e)=>Object.assign(t,e);function h(t,e){return t.classList.contains(e)}function u(t,e){t.classList.remove(e)}const f=(t,e)=>t.dispatchEvent(e),p=new Map,g={set:(t,e,n)=>{const o=r(t);if(!o)return;p.has(e)||p.set(e,new Map);p.get(e).set(o,n)},getAllFor:t=>p.get(t)||null,get:(t,e)=>{const n=r(t),o=g.getAllFor(e);return n&&o&&o.get(n)||null},remove:(t,e)=>{const n=r(t),o=p.get(e);o&&n&&(o.delete(n),0===o.size&&p.delete(e))}},m=(t,e)=>g.get(t,e);function b(t,e){const n=new CustomEvent(t,{cancelable:!0,bubbles:!0});return e instanceof Object&&d(n,e),n}const v={};function w(t){const e=this,{type:n}=t;(v[n]?[...v[n]]:[]).forEach(o=>{const[s,i]=o;[...i].forEach(o=>{if(s===e){const[e,i]=o;e.apply(s,[t]),i&&i.once&&y(s,n,e,i)}})})}const y=(t,e,n,o)=>{const s=v[e],i=s&&s.get(t),a=i&&i.get(n),{options:l}=void 0!==a?a:{options:o};i&&i.has(n)&&i.delete(n),!s||i&&i.size||s.delete(t),s&&s.size||delete v[e],i&&i.size||t.removeEventListener(e,w,l)},T={on:(t,e,n,o)=>{v[e]||(v[e]=new Map);const s=v[e];s.has(t)||s.set(t,new Map);const i=s.get(t),{size:a}=i;i&&i.set(n,o),a||t.addEventListener(e,w,o)},off:y,globalListener:w,registry:v},E=(t,e)=>t.getAttribute(e);function x(t){return"true"===t||"false"!==t&&(Number.isNaN(+t)?""===t||"null"===t?null:t:+t)}const H=t=>Object.keys(t),k=t=>t.toLowerCase();class A{constructor(t,e){const n=this,o=r(t);if(!o)throw Error(`${n.name} Error: "${t}" is not a valid selector.`);n.options={};const s=g.get(o,n.name);s&&s.dispose(),n.element=o,n.defaults&&Object.keys(n.defaults).length&&(n.options=function(t,e,n,o){const s={...t.dataset},i={},a={};return H(s).forEach(t=>{const e=o&&t.includes(o)?t.replace(o,"").replace(/[A-Z]/,t=>k(t)):t;a[e]=x(s[t])}),H(n).forEach(t=>{n[t]=x(n[t])}),H(e).forEach(o=>{i[o]=o in n?n[o]:o in a?a[o]:"title"===o?E(t,"title"):e[o]}),i}(o,n.defaults,e||{},"bs")),g.set(o,n.name,n)}get version(){return"4.1.0alpha4"}get name(){return this.constructor.name}get defaults(){return this.constructor.defaults}dispose(){const t=this;g.remove(t.element,t.name),H(t).forEach(e=>{t[e]=null})}}const{on:P,off:M}=T,N=t=>m(t,"Alert"),L=b("close.bs.alert"),D=b("closed.bs.alert");function C(t){const{element:e}=t;S(t),f(e,D),t.dispose(),e.remove()}function S(t,e){const n=e?P:M,{dismiss:o}=t;o&&n(o,"click",t.close)}class I extends A{constructor(t){super(t);const{element:e}=this;this.dismiss=r('[data-bs-dismiss="alert"]',e),S(this,!0)}get name(){return"Alert"}close(t){const e=t?N(c(this,".alert")):this;if(!e)return;const{element:n}=e;if(h(n,"show")){if(f(n,L),L.defaultPrevented)return;u(n,"show"),h(n,"fade")?s(n,()=>C(e)):C(e)}}dispose(){S(this),super.dispose()}}d(I,{selector:".alert",init:t=>new I(t),getInstance:N});const R=(t,e,n)=>t.setAttribute(e,n);function $(t,e){t.classList.add(e)}const O="data-bs-toggle",{on:W,off:F}=T,B=t=>m(t,"Button");function z(t,e){(e?W:F)(t.element,"click",t.toggle)}class X extends A{constructor(t){super(t);const{element:e}=this;this.isActive=h(e,"active"),R(e,"aria-pressed",""+!!this.isActive),z(this,!0)}get name(){return"Button"}toggle(t){t&&t.preventDefault();const e=t?B(this):this;if(!e)return;const{element:n}=e;if(h(n,"disabled"))return;e.isActive=h(n,"active");const{isActive:o}=e;(o?u:$)(n,"active"),R(n,"aria-pressed",o?"false":"true")}dispose(){z(this),super.dispose()}}d(X,{selector:'[data-bs-toggle="button"]',init:t=>new X(t),getInstance:B});const j="mouseenter",Y="mouseleave";function V(t){if(null==t)return window;if(!(t instanceof Window)){const{ownerDocument:e}=t;return e&&e.defaultView||window}return t}function q(t,e){const{width:n,height:o,top:s,right:i,bottom:a,left:l}=t.getBoundingClientRect();let r=1,c=1;if(e&&t instanceof HTMLElement){const{offsetWidth:e,offsetHeight:s}=t;r=e>0&&Math.round(n)/e||1,c=s>0&&Math.round(o)/s||1}return{width:n/r,height:o/c,top:s/c,right:i/r,bottom:a/c,left:l/r,x:l/r,y:s/c}}function U(t){return i(t).documentElement}const G=t=>{const{top:e,bottom:n}=q(t),{clientHeight:o}=U(t);return e<=o&&n>=0},Z=t=>"rtl"===U(t).dir;function J(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).querySelectorAll(t)}function K(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByClassName(t)}const Q=new Map,_=(t,e,n,o)=>{const s=r(t);if(s)if(o&&o.length){Q.has(s)||Q.set(s,new Map);Q.get(s).set(o,setTimeout(e,n))}else Q.set(s,setTimeout(e,n))},tt=(t,e)=>{const n=r(t);if(!n)return null;const o=Q.get(n);return e&&e.length&&o&&o.get?o.get(e)||null:o||null},et=(t,e)=>{const n=r(t);if(n)if(e&&e.length){const t=Q.get(n);t&&t.get&&(clearTimeout(t.get(e)),t.delete(e),0===t.size&&Q.delete(n))}else clearTimeout(Q.get(n)),Q.delete(n)},nt=t=>t.offsetHeight,ot={passive:!0};function st(t){const e=["data-bs-target","data-bs-parent","data-bs-container","href"],n=i(t);return e.map(e=>{const o=E(t,e);return o?"data-bs-parent"===e?c(t,o):r(o,n):null}).filter(t=>t)[0]}const it="carousel-item",{on:at,off:lt}=T,rt={pause:"hover",keyboard:!1,touch:!0,interval:5e3},ct=t=>m(t,"Carousel");let dt=0,ht=0,ut=0;const ft=b("slide.bs.carousel"),pt=b("slid.bs.carousel");function gt(){const t=this,e=ct(t);!e||e.isPaused||tt(t,"paused")||$(t,"paused")}function mt(){const t=ct(this);t&&t.isPaused&&!tt(this,"paused")&&t.cycle()}function bt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||st(this);if(!e)return;const n=ct(e);if(!n||n.isAnimating)return;const o=+E(this,"data-bs-slide-to");!this||h(this,"active")||Number.isNaN(o)||n.to(o)}function vt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||st(this),n=e&&ct(e);if(!n||n.isAnimating)return;const o=E(this,"data-bs-slide");"next"===o?n.next():"prev"===o&&n.prev()}function wt({code:t}){const[e]=[...J('[data-bs-ride="carousel"]')].filter(t=>G(t)),n=ct(e);if(!n)return;const o=Z(),s=o?"ArrowLeft":"ArrowRight";t===(o?"ArrowRight":"ArrowLeft")?n.prev():t===s&&n.next()}function yt(t){const e=ct(this);e&&!e.isTouch&&(dt=t.changedTouches[0].pageX,this.contains(t.target)&&(e.isTouch=!0,Ht(e,!0)))}function Tt(t){const{changedTouches:e,type:n}=t,o=ct(this);o&&o.isTouch&&(ht=e[0].pageX,"touchmove"===n&&e.length>1&&t.preventDefault())}function Et(t){const e=this,n=ct(e);if(n&&n.isTouch&&(ut=ht||t.changedTouches[0].pageX,n.isTouch)){if((!e.contains(t.target)||!e.contains(t.relatedTarget))&&Math.abs(dt-ut)<75)return;htdt&&(n.index-=1),n.isTouch=!1,n.to(n.index),Ht(n)}}function xt(t,e){const{indicators:n}=t;[...n].forEach(t=>u(t,"active")),t.indicators[e]&&$(n[e],"active")}function Ht(t,e){const{element:n}=t,o=e?at:lt;o(n,"touchmove",Tt,ot),o(n,"touchend",Et,ot)}function kt(t,e){const{element:n,options:o,slides:s,controls:i,indicators:a}=t,{touch:l,pause:r,interval:c,keyboard:d}=o,h=e?at:lt;r&&c&&(h(n,j,gt),h(n,Y,mt),h(n,"touchstart",gt,ot),h(n,"touchend",mt,ot)),l&&s.length>1&&h(n,"touchstart",yt,ot),i.length&&i.forEach(t=>{t&&h(t,"click",vt)}),a.length&&a.forEach(t=>{h(t,"click",bt)}),d&&h(V(n),"keydown",wt)}function At(t){const{slides:e,element:n}=t,o=r(".carousel-item.active",n);return[...e].indexOf(o)}class Pt extends A{constructor(t,e){super(t,e);const n=this;n.direction=Z()?"right":"left",n.index=0,n.isTouch=!1;const{element:o}=n;n.slides=K(it,o);const{slides:s}=n;if(s.length<2)return;n.controls=[...J("[data-bs-slide]",o),...J(`[data-bs-slide][data-bs-target="#${o.id}"]`)],n.indicator=r(".carousel-indicators",o),n.indicators=[...n.indicator?J("[data-bs-slide-to]",n.indicator):[],...J(`[data-bs-slide-to][data-bs-target="#${o.id}"]`)];const{options:i}=n;n.options.interval=!0===i.interval?rt.interval:i.interval,At(n)<0&&(s.length&&$(s[0],"active"),n.indicators.length&&xt(n,0)),kt(n,!0),i.interval&&n.cycle()}get name(){return"Carousel"}get defaults(){return rt}get isPaused(){return h(this.element,"paused")}get isAnimating(){return null!==r(".carousel-item-next,.carousel-item-prev",this.element)}cycle(){const t=this,{element:e,options:n,isPaused:o}=t;et(e,"carousel"),o&&(et(e,"paused"),u(e,"paused")),_(e,()=>{!t.isPaused&&G(e)&&(t.index+=1,t.to(t.index))},n.interval,"carousel")}pause(){const{element:t,options:e}=this;!this.isPaused&&e.interval&&($(t,"paused"),_(t,()=>{},1,"paused"))}next(){const t=this;t.isAnimating||(t.index+=1,t.to(t.index))}prev(){const t=this;t.isAnimating||(t.index-=1,t.to(t.index))}to(t){const n=this,{element:o,slides:a,options:l}=n,r=At(n),c=Z();let p=t;if(n.isAnimating||r===p)return;rp||r===a.length-1&&0===p)&&(n.direction=c?"left":"right");const{direction:g}=n;p<0?p=a.length-1:p>=a.length&&(p=0);const m="left"===g?"next":"prev",b="left"===g?"start":"end",v={relatedTarget:a[p],from:r,to:p,direction:g};d(ft,v),d(pt,v),f(o,ft),ft.defaultPrevented||(n.index=p,xt(n,p),e(a[p])&&h(o,"slide")?_(o,()=>{$(a[p],"carousel-item-"+m),nt(a[p]),$(a[p],"carousel-item-"+b),$(a[r],"carousel-item-"+b),s(a[p],()=>function(t){const{index:e,direction:n,element:o,slides:s,options:a}=t;if(t.isAnimating&&ct(o)){const l=At(t),r="left"===n?"next":"prev",c="left"===n?"start":"end";$(s[e],"active"),u(s[e],"carousel-item-"+r),u(s[e],"carousel-item-"+c),u(s[l],"active"),u(s[l],"carousel-item-"+c),f(o,pt),et(o,"data-bs-slide"),i(o).hidden||!a.interval||t.isPaused||t.cycle()}}(n))},17,"data-bs-slide"):($(a[p],"active"),u(a[r],"active"),_(o,()=>{et(o,"data-bs-slide"),o&&l.interval&&!n.isPaused&&n.cycle(),f(o,pt)},17,"data-bs-slide")))}dispose(){const t=this,{slides:e}=t,n=["start","end","prev","next"];[...e].forEach((e,o)=>{h(e,"active")&&xt(t,o),n.forEach(t=>u(e,"carousel-item-"+t))}),kt(t),super.dispose()}}d(Pt,{selector:'[data-bs-ride="carousel"]',init:t=>new Pt(t),getInstance:ct});const Mt={parent:null},{on:Nt,off:Lt}=T,Dt=t=>m(t,"Collapse"),Ct=b("show.bs.collapse"),St=b("shown.bs.collapse"),It=b("hide.bs.collapse"),Rt=b("hidden.bs.collapse");function $t(t){const{element:e,parent:n,triggers:o}=t;f(e,It),It.defaultPrevented||(_(e,()=>{},17),n&&_(n,()=>{},17),e.style.height=e.scrollHeight+"px",u(e,"collapse"),u(e,"show"),$(e,"collapsing"),nt(e),e.style.height="0px",s(e,()=>{et(e),n&&et(n),o.forEach(t=>R(t,"aria-expanded","false")),u(e,"collapsing"),$(e,"collapse"),e.style.height="",f(e,Rt)}))}function Ot(t,e){const n=e?Nt:Lt,{triggers:o}=t;o.length&&o.forEach(t=>n(t,"click",Wt))}function Wt(t){const{target:e}=t,n=e&&c(e,'[data-bs-toggle="collapse"]'),o=n&&st(n),s=o&&Dt(o);s&&s.toggle(),n&&"A"===n.tagName&&t.preventDefault()}class Ft extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;this.triggers=[...J('[data-bs-toggle="collapse"]')].filter(t=>st(t)===n),this.parent=r(o.parent),Ot(this,!0)}get name(){return"Collapse"}get defaults(){return Mt}toggle(){h(this.element,"show")?this.hide():this.show()}hide(){const{triggers:t,element:e}=this;tt(e)||($t(this),t.length&&t.forEach(t=>$(t,"collapsed")))}show(){const t=this,{element:e,parent:n,triggers:o}=t;let i,a;n&&(i=[...J(".collapse.show",n)].find(t=>Dt(t)),a=i&&Dt(i)),n&&(!n||tt(n))||tt(e)||(a&&i!==e&&($t(a),a.triggers.forEach(t=>{$(t,"collapsed")})),function(t){const{element:e,parent:n,triggers:o}=t;f(e,Ct),Ct.defaultPrevented||(_(e,()=>{},17),n&&_(n,()=>{},17),$(e,"collapsing"),u(e,"collapse"),e.style.height=e.scrollHeight+"px",s(e,()=>{et(e),n&&et(n),o.forEach(t=>R(t,"aria-expanded","true")),u(e,"collapsing"),$(e,"collapse"),$(e,"show"),e.style.height="",f(e,St)}))}(t),o.length&&o.forEach(t=>u(t,"collapsed")))}dispose(){Ot(this),super.dispose()}}d(Ft,{selector:".collapse",init:t=>new Ft(t),getInstance:Dt});const Bt="scroll",zt="resize",Xt="ArrowUp",jt="ArrowDown",Yt=(t,e)=>t.hasAttribute(e),Vt=(t,e)=>{d(t.style,e)},qt=t=>t.focus(),Ut=["dropdown","dropup","dropstart","dropend"];function Gt(t){const e=c(t,"A");return t&&(Yt(t,"href")&&"#"===t.href.slice(-1)||e&&Yt(e,"href")&&"#"===e.href.slice(-1))}const[Zt,Jt,Kt,Qt]=Ut,_t=`[data-bs-toggle="${Zt}"]`,{on:te,off:ee}=T,ne=t=>m(t,"Dropdown"),oe=[Zt,Jt],se=[Kt,Qt],ie=["A","BUTTON"],ae={offset:5,display:"dynamic"},le=b("show.bs."+Zt),re=b("shown.bs."+Zt),ce=b("hide.bs."+Zt),de=b("hidden.bs."+Zt);function he(e){const{element:n,menu:o,parentElement:s,options:i}=e,{offset:a}=i;if("static"===t(o,"position"))return;const l=Z(n),r=h(s,"dropdown-menu-end");["margin","top","bottom","left","right"].forEach(t=>{o.style[t]=""});let c=Ut.find(t=>h(s,t))||Zt,u={dropdown:[a,0,0],dropup:[0,0,a],dropstart:l?[-1,0,0,a]:[-1,a,0],dropend:l?[-1,a,0]:[-1,0,0,a]};const f={dropdown:{top:"100%"},dropup:{top:"auto",bottom:"100%"},dropstart:l?{left:"100%",right:"auto"}:{left:"auto",right:"100%"},dropend:l?{left:"auto",right:"100%"}:{left:"100%",right:"auto"},menuEnd:l?{right:"auto",left:0}:{right:0,left:"auto"}},{offsetWidth:p,offsetHeight:g}=o,{clientWidth:m,clientHeight:b}=U(n),{left:v,top:w,width:y,height:T}=q(n),E=v-p-a<0,x=v+p+y+a>=m,H=w+g+a>=b,k=w+g+T+a>=b,A=w-g-a<0,P=(!l&&r||l&&!r)&&v+y-p<0,M=(l&&r||!l&&!r)&&v+p>=m;se.includes(c)&&E&&x&&(c=Zt),c===Kt&&(l?x:E)&&(c=Qt),c===Qt&&(l?E:x)&&(c=Kt),c===Jt&&A&&!k&&(c=Zt),c===Zt&&k&&!A&&(c=Jt),se.includes(c)&&H&&d(f[c],{top:"auto",bottom:0}),oe.includes(c)&&(P||M)&&v+y+Math.abs(p-y)+at?t+"px":t).join(" "),Vt(o,f[c]),h(o,"dropdown-menu-end")&&Vt(o,f.menuEnd)}function ue(t){const{element:e}=t,n=t.open?te:ee,o=i(e);n(o,"click",ge),n(o,"focus",ge),n(o,"keydown",be),n(o,"keyup",ve),"dynamic"===t.options.display&&[Bt,zt].forEach(t=>{n(V(e),t,we,ot)})}function fe(t,e){(e?te:ee)(t.element,"click",me)}function pe(t){const e=[...Ut,"btn-group","input-group"].map(t=>K(t+" show"),i(t)).find(t=>t.length);return e&&e.length?[...e[0].children].find(t=>Yt(t,O)):null}function ge(t){const{target:e,type:n}=t;if(!e||!e.closest)return;const o=pe(e);if(!o)return;const s=ne(o);if(!s)return;const{parentElement:i,menu:a}=s,l=null!==c(e,_t),r=i&&i.contains(e)&&("form"===e.tagName||null!==c(e,"form"));"click"===n&&Gt(e)&&t.preventDefault(),("focus"!==n||e!==o&&e!==a&&!a.contains(e))&&(r||l||s&&s.hide())}function me(t){const{target:e}=t,n=ne(this);n&&(n.toggle(),e&&Gt(e)&&t.preventDefault())}function be(t){[jt,Xt].includes(t.code)&&t.preventDefault()}function ve(t){const{code:e}=t,n=pe(this),o=n&&ne(n),s=n&&i(n).activeElement;if(!o||!s)return;const{menu:a,open:l}=o,r=function(t){return[...t.children].map(t=>{if(t&&ie.includes(t.tagName))return t;const{firstElementChild:e}=t;return e&&ie.includes(e.tagName)?e:null}).filter(t=>t)}(a);if(r&&r.length&&[jt,Xt].includes(e)){let t=r.indexOf(s);s===n?t=0:e===Xt?t=t>1?t-1:0:e===jt&&(t=t{t.relatedTarget=e}),f(s,le),le.defaultPrevented||($(o,"show"),$(s,"show"),R(e,"aria-expanded","true"),he(t),t.open=!n,setTimeout(()=>{qt(e),ue(t),f(s,re)},1))}hide(){const t=this,{element:e,open:n,menu:o,parentElement:s}=t;[ce,de].forEach(t=>{t.relatedTarget=e}),f(s,ce),ce.defaultPrevented||(u(o,"show"),u(s,"show"),R(e,"aria-expanded","false"),t.open=!n,setTimeout(()=>ue(t),1),f(s,de))}dispose(){const{parentElement:t}=this;h(t,"show")&&this.open&&this.hide(),fe(this),super.dispose()}}d(ye,{selector:_t,init:t=>new ye(t),getInstance:ne});const Te=(t,e)=>t.removeAttribute(e);function Ee(t){return i(t).body}const xe=t=>t instanceof V(t).ShadowRoot||t instanceof ShadowRoot;const He=t=>["TABLE","TD","TH"].includes(t.tagName),ke=t=>t instanceof HTMLElement;function Ae(e,n){const o=["HTML","BODY"];if(n){let{offsetParent:n}=e;const s=V(e);for(;n&&(He(n)||ke(n)&&!["sticky","fixed"].includes(t(n,"position")));)n=n.offsetParent;return(!n||n&&(o.includes(n.tagName)||"static"===t(n,"position")))&&(n=s),n}const s=[];let{parentNode:i}=e;for(;i&&!o.includes(i.nodeName);)i="HTML"===(a=i).nodeName?a:a.assignedSlot||a.parentNode||(xe(a)?a.host:null)||U(a),xe(i)||i.shadowRoot||He(i)||s.push(i);var a;return s.find((e,n)=>"relative"!==t(e,"position")&&s.slice(n+1).every(e=>"static"===t(e,"position"))?e:null)||Ee(e)}const Pe="sticky-top",Me="position-sticky",Ne=t=>[...K("fixed-top",t),...K("fixed-bottom",t),...K(Pe,t),...K(Me,t),...K("is-fixed",t)];function Le(t){const{clientWidth:e}=U(t),{innerWidth:n}=V(t);return Math.abs(n-e)}function De(e,n){const o=Ee(e),s=parseInt(t(o,"paddingRight"),10),i="hidden"===t(o,"overflow")&&s?0:Le(e),a=Ne(o);n&&(Vt(o,{overflow:"hidden",paddingRight:s+i+"px"}),a.length&&a.forEach(e=>{const n=t(e,"paddingRight");if(e.style.paddingRight=parseInt(n,10)+i+"px",[Pe,Me].some(t=>h(e,t))){const n=t(e,"marginRight");e.style.marginRight=parseInt(n,10)-i+"px"}}))}const Ce="modal-backdrop",Se="offcanvas-backdrop",Ie=i().createElement("div");function Re(t){return r(".modal.show,.offcanvas.show",i(t))}function $e(t){const e=t?Ce:Se;[Ce,Se].forEach(t=>{u(Ie,t)}),$(Ie,e)}function Oe(t,e,n){$e(n),t.append(Ie),e&&$(Ie,"fade")}function We(){$(Ie,"show"),nt(Ie)}function Fe(){u(Ie,"show")}function Be(t){Re(t)||(u(Ie,"fade"),Ie.remove(),function(t){const e=Ee(t);Vt(e,{paddingRight:"",overflow:""});const n=Ne(e);n.length&&n.forEach(t=>{Vt(t,{paddingRight:"",marginRight:""})})}(t))}function ze(e){return e&&"hidden"!==t(e,"visibility")&&null!==e.offsetParent}const{on:Xe,off:je}=T,Ye={backdrop:!0,keyboard:!0},Ve=t=>m(t,"Modal"),qe=b("show.bs.modal"),Ue=b("shown.bs.modal"),Ge=b("hide.bs.modal"),Ze=b("hidden.bs.modal");function Je(t){const{element:e}=t,n=Le(e),{clientHeight:o,scrollHeight:s}=U(e),{clientHeight:i,scrollHeight:a}=e,l=i!==a;if(!l&&n){const t=Z(e)?"paddingLeft":"paddingRight";e.style[t]=n+"px"}De(e,l||o!==s)}function Ke(t,e){const n=e?Xe:je,{element:o}=t;n(o,"click",an),n(V(o),zt,t.update,ot),n(i(o),"keydown",sn)}function Qe(t,e){const n=e?Xe:je,{triggers:o}=t;o.length&&o.forEach(t=>n(t,"click",on))}function _e(t){const{triggers:e,element:n}=t;if(Be(n),n.style.paddingRight="",e.length){const t=e.find(t=>ze(t));t&&qt(t)}}function tn(t){const{element:e,relatedTarget:n}=t;qt(e),Ke(t,!0),Ue.relatedTarget=n,f(e,Ue)}function en(t){const{element:e,hasFade:n}=t;e.style.display="block",Je(t),Re(e)||(Ee(e).style.overflow="hidden"),$(e,"show"),Te(e,"aria-hidden"),R(e,"aria-modal","true"),n?s(e,()=>tn(t)):tn(t)}function nn(t,e){const{element:n,options:o,relatedTarget:i,hasFade:a}=t;n.style.display="",o.backdrop&&!e&&a&&h(Ie,"show")&&!Re(n)?(Fe(),s(Ie,()=>_e(t))):_e(t),Ke(t),Ze.relatedTarget=i,f(n,Ze)}function on(t){const{target:e}=t,n=e&&c(this,'[data-bs-toggle="modal"]'),o=n&&st(n),s=o&&Ve(o);s&&(n&&"A"===n.tagName&&t.preventDefault(),s.relatedTarget=n,s.toggle())}function sn({code:t}){const e=r(".modal.show"),n=e&&Ve(e);if(!n)return;const{options:o}=n;o.keyboard&&"Escape"===t&&h(e,"show")&&(n.relatedTarget=null,n.hide())}function an(t){const n=this,o=Ve(n);if(!o||tt(n))return;const{options:a,isStatic:l,modalDialog:r}=o,{backdrop:d}=a,{target:h}=t,f=i(n).getSelection().toString().length,p=r.contains(h),g=h&&c(h,'[data-bs-dismiss="modal"]');l&&!p?_(n,()=>{$(n,"modal-static"),s(r,()=>function(t){const{element:n,modalDialog:o}=t,s=e(o)+17;u(n,"modal-static"),_(n,()=>et(n),s)}(o))},17):(g||!f&&!l&&!p&&d)&&(o.relatedTarget=g||null,o.hide(),t.preventDefault())}class ln extends A{constructor(t,e){super(t,e);const{element:n}=this;this.modalDialog=r(".modal-dialog",n),this.triggers=[...J('[data-bs-toggle="modal"]')].filter(t=>st(t)===n),this.isStatic="static"===this.options.backdrop,this.hasFade=h(n,"fade"),this.relatedTarget=null,this.container=Ae(n),Qe(this,!0),this.update=this.update.bind(this)}get name(){return"Modal"}get defaults(){return Ye}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,hasFade:s,relatedTarget:i,container:a}=t,{backdrop:l}=o;let r=0;if(h(n,"show"))return;if(qe.relatedTarget=i||null,f(n,qe),qe.defaultPrevented)return;const c=Re(n);if(c&&c!==n){(Ve(c)||m(c,"Offcanvas")).hide()}l?(c||h(Ie,"show")?$e(!0):Oe(a,s,!0),r=e(Ie),h(Ie,"show")||We(),setTimeout(()=>en(t),r)):(en(t),c&&h(Ie,"show")&&Fe())}hide(t){const e=this,{element:n,hasFade:o,relatedTarget:i}=e;h(n,"show")&&(Ge.relatedTarget=i||null,f(n,Ge),Ge.defaultPrevented||(u(n,"show"),R(n,"aria-hidden","true"),Te(n,"aria-modal"),o&&!1!==t?s(n,()=>nn(e)):nn(e,t)))}update(){h(this.element,"show")&&Je(this)}dispose(){this.hide(!0),Qe(this),super.dispose()}}d(ln,{selector:".modal",init:t=>new ln(t),getInstance:Ve});const{on:rn,off:cn}=T,dn={backdrop:!0,keyboard:!0,scroll:!1},hn=t=>m(t,"Offcanvas"),un=b("show.bs.offcanvas"),fn=b("shown.bs.offcanvas"),pn=b("hide.bs.offcanvas"),gn=b("hidden.bs.offcanvas");function mn(t,e){const n=e?rn:cn;t.triggers.forEach(t=>n(t,"click",yn))}function bn(t,e){const n=e?rn:cn,o=i(t.element);n(o,"keydown",En),n(o,"click",Tn)}function vn(t){const{element:e,options:n}=t;n.scroll||(!function(t){const{element:e}=t,{clientHeight:n,scrollHeight:o}=U(e);De(e,n!==o)}(t),Ee(e).style.overflow="hidden"),$(e,"offcanvas-toggling"),$(e,"show"),e.style.visibility="visible",s(e,()=>function(t){const{element:e,triggers:n}=t;u(e,"offcanvas-toggling"),Te(e,"aria-hidden"),R(e,"aria-modal","true"),R(e,"role","dialog"),n.length&&n.forEach(t=>R(t,"aria-expanded","true"));f(e,fn),bn(t,!0),qt(e)}(t))}function wn(t){const{element:e,options:n}=t,o=Re(e);e.blur(),!o&&n.backdrop&&h(Ie,"show")?(Fe(),s(Ie,()=>xn(t))):xn(t)}function yn(t){const e=c(this,'[data-bs-toggle="offcanvas"]'),n=e&&st(e),o=n&&hn(n);o&&(o.relatedTarget=e,o.toggle(),e&&"A"===e.tagName&&t.preventDefault())}function Tn(t){const e=r(".offcanvas.show",this);if(!e)return;const n=r('[data-bs-dismiss="offcanvas"]',e),o=hn(e);if(!o)return;const{options:s,triggers:a}=o,{target:l}=t,d=c(l,'[data-bs-toggle="offcanvas"]'),h=i(e).getSelection();h&&h.toString().length||!(!e.contains(l)&&s.backdrop&&(!d||d&&!a.includes(d))||n&&n.contains(l))||(o.relatedTarget=n&&n.contains(l)?n:null,o.hide()),d&&"A"===d.tagName&&t.preventDefault()}function En({code:t}){const e=r(".offcanvas.show",this);if(!e)return;const n=hn(e);n&&n.options.keyboard&&"Escape"===t&&(n.relatedTarget=null,n.hide())}function xn(t){const{element:e,triggers:n}=t;if(R(e,"aria-hidden","true"),Te(e,"aria-modal"),Te(e,"role"),e.style.visibility="",n.length){n.forEach(t=>R(t,"aria-expanded","false"));const t=n.find(t=>ze(t));t&&qt(t)}Be(e),f(e,gn),u(e,"offcanvas-toggling"),Re(e)||bn(t)}class Hn extends A{constructor(t,e){super(t,e);const{element:n}=this;this.triggers=[...J('[data-bs-toggle="offcanvas"]')].filter(t=>st(t)===n),this.container=Ae(n),this.relatedTarget=null,mn(this,!0)}get name(){return"Offcanvas"}get defaults(){return dn}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,container:s,relatedTarget:i}=t;let a=0;if(h(n,"show"))return;if(un.relatedTarget=i,fn.relatedTarget=i,f(n,un),un.defaultPrevented)return;const l=Re(n);if(l&&l!==n){(hn(l)||m(l,"Modal")).hide()}o.backdrop?(l?$e():Oe(s,!0),a=e(Ie),h(Ie,"show")||We(),setTimeout(()=>vn(t),a)):(vn(t),l&&h(Ie,"show")&&Fe())}hide(t){const e=this,{element:n,relatedTarget:o}=e;h(n,"show")&&(pn.relatedTarget=o,gn.relatedTarget=o,f(n,pn),pn.defaultPrevented||($(n,"offcanvas-toggling"),u(n,"show"),t?wn(e):s(n,()=>wn(e))))}dispose(){this.hide(!0),mn(this),super.dispose()}}d(Hn,{selector:".offcanvas",init:t=>new Hn(t),getInstance:hn});function kn(t){const e="tooltip"===t;return``}const An=t=>t&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(e=>t instanceof e);function Pn(t,e,n){const o=e instanceof HTMLElement,s=q(t,o&&function(t){const{width:e,height:n}=q(t),{offsetWidth:o,offsetHeight:s}=t;return Math.round(e)!==o||Math.round(n)!==s}(e)),i={x:0,y:0};if(o){const t=q(e,!0);i.x=t.x+e.clientLeft,i.y=t.y+e.clientTop}return{x:s.left+n.x-i.x,y:s.top+n.y-i.y,width:s.width,height:s.height}}var Mn={top:"top",bottom:"bottom",left:"start",right:"end"};function Nn(e,n){const o=/\b(top|bottom|start|end)+/,{element:s,tooltip:i,options:a,arrow:l,offsetParent:r}=e,c={...Mn};Vt(i,{top:"0px",left:"0px",right:""});const d="Popover"===e.name,h=i.offsetWidth,u=i.offsetHeight,f=Z(s);f&&(c.left="end",c.right="start");const p=U(s),g=p.clientWidth,m=p.clientHeight,{container:b}=a;let{placement:v}=a;const{left:w,right:y,top:T}=q(b,!0),E=b.clientWidth,x=Math.abs(E-b.offsetWidth),H=t(b,"position"),k="fixed"===H,A="static"===H,P="sticky"===H&&T===parseFloat(t(b,"top")),M=f&&k?x:0,N=k?E+w+(f?x:0):E+w+(g-y)-1,{width:L,height:D,left:C,right:S,top:I}=q(s,!0),R=function(t){const e="scrollX"in t;return{x:e?t.scrollX:t.scrollLeft,y:e?t.scrollY:t.scrollTop}}(r),{x:$,y:O}=Pn(s,r,R);let W,F,B,z,X,j;Vt(l,{top:"",left:"",right:""});const Y=l.offsetWidth||0,V=l.offsetHeight||0,G=Y/2;let J=I-u-V<0,K=I+u+D+V>=m,Q=C-h-Y=N;const tt=["left","right"],et=["top","bottom"];if(J=tt.includes(v)?I+D/2-u/2-V<0:J,K=tt.includes(v)?I+u/2+D/2+V>=m:K,Q=et.includes(v)?C+L/2-h/2=N:_,v=tt.includes(v)&&Q&&_?"top":v,v="top"===v&&J?"bottom":v,v="bottom"===v&&K?"top":v,v="left"===v&&Q?"right":v,v="right"===v&&_?"left":v,i.className.includes(v)||(i.className=i.className.replace(o,c[v])),tt.includes(v))F="left"===v?$-h-(d?Y:0):$+L+(d?Y:0),J?(W=O,W+=P?-T-R.y:0,z=D/2-Y):K?(W=O-u+D,W+=P?-T-R.y:0,z=u-D/2-Y):(W=O-u/2+D/2,W+=P?-T-R.y:0,z=u/2-V/2);else if(et.includes(v))if(n&&An(s)){let t=0,e=0;A?(t=n.pageX,e=n.pageY):(t=n.clientX-w+(k?R.x:0),e=n.clientY-T+(k?R.y:0)),t-=f&&k&&x?x:0,W="top"===v?e-u-Y:e+Y,n.clientX-h/2N?(F="auto",B=0,j=N-t-G,j-=k?w+(f?x:0):0):(F=t-h/2,X=h/2-G)}else W="top"===v?O-u-(d?V:0):O+D+(d?V:0),Q?(F=0,X=$+L/2-G):_?(F="auto",B=0,j=L/2+N-S-G):(F=$-h/2+L/2,X=h/2-G);Vt(i,{top:W+"px",left:"auto"===F?F:F+"px",right:void 0!==B?B+"px":""}),l instanceof HTMLElement&&(void 0!==z&&(l.style.top=z+"px"),void 0!==X?l.style.left=X+"px":void 0!==j&&(l.style.right=j+"px"))}const Ln={template:kn("tooltip"),title:null,customClass:null,trigger:"hover focus",placement:"top",sanitizeFn:null,animation:!0,delay:200,container:null},Dn="focusin",Cn="focusout",{userAgentData:Sn}=navigator,In=Sn,{userAgent:Rn}=navigator,$n=Rn,On=/(iPhone|iPod|iPad)/,Wn=In?In.brands.some(t=>On.test(t.brand)):On.test($n);let Fn=1;const Bn=new Map;function zn(t,e,n){if("string"!=typeof e||e.length)if("string"==typeof e){let o=e.trim();"function"==typeof n&&(o=n(o));const s=(new DOMParser).parseFromString(o,"text/html"),{body:i}=s,a=i.children.length?"innerHTML":"innerText";t[a]=i[a]}else e instanceof HTMLElement&&t.append(e)}function Xn(t,e){return t instanceof HTMLElement&&e.contains(t)}const{on:jn,off:Yn}=T;let Vn=t=>m(t,"Tooltip");function qn(t){const{element:e}=t;Jn(t),e.hasAttribute("data-original-title")&&"tooltip"===t.name&&Qn(t)}function Un(t,e){const n=e?jn:Yn,{element:o}=t;n(i(o),"touchstart",_n,ot),An(o)||[Bt,zt].forEach(e=>{n(V(o),e,t.update,ot)})}function Gn(t){const{element:e}=t,n=b("shown.bs."+k(t.name));Un(t,!0),f(e,n),et(e,"in")}function Zn(t){const{element:e}=t,n=b("hidden.bs."+k(t.name));Un(t),function(t){const{element:e,tooltip:n}=t;Te(e,"aria-describedby"),n.remove()}(t),f(e,n),et(e,"out")}function Jn(t,e){const n=e?jn:Yn,{element:o,options:s,btn:a}=t,{trigger:l,dismissible:r}=s;if(l.includes("manual"))return;t.enabled=!!e;const c=l.split(" "),d=An(o);d&&n(o,"mousemove",t.update,ot),c.forEach(e=>{d||"hover"===e?(n(o,"mousedown",t.show),n(o,j,t.show),r&&a?n(a,"click",t.hide):(n(o,Y,t.hide),n(i(o),"touchstart",_n,ot))):"click"===e?n(o,e,r?t.show:t.toggle):"focus"===e&&(n(o,Dn,t.show),r||n(o,Cn,t.hide),Wn&&n(o,"click",()=>qt(o)))})}function Kn(t,e){const n=e?jn:Yn,{element:o,options:s,offsetParent:i}=t,{container:a}=s,{offsetHeight:l,scrollHeight:r}=a,d=c(o,".modal"),h=c(o,".offcanvas");if(!An(o)){const e=V(o),s=l!==r||i!==e?a:e;n(e,zt,t.update,ot),n(s,Bt,t.update,ot)}d&&jn(d,"hide.bs.modal",t.hide),h&&jn(h,"hide.bs.offcanvas",t.hide)}function Qn(t,e){const n=["data-original-title","title"],{element:o}=t;R(o,n[e?0:1],e||E(o,n[0])),Te(o,n[e?1:0])}function _n({target:t}){const{tooltip:e,element:n}=this;e.contains(t)||t===n||n.contains(t)||this.hide()}class to extends A{constructor(e,n){super(e,n);const o=this,{element:s}=o,a="Tooltip"===o.name,l=a?"tooltip":"popover",c=a?"Tooltip":"Popover";Vn=t=>m(t,c),o.tooltip={},a||(o.btn=null),o.arrow={},o.offsetParent={},o.enabled=!0,o.id=`${l}-${function(t,e){Fn+=1;let n=Bn.get(t),o=Fn;if(e&&e.length)if(n){const t=n.get(e);Number.isNaN(t)?n.set(e,o):o=t}else Bn.set(t,new Map),n=Bn.get(t),n.set(e,o);else Number.isNaN(n)?Bn.set(t,o):o=n;return o}(s,l)}`;const{options:d}=o;if(!d.title&&a||!a&&!d.content)return;const u=r(d.container),f=Ae(s);o.options.container=!u||u&&["static","relative"].includes(t(u,"position"))?f:u||Ee(s),Ln.title=null,_n.bind(o),o.update=o.update.bind(o),o.show=o.show.bind(o),o.hide=o.hide.bind(o),o.toggle=o.toggle.bind(o),s.hasAttribute("title")&&a&&Qn(o,d.title),function(t){const{id:e,element:n,options:o}=t,{animation:s,customClass:a,sanitizeFn:l,placement:c,dismissible:d}=o;let{title:u,content:f}=o;const p="Tooltip"===t.name,g=p?"tooltip":"popover",{template:m,btnClose:b}=o,v={...Mn};Z(n)&&(v.left="end",v.right="start");const w=`bs-${g}-${v[c]}`;let y;if([Element,HTMLElement].some(t=>m instanceof t))y=m;else{const t=i(n).createElement("div");zn(t,m,l),y=t.firstElementChild}t.tooltip=y&&y.cloneNode(!0);const{tooltip:T}=t;R(T,"id",e),R(T,"role","tooltip");const E=p?"tooltip-inner":"popover-body",x=p?null:r(".popover-header",T),H=r("."+E,T);t.arrow=r(`.${g}-arrow`,T),d&&(u?u instanceof HTMLElement?zn(u,b,l):u+=b:(x&&x.remove(),f instanceof HTMLElement?zn(f,b,l):f+=b)),p?u&&H&&zn(H,u,l):(u&&x&&zn(x,u,l),f&&H&&zn(H,f,l),t.btn=r(".btn-close",T)),h(T,g)||$(T,g),s&&!h(T,"fade")&&$(T,"fade"),a&&!h(T,a)&&$(T,a),h(T,w)||$(T,w)}(o),Jn(o,!0)}get name(){return"Tooltip"}get defaults(){return Ln}show(t){const e=this,{options:n,tooltip:o,element:i,id:a}=e,{container:l,animation:r}=n,c=tt(i,"out");et(i,"out"),!o||c||Xn(o,l)||_(i,()=>{const n=b("show.bs."+k(e.name));f(i,n),n.defaultPrevented||(l.append(o),R(i,"aria-describedby","#"+a),e.offsetParent=Ae(o,!0),e.update(t),Kn(e,!0),h(o,"show")||$(o,"show"),r?s(o,()=>Gn(e)):Gn(e))},17,"in")}hide(){const t=this,{options:e,tooltip:n,element:o}=t,{container:i,animation:a,delay:l}=e;et(o,"in"),n&&Xn(n,i)&&_(o,()=>{const e=b("hide.bs."+k(t.name));f(o,e),e.defaultPrevented||(u(n,"show"),Kn(t),a?s(n,()=>Zn(t)):Zn(t))},l+17,"out")}update(t){Nn(this,t)}toggle(t){const{tooltip:e,options:n}=this;Xn(e,n.container)?this.hide():this.show(t)}enable(){const t=this,{enabled:e}=t;e||(Jn(t,!0),t.enabled=!e)}disable(){const t=this,{element:n,tooltip:o,options:s,enabled:i}=t,{animation:a,container:l,delay:r}=s;i&&(Xn(o,l)&&a?(t.hide(),_(n,()=>{Jn(t),et(n,"tooltip")},e(o)+r+17,"tooltip")):Jn(t),t.enabled=!i)}toggleEnabled(){this.enabled?this.disable():this.enable()}dispose(){const t=this,{tooltip:e,options:n}=t;n.animation&&Xn(e,n.container)?(n.delay=0,t.hide(),s(e,()=>qn(t))):qn(t),super.dispose()}}d(to,{selector:'[data-bs-toggle="tooltip"],[data-tip="tooltip"]',init:t=>new to(t),getInstance:Vn,styleTip:Nn});const eo={...Ln,template:kn("popover"),btnClose:'',dismissible:!1,content:null};class no extends to{constructor(t,e){super(t,e)}get name(){return"Popover"}get defaults(){return eo}show(){super.show();const{options:t,btn:e}=this;t.dismissible&&e&&setTimeout(()=>qt(e),17)}}function oo(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByTagName(t)}d(no,{selector:'[data-bs-toggle="popover"],[data-tip="popover"]',init:t=>new no(t),getInstance:t=>m(t,"Popover"),styleTip:Nn});const{on:so,off:io}=T,ao={offset:10,target:null},lo=b("activate.bs.scrollspy");function ro(t){const{target:e,scrollTarget:n,options:o,itemsLength:s,scrollHeight:a,element:l}=t,{offset:c}=o,d=n instanceof Window,h=e&&oo("A",e),u=n&&function(t){return t instanceof HTMLElement?t.scrollHeight:U(t).scrollHeight}(n);if(t.scrollTop=d?n.scrollY:n.scrollTop,h&&(s!==h.length||u!==a)){let e,n,o;t.items=[],t.offsets=[],t.scrollHeight=u,t.maxScroll=t.scrollHeight-function({element:t,scrollTarget:e}){return e instanceof Window?e.innerHeight:q(t).height}(t),[...h].forEach(s=>{e=E(s,"href"),n=e&&"#"===e.charAt(0)&&"#"!==e.slice(-1)&&r(e,i(l)),n&&(t.items.push(s),o=q(n),t.offsets.push((d?o.top+t.scrollTop:n.offsetTop)-c))}),t.itemsLength=t.items.length}}function co(t){[...oo("A",t)].forEach(t=>{h(t,"active")&&u(t,"active")})}function ho(t,e){const{target:n,element:o}=t;co(n),t.activeItem=e,$(e,"active");const s=[];let i=e;for(;i!==Ee(o);)i=i.parentElement,(h(i,"nav")||h(i,"dropdown-menu"))&&s.push(i);s.forEach(t=>{const e=t.previousElementSibling;e&&!h(e,"active")&&$(e,"active")}),lo.relatedTarget=e,f(o,lo)}function uo(t,e){(e?so:io)(t.scrollTarget,Bt,t.refresh,ot)}class fo extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;if(this.target=r(o.target,i(n)),!this.target)return;const s=V(n);this.scrollTarget=n.clientHeight=o){const e=i[s-1];return void(a!==e&&ho(t,e))}const{offsets:l}=t;if(a&&n0)return t.activeItem=null,void co(e);i.forEach((e,o)=>{a!==e&&n>=l[o]&&(void 0===l[o+1]||nnew fo(t),getInstance:t=>m(t,"ScrollSpy")});const{on:po,off:go}=T,mo=t=>m(t,"Tab"),bo=b("show.bs.tab"),vo=b("shown.bs.tab"),wo=b("hide.bs.tab"),yo=b("hidden.bs.tab"),To=new Map;function Eo(t){const{tabContent:e,nav:n}=t;e&&(e.style.height="",u(e,"collapsing")),n&&et(n)}function xo(t){const{element:e,tabContent:n,nav:o}=t,{currentHeight:i,nextHeight:a}=To.get(e),{tab:l}=o&&To.get(o);n?i===a?Eo(t):setTimeout(()=>{n.style.height=a+"px",nt(n),s(n,()=>Eo(t))},50):o&&et(o),vo.relatedTarget=l,f(e,vo)}function Ho(t){const{element:e,content:n,tabContent:o,nav:i}=t,{tab:a,content:l}=i&&To.get(i);let r=0;if(o&&([l,n].forEach(t=>$(t,"overflow-hidden")),r=l.scrollHeight),bo.relatedTarget=a,yo.relatedTarget=e,f(e,bo),!bo.defaultPrevented){if($(n,"active"),u(l,"active"),o){const t=n.scrollHeight;To.set(e,{currentHeight:r,nextHeight:t}),$(o,"collapsing"),o.style.height=r+"px",nt(o),[l,n].forEach(t=>u(t,"overflow-hidden"))}n&&h(n,"fade")?setTimeout(()=>{$(n,"show"),s(n,()=>{xo(t)})},17):xo(t),f(a,yo)}}function ko(t,e){(e?po:go)(t.element,"click",Ao)}function Ao(t){const e=mo(this);e&&(t.preventDefault(),e.show())}class Po extends A{constructor(t){super(t);const{element:e}=this,n=st(e);if(!n)return;const o=c(e,".nav"),s=c(n,".tab-content");this.nav=o,this.content=n,this.tabContent=s,this.dropdown=o&&r(`.${Ut[0]}-toggle`,o),ko(this,!0)}get name(){return"Tab"}show(){const t=this,{element:e,nav:n,dropdown:o}=t;if(!(n&&tt(n)||h(e,"active"))){const{tab:i,content:a}=function(t){const{nav:e}=t,n=K("active",e);let o;return 1!==n.length||Ut.some(t=>h(n[0].parentElement,t))?n.length>1&&(o=n[n.length-1]):[o]=n,{tab:o,content:o?st(o):null}}(t);if(n&&To.set(n,{tab:i,content:a}),wo.relatedTarget=e,f(i,wo),wo.defaultPrevented)return;n&&_(n,()=>{},17),u(i,"active"),R(i,"aria-selected","false"),$(e,"active"),R(e,"aria-selected","true"),o&&(h(e.parentNode,"dropdown-menu")?h(o,"active")||$(o,"active"):h(o,"active")&&u(o,"active")),h(a,"fade")?(u(a,"show"),s(a,()=>Ho(t))):Ho(t)}}dispose(){ko(this),super.dispose()}}d(Po,{selector:'[data-bs-toggle="tab"]',init:t=>new Po(t),getInstance:mo});const{on:Mo,off:No}=T,Lo={animation:!0,autohide:!0,delay:5e3},Do=t=>m(t,"Toast"),Co=b("show.bs.toast"),So=b("shown.bs.toast"),Io=b("hide.bs.toast"),Ro=b("hidden.bs.toast");function $o(t){const{element:e,options:n}=t;u(e,"showing"),et(e,"showing"),f(e,So),n.autohide&&_(e,()=>t.hide(),n.delay,"toast")}function Oo(t){const{element:e}=t;u(e,"showing"),u(e,"show"),$(e,"hide"),et(e,"toast"),f(e,Ro)}function Wo(t,e){const n=e?Mo:No,{element:o,dismiss:s,options:i}=t;s&&n(s,"click",t.hide),i.autohide&&[Dn,Cn,j,Y].forEach(t=>n(o,t,Fo))}function Fo(t){const e=this,n=Do(e),{type:o,relatedTarget:s}=t;n&&e!==s&&!e.contains(s)&&([j,Dn].includes(o)?et(e,"toast"):_(e,()=>n.hide(),n.options.delay,"toast"))}class Bo extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;o.animation&&!h(n,"fade")?$(n,"fade"):!o.animation&&h(n,"fade")&&u(n,"fade"),this.dismiss=r('[data-bs-dismiss="toast"]',n),this.show=this.show.bind(this),this.hide=this.hide.bind(this),Wo(this,!0)}get name(){return"Toast"}get defaults(){return Lo}show(){const t=this,{element:e}=t;if(e&&!h(e,"show")){if(f(e,Co),Co.defaultPrevented)return;!function(t){const{element:e,options:n}=t;_(e,()=>{u(e,"hide"),nt(e),$(e,"show"),$(e,"showing"),n.animation?s(e,()=>$o(t)):$o(t)},17,"showing")}(t)}}hide(){const t=this,{element:e}=t;if(e&&h(e,"show")){if(f(e,Io),Io.defaultPrevented)return;!function(t){const{element:e,options:n}=t;$(e,"showing"),n.animation?(nt(e),s(e,()=>Oo(t))):Oo(t)}(t)}}dispose(){const{element:t}=this;h(t,"show")&&u(t,"show"),function(t){et(t.element,"toast"),Wo(t)}(this),super.dispose()}}d(Bo,{selector:".toast",init:t=>new Bo(t),getInstance:Do});const zo={Alert:I,Button:X,Carousel:Pt,Collapse:Ft,Dropdown:ye,Modal:ln,Offcanvas:Hn,Popover:no,ScrollSpy:fo,Tab:Po,Toast:Bo,Tooltip:to};function Xo(t){const e=[...oo("*",t&&a.some(e=>t instanceof e)?t:void 0)];H(zo).forEach(t=>{const{init:n,selector:o}=zo[t];var s,i;s=n,i=e.filter(t=>function(t,e){return t.matches(e)}(t,o)),[...i].forEach(t=>s(t))})}document.body?Xo():function(t,e,s,i){const a=n=>{n.target===t&&(s.apply(t,[n]),o(t,e,a,i))};n(t,e,a,i)}(document,"DOMContentLoaded",()=>Xo());const jo={Alert:I,Button:X,Carousel:Pt,Collapse:Ft,Dropdown:ye,Modal:ln,Offcanvas:Hn,Popover:no,ScrollSpy:fo,Tab:Po,Toast:Bo,Tooltip:to,initCallback:Xo,removeDataAPI:function(t){const e=t&&a.some(e=>t instanceof e)?t:void 0;H(zo).forEach(t=>{!function(t,e){const n=g.getAllFor(t);n&&[...n].forEach(t=>{const[n,o]=t;e&&e.contains(n)&&o.dispose()})}(t,e)})},Version:"4.1.0alpha4"};export{jo as default}; diff --git a/dist/bootstrap-native.js b/dist/bootstrap-native.js index ad43e00d..2dc1e8b5 100644 --- a/dist/bootstrap-native.js +++ b/dist/bootstrap-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -104,7 +104,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function on(element, eventName, handler, options) { + function on$b(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -117,7 +117,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function off(element, eventName, handler, options) { + function off$b(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -143,11 +143,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$b(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$b(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -343,6 +343,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `fade` class. */ @@ -464,7 +572,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -531,6 +639,7 @@ // ================ const alertSelector = `.${alertString}`; const alertDismissSelector = `[${dataBsDismiss}="${alertString}"]`; + const { on: on$a, off: off$a } = EventListener; /** * Static method which returns an existing `Alert` instance associated @@ -575,7 +684,7 @@ * @param {boolean=} add when `true`, event listener is added */ function toggleAlertHandler(self, add) { - const action = add ? on : off; + const action = add ? on$a : off$a; const { dismiss } = self; if (dismiss) action(dismiss, mouseclickEvent, self.close); } @@ -696,6 +805,7 @@ // BUTTON PRIVATE GC // ================= const buttonSelector = `[${dataBsToggle}="${buttonString}"]`; + const { on: on$9, off: off$9 } = EventListener; /** * Static method which returns an existing `Button` instance associated @@ -719,7 +829,7 @@ * @param {boolean=} add when `true`, event listener is added */ function toggleButtonHandler(self, add) { - const action = add ? on : off; + const action = add ? on$9 : off$9; action(self.element, mouseclickEvent, self.toggle); } @@ -1092,7 +1202,7 @@ const carouselItem = `${carouselString}-item`; const dataBsSlideTo = 'data-bs-slide-to'; const dataBsSlide = 'data-bs-slide'; - + const { on: on$8, off: off$8 } = EventListener; const pausedClass = 'paused'; const carouselDefaults = { @@ -1143,10 +1253,10 @@ const directionClass = direction === 'left' ? 'start' : 'end'; addClass(slides[index], activeClass); - removeClass(slides[activeItem], activeClass); - removeClass(slides[index], `${carouselItem}-${orientation}`); removeClass(slides[index], `${carouselItem}-${directionClass}`); + + removeClass(slides[activeItem], activeClass); removeClass(slides[activeItem], `${carouselItem}-${directionClass}`); dispatchEvent(element, carouselSlidEvent); @@ -1354,7 +1464,7 @@ */ function toggleCarouselTouchHandlers(self, add) { const { element } = self; - const action = add ? on : off; + const action = add ? on$8 : off$8; action(element, touchmoveEvent, carouselTouchMoveHandler, passiveHandler); action(element, touchendEvent, carouselTouchEndHandler, passiveHandler); } @@ -1371,7 +1481,7 @@ const { touch, pause, interval, keyboard, } = options; - const action = add ? on : off; + const action = add ? on$8 : off$8; if (pause && interval) { action(element, mouseenterEvent, carouselPauseHandler); @@ -1675,6 +1785,7 @@ const collapseSelector = `.${collapseString}`; const collapseToggleSelector = `[${dataBsToggle}="${collapseString}"]`; const collapseDefaults = { parent: null }; + const { on: on$7, off: off$7 } = EventListener; /** * Static method which returns an existing `Collapse` instance associated @@ -1787,7 +1898,7 @@ * @param {boolean=} add when `true`, the event listener is added */ function toggleCollapseHandler(self, add) { - const action = add ? on : off; + const action = add ? on$7 : off$7; const { triggers } = self; if (triggers.length) { @@ -2027,6 +2138,7 @@ dropendString, ] = dropdownMenuClasses; const dropdownSelector = `[${dataBsToggle}="${dropdownString}"]`; + const { on: on$6, off: off$6 } = EventListener; /** * Static method which returns an existing `Dropdown` instance associated @@ -2202,7 +2314,7 @@ */ function toggleDropdownDismiss(self) { const { element } = self; - const action = self.open ? on : off; + const action = self.open ? on$6 : off$6; const doc = getDocument(element); action(doc, mouseclickEvent, dropdownDismissHandler); @@ -2225,7 +2337,7 @@ * @param {boolean=} add when `true`, it will add the event listener */ function toggleDropdownHandler(self, add) { - const action = add ? on : off; + const action = add ? on$6 : off$6; action(self.element, mouseclickEvent, dropdownClickHandler); } @@ -2821,6 +2933,7 @@ const modalToggleSelector = `[${dataBsToggle}="${modalString}"]`; const modalDismissSelector = `[${dataBsDismiss}="${modalString}"]`; const modalStaticClass = `${modalString}-static`; + const { on: on$5, off: off$5 } = EventListener; const modalDefaults = { backdrop: true, // boolean|string @@ -2878,7 +2991,7 @@ * @param {boolean=} add when `true`, event listeners are added */ function toggleModalDismiss(self, add) { - const action = add ? on : off; + const action = add ? on$5 : off$5; const { element } = self; action(element, mouseclickEvent, modalDismissHandler); // @ts-ignore @@ -2892,7 +3005,7 @@ * @param {boolean=} add when `true`, event listener is added */ function toggleModalHandler(self, add) { - const action = add ? on : off; + const action = add ? on$5 : off$5; const { triggers } = self; if (triggers.length) { @@ -3238,6 +3351,7 @@ const offcanvasToggleSelector = `[${dataBsToggle}="${offcanvasString}"]`; const offcanvasDismissSelector = `[${dataBsDismiss}="${offcanvasString}"]`; const offcanvasTogglingClass = `${offcanvasString}-toggling`; + const { on: on$4, off: off$4 } = EventListener; const offcanvasDefaults = { backdrop: true, // boolean @@ -3287,7 +3401,7 @@ * @param {boolean=} add when *true*, listeners are added */ function toggleOffcanvasEvents(self, add) { - const action = add ? on : off; + const action = add ? on$4 : off$4; self.triggers.forEach((btn) => action(btn, mouseclickEvent, offcanvasTriggerHandler)); } @@ -3298,7 +3412,7 @@ * @param {boolean=} add when *true* listeners are added */ function toggleOffCanvasDismiss(self, add) { - const action = add ? on : off; + const action = add ? on$4 : off$4; const doc = getDocument(self.element); action(doc, keydownEvent, offcanvasKeyDismissHandler); action(doc, mouseclickEvent, offcanvasDismissHandler); @@ -4010,15 +4124,21 @@ let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -4156,6 +4276,7 @@ // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; + const { on: on$3, off: off$3 } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated @@ -4205,7 +4326,7 @@ * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipAction(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; const { element } = self; action(getDocument(element), touchstartEvent, tooltipTouchHandler, passiveHandler); @@ -4254,7 +4375,7 @@ * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; // @ts-ignore -- btn is only for dismissible popover const { element, options, btn } = self; const { trigger, dismissible } = options; @@ -4299,7 +4420,7 @@ * @param {boolean=} add when `true`, event listeners are added */ function toggleTooltipOpenHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$3 : off$3; const { element, options, offsetParent } = self; const { container } = options; const { offsetHeight, scrollHeight } = container; @@ -4316,8 +4437,8 @@ } // dismiss tooltips inside modal / offcanvas - if (parentModal) on(parentModal, `hide.bs.${modalString}`, self.hide); - if (parentOffcanvas) on(parentOffcanvas, `hide.bs.${offcanvasString}`, self.hide); + if (parentModal) on$3(parentModal, `hide.bs.${modalString}`, self.hide); + if (parentOffcanvas) on$3(parentOffcanvas, `hide.bs.${offcanvasString}`, self.hide); } /** @@ -4696,6 +4817,7 @@ // SCROLLSPY PRIVATE GC // ==================== const scrollspySelector = '[data-bs-spy="scroll"]'; + const { on: on$2, off: off$2 } = EventListener; const scrollspyDefaults = { offset: 10, @@ -4841,7 +4963,7 @@ * @param {boolean=} add when `true`, listener is added */ function toggleSpyHandlers(self, add) { - const action = add ? on : off; + const action = add ? on$2 : off$2; // @ts-ignore action(self.scrollTarget, scrollEvent, self.refresh, passiveHandler); } @@ -4985,6 +5107,7 @@ // TAB PRIVATE GC // ================ const tabSelector = `[${dataBsToggle}="${tabString}"]`; + const { on: on$1, off: off$1 } = EventListener; /** * Static method which returns an existing `Tab` instance associated @@ -5133,7 +5256,7 @@ * @param {boolean=} add when `true`, event listener is added */ function toggleTabHandler(self, add) { - const action = add ? on : off; + const action = add ? on$1 : off$1; action(self.element, mouseclickEvent, tabClickHandler); } @@ -5265,6 +5388,7 @@ const showingClass = 'showing'; /** @deprecated */ const hideClass = 'hide'; + const { on, off } = EventListener; const toastDefaults = { animation: true, @@ -5514,10 +5638,10 @@ const handlerWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, eventName, handlerWrapper, options); + off$b(element, eventName, handlerWrapper, options); } }; - on(element, eventName, handlerWrapper, options); + on$b(element, eventName, handlerWrapper, options); } /** diff --git a/dist/bootstrap-native.min.js b/dist/bootstrap-native.min.js index f7fb0961..40ebc04f 100644 --- a/dist/bootstrap-native.min.js +++ b/dist/bootstrap-native.min.js @@ -1,2 +1,2 @@ -// Native JavaScript for Bootstrap v4.1.0alpha3 | 2022 © dnp_theme | MIT-License -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BSN=e()}(this,(function(){"use strict";function t(t,e){const n=getComputedStyle(t);return e in n?n[e]:""}function e(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDuration"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}function n(t,e,n,o){const s=o||!1;t.addEventListener(e,n,s)}function o(t,e,n,o){const s=o||!1;t.removeEventListener(e,n,s)}function s(s,i){let a=0;const l=new Event("transitionend"),r=e(s),c=function(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDelay"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}(s);if(r){const t=e=>{e.target===s&&(i.apply(s,[e]),o(s,"transitionend",t),a=1)};n(s,"transitionend",t),setTimeout(()=>{a||s.dispatchEvent(l)},r+c+17)}else i.apply(s,[l])}function i(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}const a=[Document,Node,Element,HTMLElement],l=[Element,HTMLElement];function r(t,e){const n="string"==typeof t,o=e&&a.some(t=>e instanceof t)?e:i();return!n&&l.some(e=>t instanceof e)?t:n?o.querySelector(t):null}function c(t,e){return t?t.closest(e)||c(t.getRootNode().host,e):null}const d=(t,e)=>Object.assign(t,e);function h(t,e){return t.classList.contains(e)}function u(t,e){t.classList.remove(e)}const f=(t,e)=>t.dispatchEvent(e),p=new Map,g={set:(t,e,n)=>{const o=r(t);if(!o)return;p.has(e)||p.set(e,new Map);p.get(e).set(o,n)},getAllFor:t=>p.get(t)||null,get:(t,e)=>{const n=r(t),o=g.getAllFor(e);return n&&o&&o.get(n)||null},remove:(t,e)=>{const n=r(t),o=p.get(e);o&&n&&(o.delete(n),0===o.size&&p.delete(e))}},m=(t,e)=>g.get(t,e);function b(t,e){const n=new CustomEvent(t,{cancelable:!0,bubbles:!0});return e instanceof Object&&d(n,e),n}const v=(t,e)=>t.getAttribute(e);function w(t){return"true"===t||"false"!==t&&(Number.isNaN(+t)?""===t||"null"===t?null:t:+t)}const y=t=>Object.keys(t),T=t=>t.toLowerCase();class E{constructor(t,e){const n=this,o=r(t);if(!o)throw Error(`${n.name} Error: "${t}" is not a valid selector.`);n.options={};const s=g.get(o,n.name);s&&s.dispose(),n.element=o,n.defaults&&Object.keys(n.defaults).length&&(n.options=function(t,e,n,o){const s={...t.dataset},i={},a={};return y(s).forEach(t=>{const e=o&&t.includes(o)?t.replace(o,"").replace(/[A-Z]/,t=>T(t)):t;a[e]=w(s[t])}),y(n).forEach(t=>{n[t]=w(n[t])}),y(e).forEach(o=>{i[o]=o in n?n[o]:o in a?a[o]:"title"===o?v(t,"title"):e[o]}),i}(o,n.defaults,e||{},"bs")),g.set(o,n.name,n)}get version(){return"4.1.0alpha3"}get name(){return this.constructor.name}get defaults(){return this.constructor.defaults}dispose(){const t=this;g.remove(t.element,t.name),y(t).forEach(e=>{t[e]=null})}}const x=t=>m(t,"Alert"),H=b("close.bs.alert"),k=b("closed.bs.alert");function A(t){const{element:e}=t;P(t),f(e,k),t.dispose(),e.remove()}function P(t,e){const s=e?n:o,{dismiss:i}=t;i&&s(i,"click",t.close)}class $ extends E{constructor(t){super(t);const{element:e}=this;this.dismiss=r('[data-bs-dismiss="alert"]',e),P(this,!0)}get name(){return"Alert"}close(t){const e=t?x(c(this,".alert")):this;if(!e)return;const{element:n}=e;if(h(n,"show")){if(f(n,H),H.defaultPrevented)return;u(n,"show"),h(n,"fade")?s(n,()=>A(e)):A(e)}}dispose(){P(this),super.dispose()}}d($,{selector:".alert",init:t=>new $(t),getInstance:x});const M=(t,e,n)=>t.setAttribute(e,n);function N(t,e){t.classList.add(e)}const L="data-bs-toggle",D=`[${L}="button"]`,S=t=>m(t,"Button");function C(t,e){(e?n:o)(t.element,"click",t.toggle)}class I extends E{constructor(t){super(t);const{element:e}=this;this.isActive=h(e,"active"),M(e,"aria-pressed",""+!!this.isActive),C(this,!0)}get name(){return"Button"}toggle(t){t&&t.preventDefault();const e=t?S(this):this;if(!e)return;const{element:n}=e;if(h(n,"disabled"))return;e.isActive=h(n,"active");const{isActive:o}=e;(o?u:N)(n,"active"),M(n,"aria-pressed",o?"false":"true")}dispose(){C(this),super.dispose()}}d(I,{selector:D,init:t=>new I(t),getInstance:S});const R="mouseenter",O="mouseleave";function W(t){if(null==t)return window;if(!(t instanceof Window)){const{ownerDocument:e}=t;return e&&e.defaultView||window}return t}function F(t,e){const{width:n,height:o,top:s,right:i,bottom:a,left:l}=t.getBoundingClientRect();let r=1,c=1;if(e&&t instanceof HTMLElement){const{offsetWidth:e,offsetHeight:s}=t;r=e>0&&Math.round(n)/e||1,c=s>0&&Math.round(o)/s||1}return{width:n/r,height:o/c,top:s/c,right:i/r,bottom:a/c,left:l/r,x:l/r,y:s/c}}function B(t){return i(t).documentElement}const X=t=>{const{top:e,bottom:n}=F(t),{clientHeight:o}=B(t);return e<=o&&n>=0},j=t=>"rtl"===B(t).dir;function z(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).querySelectorAll(t)}function Y(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByClassName(t)}const V=new Map,q=(t,e,n,o)=>{const s=r(t);if(s)if(o&&o.length){V.has(s)||V.set(s,new Map);V.get(s).set(o,setTimeout(e,n))}else V.set(s,setTimeout(e,n))},U=(t,e)=>{const n=r(t);if(!n)return null;const o=V.get(n);return e&&e.length&&o&&o.get?o.get(e)||null:o||null},G=(t,e)=>{const n=r(t);if(n)if(e&&e.length){const t=V.get(n);t&&t.get&&(clearTimeout(t.get(e)),t.delete(e),0===t.size&&V.delete(n))}else clearTimeout(V.get(n)),V.delete(n)},Z=t=>t.offsetHeight,J={passive:!0};function K(t){const e=["data-bs-target","data-bs-parent","data-bs-container","href"],n=i(t);return e.map(e=>{const o=v(t,e);return o?"data-bs-parent"===e?c(t,o):r(o,n):null}).filter(t=>t)[0]}const Q="carousel-item",_={pause:"hover",keyboard:!1,touch:!0,interval:5e3},tt=t=>m(t,"Carousel");let et=0,nt=0,ot=0;const st=b("slide.bs.carousel"),it=b("slid.bs.carousel");function at(){const t=this,e=tt(t);!e||e.isPaused||U(t,"paused")||N(t,"paused")}function lt(){const t=tt(this);t&&t.isPaused&&!U(this,"paused")&&t.cycle()}function rt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||K(this);if(!e)return;const n=tt(e);if(!n||n.isAnimating)return;const o=+v(this,"data-bs-slide-to");!this||h(this,"active")||Number.isNaN(o)||n.to(o)}function ct(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||K(this),n=e&&tt(e);if(!n||n.isAnimating)return;const o=v(this,"data-bs-slide");"next"===o?n.next():"prev"===o&&n.prev()}function dt({code:t}){const[e]=[...z('[data-bs-ride="carousel"]')].filter(t=>X(t)),n=tt(e);if(!n)return;const o=j(),s=o?"ArrowLeft":"ArrowRight";t===(o?"ArrowRight":"ArrowLeft")?n.prev():t===s&&n.next()}function ht(t){const e=tt(this);e&&!e.isTouch&&(et=t.changedTouches[0].pageX,this.contains(t.target)&&(e.isTouch=!0,gt(e,!0)))}function ut(t){const{changedTouches:e,type:n}=t,o=tt(this);o&&o.isTouch&&(nt=e[0].pageX,"touchmove"===n&&e.length>1&&t.preventDefault())}function ft(t){const e=this,n=tt(e);if(n&&n.isTouch&&(ot=nt||t.changedTouches[0].pageX,n.isTouch)){if((!e.contains(t.target)||!e.contains(t.relatedTarget))&&Math.abs(et-ot)<75)return;ntet&&(n.index-=1),n.isTouch=!1,n.to(n.index),gt(n)}}function pt(t,e){const{indicators:n}=t;[...n].forEach(t=>u(t,"active")),t.indicators[e]&&N(n[e],"active")}function gt(t,e){const{element:s}=t,i=e?n:o;i(s,"touchmove",ut,J),i(s,"touchend",ft,J)}function mt(t,e){const{element:s,options:i,slides:a,controls:l,indicators:r}=t,{touch:c,pause:d,interval:h,keyboard:u}=i,f=e?n:o;d&&h&&(f(s,R,at),f(s,O,lt),f(s,"touchstart",at,J),f(s,"touchend",lt,J)),c&&a.length>1&&f(s,"touchstart",ht,J),l.length&&l.forEach(t=>{t&&f(t,"click",ct)}),r.length&&r.forEach(t=>{f(t,"click",rt)}),u&&f(W(s),"keydown",dt)}function bt(t){const{slides:e,element:n}=t,o=r(`.${Q}.active`,n);return[...e].indexOf(o)}class vt extends E{constructor(t,e){super(t,e);const n=this;n.direction=j()?"right":"left",n.index=0,n.isTouch=!1;const{element:o}=n;n.slides=Y(Q,o);const{slides:s}=n;if(s.length<2)return;n.controls=[...z("[data-bs-slide]",o),...z(`[data-bs-slide][data-bs-target="#${o.id}"]`)],n.indicator=r(".carousel-indicators",o),n.indicators=[...n.indicator?z("[data-bs-slide-to]",n.indicator):[],...z(`[data-bs-slide-to][data-bs-target="#${o.id}"]`)];const{options:i}=n;n.options.interval=!0===i.interval?_.interval:i.interval,bt(n)<0&&(s.length&&N(s[0],"active"),n.indicators.length&&pt(n,0)),mt(n,!0),i.interval&&n.cycle()}get name(){return"Carousel"}get defaults(){return _}get isPaused(){return h(this.element,"paused")}get isAnimating(){return null!==r(`.${Q}-next,.${Q}-prev`,this.element)}cycle(){const t=this,{element:e,options:n,isPaused:o}=t;G(e,"carousel"),o&&(G(e,"paused"),u(e,"paused")),q(e,()=>{!t.isPaused&&X(e)&&(t.index+=1,t.to(t.index))},n.interval,"carousel")}pause(){const{element:t,options:e}=this;!this.isPaused&&e.interval&&(N(t,"paused"),q(t,()=>{},1,"paused"))}next(){const t=this;t.isAnimating||(t.index+=1,t.to(t.index))}prev(){const t=this;t.isAnimating||(t.index-=1,t.to(t.index))}to(t){const n=this,{element:o,slides:a,options:l}=n,r=bt(n),c=j();let p=t;if(n.isAnimating||r===p)return;rp||r===a.length-1&&0===p)&&(n.direction=c?"left":"right");const{direction:g}=n;p<0?p=a.length-1:p>=a.length&&(p=0);const m="left"===g?"next":"prev",b="left"===g?"start":"end",v={relatedTarget:a[p],from:r,to:p,direction:g};d(st,v),d(it,v),f(o,st),st.defaultPrevented||(n.index=p,pt(n,p),e(a[p])&&h(o,"slide")?q(o,()=>{N(a[p],`${Q}-${m}`),Z(a[p]),N(a[p],`${Q}-${b}`),N(a[r],`${Q}-${b}`),s(a[p],()=>function(t){const{index:e,direction:n,element:o,slides:s,options:a}=t;if(t.isAnimating&&tt(o)){const l=bt(t),r="left"===n?"next":"prev",c="left"===n?"start":"end";N(s[e],"active"),u(s[l],"active"),u(s[e],`${Q}-${r}`),u(s[e],`${Q}-${c}`),u(s[l],`${Q}-${c}`),f(o,it),G(o,"data-bs-slide"),i(o).hidden||!a.interval||t.isPaused||t.cycle()}}(n))},17,"data-bs-slide"):(N(a[p],"active"),u(a[r],"active"),q(o,()=>{G(o,"data-bs-slide"),o&&l.interval&&!n.isPaused&&n.cycle(),f(o,it)},17,"data-bs-slide")))}dispose(){const t=this,{slides:e}=t,n=["start","end","prev","next"];[...e].forEach((e,o)=>{h(e,"active")&&pt(t,o),n.forEach(t=>u(e,`${Q}-${t}`))}),mt(t),super.dispose()}}d(vt,{selector:'[data-bs-ride="carousel"]',init:t=>new vt(t),getInstance:tt});const wt=`[${L}="collapse"]`,yt={parent:null},Tt=t=>m(t,"Collapse"),Et=b("show.bs.collapse"),xt=b("shown.bs.collapse"),Ht=b("hide.bs.collapse"),kt=b("hidden.bs.collapse");function At(t){const{element:e,parent:n,triggers:o}=t;f(e,Ht),Ht.defaultPrevented||(q(e,()=>{},17),n&&q(n,()=>{},17),e.style.height=e.scrollHeight+"px",u(e,"collapse"),u(e,"show"),N(e,"collapsing"),Z(e),e.style.height="0px",s(e,()=>{G(e),n&&G(n),o.forEach(t=>M(t,"aria-expanded","false")),u(e,"collapsing"),N(e,"collapse"),e.style.height="",f(e,kt)}))}function Pt(t,e){const s=e?n:o,{triggers:i}=t;i.length&&i.forEach(t=>s(t,"click",$t))}function $t(t){const{target:e}=t,n=e&&c(e,wt),o=n&&K(n),s=o&&Tt(o);s&&s.toggle(),n&&"A"===n.tagName&&t.preventDefault()}class Mt extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;this.triggers=[...z(wt)].filter(t=>K(t)===n),this.parent=r(o.parent),Pt(this,!0)}get name(){return"Collapse"}get defaults(){return yt}toggle(){h(this.element,"show")?this.hide():this.show()}hide(){const{triggers:t,element:e}=this;U(e)||(At(this),t.length&&t.forEach(t=>N(t,"collapsed")))}show(){const t=this,{element:e,parent:n,triggers:o}=t;let i,a;n&&(i=[...z(".collapse.show",n)].find(t=>Tt(t)),a=i&&Tt(i)),n&&(!n||U(n))||U(e)||(a&&i!==e&&(At(a),a.triggers.forEach(t=>{N(t,"collapsed")})),function(t){const{element:e,parent:n,triggers:o}=t;f(e,Et),Et.defaultPrevented||(q(e,()=>{},17),n&&q(n,()=>{},17),N(e,"collapsing"),u(e,"collapse"),e.style.height=e.scrollHeight+"px",s(e,()=>{G(e),n&&G(n),o.forEach(t=>M(t,"aria-expanded","true")),u(e,"collapsing"),N(e,"collapse"),N(e,"show"),e.style.height="",f(e,xt)}))}(t),o.length&&o.forEach(t=>u(t,"collapsed")))}dispose(){Pt(this),super.dispose()}}d(Mt,{selector:".collapse",init:t=>new Mt(t),getInstance:Tt});const Nt="scroll",Lt="resize",Dt="ArrowUp",St="ArrowDown",Ct=(t,e)=>t.hasAttribute(e),It=(t,e)=>{d(t.style,e)},Rt=t=>t.focus(),Ot=["dropdown","dropup","dropstart","dropend"];function Wt(t){const e=c(t,"A");return t&&(Ct(t,"href")&&"#"===t.href.slice(-1)||e&&Ct(e,"href")&&"#"===e.href.slice(-1))}const[Ft,Bt,Xt,jt]=Ot,zt=`[${L}="${Ft}"]`,Yt=t=>m(t,"Dropdown"),Vt=[Ft,Bt],qt=[Xt,jt],Ut=["A","BUTTON"],Gt={offset:5,display:"dynamic"},Zt=b("show.bs."+Ft),Jt=b("shown.bs."+Ft),Kt=b("hide.bs."+Ft),Qt=b("hidden.bs."+Ft);function _t(e){const{element:n,menu:o,parentElement:s,options:i}=e,{offset:a}=i;if("static"===t(o,"position"))return;const l=j(n),r=h(s,"dropdown-menu-end");["margin","top","bottom","left","right"].forEach(t=>{o.style[t]=""});let c=Ot.find(t=>h(s,t))||Ft,u={dropdown:[a,0,0],dropup:[0,0,a],dropstart:l?[-1,0,0,a]:[-1,a,0],dropend:l?[-1,a,0]:[-1,0,0,a]};const f={dropdown:{top:"100%"},dropup:{top:"auto",bottom:"100%"},dropstart:l?{left:"100%",right:"auto"}:{left:"auto",right:"100%"},dropend:l?{left:"auto",right:"100%"}:{left:"100%",right:"auto"},menuEnd:l?{right:"auto",left:0}:{right:0,left:"auto"}},{offsetWidth:p,offsetHeight:g}=o,{clientWidth:m,clientHeight:b}=B(n),{left:v,top:w,width:y,height:T}=F(n),E=v-p-a<0,x=v+p+y+a>=m,H=w+g+a>=b,k=w+g+T+a>=b,A=w-g-a<0,P=(!l&&r||l&&!r)&&v+y-p<0,$=(l&&r||!l&&!r)&&v+p>=m;qt.includes(c)&&E&&x&&(c=Ft),c===Xt&&(l?x:E)&&(c=jt),c===jt&&(l?E:x)&&(c=Xt),c===Bt&&A&&!k&&(c=Ft),c===Ft&&k&&!A&&(c=Bt),qt.includes(c)&&H&&d(f[c],{top:"auto",bottom:0}),Vt.includes(c)&&(P||$)&&v+y+Math.abs(p-y)+at?t+"px":t).join(" "),It(o,f[c]),h(o,"dropdown-menu-end")&&It(o,f.menuEnd)}function te(t){const{element:e}=t,s=t.open?n:o,a=i(e);s(a,"click",oe),s(a,"focus",oe),s(a,"keydown",ie),s(a,"keyup",ae),"dynamic"===t.options.display&&[Nt,Lt].forEach(t=>{s(W(e),t,le,J)})}function ee(t,e){(e?n:o)(t.element,"click",se)}function ne(t){const e=[...Ot,"btn-group","input-group"].map(t=>Y(t+" show"),i(t)).find(t=>t.length);return e&&e.length?[...e[0].children].find(t=>Ct(t,L)):null}function oe(t){const{target:e,type:n}=t;if(!e||!e.closest)return;const o=ne(e);if(!o)return;const s=Yt(o);if(!s)return;const{parentElement:i,menu:a}=s,l=null!==c(e,zt),r=i&&i.contains(e)&&("form"===e.tagName||null!==c(e,"form"));"click"===n&&Wt(e)&&t.preventDefault(),("focus"!==n||e!==o&&e!==a&&!a.contains(e))&&(r||l||s&&s.hide())}function se(t){const{target:e}=t,n=Yt(this);n&&(n.toggle(),e&&Wt(e)&&t.preventDefault())}function ie(t){[St,Dt].includes(t.code)&&t.preventDefault()}function ae(t){const{code:e}=t,n=ne(this),o=n&&Yt(n),s=n&&i(n).activeElement;if(!o||!s)return;const{menu:a,open:l}=o,r=function(t){return[...t.children].map(t=>{if(t&&Ut.includes(t.tagName))return t;const{firstElementChild:e}=t;return e&&Ut.includes(e.tagName)?e:null}).filter(t=>t)}(a);if(r&&r.length&&[St,Dt].includes(e)){let t=r.indexOf(s);s===n?t=0:e===Dt?t=t>1?t-1:0:e===St&&(t=t{t.relatedTarget=e}),f(s,Zt),Zt.defaultPrevented||(N(o,"show"),N(s,"show"),M(e,"aria-expanded","true"),_t(t),t.open=!n,setTimeout(()=>{Rt(e),te(t),f(s,Jt)},1))}hide(){const t=this,{element:e,open:n,menu:o,parentElement:s}=t;[Kt,Qt].forEach(t=>{t.relatedTarget=e}),f(s,Kt),Kt.defaultPrevented||(u(o,"show"),u(s,"show"),M(e,"aria-expanded","false"),t.open=!n,setTimeout(()=>te(t),1),f(s,Qt))}dispose(){const{parentElement:t}=this;h(t,"show")&&this.open&&this.hide(),ee(this),super.dispose()}}d(re,{selector:zt,init:t=>new re(t),getInstance:Yt});const ce=(t,e)=>t.removeAttribute(e);function de(t){return i(t).body}const he=t=>t instanceof W(t).ShadowRoot||t instanceof ShadowRoot;const ue=t=>["TABLE","TD","TH"].includes(t.tagName),fe=t=>t instanceof HTMLElement;function pe(e,n){const o=["HTML","BODY"];if(n){let{offsetParent:n}=e;const s=W(e);for(;n&&(ue(n)||fe(n)&&!["sticky","fixed"].includes(t(n,"position")));)n=n.offsetParent;return(!n||n&&(o.includes(n.tagName)||"static"===t(n,"position")))&&(n=s),n}const s=[];let{parentNode:i}=e;for(;i&&!o.includes(i.nodeName);)i="HTML"===(a=i).nodeName?a:a.assignedSlot||a.parentNode||(he(a)?a.host:null)||B(a),he(i)||i.shadowRoot||ue(i)||s.push(i);var a;return s.find((e,n)=>"relative"!==t(e,"position")&&s.slice(n+1).every(e=>"static"===t(e,"position"))?e:null)||de(e)}const ge="sticky-top",me="position-sticky",be=t=>[...Y("fixed-top",t),...Y("fixed-bottom",t),...Y(ge,t),...Y(me,t),...Y("is-fixed",t)];function ve(t){const{clientWidth:e}=B(t),{innerWidth:n}=W(t);return Math.abs(n-e)}function we(e,n){const o=de(e),s=parseInt(t(o,"paddingRight"),10),i="hidden"===t(o,"overflow")&&s?0:ve(e),a=be(o);n&&(It(o,{overflow:"hidden",paddingRight:s+i+"px"}),a.length&&a.forEach(e=>{const n=t(e,"paddingRight");if(e.style.paddingRight=parseInt(n,10)+i+"px",[ge,me].some(t=>h(e,t))){const n=t(e,"marginRight");e.style.marginRight=parseInt(n,10)-i+"px"}}))}const ye="modal-backdrop",Te="offcanvas-backdrop",Ee=i().createElement("div");function xe(t){return r(".modal.show,.offcanvas.show",i(t))}function He(t){const e=t?ye:Te;[ye,Te].forEach(t=>{u(Ee,t)}),N(Ee,e)}function ke(t,e,n){He(n),t.append(Ee),e&&N(Ee,"fade")}function Ae(){N(Ee,"show"),Z(Ee)}function Pe(){u(Ee,"show")}function $e(t){xe(t)||(u(Ee,"fade"),Ee.remove(),function(t){const e=de(t);It(e,{paddingRight:"",overflow:""});const n=be(e);n.length&&n.forEach(t=>{It(t,{paddingRight:"",marginRight:""})})}(t))}function Me(e){return e&&"hidden"!==t(e,"visibility")&&null!==e.offsetParent}const Ne=`[${L}="modal"]`,Le={backdrop:!0,keyboard:!0},De=t=>m(t,"Modal"),Se=b("show.bs.modal"),Ce=b("shown.bs.modal"),Ie=b("hide.bs.modal"),Re=b("hidden.bs.modal");function Oe(t){const{element:e}=t,n=ve(e),{clientHeight:o,scrollHeight:s}=B(e),{clientHeight:i,scrollHeight:a}=e,l=i!==a;if(!l&&n){const t=j(e)?"paddingLeft":"paddingRight";e.style[t]=n+"px"}we(e,l||o!==s)}function We(t,e){const s=e?n:o,{element:a}=t;s(a,"click",qe),s(W(a),Lt,t.update,J),s(i(a),"keydown",Ve)}function Fe(t,e){const s=e?n:o,{triggers:i}=t;i.length&&i.forEach(t=>s(t,"click",Ye))}function Be(t){const{triggers:e,element:n}=t;if($e(n),n.style.paddingRight="",e.length){const t=e.find(t=>Me(t));t&&Rt(t)}}function Xe(t){const{element:e,relatedTarget:n}=t;Rt(e),We(t,!0),Ce.relatedTarget=n,f(e,Ce)}function je(t){const{element:e,hasFade:n}=t;e.style.display="block",Oe(t),xe(e)||(de(e).style.overflow="hidden"),N(e,"show"),ce(e,"aria-hidden"),M(e,"aria-modal","true"),n?s(e,()=>Xe(t)):Xe(t)}function ze(t,e){const{element:n,options:o,relatedTarget:i,hasFade:a}=t;n.style.display="",o.backdrop&&!e&&a&&h(Ee,"show")&&!xe(n)?(Pe(),s(Ee,()=>Be(t))):Be(t),We(t),Re.relatedTarget=i,f(n,Re)}function Ye(t){const{target:e}=t,n=e&&c(this,Ne),o=n&&K(n),s=o&&De(o);s&&(n&&"A"===n.tagName&&t.preventDefault(),s.relatedTarget=n,s.toggle())}function Ve({code:t}){const e=r(".modal.show"),n=e&&De(e);if(!n)return;const{options:o}=n;o.keyboard&&"Escape"===t&&h(e,"show")&&(n.relatedTarget=null,n.hide())}function qe(t){const n=this,o=De(n);if(!o||U(n))return;const{options:a,isStatic:l,modalDialog:r}=o,{backdrop:d}=a,{target:h}=t,f=i(n).getSelection().toString().length,p=r.contains(h),g=h&&c(h,'[data-bs-dismiss="modal"]');l&&!p?q(n,()=>{N(n,"modal-static"),s(r,()=>function(t){const{element:n,modalDialog:o}=t,s=e(o)+17;u(n,"modal-static"),q(n,()=>G(n),s)}(o))},17):(g||!f&&!l&&!p&&d)&&(o.relatedTarget=g||null,o.hide(),t.preventDefault())}class Ue extends E{constructor(t,e){super(t,e);const{element:n}=this;this.modalDialog=r(".modal-dialog",n),this.triggers=[...z(Ne)].filter(t=>K(t)===n),this.isStatic="static"===this.options.backdrop,this.hasFade=h(n,"fade"),this.relatedTarget=null,this.container=pe(n),Fe(this,!0),this.update=this.update.bind(this)}get name(){return"Modal"}get defaults(){return Le}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,hasFade:s,relatedTarget:i,container:a}=t,{backdrop:l}=o;let r=0;if(h(n,"show"))return;if(Se.relatedTarget=i||null,f(n,Se),Se.defaultPrevented)return;const c=xe(n);if(c&&c!==n){(De(c)||m(c,"Offcanvas")).hide()}l?(c||h(Ee,"show")?He(!0):ke(a,s,!0),r=e(Ee),h(Ee,"show")||Ae(),setTimeout(()=>je(t),r)):(je(t),c&&h(Ee,"show")&&Pe())}hide(t){const e=this,{element:n,hasFade:o,relatedTarget:i}=e;h(n,"show")&&(Ie.relatedTarget=i||null,f(n,Ie),Ie.defaultPrevented||(u(n,"show"),M(n,"aria-hidden","true"),ce(n,"aria-modal"),o&&!1!==t?s(n,()=>ze(e)):ze(e,t)))}update(){h(this.element,"show")&&Oe(this)}dispose(){this.hide(!0),Fe(this),super.dispose()}}d(Ue,{selector:".modal",init:t=>new Ue(t),getInstance:De});const Ge=`[${L}="offcanvas"]`,Ze={backdrop:!0,keyboard:!0,scroll:!1},Je=t=>m(t,"Offcanvas"),Ke=b("show.bs.offcanvas"),Qe=b("shown.bs.offcanvas"),_e=b("hide.bs.offcanvas"),tn=b("hidden.bs.offcanvas");function en(t,e){const s=e?n:o;t.triggers.forEach(t=>s(t,"click",an))}function nn(t,e){const s=e?n:o,a=i(t.element);s(a,"keydown",rn),s(a,"click",ln)}function on(t){const{element:e,options:n}=t;n.scroll||(!function(t){const{element:e}=t,{clientHeight:n,scrollHeight:o}=B(e);we(e,n!==o)}(t),de(e).style.overflow="hidden"),N(e,"offcanvas-toggling"),N(e,"show"),e.style.visibility="visible",s(e,()=>function(t){const{element:e,triggers:n}=t;u(e,"offcanvas-toggling"),ce(e,"aria-hidden"),M(e,"aria-modal","true"),M(e,"role","dialog"),n.length&&n.forEach(t=>M(t,"aria-expanded","true"));f(e,Qe),nn(t,!0),Rt(e)}(t))}function sn(t){const{element:e,options:n}=t,o=xe(e);e.blur(),!o&&n.backdrop&&h(Ee,"show")?(Pe(),s(Ee,()=>cn(t))):cn(t)}function an(t){const e=c(this,Ge),n=e&&K(e),o=n&&Je(n);o&&(o.relatedTarget=e,o.toggle(),e&&"A"===e.tagName&&t.preventDefault())}function ln(t){const e=r(".offcanvas.show",this);if(!e)return;const n=r('[data-bs-dismiss="offcanvas"]',e),o=Je(e);if(!o)return;const{options:s,triggers:a}=o,{target:l}=t,d=c(l,Ge),h=i(e).getSelection();h&&h.toString().length||!(!e.contains(l)&&s.backdrop&&(!d||d&&!a.includes(d))||n&&n.contains(l))||(o.relatedTarget=n&&n.contains(l)?n:null,o.hide()),d&&"A"===d.tagName&&t.preventDefault()}function rn({code:t}){const e=r(".offcanvas.show",this);if(!e)return;const n=Je(e);n&&n.options.keyboard&&"Escape"===t&&(n.relatedTarget=null,n.hide())}function cn(t){const{element:e,triggers:n}=t;if(M(e,"aria-hidden","true"),ce(e,"aria-modal"),ce(e,"role"),e.style.visibility="",n.length){n.forEach(t=>M(t,"aria-expanded","false"));const t=n.find(t=>Me(t));t&&Rt(t)}$e(e),f(e,tn),u(e,"offcanvas-toggling"),xe(e)||nn(t)}class dn extends E{constructor(t,e){super(t,e);const{element:n}=this;this.triggers=[...z(Ge)].filter(t=>K(t)===n),this.container=pe(n),this.relatedTarget=null,en(this,!0)}get name(){return"Offcanvas"}get defaults(){return Ze}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,container:s,relatedTarget:i}=t;let a=0;if(h(n,"show"))return;if(Ke.relatedTarget=i,Qe.relatedTarget=i,f(n,Ke),Ke.defaultPrevented)return;const l=xe(n);if(l&&l!==n){(Je(l)||m(l,"Modal")).hide()}o.backdrop?(l?He():ke(s,!0),a=e(Ee),h(Ee,"show")||Ae(),setTimeout(()=>on(t),a)):(on(t),l&&h(Ee,"show")&&Pe())}hide(t){const e=this,{element:n,relatedTarget:o}=e;h(n,"show")&&(_e.relatedTarget=o,tn.relatedTarget=o,f(n,_e),_e.defaultPrevented||(N(n,"offcanvas-toggling"),u(n,"show"),t?sn(e):s(n,()=>sn(e))))}dispose(){this.hide(!0),en(this),super.dispose()}}d(dn,{selector:".offcanvas",init:t=>new dn(t),getInstance:Je});function hn(t){const e="tooltip"===t;return``}const un=t=>t&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(e=>t instanceof e);function fn(t,e,n){const o=e instanceof HTMLElement,s=F(t,o&&function(t){const{width:e,height:n}=F(t),{offsetWidth:o,offsetHeight:s}=t;return Math.round(e)!==o||Math.round(n)!==s}(e)),i={x:0,y:0};if(o){const t=F(e,!0);i.x=t.x+e.clientLeft,i.y=t.y+e.clientTop}return{x:s.left+n.x-i.x,y:s.top+n.y-i.y,width:s.width,height:s.height}}var pn={top:"top",bottom:"bottom",left:"start",right:"end"};function gn(e,n){const o=/\b(top|bottom|start|end)+/,{element:s,tooltip:i,options:a,arrow:l,offsetParent:r}=e,c={...pn};It(i,{top:"0px",left:"0px",right:""});const d="Popover"===e.name,h=i.offsetWidth,u=i.offsetHeight,f=j(s);f&&(c.left="end",c.right="start");const p=B(s),g=p.clientWidth,m=p.clientHeight,{container:b}=a;let{placement:v}=a;const{left:w,right:y,top:T}=F(b,!0),E=b.clientWidth,x=Math.abs(E-b.offsetWidth),H=t(b,"position"),k="fixed"===H,A="static"===H,P="sticky"===H&&T===parseFloat(t(b,"top")),$=f&&k?x:0,M=k?E+w+(f?x:0):E+w+(g-y)-1,{width:N,height:L,left:D,right:S,top:C}=F(s,!0),I=function(t){const e="scrollX"in t;return{x:e?t.scrollX:t.scrollLeft,y:e?t.scrollY:t.scrollTop}}(r),{x:R,y:O}=fn(s,r,I);let W,X,z,Y,V,q;It(l,{top:"",left:"",right:""});const U=l.offsetWidth||0,G=l.offsetHeight||0,Z=U/2;let J=C-u-G<0,K=C+u+L+G>=m,Q=D-h-U<$,_=D+h+N+U>=M;const tt=["left","right"],et=["top","bottom"];if(J=tt.includes(v)?C+L/2-u/2-G<0:J,K=tt.includes(v)?C+u/2+L/2+G>=m:K,Q=et.includes(v)?D+N/2-h/2<$:Q,_=et.includes(v)?D+h/2+N/2>=M:_,v=tt.includes(v)&&Q&&_?"top":v,v="top"===v&&J?"bottom":v,v="bottom"===v&&K?"top":v,v="left"===v&&Q?"right":v,v="right"===v&&_?"left":v,i.className.includes(v)||(i.className=i.className.replace(o,c[v])),tt.includes(v))X="left"===v?R-h-(d?U:0):R+N+(d?U:0),J?(W=O,W+=P?-T-I.y:0,Y=L/2-U):K?(W=O-u+L,W+=P?-T-I.y:0,Y=u-L/2-U):(W=O-u/2+L/2,W+=P?-T-I.y:0,Y=u/2-G/2);else if(et.includes(v))if(n&&un(s)){let t=0,e=0;A?(t=n.pageX,e=n.pageY):(t=n.clientX-w+(k?I.x:0),e=n.clientY-T+(k?I.y:0)),t-=f&&k&&x?x:0,W="top"===v?e-u-U:e+U,n.clientX-h/2<$?(X=0,V=t-Z):n.clientX+h/2>M?(X="auto",z=0,q=M-t-Z,q-=k?w+(f?x:0):0):(X=t-h/2,V=h/2-Z)}else W="top"===v?O-u-(d?G:0):O+L+(d?G:0),Q?(X=0,V=R+N/2-Z):_?(X="auto",z=0,q=N/2+M-S-Z):(X=R-h/2+N/2,V=h/2-Z);It(i,{top:W+"px",left:"auto"===X?X:X+"px",right:void 0!==z?z+"px":""}),l instanceof HTMLElement&&(void 0!==Y&&(l.style.top=Y+"px"),void 0!==V?l.style.left=V+"px":void 0!==q&&(l.style.right=q+"px"))}const mn={template:hn("tooltip"),title:null,customClass:null,trigger:"hover focus",placement:"top",sanitizeFn:null,animation:!0,delay:200,container:null},bn="focusin",vn="focusout",{userAgentData:wn}=navigator,yn=wn,{userAgent:Tn}=navigator,En=Tn,xn=/(iPhone|iPod|iPad)/,Hn=yn?yn.brands.some(t=>xn.test(t.brand)):xn.test(En);let kn=1;const An=new Map;function Pn(t,e,n){if("string"!=typeof e||e.length)if("string"==typeof e){let o=e.trim();"function"==typeof n&&(o=n(o));const s=(new DOMParser).parseFromString(o,"text/html"),{body:i}=s,a=i.children.length?"innerHTML":"innerText";t[a]=i[a]}else e instanceof HTMLElement&&t.append(e)}function $n(t,e){return t instanceof HTMLElement&&e.contains(t)}const Mn=`[${L}="tooltip"],[data-tip="tooltip"]`;let Nn=t=>m(t,"Tooltip");function Ln(t){const{element:e}=t;In(t),e.hasAttribute("data-original-title")&&"tooltip"===t.name&&On(t)}function Dn(t,e){const s=e?n:o,{element:a}=t;s(i(a),"touchstart",Wn,J),un(a)||[Nt,Lt].forEach(e=>{s(W(a),e,t.update,J)})}function Sn(t){const{element:e}=t,n=b("shown.bs."+T(t.name));Dn(t,!0),f(e,n),G(e,"in")}function Cn(t){const{element:e}=t,n=b("hidden.bs."+T(t.name));Dn(t),function(t){const{element:e,tooltip:n}=t;ce(e,"aria-describedby"),n.remove()}(t),f(e,n),G(e,"out")}function In(t,e){const s=e?n:o,{element:a,options:l,btn:r}=t,{trigger:c,dismissible:d}=l;if(c.includes("manual"))return;t.enabled=!!e;const h=c.split(" "),u=un(a);u&&s(a,"mousemove",t.update,J),h.forEach(e=>{u||"hover"===e?(s(a,"mousedown",t.show),s(a,R,t.show),d&&r?s(r,"click",t.hide):(s(a,O,t.hide),s(i(a),"touchstart",Wn,J))):"click"===e?s(a,e,d?t.show:t.toggle):"focus"===e&&(s(a,bn,t.show),d||s(a,vn,t.hide),Hn&&s(a,"click",()=>Rt(a)))})}function Rn(t,e){const s=e?n:o,{element:i,options:a,offsetParent:l}=t,{container:r}=a,{offsetHeight:d,scrollHeight:h}=r,u=c(i,".modal"),f=c(i,".offcanvas");if(!un(i)){const e=W(i),n=d!==h||l!==e?r:e;s(e,Lt,t.update,J),s(n,Nt,t.update,J)}u&&n(u,"hide.bs.modal",t.hide),f&&n(f,"hide.bs.offcanvas",t.hide)}function On(t,e){const n=["data-original-title","title"],{element:o}=t;M(o,n[e?0:1],e||v(o,n[0])),ce(o,n[e?1:0])}function Wn({target:t}){const{tooltip:e,element:n}=this;e.contains(t)||t===n||n.contains(t)||this.hide()}class Fn extends E{constructor(e,n){super(e,n);const o=this,{element:s}=o,a="Tooltip"===o.name,l=a?"tooltip":"popover",c=a?"Tooltip":"Popover";Nn=t=>m(t,c),o.tooltip={},a||(o.btn=null),o.arrow={},o.offsetParent={},o.enabled=!0,o.id=`${l}-${function(t,e){kn+=1;let n=An.get(t),o=kn;return n?o=e&&e.length&&n.get&&n.get(e)?n.get(e):n:e&&e.length?(n||(An.set(t,new Map),n=An.get(t)),n.set(e,o)):An.set(t,o),o}(s,l)}`;const{options:d}=o;if(!d.title&&a||!a&&!d.content)return;const u=r(d.container),f=pe(s);o.options.container=!u||u&&["static","relative"].includes(t(u,"position"))?f:u||de(s),mn.title=null,Wn.bind(o),o.update=o.update.bind(o),o.show=o.show.bind(o),o.hide=o.hide.bind(o),o.toggle=o.toggle.bind(o),s.hasAttribute("title")&&a&&On(o,d.title),function(t){const{id:e,element:n,options:o}=t,{animation:s,customClass:a,sanitizeFn:l,placement:c,dismissible:d}=o;let{title:u,content:f}=o;const p="Tooltip"===t.name,g=p?"tooltip":"popover",{template:m,btnClose:b}=o,v={...pn};j(n)&&(v.left="end",v.right="start");const w=`bs-${g}-${v[c]}`;let y;if([Element,HTMLElement].some(t=>m instanceof t))y=m;else{const t=i(n).createElement("div");Pn(t,m,l),y=t.firstElementChild}t.tooltip=y&&y.cloneNode(!0);const{tooltip:T}=t;M(T,"id",e),M(T,"role","tooltip");const E=p?"tooltip-inner":"popover-body",x=p?null:r(".popover-header",T),H=r("."+E,T);t.arrow=r(`.${g}-arrow`,T),d&&(u?u instanceof HTMLElement?Pn(u,b,l):u+=b:(x&&x.remove(),f instanceof HTMLElement?Pn(f,b,l):f+=b)),p?u&&H&&Pn(H,u,l):(u&&x&&Pn(x,u,l),f&&H&&Pn(H,f,l),t.btn=r(".btn-close",T)),h(T,g)||N(T,g),s&&!h(T,"fade")&&N(T,"fade"),a&&!h(T,a)&&N(T,a),h(T,w)||N(T,w)}(o),In(o,!0)}get name(){return"Tooltip"}get defaults(){return mn}show(t){const e=this,{options:n,tooltip:o,element:i,id:a}=e,{container:l,animation:r}=n,c=U(i,"out");G(i,"out"),!o||c||$n(o,l)||q(i,()=>{const n=b("show.bs."+T(e.name));f(i,n),n.defaultPrevented||(l.append(o),M(i,"aria-describedby","#"+a),e.offsetParent=pe(o,!0),e.update(t),Rn(e,!0),h(o,"show")||N(o,"show"),r?s(o,()=>Sn(e)):Sn(e))},17,"in")}hide(){const t=this,{options:e,tooltip:n,element:o}=t,{container:i,animation:a,delay:l}=e;G(o,"in"),n&&$n(n,i)&&q(o,()=>{const e=b("hide.bs."+T(t.name));f(o,e),e.defaultPrevented||(u(n,"show"),Rn(t),a?s(n,()=>Cn(t)):Cn(t))},l+17,"out")}update(t){gn(this,t)}toggle(t){const{tooltip:e,options:n}=this;$n(e,n.container)?this.hide():this.show(t)}enable(){const t=this,{enabled:e}=t;e||(In(t,!0),t.enabled=!e)}disable(){const t=this,{element:n,tooltip:o,options:s,enabled:i}=t,{animation:a,container:l,delay:r}=s;i&&($n(o,l)&&a?(t.hide(),q(n,()=>{In(t),G(n,"tooltip")},e(o)+r+17,"tooltip")):In(t),t.enabled=!i)}toggleEnabled(){this.enabled?this.disable():this.enable()}dispose(){const t=this,{tooltip:e,options:n}=t;n.animation&&$n(e,n.container)?(n.delay=0,t.hide(),s(e,()=>Ln(t))):Ln(t),super.dispose()}}d(Fn,{selector:Mn,init:t=>new Fn(t),getInstance:Nn,styleTip:gn});const Bn=`[${L}="popover"],[data-tip="popover"]`,Xn={...mn,template:hn("popover"),btnClose:'',dismissible:!1,content:null};class jn extends Fn{constructor(t,e){super(t,e)}get name(){return"Popover"}get defaults(){return Xn}show(){super.show();const{options:t,btn:e}=this;t.dismissible&&e&&setTimeout(()=>Rt(e),17)}}function zn(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByTagName(t)}d(jn,{selector:Bn,init:t=>new jn(t),getInstance:t=>m(t,"Popover"),styleTip:gn});const Yn={offset:10,target:null},Vn=b("activate.bs.scrollspy");function qn(t){const{target:e,scrollTarget:n,options:o,itemsLength:s,scrollHeight:a,element:l}=t,{offset:c}=o,d=n instanceof Window,h=e&&zn("A",e),u=n&&function(t){return t instanceof HTMLElement?t.scrollHeight:B(t).scrollHeight}(n);if(t.scrollTop=d?n.scrollY:n.scrollTop,h&&(s!==h.length||u!==a)){let e,n,o;t.items=[],t.offsets=[],t.scrollHeight=u,t.maxScroll=t.scrollHeight-function({element:t,scrollTarget:e}){return e instanceof Window?e.innerHeight:F(t).height}(t),[...h].forEach(s=>{e=v(s,"href"),n=e&&"#"===e.charAt(0)&&"#"!==e.slice(-1)&&r(e,i(l)),n&&(t.items.push(s),o=F(n),t.offsets.push((d?o.top+t.scrollTop:n.offsetTop)-c))}),t.itemsLength=t.items.length}}function Un(t){[...zn("A",t)].forEach(t=>{h(t,"active")&&u(t,"active")})}function Gn(t,e){const{target:n,element:o}=t;Un(n),t.activeItem=e,N(e,"active");const s=[];let i=e;for(;i!==de(o);)i=i.parentElement,(h(i,"nav")||h(i,"dropdown-menu"))&&s.push(i);s.forEach(t=>{const e=t.previousElementSibling;e&&!h(e,"active")&&N(e,"active")}),Vn.relatedTarget=e,f(o,Vn)}function Zn(t,e){(e?n:o)(t.scrollTarget,Nt,t.refresh,J)}class Jn extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;if(this.target=r(o.target,i(n)),!this.target)return;const s=W(n);this.scrollTarget=n.clientHeight=o){const e=i[s-1];return void(a!==e&&Gn(t,e))}const{offsets:l}=t;if(a&&n0)return t.activeItem=null,void Un(e);i.forEach((e,o)=>{a!==e&&n>=l[o]&&(void 0===l[o+1]||nnew Jn(t),getInstance:t=>m(t,"ScrollSpy")});const Kn=`[${L}="tab"]`,Qn=t=>m(t,"Tab"),_n=b("show.bs.tab"),to=b("shown.bs.tab"),eo=b("hide.bs.tab"),no=b("hidden.bs.tab"),oo=new Map;function so(t){const{tabContent:e,nav:n}=t;e&&(e.style.height="",u(e,"collapsing")),n&&G(n)}function io(t){const{element:e,tabContent:n,nav:o}=t,{currentHeight:i,nextHeight:a}=oo.get(e),{tab:l}=o&&oo.get(o);n?i===a?so(t):setTimeout(()=>{n.style.height=a+"px",Z(n),s(n,()=>so(t))},50):o&&G(o),to.relatedTarget=l,f(e,to)}function ao(t){const{element:e,content:n,tabContent:o,nav:i}=t,{tab:a,content:l}=i&&oo.get(i);let r=0;if(o&&([l,n].forEach(t=>N(t,"overflow-hidden")),r=l.scrollHeight),_n.relatedTarget=a,no.relatedTarget=e,f(e,_n),!_n.defaultPrevented){if(N(n,"active"),u(l,"active"),o){const t=n.scrollHeight;oo.set(e,{currentHeight:r,nextHeight:t}),N(o,"collapsing"),o.style.height=r+"px",Z(o),[l,n].forEach(t=>u(t,"overflow-hidden"))}n&&h(n,"fade")?setTimeout(()=>{N(n,"show"),s(n,()=>{io(t)})},17):io(t),f(a,no)}}function lo(t,e){(e?n:o)(t.element,"click",ro)}function ro(t){const e=Qn(this);e&&(t.preventDefault(),e.show())}class co extends E{constructor(t){super(t);const{element:e}=this,n=K(e);if(!n)return;const o=c(e,".nav"),s=c(n,".tab-content");this.nav=o,this.content=n,this.tabContent=s,this.dropdown=o&&r(`.${Ot[0]}-toggle`,o),lo(this,!0)}get name(){return"Tab"}show(){const t=this,{element:e,nav:n,dropdown:o}=t;if(!(n&&U(n)||h(e,"active"))){const{tab:i,content:a}=function(t){const{nav:e}=t,n=Y("active",e);let o;return 1!==n.length||Ot.some(t=>h(n[0].parentElement,t))?n.length>1&&(o=n[n.length-1]):[o]=n,{tab:o,content:o?K(o):null}}(t);if(n&&oo.set(n,{tab:i,content:a}),eo.relatedTarget=e,f(i,eo),eo.defaultPrevented)return;n&&q(n,()=>{},17),u(i,"active"),M(i,"aria-selected","false"),N(e,"active"),M(e,"aria-selected","true"),o&&(h(e.parentNode,"dropdown-menu")?h(o,"active")||N(o,"active"):h(o,"active")&&u(o,"active")),h(a,"fade")?(u(a,"show"),s(a,()=>ao(t))):ao(t)}}dispose(){lo(this),super.dispose()}}d(co,{selector:Kn,init:t=>new co(t),getInstance:Qn});const ho={animation:!0,autohide:!0,delay:5e3},uo=t=>m(t,"Toast"),fo=b("show.bs.toast"),po=b("shown.bs.toast"),go=b("hide.bs.toast"),mo=b("hidden.bs.toast");function bo(t){const{element:e,options:n}=t;u(e,"showing"),G(e,"showing"),f(e,po),n.autohide&&q(e,()=>t.hide(),n.delay,"toast")}function vo(t){const{element:e}=t;u(e,"showing"),u(e,"show"),N(e,"hide"),G(e,"toast"),f(e,mo)}function wo(t,e){const s=e?n:o,{element:i,dismiss:a,options:l}=t;a&&s(a,"click",t.hide),l.autohide&&[bn,vn,R,O].forEach(t=>s(i,t,yo))}function yo(t){const e=this,n=uo(e),{type:o,relatedTarget:s}=t;n&&e!==s&&!e.contains(s)&&([R,bn].includes(o)?G(e,"toast"):q(e,()=>n.hide(),n.options.delay,"toast"))}class To extends E{constructor(t,e){super(t,e);const{element:n,options:o}=this;o.animation&&!h(n,"fade")?N(n,"fade"):!o.animation&&h(n,"fade")&&u(n,"fade"),this.dismiss=r('[data-bs-dismiss="toast"]',n),this.show=this.show.bind(this),this.hide=this.hide.bind(this),wo(this,!0)}get name(){return"Toast"}get defaults(){return ho}show(){const t=this,{element:e}=t;if(e&&!h(e,"show")){if(f(e,fo),fo.defaultPrevented)return;!function(t){const{element:e,options:n}=t;q(e,()=>{u(e,"hide"),Z(e),N(e,"show"),N(e,"showing"),n.animation?s(e,()=>bo(t)):bo(t)},17,"showing")}(t)}}hide(){const t=this,{element:e}=t;if(e&&h(e,"show")){if(f(e,go),go.defaultPrevented)return;!function(t){const{element:e,options:n}=t;N(e,"showing"),n.animation?(Z(e),s(e,()=>vo(t))):vo(t)}(t)}}dispose(){const{element:t}=this;h(t,"show")&&u(t,"show"),function(t){G(t.element,"toast"),wo(t)}(this),super.dispose()}}d(To,{selector:".toast",init:t=>new To(t),getInstance:uo});const Eo={Alert:$,Button:I,Carousel:vt,Collapse:Mt,Dropdown:re,Modal:Ue,Offcanvas:dn,Popover:jn,ScrollSpy:Jn,Tab:co,Toast:To,Tooltip:Fn};function xo(t){const e=[...zn("*",t&&a.some(e=>t instanceof e)?t:void 0)];y(Eo).forEach(t=>{const{init:n,selector:o}=Eo[t];var s,i;s=n,i=e.filter(t=>function(t,e){return t.matches(e)}(t,o)),[...i].forEach(t=>s(t))})}document.body?xo():function(t,e,s,i){const a=n=>{n.target===t&&(s.apply(t,[n]),o(t,e,a,i))};n(t,e,a,i)}(document,"DOMContentLoaded",()=>xo());return{Alert:$,Button:I,Carousel:vt,Collapse:Mt,Dropdown:re,Modal:Ue,Offcanvas:dn,Popover:jn,ScrollSpy:Jn,Tab:co,Toast:To,Tooltip:Fn,initCallback:xo,removeDataAPI:function(t){const e=t&&a.some(e=>t instanceof e)?t:void 0;y(Eo).forEach(t=>{!function(t,e){const n=g.getAllFor(t);n&&[...n].forEach(t=>{const[n,o]=t;e&&e.contains(n)&&o.dispose()})}(t,e)})},Version:"4.1.0alpha3"}})); +// Native JavaScript for Bootstrap v4.1.0alpha4 | 2022 © dnp_theme | MIT-License +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).BSN=e()}(this,(function(){"use strict";function t(t,e){const n=getComputedStyle(t);return e in n?n[e]:""}function e(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDuration"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}function n(t,e,n,o){const s=o||!1;t.addEventListener(e,n,s)}function o(t,e,n,o){const s=o||!1;t.removeEventListener(e,n,s)}function s(s,i){let a=0;const r=new Event("transitionend"),l=e(s),c=function(e){const n=t(e,"transitionProperty"),o=t(e,"transitionDelay"),s=o.includes("ms")?1:1e3,i=n&&"none"!==n?parseFloat(o)*s:0;return Number.isNaN(i)?0:i}(s);if(l){const t=e=>{e.target===s&&(i.apply(s,[e]),o(s,"transitionend",t),a=1)};n(s,"transitionend",t),setTimeout(()=>{a||s.dispatchEvent(r)},l+c+17)}else i.apply(s,[r])}function i(t){return t instanceof HTMLElement?t.ownerDocument:t instanceof Window?t.document:window.document}const a=[Document,Node,Element,HTMLElement],r=[Element,HTMLElement];function l(t,e){const n="string"==typeof t,o=e&&a.some(t=>e instanceof t)?e:i();return!n&&r.some(e=>t instanceof e)?t:n?o.querySelector(t):null}function c(t,e){return t?t.closest(e)||c(t.getRootNode().host,e):null}const d=(t,e)=>Object.assign(t,e);function h(t,e){return t.classList.contains(e)}function u(t,e){t.classList.remove(e)}const f=(t,e)=>t.dispatchEvent(e),p=new Map,g={set:(t,e,n)=>{const o=l(t);if(!o)return;p.has(e)||p.set(e,new Map);p.get(e).set(o,n)},getAllFor:t=>p.get(t)||null,get:(t,e)=>{const n=l(t),o=g.getAllFor(e);return n&&o&&o.get(n)||null},remove:(t,e)=>{const n=l(t),o=p.get(e);o&&n&&(o.delete(n),0===o.size&&p.delete(e))}},m=(t,e)=>g.get(t,e);function b(t,e){const n=new CustomEvent(t,{cancelable:!0,bubbles:!0});return e instanceof Object&&d(n,e),n}const v={};function w(t){const e=this,{type:n}=t;(v[n]?[...v[n]]:[]).forEach(o=>{const[s,i]=o;[...i].forEach(o=>{if(s===e){const[e,i]=o;e.apply(s,[t]),i&&i.once&&y(s,n,e,i)}})})}const y=(t,e,n,o)=>{const s=v[e],i=s&&s.get(t),a=i&&i.get(n),{options:r}=void 0!==a?a:{options:o};i&&i.has(n)&&i.delete(n),!s||i&&i.size||s.delete(t),s&&s.size||delete v[e],i&&i.size||t.removeEventListener(e,w,r)},T={on:(t,e,n,o)=>{v[e]||(v[e]=new Map);const s=v[e];s.has(t)||s.set(t,new Map);const i=s.get(t),{size:a}=i;i&&i.set(n,o),a||t.addEventListener(e,w,o)},off:y,globalListener:w,registry:v},E=(t,e)=>t.getAttribute(e);function x(t){return"true"===t||"false"!==t&&(Number.isNaN(+t)?""===t||"null"===t?null:t:+t)}const H=t=>Object.keys(t),k=t=>t.toLowerCase();class A{constructor(t,e){const n=this,o=l(t);if(!o)throw Error(`${n.name} Error: "${t}" is not a valid selector.`);n.options={};const s=g.get(o,n.name);s&&s.dispose(),n.element=o,n.defaults&&Object.keys(n.defaults).length&&(n.options=function(t,e,n,o){const s={...t.dataset},i={},a={};return H(s).forEach(t=>{const e=o&&t.includes(o)?t.replace(o,"").replace(/[A-Z]/,t=>k(t)):t;a[e]=x(s[t])}),H(n).forEach(t=>{n[t]=x(n[t])}),H(e).forEach(o=>{i[o]=o in n?n[o]:o in a?a[o]:"title"===o?E(t,"title"):e[o]}),i}(o,n.defaults,e||{},"bs")),g.set(o,n.name,n)}get version(){return"4.1.0alpha4"}get name(){return this.constructor.name}get defaults(){return this.constructor.defaults}dispose(){const t=this;g.remove(t.element,t.name),H(t).forEach(e=>{t[e]=null})}}const{on:P,off:M}=T,N=t=>m(t,"Alert"),$=b("close.bs.alert"),L=b("closed.bs.alert");function D(t){const{element:e}=t;S(t),f(e,L),t.dispose(),e.remove()}function S(t,e){const n=e?P:M,{dismiss:o}=t;o&&n(o,"click",t.close)}class C extends A{constructor(t){super(t);const{element:e}=this;this.dismiss=l('[data-bs-dismiss="alert"]',e),S(this,!0)}get name(){return"Alert"}close(t){const e=t?N(c(this,".alert")):this;if(!e)return;const{element:n}=e;if(h(n,"show")){if(f(n,$),$.defaultPrevented)return;u(n,"show"),h(n,"fade")?s(n,()=>D(e)):D(e)}}dispose(){S(this),super.dispose()}}d(C,{selector:".alert",init:t=>new C(t),getInstance:N});const I=(t,e,n)=>t.setAttribute(e,n);function R(t,e){t.classList.add(e)}const O="data-bs-toggle",W=`[${O}="button"]`,{on:F,off:B}=T,z=t=>m(t,"Button");function X(t,e){(e?F:B)(t.element,"click",t.toggle)}class j extends A{constructor(t){super(t);const{element:e}=this;this.isActive=h(e,"active"),I(e,"aria-pressed",""+!!this.isActive),X(this,!0)}get name(){return"Button"}toggle(t){t&&t.preventDefault();const e=t?z(this):this;if(!e)return;const{element:n}=e;if(h(n,"disabled"))return;e.isActive=h(n,"active");const{isActive:o}=e;(o?u:R)(n,"active"),I(n,"aria-pressed",o?"false":"true")}dispose(){X(this),super.dispose()}}d(j,{selector:W,init:t=>new j(t),getInstance:z});const Y="mouseenter",V="mouseleave";function q(t){if(null==t)return window;if(!(t instanceof Window)){const{ownerDocument:e}=t;return e&&e.defaultView||window}return t}function U(t,e){const{width:n,height:o,top:s,right:i,bottom:a,left:r}=t.getBoundingClientRect();let l=1,c=1;if(e&&t instanceof HTMLElement){const{offsetWidth:e,offsetHeight:s}=t;l=e>0&&Math.round(n)/e||1,c=s>0&&Math.round(o)/s||1}return{width:n/l,height:o/c,top:s/c,right:i/l,bottom:a/c,left:r/l,x:r/l,y:s/c}}function G(t){return i(t).documentElement}const Z=t=>{const{top:e,bottom:n}=U(t),{clientHeight:o}=G(t);return e<=o&&n>=0},J=t=>"rtl"===G(t).dir;function K(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).querySelectorAll(t)}function Q(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByClassName(t)}const _=new Map,tt=(t,e,n,o)=>{const s=l(t);if(s)if(o&&o.length){_.has(s)||_.set(s,new Map);_.get(s).set(o,setTimeout(e,n))}else _.set(s,setTimeout(e,n))},et=(t,e)=>{const n=l(t);if(!n)return null;const o=_.get(n);return e&&e.length&&o&&o.get?o.get(e)||null:o||null},nt=(t,e)=>{const n=l(t);if(n)if(e&&e.length){const t=_.get(n);t&&t.get&&(clearTimeout(t.get(e)),t.delete(e),0===t.size&&_.delete(n))}else clearTimeout(_.get(n)),_.delete(n)},ot=t=>t.offsetHeight,st={passive:!0};function it(t){const e=["data-bs-target","data-bs-parent","data-bs-container","href"],n=i(t);return e.map(e=>{const o=E(t,e);return o?"data-bs-parent"===e?c(t,o):l(o,n):null}).filter(t=>t)[0]}const at="carousel-item",{on:rt,off:lt}=T,ct={pause:"hover",keyboard:!1,touch:!0,interval:5e3},dt=t=>m(t,"Carousel");let ht=0,ut=0,ft=0;const pt=b("slide.bs.carousel"),gt=b("slid.bs.carousel");function mt(){const t=this,e=dt(t);!e||e.isPaused||et(t,"paused")||R(t,"paused")}function bt(){const t=dt(this);t&&t.isPaused&&!et(this,"paused")&&t.cycle()}function vt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||it(this);if(!e)return;const n=dt(e);if(!n||n.isAnimating)return;const o=+E(this,"data-bs-slide-to");!this||h(this,"active")||Number.isNaN(o)||n.to(o)}function wt(t){t.preventDefault();const e=c(this,'[data-bs-ride="carousel"]')||it(this),n=e&&dt(e);if(!n||n.isAnimating)return;const o=E(this,"data-bs-slide");"next"===o?n.next():"prev"===o&&n.prev()}function yt({code:t}){const[e]=[...K('[data-bs-ride="carousel"]')].filter(t=>Z(t)),n=dt(e);if(!n)return;const o=J(),s=o?"ArrowLeft":"ArrowRight";t===(o?"ArrowRight":"ArrowLeft")?n.prev():t===s&&n.next()}function Tt(t){const e=dt(this);e&&!e.isTouch&&(ht=t.changedTouches[0].pageX,this.contains(t.target)&&(e.isTouch=!0,kt(e,!0)))}function Et(t){const{changedTouches:e,type:n}=t,o=dt(this);o&&o.isTouch&&(ut=e[0].pageX,"touchmove"===n&&e.length>1&&t.preventDefault())}function xt(t){const e=this,n=dt(e);if(n&&n.isTouch&&(ft=ut||t.changedTouches[0].pageX,n.isTouch)){if((!e.contains(t.target)||!e.contains(t.relatedTarget))&&Math.abs(ht-ft)<75)return;utht&&(n.index-=1),n.isTouch=!1,n.to(n.index),kt(n)}}function Ht(t,e){const{indicators:n}=t;[...n].forEach(t=>u(t,"active")),t.indicators[e]&&R(n[e],"active")}function kt(t,e){const{element:n}=t,o=e?rt:lt;o(n,"touchmove",Et,st),o(n,"touchend",xt,st)}function At(t,e){const{element:n,options:o,slides:s,controls:i,indicators:a}=t,{touch:r,pause:l,interval:c,keyboard:d}=o,h=e?rt:lt;l&&c&&(h(n,Y,mt),h(n,V,bt),h(n,"touchstart",mt,st),h(n,"touchend",bt,st)),r&&s.length>1&&h(n,"touchstart",Tt,st),i.length&&i.forEach(t=>{t&&h(t,"click",wt)}),a.length&&a.forEach(t=>{h(t,"click",vt)}),d&&h(q(n),"keydown",yt)}function Pt(t){const{slides:e,element:n}=t,o=l(`.${at}.active`,n);return[...e].indexOf(o)}class Mt extends A{constructor(t,e){super(t,e);const n=this;n.direction=J()?"right":"left",n.index=0,n.isTouch=!1;const{element:o}=n;n.slides=Q(at,o);const{slides:s}=n;if(s.length<2)return;n.controls=[...K("[data-bs-slide]",o),...K(`[data-bs-slide][data-bs-target="#${o.id}"]`)],n.indicator=l(".carousel-indicators",o),n.indicators=[...n.indicator?K("[data-bs-slide-to]",n.indicator):[],...K(`[data-bs-slide-to][data-bs-target="#${o.id}"]`)];const{options:i}=n;n.options.interval=!0===i.interval?ct.interval:i.interval,Pt(n)<0&&(s.length&&R(s[0],"active"),n.indicators.length&&Ht(n,0)),At(n,!0),i.interval&&n.cycle()}get name(){return"Carousel"}get defaults(){return ct}get isPaused(){return h(this.element,"paused")}get isAnimating(){return null!==l(`.${at}-next,.${at}-prev`,this.element)}cycle(){const t=this,{element:e,options:n,isPaused:o}=t;nt(e,"carousel"),o&&(nt(e,"paused"),u(e,"paused")),tt(e,()=>{!t.isPaused&&Z(e)&&(t.index+=1,t.to(t.index))},n.interval,"carousel")}pause(){const{element:t,options:e}=this;!this.isPaused&&e.interval&&(R(t,"paused"),tt(t,()=>{},1,"paused"))}next(){const t=this;t.isAnimating||(t.index+=1,t.to(t.index))}prev(){const t=this;t.isAnimating||(t.index-=1,t.to(t.index))}to(t){const n=this,{element:o,slides:a,options:r}=n,l=Pt(n),c=J();let p=t;if(n.isAnimating||l===p)return;lp||l===a.length-1&&0===p)&&(n.direction=c?"left":"right");const{direction:g}=n;p<0?p=a.length-1:p>=a.length&&(p=0);const m="left"===g?"next":"prev",b="left"===g?"start":"end",v={relatedTarget:a[p],from:l,to:p,direction:g};d(pt,v),d(gt,v),f(o,pt),pt.defaultPrevented||(n.index=p,Ht(n,p),e(a[p])&&h(o,"slide")?tt(o,()=>{R(a[p],`${at}-${m}`),ot(a[p]),R(a[p],`${at}-${b}`),R(a[l],`${at}-${b}`),s(a[p],()=>function(t){const{index:e,direction:n,element:o,slides:s,options:a}=t;if(t.isAnimating&&dt(o)){const r=Pt(t),l="left"===n?"next":"prev",c="left"===n?"start":"end";R(s[e],"active"),u(s[e],`${at}-${l}`),u(s[e],`${at}-${c}`),u(s[r],"active"),u(s[r],`${at}-${c}`),f(o,gt),nt(o,"data-bs-slide"),i(o).hidden||!a.interval||t.isPaused||t.cycle()}}(n))},17,"data-bs-slide"):(R(a[p],"active"),u(a[l],"active"),tt(o,()=>{nt(o,"data-bs-slide"),o&&r.interval&&!n.isPaused&&n.cycle(),f(o,gt)},17,"data-bs-slide")))}dispose(){const t=this,{slides:e}=t,n=["start","end","prev","next"];[...e].forEach((e,o)=>{h(e,"active")&&Ht(t,o),n.forEach(t=>u(e,`${at}-${t}`))}),At(t),super.dispose()}}d(Mt,{selector:'[data-bs-ride="carousel"]',init:t=>new Mt(t),getInstance:dt});const Nt=`[${O}="collapse"]`,$t={parent:null},{on:Lt,off:Dt}=T,St=t=>m(t,"Collapse"),Ct=b("show.bs.collapse"),It=b("shown.bs.collapse"),Rt=b("hide.bs.collapse"),Ot=b("hidden.bs.collapse");function Wt(t){const{element:e,parent:n,triggers:o}=t;f(e,Rt),Rt.defaultPrevented||(tt(e,()=>{},17),n&&tt(n,()=>{},17),e.style.height=e.scrollHeight+"px",u(e,"collapse"),u(e,"show"),R(e,"collapsing"),ot(e),e.style.height="0px",s(e,()=>{nt(e),n&&nt(n),o.forEach(t=>I(t,"aria-expanded","false")),u(e,"collapsing"),R(e,"collapse"),e.style.height="",f(e,Ot)}))}function Ft(t,e){const n=e?Lt:Dt,{triggers:o}=t;o.length&&o.forEach(t=>n(t,"click",Bt))}function Bt(t){const{target:e}=t,n=e&&c(e,Nt),o=n&&it(n),s=o&&St(o);s&&s.toggle(),n&&"A"===n.tagName&&t.preventDefault()}class zt extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;this.triggers=[...K(Nt)].filter(t=>it(t)===n),this.parent=l(o.parent),Ft(this,!0)}get name(){return"Collapse"}get defaults(){return $t}toggle(){h(this.element,"show")?this.hide():this.show()}hide(){const{triggers:t,element:e}=this;et(e)||(Wt(this),t.length&&t.forEach(t=>R(t,"collapsed")))}show(){const t=this,{element:e,parent:n,triggers:o}=t;let i,a;n&&(i=[...K(".collapse.show",n)].find(t=>St(t)),a=i&&St(i)),n&&(!n||et(n))||et(e)||(a&&i!==e&&(Wt(a),a.triggers.forEach(t=>{R(t,"collapsed")})),function(t){const{element:e,parent:n,triggers:o}=t;f(e,Ct),Ct.defaultPrevented||(tt(e,()=>{},17),n&&tt(n,()=>{},17),R(e,"collapsing"),u(e,"collapse"),e.style.height=e.scrollHeight+"px",s(e,()=>{nt(e),n&&nt(n),o.forEach(t=>I(t,"aria-expanded","true")),u(e,"collapsing"),R(e,"collapse"),R(e,"show"),e.style.height="",f(e,It)}))}(t),o.length&&o.forEach(t=>u(t,"collapsed")))}dispose(){Ft(this),super.dispose()}}d(zt,{selector:".collapse",init:t=>new zt(t),getInstance:St});const Xt="scroll",jt="resize",Yt="ArrowUp",Vt="ArrowDown",qt=(t,e)=>t.hasAttribute(e),Ut=(t,e)=>{d(t.style,e)},Gt=t=>t.focus(),Zt=["dropdown","dropup","dropstart","dropend"];function Jt(t){const e=c(t,"A");return t&&(qt(t,"href")&&"#"===t.href.slice(-1)||e&&qt(e,"href")&&"#"===e.href.slice(-1))}const[Kt,Qt,_t,te]=Zt,ee=`[${O}="${Kt}"]`,{on:ne,off:oe}=T,se=t=>m(t,"Dropdown"),ie=[Kt,Qt],ae=[_t,te],re=["A","BUTTON"],le={offset:5,display:"dynamic"},ce=b("show.bs."+Kt),de=b("shown.bs."+Kt),he=b("hide.bs."+Kt),ue=b("hidden.bs."+Kt);function fe(e){const{element:n,menu:o,parentElement:s,options:i}=e,{offset:a}=i;if("static"===t(o,"position"))return;const r=J(n),l=h(s,"dropdown-menu-end");["margin","top","bottom","left","right"].forEach(t=>{o.style[t]=""});let c=Zt.find(t=>h(s,t))||Kt,u={dropdown:[a,0,0],dropup:[0,0,a],dropstart:r?[-1,0,0,a]:[-1,a,0],dropend:r?[-1,a,0]:[-1,0,0,a]};const f={dropdown:{top:"100%"},dropup:{top:"auto",bottom:"100%"},dropstart:r?{left:"100%",right:"auto"}:{left:"auto",right:"100%"},dropend:r?{left:"auto",right:"100%"}:{left:"100%",right:"auto"},menuEnd:r?{right:"auto",left:0}:{right:0,left:"auto"}},{offsetWidth:p,offsetHeight:g}=o,{clientWidth:m,clientHeight:b}=G(n),{left:v,top:w,width:y,height:T}=U(n),E=v-p-a<0,x=v+p+y+a>=m,H=w+g+a>=b,k=w+g+T+a>=b,A=w-g-a<0,P=(!r&&l||r&&!l)&&v+y-p<0,M=(r&&l||!r&&!l)&&v+p>=m;ae.includes(c)&&E&&x&&(c=Kt),c===_t&&(r?x:E)&&(c=te),c===te&&(r?E:x)&&(c=_t),c===Qt&&A&&!k&&(c=Kt),c===Kt&&k&&!A&&(c=Qt),ae.includes(c)&&H&&d(f[c],{top:"auto",bottom:0}),ie.includes(c)&&(P||M)&&v+y+Math.abs(p-y)+at?t+"px":t).join(" "),Ut(o,f[c]),h(o,"dropdown-menu-end")&&Ut(o,f.menuEnd)}function pe(t){const{element:e}=t,n=t.open?ne:oe,o=i(e);n(o,"click",be),n(o,"focus",be),n(o,"keydown",we),n(o,"keyup",ye),"dynamic"===t.options.display&&[Xt,jt].forEach(t=>{n(q(e),t,Te,st)})}function ge(t,e){(e?ne:oe)(t.element,"click",ve)}function me(t){const e=[...Zt,"btn-group","input-group"].map(t=>Q(t+" show"),i(t)).find(t=>t.length);return e&&e.length?[...e[0].children].find(t=>qt(t,O)):null}function be(t){const{target:e,type:n}=t;if(!e||!e.closest)return;const o=me(e);if(!o)return;const s=se(o);if(!s)return;const{parentElement:i,menu:a}=s,r=null!==c(e,ee),l=i&&i.contains(e)&&("form"===e.tagName||null!==c(e,"form"));"click"===n&&Jt(e)&&t.preventDefault(),("focus"!==n||e!==o&&e!==a&&!a.contains(e))&&(l||r||s&&s.hide())}function ve(t){const{target:e}=t,n=se(this);n&&(n.toggle(),e&&Jt(e)&&t.preventDefault())}function we(t){[Vt,Yt].includes(t.code)&&t.preventDefault()}function ye(t){const{code:e}=t,n=me(this),o=n&&se(n),s=n&&i(n).activeElement;if(!o||!s)return;const{menu:a,open:r}=o,l=function(t){return[...t.children].map(t=>{if(t&&re.includes(t.tagName))return t;const{firstElementChild:e}=t;return e&&re.includes(e.tagName)?e:null}).filter(t=>t)}(a);if(l&&l.length&&[Vt,Yt].includes(e)){let t=l.indexOf(s);s===n?t=0:e===Yt?t=t>1?t-1:0:e===Vt&&(t=t{t.relatedTarget=e}),f(s,ce),ce.defaultPrevented||(R(o,"show"),R(s,"show"),I(e,"aria-expanded","true"),fe(t),t.open=!n,setTimeout(()=>{Gt(e),pe(t),f(s,de)},1))}hide(){const t=this,{element:e,open:n,menu:o,parentElement:s}=t;[he,ue].forEach(t=>{t.relatedTarget=e}),f(s,he),he.defaultPrevented||(u(o,"show"),u(s,"show"),I(e,"aria-expanded","false"),t.open=!n,setTimeout(()=>pe(t),1),f(s,ue))}dispose(){const{parentElement:t}=this;h(t,"show")&&this.open&&this.hide(),ge(this),super.dispose()}}d(Ee,{selector:ee,init:t=>new Ee(t),getInstance:se});const xe=(t,e)=>t.removeAttribute(e);function He(t){return i(t).body}const ke=t=>t instanceof q(t).ShadowRoot||t instanceof ShadowRoot;const Ae=t=>["TABLE","TD","TH"].includes(t.tagName),Pe=t=>t instanceof HTMLElement;function Me(e,n){const o=["HTML","BODY"];if(n){let{offsetParent:n}=e;const s=q(e);for(;n&&(Ae(n)||Pe(n)&&!["sticky","fixed"].includes(t(n,"position")));)n=n.offsetParent;return(!n||n&&(o.includes(n.tagName)||"static"===t(n,"position")))&&(n=s),n}const s=[];let{parentNode:i}=e;for(;i&&!o.includes(i.nodeName);)i="HTML"===(a=i).nodeName?a:a.assignedSlot||a.parentNode||(ke(a)?a.host:null)||G(a),ke(i)||i.shadowRoot||Ae(i)||s.push(i);var a;return s.find((e,n)=>"relative"!==t(e,"position")&&s.slice(n+1).every(e=>"static"===t(e,"position"))?e:null)||He(e)}const Ne="sticky-top",$e="position-sticky",Le=t=>[...Q("fixed-top",t),...Q("fixed-bottom",t),...Q(Ne,t),...Q($e,t),...Q("is-fixed",t)];function De(t){const{clientWidth:e}=G(t),{innerWidth:n}=q(t);return Math.abs(n-e)}function Se(e,n){const o=He(e),s=parseInt(t(o,"paddingRight"),10),i="hidden"===t(o,"overflow")&&s?0:De(e),a=Le(o);n&&(Ut(o,{overflow:"hidden",paddingRight:s+i+"px"}),a.length&&a.forEach(e=>{const n=t(e,"paddingRight");if(e.style.paddingRight=parseInt(n,10)+i+"px",[Ne,$e].some(t=>h(e,t))){const n=t(e,"marginRight");e.style.marginRight=parseInt(n,10)-i+"px"}}))}const Ce="modal-backdrop",Ie="offcanvas-backdrop",Re=i().createElement("div");function Oe(t){return l(".modal.show,.offcanvas.show",i(t))}function We(t){const e=t?Ce:Ie;[Ce,Ie].forEach(t=>{u(Re,t)}),R(Re,e)}function Fe(t,e,n){We(n),t.append(Re),e&&R(Re,"fade")}function Be(){R(Re,"show"),ot(Re)}function ze(){u(Re,"show")}function Xe(t){Oe(t)||(u(Re,"fade"),Re.remove(),function(t){const e=He(t);Ut(e,{paddingRight:"",overflow:""});const n=Le(e);n.length&&n.forEach(t=>{Ut(t,{paddingRight:"",marginRight:""})})}(t))}function je(e){return e&&"hidden"!==t(e,"visibility")&&null!==e.offsetParent}const Ye=`[${O}="modal"]`,{on:Ve,off:qe}=T,Ue={backdrop:!0,keyboard:!0},Ge=t=>m(t,"Modal"),Ze=b("show.bs.modal"),Je=b("shown.bs.modal"),Ke=b("hide.bs.modal"),Qe=b("hidden.bs.modal");function _e(t){const{element:e}=t,n=De(e),{clientHeight:o,scrollHeight:s}=G(e),{clientHeight:i,scrollHeight:a}=e,r=i!==a;if(!r&&n){const t=J(e)?"paddingLeft":"paddingRight";e.style[t]=n+"px"}Se(e,r||o!==s)}function tn(t,e){const n=e?Ve:qe,{element:o}=t;n(o,"click",cn),n(q(o),jt,t.update,st),n(i(o),"keydown",ln)}function en(t,e){const n=e?Ve:qe,{triggers:o}=t;o.length&&o.forEach(t=>n(t,"click",rn))}function nn(t){const{triggers:e,element:n}=t;if(Xe(n),n.style.paddingRight="",e.length){const t=e.find(t=>je(t));t&&Gt(t)}}function on(t){const{element:e,relatedTarget:n}=t;Gt(e),tn(t,!0),Je.relatedTarget=n,f(e,Je)}function sn(t){const{element:e,hasFade:n}=t;e.style.display="block",_e(t),Oe(e)||(He(e).style.overflow="hidden"),R(e,"show"),xe(e,"aria-hidden"),I(e,"aria-modal","true"),n?s(e,()=>on(t)):on(t)}function an(t,e){const{element:n,options:o,relatedTarget:i,hasFade:a}=t;n.style.display="",o.backdrop&&!e&&a&&h(Re,"show")&&!Oe(n)?(ze(),s(Re,()=>nn(t))):nn(t),tn(t),Qe.relatedTarget=i,f(n,Qe)}function rn(t){const{target:e}=t,n=e&&c(this,Ye),o=n&&it(n),s=o&&Ge(o);s&&(n&&"A"===n.tagName&&t.preventDefault(),s.relatedTarget=n,s.toggle())}function ln({code:t}){const e=l(".modal.show"),n=e&&Ge(e);if(!n)return;const{options:o}=n;o.keyboard&&"Escape"===t&&h(e,"show")&&(n.relatedTarget=null,n.hide())}function cn(t){const n=this,o=Ge(n);if(!o||et(n))return;const{options:a,isStatic:r,modalDialog:l}=o,{backdrop:d}=a,{target:h}=t,f=i(n).getSelection().toString().length,p=l.contains(h),g=h&&c(h,'[data-bs-dismiss="modal"]');r&&!p?tt(n,()=>{R(n,"modal-static"),s(l,()=>function(t){const{element:n,modalDialog:o}=t,s=e(o)+17;u(n,"modal-static"),tt(n,()=>nt(n),s)}(o))},17):(g||!f&&!r&&!p&&d)&&(o.relatedTarget=g||null,o.hide(),t.preventDefault())}class dn extends A{constructor(t,e){super(t,e);const{element:n}=this;this.modalDialog=l(".modal-dialog",n),this.triggers=[...K(Ye)].filter(t=>it(t)===n),this.isStatic="static"===this.options.backdrop,this.hasFade=h(n,"fade"),this.relatedTarget=null,this.container=Me(n),en(this,!0),this.update=this.update.bind(this)}get name(){return"Modal"}get defaults(){return Ue}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,hasFade:s,relatedTarget:i,container:a}=t,{backdrop:r}=o;let l=0;if(h(n,"show"))return;if(Ze.relatedTarget=i||null,f(n,Ze),Ze.defaultPrevented)return;const c=Oe(n);if(c&&c!==n){(Ge(c)||m(c,"Offcanvas")).hide()}r?(c||h(Re,"show")?We(!0):Fe(a,s,!0),l=e(Re),h(Re,"show")||Be(),setTimeout(()=>sn(t),l)):(sn(t),c&&h(Re,"show")&&ze())}hide(t){const e=this,{element:n,hasFade:o,relatedTarget:i}=e;h(n,"show")&&(Ke.relatedTarget=i||null,f(n,Ke),Ke.defaultPrevented||(u(n,"show"),I(n,"aria-hidden","true"),xe(n,"aria-modal"),o&&!1!==t?s(n,()=>an(e)):an(e,t)))}update(){h(this.element,"show")&&_e(this)}dispose(){this.hide(!0),en(this),super.dispose()}}d(dn,{selector:".modal",init:t=>new dn(t),getInstance:Ge});const hn=`[${O}="offcanvas"]`,{on:un,off:fn}=T,pn={backdrop:!0,keyboard:!0,scroll:!1},gn=t=>m(t,"Offcanvas"),mn=b("show.bs.offcanvas"),bn=b("shown.bs.offcanvas"),vn=b("hide.bs.offcanvas"),wn=b("hidden.bs.offcanvas");function yn(t,e){const n=e?un:fn;t.triggers.forEach(t=>n(t,"click",Hn))}function Tn(t,e){const n=e?un:fn,o=i(t.element);n(o,"keydown",An),n(o,"click",kn)}function En(t){const{element:e,options:n}=t;n.scroll||(!function(t){const{element:e}=t,{clientHeight:n,scrollHeight:o}=G(e);Se(e,n!==o)}(t),He(e).style.overflow="hidden"),R(e,"offcanvas-toggling"),R(e,"show"),e.style.visibility="visible",s(e,()=>function(t){const{element:e,triggers:n}=t;u(e,"offcanvas-toggling"),xe(e,"aria-hidden"),I(e,"aria-modal","true"),I(e,"role","dialog"),n.length&&n.forEach(t=>I(t,"aria-expanded","true"));f(e,bn),Tn(t,!0),Gt(e)}(t))}function xn(t){const{element:e,options:n}=t,o=Oe(e);e.blur(),!o&&n.backdrop&&h(Re,"show")?(ze(),s(Re,()=>Pn(t))):Pn(t)}function Hn(t){const e=c(this,hn),n=e&&it(e),o=n&&gn(n);o&&(o.relatedTarget=e,o.toggle(),e&&"A"===e.tagName&&t.preventDefault())}function kn(t){const e=l(".offcanvas.show",this);if(!e)return;const n=l('[data-bs-dismiss="offcanvas"]',e),o=gn(e);if(!o)return;const{options:s,triggers:a}=o,{target:r}=t,d=c(r,hn),h=i(e).getSelection();h&&h.toString().length||!(!e.contains(r)&&s.backdrop&&(!d||d&&!a.includes(d))||n&&n.contains(r))||(o.relatedTarget=n&&n.contains(r)?n:null,o.hide()),d&&"A"===d.tagName&&t.preventDefault()}function An({code:t}){const e=l(".offcanvas.show",this);if(!e)return;const n=gn(e);n&&n.options.keyboard&&"Escape"===t&&(n.relatedTarget=null,n.hide())}function Pn(t){const{element:e,triggers:n}=t;if(I(e,"aria-hidden","true"),xe(e,"aria-modal"),xe(e,"role"),e.style.visibility="",n.length){n.forEach(t=>I(t,"aria-expanded","false"));const t=n.find(t=>je(t));t&&Gt(t)}Xe(e),f(e,wn),u(e,"offcanvas-toggling"),Oe(e)||Tn(t)}class Mn extends A{constructor(t,e){super(t,e);const{element:n}=this;this.triggers=[...K(hn)].filter(t=>it(t)===n),this.container=Me(n),this.relatedTarget=null,yn(this,!0)}get name(){return"Offcanvas"}get defaults(){return pn}toggle(){h(this.element,"show")?this.hide():this.show()}show(){const t=this,{element:n,options:o,container:s,relatedTarget:i}=t;let a=0;if(h(n,"show"))return;if(mn.relatedTarget=i,bn.relatedTarget=i,f(n,mn),mn.defaultPrevented)return;const r=Oe(n);if(r&&r!==n){(gn(r)||m(r,"Modal")).hide()}o.backdrop?(r?We():Fe(s,!0),a=e(Re),h(Re,"show")||Be(),setTimeout(()=>En(t),a)):(En(t),r&&h(Re,"show")&&ze())}hide(t){const e=this,{element:n,relatedTarget:o}=e;h(n,"show")&&(vn.relatedTarget=o,wn.relatedTarget=o,f(n,vn),vn.defaultPrevented||(R(n,"offcanvas-toggling"),u(n,"show"),t?xn(e):s(n,()=>xn(e))))}dispose(){this.hide(!0),yn(this),super.dispose()}}d(Mn,{selector:".offcanvas",init:t=>new Mn(t),getInstance:gn});function Nn(t){const e="tooltip"===t;return``}const $n=t=>t&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(e=>t instanceof e);function Ln(t,e,n){const o=e instanceof HTMLElement,s=U(t,o&&function(t){const{width:e,height:n}=U(t),{offsetWidth:o,offsetHeight:s}=t;return Math.round(e)!==o||Math.round(n)!==s}(e)),i={x:0,y:0};if(o){const t=U(e,!0);i.x=t.x+e.clientLeft,i.y=t.y+e.clientTop}return{x:s.left+n.x-i.x,y:s.top+n.y-i.y,width:s.width,height:s.height}}var Dn={top:"top",bottom:"bottom",left:"start",right:"end"};function Sn(e,n){const o=/\b(top|bottom|start|end)+/,{element:s,tooltip:i,options:a,arrow:r,offsetParent:l}=e,c={...Dn};Ut(i,{top:"0px",left:"0px",right:""});const d="Popover"===e.name,h=i.offsetWidth,u=i.offsetHeight,f=J(s);f&&(c.left="end",c.right="start");const p=G(s),g=p.clientWidth,m=p.clientHeight,{container:b}=a;let{placement:v}=a;const{left:w,right:y,top:T}=U(b,!0),E=b.clientWidth,x=Math.abs(E-b.offsetWidth),H=t(b,"position"),k="fixed"===H,A="static"===H,P="sticky"===H&&T===parseFloat(t(b,"top")),M=f&&k?x:0,N=k?E+w+(f?x:0):E+w+(g-y)-1,{width:$,height:L,left:D,right:S,top:C}=U(s,!0),I=function(t){const e="scrollX"in t;return{x:e?t.scrollX:t.scrollLeft,y:e?t.scrollY:t.scrollTop}}(l),{x:R,y:O}=Ln(s,l,I);let W,F,B,z,X,j;Ut(r,{top:"",left:"",right:""});const Y=r.offsetWidth||0,V=r.offsetHeight||0,q=Y/2;let Z=C-u-V<0,K=C+u+L+V>=m,Q=D-h-Y=N;const tt=["left","right"],et=["top","bottom"];if(Z=tt.includes(v)?C+L/2-u/2-V<0:Z,K=tt.includes(v)?C+u/2+L/2+V>=m:K,Q=et.includes(v)?D+$/2-h/2=N:_,v=tt.includes(v)&&Q&&_?"top":v,v="top"===v&&Z?"bottom":v,v="bottom"===v&&K?"top":v,v="left"===v&&Q?"right":v,v="right"===v&&_?"left":v,i.className.includes(v)||(i.className=i.className.replace(o,c[v])),tt.includes(v))F="left"===v?R-h-(d?Y:0):R+$+(d?Y:0),Z?(W=O,W+=P?-T-I.y:0,z=L/2-Y):K?(W=O-u+L,W+=P?-T-I.y:0,z=u-L/2-Y):(W=O-u/2+L/2,W+=P?-T-I.y:0,z=u/2-V/2);else if(et.includes(v))if(n&&$n(s)){let t=0,e=0;A?(t=n.pageX,e=n.pageY):(t=n.clientX-w+(k?I.x:0),e=n.clientY-T+(k?I.y:0)),t-=f&&k&&x?x:0,W="top"===v?e-u-Y:e+Y,n.clientX-h/2N?(F="auto",B=0,j=N-t-q,j-=k?w+(f?x:0):0):(F=t-h/2,X=h/2-q)}else W="top"===v?O-u-(d?V:0):O+L+(d?V:0),Q?(F=0,X=R+$/2-q):_?(F="auto",B=0,j=$/2+N-S-q):(F=R-h/2+$/2,X=h/2-q);Ut(i,{top:W+"px",left:"auto"===F?F:F+"px",right:void 0!==B?B+"px":""}),r instanceof HTMLElement&&(void 0!==z&&(r.style.top=z+"px"),void 0!==X?r.style.left=X+"px":void 0!==j&&(r.style.right=j+"px"))}const Cn={template:Nn("tooltip"),title:null,customClass:null,trigger:"hover focus",placement:"top",sanitizeFn:null,animation:!0,delay:200,container:null},In="focusin",Rn="focusout",{userAgentData:On}=navigator,Wn=On,{userAgent:Fn}=navigator,Bn=Fn,zn=/(iPhone|iPod|iPad)/,Xn=Wn?Wn.brands.some(t=>zn.test(t.brand)):zn.test(Bn);let jn=1;const Yn=new Map;function Vn(t,e,n){if("string"!=typeof e||e.length)if("string"==typeof e){let o=e.trim();"function"==typeof n&&(o=n(o));const s=(new DOMParser).parseFromString(o,"text/html"),{body:i}=s,a=i.children.length?"innerHTML":"innerText";t[a]=i[a]}else e instanceof HTMLElement&&t.append(e)}function qn(t,e){return t instanceof HTMLElement&&e.contains(t)}const Un=`[${O}="tooltip"],[data-tip="tooltip"]`,{on:Gn,off:Zn}=T;let Jn=t=>m(t,"Tooltip");function Kn(t){const{element:e}=t;eo(t),e.hasAttribute("data-original-title")&&"tooltip"===t.name&&oo(t)}function Qn(t,e){const n=e?Gn:Zn,{element:o}=t;n(i(o),"touchstart",so,st),$n(o)||[Xt,jt].forEach(e=>{n(q(o),e,t.update,st)})}function _n(t){const{element:e}=t,n=b("shown.bs."+k(t.name));Qn(t,!0),f(e,n),nt(e,"in")}function to(t){const{element:e}=t,n=b("hidden.bs."+k(t.name));Qn(t),function(t){const{element:e,tooltip:n}=t;xe(e,"aria-describedby"),n.remove()}(t),f(e,n),nt(e,"out")}function eo(t,e){const n=e?Gn:Zn,{element:o,options:s,btn:a}=t,{trigger:r,dismissible:l}=s;if(r.includes("manual"))return;t.enabled=!!e;const c=r.split(" "),d=$n(o);d&&n(o,"mousemove",t.update,st),c.forEach(e=>{d||"hover"===e?(n(o,"mousedown",t.show),n(o,Y,t.show),l&&a?n(a,"click",t.hide):(n(o,V,t.hide),n(i(o),"touchstart",so,st))):"click"===e?n(o,e,l?t.show:t.toggle):"focus"===e&&(n(o,In,t.show),l||n(o,Rn,t.hide),Xn&&n(o,"click",()=>Gt(o)))})}function no(t,e){const n=e?Gn:Zn,{element:o,options:s,offsetParent:i}=t,{container:a}=s,{offsetHeight:r,scrollHeight:l}=a,d=c(o,".modal"),h=c(o,".offcanvas");if(!$n(o)){const e=q(o),s=r!==l||i!==e?a:e;n(e,jt,t.update,st),n(s,Xt,t.update,st)}d&&Gn(d,"hide.bs.modal",t.hide),h&&Gn(h,"hide.bs.offcanvas",t.hide)}function oo(t,e){const n=["data-original-title","title"],{element:o}=t;I(o,n[e?0:1],e||E(o,n[0])),xe(o,n[e?1:0])}function so({target:t}){const{tooltip:e,element:n}=this;e.contains(t)||t===n||n.contains(t)||this.hide()}class io extends A{constructor(e,n){super(e,n);const o=this,{element:s}=o,a="Tooltip"===o.name,r=a?"tooltip":"popover",c=a?"Tooltip":"Popover";Jn=t=>m(t,c),o.tooltip={},a||(o.btn=null),o.arrow={},o.offsetParent={},o.enabled=!0,o.id=`${r}-${function(t,e){jn+=1;let n=Yn.get(t),o=jn;if(e&&e.length)if(n){const t=n.get(e);Number.isNaN(t)?n.set(e,o):o=t}else Yn.set(t,new Map),n=Yn.get(t),n.set(e,o);else Number.isNaN(n)?Yn.set(t,o):o=n;return o}(s,r)}`;const{options:d}=o;if(!d.title&&a||!a&&!d.content)return;const u=l(d.container),f=Me(s);o.options.container=!u||u&&["static","relative"].includes(t(u,"position"))?f:u||He(s),Cn.title=null,so.bind(o),o.update=o.update.bind(o),o.show=o.show.bind(o),o.hide=o.hide.bind(o),o.toggle=o.toggle.bind(o),s.hasAttribute("title")&&a&&oo(o,d.title),function(t){const{id:e,element:n,options:o}=t,{animation:s,customClass:a,sanitizeFn:r,placement:c,dismissible:d}=o;let{title:u,content:f}=o;const p="Tooltip"===t.name,g=p?"tooltip":"popover",{template:m,btnClose:b}=o,v={...Dn};J(n)&&(v.left="end",v.right="start");const w=`bs-${g}-${v[c]}`;let y;if([Element,HTMLElement].some(t=>m instanceof t))y=m;else{const t=i(n).createElement("div");Vn(t,m,r),y=t.firstElementChild}t.tooltip=y&&y.cloneNode(!0);const{tooltip:T}=t;I(T,"id",e),I(T,"role","tooltip");const E=p?"tooltip-inner":"popover-body",x=p?null:l(".popover-header",T),H=l("."+E,T);t.arrow=l(`.${g}-arrow`,T),d&&(u?u instanceof HTMLElement?Vn(u,b,r):u+=b:(x&&x.remove(),f instanceof HTMLElement?Vn(f,b,r):f+=b)),p?u&&H&&Vn(H,u,r):(u&&x&&Vn(x,u,r),f&&H&&Vn(H,f,r),t.btn=l(".btn-close",T)),h(T,g)||R(T,g),s&&!h(T,"fade")&&R(T,"fade"),a&&!h(T,a)&&R(T,a),h(T,w)||R(T,w)}(o),eo(o,!0)}get name(){return"Tooltip"}get defaults(){return Cn}show(t){const e=this,{options:n,tooltip:o,element:i,id:a}=e,{container:r,animation:l}=n,c=et(i,"out");nt(i,"out"),!o||c||qn(o,r)||tt(i,()=>{const n=b("show.bs."+k(e.name));f(i,n),n.defaultPrevented||(r.append(o),I(i,"aria-describedby","#"+a),e.offsetParent=Me(o,!0),e.update(t),no(e,!0),h(o,"show")||R(o,"show"),l?s(o,()=>_n(e)):_n(e))},17,"in")}hide(){const t=this,{options:e,tooltip:n,element:o}=t,{container:i,animation:a,delay:r}=e;nt(o,"in"),n&&qn(n,i)&&tt(o,()=>{const e=b("hide.bs."+k(t.name));f(o,e),e.defaultPrevented||(u(n,"show"),no(t),a?s(n,()=>to(t)):to(t))},r+17,"out")}update(t){Sn(this,t)}toggle(t){const{tooltip:e,options:n}=this;qn(e,n.container)?this.hide():this.show(t)}enable(){const t=this,{enabled:e}=t;e||(eo(t,!0),t.enabled=!e)}disable(){const t=this,{element:n,tooltip:o,options:s,enabled:i}=t,{animation:a,container:r,delay:l}=s;i&&(qn(o,r)&&a?(t.hide(),tt(n,()=>{eo(t),nt(n,"tooltip")},e(o)+l+17,"tooltip")):eo(t),t.enabled=!i)}toggleEnabled(){this.enabled?this.disable():this.enable()}dispose(){const t=this,{tooltip:e,options:n}=t;n.animation&&qn(e,n.container)?(n.delay=0,t.hide(),s(e,()=>Kn(t))):Kn(t),super.dispose()}}d(io,{selector:Un,init:t=>new io(t),getInstance:Jn,styleTip:Sn});const ao=`[${O}="popover"],[data-tip="popover"]`,ro={...Cn,template:Nn("popover"),btnClose:'',dismissible:!1,content:null};class lo extends io{constructor(t,e){super(t,e)}get name(){return"Popover"}get defaults(){return ro}show(){super.show();const{options:t,btn:e}=this;t.dismissible&&e&&setTimeout(()=>Gt(e),17)}}function co(t,e){return(e&&a.some(t=>e instanceof t)?e:i()).getElementsByTagName(t)}d(lo,{selector:ao,init:t=>new lo(t),getInstance:t=>m(t,"Popover"),styleTip:Sn});const{on:ho,off:uo}=T,fo={offset:10,target:null},po=b("activate.bs.scrollspy");function go(t){const{target:e,scrollTarget:n,options:o,itemsLength:s,scrollHeight:a,element:r}=t,{offset:c}=o,d=n instanceof Window,h=e&&co("A",e),u=n&&function(t){return t instanceof HTMLElement?t.scrollHeight:G(t).scrollHeight}(n);if(t.scrollTop=d?n.scrollY:n.scrollTop,h&&(s!==h.length||u!==a)){let e,n,o;t.items=[],t.offsets=[],t.scrollHeight=u,t.maxScroll=t.scrollHeight-function({element:t,scrollTarget:e}){return e instanceof Window?e.innerHeight:U(t).height}(t),[...h].forEach(s=>{e=E(s,"href"),n=e&&"#"===e.charAt(0)&&"#"!==e.slice(-1)&&l(e,i(r)),n&&(t.items.push(s),o=U(n),t.offsets.push((d?o.top+t.scrollTop:n.offsetTop)-c))}),t.itemsLength=t.items.length}}function mo(t){[...co("A",t)].forEach(t=>{h(t,"active")&&u(t,"active")})}function bo(t,e){const{target:n,element:o}=t;mo(n),t.activeItem=e,R(e,"active");const s=[];let i=e;for(;i!==He(o);)i=i.parentElement,(h(i,"nav")||h(i,"dropdown-menu"))&&s.push(i);s.forEach(t=>{const e=t.previousElementSibling;e&&!h(e,"active")&&R(e,"active")}),po.relatedTarget=e,f(o,po)}function vo(t,e){(e?ho:uo)(t.scrollTarget,Xt,t.refresh,st)}class wo extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;if(this.target=l(o.target,i(n)),!this.target)return;const s=q(n);this.scrollTarget=n.clientHeight=o){const e=i[s-1];return void(a!==e&&bo(t,e))}const{offsets:r}=t;if(a&&n0)return t.activeItem=null,void mo(e);i.forEach((e,o)=>{a!==e&&n>=r[o]&&(void 0===r[o+1]||nnew wo(t),getInstance:t=>m(t,"ScrollSpy")});const yo=`[${O}="tab"]`,{on:To,off:Eo}=T,xo=t=>m(t,"Tab"),Ho=b("show.bs.tab"),ko=b("shown.bs.tab"),Ao=b("hide.bs.tab"),Po=b("hidden.bs.tab"),Mo=new Map;function No(t){const{tabContent:e,nav:n}=t;e&&(e.style.height="",u(e,"collapsing")),n&&nt(n)}function $o(t){const{element:e,tabContent:n,nav:o}=t,{currentHeight:i,nextHeight:a}=Mo.get(e),{tab:r}=o&&Mo.get(o);n?i===a?No(t):setTimeout(()=>{n.style.height=a+"px",ot(n),s(n,()=>No(t))},50):o&&nt(o),ko.relatedTarget=r,f(e,ko)}function Lo(t){const{element:e,content:n,tabContent:o,nav:i}=t,{tab:a,content:r}=i&&Mo.get(i);let l=0;if(o&&([r,n].forEach(t=>R(t,"overflow-hidden")),l=r.scrollHeight),Ho.relatedTarget=a,Po.relatedTarget=e,f(e,Ho),!Ho.defaultPrevented){if(R(n,"active"),u(r,"active"),o){const t=n.scrollHeight;Mo.set(e,{currentHeight:l,nextHeight:t}),R(o,"collapsing"),o.style.height=l+"px",ot(o),[r,n].forEach(t=>u(t,"overflow-hidden"))}n&&h(n,"fade")?setTimeout(()=>{R(n,"show"),s(n,()=>{$o(t)})},17):$o(t),f(a,Po)}}function Do(t,e){(e?To:Eo)(t.element,"click",So)}function So(t){const e=xo(this);e&&(t.preventDefault(),e.show())}class Co extends A{constructor(t){super(t);const{element:e}=this,n=it(e);if(!n)return;const o=c(e,".nav"),s=c(n,".tab-content");this.nav=o,this.content=n,this.tabContent=s,this.dropdown=o&&l(`.${Zt[0]}-toggle`,o),Do(this,!0)}get name(){return"Tab"}show(){const t=this,{element:e,nav:n,dropdown:o}=t;if(!(n&&et(n)||h(e,"active"))){const{tab:i,content:a}=function(t){const{nav:e}=t,n=Q("active",e);let o;return 1!==n.length||Zt.some(t=>h(n[0].parentElement,t))?n.length>1&&(o=n[n.length-1]):[o]=n,{tab:o,content:o?it(o):null}}(t);if(n&&Mo.set(n,{tab:i,content:a}),Ao.relatedTarget=e,f(i,Ao),Ao.defaultPrevented)return;n&&tt(n,()=>{},17),u(i,"active"),I(i,"aria-selected","false"),R(e,"active"),I(e,"aria-selected","true"),o&&(h(e.parentNode,"dropdown-menu")?h(o,"active")||R(o,"active"):h(o,"active")&&u(o,"active")),h(a,"fade")?(u(a,"show"),s(a,()=>Lo(t))):Lo(t)}}dispose(){Do(this),super.dispose()}}d(Co,{selector:yo,init:t=>new Co(t),getInstance:xo});const{on:Io,off:Ro}=T,Oo={animation:!0,autohide:!0,delay:5e3},Wo=t=>m(t,"Toast"),Fo=b("show.bs.toast"),Bo=b("shown.bs.toast"),zo=b("hide.bs.toast"),Xo=b("hidden.bs.toast");function jo(t){const{element:e,options:n}=t;u(e,"showing"),nt(e,"showing"),f(e,Bo),n.autohide&&tt(e,()=>t.hide(),n.delay,"toast")}function Yo(t){const{element:e}=t;u(e,"showing"),u(e,"show"),R(e,"hide"),nt(e,"toast"),f(e,Xo)}function Vo(t,e){const n=e?Io:Ro,{element:o,dismiss:s,options:i}=t;s&&n(s,"click",t.hide),i.autohide&&[In,Rn,Y,V].forEach(t=>n(o,t,qo))}function qo(t){const e=this,n=Wo(e),{type:o,relatedTarget:s}=t;n&&e!==s&&!e.contains(s)&&([Y,In].includes(o)?nt(e,"toast"):tt(e,()=>n.hide(),n.options.delay,"toast"))}class Uo extends A{constructor(t,e){super(t,e);const{element:n,options:o}=this;o.animation&&!h(n,"fade")?R(n,"fade"):!o.animation&&h(n,"fade")&&u(n,"fade"),this.dismiss=l('[data-bs-dismiss="toast"]',n),this.show=this.show.bind(this),this.hide=this.hide.bind(this),Vo(this,!0)}get name(){return"Toast"}get defaults(){return Oo}show(){const t=this,{element:e}=t;if(e&&!h(e,"show")){if(f(e,Fo),Fo.defaultPrevented)return;!function(t){const{element:e,options:n}=t;tt(e,()=>{u(e,"hide"),ot(e),R(e,"show"),R(e,"showing"),n.animation?s(e,()=>jo(t)):jo(t)},17,"showing")}(t)}}hide(){const t=this,{element:e}=t;if(e&&h(e,"show")){if(f(e,zo),zo.defaultPrevented)return;!function(t){const{element:e,options:n}=t;R(e,"showing"),n.animation?(ot(e),s(e,()=>Yo(t))):Yo(t)}(t)}}dispose(){const{element:t}=this;h(t,"show")&&u(t,"show"),function(t){nt(t.element,"toast"),Vo(t)}(this),super.dispose()}}d(Uo,{selector:".toast",init:t=>new Uo(t),getInstance:Wo});const Go={Alert:C,Button:j,Carousel:Mt,Collapse:zt,Dropdown:Ee,Modal:dn,Offcanvas:Mn,Popover:lo,ScrollSpy:wo,Tab:Co,Toast:Uo,Tooltip:io};function Zo(t){const e=[...co("*",t&&a.some(e=>t instanceof e)?t:void 0)];H(Go).forEach(t=>{const{init:n,selector:o}=Go[t];var s,i;s=n,i=e.filter(t=>function(t,e){return t.matches(e)}(t,o)),[...i].forEach(t=>s(t))})}document.body?Zo():function(t,e,s,i){const a=n=>{n.target===t&&(s.apply(t,[n]),o(t,e,a,i))};n(t,e,a,i)}(document,"DOMContentLoaded",()=>Zo());return{Alert:C,Button:j,Carousel:Mt,Collapse:zt,Dropdown:Ee,Modal:dn,Offcanvas:Mn,Popover:lo,ScrollSpy:wo,Tab:Co,Toast:Uo,Tooltip:io,initCallback:Zo,removeDataAPI:function(t){const e=t&&a.some(e=>t instanceof e)?t:void 0;H(Go).forEach(t=>{!function(t,e){const n=g.getAllFor(t);n&&[...n].forEach(t=>{const[n,o]=t;e&&e.contains(n)&&o.dispose()})}(t,e)})},Version:"4.1.0alpha4"}})); diff --git a/dist/components/alert-native.esm.js b/dist/components/alert-native.esm.js index f49bc65d..66bbf996 100644 --- a/dist/components/alert-native.esm.js +++ b/dist/components/alert-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Alert v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Alert v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -98,7 +98,7 @@ function getElementTransitionDuration(element) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function on(element, eventName, handler, options) { +function on$1(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -111,7 +111,7 @@ function on(element, eventName, handler, options) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function off(element, eventName, handler, options) { +function off$1(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -137,11 +137,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -337,6 +337,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `fade` class. */ @@ -458,7 +566,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -525,6 +633,7 @@ class BaseComponent { // ================ const alertSelector = `.${alertString}`; const alertDismissSelector = `[${dataBsDismiss}="${alertString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Alert` instance associated diff --git a/dist/components/alert-native.js b/dist/components/alert-native.js index 4a878e39..2a565ccd 100644 --- a/dist/components/alert-native.js +++ b/dist/components/alert-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Alert v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Alert v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -104,7 +104,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function on(element, eventName, handler, options) { + function on$1(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -117,7 +117,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function off(element, eventName, handler, options) { + function off$1(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -143,11 +143,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -343,6 +343,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `fade` class. */ @@ -464,7 +572,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -531,6 +639,7 @@ // ================ const alertSelector = `.${alertString}`; const alertDismissSelector = `[${dataBsDismiss}="${alertString}"]`; + const { on, off } = EventListener; /** * Static method which returns an existing `Alert` instance associated diff --git a/dist/components/button-native.esm.js b/dist/components/button-native.esm.js index c6860e07..ad71c9c7 100644 --- a/dist/components/button-native.esm.js +++ b/dist/components/button-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Button v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Button v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -178,31 +178,113 @@ const Data = { */ const getInstance = (target, component) => Data.get(target, component); +/** @type {Record} */ +const EventRegistry = {}; + /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * The global event listener. * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); } /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; /** * Global namespace for most components active class. @@ -320,7 +402,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -386,6 +468,7 @@ class BaseComponent { // BUTTON PRIVATE GC // ================= const buttonSelector = `[${dataBsToggle}="${buttonString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Button` instance associated diff --git a/dist/components/button-native.js b/dist/components/button-native.js index b94a3100..b143cc74 100644 --- a/dist/components/button-native.js +++ b/dist/components/button-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Button v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Button v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -184,31 +184,113 @@ */ const getInstance = (target, component) => Data.get(target, component); + /** @type {Record} */ + const EventRegistry = {}; + /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * The global event listener. * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); } /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; /** * Global namespace for most components active class. @@ -326,7 +408,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -392,6 +474,7 @@ // BUTTON PRIVATE GC // ================= const buttonSelector = `[${dataBsToggle}="${buttonString}"]`; + const { on, off } = EventListener; /** * Static method which returns an existing `Button` instance associated diff --git a/dist/components/carousel-native.esm.js b/dist/components/carousel-native.esm.js index d81b838d..36f21901 100644 --- a/dist/components/carousel-native.esm.js +++ b/dist/components/carousel-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Carousel v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Carousel v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -57,32 +57,6 @@ const keyArrowLeft = 'ArrowLeft'; */ const keyArrowRight = 'ArrowRight'; -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Returns the `Window` object of a target node. * @see https://github.com/floating-ui/floating-ui @@ -434,6 +408,32 @@ function getElementTransitionDelay(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -455,11 +455,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -606,6 +606,114 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components active class. */ @@ -745,7 +853,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -814,7 +922,7 @@ const carouselSelector = `[data-bs-ride="${carouselString}"]`; const carouselItem = `${carouselString}-item`; const dataBsSlideTo = 'data-bs-slide-to'; const dataBsSlide = 'data-bs-slide'; - +const { on, off } = EventListener; const pausedClass = 'paused'; const carouselDefaults = { @@ -865,10 +973,10 @@ function carouselTransitionEndHandler(self) { const directionClass = direction === 'left' ? 'start' : 'end'; addClass(slides[index], activeClass); - removeClass(slides[activeItem], activeClass); - removeClass(slides[index], `${carouselItem}-${orientation}`); removeClass(slides[index], `${carouselItem}-${directionClass}`); + + removeClass(slides[activeItem], activeClass); removeClass(slides[activeItem], `${carouselItem}-${directionClass}`); dispatchEvent(element, carouselSlidEvent); diff --git a/dist/components/carousel-native.js b/dist/components/carousel-native.js index f2238a4a..cb6261b4 100644 --- a/dist/components/carousel-native.js +++ b/dist/components/carousel-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Carousel v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Carousel v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -63,32 +63,6 @@ */ const keyArrowRight = 'ArrowRight'; - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Returns the `Window` object of a target node. * @see https://github.com/floating-ui/floating-ui @@ -440,6 +414,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -461,11 +461,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -612,6 +612,114 @@ element.classList.remove(classNAME); } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components active class. */ @@ -751,7 +859,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -820,7 +928,7 @@ const carouselItem = `${carouselString}-item`; const dataBsSlideTo = 'data-bs-slide-to'; const dataBsSlide = 'data-bs-slide'; - + const { on, off } = EventListener; const pausedClass = 'paused'; const carouselDefaults = { @@ -871,10 +979,10 @@ const directionClass = direction === 'left' ? 'start' : 'end'; addClass(slides[index], activeClass); - removeClass(slides[activeItem], activeClass); - removeClass(slides[index], `${carouselItem}-${orientation}`); removeClass(slides[index], `${carouselItem}-${directionClass}`); + + removeClass(slides[activeItem], activeClass); removeClass(slides[activeItem], `${carouselItem}-${directionClass}`); dispatchEvent(element, carouselSlidEvent); diff --git a/dist/components/collapse-native.esm.js b/dist/components/collapse-native.esm.js index 188c896d..d66b13fa 100644 --- a/dist/components/collapse-native.esm.js +++ b/dist/components/collapse-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Collapse v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Collapse v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -100,7 +100,7 @@ function getElementTransitionDuration(element) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function on(element, eventName, handler, options) { +function on$1(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -113,7 +113,7 @@ function on(element, eventName, handler, options) { * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ -function off(element, eventName, handler, options) { +function off$1(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -139,11 +139,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -459,6 +459,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `toggle` option. */ @@ -616,7 +724,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -684,6 +792,7 @@ class BaseComponent { const collapseSelector = `.${collapseString}`; const collapseToggleSelector = `[${dataBsToggle}="${collapseString}"]`; const collapseDefaults = { parent: null }; +const { on, off } = EventListener; /** * Static method which returns an existing `Collapse` instance associated diff --git a/dist/components/collapse-native.js b/dist/components/collapse-native.js index 9d9dd107..dbeaf0f4 100644 --- a/dist/components/collapse-native.js +++ b/dist/components/collapse-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Collapse v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Collapse v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -106,7 +106,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function on(element, eventName, handler, options) { + function on$1(element, eventName, handler, options) { const ops = options || false; element.addEventListener(eventName, handler, ops); } @@ -119,7 +119,7 @@ * @param {EventListenerObject['handleEvent']} handler callback * @param {(EventListenerOptions | boolean)=} options other event options */ - function off(element, eventName, handler, options) { + function off$1(element, eventName, handler, options) { const ops = options || false; element.removeEventListener(eventName, handler, ops); } @@ -145,11 +145,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -465,6 +465,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `toggle` option. */ @@ -622,7 +730,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -690,6 +798,7 @@ const collapseSelector = `.${collapseString}`; const collapseToggleSelector = `[${dataBsToggle}="${collapseString}"]`; const collapseDefaults = { parent: null }; + const { on, off } = EventListener; /** * Static method which returns an existing `Collapse` instance associated diff --git a/dist/components/dropdown-native.esm.js b/dist/components/dropdown-native.esm.js index 63b3d1bf..fb3c9ac4 100644 --- a/dist/components/dropdown-native.esm.js +++ b/dist/components/dropdown-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Dropdown v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Dropdown v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -311,32 +311,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Returns the `document.documentElement` or the `` element. * @@ -428,6 +402,114 @@ function getWindow(node) { return node; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `show` class. */ @@ -567,7 +649,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -639,6 +721,7 @@ const [ dropendString, ] = dropdownMenuClasses; const dropdownSelector = `[${dataBsToggle}="${dropdownString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Dropdown` instance associated diff --git a/dist/components/dropdown-native.js b/dist/components/dropdown-native.js index 386954a6..001a6d0c 100644 --- a/dist/components/dropdown-native.js +++ b/dist/components/dropdown-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Dropdown v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Dropdown v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -317,32 +317,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Returns the `document.documentElement` or the `` element. * @@ -434,6 +408,114 @@ return node; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `show` class. */ @@ -573,7 +655,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -645,6 +727,7 @@ dropendString, ] = dropdownMenuClasses; const dropdownSelector = `[${dataBsToggle}="${dropdownString}"]`; + const { on, off } = EventListener; /** * Static method which returns an existing `Dropdown` instance associated diff --git a/dist/components/modal-native.esm.js b/dist/components/modal-native.esm.js index 820fa6f8..67424986 100644 --- a/dist/components/modal-native.esm.js +++ b/dist/components/modal-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Modal v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Modal v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -250,32 +250,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Checks if a page is Right To Left. * @param {(HTMLElement | Element)=} node the target @@ -492,6 +466,32 @@ function getElementTransitionDelay(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -513,11 +513,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -543,6 +543,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `toggle` option. */ @@ -1023,7 +1131,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -1092,6 +1200,7 @@ const modalSelector = `.${modalString}`; const modalToggleSelector = `[${dataBsToggle}="${modalString}"]`; const modalDismissSelector = `[${dataBsDismiss}="${modalString}"]`; const modalStaticClass = `${modalString}-static`; +const { on, off } = EventListener; const modalDefaults = { backdrop: true, // boolean|string diff --git a/dist/components/modal-native.js b/dist/components/modal-native.js index 6c2b5f82..5fdbabea 100644 --- a/dist/components/modal-native.js +++ b/dist/components/modal-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Modal v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Modal v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -256,32 +256,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Checks if a page is Right To Left. * @param {(HTMLElement | Element)=} node the target @@ -498,6 +472,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -519,11 +519,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -549,6 +549,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `toggle` option. */ @@ -1029,7 +1137,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -1098,6 +1206,7 @@ const modalToggleSelector = `[${dataBsToggle}="${modalString}"]`; const modalDismissSelector = `[${dataBsDismiss}="${modalString}"]`; const modalStaticClass = `${modalString}-static`; + const { on, off } = EventListener; const modalDefaults = { backdrop: true, // boolean|string diff --git a/dist/components/offcanvas-native.esm.js b/dist/components/offcanvas-native.esm.js index 6a594343..f35f79fc 100644 --- a/dist/components/offcanvas-native.esm.js +++ b/dist/components/offcanvas-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Offcanvas v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Offcanvas v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -127,32 +127,6 @@ function closest(element, selector) { || closest(element.getRootNode().host, selector)) : null; } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Check class in `HTMLElement.classList`. * @@ -293,6 +267,32 @@ function getElementTransitionDelay(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -314,11 +314,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -434,6 +434,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `dismiss` option. */ @@ -935,7 +1043,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -1004,6 +1112,7 @@ const offcanvasSelector = `.${offcanvasString}`; const offcanvasToggleSelector = `[${dataBsToggle}="${offcanvasString}"]`; const offcanvasDismissSelector = `[${dataBsDismiss}="${offcanvasString}"]`; const offcanvasTogglingClass = `${offcanvasString}-toggling`; +const { on, off } = EventListener; const offcanvasDefaults = { backdrop: true, // boolean diff --git a/dist/components/offcanvas-native.js b/dist/components/offcanvas-native.js index a87d43ab..02ef01cc 100644 --- a/dist/components/offcanvas-native.js +++ b/dist/components/offcanvas-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Offcanvas v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Offcanvas v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -133,32 +133,6 @@ || closest(element.getRootNode().host, selector)) : null; } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Check class in `HTMLElement.classList`. * @@ -299,6 +273,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -320,11 +320,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -440,6 +440,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `dismiss` option. */ @@ -941,7 +1049,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -1010,6 +1118,7 @@ const offcanvasToggleSelector = `[${dataBsToggle}="${offcanvasString}"]`; const offcanvasDismissSelector = `[${dataBsDismiss}="${offcanvasString}"]`; const offcanvasTogglingClass = `${offcanvasString}-toggling`; + const { on, off } = EventListener; const offcanvasDefaults = { backdrop: true, // boolean diff --git a/dist/components/popover-native.esm.js b/dist/components/popover-native.esm.js index 52ecb8b1..4039c235 100644 --- a/dist/components/popover-native.esm.js +++ b/dist/components/popover-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Popover v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Popover v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -759,32 +759,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - // @ts-ignore const { userAgentData: uaDATA } = navigator; @@ -853,6 +827,32 @@ function getElementTransitionDelay(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -874,11 +874,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -977,15 +977,21 @@ function getUID(element, key) { let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -1017,6 +1023,114 @@ function OriginalEvent(EventType, config) { */ const toLowerCase = (source) => source.toLowerCase(); +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for `data-bs-title` attribute. */ @@ -1348,7 +1462,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -1415,6 +1529,7 @@ class BaseComponent { // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; +const { on, off } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated diff --git a/dist/components/popover-native.js b/dist/components/popover-native.js index bbcfc6bd..26f349aa 100644 --- a/dist/components/popover-native.js +++ b/dist/components/popover-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Popover v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Popover v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -765,32 +765,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - // @ts-ignore const { userAgentData: uaDATA } = navigator; @@ -859,6 +833,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -880,11 +880,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -983,15 +983,21 @@ let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -1023,6 +1029,114 @@ */ const toLowerCase = (source) => source.toLowerCase(); + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for `data-bs-title` attribute. */ @@ -1354,7 +1468,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -1421,6 +1535,7 @@ // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; + const { on, off } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated diff --git a/dist/components/scrollspy-native.esm.js b/dist/components/scrollspy-native.esm.js index bf408759..3cad85f9 100644 --- a/dist/components/scrollspy-native.esm.js +++ b/dist/components/scrollspy-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - ScrollSpy v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - ScrollSpy v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -172,32 +172,6 @@ function getBoundingClientRect(element, includeScale) { }; } -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - /** * Shortcut for the `Element.dispatchEvent(Event)` method. * @@ -317,6 +291,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components active class. */ @@ -421,7 +503,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -489,6 +571,7 @@ class BaseComponent { // SCROLLSPY PRIVATE GC // ==================== const scrollspySelector = '[data-bs-spy="scroll"]'; +const { on, off } = EventListener; const scrollspyDefaults = { offset: 10, diff --git a/dist/components/scrollspy-native.js b/dist/components/scrollspy-native.js index a394d20a..53b1c6ec 100644 --- a/dist/components/scrollspy-native.js +++ b/dist/components/scrollspy-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - ScrollSpy v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - ScrollSpy v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -178,32 +178,6 @@ }; } - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - /** * Shortcut for the `Element.dispatchEvent(Event)` method. * @@ -323,6 +297,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components active class. */ @@ -427,7 +509,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -495,6 +577,7 @@ // SCROLLSPY PRIVATE GC // ==================== const scrollspySelector = '[data-bs-spy="scroll"]'; + const { on, off } = EventListener; const scrollspyDefaults = { offset: 10, diff --git a/dist/components/tab-native.esm.js b/dist/components/tab-native.esm.js index 65331ac4..26b3c811 100644 --- a/dist/components/tab-native.esm.js +++ b/dist/components/tab-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Tab v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Tab v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -127,32 +127,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Shortcut for the `Element.dispatchEvent(Event)` method. * @@ -242,6 +216,32 @@ function getElementTransitionDuration(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -263,11 +263,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -459,6 +459,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `collapsing` class. * As used by `Collapse` / `Tab`. @@ -636,7 +744,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -702,6 +810,7 @@ class BaseComponent { // TAB PRIVATE GC // ================ const tabSelector = `[${dataBsToggle}="${tabString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Tab` instance associated diff --git a/dist/components/tab-native.js b/dist/components/tab-native.js index b1b93187..4f84b2a2 100644 --- a/dist/components/tab-native.js +++ b/dist/components/tab-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Tab v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Tab v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -133,32 +133,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Shortcut for the `Element.dispatchEvent(Event)` method. * @@ -248,6 +222,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -269,11 +269,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -465,6 +465,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `collapsing` class. * As used by `Collapse` / `Tab`. @@ -642,7 +750,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -708,6 +816,7 @@ // TAB PRIVATE GC // ================ const tabSelector = `[${dataBsToggle}="${tabString}"]`; + const { on, off } = EventListener; /** * Static method which returns an existing `Tab` instance associated diff --git a/dist/components/toast-native.esm.js b/dist/components/toast-native.esm.js index d667d405..45cf840b 100644 --- a/dist/components/toast-native.esm.js +++ b/dist/components/toast-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Toast v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Toast v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -64,32 +64,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Returns the `document` or the `#document` element. * @see https://github.com/floating-ui/floating-ui @@ -221,6 +195,32 @@ function getElementTransitionDuration(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -242,11 +242,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -438,6 +438,114 @@ function OriginalEvent(EventType, config) { return OriginalCustomEvent; } +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `fade` class. */ @@ -559,7 +667,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -629,6 +737,7 @@ const toastDismissSelector = `[${dataBsDismiss}="${toastString}"]`; const showingClass = 'showing'; /** @deprecated */ const hideClass = 'hide'; +const { on, off } = EventListener; const toastDefaults = { animation: true, diff --git a/dist/components/toast-native.js b/dist/components/toast-native.js index a1da61d9..978516fc 100644 --- a/dist/components/toast-native.js +++ b/dist/components/toast-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Toast v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Toast v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -70,32 +70,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Returns the `document` or the `#document` element. * @see https://github.com/floating-ui/floating-ui @@ -227,6 +201,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -248,11 +248,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -444,6 +444,114 @@ return OriginalCustomEvent; } + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `fade` class. */ @@ -565,7 +673,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -635,6 +743,7 @@ const showingClass = 'showing'; /** @deprecated */ const hideClass = 'hide'; + const { on, off } = EventListener; const toastDefaults = { animation: true, diff --git a/dist/components/tooltip-native.esm.js b/dist/components/tooltip-native.esm.js index 42317f06..db36a6ef 100644 --- a/dist/components/tooltip-native.esm.js +++ b/dist/components/tooltip-native.esm.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Tooltip v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Tooltip v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -275,32 +275,6 @@ function removeClass(element, classNAME) { element.classList.remove(classNAME); } -/** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); -} - -/** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ -function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); -} - /** * Shortcut for `Object.assign()` static method. * @param {Record} obj a target object @@ -463,6 +437,32 @@ function getElementTransitionDelay(element) { return !Number.isNaN(duration) ? duration : 0; } +/** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); +} + +/** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ +function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); +} + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -484,11 +484,11 @@ function emulateTransitionEnd(element, handler) { const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -587,15 +587,21 @@ function getUID(element, key) { let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -635,6 +641,114 @@ function OriginalEvent(EventType, config) { */ const toLowerCase = (source) => source.toLowerCase(); +/** @type {Record} */ +const EventRegistry = {}; + +/** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ +function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); +} + +/** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } +}; + +/** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ +const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } +}; + +/** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ +const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, +}; + /** * Global namespace for most components `toggle` option. */ @@ -1348,7 +1462,7 @@ function normalizeOptions(element, defaultOps, inputOps, ns) { return normalOps; } -var version = "4.1.0alpha3"; +var version = "4.1.0alpha4"; const Version = version; @@ -1415,6 +1529,7 @@ class BaseComponent { // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; +const { on, off } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated diff --git a/dist/components/tooltip-native.js b/dist/components/tooltip-native.js index af6c1b5b..6dc7cdf9 100644 --- a/dist/components/tooltip-native.js +++ b/dist/components/tooltip-native.js @@ -1,5 +1,5 @@ /*! - * Native JavaScript for Bootstrap - Tooltip v4.1.0alpha3 (https://thednp.github.io/bootstrap.native/) + * Native JavaScript for Bootstrap - Tooltip v4.1.0alpha4 (https://thednp.github.io/bootstrap.native/) * Copyright 2015-2022 © dnp_theme * Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE) */ @@ -281,32 +281,6 @@ element.classList.remove(classNAME); } - /** - * Add eventListener to an `Element` | `HTMLElement` | `Document` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function on(element, eventName, handler, options) { - const ops = options || false; - element.addEventListener(eventName, handler, ops); - } - - /** - * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. - * - * @param {HTMLElement | Element | Document | Window} element event.target - * @param {string} eventName event.type - * @param {EventListenerObject['handleEvent']} handler callback - * @param {(EventListenerOptions | boolean)=} options other event options - */ - function off(element, eventName, handler, options) { - const ops = options || false; - element.removeEventListener(eventName, handler, ops); - } - /** * Shortcut for `Object.assign()` static method. * @param {Record} obj a target object @@ -469,6 +443,32 @@ return !Number.isNaN(duration) ? duration : 0; } + /** + * Add eventListener to an `Element` | `HTMLElement` | `Document` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function on$1(element, eventName, handler, options) { + const ops = options || false; + element.addEventListener(eventName, handler, ops); + } + + /** + * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target. + * + * @param {HTMLElement | Element | Document | Window} element event.target + * @param {string} eventName event.type + * @param {EventListenerObject['handleEvent']} handler callback + * @param {(EventListenerOptions | boolean)=} options other event options + */ + function off$1(element, eventName, handler, options) { + const ops = options || false; + element.removeEventListener(eventName, handler, ops); + } + /** * Utility to make sure callbacks are consistently * called when transition ends. @@ -490,11 +490,11 @@ const transitionEndWrapper = (e) => { if (e.target === element) { handler.apply(element, [e]); - off(element, transitionEndEvent, transitionEndWrapper); + off$1(element, transitionEndEvent, transitionEndWrapper); called = 1; } }; - on(element, transitionEndEvent, transitionEndWrapper); + on$1(element, transitionEndEvent, transitionEndWrapper); setTimeout(() => { if (!called) element.dispatchEvent(endEvent); }, duration + delay + 17); @@ -593,15 +593,21 @@ let elMap = elementIDMap.get(element); let result = elementUID; - if (elMap) { - result = key && key.length && elMap.get && elMap.get(key) - ? elMap.get(key) : elMap; - } else if (key && key.length) { - if (!elMap) { + if (key && key.length) { + if (elMap) { + const elMapId = elMap.get(key); + if (!Number.isNaN(elMapId)) { + result = elMapId; + } else { + elMap.set(key, result); + } + } else { elementIDMap.set(element, new Map()); elMap = elementIDMap.get(element); + elMap.set(key, result); } - elMap.set(key, result); + } else if (!Number.isNaN(elMap)) { + result = elMap; } else { elementIDMap.set(element, result); } @@ -641,6 +647,114 @@ */ const toLowerCase = (source) => source.toLowerCase(); + /** @type {Record} */ + const EventRegistry = {}; + + /** + * The global event listener. + * + * @this {Element | HTMLElement | Window | Document} + * @param {Event} e + * @returns {void} + */ + function globalListener(e) { + const that = this; + const { type } = e; + const oneEvMap = EventRegistry[type] ? [...EventRegistry[type]] : []; + + oneEvMap.forEach((elementsMap) => { + const [element, listenersMap] = elementsMap; + [...listenersMap].forEach((listenerMap) => { + if (element === that) { + const [listener, options] = listenerMap; + listener.apply(element, [e]); + + if (options && options.once) { + removeListener(element, type, listener, options); + } + } + }); + }); + } + + /** + * Register a new listener with its options and attach the `globalListener` + * to the target if this is the first listener. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const addListener = (element, eventType, listener, options) => { + // get element listeners first + if (!EventRegistry[eventType]) { + EventRegistry[eventType] = new Map(); + } + const oneEventMap = EventRegistry[eventType]; + + if (!oneEventMap.has(element)) { + oneEventMap.set(element, new Map()); + } + const oneElementMap = oneEventMap.get(element); + + // get listeners size + const { size } = oneElementMap; + + // register listener with its options + if (oneElementMap) { + oneElementMap.set(listener, options); + } + + // add listener last + if (!size) { + element.addEventListener(eventType, globalListener, options); + } + }; + + /** + * Remove a listener from registry and detach the `globalListener` + * if no listeners are found in the registry. + * + * @param {Element | HTMLElement | Window | Document} element + * @param {string} eventType + * @param {EventListenerObject['handleEvent']} listener + * @param {AddEventListenerOptions=} options + */ + const removeListener = (element, eventType, listener, options) => { + // get listener first + const oneEventMap = EventRegistry[eventType]; + const oneElementMap = oneEventMap && oneEventMap.get(element); + const savedOptions = oneElementMap && oneElementMap.get(listener); + // also recover initial options + const { options: eventOptions } = savedOptions !== undefined + ? savedOptions + : { options }; + + // unsubscribe second, remove from registry + if (oneElementMap && oneElementMap.has(listener)) oneElementMap.delete(listener); + if (oneEventMap && (!oneElementMap || !oneElementMap.size)) oneEventMap.delete(element); + if (!oneEventMap || !oneEventMap.size) delete EventRegistry[eventType]; + + // remove listener last + if (!oneElementMap || !oneElementMap.size) { + element.removeEventListener(eventType, globalListener, eventOptions); + } + }; + + /** + * Advanced event listener based on subscribe / publish pattern. + * @see https://www.patterns.dev/posts/classic-design-patterns/#observerpatternjavascript + * @see https://gist.github.com/shystruk/d16c0ee7ac7d194da9644e5d740c8338#file-subpub-js + * @see https://hackernoon.com/do-you-still-register-window-event-listeners-in-each-component-react-in-example-31a4b1f6f1c8 + */ + const EventListener = { + on: addListener, + off: removeListener, + globalListener, + registry: EventRegistry, + }; + /** * Global namespace for most components `toggle` option. */ @@ -1354,7 +1468,7 @@ return normalOps; } - var version = "4.1.0alpha3"; + var version = "4.1.0alpha4"; const Version = version; @@ -1421,6 +1535,7 @@ // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; + const { on, off } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated diff --git a/package.json b/package.json index 2c77c2c2..9b834b96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap.native", - "version": "4.1.0alpha3", + "version": "4.1.0alpha4", "description": "Native JavaScript for Bootstrap, the sweetest JavaScript library without jQuery.", "main": "dist/bootstrap-native.min.js", "types": "src/index.d.ts", @@ -81,18 +81,17 @@ "homepage": "https://thednp.github.io/bootstrap.native/", "dependencies": { "minifill": "^0.0.17", + "event-listener.js": "^0.0.4", "shorter-js": "^0.3.0-alpha22" }, "devDependencies": { "@rollup/plugin-buble": "^0.21.3", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-replace": "^3.0.1", "@rollup/plugin-node-resolve": "^7.1.0", "@rollup/plugin-typescript": "^8.3.0", "eslint": "^7.22.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-vue": "^7.7.0", "npm-run-all": "^4.1.5", "rollup": "^2.38.5", "rollup-plugin-terser": "^5.3.1", diff --git a/rollup.config.js b/rollup.config.js index c692c489..70150c66 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -32,7 +32,7 @@ const OUTPUT = { const PLUGINS = [ json(), - node({mainFields: ['jsnext','module'], dedupe: ['shorter-js']}) + node({mainFields: ['jsnext','module'], dedupe: ['shorter-js', 'event-listener.js']}) ] if (MIN){ diff --git a/rollup.module.js b/rollup.module.js index 606bebc5..550a67c2 100644 --- a/rollup.module.js +++ b/rollup.module.js @@ -31,7 +31,7 @@ const OUTPUT = { const PLUGINS = [ json(), - node({mainFields: ['jsnext','module'], dedupe: ['shorter-js']}), + node({mainFields: ['jsnext','module'], dedupe: ['shorter-js','event-listener.js']}), ] if (MIN){ diff --git a/src/components/alert-native.js b/src/components/alert-native.js index cf40ee19..8c982a34 100644 --- a/src/components/alert-native.js +++ b/src/components/alert-native.js @@ -10,8 +10,9 @@ import removeClass from 'shorter-js/src/class/removeClass'; import dispatchEvent from 'shorter-js/src/misc/dispatchEvent'; import { getInstance } from 'shorter-js/src/misc/data'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; +import EventListener from 'event-listener.js'; import fadeClass from '../strings/fadeClass'; import showClass from '../strings/showClass'; @@ -25,6 +26,7 @@ import BaseComponent from './base-component'; // ================ const alertSelector = `.${alertString}`; const alertDismissSelector = `[${dataBsDismiss}="${alertString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Alert` instance associated diff --git a/src/components/button-native.js b/src/components/button-native.js index f928890e..78bee3dc 100644 --- a/src/components/button-native.js +++ b/src/components/button-native.js @@ -9,8 +9,9 @@ import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; import { getInstance } from 'shorter-js/src/misc/data'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; +import EventListener from 'event-listener.js'; import activeClass from '../strings/activeClass'; import dataBsToggle from '../strings/dataBsToggle'; @@ -22,6 +23,7 @@ import BaseComponent from './base-component'; // BUTTON PRIVATE GC // ================= const buttonSelector = `[${dataBsToggle}="${buttonString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Button` instance associated diff --git a/src/components/carousel-native.js b/src/components/carousel-native.js index 51bee33b..c970ae7b 100644 --- a/src/components/carousel-native.js +++ b/src/components/carousel-native.js @@ -9,8 +9,8 @@ import touchendEvent from 'shorter-js/src/strings/touchendEvent'; import touchstartEvent from 'shorter-js/src/strings/touchstartEvent'; import keyArrowLeft from 'shorter-js/src/strings/keyArrowLeft'; import keyArrowRight from 'shorter-js/src/strings/keyArrowRight'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import getWindow from 'shorter-js/src/get/getWindow'; import getDocument from 'shorter-js/src/get/getDocument'; import getElementTransitionDuration from 'shorter-js/src/get/getElementTransitionDuration'; @@ -34,6 +34,8 @@ import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; +import EventListener from 'event-listener.js'; + import activeClass from '../strings/activeClass'; import dataBsTarget from '../strings/dataBsTarget'; import carouselString from '../strings/carouselString'; @@ -47,7 +49,7 @@ const carouselSelector = `[data-bs-ride="${carouselString}"]`; const carouselItem = `${carouselString}-item`; const dataBsSlideTo = 'data-bs-slide-to'; const dataBsSlide = 'data-bs-slide'; - +const { on, off } = EventListener; const pausedClass = 'paused'; const carouselDefaults = { @@ -98,10 +100,10 @@ function carouselTransitionEndHandler(self) { const directionClass = direction === 'left' ? 'start' : 'end'; addClass(slides[index], activeClass); - removeClass(slides[activeItem], activeClass); - removeClass(slides[index], `${carouselItem}-${orientation}`); removeClass(slides[index], `${carouselItem}-${directionClass}`); + + removeClass(slides[activeItem], activeClass); removeClass(slides[activeItem], `${carouselItem}-${directionClass}`); dispatchEvent(element, carouselSlidEvent); diff --git a/src/components/collapse-native.js b/src/components/collapse-native.js index 42e70b80..843067ba 100644 --- a/src/components/collapse-native.js +++ b/src/components/collapse-native.js @@ -9,8 +9,8 @@ import reflow from 'shorter-js/src/misc/reflow'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import mouseclickEvent from 'shorter-js/src/strings/mouseclickEvent'; import ariaExpanded from 'shorter-js/src/strings/ariaExpanded'; import ObjectAssign from 'shorter-js/src/misc/ObjectAssign'; @@ -19,6 +19,8 @@ import { getInstance } from 'shorter-js/src/misc/data'; import Timer from 'shorter-js/src/misc/timer'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import dataBsToggle from '../strings/dataBsToggle'; import collapsingClass from '../strings/collapsingClass'; import showClass from '../strings/showClass'; @@ -33,6 +35,7 @@ import BaseComponent from './base-component'; const collapseSelector = `.${collapseString}`; const collapseToggleSelector = `[${dataBsToggle}="${collapseString}"]`; const collapseDefaults = { parent: null }; +const { on, off } = EventListener; /** * Static method which returns an existing `Collapse` instance associated diff --git a/src/components/dropdown-native.js b/src/components/dropdown-native.js index 5059bde2..13e3db79 100644 --- a/src/components/dropdown-native.js +++ b/src/components/dropdown-native.js @@ -25,8 +25,8 @@ import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import isRTL from 'shorter-js/src/is/isRTL'; import getElementStyle from 'shorter-js/src/get/getElementStyle'; import getDocumentElement from 'shorter-js/src/get/getDocumentElement'; @@ -34,6 +34,8 @@ import getBoundingClientRect from 'shorter-js/src/get/getBoundingClientRect'; import getDocument from 'shorter-js/src/get/getDocument'; import getWindow from 'shorter-js/src/get/getWindow'; +import EventListener from 'event-listener.js'; + import showClass from '../strings/showClass'; import dataBsToggle from '../strings/dataBsToggle'; import dropdownClasses from '../strings/dropdownClasses'; @@ -52,6 +54,7 @@ const [ dropendString, ] = dropdownClasses; const dropdownSelector = `[${dataBsToggle}="${dropdownString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Dropdown` instance associated diff --git a/src/components/modal-native.js b/src/components/modal-native.js index 043a6e2c..eab8b5fd 100644 --- a/src/components/modal-native.js +++ b/src/components/modal-native.js @@ -19,8 +19,8 @@ import closest from 'shorter-js/src/selectors/closest'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import isRTL from 'shorter-js/src/is/isRTL'; import { getInstance } from 'shorter-js/src/misc/data'; import Timer from 'shorter-js/src/misc/timer'; @@ -31,6 +31,8 @@ import passiveHandler from 'shorter-js/src/misc/passiveHandler'; import emulateTransitionEnd from 'shorter-js/src/misc/emulateTransitionEnd'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import dataBsToggle from '../strings/dataBsToggle'; import dataBsDismiss from '../strings/dataBsDismiss'; import fadeClass from '../strings/fadeClass'; @@ -60,6 +62,7 @@ const modalSelector = `.${modalString}`; const modalToggleSelector = `[${dataBsToggle}="${modalString}"]`; const modalDismissSelector = `[${dataBsDismiss}="${modalString}"]`; const modalStaticClass = `${modalString}-static`; +const { on, off } = EventListener; const modalDefaults = { backdrop: true, // boolean|string diff --git a/src/components/offcanvas-native.js b/src/components/offcanvas-native.js index 2038a012..9a80a0a8 100644 --- a/src/components/offcanvas-native.js +++ b/src/components/offcanvas-native.js @@ -11,8 +11,8 @@ import removeAttribute from 'shorter-js/src/attr/removeAttribute'; import querySelector from 'shorter-js/src/selectors/querySelector'; import querySelectorAll from 'shorter-js/src/selectors/querySelectorAll'; import closest from 'shorter-js/src/selectors/closest'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import hasClass from 'shorter-js/src/class/hasClass'; import addClass from 'shorter-js/src/class/addClass'; import removeClass from 'shorter-js/src/class/removeClass'; @@ -27,6 +27,8 @@ import { getInstance } from 'shorter-js/src/misc/data'; import focus from 'shorter-js/src/misc/focus'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import dataBsDismiss from '../strings/dataBsDismiss'; import dataBsToggle from '../strings/dataBsToggle'; import showClass from '../strings/showClass'; @@ -55,6 +57,7 @@ const offcanvasSelector = `.${offcanvasString}`; const offcanvasToggleSelector = `[${dataBsToggle}="${offcanvasString}"]`; const offcanvasDismissSelector = `[${dataBsDismiss}="${offcanvasString}"]`; const offcanvasTogglingClass = `${offcanvasString}-toggling`; +const { on, off } = EventListener; const offcanvasDefaults = { backdrop: true, // boolean diff --git a/src/components/scrollspy-native.js b/src/components/scrollspy-native.js index 019d5871..effe3ccc 100644 --- a/src/components/scrollspy-native.js +++ b/src/components/scrollspy-native.js @@ -11,8 +11,8 @@ import getDocument from 'shorter-js/src/get/getDocument'; import getDocumentElement from 'shorter-js/src/get/getDocumentElement'; import getDocumentBody from 'shorter-js/src/get/getDocumentBody'; import getBoundingClientRect from 'shorter-js/src/get/getBoundingClientRect'; -import off from 'shorter-js/src/event/off'; -import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; import dispatchEvent from 'shorter-js/src/misc/dispatchEvent'; import passiveHandler from 'shorter-js/src/misc/passiveHandler'; import ObjectAssign from 'shorter-js/src/misc/ObjectAssign'; @@ -20,6 +20,8 @@ import scrollEvent from 'shorter-js/src/strings/scrollEvent'; import { getInstance } from 'shorter-js/src/misc/data'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import activeClass from '../strings/activeClass'; import scrollspyString from '../strings/scrollspyString'; import scrollspyComponent from '../strings/scrollspyComponent'; @@ -31,6 +33,7 @@ import BaseComponent from './base-component'; // SCROLLSPY PRIVATE GC // ==================== const scrollspySelector = '[data-bs-spy="scroll"]'; +const { on, off } = EventListener; const scrollspyDefaults = { offset: 10, diff --git a/src/components/tab-native.js b/src/components/tab-native.js index 682f6dd8..ef027a85 100644 --- a/src/components/tab-native.js +++ b/src/components/tab-native.js @@ -9,8 +9,8 @@ import querySelector from 'shorter-js/src/selectors/querySelector'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import dispatchEvent from 'shorter-js/src/misc/dispatchEvent'; import emulateTransitionEnd from 'shorter-js/src/misc/emulateTransitionEnd'; import reflow from 'shorter-js/src/misc/reflow'; @@ -19,6 +19,8 @@ import { getInstance } from 'shorter-js/src/misc/data'; import Timer from 'shorter-js/src/misc/timer'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import collapsingClass from '../strings/collapsingClass'; import activeClass from '../strings/activeClass'; import fadeClass from '../strings/fadeClass'; @@ -35,6 +37,7 @@ import BaseComponent from './base-component'; // TAB PRIVATE GC // ================ const tabSelector = `[${dataBsToggle}="${tabString}"]`; +const { on, off } = EventListener; /** * Static method which returns an existing `Tab` instance associated diff --git a/src/components/toast-native.js b/src/components/toast-native.js index 40d4fcfe..382770f9 100644 --- a/src/components/toast-native.js +++ b/src/components/toast-native.js @@ -8,8 +8,8 @@ import focusoutEvent from 'shorter-js/src/strings/focusoutEvent'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import querySelector from 'shorter-js/src/selectors/querySelector'; import dispatchEvent from 'shorter-js/src/misc/dispatchEvent'; import emulateTransitionEnd from 'shorter-js/src/misc/emulateTransitionEnd'; @@ -19,6 +19,8 @@ import { getInstance } from 'shorter-js/src/misc/data'; import Timer from 'shorter-js/src/misc/timer'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; +import EventListener from 'event-listener.js'; + import fadeClass from '../strings/fadeClass'; import showClass from '../strings/showClass'; import dataBsDismiss from '../strings/dataBsDismiss'; @@ -34,6 +36,7 @@ const toastDismissSelector = `[${dataBsDismiss}="${toastString}"]`; const showingClass = 'showing'; /** @deprecated */ const hideClass = 'hide'; +const { on, off } = EventListener; const toastDefaults = { animation: true, diff --git a/src/components/tooltip-native.js b/src/components/tooltip-native.js index 2ea94a6e..8f19f726 100644 --- a/src/components/tooltip-native.js +++ b/src/components/tooltip-native.js @@ -26,8 +26,8 @@ import querySelector from 'shorter-js/src/selectors/querySelector'; import addClass from 'shorter-js/src/class/addClass'; import hasClass from 'shorter-js/src/class/hasClass'; import removeClass from 'shorter-js/src/class/removeClass'; -import on from 'shorter-js/src/event/on'; -import off from 'shorter-js/src/event/off'; +// import on from 'shorter-js/src/event/on'; +// import off from 'shorter-js/src/event/off'; import ObjectAssign from 'shorter-js/src/misc/ObjectAssign'; import { getInstance } from 'shorter-js/src/misc/data'; import isMedia from 'shorter-js/src/is/isMedia'; @@ -41,6 +41,8 @@ import focus from 'shorter-js/src/misc/focus'; import OriginalEvent from 'shorter-js/src/misc/OriginalEvent'; import toLowerCase from 'shorter-js/src/misc/toLowerCase'; +import EventListener from 'event-listener.js'; + import dataBsToggle from '../strings/dataBsToggle'; import dataOriginalTitle from '../strings/dataOriginalTitle'; import showClass from '../strings/showClass'; @@ -62,6 +64,7 @@ import BaseComponent from './base-component'; // ================== const tooltipSelector = `[${dataBsToggle}="${tooltipString}"],[data-tip="${tooltipString}"]`; const titleAttr = 'title'; +const { on, off } = EventListener; /** * Static method which returns an existing `Tooltip` instance associated diff --git a/types/index.d.ts b/types/index.d.ts index f43de37b..38ec3d7b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -158,3 +158,4 @@ declare global { // dependency export * as SHORTER from "shorter-js"; +export * as EventListener from "event-listener.js";