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.

6314 lines
203 KiB

6 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. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory());
  10. })(this, (function () { 'use strict';
  11. /**
  12. * --------------------------------------------------------------------------
  13. * Bootstrap dom/data.js
  14. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15. * --------------------------------------------------------------------------
  16. */
  17. /**
  18. * Constants
  19. */
  20. const elementMap = new Map();
  21. const Data = {
  22. set(element, key, instance) {
  23. if (!elementMap.has(element)) {
  24. elementMap.set(element, new Map());
  25. }
  26. const instanceMap = elementMap.get(element);
  27. // make it clear we only want one instance per element
  28. // can be removed later when multiple key/instances are fine to be used
  29. if (!instanceMap.has(key) && instanceMap.size !== 0) {
  30. // eslint-disable-next-line no-console
  31. console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
  32. return;
  33. }
  34. instanceMap.set(key, instance);
  35. },
  36. get(element, key) {
  37. if (elementMap.has(element)) {
  38. return elementMap.get(element).get(key) || null;
  39. }
  40. return null;
  41. },
  42. remove(element, key) {
  43. if (!elementMap.has(element)) {
  44. return;
  45. }
  46. const instanceMap = elementMap.get(element);
  47. instanceMap.delete(key);
  48. // free up element references if there are no instances left for an element
  49. if (instanceMap.size === 0) {
  50. elementMap.delete(element);
  51. }
  52. }
  53. };
  54. /**
  55. * --------------------------------------------------------------------------
  56. * Bootstrap util/index.js
  57. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  58. * --------------------------------------------------------------------------
  59. */
  60. const MAX_UID = 1000000;
  61. const MILLISECONDS_MULTIPLIER = 1000;
  62. const TRANSITION_END = 'transitionend';
  63. /**
  64. * Properly escape IDs selectors to handle weird IDs
  65. * @param {string} selector
  66. * @returns {string}
  67. */
  68. const parseSelector = selector => {
  69. if (selector && window.CSS && window.CSS.escape) {
  70. // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
  71. selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
  72. }
  73. return selector;
  74. };
  75. // Shout-out Angus Croll (https://goo.gl/pxwQGp)
  76. const toType = object => {
  77. if (object === null || object === undefined) {
  78. return `${object}`;
  79. }
  80. return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
  81. };
  82. /**
  83. * Public Util API
  84. */
  85. const getUID = prefix => {
  86. do {
  87. prefix += Math.floor(Math.random() * MAX_UID);
  88. } while (document.getElementById(prefix));
  89. return prefix;
  90. };
  91. const getTransitionDurationFromElement = element => {
  92. if (!element) {
  93. return 0;
  94. }
  95. // Get transition-duration of the element
  96. let {
  97. transitionDuration,
  98. transitionDelay
  99. } = window.getComputedStyle(element);
  100. const floatTransitionDuration = Number.parseFloat(transitionDuration);
  101. const floatTransitionDelay = Number.parseFloat(transitionDelay);
  102. // Return 0 if element or transition duration is not found
  103. if (!floatTransitionDuration && !floatTransitionDelay) {
  104. return 0;
  105. }
  106. // If multiple durations are defined, take the first
  107. transitionDuration = transitionDuration.split(',')[0];
  108. transitionDelay = transitionDelay.split(',')[0];
  109. return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  110. };
  111. const triggerTransitionEnd = element => {
  112. element.dispatchEvent(new Event(TRANSITION_END));
  113. };
  114. const isElement$1 = object => {
  115. if (!object || typeof object !== 'object') {
  116. return false;
  117. }
  118. if (typeof object.jquery !== 'undefined') {
  119. object = object[0];
  120. }
  121. return typeof object.nodeType !== 'undefined';
  122. };
  123. const getElement = object => {
  124. // it's a jQuery object or a node element
  125. if (isElement$1(object)) {
  126. return object.jquery ? object[0] : object;
  127. }
  128. if (typeof object === 'string' && object.length > 0) {
  129. return document.querySelector(parseSelector(object));
  130. }
  131. return null;
  132. };
  133. const isVisible = element => {
  134. if (!isElement$1(element) || element.getClientRects().length === 0) {
  135. return false;
  136. }
  137. const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
  138. // Handle `details` element as its content may falsie appear visible when it is closed
  139. const closedDetails = element.closest('details:not([open])');
  140. if (!closedDetails) {
  141. return elementIsVisible;
  142. }
  143. if (closedDetails !== element) {
  144. const summary = element.closest('summary');
  145. if (summary && summary.parentNode !== closedDetails) {
  146. return false;
  147. }
  148. if (summary === null) {
  149. return false;
  150. }
  151. }
  152. return elementIsVisible;
  153. };
  154. const isDisabled = element => {
  155. if (!element || element.nodeType !== Node.ELEMENT_NODE) {
  156. return true;
  157. }
  158. if (element.classList.contains('disabled')) {
  159. return true;
  160. }
  161. if (typeof element.disabled !== 'undefined') {
  162. return element.disabled;
  163. }
  164. return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
  165. };
  166. const findShadowRoot = element => {
  167. if (!document.documentElement.attachShadow) {
  168. return null;
  169. }
  170. // Can find the shadow root otherwise it'll return the document
  171. if (typeof element.getRootNode === 'function') {
  172. const root = element.getRootNode();
  173. return root instanceof ShadowRoot ? root : null;
  174. }
  175. if (element instanceof ShadowRoot) {
  176. return element;
  177. }
  178. // when we don't find a shadow root
  179. if (!element.parentNode) {
  180. return null;
  181. }
  182. return findShadowRoot(element.parentNode);
  183. };
  184. const noop = () => {};
  185. /**
  186. * Trick to restart an element's animation
  187. *
  188. * @param {HTMLElement} element
  189. * @return void
  190. *
  191. * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
  192. */
  193. const reflow = element => {
  194. element.offsetHeight; // eslint-disable-line no-unused-expressions
  195. };
  196. const getjQuery = () => {
  197. if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
  198. return window.jQuery;
  199. }
  200. return null;
  201. };
  202. const DOMContentLoadedCallbacks = [];
  203. const onDOMContentLoaded = callback => {
  204. if (document.readyState === 'loading') {
  205. // add listener on the first call when the document is in loading state
  206. if (!DOMContentLoadedCallbacks.length) {
  207. document.addEventListener('DOMContentLoaded', () => {
  208. for (const callback of DOMContentLoadedCallbacks) {
  209. callback();
  210. }
  211. });
  212. }
  213. DOMContentLoadedCallbacks.push(callback);
  214. } else {
  215. callback();
  216. }
  217. };
  218. const isRTL = () => document.documentElement.dir === 'rtl';
  219. const defineJQueryPlugin = plugin => {
  220. onDOMContentLoaded(() => {
  221. const $ = getjQuery();
  222. /* istanbul ignore if */
  223. if ($) {
  224. const name = plugin.NAME;
  225. const JQUERY_NO_CONFLICT = $.fn[name];
  226. $.fn[name] = plugin.jQueryInterface;
  227. $.fn[name].Constructor = plugin;
  228. $.fn[name].noConflict = () => {
  229. $.fn[name] = JQUERY_NO_CONFLICT;
  230. return plugin.jQueryInterface;
  231. };
  232. }
  233. });
  234. };
  235. const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
  236. return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
  237. };
  238. const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
  239. if (!waitForTransition) {
  240. execute(callback);
  241. return;
  242. }
  243. const durationPadding = 5;
  244. const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
  245. let called = false;
  246. const handler = ({
  247. target
  248. }) => {
  249. if (target !== transitionElement) {
  250. return;
  251. }
  252. called = true;
  253. transitionElement.removeEventListener(TRANSITION_END, handler);
  254. execute(callback);
  255. };
  256. transitionElement.addEventListener(TRANSITION_END, handler);
  257. setTimeout(() => {
  258. if (!called) {
  259. triggerTransitionEnd(transitionElement);
  260. }
  261. }, emulatedDuration);
  262. };
  263. /**
  264. * Return the previous/next element of a list.
  265. *
  266. * @param {array} list The list of elements
  267. * @param activeElement The active element
  268. * @param shouldGetNext Choose to get next or previous element
  269. * @param isCycleAllowed
  270. * @return {Element|elem} The proper element
  271. */
  272. const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
  273. const listLength = list.length;
  274. let index = list.indexOf(activeElement);
  275. // if the element does not exist in the list return an element
  276. // depending on the direction and if cycle is allowed
  277. if (index === -1) {
  278. return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
  279. }
  280. index += shouldGetNext ? 1 : -1;
  281. if (isCycleAllowed) {
  282. index = (index + listLength) % listLength;
  283. }
  284. return list[Math.max(0, Math.min(index, listLength - 1))];
  285. };
  286. /**
  287. * --------------------------------------------------------------------------
  288. * Bootstrap dom/event-handler.js
  289. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  290. * --------------------------------------------------------------------------
  291. */
  292. /**
  293. * Constants
  294. */
  295. const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
  296. const stripNameRegex = /\..*/;
  297. const stripUidRegex = /::\d+$/;
  298. const eventRegistry = {}; // Events storage
  299. let uidEvent = 1;
  300. const customEvents = {
  301. mouseenter: 'mouseover',
  302. mouseleave: 'mouseout'
  303. };
  304. 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']);
  305. /**
  306. * Private methods
  307. */
  308. function makeEventUid(element, uid) {
  309. return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
  310. }
  311. function getElementEvents(element) {
  312. const uid = makeEventUid(element);
  313. element.uidEvent = uid;
  314. eventRegistry[uid] = eventRegistry[uid] || {};
  315. return eventRegistry[uid];
  316. }
  317. function bootstrapHandler(element, fn) {
  318. return function handler(event) {
  319. hydrateObj(event, {
  320. delegateTarget: element
  321. });
  322. if (handler.oneOff) {
  323. EventHandler.off(element, event.type, fn);
  324. }
  325. return fn.apply(element, [event]);
  326. };
  327. }
  328. function bootstrapDelegationHandler(element, selector, fn) {
  329. return function handler(event) {
  330. const domElements = element.querySelectorAll(selector);
  331. for (let {
  332. target
  333. } = event; target && target !== this; target = target.parentNode) {
  334. for (const domElement of domElements) {
  335. if (domElement !== target) {
  336. continue;
  337. }
  338. hydrateObj(event, {
  339. delegateTarget: target
  340. });
  341. if (handler.oneOff) {
  342. EventHandler.off(element, event.type, selector, fn);
  343. }
  344. return fn.apply(target, [event]);
  345. }
  346. }
  347. };
  348. }
  349. function findHandler(events, callable, delegationSelector = null) {
  350. return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
  351. }
  352. function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
  353. const isDelegated = typeof handler === 'string';
  354. // TODO: tooltip passes `false` instead of selector, so we need to check
  355. const callable = isDelegated ? delegationFunction : handler || delegationFunction;
  356. let typeEvent = getTypeEvent(originalTypeEvent);
  357. if (!nativeEvents.has(typeEvent)) {
  358. typeEvent = originalTypeEvent;
  359. }
  360. return [isDelegated, callable, typeEvent];
  361. }
  362. function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
  363. if (typeof originalTypeEvent !== 'string' || !element) {
  364. return;
  365. }
  366. let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  367. // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position
  368. // this prevents the handler from being dispatched the same way as mouseover or mouseout does
  369. if (originalTypeEvent in customEvents) {
  370. const wrapFunction = fn => {
  371. return function (event) {
  372. if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
  373. return fn.call(this, event);
  374. }
  375. };
  376. };
  377. callable = wrapFunction(callable);
  378. }
  379. const events = getElementEvents(element);
  380. const handlers = events[typeEvent] || (events[typeEvent] = {});
  381. const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null);
  382. if (previousFunction) {
  383. previousFunction.oneOff = previousFunction.oneOff && oneOff;
  384. return;
  385. }
  386. const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ''));
  387. const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable);
  388. fn.delegationSelector = isDelegated ? handler : null;
  389. fn.callable = callable;
  390. fn.oneOff = oneOff;
  391. fn.uidEvent = uid;
  392. handlers[uid] = fn;
  393. element.addEventListener(typeEvent, fn, isDelegated);
  394. }
  395. function removeHandler(element, events, typeEvent, handler, delegationSelector) {
  396. const fn = findHandler(events[typeEvent], handler, delegationSelector);
  397. if (!fn) {
  398. return;
  399. }
  400. element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  401. delete events[typeEvent][fn.uidEvent];
  402. }
  403. function removeNamespacedHandlers(element, events, typeEvent, namespace) {
  404. const storeElementEvent = events[typeEvent] || {};
  405. for (const [handlerKey, event] of Object.entries(storeElementEvent)) {
  406. if (handlerKey.includes(namespace)) {
  407. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  408. }
  409. }
  410. }
  411. function getTypeEvent(event) {
  412. // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
  413. event = event.replace(stripNameRegex, '');
  414. return customEvents[event] || event;
  415. }
  416. const EventHandler = {
  417. on(element, event, handler, delegationFunction) {
  418. addHandler(element, event, handler, delegationFunction, false);
  419. },
  420. one(element, event, handler, delegationFunction) {
  421. addHandler(element, event, handler, delegationFunction, true);
  422. },
  423. off(element, originalTypeEvent, handler, delegationFunction) {
  424. if (typeof originalTypeEvent !== 'string' || !element) {
  425. return;
  426. }
  427. const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
  428. const inNamespace = typeEvent !== originalTypeEvent;
  429. const events = getElementEvents(element);
  430. const storeElementEvent = events[typeEvent] || {};
  431. const isNamespace = originalTypeEvent.startsWith('.');
  432. if (typeof callable !== 'undefined') {
  433. // Simplest case: handler is passed, remove that listener ONLY.
  434. if (!Object.keys(storeElementEvent).length) {
  435. return;
  436. }
  437. removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
  438. return;
  439. }
  440. if (isNamespace) {
  441. for (const elementEvent of Object.keys(events)) {
  442. removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
  443. }
  444. }
  445. for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
  446. const handlerKey = keyHandlers.replace(stripUidRegex, '');
  447. if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
  448. removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
  449. }
  450. }
  451. },
  452. trigger(element, event, args) {
  453. if (typeof event !== 'string' || !element) {
  454. return null;
  455. }
  456. const $ = getjQuery();
  457. const typeEvent = getTypeEvent(event);
  458. const inNamespace = event !== typeEvent;
  459. let jQueryEvent = null;
  460. let bubbles = true;
  461. let nativeDispatch = true;
  462. let defaultPrevented = false;
  463. if (inNamespace && $) {
  464. jQueryEvent = $.Event(event, args);
  465. $(element).trigger(jQueryEvent);
  466. bubbles = !jQueryEvent.isPropagationStopped();
  467. nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
  468. defaultPrevented = jQueryEvent.isDefaultPrevented();
  469. }
  470. const evt = hydrateObj(new Event(event, {
  471. bubbles,
  472. cancelable: true
  473. }), args);
  474. if (defaultPrevented) {
  475. evt.preventDefault();
  476. }
  477. if (nativeDispatch) {
  478. element.dispatchEvent(evt);
  479. }
  480. if (evt.defaultPrevented && jQueryEvent) {
  481. jQueryEvent.preventDefault();
  482. }
  483. return evt;
  484. }
  485. };
  486. function hydrateObj(obj, meta = {}) {
  487. for (const [key, value] of Object.entries(meta)) {
  488. try {
  489. obj[key] = value;
  490. } catch (_unused) {
  491. Object.defineProperty(obj, key, {
  492. configurable: true,
  493. get() {
  494. return value;
  495. }
  496. });
  497. }
  498. }
  499. return obj;
  500. }
  501. /**
  502. * --------------------------------------------------------------------------
  503. * Bootstrap dom/manipulator.js
  504. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  505. * --------------------------------------------------------------------------
  506. */
  507. function normalizeData(value) {
  508. if (value === 'true') {
  509. return true;
  510. }
  511. if (value === 'false') {
  512. return false;
  513. }
  514. if (value === Number(value).toString()) {
  515. return Number(value);
  516. }
  517. if (value === '' || value === 'null') {
  518. return null;
  519. }
  520. if (typeof value !== 'string') {
  521. return value;
  522. }
  523. try {
  524. return JSON.parse(decodeURIComponent(value));
  525. } catch (_unused) {
  526. return value;
  527. }
  528. }
  529. function normalizeDataKey(key) {
  530. return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`);
  531. }
  532. const Manipulator = {
  533. setDataAttribute(element, key, value) {
  534. element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
  535. },
  536. removeDataAttribute(element, key) {
  537. element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
  538. },
  539. getDataAttributes(element) {
  540. if (!element) {
  541. return {};
  542. }
  543. const attributes = {};
  544. const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig'));
  545. for (const key of bsKeys) {
  546. let pureKey = key.replace(/^bs/, '');
  547. pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
  548. attributes[pureKey] = normalizeData(element.dataset[key]);
  549. }
  550. return attributes;
  551. },
  552. getDataAttribute(element, key) {
  553. return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
  554. }
  555. };
  556. /**
  557. * --------------------------------------------------------------------------
  558. * Bootstrap util/config.js
  559. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  560. * --------------------------------------------------------------------------
  561. */
  562. /**
  563. * Class definition
  564. */
  565. class Config {
  566. // Getters
  567. static get Default() {
  568. return {};
  569. }
  570. static get DefaultType() {
  571. return {};
  572. }
  573. static get NAME() {
  574. throw new Error('You have to implement the static method "NAME", for each component!');
  575. }
  576. _getConfig(config) {
  577. config = this._mergeConfigObj(config);
  578. config = this._configAfterMerge(config);
  579. this._typeCheckConfig(config);
  580. return config;
  581. }
  582. _configAfterMerge(config) {
  583. return config;
  584. }
  585. _mergeConfigObj(config, element) {
  586. const jsonConfig = isElement$1(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse
  587. return {
  588. ...this.constructor.Default,
  589. ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
  590. ...(isElement$1(element) ? Manipulator.getDataAttributes(element) : {}),
  591. ...(typeof config === 'object' ? config : {})
  592. };
  593. }
  594. _typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
  595. for (const [property, expectedTypes] of Object.entries(configTypes)) {
  596. const value = config[property];
  597. const valueType = isElement$1(value) ? 'element' : toType(value);
  598. if (!new RegExp(expectedTypes).test(valueType)) {
  599. throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
  600. }
  601. }
  602. }
  603. }
  604. /**
  605. * --------------------------------------------------------------------------
  606. * Bootstrap base-component.js
  607. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  608. * --------------------------------------------------------------------------
  609. */
  610. /**
  611. * Constants
  612. */
  613. const VERSION = '5.3.3';
  614. /**
  615. * Class definition
  616. */
  617. class BaseComponent extends Config {
  618. constructor(element, config) {
  619. super();
  620. element = getElement(element);
  621. if (!element) {
  622. return;
  623. }
  624. this._element = element;
  625. this._config = this._getConfig(config);
  626. Data.set(this._element, this.constructor.DATA_KEY, this);
  627. }
  628. // Public
  629. dispose() {
  630. Data.remove(this._element, this.constructor.DATA_KEY);
  631. EventHandler.off(this._element, this.constructor.EVENT_KEY);
  632. for (const propertyName of Object.getOwnPropertyNames(this)) {
  633. this[propertyName] = null;
  634. }
  635. }
  636. _queueCallback(callback, element, isAnimated = true) {
  637. executeAfterTransition(callback, element, isAnimated);
  638. }
  639. _getConfig(config) {
  640. config = this._mergeConfigObj(config, this._element);
  641. config = this._configAfterMerge(config);
  642. this._typeCheckConfig(config);
  643. return config;
  644. }
  645. // Static
  646. static getInstance(element) {
  647. return Data.get(getElement(element), this.DATA_KEY);
  648. }
  649. static getOrCreateInstance(element, config = {}) {
  650. return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
  651. }
  652. static get VERSION() {
  653. return VERSION;
  654. }
  655. static get DATA_KEY() {
  656. return `bs.${this.NAME}`;
  657. }
  658. static get EVENT_KEY() {
  659. return `.${this.DATA_KEY}`;
  660. }
  661. static eventName(name) {
  662. return `${name}${this.EVENT_KEY}`;
  663. }
  664. }
  665. /**
  666. * --------------------------------------------------------------------------
  667. * Bootstrap dom/selector-engine.js
  668. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  669. * --------------------------------------------------------------------------
  670. */
  671. const getSelector = element => {
  672. let selector = element.getAttribute('data-bs-target');
  673. if (!selector || selector === '#') {
  674. let hrefAttribute = element.getAttribute('href');
  675. // The only valid content that could double as a selector are IDs or classes,
  676. // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
  677. // `document.querySelector` will rightfully complain it is invalid.
  678. // See https://github.com/twbs/bootstrap/issues/32273
  679. if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) {
  680. return null;
  681. }
  682. // Just in case some CMS puts out a full URL with the anchor appended
  683. if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) {
  684. hrefAttribute = `#${hrefAttribute.split('#')[1]}`;
  685. }
  686. selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
  687. }
  688. return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null;
  689. };
  690. const SelectorEngine = {
  691. find(selector, element = document.documentElement) {
  692. return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
  693. },
  694. findOne(selector, element = document.documentElement) {
  695. return Element.prototype.querySelector.call(element, selector);
  696. },
  697. children(element, selector) {
  698. return [].concat(...element.children).filter(child => child.matches(selector));
  699. },
  700. parents(element, selector) {
  701. const parents = [];
  702. let ancestor = element.parentNode.closest(selector);
  703. while (ancestor) {
  704. parents.push(ancestor);
  705. ancestor = ancestor.parentNode.closest(selector);
  706. }
  707. return parents;
  708. },
  709. prev(element, selector) {
  710. let previous = element.previousElementSibling;
  711. while (previous) {
  712. if (previous.matches(selector)) {
  713. return [previous];
  714. }
  715. previous = previous.previousElementSibling;
  716. }
  717. return [];
  718. },
  719. // TODO: this is now unused; remove later along with prev()
  720. next(element, selector) {
  721. let next = element.nextElementSibling;
  722. while (next) {
  723. if (next.matches(selector)) {
  724. return [next];
  725. }
  726. next = next.nextElementSibling;
  727. }
  728. return [];
  729. },
  730. focusableChildren(element) {
  731. const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
  732. return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
  733. },
  734. getSelectorFromElement(element) {
  735. const selector = getSelector(element);
  736. if (selector) {
  737. return SelectorEngine.findOne(selector) ? selector : null;
  738. }
  739. return null;
  740. },
  741. getElementFromSelector(element) {
  742. const selector = getSelector(element);
  743. return selector ? SelectorEngine.findOne(selector) : null;
  744. },
  745. getMultipleElementsFromSelector(element) {
  746. const selector = getSelector(element);
  747. return selector ? SelectorEngine.find(selector) : [];
  748. }
  749. };
  750. /**
  751. * --------------------------------------------------------------------------
  752. * Bootstrap util/component-functions.js
  753. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  754. * --------------------------------------------------------------------------
  755. */
  756. const enableDismissTrigger = (component, method = 'hide') => {
  757. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  758. const name = component.NAME;
  759. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  760. if (['A', 'AREA'].includes(this.tagName)) {
  761. event.preventDefault();
  762. }
  763. if (isDisabled(this)) {
  764. return;
  765. }
  766. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  767. const instance = component.getOrCreateInstance(target);
  768. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  769. instance[method]();
  770. });
  771. };
  772. /**
  773. * --------------------------------------------------------------------------
  774. * Bootstrap alert.js
  775. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  776. * --------------------------------------------------------------------------
  777. */
  778. /**
  779. * Constants
  780. */
  781. const NAME$f = 'alert';
  782. const DATA_KEY$a = 'bs.alert';
  783. const EVENT_KEY$b = `.${DATA_KEY$a}`;
  784. const EVENT_CLOSE = `close${EVENT_KEY$b}`;
  785. const EVENT_CLOSED = `closed${EVENT_KEY$b}`;
  786. const CLASS_NAME_FADE$5 = 'fade';
  787. const CLASS_NAME_SHOW$8 = 'show';
  788. /**
  789. * Class definition
  790. */
  791. class Alert extends BaseComponent {
  792. // Getters
  793. static get NAME() {
  794. return NAME$f;
  795. }
  796. // Public
  797. close() {
  798. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  799. if (closeEvent.defaultPrevented) {
  800. return;
  801. }
  802. this._element.classList.remove(CLASS_NAME_SHOW$8);
  803. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5);
  804. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  805. }
  806. // Private
  807. _destroyElement() {
  808. this._element.remove();
  809. EventHandler.trigger(this._element, EVENT_CLOSED);
  810. this.dispose();
  811. }
  812. // Static
  813. static jQueryInterface(config) {
  814. return this.each(function () {
  815. const data = Alert.getOrCreateInstance(this);
  816. if (typeof config !== 'string') {
  817. return;
  818. }
  819. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  820. throw new TypeError(`No method named "${config}"`);
  821. }
  822. data[config](this);
  823. });
  824. }
  825. }
  826. /**
  827. * Data API implementation
  828. */
  829. enableDismissTrigger(Alert, 'close');
  830. /**
  831. * jQuery
  832. */
  833. defineJQueryPlugin(Alert);
  834. /**
  835. * --------------------------------------------------------------------------
  836. * Bootstrap button.js
  837. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  838. * --------------------------------------------------------------------------
  839. */
  840. /**
  841. * Constants
  842. */
  843. const NAME$e = 'button';
  844. const DATA_KEY$9 = 'bs.button';
  845. const EVENT_KEY$a = `.${DATA_KEY$9}`;
  846. const DATA_API_KEY$6 = '.data-api';
  847. const CLASS_NAME_ACTIVE$3 = 'active';
  848. const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]';
  849. const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`;
  850. /**
  851. * Class definition
  852. */
  853. class Button extends BaseComponent {
  854. // Getters
  855. static get NAME() {
  856. return NAME$e;
  857. }
  858. // Public
  859. toggle() {
  860. // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
  861. this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
  862. }
  863. // Static
  864. static jQueryInterface(config) {
  865. return this.each(function () {
  866. const data = Button.getOrCreateInstance(this);
  867. if (config === 'toggle') {
  868. data[config]();
  869. }
  870. });
  871. }
  872. }
  873. /**
  874. * Data API implementation
  875. */
  876. EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
  877. event.preventDefault();
  878. const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
  879. const data = Button.getOrCreateInstance(button);
  880. data.toggle();
  881. });
  882. /**
  883. * jQuery
  884. */
  885. defineJQueryPlugin(Button);
  886. /**
  887. * --------------------------------------------------------------------------
  888. * Bootstrap util/swipe.js
  889. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  890. * --------------------------------------------------------------------------
  891. */
  892. /**
  893. * Constants
  894. */
  895. const NAME$d = 'swipe';
  896. const EVENT_KEY$9 = '.bs.swipe';
  897. const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`;
  898. const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`;
  899. const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`;
  900. const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`;
  901. const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`;
  902. const POINTER_TYPE_TOUCH = 'touch';
  903. const POINTER_TYPE_PEN = 'pen';
  904. const CLASS_NAME_POINTER_EVENT = 'pointer-event';
  905. const SWIPE_THRESHOLD = 40;
  906. const Default$c = {
  907. endCallback: null,
  908. leftCallback: null,
  909. rightCallback: null
  910. };
  911. const DefaultType$c = {
  912. endCallback: '(function|null)',
  913. leftCallback: '(function|null)',
  914. rightCallback: '(function|null)'
  915. };
  916. /**
  917. * Class definition
  918. */
  919. class Swipe extends Config {
  920. constructor(element, config) {
  921. super();
  922. this._element = element;
  923. if (!element || !Swipe.isSupported()) {
  924. return;
  925. }
  926. this._config = this._getConfig(config);
  927. this._deltaX = 0;
  928. this._supportPointerEvents = Boolean(window.PointerEvent);
  929. this._initEvents();
  930. }
  931. // Getters
  932. static get Default() {
  933. return Default$c;
  934. }
  935. static get DefaultType() {
  936. return DefaultType$c;
  937. }
  938. static get NAME() {
  939. return NAME$d;
  940. }
  941. // Public
  942. dispose() {
  943. EventHandler.off(this._element, EVENT_KEY$9);
  944. }
  945. // Private
  946. _start(event) {
  947. if (!this._supportPointerEvents) {
  948. this._deltaX = event.touches[0].clientX;
  949. return;
  950. }
  951. if (this._eventIsPointerPenTouch(event)) {
  952. this._deltaX = event.clientX;
  953. }
  954. }
  955. _end(event) {
  956. if (this._eventIsPointerPenTouch(event)) {
  957. this._deltaX = event.clientX - this._deltaX;
  958. }
  959. this._handleSwipe();
  960. execute(this._config.endCallback);
  961. }
  962. _move(event) {
  963. this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX;
  964. }
  965. _handleSwipe() {
  966. const absDeltaX = Math.abs(this._deltaX);
  967. if (absDeltaX <= SWIPE_THRESHOLD) {
  968. return;
  969. }
  970. const direction = absDeltaX / this._deltaX;
  971. this._deltaX = 0;
  972. if (!direction) {
  973. return;
  974. }
  975. execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
  976. }
  977. _initEvents() {
  978. if (this._supportPointerEvents) {
  979. EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event));
  980. EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event));
  981. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  982. } else {
  983. EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event));
  984. EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event));
  985. EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event));
  986. }
  987. }
  988. _eventIsPointerPenTouch(event) {
  989. return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
  990. }
  991. // Static
  992. static isSupported() {
  993. return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  994. }
  995. }
  996. /**
  997. * --------------------------------------------------------------------------
  998. * Bootstrap carousel.js
  999. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1000. * --------------------------------------------------------------------------
  1001. */
  1002. /**
  1003. * Constants
  1004. */
  1005. const NAME$c = 'carousel';
  1006. const DATA_KEY$8 = 'bs.carousel';
  1007. const EVENT_KEY$8 = `.${DATA_KEY$8}`;
  1008. const DATA_API_KEY$5 = '.data-api';
  1009. const ARROW_LEFT_KEY$1 = 'ArrowLeft';
  1010. const ARROW_RIGHT_KEY$1 = 'ArrowRight';
  1011. const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  1012. const ORDER_NEXT = 'next';
  1013. const ORDER_PREV = 'prev';
  1014. const DIRECTION_LEFT = 'left';
  1015. const DIRECTION_RIGHT = 'right';
  1016. const EVENT_SLIDE = `slide${EVENT_KEY$8}`;
  1017. const EVENT_SLID = `slid${EVENT_KEY$8}`;
  1018. const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`;
  1019. const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`;
  1020. const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`;
  1021. const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`;
  1022. const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1023. const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`;
  1024. const CLASS_NAME_CAROUSEL = 'carousel';
  1025. const CLASS_NAME_ACTIVE$2 = 'active';
  1026. const CLASS_NAME_SLIDE = 'slide';
  1027. const CLASS_NAME_END = 'carousel-item-end';
  1028. const CLASS_NAME_START = 'carousel-item-start';
  1029. const CLASS_NAME_NEXT = 'carousel-item-next';
  1030. const CLASS_NAME_PREV = 'carousel-item-prev';
  1031. const SELECTOR_ACTIVE = '.active';
  1032. const SELECTOR_ITEM = '.carousel-item';
  1033. const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
  1034. const SELECTOR_ITEM_IMG = '.carousel-item img';
  1035. const SELECTOR_INDICATORS = '.carousel-indicators';
  1036. const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
  1037. const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
  1038. const KEY_TO_DIRECTION = {
  1039. [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT,
  1040. [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT
  1041. };
  1042. const Default$b = {
  1043. interval: 5000,
  1044. keyboard: true,
  1045. pause: 'hover',
  1046. ride: false,
  1047. touch: true,
  1048. wrap: true
  1049. };
  1050. const DefaultType$b = {
  1051. interval: '(number|boolean)',
  1052. // TODO:v6 remove boolean support
  1053. keyboard: 'boolean',
  1054. pause: '(string|boolean)',
  1055. ride: '(boolean|string)',
  1056. touch: 'boolean',
  1057. wrap: 'boolean'
  1058. };
  1059. /**
  1060. * Class definition
  1061. */
  1062. class Carousel extends BaseComponent {
  1063. constructor(element, config) {
  1064. super(element, config);
  1065. this._interval = null;
  1066. this._activeElement = null;
  1067. this._isSliding = false;
  1068. this.touchTimeout = null;
  1069. this._swipeHelper = null;
  1070. this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
  1071. this._addEventListeners();
  1072. if (this._config.ride === CLASS_NAME_CAROUSEL) {
  1073. this.cycle();
  1074. }
  1075. }
  1076. // Getters
  1077. static get Default() {
  1078. return Default$b;
  1079. }
  1080. static get DefaultType() {
  1081. return DefaultType$b;
  1082. }
  1083. static get NAME() {
  1084. return NAME$c;
  1085. }
  1086. // Public
  1087. next() {
  1088. this._slide(ORDER_NEXT);
  1089. }
  1090. nextWhenVisible() {
  1091. // FIXME TODO use `document.visibilityState`
  1092. // Don't call next when the page isn't visible
  1093. // or the carousel or its parent isn't visible
  1094. if (!document.hidden && isVisible(this._element)) {
  1095. this.next();
  1096. }
  1097. }
  1098. prev() {
  1099. this._slide(ORDER_PREV);
  1100. }
  1101. pause() {
  1102. if (this._isSliding) {
  1103. triggerTransitionEnd(this._element);
  1104. }
  1105. this._clearInterval();
  1106. }
  1107. cycle() {
  1108. this._clearInterval();
  1109. this._updateInterval();
  1110. this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval);
  1111. }
  1112. _maybeEnableCycle() {
  1113. if (!this._config.ride) {
  1114. return;
  1115. }
  1116. if (this._isSliding) {
  1117. EventHandler.one(this._element, EVENT_SLID, () => this.cycle());
  1118. return;
  1119. }
  1120. this.cycle();
  1121. }
  1122. to(index) {
  1123. const items = this._getItems();
  1124. if (index > items.length - 1 || index < 0) {
  1125. return;
  1126. }
  1127. if (this._isSliding) {
  1128. EventHandler.one(this._element, EVENT_SLID, () => this.to(index));
  1129. return;
  1130. }
  1131. const activeIndex = this._getItemIndex(this._getActive());
  1132. if (activeIndex === index) {
  1133. return;
  1134. }
  1135. const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
  1136. this._slide(order, items[index]);
  1137. }
  1138. dispose() {
  1139. if (this._swipeHelper) {
  1140. this._swipeHelper.dispose();
  1141. }
  1142. super.dispose();
  1143. }
  1144. // Private
  1145. _configAfterMerge(config) {
  1146. config.defaultInterval = config.interval;
  1147. return config;
  1148. }
  1149. _addEventListeners() {
  1150. if (this._config.keyboard) {
  1151. EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event));
  1152. }
  1153. if (this._config.pause === 'hover') {
  1154. EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause());
  1155. EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
  1156. }
  1157. if (this._config.touch && Swipe.isSupported()) {
  1158. this._addTouchEventListeners();
  1159. }
  1160. }
  1161. _addTouchEventListeners() {
  1162. for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) {
  1163. EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault());
  1164. }
  1165. const endCallBack = () => {
  1166. if (this._config.pause !== 'hover') {
  1167. return;
  1168. }
  1169. // If it's a touch-enabled device, mouseenter/leave are fired as
  1170. // part of the mouse compatibility events on first tap - the carousel
  1171. // would stop cycling until user tapped out of it;
  1172. // here, we listen for touchend, explicitly pause the carousel
  1173. // (as if it's the second time we tap on it, mouseenter compat event
  1174. // is NOT fired) and after a timeout (to allow for mouse compatibility
  1175. // events to fire) we explicitly restart cycling
  1176. this.pause();
  1177. if (this.touchTimeout) {
  1178. clearTimeout(this.touchTimeout);
  1179. }
  1180. this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
  1181. };
  1182. const swipeConfig = {
  1183. leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)),
  1184. rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)),
  1185. endCallback: endCallBack
  1186. };
  1187. this._swipeHelper = new Swipe(this._element, swipeConfig);
  1188. }
  1189. _keydown(event) {
  1190. if (/input|textarea/i.test(event.target.tagName)) {
  1191. return;
  1192. }
  1193. const direction = KEY_TO_DIRECTION[event.key];
  1194. if (direction) {
  1195. event.preventDefault();
  1196. this._slide(this._directionToOrder(direction));
  1197. }
  1198. }
  1199. _getItemIndex(element) {
  1200. return this._getItems().indexOf(element);
  1201. }
  1202. _setActiveIndicatorElement(index) {
  1203. if (!this._indicatorsElement) {
  1204. return;
  1205. }
  1206. const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
  1207. activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2);
  1208. activeIndicator.removeAttribute('aria-current');
  1209. const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
  1210. if (newActiveIndicator) {
  1211. newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2);
  1212. newActiveIndicator.setAttribute('aria-current', 'true');
  1213. }
  1214. }
  1215. _updateInterval() {
  1216. const element = this._activeElement || this._getActive();
  1217. if (!element) {
  1218. return;
  1219. }
  1220. const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
  1221. this._config.interval = elementInterval || this._config.defaultInterval;
  1222. }
  1223. _slide(order, element = null) {
  1224. if (this._isSliding) {
  1225. return;
  1226. }
  1227. const activeElement = this._getActive();
  1228. const isNext = order === ORDER_NEXT;
  1229. const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap);
  1230. if (nextElement === activeElement) {
  1231. return;
  1232. }
  1233. const nextElementIndex = this._getItemIndex(nextElement);
  1234. const triggerEvent = eventName => {
  1235. return EventHandler.trigger(this._element, eventName, {
  1236. relatedTarget: nextElement,
  1237. direction: this._orderToDirection(order),
  1238. from: this._getItemIndex(activeElement),
  1239. to: nextElementIndex
  1240. });
  1241. };
  1242. const slideEvent = triggerEvent(EVENT_SLIDE);
  1243. if (slideEvent.defaultPrevented) {
  1244. return;
  1245. }
  1246. if (!activeElement || !nextElement) {
  1247. // Some weirdness is happening, so we bail
  1248. // TODO: change tests that use empty divs to avoid this check
  1249. return;
  1250. }
  1251. const isCycling = Boolean(this._interval);
  1252. this.pause();
  1253. this._isSliding = true;
  1254. this._setActiveIndicatorElement(nextElementIndex);
  1255. this._activeElement = nextElement;
  1256. const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
  1257. const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
  1258. nextElement.classList.add(orderClassName);
  1259. reflow(nextElement);
  1260. activeElement.classList.add(directionalClassName);
  1261. nextElement.classList.add(directionalClassName);
  1262. const completeCallBack = () => {
  1263. nextElement.classList.remove(directionalClassName, orderClassName);
  1264. nextElement.classList.add(CLASS_NAME_ACTIVE$2);
  1265. activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName);
  1266. this._isSliding = false;
  1267. triggerEvent(EVENT_SLID);
  1268. };
  1269. this._queueCallback(completeCallBack, activeElement, this._isAnimated());
  1270. if (isCycling) {
  1271. this.cycle();
  1272. }
  1273. }
  1274. _isAnimated() {
  1275. return this._element.classList.contains(CLASS_NAME_SLIDE);
  1276. }
  1277. _getActive() {
  1278. return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
  1279. }
  1280. _getItems() {
  1281. return SelectorEngine.find(SELECTOR_ITEM, this._element);
  1282. }
  1283. _clearInterval() {
  1284. if (this._interval) {
  1285. clearInterval(this._interval);
  1286. this._interval = null;
  1287. }
  1288. }
  1289. _directionToOrder(direction) {
  1290. if (isRTL()) {
  1291. return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
  1292. }
  1293. return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
  1294. }
  1295. _orderToDirection(order) {
  1296. if (isRTL()) {
  1297. return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
  1298. }
  1299. return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
  1300. }
  1301. // Static
  1302. static jQueryInterface(config) {
  1303. return this.each(function () {
  1304. const data = Carousel.getOrCreateInstance(this, config);
  1305. if (typeof config === 'number') {
  1306. data.to(config);
  1307. return;
  1308. }
  1309. if (typeof config === 'string') {
  1310. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  1311. throw new TypeError(`No method named "${config}"`);
  1312. }
  1313. data[config]();
  1314. }
  1315. });
  1316. }
  1317. }
  1318. /**
  1319. * Data API implementation
  1320. */
  1321. EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) {
  1322. const target = SelectorEngine.getElementFromSelector(this);
  1323. if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
  1324. return;
  1325. }
  1326. event.preventDefault();
  1327. const carousel = Carousel.getOrCreateInstance(target);
  1328. const slideIndex = this.getAttribute('data-bs-slide-to');
  1329. if (slideIndex) {
  1330. carousel.to(slideIndex);
  1331. carousel._maybeEnableCycle();
  1332. return;
  1333. }
  1334. if (Manipulator.getDataAttribute(this, 'slide') === 'next') {
  1335. carousel.next();
  1336. carousel._maybeEnableCycle();
  1337. return;
  1338. }
  1339. carousel.prev();
  1340. carousel._maybeEnableCycle();
  1341. });
  1342. EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
  1343. const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
  1344. for (const carousel of carousels) {
  1345. Carousel.getOrCreateInstance(carousel);
  1346. }
  1347. });
  1348. /**
  1349. * jQuery
  1350. */
  1351. defineJQueryPlugin(Carousel);
  1352. /**
  1353. * --------------------------------------------------------------------------
  1354. * Bootstrap collapse.js
  1355. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  1356. * --------------------------------------------------------------------------
  1357. */
  1358. /**
  1359. * Constants
  1360. */
  1361. const NAME$b = 'collapse';
  1362. const DATA_KEY$7 = 'bs.collapse';
  1363. const EVENT_KEY$7 = `.${DATA_KEY$7}`;
  1364. const DATA_API_KEY$4 = '.data-api';
  1365. const EVENT_SHOW$6 = `show${EVENT_KEY$7}`;
  1366. const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`;
  1367. const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`;
  1368. const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`;
  1369. const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
  1370. const CLASS_NAME_SHOW$7 = 'show';
  1371. const CLASS_NAME_COLLAPSE = 'collapse';
  1372. const CLASS_NAME_COLLAPSING = 'collapsing';
  1373. const CLASS_NAME_COLLAPSED = 'collapsed';
  1374. const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
  1375. const CLASS_NAME_HORIZONTAL = 'collapse-horizontal';
  1376. const WIDTH = 'width';
  1377. const HEIGHT = 'height';
  1378. const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing';
  1379. const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]';
  1380. const Default$a = {
  1381. parent: null,
  1382. toggle: true
  1383. };
  1384. const DefaultType$a = {
  1385. parent: '(null|element)',
  1386. toggle: 'boolean'
  1387. };
  1388. /**
  1389. * Class definition
  1390. */
  1391. class Collapse extends BaseComponent {
  1392. constructor(element, config) {
  1393. super(element, config);
  1394. this._isTransitioning = false;
  1395. this._triggerArray = [];
  1396. const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4);
  1397. for (const elem of toggleList) {
  1398. const selector = SelectorEngine.getSelectorFromElement(elem);
  1399. const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element);
  1400. if (selector !== null && filterElement.length) {
  1401. this._triggerArray.push(elem);
  1402. }
  1403. }
  1404. this._initializeChildren();
  1405. if (!this._config.parent) {
  1406. this._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
  1407. }
  1408. if (this._config.toggle) {
  1409. this.toggle();
  1410. }
  1411. }
  1412. // Getters
  1413. static get Default() {
  1414. return Default$a;
  1415. }
  1416. static get DefaultType() {
  1417. return DefaultType$a;
  1418. }
  1419. static get NAME() {
  1420. return NAME$b;
  1421. }
  1422. // Public
  1423. toggle() {
  1424. if (this._isShown()) {
  1425. this.hide();
  1426. } else {
  1427. this.show();
  1428. }
  1429. }
  1430. show() {
  1431. if (this._isTransitioning || this._isShown()) {
  1432. return;
  1433. }
  1434. let activeChildren = [];
  1435. // find active children
  1436. if (this._config.parent) {
  1437. activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
  1438. toggle: false
  1439. }));
  1440. }
  1441. if (activeChildren.length && activeChildren[0]._isTransitioning) {
  1442. return;
  1443. }
  1444. const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6);
  1445. if (startEvent.defaultPrevented) {
  1446. return;
  1447. }
  1448. for (const activeInstance of activeChildren) {
  1449. activeInstance.hide();
  1450. }
  1451. const dimension = this._getDimension();
  1452. this._element.classList.remove(CLASS_NAME_COLLAPSE);
  1453. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1454. this._element.style[dimension] = 0;
  1455. this._addAriaAndCollapsedClass(this._triggerArray, true);
  1456. this._isTransitioning = true;
  1457. const complete = () => {
  1458. this._isTransitioning = false;
  1459. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1460. this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1461. this._element.style[dimension] = '';
  1462. EventHandler.trigger(this._element, EVENT_SHOWN$6);
  1463. };
  1464. const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  1465. const scrollSize = `scroll${capitalizedDimension}`;
  1466. this._queueCallback(complete, this._element, true);
  1467. this._element.style[dimension] = `${this._element[scrollSize]}px`;
  1468. }
  1469. hide() {
  1470. if (this._isTransitioning || !this._isShown()) {
  1471. return;
  1472. }
  1473. const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6);
  1474. if (startEvent.defaultPrevented) {
  1475. return;
  1476. }
  1477. const dimension = this._getDimension();
  1478. this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
  1479. reflow(this._element);
  1480. this._element.classList.add(CLASS_NAME_COLLAPSING);
  1481. this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7);
  1482. for (const trigger of this._triggerArray) {
  1483. const element = SelectorEngine.getElementFromSelector(trigger);
  1484. if (element && !this._isShown(element)) {
  1485. this._addAriaAndCollapsedClass([trigger], false);
  1486. }
  1487. }
  1488. this._isTransitioning = true;
  1489. const complete = () => {
  1490. this._isTransitioning = false;
  1491. this._element.classList.remove(CLASS_NAME_COLLAPSING);
  1492. this._element.classList.add(CLASS_NAME_COLLAPSE);
  1493. EventHandler.trigger(this._element, EVENT_HIDDEN$6);
  1494. };
  1495. this._element.style[dimension] = '';
  1496. this._queueCallback(complete, this._element, true);
  1497. }
  1498. _isShown(element = this._element) {
  1499. return element.classList.contains(CLASS_NAME_SHOW$7);
  1500. }
  1501. // Private
  1502. _configAfterMerge(config) {
  1503. config.toggle = Boolean(config.toggle); // Coerce string values
  1504. config.parent = getElement(config.parent);
  1505. return config;
  1506. }
  1507. _getDimension() {
  1508. return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
  1509. }
  1510. _initializeChildren() {
  1511. if (!this._config.parent) {
  1512. return;
  1513. }
  1514. const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4);
  1515. for (const element of children) {
  1516. const selected = SelectorEngine.getElementFromSelector(element);
  1517. if (selected) {
  1518. this._addAriaAndCollapsedClass([element], this._isShown(selected));
  1519. }
  1520. }
  1521. }
  1522. _getFirstLevelChildren(selector) {
  1523. const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
  1524. // remove children if greater depth
  1525. return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element));
  1526. }
  1527. _addAriaAndCollapsedClass(triggerArray, isOpen) {
  1528. if (!triggerArray.length) {
  1529. return;
  1530. }
  1531. for (const element of triggerArray) {
  1532. element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
  1533. element.setAttribute('aria-expanded', isOpen);
  1534. }
  1535. }
  1536. // Static
  1537. static jQueryInterface(config) {
  1538. const _config = {};
  1539. if (typeof config === 'string' && /show|hide/.test(config)) {
  1540. _config.toggle = false;
  1541. }
  1542. return this.each(function () {
  1543. const data = Collapse.getOrCreateInstance(this, _config);
  1544. if (typeof config === 'string') {
  1545. if (typeof data[config] === 'undefined') {
  1546. throw new TypeError(`No method named "${config}"`);
  1547. }
  1548. data[config]();
  1549. }
  1550. });
  1551. }
  1552. }
  1553. /**
  1554. * Data API implementation
  1555. */
  1556. EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) {
  1557. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  1558. if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
  1559. event.preventDefault();
  1560. }
  1561. for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) {
  1562. Collapse.getOrCreateInstance(element, {
  1563. toggle: false
  1564. }).toggle();
  1565. }
  1566. });
  1567. /**
  1568. * jQuery
  1569. */
  1570. defineJQueryPlugin(Collapse);
  1571. var top = 'top';
  1572. var bottom = 'bottom';
  1573. var right = 'right';
  1574. var left = 'left';
  1575. var auto = 'auto';
  1576. var basePlacements = [top, bottom, right, left];
  1577. var start = 'start';
  1578. var end = 'end';
  1579. var clippingParents = 'clippingParents';
  1580. var viewport = 'viewport';
  1581. var popper = 'popper';
  1582. var reference = 'reference';
  1583. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  1584. return acc.concat([placement + "-" + start, placement + "-" + end]);
  1585. }, []);
  1586. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  1587. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  1588. }, []); // modifiers that need to read the DOM
  1589. var beforeRead = 'beforeRead';
  1590. var read = 'read';
  1591. var afterRead = 'afterRead'; // pure-logic modifiers
  1592. var beforeMain = 'beforeMain';
  1593. var main = 'main';
  1594. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  1595. var beforeWrite = 'beforeWrite';
  1596. var write = 'write';
  1597. var afterWrite = 'afterWrite';
  1598. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  1599. function getNodeName(element) {
  1600. return element ? (element.nodeName || '').toLowerCase() : null;
  1601. }
  1602. function getWindow(node) {
  1603. if (node == null) {
  1604. return window;
  1605. }
  1606. if (node.toString() !== '[object Window]') {
  1607. var ownerDocument = node.ownerDocument;
  1608. return ownerDocument ? ownerDocument.defaultView || window : window;
  1609. }
  1610. return node;
  1611. }
  1612. function isElement(node) {
  1613. var OwnElement = getWindow(node).Element;
  1614. return node instanceof OwnElement || node instanceof Element;
  1615. }
  1616. function isHTMLElement(node) {
  1617. var OwnElement = getWindow(node).HTMLElement;
  1618. return node instanceof OwnElement || node instanceof HTMLElement;
  1619. }
  1620. function isShadowRoot(node) {
  1621. // IE 11 has no ShadowRoot
  1622. if (typeof ShadowRoot === 'undefined') {
  1623. return false;
  1624. }
  1625. var OwnElement = getWindow(node).ShadowRoot;
  1626. return node instanceof OwnElement || node instanceof ShadowRoot;
  1627. }
  1628. // and applies them to the HTMLElements such as popper and arrow
  1629. function applyStyles(_ref) {
  1630. var state = _ref.state;
  1631. Object.keys(state.elements).forEach(function (name) {
  1632. var style = state.styles[name] || {};
  1633. var attributes = state.attributes[name] || {};
  1634. var element = state.elements[name]; // arrow is optional + virtual elements
  1635. if (!isHTMLElement(element) || !getNodeName(element)) {
  1636. return;
  1637. } // Flow doesn't support to extend this property, but it's the most
  1638. // effective way to apply styles to an HTMLElement
  1639. // $FlowFixMe[cannot-write]
  1640. Object.assign(element.style, style);
  1641. Object.keys(attributes).forEach(function (name) {
  1642. var value = attributes[name];
  1643. if (value === false) {
  1644. element.removeAttribute(name);
  1645. } else {
  1646. element.setAttribute(name, value === true ? '' : value);
  1647. }
  1648. });
  1649. });
  1650. }
  1651. function effect$2(_ref2) {
  1652. var state = _ref2.state;
  1653. var initialStyles = {
  1654. popper: {
  1655. position: state.options.strategy,
  1656. left: '0',
  1657. top: '0',
  1658. margin: '0'
  1659. },
  1660. arrow: {
  1661. position: 'absolute'
  1662. },
  1663. reference: {}
  1664. };
  1665. Object.assign(state.elements.popper.style, initialStyles.popper);
  1666. state.styles = initialStyles;
  1667. if (state.elements.arrow) {
  1668. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  1669. }
  1670. return function () {
  1671. Object.keys(state.elements).forEach(function (name) {
  1672. var element = state.elements[name];
  1673. var attributes = state.attributes[name] || {};
  1674. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  1675. var style = styleProperties.reduce(function (style, property) {
  1676. style[property] = '';
  1677. return style;
  1678. }, {}); // arrow is optional + virtual elements
  1679. if (!isHTMLElement(element) || !getNodeName(element)) {
  1680. return;
  1681. }
  1682. Object.assign(element.style, style);
  1683. Object.keys(attributes).forEach(function (attribute) {
  1684. element.removeAttribute(attribute);
  1685. });
  1686. });
  1687. };
  1688. } // eslint-disable-next-line import/no-unused-modules
  1689. const applyStyles$1 = {
  1690. name: 'applyStyles',
  1691. enabled: true,
  1692. phase: 'write',
  1693. fn: applyStyles,
  1694. effect: effect$2,
  1695. requires: ['computeStyles']
  1696. };
  1697. function getBasePlacement(placement) {
  1698. return placement.split('-')[0];
  1699. }
  1700. var max = Math.max;
  1701. var min = Math.min;
  1702. var round = Math.round;
  1703. function getUAString() {
  1704. var uaData = navigator.userAgentData;
  1705. if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
  1706. return uaData.brands.map(function (item) {
  1707. return item.brand + "/" + item.version;
  1708. }).join(' ');
  1709. }
  1710. return navigator.userAgent;
  1711. }
  1712. function isLayoutViewport() {
  1713. return !/^((?!chrome|android).)*safari/i.test(getUAString());
  1714. }
  1715. function getBoundingClientRect(element, includeScale, isFixedStrategy) {
  1716. if (includeScale === void 0) {
  1717. includeScale = false;
  1718. }
  1719. if (isFixedStrategy === void 0) {
  1720. isFixedStrategy = false;
  1721. }
  1722. var clientRect = element.getBoundingClientRect();
  1723. var scaleX = 1;
  1724. var scaleY = 1;
  1725. if (includeScale && isHTMLElement(element)) {
  1726. scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
  1727. scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
  1728. }
  1729. var _ref = isElement(element) ? getWindow(element) : window,
  1730. visualViewport = _ref.visualViewport;
  1731. var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
  1732. var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
  1733. var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
  1734. var width = clientRect.width / scaleX;
  1735. var height = clientRect.height / scaleY;
  1736. return {
  1737. width: width,
  1738. height: height,
  1739. top: y,
  1740. right: x + width,
  1741. bottom: y + height,
  1742. left: x,
  1743. x: x,
  1744. y: y
  1745. };
  1746. }
  1747. // means it doesn't take into account transforms.
  1748. function getLayoutRect(element) {
  1749. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  1750. // Fixes https://github.com/popperjs/popper-core/issues/1223
  1751. var width = element.offsetWidth;
  1752. var height = element.offsetHeight;
  1753. if (Math.abs(clientRect.width - width) <= 1) {
  1754. width = clientRect.width;
  1755. }
  1756. if (Math.abs(clientRect.height - height) <= 1) {
  1757. height = clientRect.height;
  1758. }
  1759. return {
  1760. x: element.offsetLeft,
  1761. y: element.offsetTop,
  1762. width: width,
  1763. height: height
  1764. };
  1765. }
  1766. function contains(parent, child) {
  1767. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  1768. if (parent.contains(child)) {
  1769. return true;
  1770. } // then fallback to custom implementation with Shadow DOM support
  1771. else if (rootNode && isShadowRoot(rootNode)) {
  1772. var next = child;
  1773. do {
  1774. if (next && parent.isSameNode(next)) {
  1775. return true;
  1776. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  1777. next = next.parentNode || next.host;
  1778. } while (next);
  1779. } // Give up, the result is false
  1780. return false;
  1781. }
  1782. function getComputedStyle$1(element) {
  1783. return getWindow(element).getComputedStyle(element);
  1784. }
  1785. function isTableElement(element) {
  1786. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  1787. }
  1788. function getDocumentElement(element) {
  1789. // $FlowFixMe[incompatible-return]: assume body is always available
  1790. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  1791. element.document) || window.document).documentElement;
  1792. }
  1793. function getParentNode(element) {
  1794. if (getNodeName(element) === 'html') {
  1795. return element;
  1796. }
  1797. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  1798. // $FlowFixMe[incompatible-return]
  1799. // $FlowFixMe[prop-missing]
  1800. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  1801. element.parentNode || ( // DOM Element detected
  1802. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  1803. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  1804. getDocumentElement(element) // fallback
  1805. );
  1806. }
  1807. function getTrueOffsetParent(element) {
  1808. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  1809. getComputedStyle$1(element).position === 'fixed') {
  1810. return null;
  1811. }
  1812. return element.offsetParent;
  1813. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  1814. // return the containing block
  1815. function getContainingBlock(element) {
  1816. var isFirefox = /firefox/i.test(getUAString());
  1817. var isIE = /Trident/i.test(getUAString());
  1818. if (isIE && isHTMLElement(element)) {
  1819. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  1820. var elementCss = getComputedStyle$1(element);
  1821. if (elementCss.position === 'fixed') {
  1822. return null;
  1823. }
  1824. }
  1825. var currentNode = getParentNode(element);
  1826. if (isShadowRoot(currentNode)) {
  1827. currentNode = currentNode.host;
  1828. }
  1829. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  1830. var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  1831. // create a containing block.
  1832. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  1833. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  1834. return currentNode;
  1835. } else {
  1836. currentNode = currentNode.parentNode;
  1837. }
  1838. }
  1839. return null;
  1840. } // Gets the closest ancestor positioned element. Handles some edge cases,
  1841. // such as table ancestors and cross browser bugs.
  1842. function getOffsetParent(element) {
  1843. var window = getWindow(element);
  1844. var offsetParent = getTrueOffsetParent(element);
  1845. while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
  1846. offsetParent = getTrueOffsetParent(offsetParent);
  1847. }
  1848. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
  1849. return window;
  1850. }
  1851. return offsetParent || getContainingBlock(element) || window;
  1852. }
  1853. function getMainAxisFromPlacement(placement) {
  1854. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  1855. }
  1856. function within(min$1, value, max$1) {
  1857. return max(min$1, min(value, max$1));
  1858. }
  1859. function withinMaxClamp(min, value, max) {
  1860. var v = within(min, value, max);
  1861. return v > max ? max : v;
  1862. }
  1863. function getFreshSideObject() {
  1864. return {
  1865. top: 0,
  1866. right: 0,
  1867. bottom: 0,
  1868. left: 0
  1869. };
  1870. }
  1871. function mergePaddingObject(paddingObject) {
  1872. return Object.assign({}, getFreshSideObject(), paddingObject);
  1873. }
  1874. function expandToHashMap(value, keys) {
  1875. return keys.reduce(function (hashMap, key) {
  1876. hashMap[key] = value;
  1877. return hashMap;
  1878. }, {});
  1879. }
  1880. var toPaddingObject = function toPaddingObject(padding, state) {
  1881. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  1882. placement: state.placement
  1883. })) : padding;
  1884. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  1885. };
  1886. function arrow(_ref) {
  1887. var _state$modifiersData$;
  1888. var state = _ref.state,
  1889. name = _ref.name,
  1890. options = _ref.options;
  1891. var arrowElement = state.elements.arrow;
  1892. var popperOffsets = state.modifiersData.popperOffsets;
  1893. var basePlacement = getBasePlacement(state.placement);
  1894. var axis = getMainAxisFromPlacement(basePlacement);
  1895. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  1896. var len = isVertical ? 'height' : 'width';
  1897. if (!arrowElement || !popperOffsets) {
  1898. return;
  1899. }
  1900. var paddingObject = toPaddingObject(options.padding, state);
  1901. var arrowRect = getLayoutRect(arrowElement);
  1902. var minProp = axis === 'y' ? top : left;
  1903. var maxProp = axis === 'y' ? bottom : right;
  1904. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  1905. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  1906. var arrowOffsetParent = getOffsetParent(arrowElement);
  1907. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  1908. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  1909. // outside of the popper bounds
  1910. var min = paddingObject[minProp];
  1911. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  1912. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  1913. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  1914. var axisProp = axis;
  1915. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  1916. }
  1917. function effect$1(_ref2) {
  1918. var state = _ref2.state,
  1919. options = _ref2.options;
  1920. var _options$element = options.element,
  1921. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  1922. if (arrowElement == null) {
  1923. return;
  1924. } // CSS selector
  1925. if (typeof arrowElement === 'string') {
  1926. arrowElement = state.elements.popper.querySelector(arrowElement);
  1927. if (!arrowElement) {
  1928. return;
  1929. }
  1930. }
  1931. if (!contains(state.elements.popper, arrowElement)) {
  1932. return;
  1933. }
  1934. state.elements.arrow = arrowElement;
  1935. } // eslint-disable-next-line import/no-unused-modules
  1936. const arrow$1 = {
  1937. name: 'arrow',
  1938. enabled: true,
  1939. phase: 'main',
  1940. fn: arrow,
  1941. effect: effect$1,
  1942. requires: ['popperOffsets'],
  1943. requiresIfExists: ['preventOverflow']
  1944. };
  1945. function getVariation(placement) {
  1946. return placement.split('-')[1];
  1947. }
  1948. var unsetSides = {
  1949. top: 'auto',
  1950. right: 'auto',
  1951. bottom: 'auto',
  1952. left: 'auto'
  1953. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  1954. // Zooming can change the DPR, but it seems to report a value that will
  1955. // cleanly divide the values into the appropriate subpixels.
  1956. function roundOffsetsByDPR(_ref, win) {
  1957. var x = _ref.x,
  1958. y = _ref.y;
  1959. var dpr = win.devicePixelRatio || 1;
  1960. return {
  1961. x: round(x * dpr) / dpr || 0,
  1962. y: round(y * dpr) / dpr || 0
  1963. };
  1964. }
  1965. function mapToStyles(_ref2) {
  1966. var _Object$assign2;
  1967. var popper = _ref2.popper,
  1968. popperRect = _ref2.popperRect,
  1969. placement = _ref2.placement,
  1970. variation = _ref2.variation,
  1971. offsets = _ref2.offsets,
  1972. position = _ref2.position,
  1973. gpuAcceleration = _ref2.gpuAcceleration,
  1974. adaptive = _ref2.adaptive,
  1975. roundOffsets = _ref2.roundOffsets,
  1976. isFixed = _ref2.isFixed;
  1977. var _offsets$x = offsets.x,
  1978. x = _offsets$x === void 0 ? 0 : _offsets$x,
  1979. _offsets$y = offsets.y,
  1980. y = _offsets$y === void 0 ? 0 : _offsets$y;
  1981. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  1982. x: x,
  1983. y: y
  1984. }) : {
  1985. x: x,
  1986. y: y
  1987. };
  1988. x = _ref3.x;
  1989. y = _ref3.y;
  1990. var hasX = offsets.hasOwnProperty('x');
  1991. var hasY = offsets.hasOwnProperty('y');
  1992. var sideX = left;
  1993. var sideY = top;
  1994. var win = window;
  1995. if (adaptive) {
  1996. var offsetParent = getOffsetParent(popper);
  1997. var heightProp = 'clientHeight';
  1998. var widthProp = 'clientWidth';
  1999. if (offsetParent === getWindow(popper)) {
  2000. offsetParent = getDocumentElement(popper);
  2001. if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
  2002. heightProp = 'scrollHeight';
  2003. widthProp = 'scrollWidth';
  2004. }
  2005. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  2006. offsetParent = offsetParent;
  2007. if (placement === top || (placement === left || placement === right) && variation === end) {
  2008. sideY = bottom;
  2009. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  2010. offsetParent[heightProp];
  2011. y -= offsetY - popperRect.height;
  2012. y *= gpuAcceleration ? 1 : -1;
  2013. }
  2014. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  2015. sideX = right;
  2016. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  2017. offsetParent[widthProp];
  2018. x -= offsetX - popperRect.width;
  2019. x *= gpuAcceleration ? 1 : -1;
  2020. }
  2021. }
  2022. var commonStyles = Object.assign({
  2023. position: position
  2024. }, adaptive && unsetSides);
  2025. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  2026. x: x,
  2027. y: y
  2028. }, getWindow(popper)) : {
  2029. x: x,
  2030. y: y
  2031. };
  2032. x = _ref4.x;
  2033. y = _ref4.y;
  2034. if (gpuAcceleration) {
  2035. var _Object$assign;
  2036. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  2037. }
  2038. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  2039. }
  2040. function computeStyles(_ref5) {
  2041. var state = _ref5.state,
  2042. options = _ref5.options;
  2043. var _options$gpuAccelerat = options.gpuAcceleration,
  2044. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  2045. _options$adaptive = options.adaptive,
  2046. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  2047. _options$roundOffsets = options.roundOffsets,
  2048. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  2049. var commonStyles = {
  2050. placement: getBasePlacement(state.placement),
  2051. variation: getVariation(state.placement),
  2052. popper: state.elements.popper,
  2053. popperRect: state.rects.popper,
  2054. gpuAcceleration: gpuAcceleration,
  2055. isFixed: state.options.strategy === 'fixed'
  2056. };
  2057. if (state.modifiersData.popperOffsets != null) {
  2058. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  2059. offsets: state.modifiersData.popperOffsets,
  2060. position: state.options.strategy,
  2061. adaptive: adaptive,
  2062. roundOffsets: roundOffsets
  2063. })));
  2064. }
  2065. if (state.modifiersData.arrow != null) {
  2066. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  2067. offsets: state.modifiersData.arrow,
  2068. position: 'absolute',
  2069. adaptive: false,
  2070. roundOffsets: roundOffsets
  2071. })));
  2072. }
  2073. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2074. 'data-popper-placement': state.placement
  2075. });
  2076. } // eslint-disable-next-line import/no-unused-modules
  2077. const computeStyles$1 = {
  2078. name: 'computeStyles',
  2079. enabled: true,
  2080. phase: 'beforeWrite',
  2081. fn: computeStyles,
  2082. data: {}
  2083. };
  2084. var passive = {
  2085. passive: true
  2086. };
  2087. function effect(_ref) {
  2088. var state = _ref.state,
  2089. instance = _ref.instance,
  2090. options = _ref.options;
  2091. var _options$scroll = options.scroll,
  2092. scroll = _options$scroll === void 0 ? true : _options$scroll,
  2093. _options$resize = options.resize,
  2094. resize = _options$resize === void 0 ? true : _options$resize;
  2095. var window = getWindow(state.elements.popper);
  2096. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  2097. if (scroll) {
  2098. scrollParents.forEach(function (scrollParent) {
  2099. scrollParent.addEventListener('scroll', instance.update, passive);
  2100. });
  2101. }
  2102. if (resize) {
  2103. window.addEventListener('resize', instance.update, passive);
  2104. }
  2105. return function () {
  2106. if (scroll) {
  2107. scrollParents.forEach(function (scrollParent) {
  2108. scrollParent.removeEventListener('scroll', instance.update, passive);
  2109. });
  2110. }
  2111. if (resize) {
  2112. window.removeEventListener('resize', instance.update, passive);
  2113. }
  2114. };
  2115. } // eslint-disable-next-line import/no-unused-modules
  2116. const eventListeners = {
  2117. name: 'eventListeners',
  2118. enabled: true,
  2119. phase: 'write',
  2120. fn: function fn() {},
  2121. effect: effect,
  2122. data: {}
  2123. };
  2124. var hash$1 = {
  2125. left: 'right',
  2126. right: 'left',
  2127. bottom: 'top',
  2128. top: 'bottom'
  2129. };
  2130. function getOppositePlacement(placement) {
  2131. return placement.replace(/left|right|bottom|top/g, function (matched) {
  2132. return hash$1[matched];
  2133. });
  2134. }
  2135. var hash = {
  2136. start: 'end',
  2137. end: 'start'
  2138. };
  2139. function getOppositeVariationPlacement(placement) {
  2140. return placement.replace(/start|end/g, function (matched) {
  2141. return hash[matched];
  2142. });
  2143. }
  2144. function getWindowScroll(node) {
  2145. var win = getWindow(node);
  2146. var scrollLeft = win.pageXOffset;
  2147. var scrollTop = win.pageYOffset;
  2148. return {
  2149. scrollLeft: scrollLeft,
  2150. scrollTop: scrollTop
  2151. };
  2152. }
  2153. function getWindowScrollBarX(element) {
  2154. // If <html> has a CSS width greater than the viewport, then this will be
  2155. // incorrect for RTL.
  2156. // Popper 1 is broken in this case and never had a bug report so let's assume
  2157. // it's not an issue. I don't think anyone ever specifies width on <html>
  2158. // anyway.
  2159. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  2160. // this (e.g. Edge 2019, IE11, Safari)
  2161. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  2162. }
  2163. function getViewportRect(element, strategy) {
  2164. var win = getWindow(element);
  2165. var html = getDocumentElement(element);
  2166. var visualViewport = win.visualViewport;
  2167. var width = html.clientWidth;
  2168. var height = html.clientHeight;
  2169. var x = 0;
  2170. var y = 0;
  2171. if (visualViewport) {
  2172. width = visualViewport.width;
  2173. height = visualViewport.height;
  2174. var layoutViewport = isLayoutViewport();
  2175. if (layoutViewport || !layoutViewport && strategy === 'fixed') {
  2176. x = visualViewport.offsetLeft;
  2177. y = visualViewport.offsetTop;
  2178. }
  2179. }
  2180. return {
  2181. width: width,
  2182. height: height,
  2183. x: x + getWindowScrollBarX(element),
  2184. y: y
  2185. };
  2186. }
  2187. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  2188. function getDocumentRect(element) {
  2189. var _element$ownerDocumen;
  2190. var html = getDocumentElement(element);
  2191. var winScroll = getWindowScroll(element);
  2192. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  2193. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  2194. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  2195. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  2196. var y = -winScroll.scrollTop;
  2197. if (getComputedStyle$1(body || html).direction === 'rtl') {
  2198. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  2199. }
  2200. return {
  2201. width: width,
  2202. height: height,
  2203. x: x,
  2204. y: y
  2205. };
  2206. }
  2207. function isScrollParent(element) {
  2208. // Firefox wants us to check `-x` and `-y` variations as well
  2209. var _getComputedStyle = getComputedStyle$1(element),
  2210. overflow = _getComputedStyle.overflow,
  2211. overflowX = _getComputedStyle.overflowX,
  2212. overflowY = _getComputedStyle.overflowY;
  2213. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  2214. }
  2215. function getScrollParent(node) {
  2216. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  2217. // $FlowFixMe[incompatible-return]: assume body is always available
  2218. return node.ownerDocument.body;
  2219. }
  2220. if (isHTMLElement(node) && isScrollParent(node)) {
  2221. return node;
  2222. }
  2223. return getScrollParent(getParentNode(node));
  2224. }
  2225. /*
  2226. given a DOM element, return the list of all scroll parents, up the list of ancesors
  2227. until we get to the top window object. This list is what we attach scroll listeners
  2228. to, because if any of these parent elements scroll, we'll need to re-calculate the
  2229. reference element's position.
  2230. */
  2231. function listScrollParents(element, list) {
  2232. var _element$ownerDocumen;
  2233. if (list === void 0) {
  2234. list = [];
  2235. }
  2236. var scrollParent = getScrollParent(element);
  2237. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  2238. var win = getWindow(scrollParent);
  2239. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  2240. var updatedList = list.concat(target);
  2241. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  2242. updatedList.concat(listScrollParents(getParentNode(target)));
  2243. }
  2244. function rectToClientRect(rect) {
  2245. return Object.assign({}, rect, {
  2246. left: rect.x,
  2247. top: rect.y,
  2248. right: rect.x + rect.width,
  2249. bottom: rect.y + rect.height
  2250. });
  2251. }
  2252. function getInnerBoundingClientRect(element, strategy) {
  2253. var rect = getBoundingClientRect(element, false, strategy === 'fixed');
  2254. rect.top = rect.top + element.clientTop;
  2255. rect.left = rect.left + element.clientLeft;
  2256. rect.bottom = rect.top + element.clientHeight;
  2257. rect.right = rect.left + element.clientWidth;
  2258. rect.width = element.clientWidth;
  2259. rect.height = element.clientHeight;
  2260. rect.x = rect.left;
  2261. rect.y = rect.top;
  2262. return rect;
  2263. }
  2264. function getClientRectFromMixedType(element, clippingParent, strategy) {
  2265. return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  2266. } // A "clipping parent" is an overflowable container with the characteristic of
  2267. // clipping (or hiding) overflowing elements with a position different from
  2268. // `initial`
  2269. function getClippingParents(element) {
  2270. var clippingParents = listScrollParents(getParentNode(element));
  2271. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
  2272. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  2273. if (!isElement(clipperElement)) {
  2274. return [];
  2275. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  2276. return clippingParents.filter(function (clippingParent) {
  2277. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  2278. });
  2279. } // Gets the maximum area that the element is visible in due to any number of
  2280. // clipping parents
  2281. function getClippingRect(element, boundary, rootBoundary, strategy) {
  2282. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  2283. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  2284. var firstClippingParent = clippingParents[0];
  2285. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  2286. var rect = getClientRectFromMixedType(element, clippingParent, strategy);
  2287. accRect.top = max(rect.top, accRect.top);
  2288. accRect.right = min(rect.right, accRect.right);
  2289. accRect.bottom = min(rect.bottom, accRect.bottom);
  2290. accRect.left = max(rect.left, accRect.left);
  2291. return accRect;
  2292. }, getClientRectFromMixedType(element, firstClippingParent, strategy));
  2293. clippingRect.width = clippingRect.right - clippingRect.left;
  2294. clippingRect.height = clippingRect.bottom - clippingRect.top;
  2295. clippingRect.x = clippingRect.left;
  2296. clippingRect.y = clippingRect.top;
  2297. return clippingRect;
  2298. }
  2299. function computeOffsets(_ref) {
  2300. var reference = _ref.reference,
  2301. element = _ref.element,
  2302. placement = _ref.placement;
  2303. var basePlacement = placement ? getBasePlacement(placement) : null;
  2304. var variation = placement ? getVariation(placement) : null;
  2305. var commonX = reference.x + reference.width / 2 - element.width / 2;
  2306. var commonY = reference.y + reference.height / 2 - element.height / 2;
  2307. var offsets;
  2308. switch (basePlacement) {
  2309. case top:
  2310. offsets = {
  2311. x: commonX,
  2312. y: reference.y - element.height
  2313. };
  2314. break;
  2315. case bottom:
  2316. offsets = {
  2317. x: commonX,
  2318. y: reference.y + reference.height
  2319. };
  2320. break;
  2321. case right:
  2322. offsets = {
  2323. x: reference.x + reference.width,
  2324. y: commonY
  2325. };
  2326. break;
  2327. case left:
  2328. offsets = {
  2329. x: reference.x - element.width,
  2330. y: commonY
  2331. };
  2332. break;
  2333. default:
  2334. offsets = {
  2335. x: reference.x,
  2336. y: reference.y
  2337. };
  2338. }
  2339. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  2340. if (mainAxis != null) {
  2341. var len = mainAxis === 'y' ? 'height' : 'width';
  2342. switch (variation) {
  2343. case start:
  2344. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  2345. break;
  2346. case end:
  2347. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  2348. break;
  2349. }
  2350. }
  2351. return offsets;
  2352. }
  2353. function detectOverflow(state, options) {
  2354. if (options === void 0) {
  2355. options = {};
  2356. }
  2357. var _options = options,
  2358. _options$placement = _options.placement,
  2359. placement = _options$placement === void 0 ? state.placement : _options$placement,
  2360. _options$strategy = _options.strategy,
  2361. strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
  2362. _options$boundary = _options.boundary,
  2363. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  2364. _options$rootBoundary = _options.rootBoundary,
  2365. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  2366. _options$elementConte = _options.elementContext,
  2367. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  2368. _options$altBoundary = _options.altBoundary,
  2369. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  2370. _options$padding = _options.padding,
  2371. padding = _options$padding === void 0 ? 0 : _options$padding;
  2372. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  2373. var altContext = elementContext === popper ? reference : popper;
  2374. var popperRect = state.rects.popper;
  2375. var element = state.elements[altBoundary ? altContext : elementContext];
  2376. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
  2377. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  2378. var popperOffsets = computeOffsets({
  2379. reference: referenceClientRect,
  2380. element: popperRect,
  2381. strategy: 'absolute',
  2382. placement: placement
  2383. });
  2384. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  2385. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  2386. // 0 or negative = within the clipping rect
  2387. var overflowOffsets = {
  2388. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  2389. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  2390. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  2391. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  2392. };
  2393. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  2394. if (elementContext === popper && offsetData) {
  2395. var offset = offsetData[placement];
  2396. Object.keys(overflowOffsets).forEach(function (key) {
  2397. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  2398. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  2399. overflowOffsets[key] += offset[axis] * multiply;
  2400. });
  2401. }
  2402. return overflowOffsets;
  2403. }
  2404. function computeAutoPlacement(state, options) {
  2405. if (options === void 0) {
  2406. options = {};
  2407. }
  2408. var _options = options,
  2409. placement = _options.placement,
  2410. boundary = _options.boundary,
  2411. rootBoundary = _options.rootBoundary,
  2412. padding = _options.padding,
  2413. flipVariations = _options.flipVariations,
  2414. _options$allowedAutoP = _options.allowedAutoPlacements,
  2415. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  2416. var variation = getVariation(placement);
  2417. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  2418. return getVariation(placement) === variation;
  2419. }) : basePlacements;
  2420. var allowedPlacements = placements$1.filter(function (placement) {
  2421. return allowedAutoPlacements.indexOf(placement) >= 0;
  2422. });
  2423. if (allowedPlacements.length === 0) {
  2424. allowedPlacements = placements$1;
  2425. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  2426. var overflows = allowedPlacements.reduce(function (acc, placement) {
  2427. acc[placement] = detectOverflow(state, {
  2428. placement: placement,
  2429. boundary: boundary,
  2430. rootBoundary: rootBoundary,
  2431. padding: padding
  2432. })[getBasePlacement(placement)];
  2433. return acc;
  2434. }, {});
  2435. return Object.keys(overflows).sort(function (a, b) {
  2436. return overflows[a] - overflows[b];
  2437. });
  2438. }
  2439. function getExpandedFallbackPlacements(placement) {
  2440. if (getBasePlacement(placement) === auto) {
  2441. return [];
  2442. }
  2443. var oppositePlacement = getOppositePlacement(placement);
  2444. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  2445. }
  2446. function flip(_ref) {
  2447. var state = _ref.state,
  2448. options = _ref.options,
  2449. name = _ref.name;
  2450. if (state.modifiersData[name]._skip) {
  2451. return;
  2452. }
  2453. var _options$mainAxis = options.mainAxis,
  2454. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  2455. _options$altAxis = options.altAxis,
  2456. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  2457. specifiedFallbackPlacements = options.fallbackPlacements,
  2458. padding = options.padding,
  2459. boundary = options.boundary,
  2460. rootBoundary = options.rootBoundary,
  2461. altBoundary = options.altBoundary,
  2462. _options$flipVariatio = options.flipVariations,
  2463. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  2464. allowedAutoPlacements = options.allowedAutoPlacements;
  2465. var preferredPlacement = state.options.placement;
  2466. var basePlacement = getBasePlacement(preferredPlacement);
  2467. var isBasePlacement = basePlacement === preferredPlacement;
  2468. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  2469. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  2470. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  2471. placement: placement,
  2472. boundary: boundary,
  2473. rootBoundary: rootBoundary,
  2474. padding: padding,
  2475. flipVariations: flipVariations,
  2476. allowedAutoPlacements: allowedAutoPlacements
  2477. }) : placement);
  2478. }, []);
  2479. var referenceRect = state.rects.reference;
  2480. var popperRect = state.rects.popper;
  2481. var checksMap = new Map();
  2482. var makeFallbackChecks = true;
  2483. var firstFittingPlacement = placements[0];
  2484. for (var i = 0; i < placements.length; i++) {
  2485. var placement = placements[i];
  2486. var _basePlacement = getBasePlacement(placement);
  2487. var isStartVariation = getVariation(placement) === start;
  2488. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  2489. var len = isVertical ? 'width' : 'height';
  2490. var overflow = detectOverflow(state, {
  2491. placement: placement,
  2492. boundary: boundary,
  2493. rootBoundary: rootBoundary,
  2494. altBoundary: altBoundary,
  2495. padding: padding
  2496. });
  2497. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  2498. if (referenceRect[len] > popperRect[len]) {
  2499. mainVariationSide = getOppositePlacement(mainVariationSide);
  2500. }
  2501. var altVariationSide = getOppositePlacement(mainVariationSide);
  2502. var checks = [];
  2503. if (checkMainAxis) {
  2504. checks.push(overflow[_basePlacement] <= 0);
  2505. }
  2506. if (checkAltAxis) {
  2507. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  2508. }
  2509. if (checks.every(function (check) {
  2510. return check;
  2511. })) {
  2512. firstFittingPlacement = placement;
  2513. makeFallbackChecks = false;
  2514. break;
  2515. }
  2516. checksMap.set(placement, checks);
  2517. }
  2518. if (makeFallbackChecks) {
  2519. // `2` may be desired in some cases – research later
  2520. var numberOfChecks = flipVariations ? 3 : 1;
  2521. var _loop = function _loop(_i) {
  2522. var fittingPlacement = placements.find(function (placement) {
  2523. var checks = checksMap.get(placement);
  2524. if (checks) {
  2525. return checks.slice(0, _i).every(function (check) {
  2526. return check;
  2527. });
  2528. }
  2529. });
  2530. if (fittingPlacement) {
  2531. firstFittingPlacement = fittingPlacement;
  2532. return "break";
  2533. }
  2534. };
  2535. for (var _i = numberOfChecks; _i > 0; _i--) {
  2536. var _ret = _loop(_i);
  2537. if (_ret === "break") break;
  2538. }
  2539. }
  2540. if (state.placement !== firstFittingPlacement) {
  2541. state.modifiersData[name]._skip = true;
  2542. state.placement = firstFittingPlacement;
  2543. state.reset = true;
  2544. }
  2545. } // eslint-disable-next-line import/no-unused-modules
  2546. const flip$1 = {
  2547. name: 'flip',
  2548. enabled: true,
  2549. phase: 'main',
  2550. fn: flip,
  2551. requiresIfExists: ['offset'],
  2552. data: {
  2553. _skip: false
  2554. }
  2555. };
  2556. function getSideOffsets(overflow, rect, preventedOffsets) {
  2557. if (preventedOffsets === void 0) {
  2558. preventedOffsets = {
  2559. x: 0,
  2560. y: 0
  2561. };
  2562. }
  2563. return {
  2564. top: overflow.top - rect.height - preventedOffsets.y,
  2565. right: overflow.right - rect.width + preventedOffsets.x,
  2566. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  2567. left: overflow.left - rect.width - preventedOffsets.x
  2568. };
  2569. }
  2570. function isAnySideFullyClipped(overflow) {
  2571. return [top, right, bottom, left].some(function (side) {
  2572. return overflow[side] >= 0;
  2573. });
  2574. }
  2575. function hide(_ref) {
  2576. var state = _ref.state,
  2577. name = _ref.name;
  2578. var referenceRect = state.rects.reference;
  2579. var popperRect = state.rects.popper;
  2580. var preventedOffsets = state.modifiersData.preventOverflow;
  2581. var referenceOverflow = detectOverflow(state, {
  2582. elementContext: 'reference'
  2583. });
  2584. var popperAltOverflow = detectOverflow(state, {
  2585. altBoundary: true
  2586. });
  2587. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  2588. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  2589. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  2590. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  2591. state.modifiersData[name] = {
  2592. referenceClippingOffsets: referenceClippingOffsets,
  2593. popperEscapeOffsets: popperEscapeOffsets,
  2594. isReferenceHidden: isReferenceHidden,
  2595. hasPopperEscaped: hasPopperEscaped
  2596. };
  2597. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  2598. 'data-popper-reference-hidden': isReferenceHidden,
  2599. 'data-popper-escaped': hasPopperEscaped
  2600. });
  2601. } // eslint-disable-next-line import/no-unused-modules
  2602. const hide$1 = {
  2603. name: 'hide',
  2604. enabled: true,
  2605. phase: 'main',
  2606. requiresIfExists: ['preventOverflow'],
  2607. fn: hide
  2608. };
  2609. function distanceAndSkiddingToXY(placement, rects, offset) {
  2610. var basePlacement = getBasePlacement(placement);
  2611. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  2612. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  2613. placement: placement
  2614. })) : offset,
  2615. skidding = _ref[0],
  2616. distance = _ref[1];
  2617. skidding = skidding || 0;
  2618. distance = (distance || 0) * invertDistance;
  2619. return [left, right].indexOf(basePlacement) >= 0 ? {
  2620. x: distance,
  2621. y: skidding
  2622. } : {
  2623. x: skidding,
  2624. y: distance
  2625. };
  2626. }
  2627. function offset(_ref2) {
  2628. var state = _ref2.state,
  2629. options = _ref2.options,
  2630. name = _ref2.name;
  2631. var _options$offset = options.offset,
  2632. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  2633. var data = placements.reduce(function (acc, placement) {
  2634. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  2635. return acc;
  2636. }, {});
  2637. var _data$state$placement = data[state.placement],
  2638. x = _data$state$placement.x,
  2639. y = _data$state$placement.y;
  2640. if (state.modifiersData.popperOffsets != null) {
  2641. state.modifiersData.popperOffsets.x += x;
  2642. state.modifiersData.popperOffsets.y += y;
  2643. }
  2644. state.modifiersData[name] = data;
  2645. } // eslint-disable-next-line import/no-unused-modules
  2646. const offset$1 = {
  2647. name: 'offset',
  2648. enabled: true,
  2649. phase: 'main',
  2650. requires: ['popperOffsets'],
  2651. fn: offset
  2652. };
  2653. function popperOffsets(_ref) {
  2654. var state = _ref.state,
  2655. name = _ref.name;
  2656. // Offsets are the actual position the popper needs to have to be
  2657. // properly positioned near its reference element
  2658. // This is the most basic placement, and will be adjusted by
  2659. // the modifiers in the next step
  2660. state.modifiersData[name] = computeOffsets({
  2661. reference: state.rects.reference,
  2662. element: state.rects.popper,
  2663. strategy: 'absolute',
  2664. placement: state.placement
  2665. });
  2666. } // eslint-disable-next-line import/no-unused-modules
  2667. const popperOffsets$1 = {
  2668. name: 'popperOffsets',
  2669. enabled: true,
  2670. phase: 'read',
  2671. fn: popperOffsets,
  2672. data: {}
  2673. };
  2674. function getAltAxis(axis) {
  2675. return axis === 'x' ? 'y' : 'x';
  2676. }
  2677. function preventOverflow(_ref) {
  2678. var state = _ref.state,
  2679. options = _ref.options,
  2680. name = _ref.name;
  2681. var _options$mainAxis = options.mainAxis,
  2682. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  2683. _options$altAxis = options.altAxis,
  2684. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  2685. boundary = options.boundary,
  2686. rootBoundary = options.rootBoundary,
  2687. altBoundary = options.altBoundary,
  2688. padding = options.padding,
  2689. _options$tether = options.tether,
  2690. tether = _options$tether === void 0 ? true : _options$tether,
  2691. _options$tetherOffset = options.tetherOffset,
  2692. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  2693. var overflow = detectOverflow(state, {
  2694. boundary: boundary,
  2695. rootBoundary: rootBoundary,
  2696. padding: padding,
  2697. altBoundary: altBoundary
  2698. });
  2699. var basePlacement = getBasePlacement(state.placement);
  2700. var variation = getVariation(state.placement);
  2701. var isBasePlacement = !variation;
  2702. var mainAxis = getMainAxisFromPlacement(basePlacement);
  2703. var altAxis = getAltAxis(mainAxis);
  2704. var popperOffsets = state.modifiersData.popperOffsets;
  2705. var referenceRect = state.rects.reference;
  2706. var popperRect = state.rects.popper;
  2707. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  2708. placement: state.placement
  2709. })) : tetherOffset;
  2710. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  2711. mainAxis: tetherOffsetValue,
  2712. altAxis: tetherOffsetValue
  2713. } : Object.assign({
  2714. mainAxis: 0,
  2715. altAxis: 0
  2716. }, tetherOffsetValue);
  2717. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  2718. var data = {
  2719. x: 0,
  2720. y: 0
  2721. };
  2722. if (!popperOffsets) {
  2723. return;
  2724. }
  2725. if (checkMainAxis) {
  2726. var _offsetModifierState$;
  2727. var mainSide = mainAxis === 'y' ? top : left;
  2728. var altSide = mainAxis === 'y' ? bottom : right;
  2729. var len = mainAxis === 'y' ? 'height' : 'width';
  2730. var offset = popperOffsets[mainAxis];
  2731. var min$1 = offset + overflow[mainSide];
  2732. var max$1 = offset - overflow[altSide];
  2733. var additive = tether ? -popperRect[len] / 2 : 0;
  2734. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  2735. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  2736. // outside the reference bounds
  2737. var arrowElement = state.elements.arrow;
  2738. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  2739. width: 0,
  2740. height: 0
  2741. };
  2742. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  2743. var arrowPaddingMin = arrowPaddingObject[mainSide];
  2744. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  2745. // to include its full size in the calculation. If the reference is small
  2746. // and near the edge of a boundary, the popper can overflow even if the
  2747. // reference is not overflowing as well (e.g. virtual elements with no
  2748. // width or height)
  2749. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  2750. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  2751. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  2752. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  2753. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  2754. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  2755. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  2756. var tetherMax = offset + maxOffset - offsetModifierValue;
  2757. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  2758. popperOffsets[mainAxis] = preventedOffset;
  2759. data[mainAxis] = preventedOffset - offset;
  2760. }
  2761. if (checkAltAxis) {
  2762. var _offsetModifierState$2;
  2763. var _mainSide = mainAxis === 'x' ? top : left;
  2764. var _altSide = mainAxis === 'x' ? bottom : right;
  2765. var _offset = popperOffsets[altAxis];
  2766. var _len = altAxis === 'y' ? 'height' : 'width';
  2767. var _min = _offset + overflow[_mainSide];
  2768. var _max = _offset - overflow[_altSide];
  2769. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  2770. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  2771. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  2772. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  2773. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  2774. popperOffsets[altAxis] = _preventedOffset;
  2775. data[altAxis] = _preventedOffset - _offset;
  2776. }
  2777. state.modifiersData[name] = data;
  2778. } // eslint-disable-next-line import/no-unused-modules
  2779. const preventOverflow$1 = {
  2780. name: 'preventOverflow',
  2781. enabled: true,
  2782. phase: 'main',
  2783. fn: preventOverflow,
  2784. requiresIfExists: ['offset']
  2785. };
  2786. function getHTMLElementScroll(element) {
  2787. return {
  2788. scrollLeft: element.scrollLeft,
  2789. scrollTop: element.scrollTop
  2790. };
  2791. }
  2792. function getNodeScroll(node) {
  2793. if (node === getWindow(node) || !isHTMLElement(node)) {
  2794. return getWindowScroll(node);
  2795. } else {
  2796. return getHTMLElementScroll(node);
  2797. }
  2798. }
  2799. function isElementScaled(element) {
  2800. var rect = element.getBoundingClientRect();
  2801. var scaleX = round(rect.width) / element.offsetWidth || 1;
  2802. var scaleY = round(rect.height) / element.offsetHeight || 1;
  2803. return scaleX !== 1 || scaleY !== 1;
  2804. } // Returns the composite rect of an element relative to its offsetParent.
  2805. // Composite means it takes into account transforms as well as layout.
  2806. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  2807. if (isFixed === void 0) {
  2808. isFixed = false;
  2809. }
  2810. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  2811. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  2812. var documentElement = getDocumentElement(offsetParent);
  2813. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
  2814. var scroll = {
  2815. scrollLeft: 0,
  2816. scrollTop: 0
  2817. };
  2818. var offsets = {
  2819. x: 0,
  2820. y: 0
  2821. };
  2822. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  2823. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  2824. isScrollParent(documentElement)) {
  2825. scroll = getNodeScroll(offsetParent);
  2826. }
  2827. if (isHTMLElement(offsetParent)) {
  2828. offsets = getBoundingClientRect(offsetParent, true);
  2829. offsets.x += offsetParent.clientLeft;
  2830. offsets.y += offsetParent.clientTop;
  2831. } else if (documentElement) {
  2832. offsets.x = getWindowScrollBarX(documentElement);
  2833. }
  2834. }
  2835. return {
  2836. x: rect.left + scroll.scrollLeft - offsets.x,
  2837. y: rect.top + scroll.scrollTop - offsets.y,
  2838. width: rect.width,
  2839. height: rect.height
  2840. };
  2841. }
  2842. function order(modifiers) {
  2843. var map = new Map();
  2844. var visited = new Set();
  2845. var result = [];
  2846. modifiers.forEach(function (modifier) {
  2847. map.set(modifier.name, modifier);
  2848. }); // On visiting object, check for its dependencies and visit them recursively
  2849. function sort(modifier) {
  2850. visited.add(modifier.name);
  2851. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  2852. requires.forEach(function (dep) {
  2853. if (!visited.has(dep)) {
  2854. var depModifier = map.get(dep);
  2855. if (depModifier) {
  2856. sort(depModifier);
  2857. }
  2858. }
  2859. });
  2860. result.push(modifier);
  2861. }
  2862. modifiers.forEach(function (modifier) {
  2863. if (!visited.has(modifier.name)) {
  2864. // check for visited object
  2865. sort(modifier);
  2866. }
  2867. });
  2868. return result;
  2869. }
  2870. function orderModifiers(modifiers) {
  2871. // order based on dependencies
  2872. var orderedModifiers = order(modifiers); // order based on phase
  2873. return modifierPhases.reduce(function (acc, phase) {
  2874. return acc.concat(orderedModifiers.filter(function (modifier) {
  2875. return modifier.phase === phase;
  2876. }));
  2877. }, []);
  2878. }
  2879. function debounce(fn) {
  2880. var pending;
  2881. return function () {
  2882. if (!pending) {
  2883. pending = new Promise(function (resolve) {
  2884. Promise.resolve().then(function () {
  2885. pending = undefined;
  2886. resolve(fn());
  2887. });
  2888. });
  2889. }
  2890. return pending;
  2891. };
  2892. }
  2893. function mergeByName(modifiers) {
  2894. var merged = modifiers.reduce(function (merged, current) {
  2895. var existing = merged[current.name];
  2896. merged[current.name] = existing ? Object.assign({}, existing, current, {
  2897. options: Object.assign({}, existing.options, current.options),
  2898. data: Object.assign({}, existing.data, current.data)
  2899. }) : current;
  2900. return merged;
  2901. }, {}); // IE11 does not support Object.values
  2902. return Object.keys(merged).map(function (key) {
  2903. return merged[key];
  2904. });
  2905. }
  2906. var DEFAULT_OPTIONS = {
  2907. placement: 'bottom',
  2908. modifiers: [],
  2909. strategy: 'absolute'
  2910. };
  2911. function areValidElements() {
  2912. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2913. args[_key] = arguments[_key];
  2914. }
  2915. return !args.some(function (element) {
  2916. return !(element && typeof element.getBoundingClientRect === 'function');
  2917. });
  2918. }
  2919. function popperGenerator(generatorOptions) {
  2920. if (generatorOptions === void 0) {
  2921. generatorOptions = {};
  2922. }
  2923. var _generatorOptions = generatorOptions,
  2924. _generatorOptions$def = _generatorOptions.defaultModifiers,
  2925. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  2926. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  2927. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  2928. return function createPopper(reference, popper, options) {
  2929. if (options === void 0) {
  2930. options = defaultOptions;
  2931. }
  2932. var state = {
  2933. placement: 'bottom',
  2934. orderedModifiers: [],
  2935. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  2936. modifiersData: {},
  2937. elements: {
  2938. reference: reference,
  2939. popper: popper
  2940. },
  2941. attributes: {},
  2942. styles: {}
  2943. };
  2944. var effectCleanupFns = [];
  2945. var isDestroyed = false;
  2946. var instance = {
  2947. state: state,
  2948. setOptions: function setOptions(setOptionsAction) {
  2949. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  2950. cleanupModifierEffects();
  2951. state.options = Object.assign({}, defaultOptions, state.options, options);
  2952. state.scrollParents = {
  2953. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  2954. popper: listScrollParents(popper)
  2955. }; // Orders the modifiers based on their dependencies and `phase`
  2956. // properties
  2957. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  2958. state.orderedModifiers = orderedModifiers.filter(function (m) {
  2959. return m.enabled;
  2960. });
  2961. runModifierEffects();
  2962. return instance.update();
  2963. },
  2964. // Sync update – it will always be executed, even if not necessary. This
  2965. // is useful for low frequency updates where sync behavior simplifies the
  2966. // logic.
  2967. // For high frequency updates (e.g. `resize` and `scroll` events), always
  2968. // prefer the async Popper#update method
  2969. forceUpdate: function forceUpdate() {
  2970. if (isDestroyed) {
  2971. return;
  2972. }
  2973. var _state$elements = state.elements,
  2974. reference = _state$elements.reference,
  2975. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  2976. // anymore
  2977. if (!areValidElements(reference, popper)) {
  2978. return;
  2979. } // Store the reference and popper rects to be read by modifiers
  2980. state.rects = {
  2981. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  2982. popper: getLayoutRect(popper)
  2983. }; // Modifiers have the ability to reset the current update cycle. The
  2984. // most common use case for this is the `flip` modifier changing the
  2985. // placement, which then needs to re-run all the modifiers, because the
  2986. // logic was previously ran for the previous placement and is therefore
  2987. // stale/incorrect
  2988. state.reset = false;
  2989. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  2990. // is filled with the initial data specified by the modifier. This means
  2991. // it doesn't persist and is fresh on each update.
  2992. // To ensure persistent data, use `${name}#persistent`
  2993. state.orderedModifiers.forEach(function (modifier) {
  2994. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  2995. });
  2996. for (var index = 0; index < state.orderedModifiers.length; index++) {
  2997. if (state.reset === true) {
  2998. state.reset = false;
  2999. index = -1;
  3000. continue;
  3001. }
  3002. var _state$orderedModifie = state.orderedModifiers[index],
  3003. fn = _state$orderedModifie.fn,
  3004. _state$orderedModifie2 = _state$orderedModifie.options,
  3005. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  3006. name = _state$orderedModifie.name;
  3007. if (typeof fn === 'function') {
  3008. state = fn({
  3009. state: state,
  3010. options: _options,
  3011. name: name,
  3012. instance: instance
  3013. }) || state;
  3014. }
  3015. }
  3016. },
  3017. // Async and optimistically optimized update – it will not be executed if
  3018. // not necessary (debounced to run at most once-per-tick)
  3019. update: debounce(function () {
  3020. return new Promise(function (resolve) {
  3021. instance.forceUpdate();
  3022. resolve(state);
  3023. });
  3024. }),
  3025. destroy: function destroy() {
  3026. cleanupModifierEffects();
  3027. isDestroyed = true;
  3028. }
  3029. };
  3030. if (!areValidElements(reference, popper)) {
  3031. return instance;
  3032. }
  3033. instance.setOptions(options).then(function (state) {
  3034. if (!isDestroyed && options.onFirstUpdate) {
  3035. options.onFirstUpdate(state);
  3036. }
  3037. }); // Modifiers have the ability to execute arbitrary code before the first
  3038. // update cycle runs. They will be executed in the same order as the update
  3039. // cycle. This is useful when a modifier adds some persistent data that
  3040. // other modifiers need to use, but the modifier is run after the dependent
  3041. // one.
  3042. function runModifierEffects() {
  3043. state.orderedModifiers.forEach(function (_ref) {
  3044. var name = _ref.name,
  3045. _ref$options = _ref.options,
  3046. options = _ref$options === void 0 ? {} : _ref$options,
  3047. effect = _ref.effect;
  3048. if (typeof effect === 'function') {
  3049. var cleanupFn = effect({
  3050. state: state,
  3051. name: name,
  3052. instance: instance,
  3053. options: options
  3054. });
  3055. var noopFn = function noopFn() {};
  3056. effectCleanupFns.push(cleanupFn || noopFn);
  3057. }
  3058. });
  3059. }
  3060. function cleanupModifierEffects() {
  3061. effectCleanupFns.forEach(function (fn) {
  3062. return fn();
  3063. });
  3064. effectCleanupFns = [];
  3065. }
  3066. return instance;
  3067. };
  3068. }
  3069. var createPopper$2 = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
  3070. var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
  3071. var createPopper$1 = /*#__PURE__*/popperGenerator({
  3072. defaultModifiers: defaultModifiers$1
  3073. }); // eslint-disable-next-line import/no-unused-modules
  3074. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  3075. var createPopper = /*#__PURE__*/popperGenerator({
  3076. defaultModifiers: defaultModifiers
  3077. }); // eslint-disable-next-line import/no-unused-modules
  3078. const Popper = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  3079. __proto__: null,
  3080. afterMain,
  3081. afterRead,
  3082. afterWrite,
  3083. applyStyles: applyStyles$1,
  3084. arrow: arrow$1,
  3085. auto,
  3086. basePlacements,
  3087. beforeMain,
  3088. beforeRead,
  3089. beforeWrite,
  3090. bottom,
  3091. clippingParents,
  3092. computeStyles: computeStyles$1,
  3093. createPopper,
  3094. createPopperBase: createPopper$2,
  3095. createPopperLite: createPopper$1,
  3096. detectOverflow,
  3097. end,
  3098. eventListeners,
  3099. flip: flip$1,
  3100. hide: hide$1,
  3101. left,
  3102. main,
  3103. modifierPhases,
  3104. offset: offset$1,
  3105. placements,
  3106. popper,
  3107. popperGenerator,
  3108. popperOffsets: popperOffsets$1,
  3109. preventOverflow: preventOverflow$1,
  3110. read,
  3111. reference,
  3112. right,
  3113. start,
  3114. top,
  3115. variationPlacements,
  3116. viewport,
  3117. write
  3118. }, Symbol.toStringTag, { value: 'Module' }));
  3119. /**
  3120. * --------------------------------------------------------------------------
  3121. * Bootstrap dropdown.js
  3122. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3123. * --------------------------------------------------------------------------
  3124. */
  3125. /**
  3126. * Constants
  3127. */
  3128. const NAME$a = 'dropdown';
  3129. const DATA_KEY$6 = 'bs.dropdown';
  3130. const EVENT_KEY$6 = `.${DATA_KEY$6}`;
  3131. const DATA_API_KEY$3 = '.data-api';
  3132. const ESCAPE_KEY$2 = 'Escape';
  3133. const TAB_KEY$1 = 'Tab';
  3134. const ARROW_UP_KEY$1 = 'ArrowUp';
  3135. const ARROW_DOWN_KEY$1 = 'ArrowDown';
  3136. const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
  3137. const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`;
  3138. const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`;
  3139. const EVENT_SHOW$5 = `show${EVENT_KEY$6}`;
  3140. const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`;
  3141. const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3142. const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3143. const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`;
  3144. const CLASS_NAME_SHOW$6 = 'show';
  3145. const CLASS_NAME_DROPUP = 'dropup';
  3146. const CLASS_NAME_DROPEND = 'dropend';
  3147. const CLASS_NAME_DROPSTART = 'dropstart';
  3148. const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
  3149. const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
  3150. const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
  3151. const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`;
  3152. const SELECTOR_MENU = '.dropdown-menu';
  3153. const SELECTOR_NAVBAR = '.navbar';
  3154. const SELECTOR_NAVBAR_NAV = '.navbar-nav';
  3155. const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  3156. const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
  3157. const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
  3158. const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
  3159. const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
  3160. const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
  3161. const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
  3162. const PLACEMENT_TOPCENTER = 'top';
  3163. const PLACEMENT_BOTTOMCENTER = 'bottom';
  3164. const Default$9 = {
  3165. autoClose: true,
  3166. boundary: 'clippingParents',
  3167. display: 'dynamic',
  3168. offset: [0, 2],
  3169. popperConfig: null,
  3170. reference: 'toggle'
  3171. };
  3172. const DefaultType$9 = {
  3173. autoClose: '(boolean|string)',
  3174. boundary: '(string|element)',
  3175. display: 'string',
  3176. offset: '(array|string|function)',
  3177. popperConfig: '(null|object|function)',
  3178. reference: '(string|element|object)'
  3179. };
  3180. /**
  3181. * Class definition
  3182. */
  3183. class Dropdown extends BaseComponent {
  3184. constructor(element, config) {
  3185. super(element, config);
  3186. this._popper = null;
  3187. this._parent = this._element.parentNode; // dropdown wrapper
  3188. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3189. this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
  3190. this._inNavbar = this._detectNavbar();
  3191. }
  3192. // Getters
  3193. static get Default() {
  3194. return Default$9;
  3195. }
  3196. static get DefaultType() {
  3197. return DefaultType$9;
  3198. }
  3199. static get NAME() {
  3200. return NAME$a;
  3201. }
  3202. // Public
  3203. toggle() {
  3204. return this._isShown() ? this.hide() : this.show();
  3205. }
  3206. show() {
  3207. if (isDisabled(this._element) || this._isShown()) {
  3208. return;
  3209. }
  3210. const relatedTarget = {
  3211. relatedTarget: this._element
  3212. };
  3213. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget);
  3214. if (showEvent.defaultPrevented) {
  3215. return;
  3216. }
  3217. this._createPopper();
  3218. // If this is a touch-enabled device we add extra
  3219. // empty mouseover listeners to the body's immediate children;
  3220. // only needed because of broken event delegation on iOS
  3221. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3222. if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
  3223. for (const element of [].concat(...document.body.children)) {
  3224. EventHandler.on(element, 'mouseover', noop);
  3225. }
  3226. }
  3227. this._element.focus();
  3228. this._element.setAttribute('aria-expanded', true);
  3229. this._menu.classList.add(CLASS_NAME_SHOW$6);
  3230. this._element.classList.add(CLASS_NAME_SHOW$6);
  3231. EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget);
  3232. }
  3233. hide() {
  3234. if (isDisabled(this._element) || !this._isShown()) {
  3235. return;
  3236. }
  3237. const relatedTarget = {
  3238. relatedTarget: this._element
  3239. };
  3240. this._completeHide(relatedTarget);
  3241. }
  3242. dispose() {
  3243. if (this._popper) {
  3244. this._popper.destroy();
  3245. }
  3246. super.dispose();
  3247. }
  3248. update() {
  3249. this._inNavbar = this._detectNavbar();
  3250. if (this._popper) {
  3251. this._popper.update();
  3252. }
  3253. }
  3254. // Private
  3255. _completeHide(relatedTarget) {
  3256. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget);
  3257. if (hideEvent.defaultPrevented) {
  3258. return;
  3259. }
  3260. // If this is a touch-enabled device we remove the extra
  3261. // empty mouseover listeners we added for iOS support
  3262. if ('ontouchstart' in document.documentElement) {
  3263. for (const element of [].concat(...document.body.children)) {
  3264. EventHandler.off(element, 'mouseover', noop);
  3265. }
  3266. }
  3267. if (this._popper) {
  3268. this._popper.destroy();
  3269. }
  3270. this._menu.classList.remove(CLASS_NAME_SHOW$6);
  3271. this._element.classList.remove(CLASS_NAME_SHOW$6);
  3272. this._element.setAttribute('aria-expanded', 'false');
  3273. Manipulator.removeDataAttribute(this._menu, 'popper');
  3274. EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget);
  3275. }
  3276. _getConfig(config) {
  3277. config = super._getConfig(config);
  3278. if (typeof config.reference === 'object' && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
  3279. // Popper virtual elements require a getBoundingClientRect method
  3280. throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
  3281. }
  3282. return config;
  3283. }
  3284. _createPopper() {
  3285. if (typeof Popper === 'undefined') {
  3286. throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
  3287. }
  3288. let referenceElement = this._element;
  3289. if (this._config.reference === 'parent') {
  3290. referenceElement = this._parent;
  3291. } else if (isElement$1(this._config.reference)) {
  3292. referenceElement = getElement(this._config.reference);
  3293. } else if (typeof this._config.reference === 'object') {
  3294. referenceElement = this._config.reference;
  3295. }
  3296. const popperConfig = this._getPopperConfig();
  3297. this._popper = createPopper(referenceElement, this._menu, popperConfig);
  3298. }
  3299. _isShown() {
  3300. return this._menu.classList.contains(CLASS_NAME_SHOW$6);
  3301. }
  3302. _getPlacement() {
  3303. const parentDropdown = this._parent;
  3304. if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
  3305. return PLACEMENT_RIGHT;
  3306. }
  3307. if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
  3308. return PLACEMENT_LEFT;
  3309. }
  3310. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
  3311. return PLACEMENT_TOPCENTER;
  3312. }
  3313. if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
  3314. return PLACEMENT_BOTTOMCENTER;
  3315. }
  3316. // We need to trim the value because custom properties can also include spaces
  3317. const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
  3318. if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
  3319. return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3320. }
  3321. return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
  3322. }
  3323. _detectNavbar() {
  3324. return this._element.closest(SELECTOR_NAVBAR) !== null;
  3325. }
  3326. _getOffset() {
  3327. const {
  3328. offset
  3329. } = this._config;
  3330. if (typeof offset === 'string') {
  3331. return offset.split(',').map(value => Number.parseInt(value, 10));
  3332. }
  3333. if (typeof offset === 'function') {
  3334. return popperData => offset(popperData, this._element);
  3335. }
  3336. return offset;
  3337. }
  3338. _getPopperConfig() {
  3339. const defaultBsPopperConfig = {
  3340. placement: this._getPlacement(),
  3341. modifiers: [{
  3342. name: 'preventOverflow',
  3343. options: {
  3344. boundary: this._config.boundary
  3345. }
  3346. }, {
  3347. name: 'offset',
  3348. options: {
  3349. offset: this._getOffset()
  3350. }
  3351. }]
  3352. };
  3353. // Disable Popper if we have a static display or Dropdown is in Navbar
  3354. if (this._inNavbar || this._config.display === 'static') {
  3355. Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
  3356. defaultBsPopperConfig.modifiers = [{
  3357. name: 'applyStyles',
  3358. enabled: false
  3359. }];
  3360. }
  3361. return {
  3362. ...defaultBsPopperConfig,
  3363. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  3364. };
  3365. }
  3366. _selectMenuItem({
  3367. key,
  3368. target
  3369. }) {
  3370. const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
  3371. if (!items.length) {
  3372. return;
  3373. }
  3374. // if target isn't included in items (e.g. when expanding the dropdown)
  3375. // allow cycling to get the last item in case key equals ARROW_UP_KEY
  3376. getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
  3377. }
  3378. // Static
  3379. static jQueryInterface(config) {
  3380. return this.each(function () {
  3381. const data = Dropdown.getOrCreateInstance(this, config);
  3382. if (typeof config !== 'string') {
  3383. return;
  3384. }
  3385. if (typeof data[config] === 'undefined') {
  3386. throw new TypeError(`No method named "${config}"`);
  3387. }
  3388. data[config]();
  3389. });
  3390. }
  3391. static clearMenus(event) {
  3392. if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) {
  3393. return;
  3394. }
  3395. const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
  3396. for (const toggle of openToggles) {
  3397. const context = Dropdown.getInstance(toggle);
  3398. if (!context || context._config.autoClose === false) {
  3399. continue;
  3400. }
  3401. const composedPath = event.composedPath();
  3402. const isMenuTarget = composedPath.includes(context._menu);
  3403. if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
  3404. continue;
  3405. }
  3406. // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
  3407. if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) {
  3408. continue;
  3409. }
  3410. const relatedTarget = {
  3411. relatedTarget: context._element
  3412. };
  3413. if (event.type === 'click') {
  3414. relatedTarget.clickEvent = event;
  3415. }
  3416. context._completeHide(relatedTarget);
  3417. }
  3418. }
  3419. static dataApiKeydownHandler(event) {
  3420. // If not an UP | DOWN | ESCAPE key => not a dropdown command
  3421. // If input/textarea && if key is other than ESCAPE => not a dropdown command
  3422. const isInput = /input|textarea/i.test(event.target.tagName);
  3423. const isEscapeEvent = event.key === ESCAPE_KEY$2;
  3424. const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key);
  3425. if (!isUpOrDownEvent && !isEscapeEvent) {
  3426. return;
  3427. }
  3428. if (isInput && !isEscapeEvent) {
  3429. return;
  3430. }
  3431. event.preventDefault();
  3432. // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
  3433. 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);
  3434. const instance = Dropdown.getOrCreateInstance(getToggleButton);
  3435. if (isUpOrDownEvent) {
  3436. event.stopPropagation();
  3437. instance.show();
  3438. instance._selectMenuItem(event);
  3439. return;
  3440. }
  3441. if (instance._isShown()) {
  3442. // else is escape and we check if it is shown
  3443. event.stopPropagation();
  3444. instance.hide();
  3445. getToggleButton.focus();
  3446. }
  3447. }
  3448. }
  3449. /**
  3450. * Data API implementation
  3451. */
  3452. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler);
  3453. EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  3454. EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus);
  3455. EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  3456. EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) {
  3457. event.preventDefault();
  3458. Dropdown.getOrCreateInstance(this).toggle();
  3459. });
  3460. /**
  3461. * jQuery
  3462. */
  3463. defineJQueryPlugin(Dropdown);
  3464. /**
  3465. * --------------------------------------------------------------------------
  3466. * Bootstrap util/backdrop.js
  3467. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3468. * --------------------------------------------------------------------------
  3469. */
  3470. /**
  3471. * Constants
  3472. */
  3473. const NAME$9 = 'backdrop';
  3474. const CLASS_NAME_FADE$4 = 'fade';
  3475. const CLASS_NAME_SHOW$5 = 'show';
  3476. const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`;
  3477. const Default$8 = {
  3478. className: 'modal-backdrop',
  3479. clickCallback: null,
  3480. isAnimated: false,
  3481. isVisible: true,
  3482. // if false, we use the backdrop helper without adding any element to the dom
  3483. rootElement: 'body' // give the choice to place backdrop under different elements
  3484. };
  3485. const DefaultType$8 = {
  3486. className: 'string',
  3487. clickCallback: '(function|null)',
  3488. isAnimated: 'boolean',
  3489. isVisible: 'boolean',
  3490. rootElement: '(element|string)'
  3491. };
  3492. /**
  3493. * Class definition
  3494. */
  3495. class Backdrop extends Config {
  3496. constructor(config) {
  3497. super();
  3498. this._config = this._getConfig(config);
  3499. this._isAppended = false;
  3500. this._element = null;
  3501. }
  3502. // Getters
  3503. static get Default() {
  3504. return Default$8;
  3505. }
  3506. static get DefaultType() {
  3507. return DefaultType$8;
  3508. }
  3509. static get NAME() {
  3510. return NAME$9;
  3511. }
  3512. // Public
  3513. show(callback) {
  3514. if (!this._config.isVisible) {
  3515. execute(callback);
  3516. return;
  3517. }
  3518. this._append();
  3519. const element = this._getElement();
  3520. if (this._config.isAnimated) {
  3521. reflow(element);
  3522. }
  3523. element.classList.add(CLASS_NAME_SHOW$5);
  3524. this._emulateAnimation(() => {
  3525. execute(callback);
  3526. });
  3527. }
  3528. hide(callback) {
  3529. if (!this._config.isVisible) {
  3530. execute(callback);
  3531. return;
  3532. }
  3533. this._getElement().classList.remove(CLASS_NAME_SHOW$5);
  3534. this._emulateAnimation(() => {
  3535. this.dispose();
  3536. execute(callback);
  3537. });
  3538. }
  3539. dispose() {
  3540. if (!this._isAppended) {
  3541. return;
  3542. }
  3543. EventHandler.off(this._element, EVENT_MOUSEDOWN);
  3544. this._element.remove();
  3545. this._isAppended = false;
  3546. }
  3547. // Private
  3548. _getElement() {
  3549. if (!this._element) {
  3550. const backdrop = document.createElement('div');
  3551. backdrop.className = this._config.className;
  3552. if (this._config.isAnimated) {
  3553. backdrop.classList.add(CLASS_NAME_FADE$4);
  3554. }
  3555. this._element = backdrop;
  3556. }
  3557. return this._element;
  3558. }
  3559. _configAfterMerge(config) {
  3560. // use getElement() with the default "body" to get a fresh Element on each instantiation
  3561. config.rootElement = getElement(config.rootElement);
  3562. return config;
  3563. }
  3564. _append() {
  3565. if (this._isAppended) {
  3566. return;
  3567. }
  3568. const element = this._getElement();
  3569. this._config.rootElement.append(element);
  3570. EventHandler.on(element, EVENT_MOUSEDOWN, () => {
  3571. execute(this._config.clickCallback);
  3572. });
  3573. this._isAppended = true;
  3574. }
  3575. _emulateAnimation(callback) {
  3576. executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
  3577. }
  3578. }
  3579. /**
  3580. * --------------------------------------------------------------------------
  3581. * Bootstrap util/focustrap.js
  3582. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3583. * --------------------------------------------------------------------------
  3584. */
  3585. /**
  3586. * Constants
  3587. */
  3588. const NAME$8 = 'focustrap';
  3589. const DATA_KEY$5 = 'bs.focustrap';
  3590. const EVENT_KEY$5 = `.${DATA_KEY$5}`;
  3591. const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`;
  3592. const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`;
  3593. const TAB_KEY = 'Tab';
  3594. const TAB_NAV_FORWARD = 'forward';
  3595. const TAB_NAV_BACKWARD = 'backward';
  3596. const Default$7 = {
  3597. autofocus: true,
  3598. trapElement: null // The element to trap focus inside of
  3599. };
  3600. const DefaultType$7 = {
  3601. autofocus: 'boolean',
  3602. trapElement: 'element'
  3603. };
  3604. /**
  3605. * Class definition
  3606. */
  3607. class FocusTrap extends Config {
  3608. constructor(config) {
  3609. super();
  3610. this._config = this._getConfig(config);
  3611. this._isActive = false;
  3612. this._lastTabNavDirection = null;
  3613. }
  3614. // Getters
  3615. static get Default() {
  3616. return Default$7;
  3617. }
  3618. static get DefaultType() {
  3619. return DefaultType$7;
  3620. }
  3621. static get NAME() {
  3622. return NAME$8;
  3623. }
  3624. // Public
  3625. activate() {
  3626. if (this._isActive) {
  3627. return;
  3628. }
  3629. if (this._config.autofocus) {
  3630. this._config.trapElement.focus();
  3631. }
  3632. EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop
  3633. EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
  3634. EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
  3635. this._isActive = true;
  3636. }
  3637. deactivate() {
  3638. if (!this._isActive) {
  3639. return;
  3640. }
  3641. this._isActive = false;
  3642. EventHandler.off(document, EVENT_KEY$5);
  3643. }
  3644. // Private
  3645. _handleFocusin(event) {
  3646. const {
  3647. trapElement
  3648. } = this._config;
  3649. if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
  3650. return;
  3651. }
  3652. const elements = SelectorEngine.focusableChildren(trapElement);
  3653. if (elements.length === 0) {
  3654. trapElement.focus();
  3655. } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
  3656. elements[elements.length - 1].focus();
  3657. } else {
  3658. elements[0].focus();
  3659. }
  3660. }
  3661. _handleKeydown(event) {
  3662. if (event.key !== TAB_KEY) {
  3663. return;
  3664. }
  3665. this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
  3666. }
  3667. }
  3668. /**
  3669. * --------------------------------------------------------------------------
  3670. * Bootstrap util/scrollBar.js
  3671. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3672. * --------------------------------------------------------------------------
  3673. */
  3674. /**
  3675. * Constants
  3676. */
  3677. const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  3678. const SELECTOR_STICKY_CONTENT = '.sticky-top';
  3679. const PROPERTY_PADDING = 'padding-right';
  3680. const PROPERTY_MARGIN = 'margin-right';
  3681. /**
  3682. * Class definition
  3683. */
  3684. class ScrollBarHelper {
  3685. constructor() {
  3686. this._element = document.body;
  3687. }
  3688. // Public
  3689. getWidth() {
  3690. // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
  3691. const documentWidth = document.documentElement.clientWidth;
  3692. return Math.abs(window.innerWidth - documentWidth);
  3693. }
  3694. hide() {
  3695. const width = this.getWidth();
  3696. this._disableOverFlow();
  3697. // give padding to element to balance the hidden scrollbar width
  3698. this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  3699. // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
  3700. this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
  3701. this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
  3702. }
  3703. reset() {
  3704. this._resetElementAttributes(this._element, 'overflow');
  3705. this._resetElementAttributes(this._element, PROPERTY_PADDING);
  3706. this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
  3707. this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
  3708. }
  3709. isOverflowing() {
  3710. return this.getWidth() > 0;
  3711. }
  3712. // Private
  3713. _disableOverFlow() {
  3714. this._saveInitialAttribute(this._element, 'overflow');
  3715. this._element.style.overflow = 'hidden';
  3716. }
  3717. _setElementAttributes(selector, styleProperty, callback) {
  3718. const scrollbarWidth = this.getWidth();
  3719. const manipulationCallBack = element => {
  3720. if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
  3721. return;
  3722. }
  3723. this._saveInitialAttribute(element, styleProperty);
  3724. const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
  3725. element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
  3726. };
  3727. this._applyManipulationCallback(selector, manipulationCallBack);
  3728. }
  3729. _saveInitialAttribute(element, styleProperty) {
  3730. const actualValue = element.style.getPropertyValue(styleProperty);
  3731. if (actualValue) {
  3732. Manipulator.setDataAttribute(element, styleProperty, actualValue);
  3733. }
  3734. }
  3735. _resetElementAttributes(selector, styleProperty) {
  3736. const manipulationCallBack = element => {
  3737. const value = Manipulator.getDataAttribute(element, styleProperty);
  3738. // We only want to remove the property if the value is `null`; the value can also be zero
  3739. if (value === null) {
  3740. element.style.removeProperty(styleProperty);
  3741. return;
  3742. }
  3743. Manipulator.removeDataAttribute(element, styleProperty);
  3744. element.style.setProperty(styleProperty, value);
  3745. };
  3746. this._applyManipulationCallback(selector, manipulationCallBack);
  3747. }
  3748. _applyManipulationCallback(selector, callBack) {
  3749. if (isElement$1(selector)) {
  3750. callBack(selector);
  3751. return;
  3752. }
  3753. for (const sel of SelectorEngine.find(selector, this._element)) {
  3754. callBack(sel);
  3755. }
  3756. }
  3757. }
  3758. /**
  3759. * --------------------------------------------------------------------------
  3760. * Bootstrap modal.js
  3761. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  3762. * --------------------------------------------------------------------------
  3763. */
  3764. /**
  3765. * Constants
  3766. */
  3767. const NAME$7 = 'modal';
  3768. const DATA_KEY$4 = 'bs.modal';
  3769. const EVENT_KEY$4 = `.${DATA_KEY$4}`;
  3770. const DATA_API_KEY$2 = '.data-api';
  3771. const ESCAPE_KEY$1 = 'Escape';
  3772. const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
  3773. const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`;
  3774. const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
  3775. const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
  3776. const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
  3777. const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`;
  3778. const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
  3779. const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
  3780. const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`;
  3781. const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`;
  3782. const CLASS_NAME_OPEN = 'modal-open';
  3783. const CLASS_NAME_FADE$3 = 'fade';
  3784. const CLASS_NAME_SHOW$4 = 'show';
  3785. const CLASS_NAME_STATIC = 'modal-static';
  3786. const OPEN_SELECTOR$1 = '.modal.show';
  3787. const SELECTOR_DIALOG = '.modal-dialog';
  3788. const SELECTOR_MODAL_BODY = '.modal-body';
  3789. const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]';
  3790. const Default$6 = {
  3791. backdrop: true,
  3792. focus: true,
  3793. keyboard: true
  3794. };
  3795. const DefaultType$6 = {
  3796. backdrop: '(boolean|string)',
  3797. focus: 'boolean',
  3798. keyboard: 'boolean'
  3799. };
  3800. /**
  3801. * Class definition
  3802. */
  3803. class Modal extends BaseComponent {
  3804. constructor(element, config) {
  3805. super(element, config);
  3806. this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
  3807. this._backdrop = this._initializeBackDrop();
  3808. this._focustrap = this._initializeFocusTrap();
  3809. this._isShown = false;
  3810. this._isTransitioning = false;
  3811. this._scrollBar = new ScrollBarHelper();
  3812. this._addEventListeners();
  3813. }
  3814. // Getters
  3815. static get Default() {
  3816. return Default$6;
  3817. }
  3818. static get DefaultType() {
  3819. return DefaultType$6;
  3820. }
  3821. static get NAME() {
  3822. return NAME$7;
  3823. }
  3824. // Public
  3825. toggle(relatedTarget) {
  3826. return this._isShown ? this.hide() : this.show(relatedTarget);
  3827. }
  3828. show(relatedTarget) {
  3829. if (this._isShown || this._isTransitioning) {
  3830. return;
  3831. }
  3832. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, {
  3833. relatedTarget
  3834. });
  3835. if (showEvent.defaultPrevented) {
  3836. return;
  3837. }
  3838. this._isShown = true;
  3839. this._isTransitioning = true;
  3840. this._scrollBar.hide();
  3841. document.body.classList.add(CLASS_NAME_OPEN);
  3842. this._adjustDialog();
  3843. this._backdrop.show(() => this._showElement(relatedTarget));
  3844. }
  3845. hide() {
  3846. if (!this._isShown || this._isTransitioning) {
  3847. return;
  3848. }
  3849. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
  3850. if (hideEvent.defaultPrevented) {
  3851. return;
  3852. }
  3853. this._isShown = false;
  3854. this._isTransitioning = true;
  3855. this._focustrap.deactivate();
  3856. this._element.classList.remove(CLASS_NAME_SHOW$4);
  3857. this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
  3858. }
  3859. dispose() {
  3860. EventHandler.off(window, EVENT_KEY$4);
  3861. EventHandler.off(this._dialog, EVENT_KEY$4);
  3862. this._backdrop.dispose();
  3863. this._focustrap.deactivate();
  3864. super.dispose();
  3865. }
  3866. handleUpdate() {
  3867. this._adjustDialog();
  3868. }
  3869. // Private
  3870. _initializeBackDrop() {
  3871. return new Backdrop({
  3872. isVisible: Boolean(this._config.backdrop),
  3873. // 'static' option will be translated to true, and booleans will keep their value,
  3874. isAnimated: this._isAnimated()
  3875. });
  3876. }
  3877. _initializeFocusTrap() {
  3878. return new FocusTrap({
  3879. trapElement: this._element
  3880. });
  3881. }
  3882. _showElement(relatedTarget) {
  3883. // try to append dynamic modal
  3884. if (!document.body.contains(this._element)) {
  3885. document.body.append(this._element);
  3886. }
  3887. this._element.style.display = 'block';
  3888. this._element.removeAttribute('aria-hidden');
  3889. this._element.setAttribute('aria-modal', true);
  3890. this._element.setAttribute('role', 'dialog');
  3891. this._element.scrollTop = 0;
  3892. const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
  3893. if (modalBody) {
  3894. modalBody.scrollTop = 0;
  3895. }
  3896. reflow(this._element);
  3897. this._element.classList.add(CLASS_NAME_SHOW$4);
  3898. const transitionComplete = () => {
  3899. if (this._config.focus) {
  3900. this._focustrap.activate();
  3901. }
  3902. this._isTransitioning = false;
  3903. EventHandler.trigger(this._element, EVENT_SHOWN$4, {
  3904. relatedTarget
  3905. });
  3906. };
  3907. this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
  3908. }
  3909. _addEventListeners() {
  3910. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => {
  3911. if (event.key !== ESCAPE_KEY$1) {
  3912. return;
  3913. }
  3914. if (this._config.keyboard) {
  3915. this.hide();
  3916. return;
  3917. }
  3918. this._triggerBackdropTransition();
  3919. });
  3920. EventHandler.on(window, EVENT_RESIZE$1, () => {
  3921. if (this._isShown && !this._isTransitioning) {
  3922. this._adjustDialog();
  3923. }
  3924. });
  3925. EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
  3926. // a bad trick to segregate clicks that may start inside dialog but end outside, and avoid listen to scrollbar clicks
  3927. EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
  3928. if (this._element !== event.target || this._element !== event2.target) {
  3929. return;
  3930. }
  3931. if (this._config.backdrop === 'static') {
  3932. this._triggerBackdropTransition();
  3933. return;
  3934. }
  3935. if (this._config.backdrop) {
  3936. this.hide();
  3937. }
  3938. });
  3939. });
  3940. }
  3941. _hideModal() {
  3942. this._element.style.display = 'none';
  3943. this._element.setAttribute('aria-hidden', true);
  3944. this._element.removeAttribute('aria-modal');
  3945. this._element.removeAttribute('role');
  3946. this._isTransitioning = false;
  3947. this._backdrop.hide(() => {
  3948. document.body.classList.remove(CLASS_NAME_OPEN);
  3949. this._resetAdjustments();
  3950. this._scrollBar.reset();
  3951. EventHandler.trigger(this._element, EVENT_HIDDEN$4);
  3952. });
  3953. }
  3954. _isAnimated() {
  3955. return this._element.classList.contains(CLASS_NAME_FADE$3);
  3956. }
  3957. _triggerBackdropTransition() {
  3958. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1);
  3959. if (hideEvent.defaultPrevented) {
  3960. return;
  3961. }
  3962. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3963. const initialOverflowY = this._element.style.overflowY;
  3964. // return if the following background transition hasn't yet completed
  3965. if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
  3966. return;
  3967. }
  3968. if (!isModalOverflowing) {
  3969. this._element.style.overflowY = 'hidden';
  3970. }
  3971. this._element.classList.add(CLASS_NAME_STATIC);
  3972. this._queueCallback(() => {
  3973. this._element.classList.remove(CLASS_NAME_STATIC);
  3974. this._queueCallback(() => {
  3975. this._element.style.overflowY = initialOverflowY;
  3976. }, this._dialog);
  3977. }, this._dialog);
  3978. this._element.focus();
  3979. }
  3980. /**
  3981. * The following methods are used to handle overflowing modals
  3982. */
  3983. _adjustDialog() {
  3984. const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3985. const scrollbarWidth = this._scrollBar.getWidth();
  3986. const isBodyOverflowing = scrollbarWidth > 0;
  3987. if (isBodyOverflowing && !isModalOverflowing) {
  3988. const property = isRTL() ? 'paddingLeft' : 'paddingRight';
  3989. this._element.style[property] = `${scrollbarWidth}px`;
  3990. }
  3991. if (!isBodyOverflowing && isModalOverflowing) {
  3992. const property = isRTL() ? 'paddingRight' : 'paddingLeft';
  3993. this._element.style[property] = `${scrollbarWidth}px`;
  3994. }
  3995. }
  3996. _resetAdjustments() {
  3997. this._element.style.paddingLeft = '';
  3998. this._element.style.paddingRight = '';
  3999. }
  4000. // Static
  4001. static jQueryInterface(config, relatedTarget) {
  4002. return this.each(function () {
  4003. const data = Modal.getOrCreateInstance(this, config);
  4004. if (typeof config !== 'string') {
  4005. return;
  4006. }
  4007. if (typeof data[config] === 'undefined') {
  4008. throw new TypeError(`No method named "${config}"`);
  4009. }
  4010. data[config](relatedTarget);
  4011. });
  4012. }
  4013. }
  4014. /**
  4015. * Data API implementation
  4016. */
  4017. EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) {
  4018. const target = SelectorEngine.getElementFromSelector(this);
  4019. if (['A', 'AREA'].includes(this.tagName)) {
  4020. event.preventDefault();
  4021. }
  4022. EventHandler.one(target, EVENT_SHOW$4, showEvent => {
  4023. if (showEvent.defaultPrevented) {
  4024. // only register focus restorer if modal will actually get shown
  4025. return;
  4026. }
  4027. EventHandler.one(target, EVENT_HIDDEN$4, () => {
  4028. if (isVisible(this)) {
  4029. this.focus();
  4030. }
  4031. });
  4032. });
  4033. // avoid conflict when clicking modal toggler while another one is open
  4034. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1);
  4035. if (alreadyOpen) {
  4036. Modal.getInstance(alreadyOpen).hide();
  4037. }
  4038. const data = Modal.getOrCreateInstance(target);
  4039. data.toggle(this);
  4040. });
  4041. enableDismissTrigger(Modal);
  4042. /**
  4043. * jQuery
  4044. */
  4045. defineJQueryPlugin(Modal);
  4046. /**
  4047. * --------------------------------------------------------------------------
  4048. * Bootstrap offcanvas.js
  4049. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4050. * --------------------------------------------------------------------------
  4051. */
  4052. /**
  4053. * Constants
  4054. */
  4055. const NAME$6 = 'offcanvas';
  4056. const DATA_KEY$3 = 'bs.offcanvas';
  4057. const EVENT_KEY$3 = `.${DATA_KEY$3}`;
  4058. const DATA_API_KEY$1 = '.data-api';
  4059. const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4060. const ESCAPE_KEY = 'Escape';
  4061. const CLASS_NAME_SHOW$3 = 'show';
  4062. const CLASS_NAME_SHOWING$1 = 'showing';
  4063. const CLASS_NAME_HIDING = 'hiding';
  4064. const CLASS_NAME_BACKDROP = 'offcanvas-backdrop';
  4065. const OPEN_SELECTOR = '.offcanvas.show';
  4066. const EVENT_SHOW$3 = `show${EVENT_KEY$3}`;
  4067. const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`;
  4068. const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`;
  4069. const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`;
  4070. const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`;
  4071. const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
  4072. const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`;
  4073. const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`;
  4074. const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]';
  4075. const Default$5 = {
  4076. backdrop: true,
  4077. keyboard: true,
  4078. scroll: false
  4079. };
  4080. const DefaultType$5 = {
  4081. backdrop: '(boolean|string)',
  4082. keyboard: 'boolean',
  4083. scroll: 'boolean'
  4084. };
  4085. /**
  4086. * Class definition
  4087. */
  4088. class Offcanvas extends BaseComponent {
  4089. constructor(element, config) {
  4090. super(element, config);
  4091. this._isShown = false;
  4092. this._backdrop = this._initializeBackDrop();
  4093. this._focustrap = this._initializeFocusTrap();
  4094. this._addEventListeners();
  4095. }
  4096. // Getters
  4097. static get Default() {
  4098. return Default$5;
  4099. }
  4100. static get DefaultType() {
  4101. return DefaultType$5;
  4102. }
  4103. static get NAME() {
  4104. return NAME$6;
  4105. }
  4106. // Public
  4107. toggle(relatedTarget) {
  4108. return this._isShown ? this.hide() : this.show(relatedTarget);
  4109. }
  4110. show(relatedTarget) {
  4111. if (this._isShown) {
  4112. return;
  4113. }
  4114. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
  4115. relatedTarget
  4116. });
  4117. if (showEvent.defaultPrevented) {
  4118. return;
  4119. }
  4120. this._isShown = true;
  4121. this._backdrop.show();
  4122. if (!this._config.scroll) {
  4123. new ScrollBarHelper().hide();
  4124. }
  4125. this._element.setAttribute('aria-modal', true);
  4126. this._element.setAttribute('role', 'dialog');
  4127. this._element.classList.add(CLASS_NAME_SHOWING$1);
  4128. const completeCallBack = () => {
  4129. if (!this._config.scroll || this._config.backdrop) {
  4130. this._focustrap.activate();
  4131. }
  4132. this._element.classList.add(CLASS_NAME_SHOW$3);
  4133. this._element.classList.remove(CLASS_NAME_SHOWING$1);
  4134. EventHandler.trigger(this._element, EVENT_SHOWN$3, {
  4135. relatedTarget
  4136. });
  4137. };
  4138. this._queueCallback(completeCallBack, this._element, true);
  4139. }
  4140. hide() {
  4141. if (!this._isShown) {
  4142. return;
  4143. }
  4144. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
  4145. if (hideEvent.defaultPrevented) {
  4146. return;
  4147. }
  4148. this._focustrap.deactivate();
  4149. this._element.blur();
  4150. this._isShown = false;
  4151. this._element.classList.add(CLASS_NAME_HIDING);
  4152. this._backdrop.hide();
  4153. const completeCallback = () => {
  4154. this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING);
  4155. this._element.removeAttribute('aria-modal');
  4156. this._element.removeAttribute('role');
  4157. if (!this._config.scroll) {
  4158. new ScrollBarHelper().reset();
  4159. }
  4160. EventHandler.trigger(this._element, EVENT_HIDDEN$3);
  4161. };
  4162. this._queueCallback(completeCallback, this._element, true);
  4163. }
  4164. dispose() {
  4165. this._backdrop.dispose();
  4166. this._focustrap.deactivate();
  4167. super.dispose();
  4168. }
  4169. // Private
  4170. _initializeBackDrop() {
  4171. const clickCallback = () => {
  4172. if (this._config.backdrop === 'static') {
  4173. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4174. return;
  4175. }
  4176. this.hide();
  4177. };
  4178. // 'static' option will be translated to true, and booleans will keep their value
  4179. const isVisible = Boolean(this._config.backdrop);
  4180. return new Backdrop({
  4181. className: CLASS_NAME_BACKDROP,
  4182. isVisible,
  4183. isAnimated: true,
  4184. rootElement: this._element.parentNode,
  4185. clickCallback: isVisible ? clickCallback : null
  4186. });
  4187. }
  4188. _initializeFocusTrap() {
  4189. return new FocusTrap({
  4190. trapElement: this._element
  4191. });
  4192. }
  4193. _addEventListeners() {
  4194. EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
  4195. if (event.key !== ESCAPE_KEY) {
  4196. return;
  4197. }
  4198. if (this._config.keyboard) {
  4199. this.hide();
  4200. return;
  4201. }
  4202. EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
  4203. });
  4204. }
  4205. // Static
  4206. static jQueryInterface(config) {
  4207. return this.each(function () {
  4208. const data = Offcanvas.getOrCreateInstance(this, config);
  4209. if (typeof config !== 'string') {
  4210. return;
  4211. }
  4212. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  4213. throw new TypeError(`No method named "${config}"`);
  4214. }
  4215. data[config](this);
  4216. });
  4217. }
  4218. }
  4219. /**
  4220. * Data API implementation
  4221. */
  4222. EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) {
  4223. const target = SelectorEngine.getElementFromSelector(this);
  4224. if (['A', 'AREA'].includes(this.tagName)) {
  4225. event.preventDefault();
  4226. }
  4227. if (isDisabled(this)) {
  4228. return;
  4229. }
  4230. EventHandler.one(target, EVENT_HIDDEN$3, () => {
  4231. // focus on trigger when it is closed
  4232. if (isVisible(this)) {
  4233. this.focus();
  4234. }
  4235. });
  4236. // avoid conflict when clicking a toggler of an offcanvas, while another is open
  4237. const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
  4238. if (alreadyOpen && alreadyOpen !== target) {
  4239. Offcanvas.getInstance(alreadyOpen).hide();
  4240. }
  4241. const data = Offcanvas.getOrCreateInstance(target);
  4242. data.toggle(this);
  4243. });
  4244. EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
  4245. for (const selector of SelectorEngine.find(OPEN_SELECTOR)) {
  4246. Offcanvas.getOrCreateInstance(selector).show();
  4247. }
  4248. });
  4249. EventHandler.on(window, EVENT_RESIZE, () => {
  4250. for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) {
  4251. if (getComputedStyle(element).position !== 'fixed') {
  4252. Offcanvas.getOrCreateInstance(element).hide();
  4253. }
  4254. }
  4255. });
  4256. enableDismissTrigger(Offcanvas);
  4257. /**
  4258. * jQuery
  4259. */
  4260. defineJQueryPlugin(Offcanvas);
  4261. /**
  4262. * --------------------------------------------------------------------------
  4263. * Bootstrap util/sanitizer.js
  4264. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4265. * --------------------------------------------------------------------------
  4266. */
  4267. // js-docs-start allow-list
  4268. const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4269. const DefaultAllowlist = {
  4270. // Global attributes allowed on any supplied element below.
  4271. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4272. a: ['target', 'href', 'title', 'rel'],
  4273. area: [],
  4274. b: [],
  4275. br: [],
  4276. col: [],
  4277. code: [],
  4278. dd: [],
  4279. div: [],
  4280. dl: [],
  4281. dt: [],
  4282. em: [],
  4283. hr: [],
  4284. h1: [],
  4285. h2: [],
  4286. h3: [],
  4287. h4: [],
  4288. h5: [],
  4289. h6: [],
  4290. i: [],
  4291. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  4292. li: [],
  4293. ol: [],
  4294. p: [],
  4295. pre: [],
  4296. s: [],
  4297. small: [],
  4298. span: [],
  4299. sub: [],
  4300. sup: [],
  4301. strong: [],
  4302. u: [],
  4303. ul: []
  4304. };
  4305. // js-docs-end allow-list
  4306. const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
  4307. /**
  4308. * A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
  4309. * contexts.
  4310. *
  4311. * Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
  4312. */
  4313. // eslint-disable-next-line unicorn/better-regex
  4314. const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
  4315. const allowedAttribute = (attribute, allowedAttributeList) => {
  4316. const attributeName = attribute.nodeName.toLowerCase();
  4317. if (allowedAttributeList.includes(attributeName)) {
  4318. if (uriAttributes.has(attributeName)) {
  4319. return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue));
  4320. }
  4321. return true;
  4322. }
  4323. // Check if a regular expression validates the attribute.
  4324. return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName));
  4325. };
  4326. function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
  4327. if (!unsafeHtml.length) {
  4328. return unsafeHtml;
  4329. }
  4330. if (sanitizeFunction && typeof sanitizeFunction === 'function') {
  4331. return sanitizeFunction(unsafeHtml);
  4332. }
  4333. const domParser = new window.DOMParser();
  4334. const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4335. const elements = [].concat(...createdDocument.body.querySelectorAll('*'));
  4336. for (const element of elements) {
  4337. const elementName = element.nodeName.toLowerCase();
  4338. if (!Object.keys(allowList).includes(elementName)) {
  4339. element.remove();
  4340. continue;
  4341. }
  4342. const attributeList = [].concat(...element.attributes);
  4343. const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []);
  4344. for (const attribute of attributeList) {
  4345. if (!allowedAttribute(attribute, allowedAttributes)) {
  4346. element.removeAttribute(attribute.nodeName);
  4347. }
  4348. }
  4349. }
  4350. return createdDocument.body.innerHTML;
  4351. }
  4352. /**
  4353. * --------------------------------------------------------------------------
  4354. * Bootstrap util/template-factory.js
  4355. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4356. * --------------------------------------------------------------------------
  4357. */
  4358. /**
  4359. * Constants
  4360. */
  4361. const NAME$5 = 'TemplateFactory';
  4362. const Default$4 = {
  4363. allowList: DefaultAllowlist,
  4364. content: {},
  4365. // { selector : text , selector2 : text2 , }
  4366. extraClass: '',
  4367. html: false,
  4368. sanitize: true,
  4369. sanitizeFn: null,
  4370. template: '<div></div>'
  4371. };
  4372. const DefaultType$4 = {
  4373. allowList: 'object',
  4374. content: 'object',
  4375. extraClass: '(string|function)',
  4376. html: 'boolean',
  4377. sanitize: 'boolean',
  4378. sanitizeFn: '(null|function)',
  4379. template: 'string'
  4380. };
  4381. const DefaultContentType = {
  4382. entry: '(string|element|function|null)',
  4383. selector: '(string|element)'
  4384. };
  4385. /**
  4386. * Class definition
  4387. */
  4388. class TemplateFactory extends Config {
  4389. constructor(config) {
  4390. super();
  4391. this._config = this._getConfig(config);
  4392. }
  4393. // Getters
  4394. static get Default() {
  4395. return Default$4;
  4396. }
  4397. static get DefaultType() {
  4398. return DefaultType$4;
  4399. }
  4400. static get NAME() {
  4401. return NAME$5;
  4402. }
  4403. // Public
  4404. getContent() {
  4405. return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean);
  4406. }
  4407. hasContent() {
  4408. return this.getContent().length > 0;
  4409. }
  4410. changeContent(content) {
  4411. this._checkContent(content);
  4412. this._config.content = {
  4413. ...this._config.content,
  4414. ...content
  4415. };
  4416. return this;
  4417. }
  4418. toHtml() {
  4419. const templateWrapper = document.createElement('div');
  4420. templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
  4421. for (const [selector, text] of Object.entries(this._config.content)) {
  4422. this._setContent(templateWrapper, text, selector);
  4423. }
  4424. const template = templateWrapper.children[0];
  4425. const extraClass = this._resolvePossibleFunction(this._config.extraClass);
  4426. if (extraClass) {
  4427. template.classList.add(...extraClass.split(' '));
  4428. }
  4429. return template;
  4430. }
  4431. // Private
  4432. _typeCheckConfig(config) {
  4433. super._typeCheckConfig(config);
  4434. this._checkContent(config.content);
  4435. }
  4436. _checkContent(arg) {
  4437. for (const [selector, content] of Object.entries(arg)) {
  4438. super._typeCheckConfig({
  4439. selector,
  4440. entry: content
  4441. }, DefaultContentType);
  4442. }
  4443. }
  4444. _setContent(template, content, selector) {
  4445. const templateElement = SelectorEngine.findOne(selector, template);
  4446. if (!templateElement) {
  4447. return;
  4448. }
  4449. content = this._resolvePossibleFunction(content);
  4450. if (!content) {
  4451. templateElement.remove();
  4452. return;
  4453. }
  4454. if (isElement$1(content)) {
  4455. this._putElementInTemplate(getElement(content), templateElement);
  4456. return;
  4457. }
  4458. if (this._config.html) {
  4459. templateElement.innerHTML = this._maybeSanitize(content);
  4460. return;
  4461. }
  4462. templateElement.textContent = content;
  4463. }
  4464. _maybeSanitize(arg) {
  4465. return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
  4466. }
  4467. _resolvePossibleFunction(arg) {
  4468. return execute(arg, [this]);
  4469. }
  4470. _putElementInTemplate(element, templateElement) {
  4471. if (this._config.html) {
  4472. templateElement.innerHTML = '';
  4473. templateElement.append(element);
  4474. return;
  4475. }
  4476. templateElement.textContent = element.textContent;
  4477. }
  4478. }
  4479. /**
  4480. * --------------------------------------------------------------------------
  4481. * Bootstrap tooltip.js
  4482. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4483. * --------------------------------------------------------------------------
  4484. */
  4485. /**
  4486. * Constants
  4487. */
  4488. const NAME$4 = 'tooltip';
  4489. const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
  4490. const CLASS_NAME_FADE$2 = 'fade';
  4491. const CLASS_NAME_MODAL = 'modal';
  4492. const CLASS_NAME_SHOW$2 = 'show';
  4493. const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  4494. const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
  4495. const EVENT_MODAL_HIDE = 'hide.bs.modal';
  4496. const TRIGGER_HOVER = 'hover';
  4497. const TRIGGER_FOCUS = 'focus';
  4498. const TRIGGER_CLICK = 'click';
  4499. const TRIGGER_MANUAL = 'manual';
  4500. const EVENT_HIDE$2 = 'hide';
  4501. const EVENT_HIDDEN$2 = 'hidden';
  4502. const EVENT_SHOW$2 = 'show';
  4503. const EVENT_SHOWN$2 = 'shown';
  4504. const EVENT_INSERTED = 'inserted';
  4505. const EVENT_CLICK$1 = 'click';
  4506. const EVENT_FOCUSIN$1 = 'focusin';
  4507. const EVENT_FOCUSOUT$1 = 'focusout';
  4508. const EVENT_MOUSEENTER = 'mouseenter';
  4509. const EVENT_MOUSELEAVE = 'mouseleave';
  4510. const AttachmentMap = {
  4511. AUTO: 'auto',
  4512. TOP: 'top',
  4513. RIGHT: isRTL() ? 'left' : 'right',
  4514. BOTTOM: 'bottom',
  4515. LEFT: isRTL() ? 'right' : 'left'
  4516. };
  4517. const Default$3 = {
  4518. allowList: DefaultAllowlist,
  4519. animation: true,
  4520. boundary: 'clippingParents',
  4521. container: false,
  4522. customClass: '',
  4523. delay: 0,
  4524. fallbackPlacements: ['top', 'right', 'bottom', 'left'],
  4525. html: false,
  4526. offset: [0, 6],
  4527. placement: 'top',
  4528. popperConfig: null,
  4529. sanitize: true,
  4530. sanitizeFn: null,
  4531. selector: false,
  4532. template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
  4533. title: '',
  4534. trigger: 'hover focus'
  4535. };
  4536. const DefaultType$3 = {
  4537. allowList: 'object',
  4538. animation: 'boolean',
  4539. boundary: '(string|element)',
  4540. container: '(string|element|boolean)',
  4541. customClass: '(string|function)',
  4542. delay: '(number|object)',
  4543. fallbackPlacements: 'array',
  4544. html: 'boolean',
  4545. offset: '(array|string|function)',
  4546. placement: '(string|function)',
  4547. popperConfig: '(null|object|function)',
  4548. sanitize: 'boolean',
  4549. sanitizeFn: '(null|function)',
  4550. selector: '(string|boolean)',
  4551. template: 'string',
  4552. title: '(string|element|function)',
  4553. trigger: 'string'
  4554. };
  4555. /**
  4556. * Class definition
  4557. */
  4558. class Tooltip extends BaseComponent {
  4559. constructor(element, config) {
  4560. if (typeof Popper === 'undefined') {
  4561. throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
  4562. }
  4563. super(element, config);
  4564. // Private
  4565. this._isEnabled = true;
  4566. this._timeout = 0;
  4567. this._isHovered = null;
  4568. this._activeTrigger = {};
  4569. this._popper = null;
  4570. this._templateFactory = null;
  4571. this._newContent = null;
  4572. // Protected
  4573. this.tip = null;
  4574. this._setListeners();
  4575. if (!this._config.selector) {
  4576. this._fixTitle();
  4577. }
  4578. }
  4579. // Getters
  4580. static get Default() {
  4581. return Default$3;
  4582. }
  4583. static get DefaultType() {
  4584. return DefaultType$3;
  4585. }
  4586. static get NAME() {
  4587. return NAME$4;
  4588. }
  4589. // Public
  4590. enable() {
  4591. this._isEnabled = true;
  4592. }
  4593. disable() {
  4594. this._isEnabled = false;
  4595. }
  4596. toggleEnabled() {
  4597. this._isEnabled = !this._isEnabled;
  4598. }
  4599. toggle() {
  4600. if (!this._isEnabled) {
  4601. return;
  4602. }
  4603. this._activeTrigger.click = !this._activeTrigger.click;
  4604. if (this._isShown()) {
  4605. this._leave();
  4606. return;
  4607. }
  4608. this._enter();
  4609. }
  4610. dispose() {
  4611. clearTimeout(this._timeout);
  4612. EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  4613. if (this._element.getAttribute('data-bs-original-title')) {
  4614. this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
  4615. }
  4616. this._disposePopper();
  4617. super.dispose();
  4618. }
  4619. show() {
  4620. if (this._element.style.display === 'none') {
  4621. throw new Error('Please use show on visible elements');
  4622. }
  4623. if (!(this._isWithContent() && this._isEnabled)) {
  4624. return;
  4625. }
  4626. const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
  4627. const shadowRoot = findShadowRoot(this._element);
  4628. const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
  4629. if (showEvent.defaultPrevented || !isInTheDom) {
  4630. return;
  4631. }
  4632. // TODO: v6 remove this or make it optional
  4633. this._disposePopper();
  4634. const tip = this._getTipElement();
  4635. this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
  4636. const {
  4637. container
  4638. } = this._config;
  4639. if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
  4640. container.append(tip);
  4641. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
  4642. }
  4643. this._popper = this._createPopper(tip);
  4644. tip.classList.add(CLASS_NAME_SHOW$2);
  4645. // If this is a touch-enabled device we add extra
  4646. // empty mouseover listeners to the body's immediate children;
  4647. // only needed because of broken event delegation on iOS
  4648. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4649. if ('ontouchstart' in document.documentElement) {
  4650. for (const element of [].concat(...document.body.children)) {
  4651. EventHandler.on(element, 'mouseover', noop);
  4652. }
  4653. }
  4654. const complete = () => {
  4655. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
  4656. if (this._isHovered === false) {
  4657. this._leave();
  4658. }
  4659. this._isHovered = false;
  4660. };
  4661. this._queueCallback(complete, this.tip, this._isAnimated());
  4662. }
  4663. hide() {
  4664. if (!this._isShown()) {
  4665. return;
  4666. }
  4667. const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2));
  4668. if (hideEvent.defaultPrevented) {
  4669. return;
  4670. }
  4671. const tip = this._getTipElement();
  4672. tip.classList.remove(CLASS_NAME_SHOW$2);
  4673. // If this is a touch-enabled device we remove the extra
  4674. // empty mouseover listeners we added for iOS support
  4675. if ('ontouchstart' in document.documentElement) {
  4676. for (const element of [].concat(...document.body.children)) {
  4677. EventHandler.off(element, 'mouseover', noop);
  4678. }
  4679. }
  4680. this._activeTrigger[TRIGGER_CLICK] = false;
  4681. this._activeTrigger[TRIGGER_FOCUS] = false;
  4682. this._activeTrigger[TRIGGER_HOVER] = false;
  4683. this._isHovered = null; // it is a trick to support manual triggering
  4684. const complete = () => {
  4685. if (this._isWithActiveTrigger()) {
  4686. return;
  4687. }
  4688. if (!this._isHovered) {
  4689. this._disposePopper();
  4690. }
  4691. this._element.removeAttribute('aria-describedby');
  4692. EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
  4693. };
  4694. this._queueCallback(complete, this.tip, this._isAnimated());
  4695. }
  4696. update() {
  4697. if (this._popper) {
  4698. this._popper.update();
  4699. }
  4700. }
  4701. // Protected
  4702. _isWithContent() {
  4703. return Boolean(this._getTitle());
  4704. }
  4705. _getTipElement() {
  4706. if (!this.tip) {
  4707. this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
  4708. }
  4709. return this.tip;
  4710. }
  4711. _createTipElement(content) {
  4712. const tip = this._getTemplateFactory(content).toHtml();
  4713. // TODO: remove this check in v6
  4714. if (!tip) {
  4715. return null;
  4716. }
  4717. tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2);
  4718. // TODO: v6 the following can be achieved with CSS only
  4719. tip.classList.add(`bs-${this.constructor.NAME}-auto`);
  4720. const tipId = getUID(this.constructor.NAME).toString();
  4721. tip.setAttribute('id', tipId);
  4722. if (this._isAnimated()) {
  4723. tip.classList.add(CLASS_NAME_FADE$2);
  4724. }
  4725. return tip;
  4726. }
  4727. setContent(content) {
  4728. this._newContent = content;
  4729. if (this._isShown()) {
  4730. this._disposePopper();
  4731. this.show();
  4732. }
  4733. }
  4734. _getTemplateFactory(content) {
  4735. if (this._templateFactory) {
  4736. this._templateFactory.changeContent(content);
  4737. } else {
  4738. this._templateFactory = new TemplateFactory({
  4739. ...this._config,
  4740. // the `content` var has to be after `this._config`
  4741. // to override config.content in case of popover
  4742. content,
  4743. extraClass: this._resolvePossibleFunction(this._config.customClass)
  4744. });
  4745. }
  4746. return this._templateFactory;
  4747. }
  4748. _getContentForTemplate() {
  4749. return {
  4750. [SELECTOR_TOOLTIP_INNER]: this._getTitle()
  4751. };
  4752. }
  4753. _getTitle() {
  4754. return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
  4755. }
  4756. // Private
  4757. _initializeOnDelegatedTarget(event) {
  4758. return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
  4759. }
  4760. _isAnimated() {
  4761. return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2);
  4762. }
  4763. _isShown() {
  4764. return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
  4765. }
  4766. _createPopper(tip) {
  4767. const placement = execute(this._config.placement, [this, tip, this._element]);
  4768. const attachment = AttachmentMap[placement.toUpperCase()];
  4769. return createPopper(this._element, tip, this._getPopperConfig(attachment));
  4770. }
  4771. _getOffset() {
  4772. const {
  4773. offset
  4774. } = this._config;
  4775. if (typeof offset === 'string') {
  4776. return offset.split(',').map(value => Number.parseInt(value, 10));
  4777. }
  4778. if (typeof offset === 'function') {
  4779. return popperData => offset(popperData, this._element);
  4780. }
  4781. return offset;
  4782. }
  4783. _resolvePossibleFunction(arg) {
  4784. return execute(arg, [this._element]);
  4785. }
  4786. _getPopperConfig(attachment) {
  4787. const defaultBsPopperConfig = {
  4788. placement: attachment,
  4789. modifiers: [{
  4790. name: 'flip',
  4791. options: {
  4792. fallbackPlacements: this._config.fallbackPlacements
  4793. }
  4794. }, {
  4795. name: 'offset',
  4796. options: {
  4797. offset: this._getOffset()
  4798. }
  4799. }, {
  4800. name: 'preventOverflow',
  4801. options: {
  4802. boundary: this._config.boundary
  4803. }
  4804. }, {
  4805. name: 'arrow',
  4806. options: {
  4807. element: `.${this.constructor.NAME}-arrow`
  4808. }
  4809. }, {
  4810. name: 'preSetPlacement',
  4811. enabled: true,
  4812. phase: 'beforeMain',
  4813. fn: data => {
  4814. // Pre-set Popper's placement attribute in order to read the arrow sizes properly.
  4815. // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
  4816. this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
  4817. }
  4818. }]
  4819. };
  4820. return {
  4821. ...defaultBsPopperConfig,
  4822. ...execute(this._config.popperConfig, [defaultBsPopperConfig])
  4823. };
  4824. }
  4825. _setListeners() {
  4826. const triggers = this._config.trigger.split(' ');
  4827. for (const trigger of triggers) {
  4828. if (trigger === 'click') {
  4829. EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => {
  4830. const context = this._initializeOnDelegatedTarget(event);
  4831. context.toggle();
  4832. });
  4833. } else if (trigger !== TRIGGER_MANUAL) {
  4834. const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1);
  4835. const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1);
  4836. EventHandler.on(this._element, eventIn, this._config.selector, event => {
  4837. const context = this._initializeOnDelegatedTarget(event);
  4838. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  4839. context._enter();
  4840. });
  4841. EventHandler.on(this._element, eventOut, this._config.selector, event => {
  4842. const context = this._initializeOnDelegatedTarget(event);
  4843. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
  4844. context._leave();
  4845. });
  4846. }
  4847. }
  4848. this._hideModalHandler = () => {
  4849. if (this._element) {
  4850. this.hide();
  4851. }
  4852. };
  4853. EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
  4854. }
  4855. _fixTitle() {
  4856. const title = this._element.getAttribute('title');
  4857. if (!title) {
  4858. return;
  4859. }
  4860. if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
  4861. this._element.setAttribute('aria-label', title);
  4862. }
  4863. this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
  4864. this._element.removeAttribute('title');
  4865. }
  4866. _enter() {
  4867. if (this._isShown() || this._isHovered) {
  4868. this._isHovered = true;
  4869. return;
  4870. }
  4871. this._isHovered = true;
  4872. this._setTimeout(() => {
  4873. if (this._isHovered) {
  4874. this.show();
  4875. }
  4876. }, this._config.delay.show);
  4877. }
  4878. _leave() {
  4879. if (this._isWithActiveTrigger()) {
  4880. return;
  4881. }
  4882. this._isHovered = false;
  4883. this._setTimeout(() => {
  4884. if (!this._isHovered) {
  4885. this.hide();
  4886. }
  4887. }, this._config.delay.hide);
  4888. }
  4889. _setTimeout(handler, timeout) {
  4890. clearTimeout(this._timeout);
  4891. this._timeout = setTimeout(handler, timeout);
  4892. }
  4893. _isWithActiveTrigger() {
  4894. return Object.values(this._activeTrigger).includes(true);
  4895. }
  4896. _getConfig(config) {
  4897. const dataAttributes = Manipulator.getDataAttributes(this._element);
  4898. for (const dataAttribute of Object.keys(dataAttributes)) {
  4899. if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
  4900. delete dataAttributes[dataAttribute];
  4901. }
  4902. }
  4903. config = {
  4904. ...dataAttributes,
  4905. ...(typeof config === 'object' && config ? config : {})
  4906. };
  4907. config = this._mergeConfigObj(config);
  4908. config = this._configAfterMerge(config);
  4909. this._typeCheckConfig(config);
  4910. return config;
  4911. }
  4912. _configAfterMerge(config) {
  4913. config.container = config.container === false ? document.body : getElement(config.container);
  4914. if (typeof config.delay === 'number') {
  4915. config.delay = {
  4916. show: config.delay,
  4917. hide: config.delay
  4918. };
  4919. }
  4920. if (typeof config.title === 'number') {
  4921. config.title = config.title.toString();
  4922. }
  4923. if (typeof config.content === 'number') {
  4924. config.content = config.content.toString();
  4925. }
  4926. return config;
  4927. }
  4928. _getDelegateConfig() {
  4929. const config = {};
  4930. for (const [key, value] of Object.entries(this._config)) {
  4931. if (this.constructor.Default[key] !== value) {
  4932. config[key] = value;
  4933. }
  4934. }
  4935. config.selector = false;
  4936. config.trigger = 'manual';
  4937. // In the future can be replaced with:
  4938. // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
  4939. // `Object.fromEntries(keysWithDifferentValues)`
  4940. return config;
  4941. }
  4942. _disposePopper() {
  4943. if (this._popper) {
  4944. this._popper.destroy();
  4945. this._popper = null;
  4946. }
  4947. if (this.tip) {
  4948. this.tip.remove();
  4949. this.tip = null;
  4950. }
  4951. }
  4952. // Static
  4953. static jQueryInterface(config) {
  4954. return this.each(function () {
  4955. const data = Tooltip.getOrCreateInstance(this, config);
  4956. if (typeof config !== 'string') {
  4957. return;
  4958. }
  4959. if (typeof data[config] === 'undefined') {
  4960. throw new TypeError(`No method named "${config}"`);
  4961. }
  4962. data[config]();
  4963. });
  4964. }
  4965. }
  4966. /**
  4967. * jQuery
  4968. */
  4969. defineJQueryPlugin(Tooltip);
  4970. /**
  4971. * --------------------------------------------------------------------------
  4972. * Bootstrap popover.js
  4973. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  4974. * --------------------------------------------------------------------------
  4975. */
  4976. /**
  4977. * Constants
  4978. */
  4979. const NAME$3 = 'popover';
  4980. const SELECTOR_TITLE = '.popover-header';
  4981. const SELECTOR_CONTENT = '.popover-body';
  4982. const Default$2 = {
  4983. ...Tooltip.Default,
  4984. content: '',
  4985. offset: [0, 8],
  4986. placement: 'right',
  4987. template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>',
  4988. trigger: 'click'
  4989. };
  4990. const DefaultType$2 = {
  4991. ...Tooltip.DefaultType,
  4992. content: '(null|string|element|function)'
  4993. };
  4994. /**
  4995. * Class definition
  4996. */
  4997. class Popover extends Tooltip {
  4998. // Getters
  4999. static get Default() {
  5000. return Default$2;
  5001. }
  5002. static get DefaultType() {
  5003. return DefaultType$2;
  5004. }
  5005. static get NAME() {
  5006. return NAME$3;
  5007. }
  5008. // Overrides
  5009. _isWithContent() {
  5010. return this._getTitle() || this._getContent();
  5011. }
  5012. // Private
  5013. _getContentForTemplate() {
  5014. return {
  5015. [SELECTOR_TITLE]: this._getTitle(),
  5016. [SELECTOR_CONTENT]: this._getContent()
  5017. };
  5018. }
  5019. _getContent() {
  5020. return this._resolvePossibleFunction(this._config.content);
  5021. }
  5022. // Static
  5023. static jQueryInterface(config) {
  5024. return this.each(function () {
  5025. const data = Popover.getOrCreateInstance(this, config);
  5026. if (typeof config !== 'string') {
  5027. return;
  5028. }
  5029. if (typeof data[config] === 'undefined') {
  5030. throw new TypeError(`No method named "${config}"`);
  5031. }
  5032. data[config]();
  5033. });
  5034. }
  5035. }
  5036. /**
  5037. * jQuery
  5038. */
  5039. defineJQueryPlugin(Popover);
  5040. /**
  5041. * --------------------------------------------------------------------------
  5042. * Bootstrap scrollspy.js
  5043. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5044. * --------------------------------------------------------------------------
  5045. */
  5046. /**
  5047. * Constants
  5048. */
  5049. const NAME$2 = 'scrollspy';
  5050. const DATA_KEY$2 = 'bs.scrollspy';
  5051. const EVENT_KEY$2 = `.${DATA_KEY$2}`;
  5052. const DATA_API_KEY = '.data-api';
  5053. const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`;
  5054. const EVENT_CLICK = `click${EVENT_KEY$2}`;
  5055. const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`;
  5056. const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  5057. const CLASS_NAME_ACTIVE$1 = 'active';
  5058. const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
  5059. const SELECTOR_TARGET_LINKS = '[href]';
  5060. const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  5061. const SELECTOR_NAV_LINKS = '.nav-link';
  5062. const SELECTOR_NAV_ITEMS = '.nav-item';
  5063. const SELECTOR_LIST_ITEMS = '.list-group-item';
  5064. const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
  5065. const SELECTOR_DROPDOWN = '.dropdown';
  5066. const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  5067. const Default$1 = {
  5068. offset: null,
  5069. // TODO: v6 @deprecated, keep it for backwards compatibility reasons
  5070. rootMargin: '0px 0px -25%',
  5071. smoothScroll: false,
  5072. target: null,
  5073. threshold: [0.1, 0.5, 1]
  5074. };
  5075. const DefaultType$1 = {
  5076. offset: '(number|null)',
  5077. // TODO v6 @deprecated, keep it for backwards compatibility reasons
  5078. rootMargin: 'string',
  5079. smoothScroll: 'boolean',
  5080. target: 'element',
  5081. threshold: 'array'
  5082. };
  5083. /**
  5084. * Class definition
  5085. */
  5086. class ScrollSpy extends BaseComponent {
  5087. constructor(element, config) {
  5088. super(element, config);
  5089. // this._element is the observablesContainer and config.target the menu links wrapper
  5090. this._targetLinks = new Map();
  5091. this._observableSections = new Map();
  5092. this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
  5093. this._activeTarget = null;
  5094. this._observer = null;
  5095. this._previousScrollData = {
  5096. visibleEntryTop: 0,
  5097. parentScrollTop: 0
  5098. };
  5099. this.refresh(); // initialize
  5100. }
  5101. // Getters
  5102. static get Default() {
  5103. return Default$1;
  5104. }
  5105. static get DefaultType() {
  5106. return DefaultType$1;
  5107. }
  5108. static get NAME() {
  5109. return NAME$2;
  5110. }
  5111. // Public
  5112. refresh() {
  5113. this._initializeTargetsAndObservables();
  5114. this._maybeEnableSmoothScroll();
  5115. if (this._observer) {
  5116. this._observer.disconnect();
  5117. } else {
  5118. this._observer = this._getNewObserver();
  5119. }
  5120. for (const section of this._observableSections.values()) {
  5121. this._observer.observe(section);
  5122. }
  5123. }
  5124. dispose() {
  5125. this._observer.disconnect();
  5126. super.dispose();
  5127. }
  5128. // Private
  5129. _configAfterMerge(config) {
  5130. // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
  5131. config.target = getElement(config.target) || document.body;
  5132. // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
  5133. config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
  5134. if (typeof config.threshold === 'string') {
  5135. config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
  5136. }
  5137. return config;
  5138. }
  5139. _maybeEnableSmoothScroll() {
  5140. if (!this._config.smoothScroll) {
  5141. return;
  5142. }
  5143. // unregister any previous listeners
  5144. EventHandler.off(this._config.target, EVENT_CLICK);
  5145. EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
  5146. const observableSection = this._observableSections.get(event.target.hash);
  5147. if (observableSection) {
  5148. event.preventDefault();
  5149. const root = this._rootElement || window;
  5150. const height = observableSection.offsetTop - this._element.offsetTop;
  5151. if (root.scrollTo) {
  5152. root.scrollTo({
  5153. top: height,
  5154. behavior: 'smooth'
  5155. });
  5156. return;
  5157. }
  5158. // Chrome 60 doesn't support `scrollTo`
  5159. root.scrollTop = height;
  5160. }
  5161. });
  5162. }
  5163. _getNewObserver() {
  5164. const options = {
  5165. root: this._rootElement,
  5166. threshold: this._config.threshold,
  5167. rootMargin: this._config.rootMargin
  5168. };
  5169. return new IntersectionObserver(entries => this._observerCallback(entries), options);
  5170. }
  5171. // The logic of selection
  5172. _observerCallback(entries) {
  5173. const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
  5174. const activate = entry => {
  5175. this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
  5176. this._process(targetElement(entry));
  5177. };
  5178. const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
  5179. const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
  5180. this._previousScrollData.parentScrollTop = parentScrollTop;
  5181. for (const entry of entries) {
  5182. if (!entry.isIntersecting) {
  5183. this._activeTarget = null;
  5184. this._clearActiveClass(targetElement(entry));
  5185. continue;
  5186. }
  5187. const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
  5188. // if we are scrolling down, pick the bigger offsetTop
  5189. if (userScrollsDown && entryIsLowerThanPrevious) {
  5190. activate(entry);
  5191. // if parent isn't scrolled, let's keep the first visible item, breaking the iteration
  5192. if (!parentScrollTop) {
  5193. return;
  5194. }
  5195. continue;
  5196. }
  5197. // if we are scrolling up, pick the smallest offsetTop
  5198. if (!userScrollsDown && !entryIsLowerThanPrevious) {
  5199. activate(entry);
  5200. }
  5201. }
  5202. }
  5203. _initializeTargetsAndObservables() {
  5204. this._targetLinks = new Map();
  5205. this._observableSections = new Map();
  5206. const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
  5207. for (const anchor of targetLinks) {
  5208. // ensure that the anchor has an id and is not disabled
  5209. if (!anchor.hash || isDisabled(anchor)) {
  5210. continue;
  5211. }
  5212. const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
  5213. // ensure that the observableSection exists & is visible
  5214. if (isVisible(observableSection)) {
  5215. this._targetLinks.set(decodeURI(anchor.hash), anchor);
  5216. this._observableSections.set(anchor.hash, observableSection);
  5217. }
  5218. }
  5219. }
  5220. _process(target) {
  5221. if (this._activeTarget === target) {
  5222. return;
  5223. }
  5224. this._clearActiveClass(this._config.target);
  5225. this._activeTarget = target;
  5226. target.classList.add(CLASS_NAME_ACTIVE$1);
  5227. this._activateParents(target);
  5228. EventHandler.trigger(this._element, EVENT_ACTIVATE, {
  5229. relatedTarget: target
  5230. });
  5231. }
  5232. _activateParents(target) {
  5233. // Activate dropdown parents
  5234. if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
  5235. SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1);
  5236. return;
  5237. }
  5238. for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
  5239. // Set triggered links parents as active
  5240. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5241. for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
  5242. item.classList.add(CLASS_NAME_ACTIVE$1);
  5243. }
  5244. }
  5245. }
  5246. _clearActiveClass(parent) {
  5247. parent.classList.remove(CLASS_NAME_ACTIVE$1);
  5248. const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
  5249. for (const node of activeNodes) {
  5250. node.classList.remove(CLASS_NAME_ACTIVE$1);
  5251. }
  5252. }
  5253. // Static
  5254. static jQueryInterface(config) {
  5255. return this.each(function () {
  5256. const data = ScrollSpy.getOrCreateInstance(this, config);
  5257. if (typeof config !== 'string') {
  5258. return;
  5259. }
  5260. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5261. throw new TypeError(`No method named "${config}"`);
  5262. }
  5263. data[config]();
  5264. });
  5265. }
  5266. }
  5267. /**
  5268. * Data API implementation
  5269. */
  5270. EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
  5271. for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
  5272. ScrollSpy.getOrCreateInstance(spy);
  5273. }
  5274. });
  5275. /**
  5276. * jQuery
  5277. */
  5278. defineJQueryPlugin(ScrollSpy);
  5279. /**
  5280. * --------------------------------------------------------------------------
  5281. * Bootstrap tab.js
  5282. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5283. * --------------------------------------------------------------------------
  5284. */
  5285. /**
  5286. * Constants
  5287. */
  5288. const NAME$1 = 'tab';
  5289. const DATA_KEY$1 = 'bs.tab';
  5290. const EVENT_KEY$1 = `.${DATA_KEY$1}`;
  5291. const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`;
  5292. const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`;
  5293. const EVENT_SHOW$1 = `show${EVENT_KEY$1}`;
  5294. const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`;
  5295. const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
  5296. const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
  5297. const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
  5298. const ARROW_LEFT_KEY = 'ArrowLeft';
  5299. const ARROW_RIGHT_KEY = 'ArrowRight';
  5300. const ARROW_UP_KEY = 'ArrowUp';
  5301. const ARROW_DOWN_KEY = 'ArrowDown';
  5302. const HOME_KEY = 'Home';
  5303. const END_KEY = 'End';
  5304. const CLASS_NAME_ACTIVE = 'active';
  5305. const CLASS_NAME_FADE$1 = 'fade';
  5306. const CLASS_NAME_SHOW$1 = 'show';
  5307. const CLASS_DROPDOWN = 'dropdown';
  5308. const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  5309. const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
  5310. const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
  5311. const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
  5312. const SELECTOR_OUTER = '.nav-item, .list-group-item';
  5313. const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
  5314. const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // TODO: could only be `tab` in v6
  5315. const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
  5316. 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"]`;
  5317. /**
  5318. * Class definition
  5319. */
  5320. class Tab extends BaseComponent {
  5321. constructor(element) {
  5322. super(element);
  5323. this._parent = this._element.closest(SELECTOR_TAB_PANEL);
  5324. if (!this._parent) {
  5325. return;
  5326. // TODO: should throw exception in v6
  5327. // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
  5328. }
  5329. // Set up initial aria attributes
  5330. this._setInitialAttributes(this._parent, this._getChildren());
  5331. EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
  5332. }
  5333. // Getters
  5334. static get NAME() {
  5335. return NAME$1;
  5336. }
  5337. // Public
  5338. show() {
  5339. // Shows this elem and deactivate the active sibling if exists
  5340. const innerElem = this._element;
  5341. if (this._elemIsActive(innerElem)) {
  5342. return;
  5343. }
  5344. // Search for active tab on same parent to deactivate it
  5345. const active = this._getActiveElem();
  5346. const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, {
  5347. relatedTarget: innerElem
  5348. }) : null;
  5349. const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, {
  5350. relatedTarget: active
  5351. });
  5352. if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
  5353. return;
  5354. }
  5355. this._deactivate(active, innerElem);
  5356. this._activate(innerElem, active);
  5357. }
  5358. // Private
  5359. _activate(element, relatedElem) {
  5360. if (!element) {
  5361. return;
  5362. }
  5363. element.classList.add(CLASS_NAME_ACTIVE);
  5364. this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
  5365. const complete = () => {
  5366. if (element.getAttribute('role') !== 'tab') {
  5367. element.classList.add(CLASS_NAME_SHOW$1);
  5368. return;
  5369. }
  5370. element.removeAttribute('tabindex');
  5371. element.setAttribute('aria-selected', true);
  5372. this._toggleDropDown(element, true);
  5373. EventHandler.trigger(element, EVENT_SHOWN$1, {
  5374. relatedTarget: relatedElem
  5375. });
  5376. };
  5377. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5378. }
  5379. _deactivate(element, relatedElem) {
  5380. if (!element) {
  5381. return;
  5382. }
  5383. element.classList.remove(CLASS_NAME_ACTIVE);
  5384. element.blur();
  5385. this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
  5386. const complete = () => {
  5387. if (element.getAttribute('role') !== 'tab') {
  5388. element.classList.remove(CLASS_NAME_SHOW$1);
  5389. return;
  5390. }
  5391. element.setAttribute('aria-selected', false);
  5392. element.setAttribute('tabindex', '-1');
  5393. this._toggleDropDown(element, false);
  5394. EventHandler.trigger(element, EVENT_HIDDEN$1, {
  5395. relatedTarget: relatedElem
  5396. });
  5397. };
  5398. this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1));
  5399. }
  5400. _keydown(event) {
  5401. if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY, HOME_KEY, END_KEY].includes(event.key)) {
  5402. return;
  5403. }
  5404. event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
  5405. event.preventDefault();
  5406. const children = this._getChildren().filter(element => !isDisabled(element));
  5407. let nextActiveElement;
  5408. if ([HOME_KEY, END_KEY].includes(event.key)) {
  5409. nextActiveElement = children[event.key === HOME_KEY ? 0 : children.length - 1];
  5410. } else {
  5411. const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
  5412. nextActiveElement = getNextActiveElement(children, event.target, isNext, true);
  5413. }
  5414. if (nextActiveElement) {
  5415. nextActiveElement.focus({
  5416. preventScroll: true
  5417. });
  5418. Tab.getOrCreateInstance(nextActiveElement).show();
  5419. }
  5420. }
  5421. _getChildren() {
  5422. // collection of inner elements
  5423. return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
  5424. }
  5425. _getActiveElem() {
  5426. return this._getChildren().find(child => this._elemIsActive(child)) || null;
  5427. }
  5428. _setInitialAttributes(parent, children) {
  5429. this._setAttributeIfNotExists(parent, 'role', 'tablist');
  5430. for (const child of children) {
  5431. this._setInitialAttributesOnChild(child);
  5432. }
  5433. }
  5434. _setInitialAttributesOnChild(child) {
  5435. child = this._getInnerElement(child);
  5436. const isActive = this._elemIsActive(child);
  5437. const outerElem = this._getOuterElement(child);
  5438. child.setAttribute('aria-selected', isActive);
  5439. if (outerElem !== child) {
  5440. this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
  5441. }
  5442. if (!isActive) {
  5443. child.setAttribute('tabindex', '-1');
  5444. }
  5445. this._setAttributeIfNotExists(child, 'role', 'tab');
  5446. // set attributes to the related panel too
  5447. this._setInitialAttributesOnTargetPanel(child);
  5448. }
  5449. _setInitialAttributesOnTargetPanel(child) {
  5450. const target = SelectorEngine.getElementFromSelector(child);
  5451. if (!target) {
  5452. return;
  5453. }
  5454. this._setAttributeIfNotExists(target, 'role', 'tabpanel');
  5455. if (child.id) {
  5456. this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
  5457. }
  5458. }
  5459. _toggleDropDown(element, open) {
  5460. const outerElem = this._getOuterElement(element);
  5461. if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
  5462. return;
  5463. }
  5464. const toggle = (selector, className) => {
  5465. const element = SelectorEngine.findOne(selector, outerElem);
  5466. if (element) {
  5467. element.classList.toggle(className, open);
  5468. }
  5469. };
  5470. toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
  5471. toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1);
  5472. outerElem.setAttribute('aria-expanded', open);
  5473. }
  5474. _setAttributeIfNotExists(element, attribute, value) {
  5475. if (!element.hasAttribute(attribute)) {
  5476. element.setAttribute(attribute, value);
  5477. }
  5478. }
  5479. _elemIsActive(elem) {
  5480. return elem.classList.contains(CLASS_NAME_ACTIVE);
  5481. }
  5482. // Try to get the inner element (usually the .nav-link)
  5483. _getInnerElement(elem) {
  5484. return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
  5485. }
  5486. // Try to get the outer element (usually the .nav-item)
  5487. _getOuterElement(elem) {
  5488. return elem.closest(SELECTOR_OUTER) || elem;
  5489. }
  5490. // Static
  5491. static jQueryInterface(config) {
  5492. return this.each(function () {
  5493. const data = Tab.getOrCreateInstance(this);
  5494. if (typeof config !== 'string') {
  5495. return;
  5496. }
  5497. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  5498. throw new TypeError(`No method named "${config}"`);
  5499. }
  5500. data[config]();
  5501. });
  5502. }
  5503. }
  5504. /**
  5505. * Data API implementation
  5506. */
  5507. EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
  5508. if (['A', 'AREA'].includes(this.tagName)) {
  5509. event.preventDefault();
  5510. }
  5511. if (isDisabled(this)) {
  5512. return;
  5513. }
  5514. Tab.getOrCreateInstance(this).show();
  5515. });
  5516. /**
  5517. * Initialize on focus
  5518. */
  5519. EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
  5520. for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
  5521. Tab.getOrCreateInstance(element);
  5522. }
  5523. });
  5524. /**
  5525. * jQuery
  5526. */
  5527. defineJQueryPlugin(Tab);
  5528. /**
  5529. * --------------------------------------------------------------------------
  5530. * Bootstrap toast.js
  5531. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5532. * --------------------------------------------------------------------------
  5533. */
  5534. /**
  5535. * Constants
  5536. */
  5537. const NAME = 'toast';
  5538. const DATA_KEY = 'bs.toast';
  5539. const EVENT_KEY = `.${DATA_KEY}`;
  5540. const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
  5541. const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
  5542. const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
  5543. const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
  5544. const EVENT_HIDE = `hide${EVENT_KEY}`;
  5545. const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
  5546. const EVENT_SHOW = `show${EVENT_KEY}`;
  5547. const EVENT_SHOWN = `shown${EVENT_KEY}`;
  5548. const CLASS_NAME_FADE = 'fade';
  5549. const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
  5550. const CLASS_NAME_SHOW = 'show';
  5551. const CLASS_NAME_SHOWING = 'showing';
  5552. const DefaultType = {
  5553. animation: 'boolean',
  5554. autohide: 'boolean',
  5555. delay: 'number'
  5556. };
  5557. const Default = {
  5558. animation: true,
  5559. autohide: true,
  5560. delay: 5000
  5561. };
  5562. /**
  5563. * Class definition
  5564. */
  5565. class Toast extends BaseComponent {
  5566. constructor(element, config) {
  5567. super(element, config);
  5568. this._timeout = null;
  5569. this._hasMouseInteraction = false;
  5570. this._hasKeyboardInteraction = false;
  5571. this._setListeners();
  5572. }
  5573. // Getters
  5574. static get Default() {
  5575. return Default;
  5576. }
  5577. static get DefaultType() {
  5578. return DefaultType;
  5579. }
  5580. static get NAME() {
  5581. return NAME;
  5582. }
  5583. // Public
  5584. show() {
  5585. const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
  5586. if (showEvent.defaultPrevented) {
  5587. return;
  5588. }
  5589. this._clearTimeout();
  5590. if (this._config.animation) {
  5591. this._element.classList.add(CLASS_NAME_FADE);
  5592. }
  5593. const complete = () => {
  5594. this._element.classList.remove(CLASS_NAME_SHOWING);
  5595. EventHandler.trigger(this._element, EVENT_SHOWN);
  5596. this._maybeScheduleHide();
  5597. };
  5598. this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
  5599. reflow(this._element);
  5600. this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
  5601. this._queueCallback(complete, this._element, this._config.animation);
  5602. }
  5603. hide() {
  5604. if (!this.isShown()) {
  5605. return;
  5606. }
  5607. const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
  5608. if (hideEvent.defaultPrevented) {
  5609. return;
  5610. }
  5611. const complete = () => {
  5612. this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
  5613. this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
  5614. EventHandler.trigger(this._element, EVENT_HIDDEN);
  5615. };
  5616. this._element.classList.add(CLASS_NAME_SHOWING);
  5617. this._queueCallback(complete, this._element, this._config.animation);
  5618. }
  5619. dispose() {
  5620. this._clearTimeout();
  5621. if (this.isShown()) {
  5622. this._element.classList.remove(CLASS_NAME_SHOW);
  5623. }
  5624. super.dispose();
  5625. }
  5626. isShown() {
  5627. return this._element.classList.contains(CLASS_NAME_SHOW);
  5628. }
  5629. // Private
  5630. _maybeScheduleHide() {
  5631. if (!this._config.autohide) {
  5632. return;
  5633. }
  5634. if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
  5635. return;
  5636. }
  5637. this._timeout = setTimeout(() => {
  5638. this.hide();
  5639. }, this._config.delay);
  5640. }
  5641. _onInteraction(event, isInteracting) {
  5642. switch (event.type) {
  5643. case 'mouseover':
  5644. case 'mouseout':
  5645. {
  5646. this._hasMouseInteraction = isInteracting;
  5647. break;
  5648. }
  5649. case 'focusin':
  5650. case 'focusout':
  5651. {
  5652. this._hasKeyboardInteraction = isInteracting;
  5653. break;
  5654. }
  5655. }
  5656. if (isInteracting) {
  5657. this._clearTimeout();
  5658. return;
  5659. }
  5660. const nextElement = event.relatedTarget;
  5661. if (this._element === nextElement || this._element.contains(nextElement)) {
  5662. return;
  5663. }
  5664. this._maybeScheduleHide();
  5665. }
  5666. _setListeners() {
  5667. EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
  5668. EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
  5669. EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
  5670. EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
  5671. }
  5672. _clearTimeout() {
  5673. clearTimeout(this._timeout);
  5674. this._timeout = null;
  5675. }
  5676. // Static
  5677. static jQueryInterface(config) {
  5678. return this.each(function () {
  5679. const data = Toast.getOrCreateInstance(this, config);
  5680. if (typeof config === 'string') {
  5681. if (typeof data[config] === 'undefined') {
  5682. throw new TypeError(`No method named "${config}"`);
  5683. }
  5684. data[config](this);
  5685. }
  5686. });
  5687. }
  5688. }
  5689. /**
  5690. * Data API implementation
  5691. */
  5692. enableDismissTrigger(Toast);
  5693. /**
  5694. * jQuery
  5695. */
  5696. defineJQueryPlugin(Toast);
  5697. /**
  5698. * --------------------------------------------------------------------------
  5699. * Bootstrap index.umd.js
  5700. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5701. * --------------------------------------------------------------------------
  5702. */
  5703. const index_umd = {
  5704. Alert,
  5705. Button,
  5706. Carousel,
  5707. Collapse,
  5708. Dropdown,
  5709. Modal,
  5710. Offcanvas,
  5711. Popover,
  5712. ScrollSpy,
  5713. Tab,
  5714. Toast,
  5715. Tooltip
  5716. };
  5717. return index_umd;
  5718. }));
  5719. //# sourceMappingURL=bootstrap.bundle.js.map