You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4447 lines
133 KiB

7 months ago
  1. /*!
  2. * Bootstrap v5.3.3 (https://getbootstrap.com/)
  3. * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. import * as Popper from '@popperjs/core';
  7. /**
  8. * --------------------------------------------------------------------------
  9. * Bootstrap dom/data.js
  10. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  11. * --------------------------------------------------------------------------
  12. */
  13. /**
  14. * Constants
  15. */
  16. const elementMap = new Map();
  17. const Data = {
  18. set(element, key, instance) {
  19. if (!elementMap.has(element)) {
  20. elementMap.set(element, new Map());
  21. }
  22. const instanceMap = elementMap.get(element);
  23. // make it clear we only want one instance per element
  24. // can be removed later when multiple key/instances are fine to be used
  25. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  26. // eslint-disable-next-line no-console
  27. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  28. return;
  29. }
  30. instanceMap.set(key, instance);
  31. },
  32. get(element, key) {
  33. if (elementMap.has(element)) {
  34. return elementMap.get(element).get(key) || null;
  35. }
  36. return null;
  37. },
  38. remove(element, key) {
  39. if (!elementMap.has(element)) {
  40. return;
  41. }
  42. const instanceMap = elementMap.get(element);
  43. instanceMap.delete(key);
  44. // free up element references if there are no instances left for an element
  45. if (instanceMap.size === 0) {
  46. elementMap.delete(element);
  47. }
  48. }
  49. };
  50. /**
  51. * --------------------------------------------------------------------------
  52. * Bootstrap util/index.js
  53. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  54. * --------------------------------------------------------------------------
  55. */
  56. const MAX_UID = 1000000;
  57. const MILLISECONDS_MULTIPLIER = 1000;
  58. const TRANSITION_END = 'transitionend';
  59. /**
  60. * Properly escape IDs selectors to handle weird IDs
  61. * @param {string} selector
  62. * @returns {string}
  63. */
  64. const parseSelector = selector => {
  65. if (selector && window.CSS && window.CSS.escape) {
  66. // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
  67. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  68. }
  69. return selector;
  70. };
  71. // Shout-out Angus Croll (https://goo.gl/pxwQGp)
  72. const toType = object => {
  73. if (object === null || object === undefined) {
  74. return `${object}`;
  75. }
  76. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  77. };
  78. /**
  79. * Public Util API
  80. */
  81. const getUID = prefix => {
  82. do {
  83. prefix += Math.floor(Math.random() * MAX_UID);
  84. } while (document.getElementById(prefix));
  85. return prefix;
  86. };
  87. const getTransitionDurationFromElement = element => {
  88. if (!element) {
  89. return 0;
  90. }
  91. // Get transition-duration of the element
  92. let {
  93. transitionDuration,
  94. transitionDelay
  95. } = window.getComputedStyle(element);
  96. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  97. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  98. // Return 0 if element or transition duration is not found
  99. if (!floatTransitionDuration && !floatTransitionDelay) {
  100. return 0;
  101. }
  102. // If multiple durations are defined, take the first
  103. transitionDuration = transitionDuration.split(',')[0];
  104. transitionDelay = transitionDelay.split(',')[0];
  105. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  106. };
  107. const triggerTransitionEnd = element => {
  108. element.dispatchEvent(new Event(TRANSITION_END));
  109. };
  110. const isElement = object => {
  111. if (!object || typeof object !== 'object') {
  112. return false;
  113. }
  114. if (typeof object.jquery !== 'undefined') {
  115. object = object[0];
  116. }
  117. return typeof object.nodeType !== 'undefined';
  118. };
  119. const getElement = object => {
  120. // it's a jQuery object or a node element
  121. if (isElement(object)) {
  122. return object.jquery ? object[0] : object;
  123. }
  124. if (typeof object === 'string' && object.length > 0) {
  125. return document.querySelector(parseSelector(object));
  126. }
  127. return null;
  128. };
  129. const isVisible = element => {
  130. if (!isElement(element) || element.getClientRects().length === 0) {
  131. return false;
  132. }
  133. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  134. // Handle `details` element as its content may falsie appear visible when it is closed
  135. const closedDetails = element.closest('details:not([open])');
  136. if (!closedDetails) {
  137. return elementIsVisible;
  138. }
  139. if (closedDetails !== element) {
  140. const summary = element.closest('summary');
  141. if (summary && summary.parentNode !== closedDetails) {
  142. return false;
  143. }
  144. if (summary === null) {
  145. return false;
  146. }
  147. }
  148. return elementIsVisible;
  149. };
  150. const isDisabled = element => {
  151. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  152. return true;
  153. }
  154. if (element.classList.contains('disabled')) {
  155. return true;
  156. }
  157. if (typeof element.disabled !== 'undefined') {
  158. return element.disabled;
  159. }
  160. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  161. };
  162. const findShadowRoot = element => {
  163. if (!document.documentElement.attachShadow) {
  164. return null;
  165. }
  166. // Can find the shadow root otherwise it'll return the document
  167. if (typeof element.getRootNode === 'function') {
  168. const root = element.getRootNode();
  169. return root instanceof ShadowRoot ? root : null;
  170. }
  171. if (element instanceof ShadowRoot) {
  172. return element;
  173. }
  174. // when we don't find a shadow root
  175. if (!element.parentNode) {
  176. return null;
  177. }
  178. return findShadowRoot(element.parentNode);
  179. };
  180. const noop = () => {};
  181. /**
  182. * Trick to restart an element's animation
  183. *
  184. * @param {HTMLElement} element
  185. * @return void
  186. *
  187. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  188. */
  189. const reflow = element => {
  190. element.offsetHeight; // eslint-disable-line no-unused-expressions
  191. };
  192. const getjQuery = () => {
  193. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  194. return window.jQuery;
  195. }
  196. return null;
  197. };
  198. const DOMContentLoadedCallbacks = [];
  199. const onDOMContentLoaded = callback => {
  200. if (document.readyState === 'loading') {
  201. // add listener on the first call when the document is in loading state
  202. if (!DOMContentLoadedCallbacks.length) {
  203. document.addEventListener('DOMContentLoaded', () => {
  204. for (const callback of DOMContentLoadedCallbacks) {
  205. callback();
  206. }
  207. });
  208. }
  209. DOMContentLoadedCallbacks.push(callback);
  210. } else {
  211. callback();
  212. }
  213. };
  214. const isRTL = () => document.documentElement.dir === 'rtl';
  215. const defineJQueryPlugin = plugin => {
  216. onDOMContentLoaded(() => {
  217. const $ = getjQuery();
  218. /* istanbul ignore if */
  219. if ($) {
  220. const name = plugin.NAME;
  221. const JQUERY_NO_CONFLICT = $.fn[name];
  222. $.fn[name] = plugin.jQueryInterface;
  223. $.fn[name].Constructor = plugin;
  224. $.fn[name].noConflict = () => {
  225. $.fn[name] = JQUERY_NO_CONFLICT;
  226. return plugin.jQueryInterface;
  227. };
  228. }
  229. });
  230. };
  231. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  232. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  233. };
  234. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  235. if (!waitForTransition) {
  236. execute(callback);
  237. return;
  238. }
  239. const durationPadding = 5;
  240. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  241. let called = false;
  242. const handler = ({
  243. target
  244. }) => {
  245. if (target !== transitionElement) {
  246. return;
  247. }
  248. called = true;
  249. transitionElement.removeEventListener(TRANSITION_END, handler);
  250. execute(callback);
  251. };
  252. transitionElement.addEventListener(TRANSITION_END, handler);
  253. setTimeout(() => {
  254. if (!called) {
  255. triggerTransitionEnd(transitionElement);
  256. }
  257. }, emulatedDuration);
  258. };
  259. /**
  260. * Return the previous/next element of a list.
  261. *
  262. * @param {array} list The list of elements
  263. * @param activeElement The active element
  264. * @param shouldGetNext Choose to get next or previous element
  265. * @param isCycleAllowed
  266. * @return {Element|elem} The proper element
  267. */
  268. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  269. const listLength = list.length;
  270. let index = list.indexOf(activeElement);
  271. // if the element does not exist in the list return an element
  272. // depending on the direction and if cycle is allowed
  273. if (index === -1) {
  274. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  275. }
  276. index += shouldGetNext ? 1 : -1;
  277. if (isCycleAllowed) {
  278. index = (index + listLength) % listLength;
  279. }
  280. return list[Math.max(0, Math.min(index, listLength - 1))];
  281. };
  282. /**
  283. * --------------------------------------------------------------------------
  284. * Bootstrap dom/event-handler.js
  285. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  286. * --------------------------------------------------------------------------
  287. */
  288. /**
  289. * Constants
  290. */
  291. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  292. const stripNameRegex = /\..*/;
  293. const stripUidRegex = /::\d+$/;
  294. const eventRegistry = {}; // Events storage
  295. let uidEvent = 1;
  296. const customEvents = {
  297. mouseenter: 'mouseover',
  298. mouseleave: 'mouseout'
  299. };
  300. const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']);
  301. /**
  302. * Private methods
  303. */
  304. function makeEventUid(element, uid) {
  305. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  306. }
  307. function getElementEvents(element) {
  308. const uid = makeEventUid(element);
  309. element.uidEvent = uid;
  310. eventRegistry[uid] = eventRegistry[uid] || {};
  311. return eventRegistry[uid];
  312. }
  313. function bootstrapHandler(element, fn) {
  314. return function handler(event) {
  315. hydrateObj(event, {
  316. delegateTarget: element
  317. });
  318. if (handler.oneOff) {
  319. EventHandler.off(element, event.type, fn);
  320. }
  321. return fn.apply(element, [event]);
  322. };
  323. }
  324. function bootstrapDelegationHandler(element, selector, fn) {
  325. return function handler(event) {
  326. const domElements = element.querySelectorAll(selector);
  327. for (let {
  328. target
  329. } = event; target && target !== this; target = target.parentNode) {
  330. for (const domElement of domElements) {
  331. if (domElement !== target) {
  332. continue;
  333. }
  334. hydrateObj(event, {
  335. delegateTarget: target
  336. });
  337. if (handler.oneOff) {
  338. EventHandler.off(element, event.type, selector, fn);
  339. }
  340. return fn.apply(target, [event]);
  341. }
  342. }
  343. };
  344. }
  345. function findHandler(events, callable, delegationSelector = null) {
  346. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  347. }
  348. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  349. const isDelegated = typeof handler === 'string';
  350. // TODO: tooltip passes `false` instead of selector, so we need to check
  351. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  352. let typeEvent = getTypeEvent(originalTypeEvent);
  353. if (!nativeEvents.has(typeEvent)) {
  354. typeEvent = originalTypeEvent;
  355. }
  356. return [isDelegated, callable, typeEvent];
  357. }
  358. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  359. if (typeof originalTypeEvent !== 'string' || !element) {
  360. return;
  361. }
  362. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  363. // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  364. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  365. if (originalTypeEvent in customEvents) {
  366. const wrapFunction = fn => {
  367. return function (event) {
  368. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  369. return fn.call(this, event);
  370. }
  371. };
  372. };
  373. callable = wrapFunction(callable);
  374. }
  375. const events = getElementEvents(element);
  376. const handlers = events[typeEvent] || (events[typeEvent] = {});
  377. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  378. if (previousFunction) {
  379. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  380. return;
  381. }
  382. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  383. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  384. fn.delegationSelector = isDelegated ? handler : null;
  385. fn.callable = callable;
  386. fn.oneOff = oneOff;
  387. fn.uidEvent = uid;
  388. handlers[uid] = fn;
  389. element.addEventListener(typeEvent, fn, isDelegated);
  390. }
  391. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  392. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  393. if (!fn) {
  394. return;
  395. }
  396. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  397. delete events[typeEvent][fn.uidEvent];
  398. }
  399. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  400. const storeElementEvent = events[typeEvent] || {};
  401. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  402. if (handlerKey.includes(namespace)) {
  403. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  404. }
  405. }
  406. }
  407. function getTypeEvent(event) {
  408. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  409. event = event.replace(stripNameRegex, '');
  410. return customEvents[event] || event;
  411. }
  412. const EventHandler = {
  413. on(element, event, handler, delegationFunction) {
  414. addHandler(element, event, handler, delegationFunction, false);
  415. },
  416. one(element, event, handler, delegationFunction) {
  417. addHandler(element, event, handler, delegationFunction, true);
  418. },
  419. off(element, originalTypeEvent, handler, delegationFunction) {
  420. if (typeof originalTypeEvent !== 'string' || !element) {
  421. return;
  422. }
  423. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  424. const inNamespace = typeEvent !== originalTypeEvent;
  425. const events = getElementEvents(element);
  426. const storeElementEvent = events[typeEvent] || {};
  427. const isNamespace = originalTypeEvent.startsWith('.');
  428. if (typeof callable !== 'undefined') {
  429. // Simplest case: handler is passed, remove that listener ONLY.
  430. if (!Object.keys(storeElementEvent).length) {
  431. return;
  432. }
  433. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  434. return;
  435. }
  436. if (isNamespace) {
  437. for (const elementEvent of Object.keys(events)) {
  438. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  439. }
  440. }
  441. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  442. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  443. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  444. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  445. }
  446. }
  447. },
  448. trigger(element, event, args) {
  449. if (typeof event !== 'string' || !element) {
  450. return null;
  451. }
  452. const $ = getjQuery();
  453. const typeEvent = getTypeEvent(event);
  454. const inNamespace = event !== typeEvent;
  455. let jQueryEvent = null;
  456. let bubbles = true;
  457. let nativeDispatch = true;
  458. let defaultPrevented = false;
  459. if (inNamespace && $) {
  460. jQueryEvent = $.Event(event, args);
  461. $(element).trigger(jQueryEvent);
  462. bubbles = !jQueryEvent.isPropagationStopped();
  463. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  464. defaultPrevented = jQueryEvent.isDefaultPrevented();
  465. }
  466. const evt = hydrateObj(new Event(event, {
  467. bubbles,
  468. cancelable: true
  469. }), args);
  470. if (defaultPrevented) {
  471. evt.preventDefault();
  472. }
  473. if (nativeDispatch) {
  474. element.dispatchEvent(evt);
  475. }
  476. if (evt.defaultPrevented && jQueryEvent) {
  477. jQueryEvent.preventDefault();
  478. }
  479. return evt;
  480. }
  481. };
  482. function hydrateObj(obj, meta = {}) {
  483. for (const [key, value] of Object.entries(meta)) {
  484. try {
  485. obj[key] = value;
  486. } catch (_unused) {
  487. Object.defineProperty(obj, key, {
  488. configurable: true,
  489. get() {
  490. return value;
  491. }
  492. });
  493. }
  494. }
  495. return obj;
  496. }
  497. /**
  498. * --------------------------------------------------------------------------
  499. * Bootstrap dom/manipulator.js
  500. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  501. * --------------------------------------------------------------------------
  502. */
  503. function normalizeData(value) {
  504. if (value === 'true') {
  505. return true;
  506. }
  507. if (value === 'false') {
  508. return false;
  509. }
  510. if (value === Number(value).toString()) {
  511. return Number(value);
  512. }
  513. if (value === '' || value === 'null') {
  514. return null;
  515. }
  516. if (typeof value !== 'string') {
  517. return value;
  518. }
  519. try {
  520. return JSON.parse(decodeURIComponent(value));
  521. } catch (_unused) {
  522. return value;
  523. }
  524. }
  525. function normalizeDataKey(key) {
  526. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  527. }
  528. const Manipulator = {
  529. setDataAttribute(element, key, value) {
  530. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  531. },
  532. removeDataAttribute(element, key) {
  533. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  534. },
  535. getDataAttributes(element) {
  536. if (!element) {
  537. return {};
  538. }
  539. const attributes = {};
  540. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  541. for (const key of bsKeys) {
  542. let pureKey = key.replace(/^bs/, '');
  543. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  544. attributes[pureKey] = normalizeData(element.dataset[key]);
  545. }
  546. return attributes;
  547. },
  548. getDataAttribute(element, key) {
  549. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  550. }
  551. };
  552. /**
  553. * --------------------------------------------------------------------------
  554. * Bootstrap util/config.js
  555. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  556. * --------------------------------------------------------------------------
  557. */
  558. /**
  559. * Class definition
  560. */
  561. class Config {
  562. // Getters
  563. static get Default() {
  564. return {};
  565. }
  566. static get DefaultType() {
  567. return {};
  568. }
  569. static get NAME() {
  570. throw new Error('You have to implement the static method "NAME", for each component!');
  571. }
  572. _getConfig(config) {
  573. config = this._mergeConfigObj(config);
  574. config = this._configAfterMerge(config);
  575. this._typeCheckConfig(config);
  576. return config;
  577. }
  578. _configAfterMerge(config) {
  579. return config;
  580. }
  581. _mergeConfigObj(config, element) {
  582. const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
  583. return {
  584. ...this.constructor.Default,
  585. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  586. ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}),
  587. ...(typeof config === 'object' ? config : {})
  588. };
  589. }
  590. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  591. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  592. const value = config[property];
  593. const valueType = isElement(value) ? 'element' : toType(value);
  594. if (!new RegExp(expectedTypes).test(valueType)) {
  595. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  596. }
  597. }
  598. }
  599. }
  600. /**
  601. * --------------------------------------------------------------------------
  602. * Bootstrap base-component.js
  603. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  604. * --------------------------------------------------------------------------
  605. */
  606. /**
  607. * Constants
  608. */
  609. const VERSION = '5.3.3';
  610. /**
  611. * Class definition
  612. */
  613. class BaseComponent extends Config {
  614. constructor(element, config) {
  615. super();
  616. element = getElement(element);
  617. if (!element) {
  618. return;
  619. }
  620. this._element = element;
  621. this._config = this._getConfig(config);
  622. Data.set(this._element, this.constructor.DATA_KEY, this);
  623. }
  624. // Public
  625. dispose() {
  626. Data.remove(this._element, this.constructor.DATA_KEY);
  627. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  628. for (const propertyName of Object.getOwnPropertyNames(this)) {
  629. this[propertyName] = null;
  630. }
  631. }
  632. _queueCallback(callback, element, isAnimated = true) {
  633. executeAfterTransition(callback, element, isAnimated);
  634. }
  635. _getConfig(config) {
  636. config = this._mergeConfigObj(config, this._element);
  637. config = this._configAfterMerge(config);
  638. this._typeCheckConfig(config);
  639. return config;
  640. }
  641. // Static
  642. static getInstance(element) {
  643. return Data.get(getElement(element), this.DATA_KEY);
  644. }
  645. static getOrCreateInstance(element, config = {}) {
  646. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  647. }
  648. static get VERSION() {
  649. return VERSION;
  650. }
  651. static get DATA_KEY() {
  652. return `bs.${this.NAME}`;
  653. }
  654. static get EVENT_KEY() {
  655. return `.${this.DATA_KEY}`;
  656. }
  657. static eventName(name) {
  658. return `${name}${this.EVENT_KEY}`;
  659. }
  660. }
  661. /**
  662. * --------------------------------------------------------------------------
  663. * Bootstrap dom/selector-engine.js
  664. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  665. * --------------------------------------------------------------------------
  666. */
  667. const getSelector = element => {
  668. let selector = element.getAttribute('data-bs-target');
  669. if (!selector || selector === '#') {
  670. let hrefAttribute = element.getAttribute('href');
  671. // The only valid content that could double as a selector are IDs or classes,
  672. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  673. // `document.querySelector` will rightfully complain it is invalid.
  674. // See https://github.com/twbs/bootstrap/issues/32273
  675. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  676. return null;
  677. }
  678. // Just in case some CMS puts out a full URL with the anchor appended
  679. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  680. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  681. }
  682. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  683. }
  684. return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null;
  685. };
  686. const SelectorEngine = {
  687. find(selector, element = document.documentElement) {
  688. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  689. },
  690. findOne(selector, element = document.documentElement) {
  691. return Element.prototype.querySelector.call(element, selector);
  692. },
  693. children(element, selector) {
  694. return [].concat(...element.children).filter(child => child.matches(selector));
  695. },
  696. parents(element, selector) {
  697. const parents = [];
  698. let ancestor = element.parentNode.closest(selector);
  699. while (ancestor) {
  700. parents.push(ancestor);
  701. ancestor = ancestor.parentNode.closest(selector);
  702. }
  703. return parents;
  704. },
  705. prev(element, selector) {
  706. let previous = element.previousElementSibling;
  707. while (previous) {
  708. if (previous.matches(selector)) {
  709. return [previous];
  710. }
  711. previous = previous.previousElementSibling;
  712. }
  713. return [];
  714. },
  715. // TODO: this is now unused; remove later along with prev()
  716. next(element, selector) {
  717. let next = element.nextElementSibling;
  718. while (next) {
  719. if (next.matches(selector)) {
  720. return [next];
  721. }
  722. next = next.nextElementSibling;
  723. }
  724. return [];
  725. },
  726. focusableChildren(element) {
  727. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  728. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  729. },
  730. getSelectorFromElement(element) {
  731. const selector = getSelector(element);
  732. if (selector) {
  733. return SelectorEngine.findOne(selector) ? selector : null;
  734. }
  735. return null;
  736. },
  737. getElementFromSelector(element) {
  738. const selector = getSelector(element);
  739. return selector ? SelectorEngine.findOne(selector) : null;
  740. },
  741. getMultipleElementsFromSelector(element) {
  742. const selector = getSelector(element);
  743. return selector ? SelectorEngine.find(selector) : [];
  744. }
  745. };
  746. /**
  747. * --------------------------------------------------------------------------
  748. * Bootstrap util/component-functions.js
  749. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  750. * --------------------------------------------------------------------------
  751. */
  752. const enableDismissTrigger = (component, method = 'hide') => {
  753. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  754. const name = component.NAME;
  755. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  756. if (['A', 'AREA'].includes(this.tagName)) {
  757. event.preventDefault();
  758. }
  759. if (isDisabled(this)) {
  760. return;
  761. }
  762. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  763. const instance = component.getOrCreateInstance(target);
  764. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  765. instance[method]();
  766. });
  767. };
  768. /**
  769. * --------------------------------------------------------------------------
  770. * Bootstrap alert.js
  771. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  772. * --------------------------------------------------------------------------
  773. */
  774. /**
  775. * Constants
  776. */
  777. const NAME$f = 'alert';
  778. const DATA_KEY$a = 'bs.alert';
  779. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  780. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  781. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  782. const CLASS_NAME_FADE$5 = 'fade';
  783. const CLASS_NAME_SHOW$8 = 'show';
  784. /**
  785. * Class definition
  786. */
  787. class Alert extends BaseComponent {
  788. // Getters
  789. static get NAME() {
  790. return NAME$f;
  791. }
  792. // Public
  793. close() {
  794. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  795. if (closeEvent.defaultPrevented) {
  796. return;
  797. }
  798. this._element.classList.remove(CLASS_NAME_SHOW$8);
  799. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  800. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  801. }
  802. // Private
  803. _destroyElement() {
  804. this._element.remove();
  805. EventHandler.trigger(this._element, EVENT_CLOSED);
  806. this.dispose();
  807. }
  808. // Static
  809. static jQueryInterface(config) {
  810. return this.each(function () {
  811. const data = Alert.getOrCreateInstance(this);
  812. if (typeof config !== 'string') {
  813. return;
  814. }
  815. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  816. throw new TypeError(`No method named "${config}"`);
  817. }
  818. data[config](this);
  819. });
  820. }
  821. }
  822. /**
  823. * Data API implementation
  824. */
  825. enableDismissTrigger(Alert, 'close');
  826. /**
  827. * jQuery
  828. */
  829. defineJQueryPlugin(Alert);
  830. /**
  831. * --------------------------------------------------------------------------
  832. * Bootstrap button.js
  833. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  834. * --------------------------------------------------------------------------
  835. */
  836. /**
  837. * Constants
  838. */
  839. const NAME$e = 'button';
  840. const DATA_KEY$9 = 'bs.button';
  841. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  842. const DATA_API_KEY$6 = '.data-api';
  843. const CLASS_NAME_ACTIVE$3 = 'active';
  844. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  845. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  846. /**
  847. * Class definition
  848. */
  849. class Button extends BaseComponent {
  850. // Getters
  851. static get NAME() {
  852. return NAME$e;
  853. }
  854. // Public
  855. toggle() {
  856. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  857. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  858. }
  859. // Static
  860. static jQueryInterface(config) {
  861. return this.each(function () {
  862. const data = Button.getOrCreateInstance(this);
  863. if (config === 'toggle') {
  864. data[config]();
  865. }
  866. });
  867. }
  868. }
  869. /**
  870. * Data API implementation
  871. */
  872. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  873. event.preventDefault();
  874. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  875. const data = Button.getOrCreateInstance(button);
  876. data.toggle();
  877. });
  878. /**
  879. * jQuery
  880. */
  881. defineJQueryPlugin(Button);
  882. /**
  883. * --------------------------------------------------------------------------
  884. * Bootstrap util/swipe.js
  885. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  886. * --------------------------------------------------------------------------
  887. */
  888. /**
  889. * Constants
  890. */
  891. const NAME$d = 'swipe';
  892. const EVENT_KEY$9 = '.bs.swipe';
  893. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  894. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  895. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  896. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  897. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  898. const POINTER_TYPE_TOUCH = 'touch';
  899. const POINTER_TYPE_PEN = 'pen';
  900. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  901. const SWIPE_THRESHOLD = 40;
  902. const Default$c = {
  903. endCallback: null,
  904. leftCallback: null,
  905. rightCallback: null
  906. };
  907. const DefaultType$c = {
  908. endCallback: '(function|null)',
  909. leftCallback: '(function|null)',
  910. rightCallback: '(function|null)'
  911. };
  912. /**
  913. * Class definition
  914. */
  915. class Swipe extends Config {
  916. constructor(element, config) {
  917. super();
  918. this._element = element;
  919. if (!element || !Swipe.isSupported()) {
  920. return;
  921. }
  922. this._config = this._getConfig(config);
  923. this._deltaX = 0;
  924. this._supportPointerEvents = Boolean(window.PointerEvent);
  925. this._initEvents();
  926. }
  927. // Getters
  928. static get Default() {
  929. return Default$c;
  930. }
  931. static get DefaultType() {
  932. return DefaultType$c;
  933. }
  934. static get NAME() {
  935. return NAME$d;
  936. }
  937. // Public
  938. dispose() {
  939. EventHandler.off(this._element, EVENT_KEY$9);
  940. }
  941. // Private
  942. _start(event) {
  943. if (!this._supportPointerEvents) {
  944. this._deltaX = event.touches[0].clientX;
  945. return;
  946. }
  947. if (this._eventIsPointerPenTouch(event)) {
  948. this._deltaX = event.clientX;
  949. }
  950. }
  951. _end(event) {
  952. if (this._eventIsPointerPenTouch(event)) {
  953. this._deltaX = event.clientX - this._deltaX;
  954. }
  955. this._handleSwipe();
  956. execute(this._config.endCallback);
  957. }
  958. _move(event) {
  959. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  960. }
  961. _handleSwipe() {
  962. const absDeltaX = Math.abs(this._deltaX);
  963. if (absDeltaX <= SWIPE_THRESHOLD) {
  964. return;
  965. }
  966. const direction = absDeltaX / this._deltaX;
  967. this._deltaX = 0;
  968. if (!direction) {
  969. return;
  970. }
  971. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  972. }
  973. _initEvents() {
  974. if (this._supportPointerEvents) {
  975. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  976. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  977. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  978. } else {
  979. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  980. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  981. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  982. }
  983. }
  984. _eventIsPointerPenTouch(event) {
  985. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  986. }
  987. // Static
  988. static isSupported() {
  989. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  990. }
  991. }
  992. /**
  993. * --------------------------------------------------------------------------
  994. * Bootstrap carousel.js
  995. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  996. * --------------------------------------------------------------------------
  997. */
  998. /**
  999. * Constants
  1000. */
  1001. const NAME$c = 'carousel';
  1002. const DATA_KEY$8 = 'bs.carousel';
  1003. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  1004. const DATA_API_KEY$5 = '.data-api';
  1005. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  1006. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  1007. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1008. const ORDER_NEXT = 'next';
  1009. const ORDER_PREV = 'prev';
  1010. const DIRECTION_LEFT = 'left';
  1011. const DIRECTION_RIGHT = 'right';
  1012. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  1013. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  1014. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  1015. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  1016. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  1017. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  1018. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1019. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1020. const CLASS_NAME_CAROUSEL = 'carousel';
  1021. const CLASS_NAME_ACTIVE$2 = 'active';
  1022. const CLASS_NAME_SLIDE = 'slide';
  1023. const CLASS_NAME_END = 'carousel-item-end';
  1024. const CLASS_NAME_START = 'carousel-item-start';
  1025. const CLASS_NAME_NEXT = 'carousel-item-next';
  1026. const CLASS_NAME_PREV = 'carousel-item-prev';
  1027. const SELECTOR_ACTIVE = '.active';
  1028. const SELECTOR_ITEM = '.carousel-item';
  1029. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  1030. const SELECTOR_ITEM_IMG = '.carousel-item img';
  1031. const SELECTOR_INDICATORS = '.carousel-indicators';
  1032. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  1033. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  1034. const KEY_TO_DIRECTION = {
  1035. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  1036. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  1037. };
  1038. const Default$b = {
  1039. interval: 5000,
  1040. keyboard: true,
  1041. pause: 'hover',
  1042. ride: false,
  1043. touch: true,
  1044. wrap: true
  1045. };
  1046. const DefaultType$b = {
  1047. interval: '(number|boolean)',
  1048. // TODO:v6 remove boolean support
  1049. keyboard: 'boolean',
  1050. pause: '(string|boolean)',
  1051. ride: '(boolean|string)',
  1052. touch: 'boolean',
  1053. wrap: 'boolean'
  1054. };
  1055. /**
  1056. * Class definition
  1057. */
  1058. class Carousel extends BaseComponent {
  1059. constructor(element, config) {
  1060. super(element, config);
  1061. this._interval = null;
  1062. this._activeElement = null;
  1063. this._isSliding = false;
  1064. this.touchTimeout = null;
  1065. this._swipeHelper = null;
  1066. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  1067. this._addEventListeners();
  1068. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  1069. this.cycle();
  1070. }
  1071. }
  1072. // Getters
  1073. static get Default() {
  1074. return Default$b;
  1075. }
  1076. static get DefaultType() {
  1077. return DefaultType$b;
  1078. }
  1079. static get NAME() {
  1080. return NAME$c;
  1081. }
  1082. // Public
  1083. next() {
  1084. this._slide(ORDER_NEXT);
  1085. }
  1086. nextWhenVisible() {
  1087. // FIXME TODO use `document.visibilityState`
  1088. // Don't call next when the page isn't visible
  1089. // or the carousel or its parent isn't visible
  1090. if (!document.hidden && isVisible(this._element)) {
  1091. this.next();
  1092. }
  1093. }
  1094. prev() {
  1095. this._slide(ORDER_PREV);
  1096. }
  1097. pause() {
  1098. if (this._isSliding) {
  1099. triggerTransitionEnd(this._element);
  1100. }
  1101. this._clearInterval();
  1102. }
  1103. cycle() {
  1104. this._clearInterval();
  1105. this._updateInterval();
  1106. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  1107. }
  1108. _maybeEnableCycle() {
  1109. if (!this._config.ride) {
  1110. return;
  1111. }
  1112. if (this._isSliding) {
  1113. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  1114. return;
  1115. }
  1116. this.cycle();
  1117. }
  1118. to(index) {
  1119. const items = this._getItems();
  1120. if (index > items.length - 1 || index < 0) {
  1121. return;
  1122. }
  1123. if (this._isSliding) {
  1124. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  1125. return;
  1126. }
  1127. const activeIndex = this._getItemIndex(this._getActive());
  1128. if (activeIndex === index) {
  1129. return;
  1130. }
  1131. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  1132. this._slide(order, items[index]);
  1133. }
  1134. dispose() {
  1135. if (this._swipeHelper) {
  1136. this._swipeHelper.dispose();
  1137. }
  1138. super.dispose();
  1139. }
  1140. // Private
  1141. _configAfterMerge(config) {
  1142. config.defaultInterval = config.interval;
  1143. return config;
  1144. }
  1145. _addEventListeners() {
  1146. if (this._config.keyboard) {
  1147. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  1148. }
  1149. if (this._config.pause === 'hover') {
  1150. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  1151. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  1152. }
  1153. if (this._config.touch && Swipe.isSupported()) {
  1154. this._addTouchEventListeners();
  1155. }
  1156. }
  1157. _addTouchEventListeners() {
  1158. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  1159. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  1160. }
  1161. const endCallBack = () => {
  1162. if (this._config.pause !== 'hover') {
  1163. return;
  1164. }
  1165. // If it's a touch-enabled device, mouseenter/leave are fired as
  1166. // part of the mouse compatibility events on first tap - the carousel
  1167. // would stop cycling until user tapped out of it;
  1168. // here, we listen for touchend, explicitly pause the carousel
  1169. // (as if it's the second time we tap on it, mouseenter compat event
  1170. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1171. // events to fire) we explicitly restart cycling
  1172. this.pause();
  1173. if (this.touchTimeout) {
  1174. clearTimeout(this.touchTimeout);
  1175. }
  1176. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1177. };
  1178. const swipeConfig = {
  1179. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  1180. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  1181. endCallback: endCallBack
  1182. };
  1183. this._swipeHelper = new Swipe(this._element, swipeConfig);
  1184. }
  1185. _keydown(event) {
  1186. if (/input|textarea/i.test(event.target.tagName)) {
  1187. return;
  1188. }
  1189. const direction = KEY_TO_DIRECTION[event.key];
  1190. if (direction) {
  1191. event.preventDefault();
  1192. this._slide(this._directionToOrder(direction));
  1193. }
  1194. }
  1195. _getItemIndex(element) {
  1196. return this._getItems().indexOf(element);
  1197. }
  1198. _setActiveIndicatorElement(index) {
  1199. if (!this._indicatorsElement) {
  1200. return;
  1201. }
  1202. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  1203. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1204. activeIndicator.removeAttribute('aria-current');
  1205. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  1206. if (newActiveIndicator) {
  1207. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  1208. newActiveIndicator.setAttribute('aria-current', 'true');
  1209. }
  1210. }
  1211. _updateInterval() {
  1212. const element = this._activeElement || this._getActive();
  1213. if (!element) {
  1214. return;
  1215. }
  1216. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1217. this._config.interval = elementInterval || this._config.defaultInterval;
  1218. }
  1219. _slide(order, element = null) {
  1220. if (this._isSliding) {
  1221. return;
  1222. }
  1223. const activeElement = this._getActive();
  1224. const isNext = order === ORDER_NEXT;
  1225. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  1226. if (nextElement === activeElement) {
  1227. return;
  1228. }
  1229. const nextElementIndex = this._getItemIndex(nextElement);
  1230. const triggerEvent = eventName => {
  1231. return EventHandler.trigger(this._element, eventName, {
  1232. relatedTarget: nextElement,
  1233. direction: this._orderToDirection(order),
  1234. from: this._getItemIndex(activeElement),
  1235. to: nextElementIndex
  1236. });
  1237. };
  1238. const slideEvent = triggerEvent(EVENT_SLIDE);
  1239. if (slideEvent.defaultPrevented) {
  1240. return;
  1241. }
  1242. if (!activeElement || !nextElement) {
  1243. // Some weirdness is happening, so we bail
  1244. // TODO: change tests that use empty divs to avoid this check
  1245. return;
  1246. }
  1247. const isCycling = Boolean(this._interval);
  1248. this.pause();
  1249. this._isSliding = true;
  1250. this._setActiveIndicatorElement(nextElementIndex);
  1251. this._activeElement = nextElement;
  1252. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1253. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1254. nextElement.classList.add(orderClassName);
  1255. reflow(nextElement);
  1256. activeElement.classList.add(directionalClassName);
  1257. nextElement.classList.add(directionalClassName);
  1258. const completeCallBack = () => {
  1259. nextElement.classList.remove(directionalClassName, orderClassName);
  1260. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1261. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1262. this._isSliding = false;
  1263. triggerEvent(EVENT_SLID);
  1264. };
  1265. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  1266. if (isCycling) {
  1267. this.cycle();
  1268. }
  1269. }
  1270. _isAnimated() {
  1271. return this._element.classList.contains(CLASS_NAME_SLIDE);
  1272. }
  1273. _getActive() {
  1274. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1275. }
  1276. _getItems() {
  1277. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  1278. }
  1279. _clearInterval() {
  1280. if (this._interval) {
  1281. clearInterval(this._interval);
  1282. this._interval = null;
  1283. }
  1284. }
  1285. _directionToOrder(direction) {
  1286. if (isRTL()) {
  1287. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1288. }
  1289. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1290. }
  1291. _orderToDirection(order) {
  1292. if (isRTL()) {
  1293. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1294. }
  1295. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1296. }
  1297. // Static
  1298. static jQueryInterface(config) {
  1299. return this.each(function () {
  1300. const data = Carousel.getOrCreateInstance(this, config);
  1301. if (typeof config === 'number') {
  1302. data.to(config);
  1303. return;
  1304. }
  1305. if (typeof config === 'string') {
  1306. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1307. throw new TypeError(`No method named "${config}"`);
  1308. }
  1309. data[config]();
  1310. }
  1311. });
  1312. }
  1313. }
  1314. /**
  1315. * Data API implementation
  1316. */
  1317. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  1318. const target = SelectorEngine.getElementFromSelector(this);
  1319. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1320. return;
  1321. }
  1322. event.preventDefault();
  1323. const carousel = Carousel.getOrCreateInstance(target);
  1324. const slideIndex = this.getAttribute('data-bs-slide-to');
  1325. if (slideIndex) {
  1326. carousel.to(slideIndex);
  1327. carousel._maybeEnableCycle();
  1328. return;
  1329. }
  1330. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  1331. carousel.next();
  1332. carousel._maybeEnableCycle();
  1333. return;
  1334. }
  1335. carousel.prev();
  1336. carousel._maybeEnableCycle();
  1337. });
  1338. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  1339. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1340. for (const carousel of carousels) {
  1341. Carousel.getOrCreateInstance(carousel);
  1342. }
  1343. });
  1344. /**
  1345. * jQuery
  1346. */
  1347. defineJQueryPlugin(Carousel);
  1348. /**
  1349. * --------------------------------------------------------------------------
  1350. * Bootstrap collapse.js
  1351. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1352. * --------------------------------------------------------------------------
  1353. */
  1354. /**
  1355. * Constants
  1356. */
  1357. const NAME$b = 'collapse';
  1358. const DATA_KEY$7 = 'bs.collapse';
  1359. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  1360. const DATA_API_KEY$4 = '.data-api';
  1361. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  1362. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  1363. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  1364. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  1365. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  1366. const CLASS_NAME_SHOW$7 = 'show';
  1367. const CLASS_NAME_COLLAPSE = 'collapse';
  1368. const CLASS_NAME_COLLAPSING = 'collapsing';
  1369. const CLASS_NAME_COLLAPSED = 'collapsed';
  1370. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1371. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1372. const WIDTH = 'width';
  1373. const HEIGHT = 'height';
  1374. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1375. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1376. const Default$a = {
  1377. parent: null,
  1378. toggle: true
  1379. };
  1380. const DefaultType$a = {
  1381. parent: '(null|element)',
  1382. toggle: 'boolean'
  1383. };
  1384. /**
  1385. * Class definition
  1386. */
  1387. class Collapse extends BaseComponent {
  1388. constructor(element, config) {
  1389. super(element, config);
  1390. this._isTransitioning = false;
  1391. this._triggerArray = [];
  1392. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1393. for (const elem of toggleList) {
  1394. const selector = SelectorEngine.getSelectorFromElement(elem);
  1395. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  1396. if (selector !== null && filterElement.length) {
  1397. this._triggerArray.push(elem);
  1398. }
  1399. }
  1400. this._initializeChildren();
  1401. if (!this._config.parent) {
  1402. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1403. }
  1404. if (this._config.toggle) {
  1405. this.toggle();
  1406. }
  1407. }
  1408. // Getters
  1409. static get Default() {
  1410. return Default$a;
  1411. }
  1412. static get DefaultType() {
  1413. return DefaultType$a;
  1414. }
  1415. static get NAME() {
  1416. return NAME$b;
  1417. }
  1418. // Public
  1419. toggle() {
  1420. if (this._isShown()) {
  1421. this.hide();
  1422. } else {
  1423. this.show();
  1424. }
  1425. }
  1426. show() {
  1427. if (this._isTransitioning || this._isShown()) {
  1428. return;
  1429. }
  1430. let activeChildren = [];
  1431. // find active children
  1432. if (this._config.parent) {
  1433. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  1434. toggle: false
  1435. }));
  1436. }
  1437. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  1438. return;
  1439. }
  1440. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  1441. if (startEvent.defaultPrevented) {
  1442. return;
  1443. }
  1444. for (const activeInstance of activeChildren) {
  1445. activeInstance.hide();
  1446. }
  1447. const dimension = this._getDimension();
  1448. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1449. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1450. this._element.style[dimension] = 0;
  1451. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1452. this._isTransitioning = true;
  1453. const complete = () => {
  1454. this._isTransitioning = false;
  1455. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1456. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1457. this._element.style[dimension] = '';
  1458. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  1459. };
  1460. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1461. const scrollSize = `scroll${capitalizedDimension}`;
  1462. this._queueCallback(complete, this._element, true);
  1463. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1464. }
  1465. hide() {
  1466. if (this._isTransitioning || !this._isShown()) {
  1467. return;
  1468. }
  1469. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  1470. if (startEvent.defaultPrevented) {
  1471. return;
  1472. }
  1473. const dimension = this._getDimension();
  1474. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1475. reflow(this._element);
  1476. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1477. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1478. for (const trigger of this._triggerArray) {
  1479. const element = SelectorEngine.getElementFromSelector(trigger);
  1480. if (element && !this._isShown(element)) {
  1481. this._addAriaAndCollapsedClass([trigger], false);
  1482. }
  1483. }
  1484. this._isTransitioning = true;
  1485. const complete = () => {
  1486. this._isTransitioning = false;
  1487. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1488. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1489. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  1490. };
  1491. this._element.style[dimension] = '';
  1492. this._queueCallback(complete, this._element, true);
  1493. }
  1494. _isShown(element = this._element) {
  1495. return element.classList.contains(CLASS_NAME_SHOW$7);
  1496. }
  1497. // Private
  1498. _configAfterMerge(config) {
  1499. config.toggle = Boolean(config.toggle); // Coerce string values
  1500. config.parent = getElement(config.parent);
  1501. return config;
  1502. }
  1503. _getDimension() {
  1504. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1505. }
  1506. _initializeChildren() {
  1507. if (!this._config.parent) {
  1508. return;
  1509. }
  1510. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  1511. for (const element of children) {
  1512. const selected = SelectorEngine.getElementFromSelector(element);
  1513. if (selected) {
  1514. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  1515. }
  1516. }
  1517. }
  1518. _getFirstLevelChildren(selector) {
  1519. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  1520. // remove children if greater depth
  1521. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  1522. }
  1523. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  1524. if (!triggerArray.length) {
  1525. return;
  1526. }
  1527. for (const element of triggerArray) {
  1528. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  1529. element.setAttribute('aria-expanded', isOpen);
  1530. }
  1531. }
  1532. // Static
  1533. static jQueryInterface(config) {
  1534. const _config = {};
  1535. if (typeof config === 'string' && /show|hide/.test(config)) {
  1536. _config.toggle = false;
  1537. }
  1538. return this.each(function () {
  1539. const data = Collapse.getOrCreateInstance(this, _config);
  1540. if (typeof config === 'string') {
  1541. if (typeof data[config] === 'undefined') {
  1542. throw new TypeError(`No method named "${config}"`);
  1543. }
  1544. data[config]();
  1545. }
  1546. });
  1547. }
  1548. }
  1549. /**
  1550. * Data API implementation
  1551. */
  1552. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  1553. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  1554. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  1555. event.preventDefault();
  1556. }
  1557. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  1558. Collapse.getOrCreateInstance(element, {
  1559. toggle: false
  1560. }).toggle();
  1561. }
  1562. });
  1563. /**
  1564. * jQuery
  1565. */
  1566. defineJQueryPlugin(Collapse);
  1567. /**
  1568. * --------------------------------------------------------------------------
  1569. * Bootstrap dropdown.js
  1570. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1571. * --------------------------------------------------------------------------
  1572. */
  1573. /**
  1574. * Constants
  1575. */
  1576. const NAME$a = 'dropdown';
  1577. const DATA_KEY$6 = 'bs.dropdown';
  1578. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  1579. const DATA_API_KEY$3 = '.data-api';
  1580. const ESCAPE_KEY$2 = 'Escape';
  1581. const TAB_KEY$1 = 'Tab';
  1582. const ARROW_UP_KEY$1 = 'ArrowUp';
  1583. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  1584. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  1585. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  1586. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  1587. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  1588. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  1589. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1590. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1591. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  1592. const CLASS_NAME_SHOW$6 = 'show';
  1593. const CLASS_NAME_DROPUP = 'dropup';
  1594. const CLASS_NAME_DROPEND = 'dropend';
  1595. const CLASS_NAME_DROPSTART = 'dropstart';
  1596. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  1597. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  1598. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  1599. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  1600. const SELECTOR_MENU = '.dropdown-menu';
  1601. const SELECTOR_NAVBAR = '.navbar';
  1602. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  1603. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  1604. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  1605. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  1606. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  1607. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  1608. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  1609. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  1610. const PLACEMENT_TOPCENTER = 'top';
  1611. const PLACEMENT_BOTTOMCENTER = 'bottom';
  1612. const Default$9 = {
  1613. autoClose: true,
  1614. boundary: 'clippingParents',
  1615. display: 'dynamic',
  1616. offset: [0, 2],
  1617. popperConfig: null,
  1618. reference: 'toggle'
  1619. };
  1620. const DefaultType$9 = {
  1621. autoClose: '(boolean|string)',
  1622. boundary: '(string|element)',
  1623. display: 'string',
  1624. offset: '(array|string|function)',
  1625. popperConfig: '(null|object|function)',
  1626. reference: '(string|element|object)'
  1627. };
  1628. /**
  1629. * Class definition
  1630. */
  1631. class Dropdown extends BaseComponent {
  1632. constructor(element, config) {
  1633. super(element, config);
  1634. this._popper = null;
  1635. this._parent = this._element.parentNode; // dropdown wrapper
  1636. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  1637. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  1638. this._inNavbar = this._detectNavbar();
  1639. }
  1640. // Getters
  1641. static get Default() {
  1642. return Default$9;
  1643. }
  1644. static get DefaultType() {
  1645. return DefaultType$9;
  1646. }
  1647. static get NAME() {
  1648. return NAME$a;
  1649. }
  1650. // Public
  1651. toggle() {
  1652. return this._isShown() ? this.hide() : this.show();
  1653. }
  1654. show() {
  1655. if (isDisabled(this._element) || this._isShown()) {
  1656. return;
  1657. }
  1658. const relatedTarget = {
  1659. relatedTarget: this._element
  1660. };
  1661. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  1662. if (showEvent.defaultPrevented) {
  1663. return;
  1664. }
  1665. this._createPopper();
  1666. // If this is a touch-enabled device we add extra
  1667. // empty mouseover listeners to the body's immediate children;
  1668. // only needed because of broken event delegation on iOS
  1669. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  1670. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  1671. for (const element of [].concat(...document.body.children)) {
  1672. EventHandler.on(element, 'mouseover', noop);
  1673. }
  1674. }
  1675. this._element.focus();
  1676. this._element.setAttribute('aria-expanded', true);
  1677. this._menu.classList.add(CLASS_NAME_SHOW$6);
  1678. this._element.classList.add(CLASS_NAME_SHOW$6);
  1679. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  1680. }
  1681. hide() {
  1682. if (isDisabled(this._element) || !this._isShown()) {
  1683. return;
  1684. }
  1685. const relatedTarget = {
  1686. relatedTarget: this._element
  1687. };
  1688. this._completeHide(relatedTarget);
  1689. }
  1690. dispose() {
  1691. if (this._popper) {
  1692. this._popper.destroy();
  1693. }
  1694. super.dispose();
  1695. }
  1696. update() {
  1697. this._inNavbar = this._detectNavbar();
  1698. if (this._popper) {
  1699. this._popper.update();
  1700. }
  1701. }
  1702. // Private
  1703. _completeHide(relatedTarget) {
  1704. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  1705. if (hideEvent.defaultPrevented) {
  1706. return;
  1707. }
  1708. // If this is a touch-enabled device we remove the extra
  1709. // empty mouseover listeners we added for iOS support
  1710. if ('ontouchstart' in document.documentElement) {
  1711. for (const element of [].concat(...document.body.children)) {
  1712. EventHandler.off(element, 'mouseover', noop);
  1713. }
  1714. }
  1715. if (this._popper) {
  1716. this._popper.destroy();
  1717. }
  1718. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  1719. this._element.classList.remove(CLASS_NAME_SHOW$6);
  1720. this._element.setAttribute('aria-expanded', 'false');
  1721. Manipulator.removeDataAttribute(this._menu, 'popper');
  1722. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  1723. }
  1724. _getConfig(config) {
  1725. config = super._getConfig(config);
  1726. if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  1727. // Popper virtual elements require a getBoundingClientRect method
  1728. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  1729. }
  1730. return config;
  1731. }
  1732. _createPopper() {
  1733. if (typeof Popper === 'undefined') {
  1734. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  1735. }
  1736. let referenceElement = this._element;
  1737. if (this._config.reference === 'parent') {
  1738. referenceElement = this._parent;
  1739. } else if (isElement(this._config.reference)) {
  1740. referenceElement = getElement(this._config.reference);
  1741. } else if (typeof this._config.reference === 'object') {
  1742. referenceElement = this._config.reference;
  1743. }
  1744. const popperConfig = this._getPopperConfig();
  1745. this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig);
  1746. }
  1747. _isShown() {
  1748. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  1749. }
  1750. _getPlacement() {
  1751. const parentDropdown = this._parent;
  1752. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  1753. return PLACEMENT_RIGHT;
  1754. }
  1755. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  1756. return PLACEMENT_LEFT;
  1757. }
  1758. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  1759. return PLACEMENT_TOPCENTER;
  1760. }
  1761. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  1762. return PLACEMENT_BOTTOMCENTER;
  1763. }
  1764. // We need to trim the value because custom properties can also include spaces
  1765. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  1766. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  1767. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  1768. }
  1769. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  1770. }
  1771. _detectNavbar() {
  1772. return this._element.closest(SELECTOR_NAVBAR) !== null;
  1773. }
  1774. _getOffset() {
  1775. const {
  1776. offset
  1777. } = this._config;
  1778. if (typeof offset === 'string') {
  1779. return offset.split(',').map(value => Number.parseInt(value, 10));
  1780. }
  1781. if (typeof offset === 'function') {
  1782. return popperData => offset(popperData, this._element);
  1783. }
  1784. return offset;
  1785. }
  1786. _getPopperConfig() {
  1787. const defaultBsPopperConfig = {
  1788. placement: this._getPlacement(),
  1789. modifiers: [{
  1790. name: 'preventOverflow',
  1791. options: {
  1792. boundary: this._config.boundary
  1793. }
  1794. }, {
  1795. name: 'offset',
  1796. options: {
  1797. offset: this._getOffset()
  1798. }
  1799. }]
  1800. };
  1801. // Disable Popper if we have a static display or Dropdown is in Navbar
  1802. if (this._inNavbar || this._config.display === 'static') {
  1803. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
  1804. defaultBsPopperConfig.modifiers = [{
  1805. name: 'applyStyles',
  1806. enabled: false
  1807. }];
  1808. }
  1809. return {
  1810. ...defaultBsPopperConfig,
  1811. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  1812. };
  1813. }
  1814. _selectMenuItem({
  1815. key,
  1816. target
  1817. }) {
  1818. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  1819. if (!items.length) {
  1820. return;
  1821. }
  1822. // if target isn't included in items (e.g. when expanding the dropdown)
  1823. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  1824. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  1825. }
  1826. // Static
  1827. static jQueryInterface(config) {
  1828. return this.each(function () {
  1829. const data = Dropdown.getOrCreateInstance(this, config);
  1830. if (typeof config !== 'string') {
  1831. return;
  1832. }
  1833. if (typeof data[config] === 'undefined') {
  1834. throw new TypeError(`No method named "${config}"`);
  1835. }
  1836. data[config]();
  1837. });
  1838. }
  1839. static clearMenus(event) {
  1840. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  1841. return;
  1842. }
  1843. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  1844. for (const toggle of openToggles) {
  1845. const context = Dropdown.getInstance(toggle);
  1846. if (!context || context._config.autoClose === false) {
  1847. continue;
  1848. }
  1849. const composedPath = event.composedPath();
  1850. const isMenuTarget = composedPath.includes(context._menu);
  1851. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  1852. continue;
  1853. }
  1854. // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  1855. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  1856. continue;
  1857. }
  1858. const relatedTarget = {
  1859. relatedTarget: context._element
  1860. };
  1861. if (event.type === 'click') {
  1862. relatedTarget.clickEvent = event;
  1863. }
  1864. context._completeHide(relatedTarget);
  1865. }
  1866. }
  1867. static dataApiKeydownHandler(event) {
  1868. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  1869. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  1870. const isInput = /input|textarea/i.test(event.target.tagName);
  1871. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  1872. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  1873. if (!isUpOrDownEvent && !isEscapeEvent) {
  1874. return;
  1875. }
  1876. if (isInput && !isEscapeEvent) {
  1877. return;
  1878. }
  1879. event.preventDefault();
  1880. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  1881. const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE$3)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode);
  1882. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  1883. if (isUpOrDownEvent) {
  1884. event.stopPropagation();
  1885. instance.show();
  1886. instance._selectMenuItem(event);
  1887. return;
  1888. }
  1889. if (instance._isShown()) {
  1890. // else is escape and we check if it is shown
  1891. event.stopPropagation();
  1892. instance.hide();
  1893. getToggleButton.focus();
  1894. }
  1895. }
  1896. }
  1897. /**
  1898. * Data API implementation
  1899. */
  1900. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  1901. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  1902. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  1903. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  1904. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  1905. event.preventDefault();
  1906. Dropdown.getOrCreateInstance(this).toggle();
  1907. });
  1908. /**
  1909. * jQuery
  1910. */
  1911. defineJQueryPlugin(Dropdown);
  1912. /**
  1913. * --------------------------------------------------------------------------
  1914. * Bootstrap util/backdrop.js
  1915. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1916. * --------------------------------------------------------------------------
  1917. */
  1918. /**
  1919. * Constants
  1920. */
  1921. const NAME$9 = 'backdrop';
  1922. const CLASS_NAME_FADE$4 = 'fade';
  1923. const CLASS_NAME_SHOW$5 = 'show';
  1924. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  1925. const Default$8 = {
  1926. className: 'modal-backdrop',
  1927. clickCallback: null,
  1928. isAnimated: false,
  1929. isVisible: true,
  1930. // if false, we use the backdrop helper without adding any element to the dom
  1931. rootElement: 'body' // give the choice to place backdrop under different elements
  1932. };
  1933. const DefaultType$8 = {
  1934. className: 'string',
  1935. clickCallback: '(function|null)',
  1936. isAnimated: 'boolean',
  1937. isVisible: 'boolean',
  1938. rootElement: '(element|string)'
  1939. };
  1940. /**
  1941. * Class definition
  1942. */
  1943. class Backdrop extends Config {
  1944. constructor(config) {
  1945. super();
  1946. this._config = this._getConfig(config);
  1947. this._isAppended = false;
  1948. this._element = null;
  1949. }
  1950. // Getters
  1951. static get Default() {
  1952. return Default$8;
  1953. }
  1954. static get DefaultType() {
  1955. return DefaultType$8;
  1956. }
  1957. static get NAME() {
  1958. return NAME$9;
  1959. }
  1960. // Public
  1961. show(callback) {
  1962. if (!this._config.isVisible) {
  1963. execute(callback);
  1964. return;
  1965. }
  1966. this._append();
  1967. const element = this._getElement();
  1968. if (this._config.isAnimated) {
  1969. reflow(element);
  1970. }
  1971. element.classList.add(CLASS_NAME_SHOW$5);
  1972. this._emulateAnimation(() => {
  1973. execute(callback);
  1974. });
  1975. }
  1976. hide(callback) {
  1977. if (!this._config.isVisible) {
  1978. execute(callback);
  1979. return;
  1980. }
  1981. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  1982. this._emulateAnimation(() => {
  1983. this.dispose();
  1984. execute(callback);
  1985. });
  1986. }
  1987. dispose() {
  1988. if (!this._isAppended) {
  1989. return;
  1990. }
  1991. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  1992. this._element.remove();
  1993. this._isAppended = false;
  1994. }
  1995. // Private
  1996. _getElement() {
  1997. if (!this._element) {
  1998. const backdrop = document.createElement('div');
  1999. backdrop.className = this._config.className;
  2000. if (this._config.isAnimated) {
  2001. backdrop.classList.add(CLASS_NAME_FADE$4);
  2002. }
  2003. this._element = backdrop;
  2004. }
  2005. return this._element;
  2006. }
  2007. _configAfterMerge(config) {
  2008. // use getElement() with the default "body" to get a fresh Element on each instantiation
  2009. config.rootElement = getElement(config.rootElement);
  2010. return config;
  2011. }
  2012. _append() {
  2013. if (this._isAppended) {
  2014. return;
  2015. }
  2016. const element = this._getElement();
  2017. this._config.rootElement.append(element);
  2018. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  2019. execute(this._config.clickCallback);
  2020. });
  2021. this._isAppended = true;
  2022. }
  2023. _emulateAnimation(callback) {
  2024. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  2025. }
  2026. }
  2027. /**
  2028. * --------------------------------------------------------------------------
  2029. * Bootstrap util/focustrap.js
  2030. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2031. * --------------------------------------------------------------------------
  2032. */
  2033. /**
  2034. * Constants
  2035. */
  2036. const NAME$8 = 'focustrap';
  2037. const DATA_KEY$5 = 'bs.focustrap';
  2038. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  2039. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  2040. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  2041. const TAB_KEY = 'Tab';
  2042. const TAB_NAV_FORWARD = 'forward';
  2043. const TAB_NAV_BACKWARD = 'backward';
  2044. const Default$7 = {
  2045. autofocus: true,
  2046. trapElement: null // The element to trap focus inside of
  2047. };
  2048. const DefaultType$7 = {
  2049. autofocus: 'boolean',
  2050. trapElement: 'element'
  2051. };
  2052. /**
  2053. * Class definition
  2054. */
  2055. class FocusTrap extends Config {
  2056. constructor(config) {
  2057. super();
  2058. this._config = this._getConfig(config);
  2059. this._isActive = false;
  2060. this._lastTabNavDirection = null;
  2061. }
  2062. // Getters
  2063. static get Default() {
  2064. return Default$7;
  2065. }
  2066. static get DefaultType() {
  2067. return DefaultType$7;
  2068. }
  2069. static get NAME() {
  2070. return NAME$8;
  2071. }
  2072. // Public
  2073. activate() {
  2074. if (this._isActive) {
  2075. return;
  2076. }
  2077. if (this._config.autofocus) {
  2078. this._config.trapElement.focus();
  2079. }
  2080. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  2081. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  2082. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  2083. this._isActive = true;
  2084. }
  2085. deactivate() {
  2086. if (!this._isActive) {
  2087. return;
  2088. }
  2089. this._isActive = false;
  2090. EventHandler.off(document, EVENT_KEY$5);
  2091. }
  2092. // Private
  2093. _handleFocusin(event) {
  2094. const {
  2095. trapElement
  2096. } = this._config;
  2097. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  2098. return;
  2099. }
  2100. const elements = SelectorEngine.focusableChildren(trapElement);
  2101. if (elements.length === 0) {
  2102. trapElement.focus();
  2103. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  2104. elements[elements.length - 1].focus();
  2105. } else {
  2106. elements[0].focus();
  2107. }
  2108. }
  2109. _handleKeydown(event) {
  2110. if (event.key !== TAB_KEY) {
  2111. return;
  2112. }
  2113. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  2114. }
  2115. }
  2116. /**
  2117. * --------------------------------------------------------------------------
  2118. * Bootstrap util/scrollBar.js
  2119. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2120. * --------------------------------------------------------------------------
  2121. */
  2122. /**
  2123. * Constants
  2124. */
  2125. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  2126. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  2127. const PROPERTY_PADDING = 'padding-right';
  2128. const PROPERTY_MARGIN = 'margin-right';
  2129. /**
  2130. * Class definition
  2131. */
  2132. class ScrollBarHelper {
  2133. constructor() {
  2134. this._element = document.body;
  2135. }
  2136. // Public
  2137. getWidth() {
  2138. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  2139. const documentWidth = document.documentElement.clientWidth;
  2140. return Math.abs(window.innerWidth - documentWidth);
  2141. }
  2142. hide() {
  2143. const width = this.getWidth();
  2144. this._disableOverFlow();
  2145. // give padding to element to balance the hidden scrollbar width
  2146. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  2147. // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  2148. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  2149. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  2150. }
  2151. reset() {
  2152. this._resetElementAttributes(this._element, 'overflow');
  2153. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  2154. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  2155. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  2156. }
  2157. isOverflowing() {
  2158. return this.getWidth() > 0;
  2159. }
  2160. // Private
  2161. _disableOverFlow() {
  2162. this._saveInitialAttribute(this._element, 'overflow');
  2163. this._element.style.overflow = 'hidden';
  2164. }
  2165. _setElementAttributes(selector, styleProperty, callback) {
  2166. const scrollbarWidth = this.getWidth();
  2167. const manipulationCallBack = element => {
  2168. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  2169. return;
  2170. }
  2171. this._saveInitialAttribute(element, styleProperty);
  2172. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  2173. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  2174. };
  2175. this._applyManipulationCallback(selector, manipulationCallBack);
  2176. }
  2177. _saveInitialAttribute(element, styleProperty) {
  2178. const actualValue = element.style.getPropertyValue(styleProperty);
  2179. if (actualValue) {
  2180. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  2181. }
  2182. }
  2183. _resetElementAttributes(selector, styleProperty) {
  2184. const manipulationCallBack = element => {
  2185. const value = Manipulator.getDataAttribute(element, styleProperty);
  2186. // We only want to remove the property if the value is `null`; the value can also be zero
  2187. if (value === null) {
  2188. element.style.removeProperty(styleProperty);
  2189. return;
  2190. }
  2191. Manipulator.removeDataAttribute(element, styleProperty);
  2192. element.style.setProperty(styleProperty, value);
  2193. };
  2194. this._applyManipulationCallback(selector, manipulationCallBack);
  2195. }
  2196. _applyManipulationCallback(selector, callBack) {
  2197. if (isElement(selector)) {
  2198. callBack(selector);
  2199. return;
  2200. }
  2201. for (const sel of SelectorEngine.find(selector, this._element)) {
  2202. callBack(sel);
  2203. }
  2204. }
  2205. }
  2206. /**
  2207. * --------------------------------------------------------------------------
  2208. * Bootstrap modal.js
  2209. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2210. * --------------------------------------------------------------------------
  2211. */
  2212. /**
  2213. * Constants
  2214. */
  2215. const NAME$7 = 'modal';
  2216. const DATA_KEY$4 = 'bs.modal';
  2217. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  2218. const DATA_API_KEY$2 = '.data-api';
  2219. const ESCAPE_KEY$1 = 'Escape';
  2220. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  2221. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  2222. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  2223. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  2224. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  2225. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  2226. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  2227. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  2228. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  2229. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  2230. const CLASS_NAME_OPEN = 'modal-open';
  2231. const CLASS_NAME_FADE$3 = 'fade';
  2232. const CLASS_NAME_SHOW$4 = 'show';
  2233. const CLASS_NAME_STATIC = 'modal-static';
  2234. const OPEN_SELECTOR$1 = '.modal.show';
  2235. const SELECTOR_DIALOG = '.modal-dialog';
  2236. const SELECTOR_MODAL_BODY = '.modal-body';
  2237. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  2238. const Default$6 = {
  2239. backdrop: true,
  2240. focus: true,
  2241. keyboard: true
  2242. };
  2243. const DefaultType$6 = {
  2244. backdrop: '(boolean|string)',
  2245. focus: 'boolean',
  2246. keyboard: 'boolean'
  2247. };
  2248. /**
  2249. * Class definition
  2250. */
  2251. class Modal extends BaseComponent {
  2252. constructor(element, config) {
  2253. super(element, config);
  2254. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  2255. this._backdrop = this._initializeBackDrop();
  2256. this._focustrap = this._initializeFocusTrap();
  2257. this._isShown = false;
  2258. this._isTransitioning = false;
  2259. this._scrollBar = new ScrollBarHelper();
  2260. this._addEventListeners();
  2261. }
  2262. // Getters
  2263. static get Default() {
  2264. return Default$6;
  2265. }
  2266. static get DefaultType() {
  2267. return DefaultType$6;
  2268. }
  2269. static get NAME() {
  2270. return NAME$7;
  2271. }
  2272. // Public
  2273. toggle(relatedTarget) {
  2274. return this._isShown ? this.hide() : this.show(relatedTarget);
  2275. }
  2276. show(relatedTarget) {
  2277. if (this._isShown || this._isTransitioning) {
  2278. return;
  2279. }
  2280. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  2281. relatedTarget
  2282. });
  2283. if (showEvent.defaultPrevented) {
  2284. return;
  2285. }
  2286. this._isShown = true;
  2287. this._isTransitioning = true;
  2288. this._scrollBar.hide();
  2289. document.body.classList.add(CLASS_NAME_OPEN);
  2290. this._adjustDialog();
  2291. this._backdrop.show(() => this._showElement(relatedTarget));
  2292. }
  2293. hide() {
  2294. if (!this._isShown || this._isTransitioning) {
  2295. return;
  2296. }
  2297. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  2298. if (hideEvent.defaultPrevented) {
  2299. return;
  2300. }
  2301. this._isShown = false;
  2302. this._isTransitioning = true;
  2303. this._focustrap.deactivate();
  2304. this._element.classList.remove(CLASS_NAME_SHOW$4);
  2305. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  2306. }
  2307. dispose() {
  2308. EventHandler.off(window, EVENT_KEY$4);
  2309. EventHandler.off(this._dialog, EVENT_KEY$4);
  2310. this._backdrop.dispose();
  2311. this._focustrap.deactivate();
  2312. super.dispose();
  2313. }
  2314. handleUpdate() {
  2315. this._adjustDialog();
  2316. }
  2317. // Private
  2318. _initializeBackDrop() {
  2319. return new Backdrop({
  2320. isVisible: Boolean(this._config.backdrop),
  2321. // 'static' option will be translated to true, and booleans will keep their value,
  2322. isAnimated: this._isAnimated()
  2323. });
  2324. }
  2325. _initializeFocusTrap() {
  2326. return new FocusTrap({
  2327. trapElement: this._element
  2328. });
  2329. }
  2330. _showElement(relatedTarget) {
  2331. // try to append dynamic modal
  2332. if (!document.body.contains(this._element)) {
  2333. document.body.append(this._element);
  2334. }
  2335. this._element.style.display = 'block';
  2336. this._element.removeAttribute('aria-hidden');
  2337. this._element.setAttribute('aria-modal', true);
  2338. this._element.setAttribute('role', 'dialog');
  2339. this._element.scrollTop = 0;
  2340. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  2341. if (modalBody) {
  2342. modalBody.scrollTop = 0;
  2343. }
  2344. reflow(this._element);
  2345. this._element.classList.add(CLASS_NAME_SHOW$4);
  2346. const transitionComplete = () => {
  2347. if (this._config.focus) {
  2348. this._focustrap.activate();
  2349. }
  2350. this._isTransitioning = false;
  2351. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  2352. relatedTarget
  2353. });
  2354. };
  2355. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  2356. }
  2357. _addEventListeners() {
  2358. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  2359. if (event.key !== ESCAPE_KEY$1) {
  2360. return;
  2361. }
  2362. if (this._config.keyboard) {
  2363. this.hide();
  2364. return;
  2365. }
  2366. this._triggerBackdropTransition();
  2367. });
  2368. EventHandler.on(window, EVENT_RESIZE$1, () => {
  2369. if (this._isShown && !this._isTransitioning) {
  2370. this._adjustDialog();
  2371. }
  2372. });
  2373. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  2374. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  2375. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  2376. if (this._element !== event.target || this._element !== event2.target) {
  2377. return;
  2378. }
  2379. if (this._config.backdrop === 'static') {
  2380. this._triggerBackdropTransition();
  2381. return;
  2382. }
  2383. if (this._config.backdrop) {
  2384. this.hide();
  2385. }
  2386. });
  2387. });
  2388. }
  2389. _hideModal() {
  2390. this._element.style.display = 'none';
  2391. this._element.setAttribute('aria-hidden', true);
  2392. this._element.removeAttribute('aria-modal');
  2393. this._element.removeAttribute('role');
  2394. this._isTransitioning = false;
  2395. this._backdrop.hide(() => {
  2396. document.body.classList.remove(CLASS_NAME_OPEN);
  2397. this._resetAdjustments();
  2398. this._scrollBar.reset();
  2399. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  2400. });
  2401. }
  2402. _isAnimated() {
  2403. return this._element.classList.contains(CLASS_NAME_FADE$3);
  2404. }
  2405. _triggerBackdropTransition() {
  2406. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  2407. if (hideEvent.defaultPrevented) {
  2408. return;
  2409. }
  2410. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  2411. const initialOverflowY = this._element.style.overflowY;
  2412. // return if the following background transition hasn't yet completed
  2413. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  2414. return;
  2415. }
  2416. if (!isModalOverflowing) {
  2417. this._element.style.overflowY = 'hidden';
  2418. }
  2419. this._element.classList.add(CLASS_NAME_STATIC);
  2420. this._queueCallback(() => {
  2421. this._element.classList.remove(CLASS_NAME_STATIC);
  2422. this._queueCallback(() => {
  2423. this._element.style.overflowY = initialOverflowY;
  2424. }, this._dialog);
  2425. }, this._dialog);
  2426. this._element.focus();
  2427. }
  2428. /**
  2429. * The following methods are used to handle overflowing modals
  2430. */
  2431. _adjustDialog() {
  2432. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  2433. const scrollbarWidth = this._scrollBar.getWidth();
  2434. const isBodyOverflowing = scrollbarWidth > 0;
  2435. if (isBodyOverflowing && !isModalOverflowing) {
  2436. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  2437. this._element.style[property] = `${scrollbarWidth}px`;
  2438. }
  2439. if (!isBodyOverflowing && isModalOverflowing) {
  2440. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  2441. this._element.style[property] = `${scrollbarWidth}px`;
  2442. }
  2443. }
  2444. _resetAdjustments() {
  2445. this._element.style.paddingLeft = '';
  2446. this._element.style.paddingRight = '';
  2447. }
  2448. // Static
  2449. static jQueryInterface(config, relatedTarget) {
  2450. return this.each(function () {
  2451. const data = Modal.getOrCreateInstance(this, config);
  2452. if (typeof config !== 'string') {
  2453. return;
  2454. }
  2455. if (typeof data[config] === 'undefined') {
  2456. throw new TypeError(`No method named "${config}"`);
  2457. }
  2458. data[config](relatedTarget);
  2459. });
  2460. }
  2461. }
  2462. /**
  2463. * Data API implementation
  2464. */
  2465. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  2466. const target = SelectorEngine.getElementFromSelector(this);
  2467. if (['A', 'AREA'].includes(this.tagName)) {
  2468. event.preventDefault();
  2469. }
  2470. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  2471. if (showEvent.defaultPrevented) {
  2472. // only register focus restorer if modal will actually get shown
  2473. return;
  2474. }
  2475. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  2476. if (isVisible(this)) {
  2477. this.focus();
  2478. }
  2479. });
  2480. });
  2481. // avoid conflict when clicking modal toggler while another one is open
  2482. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  2483. if (alreadyOpen) {
  2484. Modal.getInstance(alreadyOpen).hide();
  2485. }
  2486. const data = Modal.getOrCreateInstance(target);
  2487. data.toggle(this);
  2488. });
  2489. enableDismissTrigger(Modal);
  2490. /**
  2491. * jQuery
  2492. */
  2493. defineJQueryPlugin(Modal);
  2494. /**
  2495. * --------------------------------------------------------------------------
  2496. * Bootstrap offcanvas.js
  2497. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2498. * --------------------------------------------------------------------------
  2499. */
  2500. /**
  2501. * Constants
  2502. */
  2503. const NAME$6 = 'offcanvas';
  2504. const DATA_KEY$3 = 'bs.offcanvas';
  2505. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  2506. const DATA_API_KEY$1 = '.data-api';
  2507. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  2508. const ESCAPE_KEY = 'Escape';
  2509. const CLASS_NAME_SHOW$3 = 'show';
  2510. const CLASS_NAME_SHOWING$1 = 'showing';
  2511. const CLASS_NAME_HIDING = 'hiding';
  2512. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  2513. const OPEN_SELECTOR = '.offcanvas.show';
  2514. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  2515. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  2516. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  2517. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  2518. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  2519. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  2520. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  2521. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  2522. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  2523. const Default$5 = {
  2524. backdrop: true,
  2525. keyboard: true,
  2526. scroll: false
  2527. };
  2528. const DefaultType$5 = {
  2529. backdrop: '(boolean|string)',
  2530. keyboard: 'boolean',
  2531. scroll: 'boolean'
  2532. };
  2533. /**
  2534. * Class definition
  2535. */
  2536. class Offcanvas extends BaseComponent {
  2537. constructor(element, config) {
  2538. super(element, config);
  2539. this._isShown = false;
  2540. this._backdrop = this._initializeBackDrop();
  2541. this._focustrap = this._initializeFocusTrap();
  2542. this._addEventListeners();
  2543. }
  2544. // Getters
  2545. static get Default() {
  2546. return Default$5;
  2547. }
  2548. static get DefaultType() {
  2549. return DefaultType$5;
  2550. }
  2551. static get NAME() {
  2552. return NAME$6;
  2553. }
  2554. // Public
  2555. toggle(relatedTarget) {
  2556. return this._isShown ? this.hide() : this.show(relatedTarget);
  2557. }
  2558. show(relatedTarget) {
  2559. if (this._isShown) {
  2560. return;
  2561. }
  2562. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  2563. relatedTarget
  2564. });
  2565. if (showEvent.defaultPrevented) {
  2566. return;
  2567. }
  2568. this._isShown = true;
  2569. this._backdrop.show();
  2570. if (!this._config.scroll) {
  2571. new ScrollBarHelper().hide();
  2572. }
  2573. this._element.setAttribute('aria-modal', true);
  2574. this._element.setAttribute('role', 'dialog');
  2575. this._element.classList.add(CLASS_NAME_SHOWING$1);
  2576. const completeCallBack = () => {
  2577. if (!this._config.scroll || this._config.backdrop) {
  2578. this._focustrap.activate();
  2579. }
  2580. this._element.classList.add(CLASS_NAME_SHOW$3);
  2581. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  2582. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  2583. relatedTarget
  2584. });
  2585. };
  2586. this._queueCallback(completeCallBack, this._element, true);
  2587. }
  2588. hide() {
  2589. if (!this._isShown) {
  2590. return;
  2591. }
  2592. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  2593. if (hideEvent.defaultPrevented) {
  2594. return;
  2595. }
  2596. this._focustrap.deactivate();
  2597. this._element.blur();
  2598. this._isShown = false;
  2599. this._element.classList.add(CLASS_NAME_HIDING);
  2600. this._backdrop.hide();
  2601. const completeCallback = () => {
  2602. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  2603. this._element.removeAttribute('aria-modal');
  2604. this._element.removeAttribute('role');
  2605. if (!this._config.scroll) {
  2606. new ScrollBarHelper().reset();
  2607. }
  2608. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  2609. };
  2610. this._queueCallback(completeCallback, this._element, true);
  2611. }
  2612. dispose() {
  2613. this._backdrop.dispose();
  2614. this._focustrap.deactivate();
  2615. super.dispose();
  2616. }
  2617. // Private
  2618. _initializeBackDrop() {
  2619. const clickCallback = () => {
  2620. if (this._config.backdrop === 'static') {
  2621. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  2622. return;
  2623. }
  2624. this.hide();
  2625. };
  2626. // 'static' option will be translated to true, and booleans will keep their value
  2627. const isVisible = Boolean(this._config.backdrop);
  2628. return new Backdrop({
  2629. className: CLASS_NAME_BACKDROP,
  2630. isVisible,
  2631. isAnimated: true,
  2632. rootElement: this._element.parentNode,
  2633. clickCallback: isVisible ? clickCallback : null
  2634. });
  2635. }
  2636. _initializeFocusTrap() {
  2637. return new FocusTrap({
  2638. trapElement: this._element
  2639. });
  2640. }
  2641. _addEventListeners() {
  2642. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  2643. if (event.key !== ESCAPE_KEY) {
  2644. return;
  2645. }
  2646. if (this._config.keyboard) {
  2647. this.hide();
  2648. return;
  2649. }
  2650. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  2651. });
  2652. }
  2653. // Static
  2654. static jQueryInterface(config) {
  2655. return this.each(function () {
  2656. const data = Offcanvas.getOrCreateInstance(this, config);
  2657. if (typeof config !== 'string') {
  2658. return;
  2659. }
  2660. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  2661. throw new TypeError(`No method named "${config}"`);
  2662. }
  2663. data[config](this);
  2664. });
  2665. }
  2666. }
  2667. /**
  2668. * Data API implementation
  2669. */
  2670. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  2671. const target = SelectorEngine.getElementFromSelector(this);
  2672. if (['A', 'AREA'].includes(this.tagName)) {
  2673. event.preventDefault();
  2674. }
  2675. if (isDisabled(this)) {
  2676. return;
  2677. }
  2678. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  2679. // focus on trigger when it is closed
  2680. if (isVisible(this)) {
  2681. this.focus();
  2682. }
  2683. });
  2684. // avoid conflict when clicking a toggler of an offcanvas, while another is open
  2685. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  2686. if (alreadyOpen && alreadyOpen !== target) {
  2687. Offcanvas.getInstance(alreadyOpen).hide();
  2688. }
  2689. const data = Offcanvas.getOrCreateInstance(target);
  2690. data.toggle(this);
  2691. });
  2692. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  2693. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  2694. Offcanvas.getOrCreateInstance(selector).show();
  2695. }
  2696. });
  2697. EventHandler.on(window, EVENT_RESIZE, () => {
  2698. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  2699. if (getComputedStyle(element).position !== 'fixed') {
  2700. Offcanvas.getOrCreateInstance(element).hide();
  2701. }
  2702. }
  2703. });
  2704. enableDismissTrigger(Offcanvas);
  2705. /**
  2706. * jQuery
  2707. */
  2708. defineJQueryPlugin(Offcanvas);
  2709. /**
  2710. * --------------------------------------------------------------------------
  2711. * Bootstrap util/sanitizer.js
  2712. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2713. * --------------------------------------------------------------------------
  2714. */
  2715. // js-docs-start allow-list
  2716. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  2717. const DefaultAllowlist = {
  2718. // Global attributes allowed on any supplied element below.
  2719. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  2720. a: ['target', 'href', 'title', 'rel'],
  2721. area: [],
  2722. b: [],
  2723. br: [],
  2724. col: [],
  2725. code: [],
  2726. dd: [],
  2727. div: [],
  2728. dl: [],
  2729. dt: [],
  2730. em: [],
  2731. hr: [],
  2732. h1: [],
  2733. h2: [],
  2734. h3: [],
  2735. h4: [],
  2736. h5: [],
  2737. h6: [],
  2738. i: [],
  2739. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  2740. li: [],
  2741. ol: [],
  2742. p: [],
  2743. pre: [],
  2744. s: [],
  2745. small: [],
  2746. span: [],
  2747. sub: [],
  2748. sup: [],
  2749. strong: [],
  2750. u: [],
  2751. ul: []
  2752. };
  2753. // js-docs-end allow-list
  2754. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  2755. /**
  2756. * A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
  2757. * contexts.
  2758. *
  2759. * Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
  2760. */
  2761. // eslint-disable-next-line unicorn/better-regex
  2762. const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
  2763. const allowedAttribute = (attribute, allowedAttributeList) => {
  2764. const attributeName = attribute.nodeName.toLowerCase();
  2765. if (allowedAttributeList.includes(attributeName)) {
  2766. if (uriAttributes.has(attributeName)) {
  2767. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue));
  2768. }
  2769. return true;
  2770. }
  2771. // Check if a regular expression validates the attribute.
  2772. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  2773. };
  2774. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  2775. if (!unsafeHtml.length) {
  2776. return unsafeHtml;
  2777. }
  2778. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  2779. return sanitizeFunction(unsafeHtml);
  2780. }
  2781. const domParser = new window.DOMParser();
  2782. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  2783. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  2784. for (const element of elements) {
  2785. const elementName = element.nodeName.toLowerCase();
  2786. if (!Object.keys(allowList).includes(elementName)) {
  2787. element.remove();
  2788. continue;
  2789. }
  2790. const attributeList = [].concat(...element.attributes);
  2791. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  2792. for (const attribute of attributeList) {
  2793. if (!allowedAttribute(attribute, allowedAttributes)) {
  2794. element.removeAttribute(attribute.nodeName);
  2795. }
  2796. }
  2797. }
  2798. return createdDocument.body.innerHTML;
  2799. }
  2800. /**
  2801. * --------------------------------------------------------------------------
  2802. * Bootstrap util/template-factory.js
  2803. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2804. * --------------------------------------------------------------------------
  2805. */
  2806. /**
  2807. * Constants
  2808. */
  2809. const NAME$5 = 'TemplateFactory';
  2810. const Default$4 = {
  2811. allowList: DefaultAllowlist,
  2812. content: {},
  2813. // { selector : text , selector2 : text2 , }
  2814. extraClass: '',
  2815. html: false,
  2816. sanitize: true,
  2817. sanitizeFn: null,
  2818. template: '<div></div>'
  2819. };
  2820. const DefaultType$4 = {
  2821. allowList: 'object',
  2822. content: 'object',
  2823. extraClass: '(string|function)',
  2824. html: 'boolean',
  2825. sanitize: 'boolean',
  2826. sanitizeFn: '(null|function)',
  2827. template: 'string'
  2828. };
  2829. const DefaultContentType = {
  2830. entry: '(string|element|function|null)',
  2831. selector: '(string|element)'
  2832. };
  2833. /**
  2834. * Class definition
  2835. */
  2836. class TemplateFactory extends Config {
  2837. constructor(config) {
  2838. super();
  2839. this._config = this._getConfig(config);
  2840. }
  2841. // Getters
  2842. static get Default() {
  2843. return Default$4;
  2844. }
  2845. static get DefaultType() {
  2846. return DefaultType$4;
  2847. }
  2848. static get NAME() {
  2849. return NAME$5;
  2850. }
  2851. // Public
  2852. getContent() {
  2853. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  2854. }
  2855. hasContent() {
  2856. return this.getContent().length > 0;
  2857. }
  2858. changeContent(content) {
  2859. this._checkContent(content);
  2860. this._config.content = {
  2861. ...this._config.content,
  2862. ...content
  2863. };
  2864. return this;
  2865. }
  2866. toHtml() {
  2867. const templateWrapper = document.createElement('div');
  2868. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  2869. for (const [selector, text] of Object.entries(this._config.content)) {
  2870. this._setContent(templateWrapper, text, selector);
  2871. }
  2872. const template = templateWrapper.children[0];
  2873. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  2874. if (extraClass) {
  2875. template.classList.add(...extraClass.split(' '));
  2876. }
  2877. return template;
  2878. }
  2879. // Private
  2880. _typeCheckConfig(config) {
  2881. super._typeCheckConfig(config);
  2882. this._checkContent(config.content);
  2883. }
  2884. _checkContent(arg) {
  2885. for (const [selector, content] of Object.entries(arg)) {
  2886. super._typeCheckConfig({
  2887. selector,
  2888. entry: content
  2889. }, DefaultContentType);
  2890. }
  2891. }
  2892. _setContent(template, content, selector) {
  2893. const templateElement = SelectorEngine.findOne(selector, template);
  2894. if (!templateElement) {
  2895. return;
  2896. }
  2897. content = this._resolvePossibleFunction(content);
  2898. if (!content) {
  2899. templateElement.remove();
  2900. return;
  2901. }
  2902. if (isElement(content)) {
  2903. this._putElementInTemplate(getElement(content), templateElement);
  2904. return;
  2905. }
  2906. if (this._config.html) {
  2907. templateElement.innerHTML = this._maybeSanitize(content);
  2908. return;
  2909. }
  2910. templateElement.textContent = content;
  2911. }
  2912. _maybeSanitize(arg) {
  2913. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  2914. }
  2915. _resolvePossibleFunction(arg) {
  2916. return execute(arg, [this]);
  2917. }
  2918. _putElementInTemplate(element, templateElement) {
  2919. if (this._config.html) {
  2920. templateElement.innerHTML = '';
  2921. templateElement.append(element);
  2922. return;
  2923. }
  2924. templateElement.textContent = element.textContent;
  2925. }
  2926. }
  2927. /**
  2928. * --------------------------------------------------------------------------
  2929. * Bootstrap tooltip.js
  2930. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  2931. * --------------------------------------------------------------------------
  2932. */
  2933. /**
  2934. * Constants
  2935. */
  2936. const NAME$4 = 'tooltip';
  2937. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  2938. const CLASS_NAME_FADE$2 = 'fade';
  2939. const CLASS_NAME_MODAL = 'modal';
  2940. const CLASS_NAME_SHOW$2 = 'show';
  2941. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  2942. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  2943. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  2944. const TRIGGER_HOVER = 'hover';
  2945. const TRIGGER_FOCUS = 'focus';
  2946. const TRIGGER_CLICK = 'click';
  2947. const TRIGGER_MANUAL = 'manual';
  2948. const EVENT_HIDE$2 = 'hide';
  2949. const EVENT_HIDDEN$2 = 'hidden';
  2950. const EVENT_SHOW$2 = 'show';
  2951. const EVENT_SHOWN$2 = 'shown';
  2952. const EVENT_INSERTED = 'inserted';
  2953. const EVENT_CLICK$1 = 'click';
  2954. const EVENT_FOCUSIN$1 = 'focusin';
  2955. const EVENT_FOCUSOUT$1 = 'focusout';
  2956. const EVENT_MOUSEENTER = 'mouseenter';
  2957. const EVENT_MOUSELEAVE = 'mouseleave';
  2958. const AttachmentMap = {
  2959. AUTO: 'auto',
  2960. TOP: 'top',
  2961. RIGHT: isRTL() ? 'left' : 'right',
  2962. BOTTOM: 'bottom',
  2963. LEFT: isRTL() ? 'right' : 'left'
  2964. };
  2965. const Default$3 = {
  2966. allowList: DefaultAllowlist,
  2967. animation: true,
  2968. boundary: 'clippingParents',
  2969. container: false,
  2970. customClass: '',
  2971. delay: 0,
  2972. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  2973. html: false,
  2974. offset: [0, 6],
  2975. placement: 'top',
  2976. popperConfig: null,
  2977. sanitize: true,
  2978. sanitizeFn: null,
  2979. selector: false,
  2980. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  2981. title: '',
  2982. trigger: 'hover focus'
  2983. };
  2984. const DefaultType$3 = {
  2985. allowList: 'object',
  2986. animation: 'boolean',
  2987. boundary: '(string|element)',
  2988. container: '(string|element|boolean)',
  2989. customClass: '(string|function)',
  2990. delay: '(number|object)',
  2991. fallbackPlacements: 'array',
  2992. html: 'boolean',
  2993. offset: '(array|string|function)',
  2994. placement: '(string|function)',
  2995. popperConfig: '(null|object|function)',
  2996. sanitize: 'boolean',
  2997. sanitizeFn: '(null|function)',
  2998. selector: '(string|boolean)',
  2999. template: 'string',
  3000. title: '(string|element|function)',
  3001. trigger: 'string'
  3002. };
  3003. /**
  3004. * Class definition
  3005. */
  3006. class Tooltip extends BaseComponent {
  3007. constructor(element, config) {
  3008. if (typeof Popper === 'undefined') {
  3009. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  3010. }
  3011. super(element, config);
  3012. // Private
  3013. this._isEnabled = true;
  3014. this._timeout = 0;
  3015. this._isHovered = null;
  3016. this._activeTrigger = {};
  3017. this._popper = null;
  3018. this._templateFactory = null;
  3019. this._newContent = null;
  3020. // Protected
  3021. this.tip = null;
  3022. this._setListeners();
  3023. if (!this._config.selector) {
  3024. this._fixTitle();
  3025. }
  3026. }
  3027. // Getters
  3028. static get Default() {
  3029. return Default$3;
  3030. }
  3031. static get DefaultType() {
  3032. return DefaultType$3;
  3033. }
  3034. static get NAME() {
  3035. return NAME$4;
  3036. }
  3037. // Public
  3038. enable() {
  3039. this._isEnabled = true;
  3040. }
  3041. disable() {
  3042. this._isEnabled = false;
  3043. }
  3044. toggleEnabled() {
  3045. this._isEnabled = !this._isEnabled;
  3046. }
  3047. toggle() {
  3048. if (!this._isEnabled) {
  3049. return;
  3050. }
  3051. this._activeTrigger.click = !this._activeTrigger.click;
  3052. if (this._isShown()) {
  3053. this._leave();
  3054. return;
  3055. }
  3056. this._enter();
  3057. }
  3058. dispose() {
  3059. clearTimeout(this._timeout);
  3060. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  3061. if (this._element.getAttribute('data-bs-original-title')) {
  3062. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  3063. }
  3064. this._disposePopper();
  3065. super.dispose();
  3066. }
  3067. show() {
  3068. if (this._element.style.display === 'none') {
  3069. throw new Error('Please use show on visible elements');
  3070. }
  3071. if (!(this._isWithContent() && this._isEnabled)) {
  3072. return;
  3073. }
  3074. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  3075. const shadowRoot = findShadowRoot(this._element);
  3076. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  3077. if (showEvent.defaultPrevented || !isInTheDom) {
  3078. return;
  3079. }
  3080. // TODO: v6 remove this or make it optional
  3081. this._disposePopper();
  3082. const tip = this._getTipElement();
  3083. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  3084. const {
  3085. container
  3086. } = this._config;
  3087. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  3088. container.append(tip);
  3089. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  3090. }
  3091. this._popper = this._createPopper(tip);
  3092. tip.classList.add(CLASS_NAME_SHOW$2);
  3093. // If this is a touch-enabled device we add extra
  3094. // empty mouseover listeners to the body's immediate children;
  3095. // only needed because of broken event delegation on iOS
  3096. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3097. if ('ontouchstart' in document.documentElement) {
  3098. for (const element of [].concat(...document.body.children)) {
  3099. EventHandler.on(element, 'mouseover', noop);
  3100. }
  3101. }
  3102. const complete = () => {
  3103. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  3104. if (this._isHovered === false) {
  3105. this._leave();
  3106. }
  3107. this._isHovered = false;
  3108. };
  3109. this._queueCallback(complete, this.tip, this._isAnimated());
  3110. }
  3111. hide() {
  3112. if (!this._isShown()) {
  3113. return;
  3114. }
  3115. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  3116. if (hideEvent.defaultPrevented) {
  3117. return;
  3118. }
  3119. const tip = this._getTipElement();
  3120. tip.classList.remove(CLASS_NAME_SHOW$2);
  3121. // If this is a touch-enabled device we remove the extra
  3122. // empty mouseover listeners we added for iOS support
  3123. if ('ontouchstart' in document.documentElement) {
  3124. for (const element of [].concat(...document.body.children)) {
  3125. EventHandler.off(element, 'mouseover', noop);
  3126. }
  3127. }
  3128. this._activeTrigger[TRIGGER_CLICK] = false;
  3129. this._activeTrigger[TRIGGER_FOCUS] = false;
  3130. this._activeTrigger[TRIGGER_HOVER] = false;
  3131. this._isHovered = null; // it is a trick to support manual triggering
  3132. const complete = () => {
  3133. if (this._isWithActiveTrigger()) {
  3134. return;
  3135. }
  3136. if (!this._isHovered) {
  3137. this._disposePopper();
  3138. }
  3139. this._element.removeAttribute('aria-describedby');
  3140. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  3141. };
  3142. this._queueCallback(complete, this.tip, this._isAnimated());
  3143. }
  3144. update() {
  3145. if (this._popper) {
  3146. this._popper.update();
  3147. }
  3148. }
  3149. // Protected
  3150. _isWithContent() {
  3151. return Boolean(this._getTitle());
  3152. }
  3153. _getTipElement() {
  3154. if (!this.tip) {
  3155. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  3156. }
  3157. return this.tip;
  3158. }
  3159. _createTipElement(content) {
  3160. const tip = this._getTemplateFactory(content).toHtml();
  3161. // TODO: remove this check in v6
  3162. if (!tip) {
  3163. return null;
  3164. }
  3165. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  3166. // TODO: v6 the following can be achieved with CSS only
  3167. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  3168. const tipId = getUID(this.constructor.NAME).toString();
  3169. tip.setAttribute('id', tipId);
  3170. if (this._isAnimated()) {
  3171. tip.classList.add(CLASS_NAME_FADE$2);
  3172. }
  3173. return tip;
  3174. }
  3175. setContent(content) {
  3176. this._newContent = content;
  3177. if (this._isShown()) {
  3178. this._disposePopper();
  3179. this.show();
  3180. }
  3181. }
  3182. _getTemplateFactory(content) {
  3183. if (this._templateFactory) {
  3184. this._templateFactory.changeContent(content);
  3185. } else {
  3186. this._templateFactory = new TemplateFactory({
  3187. ...this._config,
  3188. // the `content` var has to be after `this._config`
  3189. // to override config.content in case of popover
  3190. content,
  3191. extraClass: this._resolvePossibleFunction(this._config.customClass)
  3192. });
  3193. }
  3194. return this._templateFactory;
  3195. }
  3196. _getContentForTemplate() {
  3197. return {
  3198. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  3199. };
  3200. }
  3201. _getTitle() {
  3202. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  3203. }
  3204. // Private
  3205. _initializeOnDelegatedTarget(event) {
  3206. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  3207. }
  3208. _isAnimated() {
  3209. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  3210. }
  3211. _isShown() {
  3212. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  3213. }
  3214. _createPopper(tip) {
  3215. const placement = execute(this._config.placement, [this, tip, this._element]);
  3216. const attachment = AttachmentMap[placement.toUpperCase()];
  3217. return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
  3218. }
  3219. _getOffset() {
  3220. const {
  3221. offset
  3222. } = this._config;
  3223. if (typeof offset === 'string') {
  3224. return offset.split(',').map(value => Number.parseInt(value, 10));
  3225. }
  3226. if (typeof offset === 'function') {
  3227. return popperData => offset(popperData, this._element);
  3228. }
  3229. return offset;
  3230. }
  3231. _resolvePossibleFunction(arg) {
  3232. return execute(arg, [this._element]);
  3233. }
  3234. _getPopperConfig(attachment) {
  3235. const defaultBsPopperConfig = {
  3236. placement: attachment,
  3237. modifiers: [{
  3238. name: 'flip',
  3239. options: {
  3240. fallbackPlacements: this._config.fallbackPlacements
  3241. }
  3242. }, {
  3243. name: 'offset',
  3244. options: {
  3245. offset: this._getOffset()
  3246. }
  3247. }, {
  3248. name: 'preventOverflow',
  3249. options: {
  3250. boundary: this._config.boundary
  3251. }
  3252. }, {
  3253. name: 'arrow',
  3254. options: {
  3255. element: `.${this.constructor.NAME}-arrow`
  3256. }
  3257. }, {
  3258. name: 'preSetPlacement',
  3259. enabled: true,
  3260. phase: 'beforeMain',
  3261. fn: data => {
  3262. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  3263. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  3264. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  3265. }
  3266. }]
  3267. };
  3268. return {
  3269. ...defaultBsPopperConfig,
  3270. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  3271. };
  3272. }
  3273. _setListeners() {
  3274. const triggers = this._config.trigger.split(' ');
  3275. for (const trigger of triggers) {
  3276. if (trigger === 'click') {
  3277. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  3278. const context = this._initializeOnDelegatedTarget(event);
  3279. context.toggle();
  3280. });
  3281. } else if (trigger !== TRIGGER_MANUAL) {
  3282. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  3283. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  3284. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  3285. const context = this._initializeOnDelegatedTarget(event);
  3286. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  3287. context._enter();
  3288. });
  3289. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  3290. const context = this._initializeOnDelegatedTarget(event);
  3291. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  3292. context._leave();
  3293. });
  3294. }
  3295. }
  3296. this._hideModalHandler = () => {
  3297. if (this._element) {
  3298. this.hide();
  3299. }
  3300. };
  3301. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  3302. }
  3303. _fixTitle() {
  3304. const title = this._element.getAttribute('title');
  3305. if (!title) {
  3306. return;
  3307. }
  3308. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  3309. this._element.setAttribute('aria-label', title);
  3310. }
  3311. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  3312. this._element.removeAttribute('title');
  3313. }
  3314. _enter() {
  3315. if (this._isShown() || this._isHovered) {
  3316. this._isHovered = true;
  3317. return;
  3318. }
  3319. this._isHovered = true;
  3320. this._setTimeout(() => {
  3321. if (this._isHovered) {
  3322. this.show();
  3323. }
  3324. }, this._config.delay.show);
  3325. }
  3326. _leave() {
  3327. if (this._isWithActiveTrigger()) {
  3328. return;
  3329. }
  3330. this._isHovered = false;
  3331. this._setTimeout(() => {
  3332. if (!this._isHovered) {
  3333. this.hide();
  3334. }
  3335. }, this._config.delay.hide);
  3336. }
  3337. _setTimeout(handler, timeout) {
  3338. clearTimeout(this._timeout);
  3339. this._timeout = setTimeout(handler, timeout);
  3340. }
  3341. _isWithActiveTrigger() {
  3342. return Object.values(this._activeTrigger).includes(true);
  3343. }
  3344. _getConfig(config) {
  3345. const dataAttributes = Manipulator.getDataAttributes(this._element);
  3346. for (const dataAttribute of Object.keys(dataAttributes)) {
  3347. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  3348. delete dataAttributes[dataAttribute];
  3349. }
  3350. }
  3351. config = {
  3352. ...dataAttributes,
  3353. ...(typeof config === 'object' && config ? config : {})
  3354. };
  3355. config = this._mergeConfigObj(config);
  3356. config = this._configAfterMerge(config);
  3357. this._typeCheckConfig(config);
  3358. return config;
  3359. }
  3360. _configAfterMerge(config) {
  3361. config.container = config.container === false ? document.body : getElement(config.container);
  3362. if (typeof config.delay === 'number') {
  3363. config.delay = {
  3364. show: config.delay,
  3365. hide: config.delay
  3366. };
  3367. }
  3368. if (typeof config.title === 'number') {
  3369. config.title = config.title.toString();
  3370. }
  3371. if (typeof config.content === 'number') {
  3372. config.content = config.content.toString();
  3373. }
  3374. return config;
  3375. }
  3376. _getDelegateConfig() {
  3377. const config = {};
  3378. for (const [key, value] of Object.entries(this._config)) {
  3379. if (this.constructor.Default[key] !== value) {
  3380. config[key] = value;
  3381. }
  3382. }
  3383. config.selector = false;
  3384. config.trigger = 'manual';
  3385. // In the future can be replaced with:
  3386. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  3387. // `Object.fromEntries(keysWithDifferentValues)`
  3388. return config;
  3389. }
  3390. _disposePopper() {
  3391. if (this._popper) {
  3392. this._popper.destroy();
  3393. this._popper = null;
  3394. }
  3395. if (this.tip) {
  3396. this.tip.remove();
  3397. this.tip = null;
  3398. }
  3399. }
  3400. // Static
  3401. static jQueryInterface(config) {
  3402. return this.each(function () {
  3403. const data = Tooltip.getOrCreateInstance(this, config);
  3404. if (typeof config !== 'string') {
  3405. return;
  3406. }
  3407. if (typeof data[config] === 'undefined') {
  3408. throw new TypeError(`No method named "${config}"`);
  3409. }
  3410. data[config]();
  3411. });
  3412. }
  3413. }
  3414. /**
  3415. * jQuery
  3416. */
  3417. defineJQueryPlugin(Tooltip);
  3418. /**
  3419. * --------------------------------------------------------------------------
  3420. * Bootstrap popover.js
  3421. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3422. * --------------------------------------------------------------------------
  3423. */
  3424. /**
  3425. * Constants
  3426. */
  3427. const NAME$3 = 'popover';
  3428. const SELECTOR_TITLE = '.popover-header';
  3429. const SELECTOR_CONTENT = '.popover-body';
  3430. const Default$2 = {
  3431. ...Tooltip.Default,
  3432. content: '',
  3433. offset: [0, 8],
  3434. placement: 'right',
  3435. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  3436. trigger: 'click'
  3437. };
  3438. const DefaultType$2 = {
  3439. ...Tooltip.DefaultType,
  3440. content: '(null|string|element|function)'
  3441. };
  3442. /**
  3443. * Class definition
  3444. */
  3445. class Popover extends Tooltip {
  3446. // Getters
  3447. static get Default() {
  3448. return Default$2;
  3449. }
  3450. static get DefaultType() {
  3451. return DefaultType$2;
  3452. }
  3453. static get NAME() {
  3454. return NAME$3;
  3455. }
  3456. // Overrides
  3457. _isWithContent() {
  3458. return this._getTitle() || this._getContent();
  3459. }
  3460. // Private
  3461. _getContentForTemplate() {
  3462. return {
  3463. [SELECTOR_TITLE]: this._getTitle(),
  3464. [SELECTOR_CONTENT]: this._getContent()
  3465. };
  3466. }
  3467. _getContent() {
  3468. return this._resolvePossibleFunction(this._config.content);
  3469. }
  3470. // Static
  3471. static jQueryInterface(config) {
  3472. return this.each(function () {
  3473. const data = Popover.getOrCreateInstance(this, config);
  3474. if (typeof config !== 'string') {
  3475. return;
  3476. }
  3477. if (typeof data[config] === 'undefined') {
  3478. throw new TypeError(`No method named "${config}"`);
  3479. }
  3480. data[config]();
  3481. });
  3482. }
  3483. }
  3484. /**
  3485. * jQuery
  3486. */
  3487. defineJQueryPlugin(Popover);
  3488. /**
  3489. * --------------------------------------------------------------------------
  3490. * Bootstrap scrollspy.js
  3491. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3492. * --------------------------------------------------------------------------
  3493. */
  3494. /**
  3495. * Constants
  3496. */
  3497. const NAME$2 = 'scrollspy';
  3498. const DATA_KEY$2 = 'bs.scrollspy';
  3499. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  3500. const DATA_API_KEY = '.data-api';
  3501. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  3502. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  3503. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  3504. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  3505. const CLASS_NAME_ACTIVE$1 = 'active';
  3506. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  3507. const SELECTOR_TARGET_LINKS = '[href]';
  3508. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  3509. const SELECTOR_NAV_LINKS = '.nav-link';
  3510. const SELECTOR_NAV_ITEMS = '.nav-item';
  3511. const SELECTOR_LIST_ITEMS = '.list-group-item';
  3512. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  3513. const SELECTOR_DROPDOWN = '.dropdown';
  3514. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  3515. const Default$1 = {
  3516. offset: null,
  3517. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  3518. rootMargin: '0px 0px -25%',
  3519. smoothScroll: false,
  3520. target: null,
  3521. threshold: [0.1, 0.5, 1]
  3522. };
  3523. const DefaultType$1 = {
  3524. offset: '(number|null)',
  3525. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  3526. rootMargin: 'string',
  3527. smoothScroll: 'boolean',
  3528. target: 'element',
  3529. threshold: 'array'
  3530. };
  3531. /**
  3532. * Class definition
  3533. */
  3534. class ScrollSpy extends BaseComponent {
  3535. constructor(element, config) {
  3536. super(element, config);
  3537. // this._element is the observablesContainer and config.target the menu links wrapper
  3538. this._targetLinks = new Map();
  3539. this._observableSections = new Map();
  3540. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  3541. this._activeTarget = null;
  3542. this._observer = null;
  3543. this._previousScrollData = {
  3544. visibleEntryTop: 0,
  3545. parentScrollTop: 0
  3546. };
  3547. this.refresh(); // initialize
  3548. }
  3549. // Getters
  3550. static get Default() {
  3551. return Default$1;
  3552. }
  3553. static get DefaultType() {
  3554. return DefaultType$1;
  3555. }
  3556. static get NAME() {
  3557. return NAME$2;
  3558. }
  3559. // Public
  3560. refresh() {
  3561. this._initializeTargetsAndObservables();
  3562. this._maybeEnableSmoothScroll();
  3563. if (this._observer) {
  3564. this._observer.disconnect();
  3565. } else {
  3566. this._observer = this._getNewObserver();
  3567. }
  3568. for (const section of this._observableSections.values()) {
  3569. this._observer.observe(section);
  3570. }
  3571. }
  3572. dispose() {
  3573. this._observer.disconnect();
  3574. super.dispose();
  3575. }
  3576. // Private
  3577. _configAfterMerge(config) {
  3578. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  3579. config.target = getElement(config.target) || document.body;
  3580. // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  3581. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  3582. if (typeof config.threshold === 'string') {
  3583. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  3584. }
  3585. return config;
  3586. }
  3587. _maybeEnableSmoothScroll() {
  3588. if (!this._config.smoothScroll) {
  3589. return;
  3590. }
  3591. // unregister any previous listeners
  3592. EventHandler.off(this._config.target, EVENT_CLICK);
  3593. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  3594. const observableSection = this._observableSections.get(event.target.hash);
  3595. if (observableSection) {
  3596. event.preventDefault();
  3597. const root = this._rootElement || window;
  3598. const height = observableSection.offsetTop - this._element.offsetTop;
  3599. if (root.scrollTo) {
  3600. root.scrollTo({
  3601. top: height,
  3602. behavior: 'smooth'
  3603. });
  3604. return;
  3605. }
  3606. // Chrome 60 doesn't support `scrollTo`
  3607. root.scrollTop = height;
  3608. }
  3609. });
  3610. }
  3611. _getNewObserver() {
  3612. const options = {
  3613. root: this._rootElement,
  3614. threshold: this._config.threshold,
  3615. rootMargin: this._config.rootMargin
  3616. };
  3617. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  3618. }
  3619. // The logic of selection
  3620. _observerCallback(entries) {
  3621. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  3622. const activate = entry => {
  3623. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  3624. this._process(targetElement(entry));
  3625. };
  3626. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  3627. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  3628. this._previousScrollData.parentScrollTop = parentScrollTop;
  3629. for (const entry of entries) {
  3630. if (!entry.isIntersecting) {
  3631. this._activeTarget = null;
  3632. this._clearActiveClass(targetElement(entry));
  3633. continue;
  3634. }
  3635. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  3636. // if we are scrolling down, pick the bigger offsetTop
  3637. if (userScrollsDown && entryIsLowerThanPrevious) {
  3638. activate(entry);
  3639. // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  3640. if (!parentScrollTop) {
  3641. return;
  3642. }
  3643. continue;
  3644. }
  3645. // if we are scrolling up, pick the smallest offsetTop
  3646. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  3647. activate(entry);
  3648. }
  3649. }
  3650. }
  3651. _initializeTargetsAndObservables() {
  3652. this._targetLinks = new Map();
  3653. this._observableSections = new Map();
  3654. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  3655. for (const anchor of targetLinks) {
  3656. // ensure that the anchor has an id and is not disabled
  3657. if (!anchor.hash || isDisabled(anchor)) {
  3658. continue;
  3659. }
  3660. const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
  3661. // ensure that the observableSection exists & is visible
  3662. if (isVisible(observableSection)) {
  3663. this._targetLinks.set(decodeURI(anchor.hash), anchor);
  3664. this._observableSections.set(anchor.hash, observableSection);
  3665. }
  3666. }
  3667. }
  3668. _process(target) {
  3669. if (this._activeTarget === target) {
  3670. return;
  3671. }
  3672. this._clearActiveClass(this._config.target);
  3673. this._activeTarget = target;
  3674. target.classList.add(CLASS_NAME_ACTIVE$1);
  3675. this._activateParents(target);
  3676. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  3677. relatedTarget: target
  3678. });
  3679. }
  3680. _activateParents(target) {
  3681. // Activate dropdown parents
  3682. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  3683. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  3684. return;
  3685. }
  3686. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  3687. // Set triggered links parents as active
  3688. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  3689. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  3690. item.classList.add(CLASS_NAME_ACTIVE$1);
  3691. }
  3692. }
  3693. }
  3694. _clearActiveClass(parent) {
  3695. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  3696. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  3697. for (const node of activeNodes) {
  3698. node.classList.remove(CLASS_NAME_ACTIVE$1);
  3699. }
  3700. }
  3701. // Static
  3702. static jQueryInterface(config) {
  3703. return this.each(function () {
  3704. const data = ScrollSpy.getOrCreateInstance(this, config);
  3705. if (typeof config !== 'string') {
  3706. return;
  3707. }
  3708. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  3709. throw new TypeError(`No method named "${config}"`);
  3710. }
  3711. data[config]();
  3712. });
  3713. }
  3714. }
  3715. /**
  3716. * Data API implementation
  3717. */
  3718. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  3719. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  3720. ScrollSpy.getOrCreateInstance(spy);
  3721. }
  3722. });
  3723. /**
  3724. * jQuery
  3725. */
  3726. defineJQueryPlugin(ScrollSpy);
  3727. /**
  3728. * --------------------------------------------------------------------------
  3729. * Bootstrap tab.js
  3730. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3731. * --------------------------------------------------------------------------
  3732. */
  3733. /**
  3734. * Constants
  3735. */
  3736. const NAME$1 = 'tab';
  3737. const DATA_KEY$1 = 'bs.tab';
  3738. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  3739. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  3740. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  3741. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  3742. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  3743. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  3744. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  3745. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  3746. const ARROW_LEFT_KEY = 'ArrowLeft';
  3747. const ARROW_RIGHT_KEY = 'ArrowRight';
  3748. const ARROW_UP_KEY = 'ArrowUp';
  3749. const ARROW_DOWN_KEY = 'ArrowDown';
  3750. const HOME_KEY = 'Home';
  3751. const END_KEY = 'End';
  3752. const CLASS_NAME_ACTIVE = 'active';
  3753. const CLASS_NAME_FADE$1 = 'fade';
  3754. const CLASS_NAME_SHOW$1 = 'show';
  3755. const CLASS_DROPDOWN = 'dropdown';
  3756. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  3757. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  3758. const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
  3759. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  3760. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  3761. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  3762. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // TODO: could only be `tab` in v6
  3763. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  3764. const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
  3765. /**
  3766. * Class definition
  3767. */
  3768. class Tab extends BaseComponent {
  3769. constructor(element) {
  3770. super(element);
  3771. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  3772. if (!this._parent) {
  3773. return;
  3774. // TODO: should throw exception in v6
  3775. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  3776. }
  3777. // Set up initial aria attributes
  3778. this._setInitialAttributes(this._parent, this._getChildren());
  3779. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  3780. }
  3781. // Getters
  3782. static get NAME() {
  3783. return NAME$1;
  3784. }
  3785. // Public
  3786. show() {
  3787. // Shows this elem and deactivate the active sibling if exists
  3788. const innerElem = this._element;
  3789. if (this._elemIsActive(innerElem)) {
  3790. return;
  3791. }
  3792. // Search for active tab on same parent to deactivate it
  3793. const active = this._getActiveElem();
  3794. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  3795. relatedTarget: innerElem
  3796. }) : null;
  3797. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  3798. relatedTarget: active
  3799. });
  3800. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  3801. return;
  3802. }
  3803. this._deactivate(active, innerElem);
  3804. this._activate(innerElem, active);
  3805. }
  3806. // Private
  3807. _activate(element, relatedElem) {
  3808. if (!element) {
  3809. return;
  3810. }
  3811. element.classList.add(CLASS_NAME_ACTIVE);
  3812. this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
  3813. const complete = () => {
  3814. if (element.getAttribute('role') !== 'tab') {
  3815. element.classList.add(CLASS_NAME_SHOW$1);
  3816. return;
  3817. }
  3818. element.removeAttribute('tabindex');
  3819. element.setAttribute('aria-selected', true);
  3820. this._toggleDropDown(element, true);
  3821. EventHandler.trigger(element, EVENT_SHOWN$1, {
  3822. relatedTarget: relatedElem
  3823. });
  3824. };
  3825. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  3826. }
  3827. _deactivate(element, relatedElem) {
  3828. if (!element) {
  3829. return;
  3830. }
  3831. element.classList.remove(CLASS_NAME_ACTIVE);
  3832. element.blur();
  3833. this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
  3834. const complete = () => {
  3835. if (element.getAttribute('role') !== 'tab') {
  3836. element.classList.remove(CLASS_NAME_SHOW$1);
  3837. return;
  3838. }
  3839. element.setAttribute('aria-selected', false);
  3840. element.setAttribute('tabindex', '-1');
  3841. this._toggleDropDown(element, false);
  3842. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  3843. relatedTarget: relatedElem
  3844. });
  3845. };
  3846. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  3847. }
  3848. _keydown(event) {
  3849. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY, HOME_KEY, END_KEY].includes(event.key)) {
  3850. return;
  3851. }
  3852. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  3853. event.preventDefault();
  3854. const children = this._getChildren().filter(element => !isDisabled(element));
  3855. let nextActiveElement;
  3856. if ([HOME_KEY, END_KEY].includes(event.key)) {
  3857. nextActiveElement = children[event.key === HOME_KEY ? 0 : children.length - 1];
  3858. } else {
  3859. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  3860. nextActiveElement = getNextActiveElement(children, event.target, isNext, true);
  3861. }
  3862. if (nextActiveElement) {
  3863. nextActiveElement.focus({
  3864. preventScroll: true
  3865. });
  3866. Tab.getOrCreateInstance(nextActiveElement).show();
  3867. }
  3868. }
  3869. _getChildren() {
  3870. // collection of inner elements
  3871. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  3872. }
  3873. _getActiveElem() {
  3874. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  3875. }
  3876. _setInitialAttributes(parent, children) {
  3877. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  3878. for (const child of children) {
  3879. this._setInitialAttributesOnChild(child);
  3880. }
  3881. }
  3882. _setInitialAttributesOnChild(child) {
  3883. child = this._getInnerElement(child);
  3884. const isActive = this._elemIsActive(child);
  3885. const outerElem = this._getOuterElement(child);
  3886. child.setAttribute('aria-selected', isActive);
  3887. if (outerElem !== child) {
  3888. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  3889. }
  3890. if (!isActive) {
  3891. child.setAttribute('tabindex', '-1');
  3892. }
  3893. this._setAttributeIfNotExists(child, 'role', 'tab');
  3894. // set attributes to the related panel too
  3895. this._setInitialAttributesOnTargetPanel(child);
  3896. }
  3897. _setInitialAttributesOnTargetPanel(child) {
  3898. const target = SelectorEngine.getElementFromSelector(child);
  3899. if (!target) {
  3900. return;
  3901. }
  3902. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  3903. if (child.id) {
  3904. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  3905. }
  3906. }
  3907. _toggleDropDown(element, open) {
  3908. const outerElem = this._getOuterElement(element);
  3909. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  3910. return;
  3911. }
  3912. const toggle = (selector, className) => {
  3913. const element = SelectorEngine.findOne(selector, outerElem);
  3914. if (element) {
  3915. element.classList.toggle(className, open);
  3916. }
  3917. };
  3918. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  3919. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  3920. outerElem.setAttribute('aria-expanded', open);
  3921. }
  3922. _setAttributeIfNotExists(element, attribute, value) {
  3923. if (!element.hasAttribute(attribute)) {
  3924. element.setAttribute(attribute, value);
  3925. }
  3926. }
  3927. _elemIsActive(elem) {
  3928. return elem.classList.contains(CLASS_NAME_ACTIVE);
  3929. }
  3930. // Try to get the inner element (usually the .nav-link)
  3931. _getInnerElement(elem) {
  3932. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  3933. }
  3934. // Try to get the outer element (usually the .nav-item)
  3935. _getOuterElement(elem) {
  3936. return elem.closest(SELECTOR_OUTER) || elem;
  3937. }
  3938. // Static
  3939. static jQueryInterface(config) {
  3940. return this.each(function () {
  3941. const data = Tab.getOrCreateInstance(this);
  3942. if (typeof config !== 'string') {
  3943. return;
  3944. }
  3945. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  3946. throw new TypeError(`No method named "${config}"`);
  3947. }
  3948. data[config]();
  3949. });
  3950. }
  3951. }
  3952. /**
  3953. * Data API implementation
  3954. */
  3955. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  3956. if (['A', 'AREA'].includes(this.tagName)) {
  3957. event.preventDefault();
  3958. }
  3959. if (isDisabled(this)) {
  3960. return;
  3961. }
  3962. Tab.getOrCreateInstance(this).show();
  3963. });
  3964. /**
  3965. * Initialize on focus
  3966. */
  3967. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  3968. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  3969. Tab.getOrCreateInstance(element);
  3970. }
  3971. });
  3972. /**
  3973. * jQuery
  3974. */
  3975. defineJQueryPlugin(Tab);
  3976. /**
  3977. * --------------------------------------------------------------------------
  3978. * Bootstrap toast.js
  3979. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3980. * --------------------------------------------------------------------------
  3981. */
  3982. /**
  3983. * Constants
  3984. */
  3985. const NAME = 'toast';
  3986. const DATA_KEY = 'bs.toast';
  3987. const EVENT_KEY = `.${DATA_KEY}`;
  3988. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  3989. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  3990. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  3991. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  3992. const EVENT_HIDE = `hide${EVENT_KEY}`;
  3993. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  3994. const EVENT_SHOW = `show${EVENT_KEY}`;
  3995. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  3996. const CLASS_NAME_FADE = 'fade';
  3997. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  3998. const CLASS_NAME_SHOW = 'show';
  3999. const CLASS_NAME_SHOWING = 'showing';
  4000. const DefaultType = {
  4001. animation: 'boolean',
  4002. autohide: 'boolean',
  4003. delay: 'number'
  4004. };
  4005. const Default = {
  4006. animation: true,
  4007. autohide: true,
  4008. delay: 5000
  4009. };
  4010. /**
  4011. * Class definition
  4012. */
  4013. class Toast extends BaseComponent {
  4014. constructor(element, config) {
  4015. super(element, config);
  4016. this._timeout = null;
  4017. this._hasMouseInteraction = false;
  4018. this._hasKeyboardInteraction = false;
  4019. this._setListeners();
  4020. }
  4021. // Getters
  4022. static get Default() {
  4023. return Default;
  4024. }
  4025. static get DefaultType() {
  4026. return DefaultType;
  4027. }
  4028. static get NAME() {
  4029. return NAME;
  4030. }
  4031. // Public
  4032. show() {
  4033. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  4034. if (showEvent.defaultPrevented) {
  4035. return;
  4036. }
  4037. this._clearTimeout();
  4038. if (this._config.animation) {
  4039. this._element.classList.add(CLASS_NAME_FADE);
  4040. }
  4041. const complete = () => {
  4042. this._element.classList.remove(CLASS_NAME_SHOWING);
  4043. EventHandler.trigger(this._element, EVENT_SHOWN);
  4044. this._maybeScheduleHide();
  4045. };
  4046. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  4047. reflow(this._element);
  4048. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  4049. this._queueCallback(complete, this._element, this._config.animation);
  4050. }
  4051. hide() {
  4052. if (!this.isShown()) {
  4053. return;
  4054. }
  4055. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  4056. if (hideEvent.defaultPrevented) {
  4057. return;
  4058. }
  4059. const complete = () => {
  4060. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  4061. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  4062. EventHandler.trigger(this._element, EVENT_HIDDEN);
  4063. };
  4064. this._element.classList.add(CLASS_NAME_SHOWING);
  4065. this._queueCallback(complete, this._element, this._config.animation);
  4066. }
  4067. dispose() {
  4068. this._clearTimeout();
  4069. if (this.isShown()) {
  4070. this._element.classList.remove(CLASS_NAME_SHOW);
  4071. }
  4072. super.dispose();
  4073. }
  4074. isShown() {
  4075. return this._element.classList.contains(CLASS_NAME_SHOW);
  4076. }
  4077. // Private
  4078. _maybeScheduleHide() {
  4079. if (!this._config.autohide) {
  4080. return;
  4081. }
  4082. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  4083. return;
  4084. }
  4085. this._timeout = setTimeout(() => {
  4086. this.hide();
  4087. }, this._config.delay);
  4088. }
  4089. _onInteraction(event, isInteracting) {
  4090. switch (event.type) {
  4091. case 'mouseover':
  4092. case 'mouseout':
  4093. {
  4094. this._hasMouseInteraction = isInteracting;
  4095. break;
  4096. }
  4097. case 'focusin':
  4098. case 'focusout':
  4099. {
  4100. this._hasKeyboardInteraction = isInteracting;
  4101. break;
  4102. }
  4103. }
  4104. if (isInteracting) {
  4105. this._clearTimeout();
  4106. return;
  4107. }
  4108. const nextElement = event.relatedTarget;
  4109. if (this._element === nextElement || this._element.contains(nextElement)) {
  4110. return;
  4111. }
  4112. this._maybeScheduleHide();
  4113. }
  4114. _setListeners() {
  4115. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  4116. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  4117. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  4118. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  4119. }
  4120. _clearTimeout() {
  4121. clearTimeout(this._timeout);
  4122. this._timeout = null;
  4123. }
  4124. // Static
  4125. static jQueryInterface(config) {
  4126. return this.each(function () {
  4127. const data = Toast.getOrCreateInstance(this, config);
  4128. if (typeof config === 'string') {
  4129. if (typeof data[config] === 'undefined') {
  4130. throw new TypeError(`No method named "${config}"`);
  4131. }
  4132. data[config](this);
  4133. }
  4134. });
  4135. }
  4136. }
  4137. /**
  4138. * Data API implementation
  4139. */
  4140. enableDismissTrigger(Toast);
  4141. /**
  4142. * jQuery
  4143. */
  4144. defineJQueryPlugin(Toast);
  4145. export { Alert, Button, Carousel, Collapse, Dropdown, Modal, Offcanvas, Popover, ScrollSpy, Tab, Toast, Tooltip };
  4146. //# sourceMappingURL=bootstrap.esm.js.map