/*!
* Bootstrap v6.0.0-alpha.2 (https://getbootstrap.com/)
* Copyright 2011-2026 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
//#region js/src/dom/data.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/data.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const elementMap = /* @__PURE__ */ new Map();
var data_default = {
set(element, key, instance) {
if (!elementMap.has(element)) elementMap.set(element, /* @__PURE__ */ new Map());
elementMap.get(element).set(key, instance);
},
get(element, key) {
if (element && elementMap.has(element)) return elementMap.get(element).get(key) || null;
return null;
},
remove(element, key) {
if (!elementMap.has(element)) return;
const instanceMap = elementMap.get(element);
instanceMap.delete(key);
if (instanceMap.size === 0) elementMap.delete(element);
}
};
//#endregion
//#region js/src/dom/event-handler.ts
/**
* Constants
*/
const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
const stripNameRegex = /\..*/;
const stripUidRegex = /::\d+$/;
const eventRegistry = {};
let uidEvent = 1;
const customEvents = {
mouseenter: "mouseover",
mouseleave: "mouseout"
};
const nativeEvents = /* @__PURE__ */ new Set([
"click",
"dblclick",
"mouseup",
"mousedown",
"contextmenu",
"mousewheel",
"DOMMouseScroll",
"mouseover",
"mouseout",
"mousemove",
"selectstart",
"selectend",
"keydown",
"keypress",
"keyup",
"input",
"compositionstart",
"compositionupdate",
"compositionend",
"paste",
"orientationchange",
"touchstart",
"touchmove",
"touchend",
"touchcancel",
"pointerdown",
"pointermove",
"pointerover",
"pointerup",
"pointerleave",
"pointercancel",
"gesturestart",
"gesturechange",
"gestureend",
"focus",
"blur",
"change",
"reset",
"select",
"submit",
"focusin",
"focusout",
"load",
"unload",
"beforeunload",
"resize",
"move",
"DOMContentLoaded",
"readystatechange",
"error",
"abort",
"scroll",
"scrollend",
"hashchange"
]);
/**
* Private methods
*/
function makeEventUid(element, uid) {
return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++;
}
function getElementEvents(element) {
const uid = makeEventUid(element);
element.uidEvent = uid;
eventRegistry[uid] = eventRegistry[uid] || {};
return eventRegistry[uid];
}
function isMouseEventWithinTarget(event) {
const { delegateTarget, relatedTarget } = event;
return Boolean(relatedTarget && delegateTarget.contains(relatedTarget));
}
function bootstrapHandler(element, fn, handlerTypeEvent) {
const isCustomMouseEvent = handlerTypeEvent in customEvents;
return function handler(event) {
const bootstrapEvent = hydrateObj(event, { delegateTarget: element });
if (isCustomMouseEvent && isMouseEventWithinTarget(bootstrapEvent)) return;
if (handler.oneOff) EventHandler.off(element, handlerTypeEvent, fn);
return fn.apply(element, [bootstrapEvent]);
};
}
function bootstrapDelegationHandler(element, selector, fn, handlerTypeEvent) {
const isCustomMouseEvent = handlerTypeEvent in customEvents;
return function handler(event) {
const domElements = element.querySelectorAll(selector);
for (let { target } = event; target && target !== this; target = target.parentNode) for (const domElement of domElements) {
if (domElement !== target) continue;
const bootstrapEvent = hydrateObj(event, { delegateTarget: target });
if (isCustomMouseEvent && isMouseEventWithinTarget(bootstrapEvent)) return;
if (handler.oneOff) EventHandler.off(element, handlerTypeEvent, selector, fn);
return fn.apply(target, [bootstrapEvent]);
}
};
}
function findHandler(events, callable, handlerTypeEvent, delegationSelector = null) {
return Object.values(events).find((event) => event.callable === callable && event.handlerTypeEvent === handlerTypeEvent && event.delegationSelector === delegationSelector);
}
function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
const isDelegated = typeof handler === "string";
const callable = isDelegated ? delegationFunction : handler || delegationFunction;
const baseTypeEvent = originalTypeEvent.replace(stripNameRegex, "");
let typeEvent = customEvents[baseTypeEvent] || baseTypeEvent;
if (!nativeEvents.has(typeEvent)) typeEvent = originalTypeEvent;
const handlerTypeEvent = baseTypeEvent in customEvents ? baseTypeEvent : typeEvent;
return {
isDelegated,
callable,
typeEvent,
handlerTypeEvent
};
}
function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
if (typeof originalTypeEvent !== "string" || !element) return;
const { isDelegated, callable, typeEvent, handlerTypeEvent } = normalizeParameters(originalTypeEvent, handler, delegationFunction);
const events = getElementEvents(element);
const handlers = events[typeEvent] || (events[typeEvent] = {});
const previousFunction = findHandler(handlers, callable, handlerTypeEvent, isDelegated ? handler : null);
if (previousFunction) {
previousFunction.oneOff = previousFunction.oneOff && oneOff;
return;
}
const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, ""));
const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable, handlerTypeEvent) : bootstrapHandler(element, callable, handlerTypeEvent);
fn.delegationSelector = isDelegated ? handler : null;
fn.callable = callable;
fn.handlerTypeEvent = handlerTypeEvent;
fn.oneOff = oneOff;
fn.uidEvent = uid;
handlers[uid] = fn;
element.addEventListener(typeEvent, fn, isDelegated);
}
function removeHandler(element, events, typeEvent, handler) {
element.removeEventListener(typeEvent, handler, Boolean(handler.delegationSelector));
delete events[typeEvent][handler.uidEvent];
}
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
const storeElementEvent = events[typeEvent] || {};
for (const [handlerKey, event] of Object.entries(storeElementEvent)) if (handlerKey.includes(namespace)) removeHandler(element, events, typeEvent, event);
}
function trigger(element, event, args) {
if (typeof event !== "string" || !element) return null;
const evt = hydrateObj(new Event(event, {
bubbles: true,
cancelable: true
}), args);
element.dispatchEvent(evt);
return evt;
}
const EventHandler = {
on(element, event, handler, delegationFunction) {
addHandler(element, event, handler, delegationFunction, false);
},
one(element, event, handler, delegationFunction) {
addHandler(element, event, handler, delegationFunction, true);
},
off(element, originalTypeEvent, handler, delegationFunction) {
if (typeof originalTypeEvent !== "string" || !element) return;
const { isDelegated, callable, typeEvent, handlerTypeEvent } = normalizeParameters(originalTypeEvent, handler, delegationFunction);
const inNamespace = typeEvent !== originalTypeEvent && handlerTypeEvent !== originalTypeEvent;
const events = getElementEvents(element);
const storeElementEvent = events[typeEvent] || {};
const isNamespace = originalTypeEvent.startsWith(".");
if (typeof callable !== "undefined") {
if (!Object.keys(storeElementEvent).length) return;
const fn = findHandler(storeElementEvent, callable, handlerTypeEvent, isDelegated ? handler : null);
if (fn) removeHandler(element, events, typeEvent, fn);
return;
}
if (isNamespace) for (const elementEvent of Object.keys(events)) removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
for (const [keyHandlers, event] of Object.entries(storeElementEvent)) {
const handlerKey = keyHandlers.replace(stripUidRegex, "");
if (event.handlerTypeEvent === handlerTypeEvent && (!inNamespace || originalTypeEvent.includes(handlerKey))) removeHandler(element, events, typeEvent, event);
}
},
trigger
};
function hydrateObj(obj, meta = {}) {
for (const [key, value] of Object.entries(meta)) try {
obj[key] = value;
} catch {
Object.defineProperty(obj, key, {
configurable: true,
get() {
return value;
}
});
}
return obj;
}
//#endregion
//#region js/src/dom/manipulator.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/manipulator.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
function normalizeData(value) {
if (value === "true") return true;
if (value === "false") return false;
if (value === Number(value).toString()) return Number(value);
if (value === "" || value === "null") return null;
if (typeof value !== "string") return value;
try {
return JSON.parse(decodeURIComponent(value));
} catch {
return value;
}
}
function normalizeDataKey(key) {
return key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`);
}
const Manipulator = {
setDataAttribute(element, key, value) {
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value);
},
removeDataAttribute(element, key) {
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`);
},
getDataAttributes(element) {
if (!element) return {};
const attributes = {};
const bsKeys = Object.keys(element.dataset).filter((key) => key.startsWith("bs") && !key.startsWith("bsConfig"));
for (const key of bsKeys) {
let pureKey = key.replace(/^bs/, "");
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1);
attributes[pureKey] = normalizeData(element.dataset[key]);
}
return attributes;
},
getDataAttribute(element, key) {
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`));
}
};
//#endregion
//#region js/src/util/index.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/index.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const MAX_UID = 1e6;
const MILLISECONDS_MULTIPLIER = 1e3;
const TRANSITION_END = "transitionend";
/**
* Properly escapes ID selectors to handle special characters in IDs
* (e.g. forward slashes, periods) so that they work with `document.querySelector`.
*
* @param selector - The selector to escape
* @returns The escaped selector
*/
const parseSelector = (selector) => {
if (selector && window.CSS && window.CSS.escape) selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
return selector;
};
const toType = (object) => {
if (object === null || object === void 0) return `${object}`;
return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
};
/**
* Public Util API
*/
const getUID = (prefix) => {
do
prefix += Math.floor(Math.random() * MAX_UID);
while (document.getElementById(prefix));
return prefix;
};
const getTransitionDurationFromElement = (element) => {
if (!element) return 0;
let { transitionDuration, transitionDelay } = window.getComputedStyle(element);
if (!Number.parseFloat(transitionDuration) && !Number.parseFloat(transitionDelay)) return 0;
transitionDuration = transitionDuration.split(",")[0];
transitionDelay = transitionDelay.split(",")[0];
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
const triggerTransitionEnd = (element) => {
element.dispatchEvent(new Event(TRANSITION_END));
};
const isElement$1 = (object) => {
if (!object || typeof object !== "object") return false;
return typeof object.nodeType !== "undefined";
};
const getElement = (object) => {
if (isElement$1(object)) return object;
if (typeof object === "string" && object.length > 0) return document.querySelector(parseSelector(object));
return null;
};
const isVisible = (element) => {
if (!isElement$1(element) || element.getClientRects().length === 0) return false;
const elementIsVisible = getComputedStyle(element).getPropertyValue("visibility") === "visible";
const closedDetails = element.closest("details:not([open])");
if (!closedDetails) return elementIsVisible;
if (closedDetails !== element) {
const summary = element.closest("summary");
if (summary && summary.parentNode !== closedDetails) return false;
if (summary === null) return false;
}
return elementIsVisible;
};
const isDisabled = (element) => {
if (!element || element.nodeType !== Node.ELEMENT_NODE) return true;
if (element.classList.contains("disabled")) return true;
const disableableElement = element;
if (typeof disableableElement.disabled !== "undefined") return disableableElement.disabled;
return element.hasAttribute("disabled") && element.getAttribute("disabled") !== "false";
};
const setAriaAttribute = (element, name, value) => {
element.setAttribute(name, String(value));
};
const findShadowRoot = (element) => {
if (!document.documentElement.attachShadow) return null;
if (typeof element.getRootNode === "function") {
const root = element.getRootNode();
return root instanceof ShadowRoot ? root : null;
}
if (element instanceof ShadowRoot) return element;
if (!element.parentNode) return null;
return findShadowRoot(element.parentNode);
};
const noop = () => {};
const isRTL$1 = () => document.documentElement.dir === "rtl";
const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
return typeof possibleCallback === "function" ? possibleCallback.call(...args) : defaultValue;
};
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
if (!waitForTransition) {
execute(callback);
return;
}
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + 5;
const handler = ({ target }) => {
if (target !== transitionElement) return;
cancel();
execute(callback);
};
transitionElement.addEventListener(TRANSITION_END, handler);
const timeout = setTimeout(() => triggerTransitionEnd(transitionElement), emulatedDuration);
const cancel = () => {
clearTimeout(timeout);
transitionElement.removeEventListener(TRANSITION_END, handler);
};
return cancel;
};
/**
* Return the previous/next element of a list.
*
* @param list - The list of elements to traverse
* @param activeElement - The currently active element
* @param shouldGetNext - Whether to return the next element (`true`) or the previous one (`false`)
* @param isCycleAllowed - Whether to cycle back to the opposite end of the list when reaching the boundary
* @returns The appropriate previous/next element from the list
*/
const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
const listLength = list.length;
let index = list.indexOf(activeElement);
if (index === -1) return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
index += shouldGetNext ? 1 : -1;
if (isCycleAllowed) index = (index + listLength) % listLength;
return list[Math.max(0, Math.min(index, listLength - 1))];
};
//#endregion
//#region js/src/util/config.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/config.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Class definition
*/
var Config = class {
static get Default() {
return {};
}
static get DefaultType() {
return {};
}
static get NAME() {
throw new Error("You have to implement the static method \"NAME\", for each component!");
}
_getConfig(config) {
config = this._mergeConfigObj(config);
config = this._configAfterMerge(config);
this._typeCheckConfig(config);
return config;
}
_configAfterMerge(config) {
return config;
}
_mergeConfigObj(config, element) {
const jsonConfig = isElement$1(element) ? Manipulator.getDataAttribute(element, "config") : {};
return {
...this.constructor.Default,
...typeof jsonConfig === "object" ? jsonConfig : {},
...isElement$1(element) ? Manipulator.getDataAttributes(element) : {},
...typeof config === "object" ? config : {}
};
}
_typeCheckConfig(config, configTypes = this.constructor.DefaultType) {
for (const [property, expectedTypes] of Object.entries(configTypes)) {
const value = config[property];
const valueType = isElement$1(value) ? "element" : toType(value);
if (!new RegExp(expectedTypes).test(valueType)) throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
}
}
};
//#endregion
//#region js/src/base-component.ts
/**
* --------------------------------------------------------------------------
* Bootstrap base-component.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const VERSION = "6.0.0-alpha.2";
/**
* Class definition
*/
var BaseComponent = class extends Config {
constructor(element, config) {
super();
element = getElement(element);
if (!element) return;
this._element = element;
this._config = this._getConfig(config);
const existingInstance = data_default.get(this._element, this.constructor.DATA_KEY);
if (existingInstance) existingInstance.dispose();
data_default.set(this._element, this.constructor.DATA_KEY, this);
}
dispose() {
data_default.remove(this._element, this.constructor.DATA_KEY);
EventHandler.off(this._element, this.constructor.EVENT_KEY);
for (const propertyName of Object.getOwnPropertyNames(this)) this[propertyName] = null;
}
_queueCallback(callback, element, isAnimated = true) {
return new Promise((resolve) => {
executeAfterTransition(() => {
if (this._element) callback();
resolve();
}, element, isAnimated);
});
}
_getConfig(config) {
config = this._mergeConfigObj(config, this._element);
config = this._configAfterMerge(config);
this._typeCheckConfig(config);
return config;
}
static getInstance(element) {
return data_default.get(getElement(element), this.DATA_KEY);
}
static getOrCreateInstance(element, config = {}) {
return this.getInstance(element) || new this(element, typeof config === "object" ? config : null);
}
static get VERSION() {
return VERSION;
}
static get DATA_KEY() {
return `bs.${this.NAME}`;
}
static get EVENT_KEY() {
return `.${this.DATA_KEY}`;
}
static eventName(name) {
return `${name}${this.EVENT_KEY}`;
}
};
//#endregion
//#region js/src/dom/selector-engine.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dom/selector-engine.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const getSelector = (element) => {
let selector = element.getAttribute("data-bs-target");
if (!selector || selector === "#") {
let hrefAttribute = element.getAttribute("href");
if (!hrefAttribute || !hrefAttribute.includes("#") && !hrefAttribute.startsWith(".")) return null;
if (hrefAttribute.includes("#") && !hrefAttribute.startsWith("#")) hrefAttribute = `#${hrefAttribute.split("#")[1]}`;
selector = hrefAttribute && hrefAttribute !== "#" ? hrefAttribute.trim() : null;
}
return selector ? selector.split(",").map((sel) => parseSelector(sel)).join(",") : null;
};
const SelectorEngine = {
find(selector, element = document.documentElement) {
return [...Element.prototype.querySelectorAll.call(element, selector)];
},
findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
},
parents(element, selector) {
const parents = [];
let ancestor = element.parentNode.closest(selector);
while (ancestor) {
parents.push(ancestor);
ancestor = ancestor.parentNode.closest(selector);
}
return parents;
},
closest(element, selector) {
return Element.prototype.closest.call(element, selector);
},
prev(element, selector) {
let previous = element.previousElementSibling;
while (previous) {
if (previous.matches(selector)) return [previous];
previous = previous.previousElementSibling;
}
return [];
},
next(element, selector) {
let next = element.nextElementSibling;
while (next) {
if (next.matches(selector)) return [next];
next = next.nextElementSibling;
}
return [];
},
getSelectorFromElement(element) {
const selector = getSelector(element);
if (selector) return SelectorEngine.findOne(selector) ? selector : null;
return null;
},
getElementFromSelector(element) {
const selector = getSelector(element);
return selector ? SelectorEngine.findOne(selector) : null;
},
getMultipleElementsFromSelector(element) {
const selector = getSelector(element);
return selector ? SelectorEngine.find(selector) : [];
}
};
//#endregion
//#region js/src/util/component-functions.ts
const enableDismissTrigger = (component, method = "hide") => {
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
const name = component.NAME;
const usesNativeDialog = name === "dialog" || name === "drawer";
EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function(event) {
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
if (isDisabled(this)) return;
const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}, [class*=":${name}"]`);
if (!target || usesNativeDialog && !(target instanceof HTMLDialogElement)) return;
component.getOrCreateInstance(target)[method]();
});
};
const eventActionOnPlugin = (Plugin, onEvent, stringSelector, method, callback = null) => {
eventAction(`${onEvent}.${Plugin.NAME}`, stringSelector, (data) => {
const instances = data.targets.filter(Boolean).map((element) => Plugin.getOrCreateInstance(element));
if (typeof callback === "function") callback({
...data,
instances
});
for (const instance of instances) instance[method]();
});
};
const eventAction = (onEvent, stringSelector, callback) => {
const selector = `${stringSelector}:not(.disabled):not(:disabled)`;
EventHandler.on(document, onEvent, selector, function(event) {
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
const selector = SelectorEngine.getSelectorFromElement(this);
callback({
targets: selector ? SelectorEngine.find(selector) : [this],
event
});
});
};
const onDocumentReady = (eventName, callback) => {
EventHandler.on(document, eventName, callback);
if (document.readyState !== "loading") callback();
};
//#endregion
//#region js/src/alert.ts
/**
* --------------------------------------------------------------------------
* Bootstrap alert.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$20 = "alert";
const EVENT_KEY$17 = `.bs.alert`;
const EVENT_CLOSE = `close${EVENT_KEY$17}`;
const EVENT_CLOSED = `closed${EVENT_KEY$17}`;
const CLASS_NAME_HIDING = "hiding";
const CLASS_NAME_SHOW$7 = "show";
/**
* Class definition
*/
var Alert = class extends BaseComponent {
static get NAME() {
return NAME$20;
}
async close() {
if (EventHandler.trigger(this._element, EVENT_CLOSE).defaultPrevented) return;
this._element.classList.remove(CLASS_NAME_SHOW$7);
this._element.classList.add(CLASS_NAME_HIDING);
const isAnimated = getTransitionDurationFromElement(this._element) > 0;
await this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
}
_destroyElement() {
this._element.remove();
EventHandler.trigger(this._element, EVENT_CLOSED);
this.dispose();
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Alert, "close");
//#endregion
//#region js/src/button.ts
/**
* --------------------------------------------------------------------------
* Bootstrap button.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$19 = "button";
const EVENT_KEY$16 = `.bs.button`;
const DATA_API_KEY$11 = ".data-api";
const CLASS_NAME_ACTIVE$3 = "active";
const SELECTOR_DATA_TOGGLE$10 = "[data-bs-toggle=\"button\"]";
const EVENT_CLICK_DATA_API$8 = `click${EVENT_KEY$16}${DATA_API_KEY$11}`;
const EVENT_DOM_CONTENT_LOADED$1 = `DOMContentLoaded${EVENT_KEY$16}${DATA_API_KEY$11}`;
/**
* Class definition
*/
var Button = class extends BaseComponent {
static get NAME() {
return NAME$19;
}
toggle() {
setAriaAttribute(this._element, "aria-pressed", this._element.classList.toggle(CLASS_NAME_ACTIVE$3));
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$8, SELECTOR_DATA_TOGGLE$10, (event) => {
event.preventDefault();
const button = event.target.closest(SELECTOR_DATA_TOGGLE$10);
Button.getOrCreateInstance(button).toggle();
});
onDocumentReady(EVENT_DOM_CONTENT_LOADED$1, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE$10)) if (!element.hasAttribute("aria-pressed")) setAriaAttribute(element, "aria-pressed", element.classList.contains(CLASS_NAME_ACTIVE$3));
});
//#endregion
//#region js/src/carousel.ts
/**
* --------------------------------------------------------------------------
* Bootstrap carousel.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$18 = "carousel";
const EVENT_KEY$15 = `.bs.carousel`;
const DATA_API_KEY$10 = ".data-api";
const ARROW_LEFT_KEY$2 = "ArrowLeft";
const ARROW_RIGHT_KEY$2 = "ArrowRight";
const DIRECTION_LEFT = "left";
const DIRECTION_RIGHT = "right";
const EVENT_SLIDE = `slide${EVENT_KEY$15}`;
const EVENT_SLID = `slid${EVENT_KEY$15}`;
const EVENT_KEYDOWN$3 = `keydown${EVENT_KEY$15}`;
const EVENT_MOUSEENTER$2 = `mouseenter${EVENT_KEY$15}`;
const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$15}`;
const EVENT_POINTERDOWN$3 = `pointerdown${EVENT_KEY$15}`;
const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$15}${DATA_API_KEY$10}`;
const EVENT_CLICK_DATA_API$7 = `click${EVENT_KEY$15}${DATA_API_KEY$10}`;
const CLASS_NAME_CAROUSEL = "carousel";
const CLASS_NAME_ACTIVE$2 = "active";
const CLASS_NAME_FADE = "carousel-fade";
const CLASS_NAME_CENTER = "carousel-center";
const CLASS_NAME_AUTO = "carousel-auto";
const CLASS_NAME_CLONE = "carousel-item-clone";
const CLASS_NAME_PAUSED = "paused";
const CLASS_NAME_PLAYING = "carousel-playing";
const PROPERTY_INTERVAL = "--bs-carousel-interval";
const SCROLL_DURATION = 300;
const ACTIVE_RATIO_TOLERANCE = .05;
const SELECTOR_ACTIVE = ".active";
const SELECTOR_ITEM = `.carousel-item:not(.${CLASS_NAME_CLONE})`;
const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM;
const SELECTOR_INNER$1 = ".carousel-inner";
const SELECTOR_INDICATORS = ".carousel-indicators";
const SELECTOR_PLAY_PAUSE = ".carousel-control-play-pause";
const SELECTOR_DATA_SLIDE = "[data-bs-slide], [data-bs-slide-to]";
const SELECTOR_DATA_SLIDE_PREV = "[data-bs-slide=\"prev\"]";
const SELECTOR_DATA_SLIDE_NEXT = "[data-bs-slide=\"next\"]";
const SELECTOR_DATA_AUTOPLAY = "[data-bs-autoplay=\"true\"]";
const ENDS_STOP = "stop";
const ENDS_WRAP = "wrap";
const ENDS_LOOP = "loop";
const Default$17 = {
autoplay: false,
ends: ENDS_LOOP,
interval: 5e3,
keyboard: true,
pause: "hover"
};
const DefaultType$17 = {
autoplay: "boolean",
ends: "string",
interval: "number",
keyboard: "boolean",
pause: "(string|boolean)"
};
const easeInOutCubic = (progress) => progress < .5 ? 4 * progress * progress * progress : 1 - (-2 * progress + 2) ** 3 / 2;
/**
* Class definition
*/
var Carousel = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._viewport = SelectorEngine.findOne(SELECTOR_INNER$1, this._element) || this._element;
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
this._playPauseElement = SelectorEngine.findOne(SELECTOR_PLAY_PAUSE, this._element);
this._prevControls = SelectorEngine.find(SELECTOR_DATA_SLIDE_PREV, this._element);
this._nextControls = SelectorEngine.find(SELECTOR_DATA_SLIDE_NEXT, this._element);
this._interval = null;
this._observer = null;
this._scrollFrame = null;
this._looping = false;
this._visibility = /* @__PURE__ */ new Map();
this._playing = this._config.autoplay;
this._activeIndex = this._initialActiveIndex();
this._addEventListeners();
this._observeItems();
this._refreshActiveState();
if (this._playing) this.cycle();
this._updatePlayPauseControl();
}
static get Default() {
return Default$17;
}
static get DefaultType() {
return DefaultType$17;
}
static get NAME() {
return NAME$18;
}
next() {
this.to(this._navIndex() + 1);
}
nextWhenVisible() {
if (document.visibilityState === "visible" && isVisible(this._element)) this.next();
}
prev() {
this.to(this._navIndex() - 1);
}
pause() {
this._clearInterval();
this._element.classList.remove(CLASS_NAME_PLAYING);
}
cycle() {
this._clearInterval();
this._scheduleAutoplay();
this._element.classList.add(CLASS_NAME_PLAYING);
}
to(index) {
if (this._looping) return;
const items = this._getItems();
const rawIndex = Number.parseInt(index, 10);
if (this._config.ends === ENDS_LOOP && !this._prefersReducedMotion() && this._canLoop()) {
if (rawIndex > items.length - 1) {
this._loopTransition(true);
return;
}
if (rawIndex < 0) {
this._loopTransition(false);
return;
}
}
const targetIndex = this._normalizeIndex(rawIndex, items.length);
const currentIndex = this._navIndex();
if (targetIndex === null || targetIndex === currentIndex) return;
if (EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: items[targetIndex],
direction: this._direction(currentIndex, targetIndex),
from: currentIndex,
to: targetIndex
}).defaultPrevented) return;
if (this._isFade()) {
this._fadeTo(targetIndex);
return;
}
this._scrollToIndex(targetIndex);
}
dispose() {
this._clearInterval();
if (this._observer) this._observer.disconnect();
if (this._scrollFrame !== null) cancelAnimationFrame(this._scrollFrame);
for (const clone of SelectorEngine.find(`.${CLASS_NAME_CLONE}`, this._viewport)) clone.remove();
this._viewport.style.scrollSnapType = "";
EventHandler.off(this._viewport, EVENT_KEY$15);
super.dispose();
}
_configAfterMerge(config) {
if (![
ENDS_STOP,
ENDS_WRAP,
ENDS_LOOP
].includes(config.ends)) config.ends = Default$17.ends;
return config;
}
_initialActiveIndex() {
const active = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
const index = active ? this._getItems().indexOf(active) : 0;
return Math.max(index, 0);
}
_addEventListeners() {
if (this._config.keyboard) EventHandler.on(this._element, EVENT_KEYDOWN$3, (event) => this._keydown(event));
if (this._config.pause === "hover") {
EventHandler.on(this._element, EVENT_MOUSEENTER$2, () => this.pause());
EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle());
}
EventHandler.on(this._viewport, EVENT_POINTERDOWN$3, () => this._pauseFromInteraction());
}
_keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) return;
const { key } = event;
if (key !== ARROW_LEFT_KEY$2 && key !== ARROW_RIGHT_KEY$2) return;
event.preventDefault();
this._pauseFromInteraction();
if (key === (isRTL$1() ? ARROW_LEFT_KEY$2 : ARROW_RIGHT_KEY$2)) this.next();
else this.prev();
}
_observeItems() {
if (this._isFade() || typeof IntersectionObserver === "undefined") return;
this._observer = new IntersectionObserver((entries) => this._handleIntersection(entries), {
root: this._viewport,
threshold: [
0,
.25,
.5,
.75,
1
]
});
for (const item of this._getItems()) this._observer.observe(item);
}
_handleIntersection(entries) {
if (this._looping) return;
for (const entry of entries) this._visibility.set(entry.target, entry.isIntersecting ? entry.intersectionRatio : 0);
const ratios = this._getItems().map((item) => this._visibility.get(item) ?? 0);
const maxRatio = Math.max(...ratios);
let bestIndex = this._activeIndex;
if (maxRatio > 0) bestIndex = ratios.findIndex((ratio) => ratio >= maxRatio - ACTIVE_RATIO_TOLERANCE);
this._setActive(bestIndex);
this._updateEndControls();
}
_navIndex() {
if (this._isFade() || this._viewport.scrollWidth - this._viewport.clientWidth <= 0) return this._activeIndex;
let index = this._activeIndex;
let smallestDelta = Number.POSITIVE_INFINITY;
for (const [itemIndex, item] of this._getItems().entries()) {
const delta = Math.abs(this._scrollDelta(item));
if (delta < smallestDelta) {
smallestDelta = delta;
index = itemIndex;
}
}
return index;
}
_scrollToIndex(index) {
const item = this._getItems()[index];
if (!item) return;
const left = this._scrollDelta(item);
if (Math.abs(left) < 1) return;
const targetLeft = this._viewport.scrollLeft + left;
this._viewport.style.scrollSnapType = "none";
this._animateScroll(targetLeft, () => {
this._viewport.style.scrollSnapType = "";
if (!this._observer) this._setActive(index);
this._updateEndControls();
});
}
_animateScroll(targetLeft, onComplete) {
if (this._scrollFrame !== null) {
cancelAnimationFrame(this._scrollFrame);
this._scrollFrame = null;
}
const startLeft = this._viewport.scrollLeft;
const distance = targetLeft - startLeft;
if (this._prefersReducedMotion() || typeof requestAnimationFrame === "undefined") {
this._viewport.scrollTo({
left: targetLeft,
behavior: "instant"
});
onComplete();
return;
}
let startTime = null;
const step = (now) => {
if (startTime === null) startTime = now;
const progress = Math.min((now - startTime) / SCROLL_DURATION, 1);
this._viewport.scrollTo({
left: startLeft + distance * easeInOutCubic(progress),
behavior: "instant"
});
if (progress < 1) {
this._scrollFrame = requestAnimationFrame(step);
return;
}
this._viewport.scrollTo({
left: targetLeft,
behavior: "instant"
});
this._scrollFrame = null;
onComplete();
};
this._scrollFrame = requestAnimationFrame(step);
}
_scrollDelta(element) {
const viewportRect = this._viewport.getBoundingClientRect();
const rect = element.getBoundingClientRect();
if (this._element.classList.contains(CLASS_NAME_CENTER)) return rect.left + rect.width / 2 - (viewportRect.left + viewportRect.width / 2);
const padStart = Number.parseFloat(getComputedStyle(this._viewport).scrollPaddingInlineStart) || 0;
return isRTL$1() ? rect.right - (viewportRect.right - padStart) : rect.left - (viewportRect.left + padStart);
}
_loopTransition(isNext) {
const items = this._getItems();
const last = items.length - 1;
const fromIndex = this._activeIndex;
const toIndex = isNext ? 0 : last;
const direction = this._loopDirection(isNext);
if (EventHandler.trigger(this._element, EVENT_SLIDE, {
relatedTarget: items[toIndex],
direction,
from: fromIndex,
to: toIndex
}).defaultPrevented) return;
this._looping = true;
const clone = (isNext ? items[0] : items[last]).cloneNode(true);
clone.classList.add(CLASS_NAME_CLONE);
clone.classList.remove(CLASS_NAME_ACTIVE$2);
clone.removeAttribute("id");
for (const node of SelectorEngine.find("[id]", clone)) node.removeAttribute("id");
clone.setAttribute("aria-hidden", "true");
clone.inert = true;
this._viewport.style.scrollSnapType = "none";
if (isNext) this._viewport.append(clone);
else {
this._viewport.prepend(clone);
this._jumpScroll(this._scrollDelta(items[fromIndex]));
}
this._animateScroll(this._viewport.scrollLeft + this._scrollDelta(clone), () => {
clone.remove();
this._jumpScroll(this._scrollDelta(items[toIndex]));
this._activeIndex = toIndex;
this._refreshActiveState();
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: items[toIndex],
direction,
from: fromIndex,
to: toIndex
});
this._viewport.style.scrollSnapType = "";
this._looping = false;
});
}
_loopDirection(isNext) {
if (isRTL$1()) return isNext ? DIRECTION_RIGHT : DIRECTION_LEFT;
return isNext ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
_jumpScroll(delta) {
this._viewport.style.scrollSnapType = "none";
this._viewport.scrollBy({
left: delta,
top: 0,
behavior: "instant"
});
}
_fadeTo(index) {
this._setActive(index);
}
_setActive(index) {
const items = this._getItems();
if (index === this._activeIndex || !items[index]) return;
const from = this._activeIndex;
this._activeIndex = index;
this._refreshActiveState();
EventHandler.trigger(this._element, EVENT_SLID, {
relatedTarget: items[index],
direction: this._direction(from, index),
from,
to: index
});
}
_refreshActiveState() {
const items = this._getItems();
for (const [index, item] of items.entries()) item.classList.toggle(CLASS_NAME_ACTIVE$2, index === this._activeIndex);
this._setActiveIndicatorElement(this._activeIndex);
this._updateEndControls();
}
_updateEndControls() {
if (this._config.ends !== ENDS_STOP) return;
const viewport = this._viewport;
const maxScroll = viewport.scrollWidth - viewport.clientWidth;
let atStart;
let atEnd;
if (maxScroll > 0) {
const progress = Math.abs(viewport.scrollLeft);
atStart = progress <= 1;
atEnd = progress >= maxScroll - 1;
} else {
const last = this._getItems().length - 1;
atStart = this._activeIndex <= 0;
atEnd = this._activeIndex >= last;
}
this._setControlsDisabled(this._prevControls, atStart);
this._setControlsDisabled(this._nextControls, atEnd);
}
_setControlsDisabled(controls, disabled) {
for (const control of controls) {
if (disabled && control === document.activeElement) {
((controls === this._prevControls ? this._nextControls : this._prevControls)[0] ?? this._viewport).focus({ preventScroll: true });
if (document.activeElement === control) control.blur();
}
control.disabled = disabled;
}
}
_setActiveIndicatorElement(index) {
if (!this._indicatorsElement) return;
const active = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
if (active) {
active.classList.remove(CLASS_NAME_ACTIVE$2);
active.removeAttribute("aria-current");
}
const newActive = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement);
if (newActive) {
newActive.classList.add(CLASS_NAME_ACTIVE$2);
newActive.setAttribute("aria-current", "true");
}
}
_normalizeIndex(index, length) {
if (Number.isNaN(index) || length === 0) return null;
if (index < 0) return this._wrapsAround() ? length - 1 : null;
if (index > length - 1) return this._wrapsAround() ? 0 : null;
return index;
}
_wrapsAround() {
return this._config.ends === ENDS_WRAP || this._config.ends === ENDS_LOOP;
}
_canLoop() {
if (this._isFade() || this._getItems().length < 2) return false;
const styles = getComputedStyle(this._element);
const num = (name) => Number.parseFloat(styles.getPropertyValue(name)) || 0;
return (num("--bs-carousel-items") || 1) === 1 && num("--bs-carousel-items-peek") === 0 && !this._element.classList.contains(CLASS_NAME_CENTER) && !this._element.classList.contains(CLASS_NAME_AUTO);
}
_direction(from, to) {
const isNext = to > from;
if (isRTL$1()) return isNext ? DIRECTION_RIGHT : DIRECTION_LEFT;
return isNext ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
_scheduleAutoplay(index = this._activeIndex) {
const interval = this._itemInterval(index);
this._element.style.setProperty(PROPERTY_INTERVAL, `${interval}ms`);
this._interval = setTimeout(() => {
const upcoming = this._upcomingIndex();
this.nextWhenVisible();
if (upcoming === null) {
this.pause();
return;
}
this._scheduleAutoplay(upcoming);
}, interval);
}
_upcomingIndex() {
return this._normalizeIndex(this._navIndex() + 1, this._getItems().length);
}
_itemInterval(index = this._activeIndex) {
const item = this._getItems()[index];
const interval = item ? Number.parseInt(item.getAttribute("data-bs-interval"), 10) : NaN;
return Number.isNaN(interval) ? this._config.interval : interval;
}
_maybeEnableCycle() {
if (!this._playing) return;
this.cycle();
}
_pauseFromInteraction() {
this._playing = false;
this.pause();
this._updatePlayPauseControl();
}
_togglePlayPause() {
if (this._playing) {
this._pauseFromInteraction();
return;
}
this._playing = true;
this.cycle();
this._updatePlayPauseControl();
}
_updatePlayPauseControl() {
if (!this._playPauseElement) return;
this._playPauseElement.classList.toggle(CLASS_NAME_PAUSED, !this._playing);
const label = this._playPauseElement.getAttribute(this._playing ? "data-bs-pause-label" : "data-bs-play-label");
if (label) this._playPauseElement.setAttribute("aria-label", label);
}
_isFade() {
return this._element.classList.contains(CLASS_NAME_FADE);
}
_prefersReducedMotion() {
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
_getItems() {
return SelectorEngine.find(SELECTOR_ITEM, this._element);
}
_clearInterval() {
if (this._interval) {
clearTimeout(this._interval);
this._interval = null;
}
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_DATA_SLIDE, function(event) {
const target = SelectorEngine.getElementFromSelector(this);
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) return;
event.preventDefault();
const carousel = Carousel.getOrCreateInstance(target);
carousel._pauseFromInteraction();
const slideIndex = this.getAttribute("data-bs-slide-to");
if (slideIndex) {
carousel.to(slideIndex);
return;
}
if (Manipulator.getDataAttribute(this, "slide") === "next") {
carousel.next();
return;
}
carousel.prev();
});
EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_PLAY_PAUSE, function(event) {
const target = SelectorEngine.getElementFromSelector(this);
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) return;
event.preventDefault();
Carousel.getOrCreateInstance(target)._togglePlayPause();
});
EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_AUTOPLAY);
for (const carousel of carousels) Carousel.getOrCreateInstance(carousel);
});
/**
* Decode a URL fragment id, tolerating malformed escapes (returns it as-is).
*/
const decodeFragment$1 = (value) => {
try {
return decodeURIComponent(value);
} catch {
return value;
}
};
/**
* Resolve the element named by `location.hash` when it opts in with `data-bs-hash`.
*/
const getHashTarget = () => {
const { hash } = window.location;
if (!hash || hash === "#") return null;
const id = decodeFragment$1(hash.slice(1));
if (!id) return null;
const element = document.getElementById(id);
if (!element?.hasAttribute("data-bs-hash")) return null;
return element;
};
/**
* Open an opted-in hash target on `load` and `hashchange`.
* Put `data-bs-hash` on the collapse or tab pane that the URL fragment names.
*
* Scrolls a visible anchor first when one exists, then opens the target, then
* scrolls the target into view after it is shown.
*/
const enableHashTarget = (namespace, handler) => {
let generation = 0;
const onHash = () => {
const current = ++generation;
const element = getHashTarget();
if (!element || !handler.matches(element)) return;
const anchor = handler.getAnchor?.(element);
if (anchor) anchor.scrollIntoView();
handler.open(element, () => {
if (current === generation && element.isConnected && getHashTarget() === element) element.scrollIntoView();
});
};
EventHandler.on(window, `load${namespace}`, onHash);
EventHandler.on(window, `hashchange${namespace}`, onHash);
if (document.readyState === "complete") onHash();
};
//#endregion
//#region js/src/collapse.ts
/**
* --------------------------------------------------------------------------
* Bootstrap collapse.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$17 = "collapse";
const EVENT_KEY$14 = `.bs.collapse`;
const DATA_API_KEY$9 = ".data-api";
const EVENT_SHOW$5 = `show${EVENT_KEY$14}`;
const EVENT_SHOWN$5 = `shown${EVENT_KEY$14}`;
const EVENT_HIDE$5 = `hide${EVENT_KEY$14}`;
const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$14}`;
const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$14}${DATA_API_KEY$9}`;
const CLASS_NAME_SHOW$6 = "show";
const CLASS_NAME_COLLAPSE = "collapse";
const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
const SELECTOR_ACTIVES = ".collapse.show";
const SELECTOR_DATA_TOGGLE$9 = "[data-bs-toggle=\"collapse\"]";
const Default$16 = { parent: null };
const DefaultType$16 = { parent: "(null|element)" };
/**
* Class definition
*/
var Collapse = class Collapse extends BaseComponent {
constructor(element, config) {
super(element, config);
this._isTransitioning = false;
this._triggerArray = [];
const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$9);
for (const elem of toggleList) {
const selector = SelectorEngine.getSelectorFromElement(elem);
const filterElement = SelectorEngine.find(selector).filter((foundElement) => foundElement === this._element);
if (selector !== null && filterElement.length) this._triggerArray.push(elem);
}
this._initializeChildren();
if (!this._config.parent) this._setAriaExpanded(this._triggerArray, this._isShown());
}
static get Default() {
return Default$16;
}
static get DefaultType() {
return DefaultType$16;
}
static get NAME() {
return NAME$17;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
async show() {
if (this._isTransitioning || this._isShown()) return;
let activeChildren = [];
if (this._config.parent) activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter((element) => element !== this._element && !this._sharesTrigger(element)).map((element) => Collapse.getOrCreateInstance(element));
if (activeChildren.length && activeChildren[0]._isTransitioning) return;
if (EventHandler.trigger(this._element, EVENT_SHOW$5).defaultPrevented) return;
for (const activeInstance of activeChildren) activeInstance.hide();
this._element.classList.add(CLASS_NAME_SHOW$6);
this._setAriaExpanded(this._triggerArray, true);
this._isTransitioning = true;
const complete = () => {
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_SHOWN$5);
};
await this._queueCallback(complete, this._element, this._isAnimated());
}
async hide() {
if (this._isTransitioning || !this._isShown()) return;
if (EventHandler.trigger(this._element, EVENT_HIDE$5).defaultPrevented) return;
this._element.classList.remove(CLASS_NAME_SHOW$6);
for (const trigger of this._triggerArray) {
const element = SelectorEngine.getElementFromSelector(trigger);
if (element && !this._isShown(element)) this._setAriaExpanded([trigger], false);
}
this._isTransitioning = true;
const complete = () => {
this._isTransitioning = false;
EventHandler.trigger(this._element, EVENT_HIDDEN$5);
};
await this._queueCallback(complete, this._element, this._isAnimated());
}
_isShown(element = this._element) {
return element.classList.contains(CLASS_NAME_SHOW$6);
}
_isAnimated() {
return getTransitionDurationFromElement(this._element) > 0;
}
_sharesTrigger(element) {
return this._triggerArray.some((trigger) => SelectorEngine.getMultipleElementsFromSelector(trigger).includes(element));
}
_configAfterMerge(config) {
config.parent = getElement(config.parent);
return config;
}
_initializeChildren() {
if (!this._config.parent) return;
const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$9);
for (const element of children) {
const selected = SelectorEngine.getElementFromSelector(element);
if (selected) this._setAriaExpanded([element], this._isShown(selected));
}
}
_getFirstLevelChildren(selector) {
const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent);
return SelectorEngine.find(selector, this._config.parent).filter((element) => !children.includes(element));
}
_setAriaExpanded(triggerArray, isOpen) {
if (!triggerArray.length) return;
for (const element of triggerArray) setAriaAttribute(element, "aria-expanded", isOpen);
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$9, function(event) {
if (event.target.tagName === "A" || event.delegateTarget && event.delegateTarget.tagName === "A") event.preventDefault();
for (const element of SelectorEngine.getMultipleElementsFromSelector(this)) Collapse.getOrCreateInstance(element).toggle();
});
/**
* Find a trigger that targets this collapse.
*/
const getCollapseTrigger = (collapseEl) => {
for (const trigger of SelectorEngine.find(SELECTOR_DATA_TOGGLE$9)) if (SelectorEngine.getMultipleElementsFromSelector(trigger).includes(collapseEl)) return trigger;
return null;
};
/**
* Open opted-in collapses when the URL fragment matches their id.
* Put `data-bs-hash` on the collapsible target.
*/
enableHashTarget(`${EVENT_KEY$14}${DATA_API_KEY$9}`, {
matches: (element) => element.classList.contains(CLASS_NAME_COLLAPSE),
getAnchor: getCollapseTrigger,
async open(element, done) {
if (element.classList.contains(CLASS_NAME_SHOW$6)) {
done();
return;
}
await Collapse.getOrCreateInstance(element).show();
if (element.classList.contains(CLASS_NAME_SHOW$6)) done();
}
});
//#endregion
//#region node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
const min = Math.min;
const max = Math.max;
const round = Math.round;
const floor = Math.floor;
const createCoords = (v) => ({
x: v,
y: v
});
const oppositeSideMap = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function clamp(start, value, end) {
return max(start, min(value, end));
}
function evaluate(value, param) {
return typeof value === "function" ? value(param) : value;
}
function getSide(placement) {
return placement.split("-")[0];
}
function getAlignment(placement) {
return placement.split("-")[1];
}
function getOppositeAxis(axis) {
return axis === "x" ? "y" : "x";
}
function getAxisLength(axis) {
return axis === "y" ? "height" : "width";
}
function getSideAxis(placement) {
const firstChar = placement[0];
return firstChar === "t" || firstChar === "b" ? "y" : "x";
}
function getAlignmentAxis(placement) {
return getOppositeAxis(getSideAxis(placement));
}
function getAlignmentSides(placement, rects, rtl) {
if (rtl === void 0) rtl = false;
const alignment = getAlignment(placement);
const alignmentAxis = getAlignmentAxis(placement);
const length = getAxisLength(alignmentAxis);
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
}
function getExpandedPlacements(placement) {
const oppositePlacement = getOppositePlacement(placement);
return [
getOppositeAlignmentPlacement(placement),
oppositePlacement,
getOppositeAlignmentPlacement(oppositePlacement)
];
}
function getOppositeAlignmentPlacement(placement) {
return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
}
const lrPlacement = ["left", "right"];
const rlPlacement = ["right", "left"];
const tbPlacement = ["top", "bottom"];
const btPlacement = ["bottom", "top"];
function getSideList(side, isStart, rtl) {
switch (side) {
case "top":
case "bottom":
if (rtl) return isStart ? rlPlacement : lrPlacement;
return isStart ? lrPlacement : rlPlacement;
case "left":
case "right": return isStart ? tbPlacement : btPlacement;
default: return [];
}
}
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
const alignment = getAlignment(placement);
let list = getSideList(getSide(placement), direction === "start", rtl);
if (alignment) {
list = list.map((side) => side + "-" + alignment);
if (flipAlignment) list = list.concat(list.map(getOppositeAlignmentPlacement));
}
return list;
}
function getOppositePlacement(placement) {
const side = getSide(placement);
return oppositeSideMap[side] + placement.slice(side.length);
}
function expandPaddingObject(padding) {
var _padding$top, _padding$right, _padding$bottom, _padding$left;
return {
top: (_padding$top = padding.top) != null ? _padding$top : 0,
right: (_padding$right = padding.right) != null ? _padding$right : 0,
bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0,
left: (_padding$left = padding.left) != null ? _padding$left : 0
};
}
function getPaddingObject(padding) {
return typeof padding !== "number" ? expandPaddingObject(padding) : {
top: padding,
right: padding,
bottom: padding,
left: padding
};
}
function rectToClientRect(rect) {
const { x, y, width, height } = rect;
return {
width,
height,
top: y,
left: x,
right: x + width,
bottom: y + height,
x,
y
};
}
//#endregion
//#region node_modules/@floating-ui/core/dist/floating-ui.core.mjs
function computeCoordsFromPlacement(_ref, placement, rtl) {
let { reference, floating } = _ref;
const sideAxis = getSideAxis(placement);
const alignmentAxis = getAlignmentAxis(placement);
const alignLength = getAxisLength(alignmentAxis);
const side = getSide(placement);
const isVertical = sideAxis === "y";
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
let coords;
switch (side) {
case "top":
coords = {
x: commonX,
y: reference.y - floating.height
};
break;
case "bottom":
coords = {
x: commonX,
y: reference.y + reference.height
};
break;
case "right":
coords = {
x: reference.x + reference.width,
y: commonY
};
break;
case "left":
coords = {
x: reference.x - floating.width,
y: commonY
};
break;
default: coords = {
x: reference.x,
y: reference.y
};
}
const alignment = getAlignment(placement);
if (alignment) coords[alignmentAxis] += commonAlign * (alignment === "end" ? 1 : -1) * (rtl && isVertical ? -1 : 1);
return coords;
}
/**
* Resolves with an object of overflow side offsets that determine how much the
* element is overflowing a given clipping boundary on each side.
* - positive = overflowing the boundary by that number of pixels
* - negative = how many pixels left before it will overflow
* - 0 = lies flush with the boundary
* @see https://floating-ui.com/docs/detectOverflow
*/
async function detectOverflow(state, options) {
var _await$platform$isEle;
if (options === void 0) options = {};
const { x, y, platform, rects, elements, strategy } = state;
const { boundary = "clippingAncestors", rootBoundary = "viewport", elementContext = "floating", altBoundary = false, padding = 0 } = evaluate(options, state);
const paddingObject = getPaddingObject(padding);
const element = elements[altBoundary ? elementContext === "floating" ? "reference" : "floating" : elementContext];
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
boundary,
rootBoundary,
strategy
}));
const rect = elementContext === "floating" ? {
x,
y,
width: rects.floating.width,
height: rects.floating.height
} : rects.reference;
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) && await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
x: 1,
y: 1
};
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
elements,
rect,
offsetParent,
strategy
}) : rect);
return {
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
};
}
const MAX_RESET_COUNT = 50;
/**
* Computes the `x` and `y` coordinates that will place the floating element
* next to a given reference element.
*
* This export does not have any `platform` interface logic. You will need to
* write one for the platform you are using Floating UI with.
*/
const computePosition$1 = async (reference, floating, config) => {
const { placement = "bottom", strategy = "absolute", middleware = [], platform } = config;
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
...platform,
detectOverflow
};
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
let rects = await platform.getElementRects({
reference,
floating,
strategy
});
let { x, y } = computeCoordsFromPlacement(rects, placement, rtl);
let statefulPlacement = placement;
let resetCount = 0;
const middlewareData = {};
for (let i = 0; i < middleware.length; i++) {
const currentMiddleware = middleware[i];
if (!currentMiddleware) continue;
const { name, fn } = currentMiddleware;
const { x: nextX, y: nextY, data, reset } = await fn({
x,
y,
initialPlacement: placement,
placement: statefulPlacement,
strategy,
middlewareData,
rects,
platform: platformWithDetectOverflow,
elements: {
reference,
floating
}
});
x = nextX != null ? nextX : x;
y = nextY != null ? nextY : y;
middlewareData[name] = {
...middlewareData[name],
...data
};
if (reset && resetCount < MAX_RESET_COUNT) {
resetCount++;
if (typeof reset === "object") {
if (reset.placement) statefulPlacement = reset.placement;
if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
({x, y} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
}
i = -1;
}
}
return {
x,
y,
placement: statefulPlacement,
strategy,
middlewareData
};
};
/**
* Provides data to position an inner element of the floating element so that it
* appears centered to the reference element.
* @see https://floating-ui.com/docs/arrow
*/
const arrow$1 = (options) => ({
name: "arrow",
options,
async fn(state) {
const { x, y, placement, rects, platform, elements, middlewareData } = state;
const { element, padding = 0 } = evaluate(options, state) || {};
if (element == null) return {};
const paddingObject = getPaddingObject(padding);
const coords = {
x,
y
};
const axis = getAlignmentAxis(placement);
const length = getAxisLength(axis);
const arrowDimensions = await platform.getDimensions(element);
const isYAxis = axis === "y";
const minProp = isYAxis ? "top" : "left";
const maxProp = isYAxis ? "bottom" : "right";
const clientProp = isYAxis ? "clientHeight" : "clientWidth";
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) clientSize = elements.floating[clientProp] || rects.floating[length];
const centerToReference = endDiff / 2 - startDiff / 2;
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
const max = clientSize - arrowDimensions[length] - maxPadding;
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset = clamp(minPadding, center, max);
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < minPadding ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
const alignmentOffset = shouldAddOffset ? center < minPadding ? center - minPadding : center - max : 0;
return {
[axis]: coords[axis] + alignmentOffset,
data: {
[axis]: offset,
centerOffset: center - offset - alignmentOffset,
...shouldAddOffset && { alignmentOffset }
},
reset: shouldAddOffset
};
}
});
/**
* Optimizes the visibility of the floating element by flipping the `placement`
* in order to keep it in view when the preferred placement(s) will overflow the
* clipping boundary. Alternative to `autoPlacement`.
* @see https://floating-ui.com/docs/flip
*/
const flip$1 = function(options) {
if (options === void 0) options = {};
return {
name: "flip",
options,
async fn(state) {
var _middlewareData$arrow, _middlewareData$flip;
const { placement, middlewareData, rects, initialPlacement, platform, elements } = state;
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = "bestFit", fallbackAxisSideDirection = "none", flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state);
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
const side = getSide(placement);
const initialSideAxis = getSideAxis(initialPlacement);
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
const placements = [initialPlacement, ...fallbackPlacements];
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const overflows = [];
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
if (checkMainAxis) overflows.push(overflow[side]);
if (checkCrossAxis) {
const sides = getAlignmentSides(placement, rects, rtl);
overflows.push(overflow[sides[0]], overflow[sides[1]]);
}
overflowsData = [...overflowsData, {
placement,
overflows
}];
if (!overflows.every((side) => side <= 0)) {
var _middlewareData$flip2, _overflowsData$filter;
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
const nextPlacement = placements[nextIndex];
if (nextPlacement) {
if (!(checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false) || overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return {
data: {
index: nextIndex,
overflows: overflowsData
},
reset: { placement: nextPlacement }
};
}
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
if (!resetPlacement) switch (fallbackStrategy) {
case "bestFit": {
var _overflowsData$filter2;
const placement = (_overflowsData$filter2 = overflowsData.filter((d) => {
if (hasFallbackAxisSideDirection) {
const currentSideAxis = getSideAxis(d.placement);
return currentSideAxis === initialSideAxis || currentSideAxis === "y";
}
return true;
}).map((d) => [d.placement, d.overflows.filter((overflow) => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
if (placement) resetPlacement = placement;
break;
}
case "initialPlacement":
resetPlacement = initialPlacement;
break;
}
if (placement !== resetPlacement) return { reset: { placement: resetPlacement } };
}
return {};
}
};
};
const originSides = /*#__PURE__*/ new Set(["left", "top"]);
async function convertValueToCoords(state, options) {
const { placement, platform, elements } = state;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
const side = getSide(placement);
const alignment = getAlignment(placement);
const isVertical = getSideAxis(placement) === "y";
const mainAxisMulti = originSides.has(side) ? -1 : 1;
const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = evaluate(options, state);
let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === "number" ? {
mainAxis: rawValue,
crossAxis: 0,
alignmentAxis: null
} : {
mainAxis: rawValue.mainAxis || 0,
crossAxis: rawValue.crossAxis || 0,
alignmentAxis: rawValue.alignmentAxis
};
if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
return isVertical ? {
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
} : {
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
};
}
/**
* Modifies the placement by translating the floating element along the
* specified axes.
* A number (shorthand for `mainAxis` or distance), or an axes configuration
* object may be passed.
* @see https://floating-ui.com/docs/offset
*/
const offset$1 = function(options) {
if (options === void 0) options = 0;
return {
name: "offset",
options,
async fn(state) {
var _middlewareData$offse, _middlewareData$arrow;
const { x, y, placement, middlewareData } = state;
const diffCoords = await convertValueToCoords(state, options);
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {};
return {
x: x + diffCoords.x,
y: y + diffCoords.y,
data: {
...diffCoords,
placement
}
};
}
};
};
/**
* Optimizes the visibility of the floating element by shifting it in order to
* keep it in view when it will overflow the clipping boundary.
* @see https://floating-ui.com/docs/shift
*/
const shift$1 = function(options) {
if (options === void 0) options = {};
return {
name: "shift",
options,
async fn(state) {
const { x, y, placement, platform } = state;
const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: (_ref) => {
let { x, y } = _ref;
return {
x,
y
};
} }, ...detectOverflowOptions } = evaluate(options, state);
const coords = {
x,
y
};
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const crossAxis = getSideAxis(placement);
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const clampCoord = (axis, coord) => clamp(coord + overflow[axis === "y" ? "top" : "left"], coord, coord - overflow[axis === "y" ? "bottom" : "right"]);
if (checkMainAxis) mainAxisCoord = clampCoord(mainAxis, mainAxisCoord);
if (checkCrossAxis) crossAxisCoord = clampCoord(crossAxis, crossAxisCoord);
const limitedCoords = limiter.fn({
...state,
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
});
return {
...limitedCoords,
data: {
x: limitedCoords.x - x,
y: limitedCoords.y - y,
enabled: {
[mainAxis]: checkMainAxis,
[crossAxis]: checkCrossAxis
}
}
};
}
};
};
/**
* Provides data that allows you to change the size of the floating element —
* for instance, prevent it from overflowing the clipping boundary or match the
* width of the reference element.
* @see https://floating-ui.com/docs/size
*/
const size$1 = function(options) {
if (options === void 0) options = {};
return {
name: "size",
options,
async fn(state) {
const { placement, rects, platform, elements } = state;
const { apply = () => {}, ...detectOverflowOptions } = evaluate(options, state);
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
const side = getSide(placement);
const alignment = getAlignment(placement);
const isYAxis = getSideAxis(placement) === "y";
const { width, height } = rects.floating;
let heightSide;
let widthSide;
if (side === "top" || side === "bottom") {
heightSide = side;
widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
} else {
widthSide = side;
heightSide = alignment === "end" ? "top" : "bottom";
}
const maximumClippingHeight = height - overflow.top - overflow.bottom;
const maximumClippingWidth = width - overflow.left - overflow.right;
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
const shiftData = state.middlewareData.shift;
const noShift = !shiftData;
let availableHeight = overflowAvailableHeight;
let availableWidth = overflowAvailableWidth;
if (shiftData != null && shiftData.enabled.x) availableWidth = maximumClippingWidth;
if (shiftData != null && shiftData.enabled.y) availableHeight = maximumClippingHeight;
if (noShift && !alignment) if (isYAxis) availableWidth = width - 2 * max(overflow.left, overflow.right);
else availableHeight = height - 2 * max(overflow.top, overflow.bottom);
await apply({
...state,
availableWidth,
availableHeight
});
const nextDimensions = await platform.getDimensions(elements.floating);
if (width !== nextDimensions.width || height !== nextDimensions.height) return { reset: { rects: true } };
return {};
}
};
};
//#endregion
//#region node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
function hasWindow() {
return typeof window !== "undefined";
}
function getNodeName(node) {
if (isNode(node)) return (node.nodeName || "").toLowerCase();
return "#document";
}
function getWindow(node) {
var _node$ownerDocument;
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
}
function getDocumentElement(node) {
var _ref;
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
}
function isNode(value) {
if (!hasWindow()) return false;
return value instanceof Node || value instanceof getWindow(value).Node;
}
function isElement(value) {
if (!hasWindow()) return false;
return value instanceof Element || value instanceof getWindow(value).Element;
}
function isHTMLElement(value) {
if (!hasWindow()) return false;
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
}
function isShadowRoot(value) {
if (!hasWindow() || typeof ShadowRoot === "undefined") return false;
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
}
function isOverflowElement(element) {
const { overflow, overflowX, overflowY, display } = getComputedStyle$1(element);
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
}
function isTableElement(element) {
return /^(table|td|th)$/.test(getNodeName(element));
}
function isTopLayer(element) {
try {
if (element.matches(":popover-open")) return true;
} catch (_e) {}
try {
return element.matches(":modal");
} catch (_e) {
return false;
}
}
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
const containRe = /paint|layout|strict|content/;
const isNotNone = (value) => !!value && value !== "none";
let isWebKitValue;
function isContainingBlock(elementOrCss) {
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
}
function getContainingBlock(element) {
let currentNode = getParentNode(element);
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
if (isContainingBlock(currentNode)) return currentNode;
else if (isTopLayer(currentNode)) return null;
currentNode = getParentNode(currentNode);
}
return null;
}
function isWebKit() {
if (isWebKitValue == null) isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
return isWebKitValue;
}
function isLastTraversableNode(node) {
return /^(html|body|#document)$/.test(getNodeName(node));
}
function getComputedStyle$1(element) {
return getWindow(element).getComputedStyle(element);
}
function getNodeScroll(element) {
if (isElement(element)) return {
scrollLeft: element.scrollLeft,
scrollTop: element.scrollTop
};
return {
scrollLeft: element.scrollX,
scrollTop: element.scrollY
};
}
function getParentNode(node) {
if (getNodeName(node) === "html") return node;
const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
return isShadowRoot(result) ? result.host : result;
}
function getNearestOverflowAncestor(node) {
const parentNode = getParentNode(node);
if (isLastTraversableNode(parentNode)) return (node.ownerDocument || node).body;
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
return getNearestOverflowAncestor(parentNode);
}
function getOverflowAncestors(node, list, traverseIframes) {
var _node$ownerDocument2;
if (list === void 0) list = [];
if (traverseIframes === void 0) traverseIframes = true;
const scrollableAncestor = getNearestOverflowAncestor(node);
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
const win = getWindow(scrollableAncestor);
if (isBody) {
const frameElement = getFrameElement(win);
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
} else return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
}
function getFrameElement(win) {
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
}
//#endregion
//#region node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
function getCssDimensions(element) {
const css = getComputedStyle$1(element);
let width = parseFloat(css.width) || 0;
let height = parseFloat(css.height) || 0;
const hasOffset = isHTMLElement(element);
const offsetWidth = hasOffset ? element.offsetWidth : width;
const offsetHeight = hasOffset ? element.offsetHeight : height;
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
if (shouldFallback) {
width = offsetWidth;
height = offsetHeight;
}
return {
width,
height,
$: shouldFallback
};
}
function unwrapElement(element) {
return !isElement(element) ? element.contextElement : element;
}
function getScale(element) {
const domElement = unwrapElement(element);
if (!isHTMLElement(domElement)) return createCoords(1);
const rect = domElement.getBoundingClientRect();
const { width, height, $ } = getCssDimensions(domElement);
let x = ($ ? round(rect.width) : rect.width) / width;
let y = ($ ? round(rect.height) : rect.height) / height;
if (!x || !Number.isFinite(x)) x = 1;
if (!y || !Number.isFinite(y)) y = 1;
return {
x,
y
};
}
const noOffsets = /*#__PURE__*/ createCoords(0);
function getVisualOffsets(element) {
const win = getWindow(element);
if (!isWebKit() || !win.visualViewport) return noOffsets;
return {
x: win.visualViewport.offsetLeft,
y: win.visualViewport.offsetTop
};
}
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
if (isFixed === void 0) isFixed = false;
return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
}
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
if (includeScale === void 0) includeScale = false;
if (isFixedStrategy === void 0) isFixedStrategy = false;
const clientRect = element.getBoundingClientRect();
const domElement = unwrapElement(element);
let scale = createCoords(1);
if (includeScale) if (offsetParent) {
if (isElement(offsetParent)) scale = getScale(offsetParent);
} else scale = getScale(element);
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
let x = (clientRect.left + visualOffsets.x) / scale.x;
let y = (clientRect.top + visualOffsets.y) / scale.y;
let width = clientRect.width / scale.x;
let height = clientRect.height / scale.y;
if (domElement && offsetParent) {
const win = getWindow(domElement);
const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
let currentWin = win;
let currentIFrame = getFrameElement(currentWin);
while (currentIFrame && offsetWin !== currentWin) {
const iframeScale = getScale(currentIFrame);
const iframeRect = currentIFrame.getBoundingClientRect();
const css = getComputedStyle$1(currentIFrame);
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
x *= iframeScale.x;
y *= iframeScale.y;
width *= iframeScale.x;
height *= iframeScale.y;
x += left;
y += top;
currentWin = getWindow(currentIFrame);
currentIFrame = getFrameElement(currentWin);
}
}
return rectToClientRect({
width,
height,
x,
y
});
}
function getWindowScrollBarX(element, rect) {
const leftScroll = getNodeScroll(element).scrollLeft;
if (!rect) return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
return rect.left + leftScroll;
}
function getHTMLOffset(documentElement, scroll) {
const htmlRect = documentElement.getBoundingClientRect();
return {
x: htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect),
y: htmlRect.top + scroll.scrollTop
};
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
let { elements, rect, offsetParent, strategy } = _ref;
const isFixed = strategy === "fixed";
const documentElement = getDocumentElement(offsetParent);
const topLayer = elements ? isTopLayer(elements.floating) : false;
if (offsetParent === documentElement || topLayer && isFixed) return rect;
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
let scale = createCoords(1);
const offsets = createCoords(0);
const isOffsetParentAnElement = isHTMLElement(offsetParent);
if (isOffsetParentAnElement || !isFixed) {
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
if (isOffsetParentAnElement) {
const offsetRect = getBoundingClientRect(offsetParent);
scale = getScale(offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
}
}
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
return {
width: rect.width * scale.x,
height: rect.height * scale.y,
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
};
}
function getClientRects(element) {
return element.getClientRects ? Array.from(element.getClientRects()) : [];
}
function getDocumentRect(html) {
const scroll = getNodeScroll(html);
const body = html.ownerDocument.body;
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
let x = -scroll.scrollLeft + getWindowScrollBarX(html);
const y = -scroll.scrollTop;
if (getComputedStyle$1(body).direction === "rtl") x += max(html.clientWidth, body.clientWidth) - width;
return {
width,
height,
x,
y
};
}
const SCROLLBAR_MAX = 25;
function getViewportRect(element, strategy, rootBoundary) {
if (rootBoundary === void 0) rootBoundary = "viewport";
const isLayoutViewport = rootBoundary === "layoutViewport";
const win = getWindow(element);
const html = getDocumentElement(element);
const visualViewport = win.visualViewport;
let width = html.clientWidth;
let height = html.clientHeight;
let x = 0;
let y = 0;
if (visualViewport) {
const layoutRelativeClientCoords = !isWebKit() || strategy === "fixed";
if (isLayoutViewport) {
if (!layoutRelativeClientCoords) {
x = -visualViewport.offsetLeft;
y = -visualViewport.offsetTop;
}
} else {
width = visualViewport.width;
height = visualViewport.height;
if (layoutRelativeClientCoords) {
x = visualViewport.offsetLeft;
y = visualViewport.offsetTop;
}
}
}
if (getWindowScrollBarX(html) <= 0) {
const doc = html.ownerDocument;
const body = doc.body;
const bodyStyles = getComputedStyle(body);
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
const gutter = getComputedStyle(html).scrollbarGutter === "stable both-edges" ? reservedWidth / 2 : reservedWidth;
if (gutter <= SCROLLBAR_MAX) width -= gutter;
}
return {
width,
height,
x,
y
};
}
function getInnerBoundingClientRect(element, strategy) {
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
const top = clientRect.top + element.clientTop;
const left = clientRect.left + element.clientLeft;
const scale = getScale(element);
return {
width: element.clientWidth * scale.x,
height: element.clientHeight * scale.y,
x: left * scale.x,
y: top * scale.y
};
}
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
let rect;
if (clippingAncestor === "viewport" || clippingAncestor === "layoutViewport") rect = getViewportRect(element, strategy, clippingAncestor);
else if (clippingAncestor === "document") rect = getDocumentRect(getDocumentElement(element));
else if (isElement(clippingAncestor)) rect = getInnerBoundingClientRect(clippingAncestor, strategy);
else {
const visualOffsets = getVisualOffsets(element);
rect = {
x: clippingAncestor.x - visualOffsets.x,
y: clippingAncestor.y - visualOffsets.y,
width: clippingAncestor.width,
height: clippingAncestor.height
};
}
return rectToClientRect(rect);
}
function getClippingElementAncestors(element, cache) {
const cachedResult = cache.get(element);
if (cachedResult) return cachedResult;
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
let lastKeptComputedStyle = null;
const elementIsFixed = getComputedStyle$1(element).position === "fixed";
let currentNode = elementIsFixed ? getParentNode(element) : element;
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
const computedStyle = getComputedStyle$1(currentNode);
const currentNodeIsContaining = isContainingBlock(currentNode);
const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? "fixed" : "";
if (!currentNodeIsContaining && (lastPosition === "fixed" || lastPosition === "absolute" && computedStyle.position === "static")) result = result.filter((ancestor) => ancestor !== currentNode);
else lastKeptComputedStyle = computedStyle;
currentNode = getParentNode(currentNode);
}
cache.set(element, result);
return result;
}
function getClippingRect(_ref) {
let { element, boundary, rootBoundary, strategy } = _ref;
const clippingAncestors = [...boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary), rootBoundary];
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
let top = firstRect.top;
let right = firstRect.right;
let bottom = firstRect.bottom;
let left = firstRect.left;
for (let i = 1; i < clippingAncestors.length; i++) {
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
top = max(rect.top, top);
right = min(rect.right, right);
bottom = min(rect.bottom, bottom);
left = max(rect.left, left);
}
return {
width: right - left,
height: bottom - top,
x: left,
y: top
};
}
function getDimensions(element) {
const { width, height } = getCssDimensions(element);
return {
width,
height
};
}
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const isFixed = strategy === "fixed";
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = createCoords(0);
if (isOffsetParentAnElement || !isFixed) {
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) scroll = getNodeScroll(offsetParent);
if (isOffsetParentAnElement) {
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
}
}
if (!isOffsetParentAnElement && documentElement) offsets.x = getWindowScrollBarX(documentElement);
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
return {
x: rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x,
y: rect.top + scroll.scrollTop - offsets.y - htmlOffset.y,
width: rect.width,
height: rect.height
};
}
function isStaticPositioned(element) {
return getComputedStyle$1(element).position === "static";
}
function getTrueOffsetParent(element, polyfill) {
if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") return null;
if (polyfill) return polyfill(element);
let rawOffsetParent = element.offsetParent;
if (getDocumentElement(element) === rawOffsetParent) rawOffsetParent = rawOffsetParent.ownerDocument.body;
return rawOffsetParent;
}
function getOffsetParent(element, polyfill) {
const win = getWindow(element);
if (isTopLayer(element)) return win;
if (!isHTMLElement(element)) {
let svgOffsetParent = getParentNode(element);
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) return svgOffsetParent;
svgOffsetParent = getParentNode(svgOffsetParent);
}
return win;
}
let offsetParent = getTrueOffsetParent(element, polyfill);
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) offsetParent = getTrueOffsetParent(offsetParent, polyfill);
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) return win;
return offsetParent || getContainingBlock(element) || win;
}
const getElementRects = async function(data) {
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
const getDimensionsFn = this.getDimensions;
const floatingDimensions = await getDimensionsFn(data.floating);
return {
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
floating: {
x: 0,
y: 0,
width: floatingDimensions.width,
height: floatingDimensions.height
}
};
};
function isRTL(element) {
return getComputedStyle$1(element).direction === "rtl";
}
const platform = {
convertOffsetParentRelativeRectToViewportRelativeRect,
getDocumentElement,
getClippingRect,
getOffsetParent,
getElementRects,
getClientRects,
getDimensions,
getScale,
isElement,
isRTL
};
function rectsAreEqual(a, b) {
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
}
function observeMove(element, onMove, ancestorResize) {
let io = null;
let timeoutId;
const root = getDocumentElement(element);
function cleanup() {
var _io;
clearTimeout(timeoutId);
(_io = io) == null || _io.disconnect();
io = null;
}
function refresh(skip, threshold) {
if (skip === void 0) skip = false;
if (threshold === void 0) threshold = 1;
cleanup();
const elementRectForRootMargin = element.getBoundingClientRect();
const { left, top, width, height } = elementRectForRootMargin;
if (!skip) onMove();
if (!width || !height) return;
const insetTop = floor(top);
const insetRight = floor(root.clientWidth - (left + width));
const insetBottom = floor(root.clientHeight - (top + height));
const insetLeft = floor(left);
const options = {
rootMargin: -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px",
threshold: max(0, min(1, threshold)) || 1
};
let isFirstUpdate = true;
function handleObserve(entries) {
const ratio = entries[0].intersectionRatio;
if (!rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) return refresh();
if (ratio !== threshold) {
if (!isFirstUpdate) return refresh();
if (!ratio) timeoutId = setTimeout(() => {
refresh(false, 1e-7);
}, 1e3);
else refresh(false, ratio);
}
isFirstUpdate = false;
}
try {
io = new IntersectionObserver(handleObserve, {
...options,
root: root.ownerDocument
});
} catch (_e) {
io = new IntersectionObserver(handleObserve, options);
}
io.observe(element);
}
const win = getWindow(element);
const handleResize = () => refresh(ancestorResize);
win.addEventListener("resize", handleResize);
refresh(true);
return () => {
win.removeEventListener("resize", handleResize);
cleanup();
};
}
/**
* Automatically updates the position of the floating element when necessary.
* Should only be called when the floating element is mounted on the DOM or
* visible on the screen.
* @returns cleanup function that should be invoked when the floating element is
* removed from the DOM or hidden from the screen.
* @see https://floating-ui.com/docs/autoUpdate
*/
function autoUpdate(reference, floating, update, options) {
if (options === void 0) options = {};
const { ancestorScroll = true, ancestorResize = true, elementResize = typeof ResizeObserver === "function", layoutShift = typeof IntersectionObserver === "function", animationFrame = false } = options;
const referenceEl = unwrapElement(reference);
const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
ancestors.forEach((ancestor) => {
ancestorScroll && ancestor.addEventListener("scroll", update);
ancestorResize && ancestor.addEventListener("resize", update);
});
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update, ancestorResize) : null;
let reobserveFrame = -1;
let resizeObserver = null;
if (elementResize) {
resizeObserver = new ResizeObserver((_ref) => {
let [firstEntry] = _ref;
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
resizeObserver.unobserve(floating);
cancelAnimationFrame(reobserveFrame);
reobserveFrame = requestAnimationFrame(() => {
var _resizeObserver;
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
});
}
update();
});
if (referenceEl && !animationFrame) resizeObserver.observe(referenceEl);
if (floating) resizeObserver.observe(floating);
}
let frameId;
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
if (animationFrame) frameLoop();
function frameLoop() {
const nextRefRect = getBoundingClientRect(reference);
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) update();
prevRefRect = nextRefRect;
frameId = requestAnimationFrame(frameLoop);
}
update();
return () => {
var _resizeObserver2;
ancestors.forEach((ancestor) => {
ancestorScroll && ancestor.removeEventListener("scroll", update);
ancestorResize && ancestor.removeEventListener("resize", update);
});
cleanupIo?.();
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
resizeObserver = null;
if (animationFrame) cancelAnimationFrame(frameId);
};
}
/**
* Modifies the placement by translating the floating element along the
* specified axes.
* A number (shorthand for `mainAxis` or distance), or an axes configuration
* object may be passed.
* @see https://floating-ui.com/docs/offset
*/
const offset = offset$1;
/**
* Optimizes the visibility of the floating element by shifting it in order to
* keep it in view when it will overflow the clipping boundary.
* @see https://floating-ui.com/docs/shift
*/
const shift = shift$1;
/**
* Optimizes the visibility of the floating element by flipping the `placement`
* in order to keep it in view when the preferred placement(s) will overflow the
* clipping boundary. Alternative to `autoPlacement`.
* @see https://floating-ui.com/docs/flip
*/
const flip = flip$1;
/**
* Provides data that allows you to change the size of the floating element —
* for instance, prevent it from overflowing the clipping boundary or match the
* width of the reference element.
* @see https://floating-ui.com/docs/size
*/
const size = size$1;
/**
* Provides data to position an inner element of the floating element so that it
* appears centered to the reference element.
* @see https://floating-ui.com/docs/arrow
*/
const arrow = arrow$1;
/**
* Computes the `x` and `y` coordinates that will place the floating element
* next to a given reference element.
*/
const computePosition = (reference, floating, options) => {
const cache = /* @__PURE__ */ new Map();
const mergedOptions = options != null ? options : {};
const platformWithCache = {
...platform,
...mergedOptions.platform,
_c: cache
};
return computePosition$1(reference, floating, {
...mergedOptions,
platform: platformWithCache
});
};
//#endregion
//#region js/src/util/floating-ui.ts
/**
* Breakpoints for responsive placement (matches SCSS $breakpoints)
*/
const BREAKPOINTS = {
sm: 576,
md: 768,
lg: 1024,
xl: 1280,
"2xl": 1536
};
/**
* Parse a placement string that may contain responsive prefixes
* Example: "bottom-start md:top-end lg:right" returns { xs: 'bottom-start', md: 'top-end', lg: 'right' }
*
* @param placementString - The placement string to parse
* @param defaultPlacement - The default placement to use for xs/base
* @returns Object with breakpoint keys and placement values, or null if not responsive
*/
const parseResponsivePlacement = (placementString, defaultPlacement = "bottom") => {
if (!placementString || !placementString.includes(":")) return null;
const parts = placementString.split(/\s+/);
const placements = { xs: defaultPlacement };
for (const part of parts) if (part.includes(":")) {
const [breakpoint, placement] = part.split(":");
if (BREAKPOINTS[breakpoint] !== void 0) placements[breakpoint] = placement;
} else placements.xs = part;
return placements;
};
/**
* Get the active placement for the current viewport width
*
* @param responsivePlacements - Object with breakpoint keys and placement values
* @param defaultPlacement - Fallback placement
* @returns The active placement for current viewport
*/
const getResponsivePlacement = (responsivePlacements, defaultPlacement = "bottom") => {
if (!responsivePlacements) return defaultPlacement;
const viewportWidth = window.innerWidth;
let activePlacement = responsivePlacements.xs || defaultPlacement;
for (const breakpoint of [
"sm",
"md",
"lg",
"xl",
"2xl"
]) if (viewportWidth >= BREAKPOINTS[breakpoint] && responsivePlacements[breakpoint]) activePlacement = responsivePlacements[breakpoint];
return activePlacement;
};
/**
* Create media query listeners for responsive placement changes
*
* @param callback - Callback to run when breakpoint changes
* @returns Array of { mql, handler } objects for cleanup
*/
const createBreakpointListeners = (callback) => {
const listeners = [];
for (const breakpoint of Object.keys(BREAKPOINTS)) {
const minWidth = BREAKPOINTS[breakpoint];
const mql = window.matchMedia(`(min-width: ${minWidth}px)`);
mql.addEventListener("change", callback);
listeners.push({
mql,
handler: callback
});
}
return listeners;
};
/**
* Clean up media query listeners
*
* @param listeners - Array of { mql, handler } objects
*/
const disposeBreakpointListeners = (listeners) => {
for (const { mql, handler } of listeners) mql.removeEventListener("change", handler);
};
/**
* Normalize an offset value into Floating UI's offset shape.
* A `[skidding, distance]` array becomes `{ mainAxis: distance, crossAxis: skidding }`;
* numbers and axis objects pass through unchanged.
*/
const toFloatingOffset = (value) => {
return Array.isArray(value) ? {
mainAxis: value[1] || 0,
crossAxis: value[0] || 0
} : value;
};
//#endregion
//#region js/src/menu.ts
/**
* --------------------------------------------------------------------------
* Bootstrap menu.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$16 = "menu";
const EVENT_KEY$13 = `.bs.menu`;
const DATA_API_KEY$8 = ".data-api";
const ESCAPE_KEY$2 = "Escape";
const TAB_KEY$1 = "Tab";
const ARROW_UP_KEY$2 = "ArrowUp";
const ARROW_DOWN_KEY$2 = "ArrowDown";
const ARROW_LEFT_KEY$1 = "ArrowLeft";
const ARROW_RIGHT_KEY$1 = "ArrowRight";
const HOME_KEY$2 = "Home";
const END_KEY$2 = "End";
const ENTER_KEY$1 = "Enter";
const SPACE_KEY$1 = " ";
const ITEM_NAVIGATION_KEYS = /* @__PURE__ */ new Set([
ARROW_UP_KEY$2,
ARROW_DOWN_KEY$2,
ARROW_LEFT_KEY$1,
ARROW_RIGHT_KEY$1,
HOME_KEY$2,
END_KEY$2
]);
const RIGHT_MOUSE_BUTTON = 2;
const SUBMENU_CLOSE_DELAY = 100;
const EVENT_HIDE$4 = `hide${EVENT_KEY$13}`;
const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$13}`;
const EVENT_SHOW$4 = `show${EVENT_KEY$13}`;
const EVENT_SHOWN$4 = `shown${EVENT_KEY$13}`;
const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$13}${DATA_API_KEY$8}`;
const EVENT_TOUCH_MOUSEOVER = `mouseover${EVENT_KEY$13}`;
const CLASS_NAME_SHOW$5 = "show";
const CLASS_NAME_MENU_BACK = "menu-back";
const SELECTOR_DATA_TOGGLE$8 = "[data-bs-toggle=\"menu\"]:not(.disabled):not(:disabled)";
const SELECTOR_MENU$3 = ".menu";
const SELECTOR_SUBMENU = ".submenu";
const SELECTOR_SUBMENU_TOGGLE = ".submenu > .menu-item";
const SELECTOR_NAVBAR_NAV = ".navbar-nav";
const SELECTOR_VISIBLE_ITEMS$1 = ".menu-item:not(.disabled):not(:disabled)";
const SELECTOR_TAB_STOPS = ":is(a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]):not(:disabled, .disabled)";
const DEFAULT_PLACEMENT = "bottom-start";
const SUBMENU_PLACEMENT = "end-start";
const resolveLogicalPlacement = (placement) => {
if (isRTL$1()) return placement.replace(/^start(?=-|$)/, "right").replace(/^end(?=-|$)/, "left");
return placement.replace(/^start(?=-|$)/, "left").replace(/^end(?=-|$)/, "right");
};
const triangleSign = (p1, p2, p3) => (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
const Default$15 = {
autoClose: true,
boundary: "clippingParents",
container: false,
display: "dynamic",
offset: [0, 2],
floatingConfig: null,
menu: null,
placement: DEFAULT_PLACEMENT,
reference: "toggle",
strategy: "absolute",
submenuTrigger: "both",
submenuDelay: SUBMENU_CLOSE_DELAY
};
const DefaultType$15 = {
autoClose: "(boolean|string)",
boundary: "(string|element)",
container: "(string|element|boolean)",
display: "string",
offset: "(array|string|function)",
floatingConfig: "(null|object|function)",
menu: "(null|element)",
placement: "string",
reference: "(string|element|object)",
strategy: "string",
submenuTrigger: "string",
submenuDelay: "number"
};
/**
* Class definition
*/
var Menu = class Menu extends BaseComponent {
static _openInstances = /* @__PURE__ */ new Set();
constructor(element, config) {
if (typeof computePosition === "undefined") throw new TypeError("Bootstrap's menus require Floating UI (https://floating-ui.com)");
super(element, config);
this._floatingCleanup = null;
this._mediaQueryListeners = [];
this._responsivePlacements = null;
this._parent = this._element.parentNode;
this._openSubmenus = /* @__PURE__ */ new Map();
this._submenuCloseTimeouts = /* @__PURE__ */ new Map();
this._hoverIntentData = null;
this._submenuPointerType = "mouse";
this._touchMouseover = () => void 0;
this._touchMouseoverTargets = /* @__PURE__ */ new Set();
this._menu = this._config.menu || this._findMenu();
if (!this._config.menu && this._menu) this._parent = this._findWrapper(this._menu);
this._isSubmenu = this._parent.classList?.contains("submenu");
this._menuOriginalParent = this._menu?.parentNode;
this._menuOriginalNextSibling = null;
this._parseResponsivePlacements();
this._setupSubmenuListeners();
this._initSubmenuTriggers();
}
static get Default() {
return Default$15;
}
static get DefaultType() {
return DefaultType$15;
}
static get NAME() {
return NAME$16;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
show() {
return this._show();
}
async _show(focus) {
if (isDisabled(this._element) || this._isShown()) return;
const relatedTarget = { relatedTarget: this._element };
if (EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget).defaultPrevented) return;
this._moveMenuToContainer();
this._disposeFloating();
this._submenuPointerType = "mouse";
if ("ontouchstart" in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) for (const element of document.body.children) {
EventHandler.on(element, EVENT_TOUCH_MOUSEOVER, this._touchMouseover);
this._touchMouseoverTargets.add(element);
}
this._element.setAttribute("aria-expanded", "true");
this._menu.classList.add(CLASS_NAME_SHOW$5);
this._element.classList.add(CLASS_NAME_SHOW$5);
if (this._parent) this._parent.classList.add(CLASS_NAME_SHOW$5);
this._syncSubmenuLayout();
this._createFloating();
Menu._openInstances.add(this);
if (focus) focus();
else this._element.focus({ focusVisible: false });
if (!this._element || !this._isShown()) return;
await this._queueCallback(() => {
if (this._menu && this._isShown()) EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget);
}, this._menu, this._isAnimated());
}
async hide() {
if (isDisabled(this._element) || !this._isShown()) return;
const relatedTarget = { relatedTarget: this._element };
await this._completeHide(relatedTarget);
}
dispose() {
this._removeTouchMouseoverListeners();
EventHandler.off(this._menu, EVENT_KEY$13);
this._disposeFloating();
this._clearSize();
this._restoreMenuToOriginalParent();
this._disposeMediaQueryListeners();
this._closeAllSubmenus();
this._clearAllSubmenuTimeouts();
Menu._openInstances.delete(this);
super.dispose();
}
update() {
if (this._floatingCleanup) this._updateFloatingPosition();
}
_findMenu() {
const wrapper = SelectorEngine.closest(this._element, `:has(${SELECTOR_MENU$3})`);
return SelectorEngine.next(this._element, SELECTOR_MENU$3)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU$3)[0] || SelectorEngine.findOne(SELECTOR_MENU$3, wrapper || this._parent);
}
_findWrapper(menu) {
let wrapper = this._element.parentNode;
while (wrapper instanceof Element && !wrapper.contains(menu)) wrapper = wrapper.parentNode;
return wrapper instanceof Element ? wrapper : this._element.parentNode;
}
async _completeHide(relatedTarget) {
if (EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget).defaultPrevented) return;
this._closeAllSubmenus();
this._removeTouchMouseoverListeners();
this._menu.classList.remove(CLASS_NAME_SHOW$5);
this._element.classList.remove(CLASS_NAME_SHOW$5);
if (this._parent) this._parent.classList.remove(CLASS_NAME_SHOW$5);
this._element.setAttribute("aria-expanded", "false");
Menu._openInstances.delete(this);
await this._queueCallback(() => {
if (!this._menu || this._isShown()) return;
this._disposeFloating();
this._clearSize();
this._restoreMenuToOriginalParent();
Manipulator.removeDataAttribute(this._menu, "placement");
Manipulator.removeDataAttribute(this._menu, "display");
EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget);
}, this._menu, this._isAnimated());
}
_removeTouchMouseoverListeners() {
for (const element of this._touchMouseoverTargets) EventHandler.off(element, EVENT_TOUCH_MOUSEOVER, this._touchMouseover);
this._touchMouseoverTargets.clear();
}
_getConfig(config) {
config = super._getConfig(config);
if (typeof config.reference === "object" && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== "function") throw new TypeError(`${NAME$16.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
return config;
}
_createFloating() {
if (this._config.display === "static") {
Manipulator.setDataAttribute(this._menu, "display", "static");
return;
}
let referenceElement = this._element;
if (this._config.reference === "parent") referenceElement = this._parent;
else if (isElement$1(this._config.reference)) referenceElement = getElement(this._config.reference);
else if (typeof this._config.reference === "object") referenceElement = this._config.reference;
this._floatingCleanup = autoUpdate(referenceElement, this._menu, () => this._updateFloatingPosition(referenceElement));
}
async _updateFloatingPosition(referenceElement = null) {
if (!this._menu) return;
if (!referenceElement) if (this._config.reference === "parent") referenceElement = this._parent;
else if (isElement$1(this._config.reference)) referenceElement = getElement(this._config.reference);
else if (typeof this._config.reference === "object") referenceElement = this._config.reference;
else referenceElement = this._element;
const placement = this._getPlacement();
const middleware = this._getFloatingMiddleware();
const floatingConfig = this._getFloatingConfig(placement, middleware);
await this._applyFloatingPosition(referenceElement, this._menu, floatingConfig.placement, floatingConfig.middleware, floatingConfig.strategy);
}
_isShown() {
return this._menu.classList.contains(CLASS_NAME_SHOW$5);
}
_isAnimated() {
return getTransitionDurationFromElement(this._menu) > 0;
}
_getPlacement() {
const placement = this._responsivePlacements ? getResponsivePlacement(this._responsivePlacements, DEFAULT_PLACEMENT) : this._config.placement;
return resolveLogicalPlacement(placement);
}
_parseResponsivePlacements() {
this._responsivePlacements = parseResponsivePlacement(this._config.placement, DEFAULT_PLACEMENT);
if (this._responsivePlacements) this._setupMediaQueryListeners();
}
_setupMediaQueryListeners() {
this._disposeMediaQueryListeners();
this._mediaQueryListeners = createBreakpointListeners(() => {
if (this._isShown()) this._updateFloatingPosition();
});
}
_disposeMediaQueryListeners() {
disposeBreakpointListeners(this._mediaQueryListeners);
this._mediaQueryListeners = [];
}
_getOffset() {
const { offset: offsetConfig } = this._config;
if (typeof offsetConfig === "string") return offsetConfig.split(",").map((value) => Number.parseInt(value, 10));
if (typeof offsetConfig === "function") return ({ placement, rects }) => {
return toFloatingOffset(offsetConfig({
placement,
reference: rects.reference,
floating: rects.floating
}, this._element));
};
return offsetConfig;
}
_getFloatingMiddleware() {
const offsetValue = this._getOffset();
const boundary = this._config.boundary === "clippingParents" ? "clippingAncestors" : this._config.boundary;
return [
offset(typeof offsetValue === "function" ? offsetValue : toFloatingOffset(offsetValue)),
flip({
boundary,
fallbackPlacements: this._getFallbackPlacements()
}),
shift({ boundary }),
size({
boundary,
apply: ({ availableWidth, availableHeight, elements }) => {
if (this._menu !== elements.floating || !this._isShown() || getComputedStyle(this._menu).position === "static") return;
this._menu.style.setProperty("--bs-menu-available-width", `${Math.max(0, Math.floor(availableWidth))}px`);
this._menu.style.setProperty("--bs-menu-available-height", `${Math.max(0, Math.floor(availableHeight))}px`);
this._syncSubmenuLayout();
}
})
];
}
_syncSubmenuLayout() {
if (!this._openSubmenus.size) this._menu.toggleAttribute("data-bs-menu-constrained", this._menu.scrollHeight > this._menu.clientHeight);
else if (this._usesStackedSubmenus() && this._menu.scrollHeight > this._menu.clientHeight) this._menu.setAttribute("data-bs-menu-constrained", "");
const { overflowX, overflowY } = getComputedStyle(this._menu);
this._menu.toggleAttribute("data-bs-menu-stacked", overflowX !== "visible" || overflowY !== "visible");
}
_clearSize() {
if (this._menu) {
this._menu.style.removeProperty("--bs-menu-available-width");
this._menu.style.removeProperty("--bs-menu-available-height");
this._menu.removeAttribute("data-bs-menu-constrained");
this._menu.removeAttribute("data-bs-menu-stacked");
}
}
_getFallbackPlacements() {
return {
bottom: [
"top",
"bottom-start",
"bottom-end",
"top-start",
"top-end"
],
"bottom-start": [
"top-start",
"bottom-end",
"top-end"
],
"bottom-end": [
"top-end",
"bottom-start",
"top-start"
],
top: [
"bottom",
"top-start",
"top-end",
"bottom-start",
"bottom-end"
],
"top-start": [
"bottom-start",
"top-end",
"bottom-end"
],
"top-end": [
"bottom-end",
"top-start",
"bottom-start"
],
right: [
"left",
"right-start",
"right-end",
"left-start",
"left-end"
],
"right-start": [
"left-start",
"right-end",
"left-end",
"top-start",
"bottom-start"
],
"right-end": [
"left-end",
"right-start",
"left-start",
"top-end",
"bottom-end"
],
left: [
"right",
"left-start",
"left-end",
"right-start",
"right-end"
],
"left-start": [
"right-start",
"left-end",
"right-end",
"top-start",
"bottom-start"
],
"left-end": [
"right-end",
"left-start",
"right-start",
"top-end",
"bottom-end"
]
}[this._getPlacement()] || [
"top",
"bottom",
"right",
"left"
];
}
_getFloatingConfig(placement, middleware) {
const defaultConfig = {
placement,
middleware,
strategy: this._config.strategy
};
return {
...defaultConfig,
...execute(this._config.floatingConfig, [void 0, defaultConfig])
};
}
_disposeFloating() {
if (this._floatingCleanup) {
this._floatingCleanup();
this._floatingCleanup = null;
}
}
_getContainer() {
const { container } = this._config;
if (container === false) return null;
return container === true ? document.body : getElement(container);
}
_moveMenuToContainer() {
const container = this._getContainer();
if (!container || !this._menu) return;
if (this._menu.parentNode !== container) {
this._menuOriginalNextSibling = this._menu.nextSibling;
container.append(this._menu);
}
}
_restoreMenuToOriginalParent() {
if (!this._menuOriginalParent || !this._menu) return;
if (this._menu.parentNode !== this._menuOriginalParent) {
const nextSibling = this._menuOriginalNextSibling;
this._menuOriginalParent.insertBefore(this._menu, nextSibling?.parentNode === this._menuOriginalParent ? nextSibling : null);
}
}
async _applyFloatingPosition(reference, floating, placement, middleware, strategy = "absolute") {
if (!floating.isConnected) return null;
const { x, y, placement: finalPlacement } = await computePosition(reference, floating, {
placement,
middleware,
strategy
});
if (!floating.isConnected) return null;
Object.assign(floating.style, {
position: strategy,
left: `${x}px`,
top: `${y}px`,
margin: "0"
});
Manipulator.setDataAttribute(floating, "placement", finalPlacement);
return finalPlacement;
}
_setupSubmenuListeners() {
if (this._config.submenuTrigger === "hover" || this._config.submenuTrigger === "both") {
EventHandler.on(this._menu, `mouseenter${EVENT_KEY$13}`, SELECTOR_SUBMENU_TOGGLE, (event) => {
this._onSubmenuTriggerEnter(event);
});
EventHandler.on(this._menu, `mouseleave${EVENT_KEY$13}`, SELECTOR_SUBMENU, (event) => {
this._onSubmenuLeave(event);
});
EventHandler.on(this._menu, `mousemove${EVENT_KEY$13}`, (event) => {
this._trackMousePosition(event);
});
}
if (this._config.submenuTrigger === "both") EventHandler.on(this._menu, `pointerover${EVENT_KEY$13}`, (event) => {
this._submenuPointerType = event.pointerType;
});
if ([
"click",
"hover",
"both"
].includes(this._config.submenuTrigger)) EventHandler.on(this._menu, `click${EVENT_KEY$13}`, SELECTOR_SUBMENU_TOGGLE, (event) => {
if (this._config.submenuTrigger !== "hover" || this._usesStackedSubmenus()) this._onSubmenuTriggerClick(event);
});
}
_usesStackedSubmenus() {
return getComputedStyle(this._menu).getPropertyValue("--bs-menu-stack-submenus") === "1";
}
_onSubmenuTriggerEnter(event) {
if (this._submenuPointerType !== "mouse" || this._usesStackedSubmenus()) return;
const trigger = event.target.closest(SELECTOR_SUBMENU_TOGGLE);
if (!trigger) return;
const submenuWrapper = trigger.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu) return;
this._cancelSubmenuCloseTimeout(submenu);
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(trigger, submenu, submenuWrapper);
}
_onSubmenuLeave(event) {
if (this._submenuPointerType !== "mouse" || this._usesStackedSubmenus()) return;
const submenuWrapper = event.target.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu || !this._openSubmenus.has(submenu)) return;
if (this._isMovingTowardSubmenu(event, submenu)) return;
this._scheduleSubmenuClose(submenu, submenuWrapper);
}
_onSubmenuTriggerClick(event) {
const trigger = event.target.closest(SELECTOR_SUBMENU_TOGGLE);
if (!trigger) return;
event.preventDefault();
event.stopPropagation();
const submenuWrapper = trigger.closest(SELECTOR_SUBMENU);
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (!submenu) return;
if (this._openSubmenus.has(submenu)) this._closeSubmenu(submenu, submenuWrapper);
else {
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(trigger, submenu, submenuWrapper);
if (this._usesStackedSubmenus()) this._getItemsInMenu(submenu)[0]?.focus();
}
}
_initSubmenuTriggers() {
if (!this._menu) return;
for (const trigger of SelectorEngine.find(SELECTOR_SUBMENU_TOGGLE, this._menu)) {
if (!SelectorEngine.findOne(SELECTOR_MENU$3, trigger.parentElement)) continue;
trigger.setAttribute("aria-haspopup", "true");
if (!trigger.hasAttribute("aria-expanded")) trigger.setAttribute("aria-expanded", "false");
}
}
_openSubmenu(trigger, submenu, submenuWrapper) {
if (this._openSubmenus.has(submenu)) return;
trigger.setAttribute("aria-expanded", "true");
trigger.setAttribute("aria-haspopup", "true");
submenu.style.opacity = "0";
submenu.classList.add(CLASS_NAME_SHOW$5);
submenuWrapper.classList.add(CLASS_NAME_SHOW$5);
const backItem = document.createElement(submenu.matches("ul, ol, menu") ? "li" : "div");
backItem.className = CLASS_NAME_MENU_BACK;
const backButton = document.createElement("button");
backButton.type = "button";
backButton.className = "menu-item";
backButton.textContent = "Back";
backButton.addEventListener("click", (event) => {
event.stopPropagation();
this._closeSubmenu(submenu, submenuWrapper);
trigger.focus();
});
backItem.append(backButton);
submenu.prepend(backItem);
const cleanup = this._createSubmenuFloating(submenu, submenuWrapper);
this._openSubmenus.set(submenu, () => {
cleanup();
backItem.remove();
});
EventHandler.on(submenu, `mouseenter${EVENT_KEY$13}`, () => {
this._cancelSubmenuCloseTimeout(submenu);
});
}
_closeSubmenu(submenu, submenuWrapper) {
if (!this._openSubmenus.has(submenu)) return;
const nestedSubmenus = SelectorEngine.find(`${SELECTOR_SUBMENU} ${SELECTOR_MENU$3}.${CLASS_NAME_SHOW$5}`, submenu);
for (const nested of nestedSubmenus) {
const nestedWrapper = nested.closest(SELECTOR_SUBMENU);
this._closeSubmenu(nested, nestedWrapper);
}
const trigger = SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, submenuWrapper);
const cleanup = this._openSubmenus.get(submenu);
if (cleanup) cleanup();
this._openSubmenus.delete(submenu);
EventHandler.off(submenu, `mouseenter${EVENT_KEY$13}`);
this._cancelSubmenuCloseTimeout(submenu);
if (trigger) trigger.setAttribute("aria-expanded", "false");
submenu.classList.remove(CLASS_NAME_SHOW$5);
submenuWrapper.classList.remove(CLASS_NAME_SHOW$5);
submenu.style.opacity = "";
}
_closeAllSubmenus() {
for (const [submenu] of this._openSubmenus) {
const submenuWrapper = submenu.closest(SELECTOR_SUBMENU);
this._closeSubmenu(submenu, submenuWrapper);
}
}
_closeSiblingSubmenus(currentSubmenuWrapper) {
const parent = currentSubmenuWrapper.parentNode;
const siblingSubmenus = SelectorEngine.find(`${SELECTOR_SUBMENU} > ${SELECTOR_MENU$3}.${CLASS_NAME_SHOW$5}`, parent);
for (const siblingMenu of siblingSubmenus) {
const siblingWrapper = siblingMenu.closest(SELECTOR_SUBMENU);
if (siblingWrapper !== currentSubmenuWrapper) this._closeSubmenu(siblingMenu, siblingWrapper);
}
}
_createSubmenuFloating(submenu, submenuWrapper) {
const referenceElement = submenuWrapper;
const placement = resolveLogicalPlacement(SUBMENU_PLACEMENT);
const middleware = [
offset({
mainAxis: 0,
crossAxis: -4
}),
flip({ fallbackPlacements: [
resolveLogicalPlacement("start-start"),
resolveLogicalPlacement("end-end"),
resolveLogicalPlacement("start-end")
] }),
shift({ padding: 8 })
];
const updatePosition = async () => {
if (this._usesStackedSubmenus()) {
submenu.style.opacity = "";
return;
}
await this._applyFloatingPosition(referenceElement, submenu, placement, middleware);
submenu.style.opacity = "";
};
return autoUpdate(referenceElement, submenu, updatePosition);
}
_scheduleSubmenuClose(submenu, submenuWrapper) {
this._cancelSubmenuCloseTimeout(submenu);
const timeoutId = setTimeout(() => {
this._closeSubmenu(submenu, submenuWrapper);
this._submenuCloseTimeouts.delete(submenu);
}, this._config.submenuDelay);
this._submenuCloseTimeouts.set(submenu, timeoutId);
}
_cancelSubmenuCloseTimeout(submenu) {
const timeoutId = this._submenuCloseTimeouts.get(submenu);
if (timeoutId) {
clearTimeout(timeoutId);
this._submenuCloseTimeouts.delete(submenu);
}
}
_clearAllSubmenuTimeouts() {
for (const timeoutId of this._submenuCloseTimeouts.values()) clearTimeout(timeoutId);
this._submenuCloseTimeouts.clear();
}
_trackMousePosition(event) {
this._hoverIntentData = {
x: event.clientX,
y: event.clientY,
timestamp: Date.now()
};
}
_isMovingTowardSubmenu(event, submenu) {
if (!this._hoverIntentData) return false;
const submenuRect = submenu.getBoundingClientRect();
const currentPos = {
x: event.clientX,
y: event.clientY
};
const lastPos = {
x: this._hoverIntentData.x,
y: this._hoverIntentData.y
};
const targetX = isRTL$1() ? submenuRect.right : submenuRect.left;
const topCorner = {
x: targetX,
y: submenuRect.top
};
const bottomCorner = {
x: targetX,
y: submenuRect.bottom
};
return this._pointInTriangle(currentPos, lastPos, topCorner, bottomCorner);
}
_pointInTriangle(point, v1, v2, v3) {
const d1 = triangleSign(point, v1, v2);
const d2 = triangleSign(point, v2, v3);
const d3 = triangleSign(point, v3, v1);
return !((d1 < 0 || d2 < 0 || d3 < 0) && (d1 > 0 || d2 > 0 || d3 > 0));
}
_getItemsInMenu(menu) {
const backSelector = this._usesStackedSubmenus() ? `, :scope > .${CLASS_NAME_MENU_BACK} > ${SELECTOR_VISIBLE_ITEMS$1}` : "";
return SelectorEngine.find(`:scope > ${SELECTOR_VISIBLE_ITEMS$1}, :scope > ${SELECTOR_SUBMENU} > ${SELECTOR_VISIBLE_ITEMS$1}${backSelector}`, menu).filter((element) => isVisible(element));
}
_selectMenuItem({ key, target }) {
const currentMenu = target.closest(SELECTOR_MENU$3) || this._menu;
const items = this._getItemsInMenu(currentMenu);
if (!items.length) return;
const nextItem = getNextActiveElement(items, target, key === ARROW_DOWN_KEY$2, !items.includes(target));
nextItem.focus();
this._closeUnrelatedSubmenus(currentMenu, nextItem);
}
_handlePortaledTab(event) {
if (!this._isShown() || this._menu.parentNode === this._menuOriginalParent || event.defaultPrevented) return;
const stops = SelectorEngine.find(SELECTOR_TAB_STOPS, this._menu).filter((element) => (element.tabIndex >= 0 || element.isContentEditable && !element.hasAttribute("tabindex")) && !element.closest("[inert]") && isVisible(element));
const first = stops[0];
if (event.target === this._element && !event.shiftKey && first) {
event.preventDefault();
first.focus();
return;
}
if (event.shiftKey && event.target === first) {
event.preventDefault();
this._element.focus();
} else if (!event.shiftKey && event.target === stops.at(-1)) this._element.focus();
}
_closeUnrelatedSubmenus(currentMenu, focusedElement) {
for (const [submenu] of this._openSubmenus) {
const submenuWrapper = submenu.closest(SELECTOR_SUBMENU);
if (!submenuWrapper || submenuWrapper.parentElement !== currentMenu || submenuWrapper.contains(focusedElement)) continue;
this._closeSubmenu(submenu, submenuWrapper);
}
}
_handleSubmenuKeydown(event) {
const { key, target } = event;
const isRtl = isRTL$1();
const enterKey = isRtl ? ARROW_LEFT_KEY$1 : ARROW_RIGHT_KEY$1;
const exitKey = isRtl ? ARROW_RIGHT_KEY$1 : ARROW_LEFT_KEY$1;
const submenuWrapper = target.closest(SELECTOR_SUBMENU);
const isSubmenuToggle = target.matches(SELECTOR_SUBMENU_TOGGLE);
if ((key === ENTER_KEY$1 || key === SPACE_KEY$1 || key === enterKey) && submenuWrapper && isSubmenuToggle) {
event.preventDefault();
event.stopPropagation();
const submenu = SelectorEngine.findOne(SELECTOR_MENU$3, submenuWrapper);
if (submenu) {
this._closeSiblingSubmenus(submenuWrapper);
this._openSubmenu(target, submenu, submenuWrapper);
requestAnimationFrame(() => {
if (this._openSubmenus?.has(submenu)) (this._usesStackedSubmenus() ? this._getItemsInMenu(submenu)[0] : SelectorEngine.findOne(`${SELECTOR_VISIBLE_ITEMS$1}:not(.${CLASS_NAME_MENU_BACK} > *)`, submenu))?.focus();
});
}
return true;
}
if (key === exitKey) {
const currentMenu = target.closest(SELECTOR_MENU$3);
const parentSubmenuWrapper = currentMenu?.closest(SELECTOR_SUBMENU);
if (parentSubmenuWrapper) {
event.preventDefault();
event.stopPropagation();
const parentTrigger = SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, parentSubmenuWrapper);
this._closeSubmenu(currentMenu, parentSubmenuWrapper);
if (parentTrigger) parentTrigger.focus();
return true;
}
}
if (key === HOME_KEY$2 || key === END_KEY$2) {
const currentMenu = target.closest(SELECTOR_MENU$3);
if (!currentMenu) return false;
event.preventDefault();
event.stopPropagation();
const items = this._getItemsInMenu(currentMenu);
if (items.length) {
const targetItem = key === HOME_KEY$2 ? items[0] : items.at(-1);
targetItem.focus();
this._closeUnrelatedSubmenus(currentMenu, targetItem);
}
return true;
}
return false;
}
_handleEscape(event) {
if (!this._isShown()) return;
event.preventDefault();
event.stopPropagation();
const currentMenu = event.target.closest(SELECTOR_MENU$3);
const parentSubmenuWrapper = currentMenu?.closest(SELECTOR_SUBMENU);
if (currentMenu && parentSubmenuWrapper && this._openSubmenus.has(currentMenu)) {
this._closeSubmenu(currentMenu, parentSubmenuWrapper);
SelectorEngine.findOne(SELECTOR_SUBMENU_TOGGLE, parentSubmenuWrapper)?.focus();
return;
}
this.hide();
this._element.focus();
}
static clearMenus(event) {
if (event.button === RIGHT_MOUSE_BUTTON || event.type === "keyup" && event.key !== TAB_KEY$1) return;
for (const instance of Menu._openInstances) {
if (instance._config.autoClose === false) continue;
const composedPath = event.composedPath();
const isMenuTarget = composedPath.includes(instance._menu);
if (composedPath.includes(instance._element) || instance._config.autoClose === "inside" && !isMenuTarget || instance._config.autoClose === "outside" && isMenuTarget) continue;
const formAncestor = event.target.closest?.("form");
const isInsideMenuForm = Boolean(formAncestor) && instance._menu.contains(formAncestor);
if (instance._menu.contains(event.target) && (event.type === "keyup" && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName) || isInsideMenuForm)) continue;
const relatedTarget = { relatedTarget: instance._element };
if (event.type === "click") relatedTarget.clickEvent = event;
instance._completeHide(relatedTarget);
}
}
static _getToggleFromKeydownContext(element, event) {
if (element.matches(SELECTOR_DATA_TOGGLE$8)) return element;
for (const instance of Menu._openInstances) if (instance._element === event.target || instance._menu?.contains(event.target)) return instance._element;
return SelectorEngine.prev(element, SELECTOR_DATA_TOGGLE$8)[0] || SelectorEngine.next(element, SELECTOR_DATA_TOGGLE$8)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$8, event.delegateTarget.parentNode);
}
static dataApiKeydownHandler(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key, target } = event;
if (key !== ESCAPE_KEY$2 && key !== TAB_KEY$1) {
const activatesSubmenu = (key === ENTER_KEY$1 || key === SPACE_KEY$1) && target.matches(SELECTOR_SUBMENU_TOGGLE);
const isMenuItemOrToggle = target.matches(`${SELECTOR_DATA_TOGGLE$8}, .menu-item`);
if (!(ITEM_NAVIGATION_KEYS.has(key) || activatesSubmenu) || !isMenuItemOrToggle || target.isContentEditable || target.matches("input, select, textarea")) return;
}
const getToggleButton = Menu._getToggleFromKeydownContext(this, event);
if (!getToggleButton) return;
if (key === TAB_KEY$1) {
Menu.getInstance(getToggleButton)?._handlePortaledTab(event);
return;
}
const instance = Menu.getOrCreateInstance(getToggleButton);
if (key === ESCAPE_KEY$2) instance._handleEscape(event);
else if (key === ARROW_UP_KEY$2 || key === ARROW_DOWN_KEY$2) {
event.preventDefault();
event.stopPropagation();
instance.show();
instance._selectMenuItem(event);
} else instance._handleSubmenuKeydown(event);
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$8, Menu.dataApiKeydownHandler);
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU$3, Menu.dataApiKeydownHandler);
EventHandler.on(document, EVENT_CLICK_DATA_API$5, Menu.clearMenus);
EventHandler.on(document, EVENT_KEYUP_DATA_API, Menu.clearMenus);
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$8, function(event) {
event.preventDefault();
Menu.getOrCreateInstance(this).toggle();
});
//#endregion
//#region js/src/combobox.ts
/**
* Constants
*/
const NAME$15 = "combobox";
const EVENT_KEY$12 = `.bs.combobox`;
const DATA_API_KEY$7 = ".data-api";
const ESCAPE_KEY$1 = "Escape";
const TAB_KEY = "Tab";
const ARROW_UP_KEY$1 = "ArrowUp";
const ARROW_DOWN_KEY$1 = "ArrowDown";
const HOME_KEY$1 = "Home";
const END_KEY$1 = "End";
const ENTER_KEY = "Enter";
const SPACE_KEY = " ";
const EVENT_CHANGE$2 = `change${EVENT_KEY$12}`;
const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$12}${DATA_API_KEY$7}`;
const CLASS_NAME_SHOW$4 = "show";
const CLASS_NAME_SELECTED = "selected";
const CLASS_NAME_PLACEHOLDER = "combobox-placeholder";
const DISMISS_ICON = " ";
const SELECTOR_DATA_TOGGLE$7 = "[data-bs-toggle=\"combobox\"]";
const SELECTOR_MENU$2 = ".menu";
const SELECTOR_MENU_ITEM = ".menu-item[data-bs-value]";
const SELECTOR_VISIBLE_ITEMS = ".menu-item[data-bs-value]:not(.disabled):not(:disabled)";
const SELECTOR_VALUE = ".combobox-value";
const SELECTOR_SEARCH_INPUT = ".combobox-search-input";
const SELECTOR_NO_RESULTS = ".combobox-no-results";
var ComboboxMenu = class extends Menu {
show(focus) {
return this._show(focus);
}
};
const Default$14 = {
allowCustom: false,
createOnBlur: false,
maxItems: null,
separator: null,
boundary: "clippingParents",
input: null,
multiple: false,
name: null,
offset: [0, 2],
placeholder: "",
placement: "bottom-start",
search: false,
searchNormalize: false
};
const DefaultType$14 = {
allowCustom: "boolean",
createOnBlur: "boolean",
maxItems: "(number|null)",
separator: "(string|null)",
boundary: "(string|element)",
input: "(null|element)",
multiple: "boolean",
name: "(string|null)",
offset: "(array|string|function)",
placeholder: "string",
placement: "string",
search: "boolean",
searchNormalize: "boolean"
};
/**
* Class definition
*/
var Combobox = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._editor = this._element.matches("input") ? this._element : SelectorEngine.findOne(".combobox-input, .form-ghost", this._element);
if (this._editor === this._element && this._config.multiple) throw new TypeError("COMBOBOX: Multiple selection requires a wrapping element.");
this._toggle = this._editor ?? this._element;
const field = this._editor && !this._element.matches("input") ? this._element : this._toggle;
this._menu = SelectorEngine.next(field, SELECTOR_MENU$2)[0];
this._ownsMenu = !this._menu && Boolean(this._editor);
if (this._ownsMenu) {
this._menu = document.createElement("div");
this._menu.className = "menu";
field.after(this._menu);
}
this._menuMinWidth = this._menu.style.minWidth;
this._valueDisplay = SelectorEngine.findOne(SELECTOR_VALUE, this._toggle);
this._searchInput = this._editor ?? SelectorEngine.findOne(SELECTOR_SEARCH_INPUT, this._menu);
this._noResults = SelectorEngine.findOne(SELECTOR_NO_RESULTS, this._menu);
this._activeItem = null;
this._chips = /* @__PURE__ */ new Map();
this._selectedChips = /* @__PURE__ */ new Set();
this._anchorChip = null;
this._focusingChip = false;
this._composing = false;
this._query = null;
this._status = null;
this._attributes = /* @__PURE__ */ new Map();
if (this._editor) this._setupEditor();
this._hiddenInput = null;
this._menuInstance = null;
this._ownsInput = false;
this._inputDisabled = false;
this._extraInputs = [];
this._initialSelection = this._getSelectedItems();
this._form = null;
this._menuEventHandlers = /* @__PURE__ */ new Map();
this._changeId = 0;
this._formObserver = new MutationObserver((records) => {
this._readInputDisabled(records);
this.update();
});
this._submitHandler = () => this.update();
this._resetTimeouts = /* @__PURE__ */ new Set();
this._resetHandler = (event) => {
const timeout = window.setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!this._element || event.defaultPrevented || event.target !== this._form) return;
const selected = new Set(this._initialSelection);
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
item.classList.toggle(CLASS_NAME_SELECTED, selected.has(item));
setAriaAttribute(item, "aria-selected", selected.has(item));
}
this._query = null;
this._selectedChips.clear();
this._anchorChip = null;
this.update();
});
this._resetTimeouts.add(timeout);
};
this._createHiddenInput();
this._createMenuInstance();
this.update();
this._addEventListeners();
}
static get Default() {
return Default$14;
}
static get DefaultType() {
return DefaultType$14;
}
static get NAME() {
return NAME$15;
}
toggle() {
return this._isShown() ? this.hide() : this.show();
}
show() {
return this._showMenu();
}
async hide() {
await this._menuInstance.hide();
}
update() {
this._changeId++;
this._readInputDisabled(this._formObserver.takeRecords());
this._syncOptionRoles();
this._updateToggleText();
this._updateHiddenInput();
this._observeFormState();
if (this._editor && this._activeItem && !this._getVisibleItems().includes(this._activeItem)) this._setActiveItem(null);
}
dispose() {
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._readInputDisabled(this._formObserver.takeRecords());
this._formObserver.disconnect();
EventHandler.off(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.off(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
for (const [event, handler] of this._menuEventHandlers) EventHandler.off(this._toggle, event, handler);
this._removeExtraInputs();
if (this._hiddenInput && !this._ownsInput) this._hiddenInput.disabled = this._inputDisabled;
if (this._menuInstance) {
this._menuInstance.dispose();
this._menuInstance = null;
}
if (this._hiddenInput && this._ownsInput) {
this._hiddenInput.remove();
this._hiddenInput = null;
}
for (const chip of this._chips.values()) chip.remove();
if (this._editor) {
this._editor.classList.remove(CLASS_NAME_SHOW$4);
this._element.classList.remove(CLASS_NAME_SHOW$4);
this._menu.classList.remove(CLASS_NAME_SHOW$4);
this._activeItem?.classList.remove("active");
}
this._status?.remove();
this._menu.style.minWidth = this._menuMinWidth;
for (const [element, attributes] of this._attributes) for (const [name, value] of attributes) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
if (this._ownsMenu) this._menu.remove();
EventHandler.off(this._menu, EVENT_KEY$12);
EventHandler.off(this._toggle, EVENT_KEY$12);
EventHandler.off(this._searchInput, EVENT_KEY$12);
super.dispose();
}
getValues() {
return this._getSelectedItems().map((item) => item.dataset.bsValue ?? "");
}
add(value) {
if (this._isDisabled() || this._config.multiple && this._config.maxItems !== null && this.getValues().length >= this._config.maxItems) return null;
let item = SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu).find((option) => option.dataset.bsValue === value);
if (!item && this._config.allowCustom && value.trim()) {
item = document.createElement("button");
item.setAttribute("type", "button");
item.className = "menu-item";
item.dataset.bsValue = value;
item.textContent = value;
this._menu.append(item);
}
if (!item || item.classList.contains(CLASS_NAME_SELECTED) || isDisabled(item)) return null;
this._selectItem(item);
return this._element && item.classList.contains(CLASS_NAME_SELECTED) ? this._chips.get(item) ?? item : null;
}
remove(value) {
const item = this._getSelectedItems().find((option) => typeof value === "string" ? option.dataset.bsValue === value : option === value || this._chips.get(option) === value);
if (!item || isDisabled(item) || this._isDisabled()) return false;
return this._removeItems([item]);
}
clear() {
this._clearSelection(null);
}
_clearSelection(query) {
this._removeItems(this._getSelectedItems(), query);
}
focus() {
this._toggle?.focus();
}
getSelectedValues() {
return this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item))).map((item) => item.dataset.bsValue ?? "");
}
selectChip(chip, options = {}) {
const chips = this._getChipElements();
if (this._isDisabled() || !chips.includes(chip)) return;
const previous = new Set(this._selectedChips);
const { addToSelection = false, rangeSelect = false } = options;
if (rangeSelect && this._anchorChip && chips.includes(this._anchorChip)) {
const anchor = chips.indexOf(this._anchorChip);
const target = chips.indexOf(chip);
if (!addToSelection) this._selectedChips.clear();
for (let index = Math.min(anchor, target); index <= Math.max(anchor, target); index++) this._selectedChips.add(chips[index]);
} else if (addToSelection) if (this._selectedChips.has(chip)) this._selectedChips.delete(chip);
else {
this._selectedChips.add(chip);
this._anchorChip = chip;
}
else {
this._selectedChips = /* @__PURE__ */ new Set([chip]);
this._anchorChip = chip;
}
if (previous.size !== this._selectedChips.size || [...previous].some((element) => !this._selectedChips.has(element))) this._notifyChipSelection();
}
clearSelection() {
this._anchorChip = null;
if (!this._selectedChips.size) return;
this._selectedChips.clear();
this._notifyChipSelection();
}
removeSelected() {
const chips = this._getChipElements();
const active = document.activeElement?.closest(".chip");
const index = Math.max(0, chips.indexOf(active));
const items = this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item)));
const changed = this._removeItems(items);
if (changed && this._element) {
const remaining = this._getChipElements();
const target = remaining[Math.min(index, remaining.length - 1)];
if (target) this._focusChip(target);
else this._editor.focus();
}
return changed;
}
_getChipElements() {
return this._getSelectedItems().filter((item) => !isDisabled(item)).map((item) => this._chips.get(item)).filter((chip) => Boolean(chip));
}
_syncChipSelection() {
for (const chip of this._chips.values()) {
const selected = this._selectedChips.has(chip);
chip.classList.toggle("active", selected);
if (selected) chip.setAttribute("aria-description", "Selected for removal");
else chip.removeAttribute("aria-description");
}
}
_notifyChipSelection() {
this._syncChipSelection();
const items = this._getSelectedItems().filter((item) => this._selectedChips.has(this._chips.get(item)));
const selected = items.map((item) => item.dataset.bsValue ?? "");
if (this._status) this._status.textContent = selected.length ? `${selected.length} chip${selected.length === 1 ? "" : "s"} selected for removal` : "Chip selection cleared";
EventHandler.trigger(this._element, `select${EVENT_KEY$12}`, {
selected,
items
});
}
_focusChip(chip, options = {}) {
this.selectChip(chip, options);
if (!this._element) return;
this.hide();
if (this._element) this._focusSelectedChip(chip);
}
_focusSelectedChip(chip) {
this._focusingChip = true;
try {
chip.focus();
} finally {
if (this._element) this._focusingChip = false;
}
}
_selectAllChips() {
const chips = this._getChipElements();
if (!chips.length) return;
this._selectedChips = new Set(chips);
this._anchorChip ??= chips[0];
this._notifyChipSelection();
}
_removeItems(items, query = null) {
if (this._isDisabled() || !items.length) return false;
const allowed = [];
const changeId = this._changeId;
for (const item of items) {
if (isDisabled(item)) continue;
const event = EventHandler.trigger(this._element, `remove${EVENT_KEY$12}`, {
value: item.dataset.bsValue,
item
});
if (!this._element || changeId !== this._changeId) return false;
if (!event.defaultPrevented) allowed.push(item);
}
for (const item of allowed) {
item.classList.remove(CLASS_NAME_SELECTED);
setAriaAttribute(item, "aria-selected", false);
}
if (allowed.length) this._selectionChanged(allowed.length === 1 ? allowed[0] : null, query);
return allowed.length > 0;
}
_isDisabled() {
return isDisabled(this._element) || isDisabled(this._toggle) || this._toggle.matches(":disabled");
}
_setAttribute(element, name, value) {
if (!this._attributes.has(element)) this._attributes.set(element, /* @__PURE__ */ new Map());
const attributes = this._attributes.get(element);
if (!attributes.has(name)) attributes.set(name, element.getAttribute(name));
element.setAttribute(name, value);
}
_syncOptionRoles() {
if (!this._menu.id) this._setAttribute(this._menu, "id", getUID("combobox-"));
this._setAttribute(this._toggle, "aria-controls", this._menu.id);
this._setAttribute(this._toggle, "aria-haspopup", "listbox");
this._setAttribute(this._menu, "role", "listbox");
if (this._config.multiple) this._setAttribute(this._menu, "aria-multiselectable", "true");
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
this._setAttribute(item, "role", "option");
this._setAttribute(item, "aria-selected", String(item.classList.contains(CLASS_NAME_SELECTED)));
}
}
_setupEditor() {
const editor = this._editor;
if (this._config.placeholder && !editor.placeholder) this._setAttribute(editor, "placeholder", this._config.placeholder);
if (!this._menu.id) this._setAttribute(this._menu, "id", getUID("combobox-"));
this._setAttribute(editor, "role", "combobox");
this._setAttribute(editor, "aria-autocomplete", "list");
this._setAttribute(editor, "aria-expanded", "false");
this._setAttribute(editor, "aria-controls", this._menu.id);
this._setAttribute(editor, "autocomplete", "off");
this._setAttribute(editor, "aria-activedescendant", "");
editor.removeAttribute("aria-activedescendant");
this._setAttribute(this._menu, "role", "listbox");
if (this._config.multiple) this._setAttribute(this._menu, "aria-multiselectable", "true");
this._status = document.createElement("span");
this._status.className = "visually-hidden";
this._status.setAttribute("role", "status");
this._menu.after(this._status);
}
_getItemLabel(item) {
return SelectorEngine.findOne(".menu-item-content > span:first-child", item)?.textContent ?? item.textContent.trim();
}
_renderEditor() {
const editor = this._editor;
const selected = this._getSelectedItems();
const selectedSet = new Set(selected);
for (const [item, chip] of this._chips) if (!selectedSet.has(item)) {
chip.remove();
this._chips.delete(item);
this._selectedChips.delete(chip);
if (this._anchorChip === chip) this._anchorChip = null;
}
for (const item of SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu)) {
if (!item.id) this._setAttribute(item, "id", getUID("combobox-option-"));
this._setAttribute(item, "tabindex", "-1");
}
if (!this._config.multiple) {
const value = this._query ?? (selected.length ? this._getItemLabel(selected[0]) : "");
if (editor.value !== value) editor.value = value;
return;
}
let next = this._hiddenInput?.parentElement === editor.parentElement && this._hiddenInput.compareDocumentPosition(editor) === Node.DOCUMENT_POSITION_FOLLOWING ? this._hiddenInput : editor;
for (let index = selected.length - 1; index >= 0; index--) {
const item = selected[index];
let chip = this._chips.get(item);
const label = this._getItemLabel(item);
if (!chip) {
chip = document.createElement("span");
chip.className = "chip";
chip.tabIndex = -1;
const text = document.createElement("span");
const button = document.createElement("button");
button.type = "button";
button.className = "chip-dismiss";
button.innerHTML = DISMISS_ICON;
chip.append(text, button);
this._chips.set(item, chip);
}
this._updateChipState(item, chip, label);
if (chip.nextElementSibling !== next) next.before(chip);
next = chip;
}
this._syncChipSelection();
const value = this._query ?? "";
if (editor.value !== value) editor.value = value;
this._menuInstance?.update();
}
_updateChipState(item, chip, label) {
chip.firstElementChild.textContent = label;
const button = chip.lastElementChild;
button.setAttribute("aria-label", `Remove ${label}`);
button.disabled = this._isDisabled() || isDisabled(item);
chip.setAttribute("role", "group");
chip.setAttribute("aria-label", label);
chip.classList.toggle("disabled", button.disabled);
if (button.disabled) {
chip.setAttribute("aria-disabled", "true");
this._selectedChips.delete(chip);
if (this._anchorChip === chip) this._anchorChip = null;
} else chip.removeAttribute("aria-disabled");
}
_setActiveItem(item) {
this._activeItem?.classList.remove("active");
this._activeItem = item;
if (!item) {
this._editor.removeAttribute("aria-activedescendant");
return;
}
item.classList.add("active");
this._editor.setAttribute("aria-activedescendant", item.id);
item.scrollIntoView({ block: "nearest" });
}
_addEditorListeners() {
const editor = this._editor;
EventHandler.on(this._menu, `mousedown${EVENT_KEY$12}`, SELECTOR_MENU_ITEM, (event) => event.preventDefault());
EventHandler.on(editor, `input${EVENT_KEY$12}`, (event) => {
if (this._composing || event.isComposing) {
this._query = editor.value;
return;
}
if (this._isDisabled()) return;
this._handleEditorInput();
});
EventHandler.on(editor, `compositionstart${EVENT_KEY$12}`, () => {
this._composing = true;
});
EventHandler.on(editor, `compositionend${EVENT_KEY$12}`, () => {
this._composing = false;
if (this._element && !this._isDisabled()) this._handleEditorInput(document.activeElement === editor);
});
EventHandler.on(editor, `paste${EVENT_KEY$12}`, (event) => {
const { separator, allowCustom } = this._config;
const text = event.clipboardData?.getData("text") ?? "";
if (!allowCustom || !separator || !text.includes(separator) || this._isDisabled()) return;
event.preventDefault();
for (const value of text.split(separator)) {
this.add(value.trim());
if (!this._element) return;
}
});
EventHandler.on(editor, `blur${EVENT_KEY$12}`, (event) => {
if (!this._composing && this._config.allowCustom && this._config.createOnBlur && !event.relatedTarget?.closest(".chip, .menu")) this.add(editor.value.trim());
});
EventHandler.on(editor, `focus${EVENT_KEY$12}`, () => this.clearSelection());
EventHandler.on(this._element, `mousedown${EVENT_KEY$12}`, ".chip", (event) => {
if (!event.target.closest(".chip-dismiss")) event.preventDefault();
});
EventHandler.on(this._element, `focusin${EVENT_KEY$12}`, ".chip", (event) => {
if (this._focusingChip || this._isDisabled()) return;
const chip = event.target.closest(".chip");
if (!this._selectedChips.has(chip)) this.selectChip(chip);
if (this._element) this.hide();
});
EventHandler.on(this._element, `click${EVENT_KEY$12}`, ".chip", (event) => {
if (event.target.closest(".chip-dismiss") || this._isDisabled()) return;
event.preventDefault();
event.stopPropagation();
const chip = event.target.closest(".chip");
this._focusChip(chip, {
addToSelection: event.metaKey || event.ctrlKey,
rangeSelect: event.shiftKey
});
});
EventHandler.on(this._element, `keydown${EVENT_KEY$12}`, ".chip", (event) => this._handleChipKeydown(event));
EventHandler.on(this._element, `click${EVENT_KEY$12}`, ".chip-dismiss", (event) => {
event.preventDefault();
event.stopPropagation();
const chip = event.target.closest(".chip");
this.remove(chip);
if (this._element) editor.focus();
});
}
_handleEditorInput(openMenu = true) {
const editor = this._editor;
let query = editor.value;
if (this._config.allowCustom && this._config.separator && query.includes(this._config.separator)) {
const parts = query.split(this._config.separator);
query = parts.pop();
for (const part of parts) {
this.add(part.trim());
if (!this._element) return;
}
}
if (!this._config.multiple && this._getSelectedItems().length) {
this._clearSelection(query);
if (!this._element) return;
if (this._getSelectedItems().length) {
this._query = null;
this._renderEditor();
return;
}
}
this._query = query;
if (editor.value !== query) editor.value = query;
this._filterItems(query);
this._setActiveItem(null);
if (openMenu && this._getVisibleItems().length) this.show();
else this.hide();
}
_handleEditorKeydown(event) {
if (this._composing || event.isComposing || event.keyCode === 229 || this._isDisabled()) return;
const editor = this._editor;
if ([ARROW_DOWN_KEY$1, ARROW_UP_KEY$1].includes(event.key)) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length) {
const item = getNextActiveElement(items, this._activeItem, event.key === ARROW_DOWN_KEY$1, true);
this.show();
if (this._element) this._setActiveItem(item);
}
return;
}
if (event.key === ENTER_KEY) {
if (this._activeItem && this._isShown()) {
event.preventDefault();
this._selectItem(this._activeItem);
} else if (this._config.allowCustom && editor.value.trim()) {
event.preventDefault();
this.add(editor.value.trim());
}
return;
}
if (event.key === ESCAPE_KEY$1 || event.key === TAB_KEY) {
if (event.key === ESCAPE_KEY$1 && this._isShown()) event.preventDefault();
this.hide();
if (this._element) this._setActiveItem(null);
return;
}
this._handleEditorChipFocus(event);
}
_handleEditorChipFocus(event) {
const editor = this._editor;
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a" && !editor.value) {
const chips = this._getChipElements();
if (chips.length) {
event.preventDefault();
this._selectAllChips();
if (this._element) {
this.hide();
if (this._element) this._focusSelectedChip(chips.at(-1));
}
}
return;
}
if (event.metaKey || event.ctrlKey || event.altKey) return;
const previousKey = getComputedStyle(editor).direction === "rtl" ? "ArrowRight" : "ArrowLeft";
const backwardDelete = ["Backspace", "Delete"].includes(event.key) && !editor.value;
const atStart = event.key === previousKey && editor.selectionStart === 0 && editor.selectionEnd === 0;
if (backwardDelete || atStart) {
const chip = this._getChipElements().at(-1);
if (chip) {
event.preventDefault();
this._focusChip(chip, { addToSelection: event.shiftKey });
}
}
}
_handleChipKeydown(event) {
if (this._composing || event.isComposing || event.keyCode === 229 || this._isDisabled()) return;
const chip = event.target.closest(".chip");
const chips = this._getChipElements();
const index = chips.indexOf(chip);
if (index === -1) return;
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
event.preventDefault();
this._selectAllChips();
return;
}
if (["Backspace", "Delete"].includes(event.key)) {
event.preventDefault();
this._deleteChipSelection(chip);
return;
}
const rtl = getComputedStyle(this._editor).direction === "rtl";
if (["ArrowLeft", "ArrowRight"].includes(event.key)) {
event.preventDefault();
const next = index + (event.key === "ArrowRight" === rtl ? -1 : 1);
if (next >= chips.length) {
this.clearSelection();
if (this._element) this._editor.focus();
} else this._focusChip(chips[Math.max(0, next)], { rangeSelect: event.shiftKey });
} else if (event.key === HOME_KEY$1 || event.key === END_KEY$1 && event.shiftKey) {
event.preventDefault();
const target = event.key === HOME_KEY$1 ? chips[0] : chips.at(-1);
this._focusChip(target, { rangeSelect: event.shiftKey });
} else if ([END_KEY$1, ESCAPE_KEY$1].includes(event.key)) {
event.preventDefault();
this.clearSelection();
if (this._element) this._editor.focus();
}
}
_deleteChipSelection(chip) {
if (!this._selectedChips.has(chip)) this.selectChip(chip);
if (this._element) this.removeSelected();
}
_isShown() {
return this._menu.classList.contains(CLASS_NAME_SHOW$4);
}
_configAfterMerge(config) {
if (config.maxItems !== null && (!Number.isSafeInteger(config.maxItems) || config.maxItems < 1)) throw new TypeError("COMBOBOX: Option \"maxItems\" must be a positive integer or null.");
if (config.input !== null) {
const input = getElement(config.input);
if (!(input instanceof HTMLInputElement) || input.type !== "hidden") throw new TypeError("COMBOBOX: Option \"input\" must reference a hidden input.");
config.input = input;
}
return config;
}
_createHiddenInput() {
if (this._config.input) {
this._hiddenInput = this._config.input;
this._inputDisabled = this._hiddenInput.disabled;
return;
}
if (!this._config.name) return;
this._hiddenInput = document.createElement("input");
this._hiddenInput.type = "hidden";
this._hiddenInput.name = this._config.name;
(this._editor ? this._element : this._toggle).before(this._hiddenInput);
this._ownsInput = true;
}
_removeExtraInputs() {
for (const input of this._extraInputs) input.remove();
this._extraInputs = [];
}
_readInputDisabled(records) {
if (!this._ownsInput && records.some((record) => record.target === this._hiddenInput && record.attributeName === "disabled")) this._inputDisabled = this._hiddenInput.disabled;
}
_observeFormState() {
this._formObserver.disconnect();
if (this._element !== this._toggle) this._formObserver.observe(this._element, {
attributes: true,
attributeFilter: ["class"]
});
this._formObserver.observe(this._toggle, {
attributes: true,
attributeFilter: [
"disabled",
"class",
"form"
]
});
if (this._hiddenInput) this._formObserver.observe(this._hiddenInput, {
attributes: true,
attributeFilter: [
"disabled",
"name",
"form"
]
});
const fieldsets = /* @__PURE__ */ new Set();
for (const element of [this._toggle, this._hiddenInput]) for (let parent = element?.parentElement; parent; parent = parent.parentElement) if (parent.matches("fieldset")) fieldsets.add(parent);
for (const fieldset of fieldsets) this._formObserver.observe(fieldset, {
attributes: true,
attributeFilter: ["disabled"]
});
const form = this._hiddenInput ? this._hiddenInput.form : this._toggle instanceof HTMLInputElement || this._toggle instanceof HTMLButtonElement ? this._toggle.form : this._toggle.closest("form");
if (form !== this._form) {
EventHandler.off(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.off(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
this._form = form;
EventHandler.on(this._form, `reset${EVENT_KEY$12}`, this._resetHandler);
EventHandler.on(this._form, `submit${EVENT_KEY$12}`, this._submitHandler);
}
}
async _showMenu(focus) {
if (this._isDisabled() || this._isShown() || this._editor && !this._getVisibleItems().length) return;
const search = this._editor || isDisabled(this._searchInput) ? null : this._searchInput;
await this._menuInstance.show(focus ?? (search ? () => search.focus({ preventScroll: true }) : void 0));
}
_createMenuInstance() {
this._menuInstance = new ComboboxMenu(this._toggle, {
menu: this._menu,
reference: this._editor ? this._element : "toggle",
autoClose: this._config.multiple ? "outside" : true,
boundary: this._config.boundary,
offset: this._config.offset,
placement: this._config.placement,
floatingConfig: this._editor ? (config) => ({
...config,
middleware: [...config.middleware, {
name: "comboboxSize",
fn: ({ elements, rects }) => {
if (this._element) elements.floating.style.minWidth = `${rects.reference.width}px`;
return {};
}
}]
}) : null
});
}
_addEventListeners() {
for (const type of [
"show",
"shown",
"hide",
"hidden"
]) {
const event = Menu.eventName(type);
const handler = (menuEvent) => {
if (!this._element) return;
if (type === "hidden" && this._editor) this._setActiveItem(null);
if (EventHandler.trigger(this._element, this.constructor.eventName(type))?.defaultPrevented || !this._element) {
menuEvent.preventDefault();
return;
}
if (type === "show" && !menuEvent.defaultPrevented && this._searchInput && !this._editor) {
this._searchInput.value = "";
this._filterItems("");
}
};
this._menuEventHandlers.set(event, handler);
EventHandler.on(this._toggle, event, handler);
}
EventHandler.on(this._menu, `click${EVENT_KEY$12}`, SELECTOR_MENU_ITEM, (event) => {
const item = event.target.closest(SELECTOR_MENU_ITEM);
if (!item || isDisabled(item)) return;
event.preventDefault();
event.stopPropagation();
this._selectItem(item);
});
EventHandler.on(this._toggle, `keydown${EVENT_KEY$12}`, (event) => {
if (this._editor) this._handleEditorKeydown(event);
else this._handleToggleKeydown(event);
});
EventHandler.on(this._menu, `keydown${EVENT_KEY$12}`, (event) => {
this._handleMenuKeydown(event);
});
if (this._editor) {
this._addEditorListeners();
return;
}
if (this._searchInput) {
EventHandler.on(this._toggle, `mousedown${EVENT_KEY$12}`, (event) => {
if (event.button === 0 && !this._isShown() && !this._isDisabled() && !isDisabled(this._searchInput)) event.preventDefault();
});
EventHandler.on(this._searchInput, `input${EVENT_KEY$12}`, () => {
this._filterItems(this._searchInput.value);
});
EventHandler.on(this._searchInput, `keydown${EVENT_KEY$12}`, (event) => {
if (event.isComposing || event.keyCode === 229) return;
if (event.key === ARROW_DOWN_KEY$1) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) items[0].focus();
}
if (event.key === ESCAPE_KEY$1) {
this.hide();
this._toggle?.focus();
}
});
}
}
_selectItem(item) {
if (this._isDisabled() || isDisabled(item) || !this._menu.contains(item)) return;
const previous = this._getSelectedItems();
if (this._config.multiple && !previous.includes(item) && this._config.maxItems !== null && previous.length >= this._config.maxItems) return;
if (!this._config.multiple && previous.length === 1 && previous[0] === item) return;
const changeId = this._changeId;
const type = this._config.multiple && previous.includes(item) ? "remove" : "add";
const event = EventHandler.trigger(this._element, `${type}${EVENT_KEY$12}`, {
value: item.dataset.bsValue,
item
});
if (!this._element || event.defaultPrevented || changeId !== this._changeId || this._isDisabled() || isDisabled(item) || !this._menu.contains(item)) return;
if (this._config.multiple) {
item.classList.toggle(CLASS_NAME_SELECTED);
setAriaAttribute(item, "aria-selected", item.classList.contains(CLASS_NAME_SELECTED));
} else {
for (const selected of previous) {
selected.classList.remove(CLASS_NAME_SELECTED);
selected.setAttribute("aria-selected", "false");
}
item.classList.add(CLASS_NAME_SELECTED);
item.setAttribute("aria-selected", "true");
}
this._selectionChanged(item);
}
_selectionChanged(item, query = null) {
this._query = query;
this.update();
const changeId = this._changeId;
const { multiple } = this._config;
const values = this.getValues();
const value = multiple ? values : values[0] ?? "";
const target = this._hiddenInput ?? this._element;
for (const event of ["input", "change"]) {
EventHandler.trigger(target, event);
if (!this._element || changeId !== this._changeId) return;
}
EventHandler.trigger(this._element, EVENT_CHANGE$2, {
value,
item
});
if (!this._element || changeId !== this._changeId) return;
if (this._editor) {
this._setActiveItem(null);
this._filterItems("");
if (this._status) this._status.textContent = `${values.length} selected`;
}
if (!multiple && query === null) {
this.hide();
this._toggle?.focus();
}
}
_updateToggleText() {
if (this._editor) {
this._renderEditor();
return;
}
const selectedItems = this._getSelectedItems();
if (selectedItems.length === 0) {
this._showPlaceholder();
return;
}
this._valueDisplay.classList.remove(CLASS_NAME_PLACEHOLDER);
if (this._config.multiple && selectedItems.length > 1) this._valueDisplay.textContent = `${selectedItems.length} selected`;
else {
const item = selectedItems[0];
const label = SelectorEngine.findOne(".menu-item-content > span:first-child", item);
this._valueDisplay.textContent = label ? label.textContent : item.textContent.trim();
}
}
_showPlaceholder() {
const { placeholder } = this._config;
this._valueDisplay.textContent = placeholder;
this._valueDisplay.classList.toggle(CLASS_NAME_PLACEHOLDER, Boolean(placeholder));
}
_updateHiddenInput() {
const input = this._hiddenInput;
if (!input) return;
const selected = this._getSelectedItems();
const values = selected.filter((item) => !isDisabled(item)).map((item) => item.dataset.bsValue ?? "");
const submittedValues = this._config.multiple ? values : [values[0] ?? ""];
const disabled = this._inputDisabled || this._isDisabled() || selected.length > 0 && values.length === 0;
if (this._ownsInput) {
const anchor = this._editor ? this._element : this._toggle;
const fields = [input, ...this._extraInputs];
if (fields.at(-1).nextElementSibling !== anchor) for (const field of fields) anchor.before(field);
const form = this._toggle.getAttribute("form");
if (form === null) input.removeAttribute("form");
else input.setAttribute("form", form);
}
input.value = submittedValues[0] ?? "";
input.disabled = disabled || submittedValues.length === 0;
for (let index = 1; index < submittedValues.length; index++) {
let extra = this._extraInputs[index - 1];
if (!extra) {
extra = document.createElement("input");
extra.type = "hidden";
this._extraInputs.push(extra);
}
const previous = this._extraInputs[index - 2] ?? input;
if (!previous.parentNode) extra.remove();
else if (extra.previousElementSibling !== previous) previous.after(extra);
extra.name = input.name;
extra.value = submittedValues[index];
extra.disabled = disabled;
const form = input.getAttribute("form");
if (form === null) extra.removeAttribute("form");
else extra.setAttribute("form", form);
}
for (const extra of this._extraInputs.splice(Math.max(0, submittedValues.length - 1))) extra.remove();
this._formObserver.takeRecords();
}
_getSelectedItems() {
return SelectorEngine.find(`${SELECTOR_MENU_ITEM}.${CLASS_NAME_SELECTED}`, this._menu);
}
_getVisibleItems() {
return SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter((item) => {
if (!this._editor) return isVisible(item);
for (let current = item; current && current !== this._menu; current = current.parentElement) {
const style = getComputedStyle(current);
if (current.hidden || style.display === "none" || style.visibility === "hidden") return false;
}
return true;
});
}
_filterItems(query) {
const normalizedQuery = this._normalizeText(query.toLowerCase().trim());
const items = SelectorEngine.find(SELECTOR_MENU_ITEM, this._menu);
let visibleCount = 0;
for (const item of items) {
const text = this._normalizeText(item.textContent.toLowerCase().trim());
const matches = !normalizedQuery || text.includes(normalizedQuery);
item.style.display = matches ? "" : "none";
if (matches) visibleCount++;
}
if (this._noResults) this._noResults.classList.toggle("d-none", visibleCount > 0);
}
_normalizeText(text) {
if (this._config.searchNormalize) return text.normalize("NFD").replace(/[\u0300-\u036F]/g, "");
return text;
}
_handleToggleKeydown(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key } = event;
if (key === ARROW_DOWN_KEY$1 || key === ARROW_UP_KEY$1) {
event.preventDefault();
const focusItem = () => {
const items = this._getVisibleItems();
((key === ARROW_DOWN_KEY$1 ? items[0] : items.at(-1)) ?? (isDisabled(this._searchInput) ? this._toggle : this._searchInput))?.focus();
};
if (this._isShown()) focusItem();
else this._showMenu(focusItem);
return;
}
if (key === ESCAPE_KEY$1 && this._isShown()) {
event.preventDefault();
event.stopPropagation();
this.hide();
return;
}
if ((key === ENTER_KEY || key === SPACE_KEY) && !this._isShown()) {
event.preventDefault();
this.show();
}
}
_handleMenuKeydown(event) {
if (event.isComposing || event.keyCode === 229) return;
const { key, target } = event;
if (key === ESCAPE_KEY$1) {
event.preventDefault();
event.stopPropagation();
this.hide();
this._toggle?.focus();
return;
}
if (key === TAB_KEY) {
this.hide();
return;
}
const isInput = target.matches("input");
if (key === ARROW_DOWN_KEY$1 || key === ARROW_UP_KEY$1) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus();
return;
}
if ((key === HOME_KEY$1 || key === END_KEY$1) && !isInput) {
event.preventDefault();
const items = this._getVisibleItems();
if (items.length > 0) (key === HOME_KEY$1 ? items[0] : items.at(-1)).focus();
return;
}
if ((key === ENTER_KEY || key === SPACE_KEY) && !isInput) {
event.preventDefault();
const item = target.closest(SELECTOR_MENU_ITEM);
if (item && !isDisabled(item)) this._selectItem(item);
}
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$7, function(event) {
const instance = Combobox.getOrCreateInstance(this);
if (this.matches("input") || this.querySelector(".combobox-input, .form-ghost")) {
if (!event.target.closest(".chip")) {
instance.focus();
instance.show();
}
return;
}
event.preventDefault();
instance.toggle();
});
onDocumentReady("DOMContentLoaded", () => {
for (const toggle of SelectorEngine.find(SELECTOR_DATA_TOGGLE$7)) Combobox.getOrCreateInstance(toggle);
});
//#endregion
//#region node_modules/vanilla-calendar-pro/index.mjs
/*! name: vanilla-calendar-pro v3.4.0 | url: https://github.com/uvarov-frontend/vanilla-calendar-pro */
var e = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`);
var t = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
var n = (n, a) => n.reduce((n, l) => {
if (l instanceof Date || "number" == typeof l) {
let e = l instanceof Date ? l : new Date(l);
n.push(t(e));
} else l.match(/^(\d{4}-\d{2}-\d{2})$/g) ? n.push(l) : l.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g, (l, o, r) => {
var i;
let s = `${o}:${r}`, c = a ? a.start.getTime() : -Infinity, d = null == a || null == (i = a.cursors) ? void 0 : i.get(s), u = void 0 !== d && d <= c ? new Date(d) : e(o), m = e(r).setHours(23, 59, 59, 999);
if (a) {
if (m < c) return l;
m = Math.min(m, new Date(a.end).setHours(23, 59, 59, 999));
}
let p = !1;
for (let e = u.getTime(); e <= m; e = u.setDate(u.getDate() + 1)) (!a || e >= c) && (null != a && a.cursors && !p && (a.cursors.set(s, e), p = !0), n.push(t(u)));
return l;
});
return n;
}, []);
var a = (e, t) => {
if (t && t.values.length === e.length) {
let n = 0;
for (; n < e.length && t.values[n] === e[n];) n++;
if (n === e.length) return t;
}
return {
values: e.slice(),
set: new Set(e)
};
};
var l = /* @__PURE__ */ new WeakMap();
var o = (e) => {
var t;
let o = null != (t = e.selectedHolidays) && t[0] ? e.selectedHolidays : [], r = JSON.stringify(o.map((e) => e instanceof Date ? e.getTime() : e)), i = l.get(e);
l.set(e, {
holidayKey: r,
holidays: (null == i ? void 0 : i.holidayKey) === r ? i.holidays : new Set(n(o)),
selected: a(e.context.selectedDates, null == i ? void 0 : i.selected),
disabled: a(e.context.disableDates, null == i ? void 0 : i.disabled),
enabled: a(e.context.enableDates, null == i ? void 0 : i.enabled),
min: Date.parse(`${e.context.displayDateMin}T00:00:00`),
max: Date.parse(`${e.context.displayDateMax}T00:00:00`),
first: Date.parse(`${e.context.selectedDates[0]}T00:00:00`),
last: Date.parse(`${e.context.selectedDates[e.context.selectedDates.length - 1]}T00:00:00`)
});
};
var r = (e) => l.get(e);
var i = [
"motion",
"time",
"annotations",
"weeks",
"months"
];
var s = /* @__PURE__ */ new WeakMap();
var c = {};
var d = /* @__PURE__ */ Object.freeze([]);
var u = (e) => {
var t;
return null == (t = s.get(e)) ? c : t;
};
var m = (e, t = e) => {
if (t.extensions && t.extensions !== e.extensions && (new Set(t.extensions).size !== e.extensions.length || t.extensions.some((t) => !e.extensions.includes(t)))) throw Error("Calendar extensions are fixed at construction. Create a new Calendar to change them.");
let n = u(e), a = (e, t, a) => {
if (e && !n[t]) throw Error(`The "${a}" option requires ${t}. Import { ${t} } from 'vanilla-calendar-pro' and add it to extensions: [${t}].`);
};
a(t.animation || t.enableSwipe, "motion", t.animation ? "animation" : "enableSwipe"), a(t.selectionTimeMode, "time", "selectionTimeMode"), a(t.popups && Object.keys(t.popups).length || t.onCreateDateRangeTooltip, "annotations", t.onCreateDateRangeTooltip ? "onCreateDateRangeTooltip" : "popups"), a("multiple" === t.type, "months", "type"), a("week" === t.type || t.enableCollapse || t.enableWeekNumbers || t.onClickWeekDay, "weeks", "week" === t.type ? "type" : t.enableCollapse ? "enableCollapse" : t.enableWeekNumbers ? "enableWeekNumbers" : "onClickWeekDay");
};
var p = (e, t, n) => {
var a;
return null == (a = u(e).annotations) ? void 0 : a.tooltip(e, t, n);
};
var h = /* @__PURE__ */ new WeakMap();
var v = (e) => {
let t = h.get(e);
return t || (t = {
lastDateEl: null,
isHovering: !1,
rangeMin: void 0,
rangeMax: void 0,
tooltipEl: null,
timeoutId: null,
frameId: null
}, h.set(e, t)), t;
};
var y = (e) => {
e.context.mainElement.querySelectorAll("[data-vc-date-hover]").forEach((e) => e.removeAttribute("data-vc-date-hover"));
};
var g = (e, t, n) => {
e.context[t] = n;
};
var f = (e, t) => void 0 === t || ("function" == typeof t ? t(e) : t);
var x = (e) => f(e, e.enableDateToggle);
var b = (e) => {
if (e.length < 3 || e.includes(void 0)) return e.sort((e, t) => +new Date(e) - new Date(t));
let t = e.map((e) => ({
date: e,
time: +new Date(e)
}));
return t.sort((e, t) => e.time - t.time), t.forEach((t, n) => e[n] = t.date), e;
};
var D = (e) => {
var t;
let n = h.get(e);
n && (null == (t = n.cleanup) || t.call(n), n.cleanup = void 0, null !== n.timeoutId && clearTimeout(n.timeoutId), null !== n.frameId && cancelAnimationFrame(n.frameId), n.lastDateEl = null, n.tooltipEl = null, n.timeoutId = null, n.frameId = null, h.delete(e));
};
var M = (a, l, o = !0) => {
let r = v(a);
if (r.lastDateEl = l, y(a), !r.cleanup) {
let n = a.context.mainElement, l = ((n) => (a) => {
if (!n.context.selectedDates[0] || 1 !== n.context.selectedDates.length && !n.onCreateDateRangeTooltip) return;
let l = v(n);
if (l.isHovering) return;
let o = a.target;
l.isHovering = !0, l.frameId = requestAnimationFrame(() => {
var a;
l.frameId = null, l.isHovering = !1, !n.context.isDestroyed && n.context.mainElement.contains(o) && (1 === n.context.selectedDates.length ? ((n, a) => {
var l;
let o = v(n);
if (n.context.mainElement.hasAttribute("data-vc-dragging") || !a || null == n || null == (l = n.context) || !l.selectedDates[0]) return;
if (!a.closest("[data-vc=\"dates\"]")) return o.lastDateEl = null, p(n, o.tooltipEl, null), void y(n);
let r = a.closest("[data-vc-date]");
if (!r || o.lastDateEl === r) return;
o.lastDateEl = r, p(n, o.tooltipEl, r), y(n);
let i = r.dataset.vcDate, s = e(n.context.selectedDates[0]), c = e(i), [d, u] = s < c ? [s, c] : [c, s], [m, h] = s < c ? [n.context.selectedDates[0], i] : [i, n.context.selectedDates[0]], g = new Set(n.context.disableDates), f = new Date(d);
for (; f <= u && g.has(t(f));) f.setDate(f.getDate() + 1);
f <= u && n.context.mainElement.querySelectorAll("[data-vc-date]").forEach((t) => {
let n = t.dataset.vcDate;
if (n === m || n === h) t.dataset.vcDateHover = m === h ? "first-and-last" : n === m ? "first" : "last";
else {
let a = e(n);
a >= d && a <= u && !g.has(n) && (t.dataset.vcDateHover = "");
}
});
})(n, o) : n.context.selectedDates[0] && n.onCreateDateRangeTooltip && (null == (a = u(n).annotations) || a.hover(n, o)));
});
})(a), o = () => ((e) => {
let t = v(e);
null !== t.timeoutId && clearTimeout(t.timeoutId), t.timeoutId = setTimeout(() => {
t.timeoutId = null, !e.context.isDestroyed && (t.lastDateEl = null, p(e, t.tooltipEl, null), y(e));
}, 50);
})(a), i = (e) => ((e, t) => {
if ("Escape" !== t.key || 1 !== e.context.selectedDates.length) return;
let n = v(e);
n.lastDateEl = null, g(e, "selectedDates", []), p(e, n.tooltipEl, null), y(e);
})(a, e);
n.addEventListener("mousemove", l), n.addEventListener("mouseleave", o), n.addEventListener("keydown", i), r.cleanup = () => {
n.removeEventListener("mousemove", l), n.removeEventListener("mouseleave", o), n.removeEventListener("keydown", i);
};
}
a.disableDatesGaps && (r.rangeMin ??= a.context.displayDateMin, r.rangeMax ??= a.context.displayDateMax), r.tooltipEl = a.onCreateDateRangeTooltip ? a.context.mainElement.querySelector("[data-vc-date-range-tooltip]") : null;
let i = null == l ? void 0 : l.dataset.vcDate;
if (i) {
let e = 1 === a.context.selectedDates.length && a.context.selectedDates[0].includes(i);
g(a, "selectedDates", e && !x(a) ? [i, i] : e && x(a) ? [] : a.context.selectedDates.length > 1 ? [i] : [...a.context.selectedDates, i]), a.context.selectedDates.length > 1 && b(a.context.selectedDates);
}
({
set: () => {
a.disableDatesGaps && ((n) => {
var a, l;
if (null == n || null == (a = n.context) || null == (a = a.selectedDates) || !a[0] || null == (l = n.context.disableDates) || !l[0]) return;
let o = e(n.context.selectedDates[0]), [r, i] = n.context.disableDates.map((t) => e(t)).reduce(([e, t], n) => [o >= n ? n : e, o < n && null === t ? n : t], [null, null]);
r && g(n, "displayDateMin", t(new Date(r.setDate(r.getDate() + 1)))), i && g(n, "displayDateMax", t(new Date(i.setDate(i.getDate() - 1)))), n.disableDatesPast && !n.disableAllDates && e(n.context.displayDateMin) < e(n.context.dateToday) && g(n, "displayDateMin", n.context.dateToday);
})(a), p(a, r.tooltipEl, l);
},
reset: () => {
if (!o) return;
let [e, t] = [a.context.selectedDates[0], a.context.selectedDates[a.context.selectedDates.length - 1]];
g(a, "selectedDates", a.context.selectedDates[0] === a.context.selectedDates[a.context.selectedDates.length - 1] ? [a.context.selectedDates[0], a.context.selectedDates[0]] : a.enableEdgeDatesOnly ? [e, t] : (() => {
let l = new Set(a.context.disableDates);
return n([`${e}:${t}`]).filter((e) => !l.has(e));
})()), a.disableDatesGaps && (g(a, "displayDateMin", r.rangeMin), g(a, "displayDateMax", r.rangeMax)), a.onCreateDateRangeTooltip && p(a, r.tooltipEl, a.context.selectedDates[0] ? l : null);
}
})[1 === a.context.selectedDates.length ? "set" : "reset"]();
};
var w = (e) => e.getRootNode ? e.getRootNode() : document;
var E = /* @__PURE__ */ new WeakSet();
var k = "data-vc-prev-tabindex";
var T = (e) => e.tabIndex >= 0 && !e.hasAttribute("disabled") && "true" !== e.getAttribute("aria-disabled");
var A = (e) => {
if (e.hasAttribute(k)) return;
let t = e.getAttribute("tabindex");
e.setAttribute(k, null == t ? "" : t);
};
var C = (e) => {
if (!e.hasAttribute(k)) return;
let t = e.getAttribute(k);
"" === t || null === t ? e.removeAttribute("tabindex") : e.setAttribute("tabindex", t), e.removeAttribute(k);
};
var S = (e) => {
e.setAttribute("inert", ""), e.ariaHidden = "true", ((e) => {
T(e) && (A(e), e.tabIndex = -1);
let t = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, { acceptNode: (e) => T(e) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
for (; t.nextNode();) {
let e = t.currentNode;
A(e), e.tabIndex = -1;
}
})(e);
};
var $ = (e) => {
var t;
if (H(e), !e.context.isShowInInputMode || !e.context.currentType) return;
let n = e.context.mainElement.contains(w(e.context.mainElement).activeElement);
e.context.mainElement.dataset.vcCalendarHidden = "", g(e, "isShowInInputMode", !1), e.inputMode && S(e.context.mainElement), null != (t = e.context.inputElement) && t.hasAttribute("aria-expanded") && e.context.inputElement.setAttribute("aria-expanded", "false"), e.context.cleanupHandlers[0] && (e.context.cleanupHandlers.forEach((e) => e()), g(e, "cleanupHandlers", [])), e.inputMode && e.context.inputElement && n && (("function" == typeof e.openOnFocus || !0 === e.openOnFocus) && ((e) => {
E.add(e);
})(e), e.context.inputElement.focus()), e.onHide && e.onHide(e);
};
function Y(e) {
if (null == e || !e.getBoundingClientRect) return {
top: 0,
bottom: 0,
left: 0,
right: 0
};
let t = e.getBoundingClientRect(), n = document.documentElement;
return {
bottom: t.bottom,
right: t.right,
top: t.top + window.scrollY - n.clientTop,
left: t.left + window.scrollX - n.clientLeft
};
}
function N() {
return {
vw: Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0),
vh: Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
};
}
function I(e, t, n = 5) {
let a = {
top: !0,
bottom: !0,
left: !0,
right: !0
}, l = [];
if (!t || !e) return {
canShow: a,
parentPositions: l
};
let { bottom: o, top: r } = function(e) {
let { top: t, left: n } = {
left: window.scrollX || document.documentElement.scrollLeft || 0,
top: window.scrollY || document.documentElement.scrollTop || 0
}, { top: a, left: l } = Y(e), { vh: o, vw: r } = N(), i = a - t, s = l - n;
return {
top: i,
bottom: o - (i + e.clientHeight),
left: s,
right: r - (s + e.clientWidth)
};
}(e), { top: i, left: s } = Y(e), { height: c, width: d } = t.getBoundingClientRect(), { vh: u, vw: m } = N(), p = m / 2, h = u / 2;
return [
{
condition: i < h,
position: "top"
},
{
condition: i > h,
position: "bottom"
},
{
condition: s < p,
position: "left"
},
{
condition: s > p,
position: "right"
}
].forEach(({ condition: e, position: t }) => {
e && l.push(t);
}), Object.assign(a, {
top: c <= r - n,
bottom: c <= o - n,
left: d <= s,
right: d <= m - s
}), {
canShow: a,
parentPositions: l
};
}
var L = (e, t, n) => {
if (!e) return;
let a = "auto" === n ? function(e, t) {
let n = "left";
if (!t || !e) return n;
let { canShow: a, parentPositions: l } = I(e, t), o = a.left && a.right;
return (o && a.bottom ? "center" : o && a.top ? ["top", "center"] : Array.isArray(l) ? ["bottom" === l[0] ? "top" : "bottom", ...l.slice(1)] : l) || n;
}(e, t) : n, l = {
top: -t.offsetHeight,
bottom: e.offsetHeight,
left: 0,
center: e.offsetWidth / 2 - t.offsetWidth / 2,
right: e.offsetWidth - t.offsetWidth
}, o = Array.isArray(a) ? a[0] : "bottom", r = Array.isArray(a) ? a[1] : a;
t.dataset.vcPosition = o;
let { top: i, left: s } = Y(e), c = i + l[o], d = s + l[r], { vw: u } = N();
if (d + t.clientWidth > u) {
let e = window.innerWidth - document.body.clientWidth;
d = u - t.clientWidth - e;
} else d < 0 && (d = 0);
Object.assign(t.style, {
left: `${d}px`,
top: `${c}px`
});
};
var W = /* @__PURE__ */ new WeakMap();
var H = (e) => {
clearTimeout(W.get(e)), W.delete(e);
};
var O = (e) => {
H(e), W.set(e, setTimeout(() => {
W.delete(e), e.context.isDestroyed || q(e);
}));
};
var q = (e) => {
var t, n;
if (H(e), e.context.isShowInInputMode || e.context.isDestroyed) return;
if (!e.context.currentType) return void e.context.mainElement.click();
g(e, "cleanupHandlers", []), g(e, "isShowInInputMode", !0), e.inputMode && ((n = e.context.mainElement).removeAttribute("inert"), n.removeAttribute("aria-hidden"), ((e) => {
C(e), e.querySelectorAll(`[${k}]`).forEach(C);
})(n)), L(e.context.inputElement, e.context.mainElement, e.positionToInput), e.context.mainElement.removeAttribute("data-vc-calendar-hidden"), null != (t = e.context.inputElement) && t.hasAttribute("aria-expanded") && e.context.inputElement.setAttribute("aria-expanded", "true");
let a = () => {
L(e.context.inputElement, e.context.mainElement, e.positionToInput);
};
window.addEventListener("resize", a), e.context.cleanupHandlers.push(() => window.removeEventListener("resize", a));
let l = (t) => {
"Escape" === t.key && $(e);
};
document.addEventListener("keydown", l), e.context.cleanupHandlers.push(() => document.removeEventListener("keydown", l));
let o = (t) => {
var n;
let a = null == (n = t.composedPath()[0]) ? t.target : n;
a === e.context.inputElement || e.context.mainElement.contains(a) || $(e);
};
document.addEventListener("click", o, { capture: !0 }), e.context.cleanupHandlers.push(() => document.removeEventListener("click", o, { capture: !0 })), e.onShow && e.onShow(e);
};
var F = "The calendar has not been initialized, please initialize it using the \"init()\" method first.";
var P = "You specified an incorrect language label or did not specify the required number of values ​​for «locale.weekdays» or «locale.months».";
var _ = (e) => String(e).replace(/[&<>"']/g, (e) => ({
"&": "&",
"<": "<",
">": ">",
"\"": """,
"'": "'"
})[e]);
var R = (e, t) => `\n
\n`;
var j = (e, t = "month") => `${R(e, t)} \n <#WeekNumbers />\n
\n <#Week />\n <#Dates />\n <#DateRangeTooltip />\n
\n
\n <#Collapse />\n <#ControlTime />\n`;
var z = (e) => e;
var K = /* @__PURE__ */ new WeakMap();
var B = (e) => {
var t;
null == (t = K.get(e)) || t.observer.disconnect(), K.delete(e);
};
var U = B;
var X = (e) => {
var t;
return !(e.animation || e.enableCollapse || e.onCreateDateEls || e.onCreateDateRangeTooltip || e.disableDatesGaps || e.popups && Object.keys(e.popups).length || e.sanitizerHTML !== z || "default" !== e.context.currentType && "multiple" !== e.context.currentType || e.layouts[e.context.currentType] !== ("multiple" === e.context.currentType ? null == (t = u(e).months) ? void 0 : t.layout(e) : j(e)));
};
var G = (e) => JSON.stringify(Object.entries(e).filter(([e]) => "context" !== e && "selectedDates" !== e), (e, t) => "function" == typeof t || t);
var Z = ({ context: e }) => JSON.stringify([
e.currentType,
e.locale,
e.dateToday,
e.dateMin,
e.dateMax,
e.displayDateMin,
e.displayDateMax,
e.selectedYear,
e.selectedMonth,
e.displayMonthsCount,
e.selectedHours,
e.selectedMinutes,
e.selectedKeeping,
e.selectedTime
]);
var V = (e) => JSON.stringify([
Z(e),
e.context.displayYear,
e.context.displayWeekDate,
e.context.selectedDates,
e.context.disableDates,
e.context.enableDates
]);
var J = (e, t = !1) => {
let n = K.get(e);
if (!n || !t && !n.fullLayout || n.dirty || n.observer.takeRecords().length || !X(e)) return;
let a = w(e.context.mainElement).activeElement;
if (!a || a === e.context.mainElement || !e.context.mainElement.contains(a) || t && !a.closest("[data-vc=\"column\"], [data-vc=\"dates\"], [data-vc-week=\"numbers\"]")) try {
if (n.options === G(e) && n.context === V(e) && n.timezone === new Intl.DateTimeFormat().resolvedOptions().timeZone) return n;
} catch (l) {}
};
var Q = (e, t = !1) => {
if (B(e), X(e) && !e.context.isDestroyed) try {
let n = G(e), a = V(e);
if (n.length + a.length > 262144) return;
let l = Array.from(e.context.mainElement.querySelectorAll("[data-vc=\"dates\"]"));
if (l.length !== e.context.displayMonthsCount) return;
let o = {
observer: new MutationObserver(() => o.dirty = !0),
dirty: !1,
fullLayout: t,
options: n,
context: a,
structure: Z(e),
timezone: new Intl.DateTimeFormat().resolvedOptions().timeZone,
month: 12 * e.context.selectedYear + e.context.selectedMonth,
count: l.length
};
o.observer.observe(e.context.mainElement, {
subtree: !0,
childList: !0,
attributes: !0,
characterData: !0
}), K.set(e, o);
} catch (n) {
B(e);
}
};
var ee = (e, t, n, a = "") => {
t ? e.getAttribute(n) !== a && e.setAttribute(n, a) : e.getAttribute(n) === a && e.removeAttribute(n);
};
var te = (t, n, a, l, o, i, s) => {
var c;
let d = (p = i, Date.parse(`${p}T00:00:00`)), u = r(t), m = u.min > d || u.max < d || u.disabled.set.has(i) || !t.selectionMonthsMode && "current" !== s || !t.selectionYearsMode && e(i).getFullYear() !== n;
var p;
ee(a, m, "data-vc-date-disabled"), l && ee(l, m, "aria-disabled", "true"), l && m && ee(l, !0, "tabindex", "-1"), l && l.disabled !== !!m && (l.disabled = !!m), ee(a, !t.disableToday && t.context.dateToday === i, "data-vc-date-today"), ee(a, !t.disableToday && t.context.dateToday === i, "aria-current", "date"), ee(a, null == (c = t.selectedWeekends) ? void 0 : c.includes(o), "data-vc-date-weekend"), ee(a, u.holidays.has(i), "data-vc-date-holiday");
let h = u.selected.set.has(i), v = h ? "" : void 0;
h ? (ee(a, !0, "aria-selected", "true"), t.context.selectedDates.length > 1 && "multiple-ranged" === t.selectionDatesMode && (t.context.selectedDates[0] === i && t.context.selectedDates[t.context.selectedDates.length - 1] === i ? v = "first-and-last" : t.context.selectedDates[0] === i ? v = "first" : t.context.selectedDates[t.context.selectedDates.length - 1] === i && (v = "last"), t.context.selectedDates[0] !== i && t.context.selectedDates[t.context.selectedDates.length - 1] !== i && (v = "middle"))) : a.hasAttribute("data-vc-date-selected") && a.removeAttribute("aria-selected"), !u.disabled.set.has(i) && t.enableEdgeDatesOnly && t.context.selectedDates.length > 1 && "multiple-ranged" === t.selectionDatesMode && (d > u.first && d < u.last ? v = "middle" : "middle" === v && (v = void 0)), void 0 === v ? a.hasAttribute("data-vc-date-selected") && a.removeAttribute("data-vc-date-selected") : ee(a, !0, "data-vc-date-selected", v);
};
var ne = /* @__PURE__ */ new Map();
var ae = /* @__PURE__ */ new Map();
var le = (e, t, n) => {
var a, l;
let o = null == (a = e.disableWeekdays) ? void 0 : a.includes(n), i = e.disableAllDates && !(null == (l = e.context.enableDates) || !l[0]), s = r(e);
if ((o || i) && !s.enabled.set.has(t) && !s.disabled.set.has(t)) {
let n = e.context.disableDates;
if (s.disabled.set.add(t), e.onCreateDateEls) n.push(t), b(n), s.disabled.values = n.slice();
else {
let e = +new Date(t), a = 0, l = n.length;
for (; a < l;) {
let t = a + l >>> 1;
+new Date(n[t]) <= e ? a = t + 1 : l = t;
}
n.splice(a, 0, t), s.disabled.values.splice(a, 0, t);
}
}
};
var oe = (t, n, a, l, r, i) => {
var s;
let c, d = e(r).getDay(), m = "string" == typeof t.locale && t.locale.length ? t.locale : "en", p = document.createElement("div");
p.className = t.styles.date, p.dataset.vcDate = r, p.dataset.vcDateMonth = i, p.dataset.vcDateWeekDay = String(d), p.role = "gridcell", ("current" === i || t.displayDatesOutside) && (c = document.createElement("button"), c.className = t.styles.dateBtn, c.type = "button", c.dataset.vcDateBtn = "", c.ariaLabel = ((e, t) => {
let n = `${t}:${e}`, a = ae.get(n);
if (void 0 !== a) return a;
let l = ne.get(t);
l || (l = new Intl.DateTimeFormat(t, {
dateStyle: "long",
timeZone: "UTC"
}), ne.size >= 8 && ne.delete(ne.keys().next().value), ne.set(t, l));
let o = l.format(/* @__PURE__ */ new Date(`${e}T00:00:00.000Z`));
return ae.size >= 512 && ae.delete(ae.keys().next().value), ae.set(n, o), o;
})(r, m), c.innerText = String(l), p.appendChild(c)), t.enableWeekNumbers && (null == (s = u(t).weeks) || s.date(t, p, r)), le(t, r, d), te(t, n, p, c, d, r, i), a.addDate(p), t.onCreateDateEls && (t.onCreateDateEls(t, p), o(t));
};
var re = [
{
container: "[data-vc=\"dates\"]",
item: "[data-vc-date-btn]",
active: ["[data-vc-date-selected] [data-vc-date-btn]", "[data-vc-date-today] [data-vc-date-btn]"]
},
{
container: "[data-vc=\"months\"]",
item: "[data-vc-months-month]",
active: ["[data-vc-months-month-selected]"]
},
{
container: "[data-vc=\"years\"]",
item: "[data-vc-years-year]",
active: ["[data-vc-years-year-selected]"]
}
];
var ie = (e) => !e.hasAttribute("disabled") && "true" !== e.getAttribute("aria-disabled");
var se = (e, t, n) => {
if (n && ie(n)) return e.querySelectorAll(`${t.item}:not([tabindex="-1"])`).forEach((e) => {
e !== n && (e.tabIndex = -1);
}), void ("0" !== n.getAttribute("tabindex") && (n.tabIndex = 0));
let a = Array.from(e.querySelectorAll(t.item));
if (!a[0]) return;
let l = ((e, t, n) => {
var a;
let l = t.active.map((t) => e.querySelector(t)).find((e) => !!e && ie(e));
return null == (a = null == l ? n.find(ie) : l) ? n[0] : a;
})(e, t, a);
a.forEach((e) => {
let t = e === l ? 0 : -1;
e.getAttribute("tabindex") !== String(t) && (e.tabIndex = t);
});
};
var ce = (e) => {
let t = e.target, n = re.find((e) => {
var n;
return null == (n = t.matches) ? void 0 : n.call(t, e.item);
}), a = n ? t.closest(n.container) : null;
n && a && se(a, n, t);
};
var de = (e) => {
re.forEach((t) => {
e.context.mainElement.querySelectorAll(t.container).forEach((e) => {
e.closest("[data-vc-ghost]") || se(e, t, null);
});
});
};
var ue = (e, n, a = !0) => {
var l;
U(e);
let r = new Date(e.context.selectedYear, e.context.selectedMonth, 1), i = e.context.mainElement.querySelectorAll("[data-vc=\"dates\"]"), s = u(e).weeks, c = e.enableWeekNumbers ? e.context.mainElement.querySelectorAll("[data-vc-week=\"numbers\"]") : [], d = null == (l = u(e).annotations) ? void 0 : l.prepare(e, i.length);
i.forEach((a, l) => {
e.selectionDatesMode || (a.dataset.vcDatesDisabled = "");
let i = n ? 12 * e.context.selectedYear + e.context.selectedMonth + l - n.month : -1;
if (n && i >= 0 && i < n.count) return;
if (a.textContent = "", o(e), "week" === e.context.currentType) return s?.dates(e, a), d?.(a), void (null == s || s.numbers(e, 0, 7, c[l], a));
let u = new Date(r);
u.setMonth(u.getMonth() + l);
let m = u.getMonth(), p = u.getFullYear(), h = (new Date(p, m, 1).getDay() - e.firstWeekday + 7) % 7, v = new Date(p, m + 1, 0).getDate(), y = h + v, g = Math.ceil(y / 7), f = 7 * g - y, x = [];
for (let t = 0; t < g; t++) {
let t = document.createElement("div");
t.className = e.styles.datesRow, t.setAttribute("data-vc-dates", "row"), t.setAttribute("role", "row"), x.push(t);
}
let b = 0, D = 0, M = { addDate: (e) => {
x[b].appendChild(e), D++, D >= 7 && (b++, D = 0);
} };
((e, t, n, a, l) => {
let o = new Date(n, a, 0).getDate() - (l - 1), r = 0 === a ? n - 1 : n, i = 0 === a ? 12 : a < 10 ? `0${a}` : a;
for (let s = l; s > 0; s--, o++) oe(e, n, t, o, `${r}-${i}-${o}`, "prev");
})(e, M, p, m, h), ((e, n, a, l, o) => {
for (let r = 1; r <= a; r++) {
let a = new Date(l, o, r);
oe(e, l, n, r, t(a), "current");
}
})(e, M, v, p, m), ((e, t, n, a, l) => {
let o = l + 1 === 12 ? a + 1 : a, r = l + 1 === 12 ? "01" : l + 2 < 10 ? `0${l + 2}` : l + 2;
for (let i = 1; i <= n; i++) {
let n = `${o}-${r}-${i < 10 ? `0${i}` : String(i)}`;
oe(e, a, t, i, n, "next");
}
})(e, M, f, p, m);
for (let e of x) a.appendChild(e);
d?.(a), s?.numbers(e, h, v, c[l], a);
}), de(e), a && Q(e, null == n ? void 0 : n.fullLayout);
};
var me = (e, t) => `${R(e, "Years" === t ? "year" : void 0)} \n`;
var pe = (e) => me(e, "Months");
var he = (e) => me(e, "Years");
var ye = (e, t, n) => e.labels["arrow" + ("prev" === t ? "Prev" : "Next")][n];
var ge = {
ArrowNext: (e, t) => ` `,
ArrowPrev: (e, t) => ` `,
Dates: (e) => `
`,
Month: (e) => ` `,
Months: (e) => `
`,
Week: (e) => `
`,
Year: (e) => ` `,
Years: (e) => `
`
};
var fe = (e, t) => t.replace(/[\n\t]/g, "").replace(/<#(?!\/?Multiple)(.*?)>/g, (t, n) => {
let a = (n.match(/\[(.*?)\]/) || [])[1], l = ((e, t) => {
var n, a, l, o;
return "Collapse" === t ? null == (n = u(e).weeks) ? void 0 : n.component : "WeekNumbers" === t ? null == (a = u(e).weeks) ? void 0 : a.numbersComponent : "DateRangeTooltip" === t ? null == (l = u(e).annotations) ? void 0 : l.component : "ControlTime" === t ? null == (o = u(e).time) ? void 0 : o.component : Object.prototype.hasOwnProperty.call(ge, t) ? ge[t] : void 0;
})(e, n.replace(/[/\s\n\t]|\[(.*?)\]/g, "")), o = l ? l(e, null == a ? null : a) : "";
return e.sanitizerHTML(o);
}).replace(/[\n\t]/g, "");
var xe = (e, t) => {
var n, a, l;
let o = u(e), r = {
default: j,
month: pe,
year: he,
multiple: null == (n = o.months) ? void 0 : n.layout,
week: null == (a = o.weeks) ? void 0 : a.layout
};
var i;
Object.keys(r).forEach((t) => {
var n, a;
let l = t;
e.layouts[l].length || (e.layouts[l] = null == (n = null == (a = r[l]) ? void 0 : a.call(r, e)) ? "" : n);
}), e.context.mainElement.className = e.styles.calendar, e.context.mainElement.dataset.vc = "calendar", e.context.mainElement.dataset.vcType = e.context.currentType, e.context.mainElement.toggleAttribute("data-vc-swipe", e.enableSwipe), e.context.mainElement.role = e.inputMode ? "dialog" : "group", e.context.mainElement.tabIndex = -1, e.context.mainElement.ariaLabel = e.labels.application, null != (l = o.months) && l.render(e, t) || (null == (i = o.time) || i.destroy(e), e.context.mainElement.innerHTML = e.sanitizerHTML(fe(e, e.layouts[e.context.currentType]))), ((e) => {
let t = ["multiple", "multiple-ranged"].includes(String(e.selectionDatesMode));
e.context.mainElement.querySelectorAll("[data-vc=\"content\"][role=\"grid\"]").forEach((e) => {
t ? e.setAttribute("aria-multiselectable", "true") : e.removeAttribute("aria-multiselectable");
});
})(e);
};
var be = (e, t, n, a) => {
e.style.visibility = n ? "hidden" : "", t.style.visibility = a ? "hidden" : "";
};
var De = (n) => {
if ("month" === n.context.currentType) return;
let a = n.context.mainElement.querySelector("[data-vc-arrow=\"prev\"]"), l = n.context.mainElement.querySelector("[data-vc-arrow=\"next\"]");
a && l && {
default: () => ((n, a, l) => {
let o = e(t(new Date(n.context.selectedYear, n.context.selectedMonth, 1))), r = new Date(o.getTime()), i = new Date(o.getTime());
r.setMonth(r.getMonth() - n.monthsToSwitch), i.setMonth(i.getMonth() + n.monthsToSwitch);
let s = e(n.context.dateMin), c = e(n.context.dateMax);
n.selectionYearsMode || (s.setFullYear(o.getFullYear()), c.setFullYear(o.getFullYear())), be(a, l, !n.selectionMonthsMode || r.getFullYear() < s.getFullYear() || r.getFullYear() === s.getFullYear() && r.getMonth() < s.getMonth(), !n.selectionMonthsMode || i.getFullYear() > c.getFullYear() || i.getFullYear() === c.getFullYear() && i.getMonth() > c.getMonth() - (n.context.displayMonthsCount - 1));
})(n, a, l),
year: () => ((t, n, a) => {
let l = e(t.context.dateMin), o = e(t.context.dateMax);
be(n, a, !!(l.getFullYear() && t.context.displayYear - 7 <= l.getFullYear()), !!(o.getFullYear() && t.context.displayYear + 7 >= o.getFullYear()));
})(n, a, l),
week: () => {
var e;
return null == (e = u(n).weeks) ? void 0 : e.arrows(n, a, l);
}
}["multiple" === n.context.currentType ? "default" : n.context.currentType]();
};
var Me = (e, t) => {
let n = e.context.mainElement.querySelectorAll("[data-vc=\"month\"]"), a = e.context.mainElement.querySelectorAll("[data-vc=\"year\"]"), l = new Date(e.context.selectedYear, e.context.selectedMonth, 1);
[n, a].forEach((n) => null == n ? void 0 : n.forEach((n, a) => {
(!t || t.includes(a)) && ((e, t, n, a, l) => {
let o = new Date(a.setFullYear(e.context.selectedYear, e.context.selectedMonth + n)).getFullYear(), r = new Date(a.setMonth(e.context.selectedMonth + n)).getMonth(), i = e.context.locale.months.long[r], s = t.closest("[data-vc=\"column\"]");
s && (s.ariaLabel = `${i} ${o}`);
let c = {
month: {
id: r,
label: i
},
year: {
id: o,
label: o
}
};
t.innerText = String(c[l].label), t.dataset[`vc${l.charAt(0).toUpperCase() + l.slice(1)}`] = String(c[l].id), t.ariaLabel = `${e.labels[l]} ${c[l].label}`;
let d = {
month: e.selectionMonthsMode,
year: e.selectionYearsMode
}, u = !1 === d[l] || "only-arrows" === d[l];
u && (t.tabIndex = -1), t.disabled = u;
})(e, n, a, l, n.dataset.vc);
}));
};
var we = (e, t, n, a, l) => {
let o = {
month: {
selected: "data-vc-months-month-selected",
aria: "aria-selected",
value: "vcMonthsMonth",
selectedProperty: "selectedMonth"
},
year: {
selected: "data-vc-years-year-selected",
aria: "aria-selected",
value: "vcYearsYear",
selectedProperty: "selectedYear"
}
};
var r, i;
l && (null == (r = e.context.mainElement.querySelectorAll({
month: "[data-vc-months-month]",
year: "[data-vc-years-year]"
}[n])) || r.forEach((e) => {
var t;
e.removeAttribute(o[n].selected), null == (t = e.parentElement) || t.removeAttribute(o[n].aria);
}), g(e, o[n].selectedProperty, Number(t.dataset[o[n].value])), Me(e), "year" === n && De(e)), a && (t.setAttribute(o[n].selected, ""), null == (i = t.parentElement) || i.setAttribute(o[n].aria, "true"));
};
var Ee = (e, t, n, a, l, o, r, i) => {
let s = "month" === t ? "months" : "years", c = document.createElement("div");
c.className = e.styles[`${s}Cell`], c.setAttribute(`data-vc-${s}`, "cell"), c.role = "gridcell";
let d = n.cloneNode(!1);
return d.className = e.styles["month" === t ? "monthsMonth" : "yearsYear"], d.innerText = r, d.ariaLabel = i, d.setAttribute(`data-vc-${s}-${t}`, String(o)), l && (d.ariaDisabled = "true"), l && (d.tabIndex = -1), d.disabled = l, c.appendChild(d), we(e, d, t, a === o, !1), c;
};
var ke = (e, t) => {
var n, a;
return null == (n = null == (a = u(e).months) ? void 0 : a.column(e, t)) ? {
currentValue: null,
columnID: 0
} : n;
};
var Te = (t, n) => {
var a;
let l = null == n || null == (a = n.closest("[data-vc=\"header\"]")) ? void 0 : a.querySelector("[data-vc=\"year\"]"), o = l ? Number(l.dataset.vcYear) : t.context.selectedYear, r = null != n && n.dataset.vcMonth ? Number(n.dataset.vcMonth) : t.context.selectedMonth;
g(t, "currentType", "month"), xe(t, n), Me(t);
let i = t.context.mainElement.querySelector("[data-vc=\"months\"]");
if (!t.selectionMonthsMode || !i) return;
let s = t.monthsToSwitch > 1 ? t.context.locale.months.long.map((e, n) => r - t.monthsToSwitch * n).concat(t.context.locale.months.long.map((e, n) => r + t.monthsToSwitch * n)).filter((e) => e >= 0 && e <= 12) : Array.from(Array(12).keys()), c = document.createElement("button");
c.type = "button";
let d, u = () => ({
min: e(t.context.dateMin),
max: e(t.context.dateMax),
monthCount: t.context.displayMonthsCount - 1,
columnID: ke(t, "month").columnID
}), m = t.onCreateMonthEls ? void 0 : u();
for (let e = 0; e < 12; e++) {
e % 4 == 0 && (d = document.createElement("div"), d.className = t.styles.monthsRow, d.dataset.vcMonths = "row", d.role = "row", i.appendChild(d));
let { min: n, max: a, monthCount: l, columnID: p } = null == m ? u() : m, h = Ee(t, "month", c, r, o <= n.getFullYear() && e < n.getMonth() + p || o >= a.getFullYear() && e > a.getMonth() - l + p || o > a.getFullYear() || e !== r && !s.includes(e), e, t.context.locale.months.short[e], t.context.locale.months.long[e]);
d?.appendChild(h), t.onCreateMonthEls && t.onCreateMonthEls(t, h);
}
de(t);
};
var Ae = (e) => {
var t;
let n = e.selectedWeekends ? [...e.selectedWeekends] : [], a = [...e.context.locale.weekdays.long].map((t, a) => ({
id: a,
titleShort: e.context.locale.weekdays.short[a],
titleLong: t,
isWeekend: n.includes(a)
})), l = [...a.slice(e.firstWeekday), ...a.slice(0, e.firstWeekday)], o = null == (t = u(e).weeks) ? void 0 : t.weekday(e), r = document.createElement(o ? "div" : "b");
e.context.mainElement.querySelectorAll("[data-vc=\"week\"]").forEach((t) => {
l.forEach((n) => {
let a = r.cloneNode(!1);
a.className = e.styles.weekDay, a.role = "columnheader", a.ariaLabel = n.titleLong, a.dataset.vcWeekDay = String(n.id), n.isWeekend && (a.dataset.vcWeekDayOff = ""), o ? o(a, n.titleShort, n.titleLong) : a.innerText = n.titleShort, t.appendChild(a);
});
});
};
var Ce = (t, n) => {
let a = null != n && n.dataset.vcYear ? Number(n.dataset.vcYear) : t.context.selectedYear;
g(t, "currentType", "year"), xe(t, n), Me(t), De(t);
let l = t.context.mainElement.querySelector("[data-vc=\"years\"]");
if (!t.selectionYearsMode || !l) return;
let o = "multiple" === t.type ? t.context.selectedYear === a ? 0 : 1 : 0, r = document.createElement("button");
r.type = "button";
let i, s = () => [e(t.context.dateMin).getFullYear(), e(t.context.dateMax).getFullYear()], c = t.onCreateYearEls ? void 0 : s();
for (let e = t.context.displayYear - 7; e < t.context.displayYear + 8; e++) {
(e - (t.context.displayYear - 7)) % 5 == 0 && (i = document.createElement("div"), i.className = t.styles.yearsRow, i.dataset.vcYears = "row", i.role = "row", l.appendChild(i));
let [n, d] = null == c ? s() : c, u = Ee(t, "year", r, a, e < n + o || e > d, e, String(e), String(e));
i?.appendChild(u), t.onCreateYearEls && t.onCreateYearEls(t, u);
}
de(t);
};
var Se = /* @__PURE__ */ new WeakMap();
var $e = (e) => {
var t, n;
let a = "not all" !== window.matchMedia("(prefers-color-scheme)").media;
var l, o;
if (!a || "system" !== e.selectedTheme) return null == (l = (o = e.context).cleanupSystemTheme) || l.call(o), void (e.context.mainElement.dataset.vcTheme = a ? e.selectedTheme : "light");
let r = e.themeAttrDetect.length ? document.querySelector(e.themeAttrDetect) : null, i = e.themeAttrDetect.replace(/^.*\[(.+)\]/g, (e, t) => t), s = Se.get(e);
if ((null == s ? void 0 : s.element) === r && s.attr === i) return void s.update();
null == (t = (n = e.context).cleanupSystemTheme) || t.call(n);
let c, d = window.matchMedia("(prefers-color-scheme: dark)"), u = () => {
let t = null == r ? void 0 : r.getAttribute(i), n = !t || "system" === t;
e.context.mainElement.dataset.vcTheme = n ? d.matches ? "dark" : "light" : t, n && !c ? d.addEventListener ? (d.addEventListener("change", u), c = () => d.removeEventListener("change", u)) : (d.addListener(u), c = () => d.removeListener(u)) : !n && c && (c(), c = void 0);
}, m = r ? ((e, t, n) => {
let a = new MutationObserver((e) => {
for (let a = 0; a < e.length; a++) if (e[a].attributeName === t) {
n();
break;
}
});
return a.observe(e, {
attributes: !0,
attributeFilter: [t]
}), () => a.disconnect();
})(r, i, u) : void 0;
Se.set(e, {
element: r,
attr: i,
update: u
}), g(e, "cleanupSystemTheme", () => {
m?.(), c?.(), Se.delete(e), g(e, "cleanupSystemTheme", void 0);
}), u();
};
function Ye(e) {
return Ye = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
return typeof e;
} : function(e) {
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, Ye(e);
}
function Ne(e, t, n) {
return (t = function(e) {
var t = function(e) {
if ("object" != Ye(e) || !e) return e;
var t = e[Symbol.toPrimitive];
if (void 0 !== t) {
var n = t.call(e, "string");
if ("object" != Ye(n)) return n;
throw TypeError("@@toPrimitive must return a primitive value.");
}
return String(e);
}(e);
return "symbol" == Ye(t) ? t : t + "";
}(t)) in e ? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[t] = n, e;
}
function Ie(e, t) {
var n = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(e);
t && (a = a.filter(function(t) {
return Object.getOwnPropertyDescriptor(e, t).enumerable;
})), n.push.apply(n, a);
}
return n;
}
function Le(e) {
for (var t = 1; t < arguments.length; t++) {
var n = null == arguments[t] ? {} : arguments[t];
t % 2 ? Ie(Object(n), !0).forEach(function(t) {
Ne(e, t, n[t]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Ie(Object(n)).forEach(function(t) {
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
});
}
return e;
}
var We = /* @__PURE__ */ new Map();
var He = (e, t, n) => {
let a = new Intl.DateTimeFormat(e, {
[t]: n,
timeZone: "UTC"
});
return Array.from({ length: "weekday" === t ? 7 : 12 }, (e, n) => {
return (l = a.format(new Date(Date.UTC(1978, "month" === t ? n : 0, "weekday" === t ? n + 1 : 1)))).charAt(0).toUpperCase() + l.slice(1).replace(/\./, "");
var l;
});
};
var Oe = (e) => {
if (e.context.locale.weekdays.short[6] && e.context.locale.weekdays.long[6] && e.context.locale.months.short[11] && e.context.locale.months.long[11]) return;
if ("string" != typeof e.locale) {
var t, n, a, l;
if (!(null != (t = e.locale) && null != (t = t.weekdays) && t.short[6] && null != (n = e.locale) && null != (n = n.weekdays) && n.long[6] && null != (a = e.locale) && null != (a = a.months) && a.short[11] && null != (l = e.locale) && null != (l = l.months) && l.long[11])) throw Error(P);
g(e, "locale", Le({}, e.locale));
return;
}
if ("string" == typeof e.locale && !e.locale.length) throw Error(P);
let o = We.get(e.locale);
o || (o = {
weekdays: {
short: He(e.locale, "weekday", "short"),
long: He(e.locale, "weekday", "long")
},
months: {
short: He(e.locale, "month", "short"),
long: He(e.locale, "month", "long")
}
}, We.size >= 8 && We.delete(We.keys().next().value), We.set(e.locale, o));
for (let r of ["weekdays", "months"]) for (let t of ["short", "long"]) e.context.locale[r][t].push(...o[r][t]);
};
var qe = (e, t = !0) => {
var n;
U(e), $e(e), Oe(e), xe(e), Me(e), De(e), null == (n = u(e).time) || n.render(e), {
default: () => {
Ae(e), ue(e, void 0, !1);
},
multiple: () => {
Ae(e), ue(e, void 0, !1);
},
week: () => {
var t;
null == (t = u(e).weeks) || t.init(e), Ae(e), ue(e, void 0, !1);
},
month: () => Te(e),
year: () => Ce(e)
}[e.context.currentType](), t && Q(e, !0);
};
var Fe = (t, n = !1) => {
o(t), t.context.mainElement.querySelectorAll("[data-vc-date]").forEach((a) => {
let l = a.querySelector("[data-vc-date-btn]"), o = a.dataset.vcDate, r = e(o), i = r.getDay();
n && le(t, o, i);
let s = n ? a.dataset.vcDateMonth : "current";
"prev" === s && r.setMonth(r.getMonth() + 1, 1), "next" === s && r.setMonth(r.getMonth() - 1, 1), te(t, n ? r.getFullYear() : t.context.selectedYear, a, l, i, o, s);
}), de(t);
};
var Pe = (e) => {
let t = [
{
container: "[data-vc=\"dates\"]",
row: "[data-vc-dates=\"row\"]",
item: "[data-vc-date-btn]"
},
{
container: "[data-vc=\"months\"]",
row: "[data-vc-months=\"row\"]",
item: "[data-vc-months-month]"
},
{
container: "[data-vc=\"years\"]",
row: "[data-vc-years=\"row\"]",
item: "[data-vc-years-year]"
}
], n = (e) => !e.disabled && "true" !== e.getAttribute("aria-disabled"), a = (e) => {
let a = e.target.closest("button");
if (!a || ![
"ArrowUp",
"ArrowDown",
"ArrowLeft",
"ArrowRight"
].includes(e.key)) return;
let l, o = t.find((e) => a.matches(e.item)), r = o ? a.closest(o.container) : null;
if (o && r && !r.closest("[data-vc-ghost]") && n(a)) {
if ("ArrowUp" === e.key || "ArrowDown" === e.key) l = ((e, t, a, l) => {
var o;
let r = a.closest(t.row);
if (!r) return a;
let i = Array.from(e.querySelectorAll(t.row)), s = i.indexOf(r), c = Array.from(r.children).indexOf(a.parentElement), d = i[s + l], u = null == d || null == (o = d.children[c]) ? void 0 : o.querySelector(t.item);
return u && n(u) ? u : a;
})(r, o, a, "ArrowUp" === e.key ? -1 : 1);
else {
let t = Array.from(r.querySelectorAll(o.item)).filter(n), i = t.indexOf(a);
if (-1 === i) return;
l = "ArrowLeft" === e.key ? t[Math.max(0, i - 1)] : t[Math.min(t.length - 1, i + 1)];
}
e.preventDefault(), l?.focus();
}
};
return e.context.mainElement.addEventListener("keydown", a), e.context.mainElement.addEventListener("focusin", ce), () => {
e.context.mainElement.removeEventListener("keydown", a), e.context.mainElement.removeEventListener("focusin", ce);
};
};
var _e = "[data-vc=\"dates\"]";
var Re = (e, t) => "next" === e ? t : -t;
var je = (n) => {
let a = {
selector: _e,
shift: (a) => ((n, a) => {
let l = e(t(new Date(n.context.selectedYear, n.context.selectedMonth, 1)));
l.setMonth(l.getMonth() + Re(a, n.monthsToSwitch)), g(n, "selectedMonth", l.getMonth()), g(n, "selectedYear", l.getFullYear());
})(n, a),
render: (e, t) => ue(n, t)
};
return {
default: a,
multiple: a,
week: {
selector: _e,
shift: (e) => {
var t;
return null == (t = u(n).weeks) ? void 0 : t.shift(n, e);
},
render: () => ue(n)
},
year: {
selector: "[data-vc=\"years\"]",
shift: (e) => g(n, "displayYear", n.context.displayYear + Re(e, 15)),
render: (e) => Ce(n, e)
},
month: null
}[n.context.currentType];
};
var ze = (e, t, n) => {
var a;
let l = je(e);
if (!l) return;
let { mainElement: o } = e.context, r = o.contains(w(o).activeElement), i = "multiple" === e.context.currentType ? J(e, !0) : void 0;
U(e), l.shift(t);
let s = i ? null == (a = u(e).months) ? void 0 : a.rotate(e, i) : void 0;
s || (i = void 0), Me(e, s), De(e);
let c = u(e).motion;
c && e.animation ? c.navigate(e, l.selector, t, () => l.render(n, i)) : l.render(n, i), ((e, t, n) => {
var a;
let { mainElement: l } = e.context;
if (!n || l.contains(w(l).activeElement)) return;
let o = l.querySelector(`[data-vc-arrow="${t}"]`);
if (o && "hidden" !== o.style.visibility) return o.focus();
null == (a = Array.from(l.querySelectorAll("[tabindex=\"0\"]")).find((e) => !e.closest("[data-vc-ghost]"))) || a.focus();
})(e, t, r);
};
var Ke = (e, t, n) => {
let a = t.dataset.vcDate, l = t.closest("[data-vc-date][data-vc-date-selected]"), o = x(e);
(!l || o) && g(e, "selectedDates", l ? e.context.selectedDates.filter((e) => e !== a) : n ? [...e.context.selectedDates, a] : [a]);
};
var Be = ["month", "year"];
var Ue = "[data-vc=\"column\"]";
var Xe = (e, t, n) => {
let a = u(e).motion;
a && e.animation ? a.changeView(e, t, n) : n();
};
var Ge = (e, t) => {
var n;
let { columnID: a } = ke(e, e.context.currentType);
g(e, "currentType", e.type), Xe(e, a, () => qe(e)), null == (n = e.context.mainElement.querySelector(`[data-vc="${t}"]`)) || n.focus();
};
var Ze = (e) => {
let t = (t) => {
var n, a;
((e, t) => {
let n = t.target, a = n.closest("[data-vc-arrow]");
a && (ze(e, a.dataset.vcArrow, n), e.onClickArrow && e.onClickArrow(e, t));
})(e, t), null == (n = u(e).weeks) || n.click(e, t), ((e, t) => {
let n = t.target, a = n.closest("[data-vc-date-btn]");
if (!e.selectionDatesMode || ![
"single",
"multiple",
"multiple-ranged"
].includes(e.selectionDatesMode) || !a) return;
let l = a.closest("[data-vc-date]");
({
single: () => Ke(e, l, !1),
multiple: () => Ke(e, l, !0),
"multiple-ranged": () => M(e, l)
})[e.selectionDatesMode](), e.context.selectedDates && b(e.context.selectedDates), e.onClickDate && e.onClickDate(e, t), e.inputMode && e.context.inputElement && e.context.mainElement && e.onChangeToInput && e.onChangeToInput(e, t);
let o = n.closest("[data-vc-date-month=\"prev\"]"), r = n.closest("[data-vc-date-month=\"next\"]");
({
prev: () => e.enableMonthChangeOnDayClick ? ze(e, "prev") : Fe(e),
next: () => e.enableMonthChangeOnDayClick ? ze(e, "next") : Fe(e),
current: () => Fe(e)
})[o ? "prev" : r ? "next" : "current"]();
})(e, t), ((e, t) => {
let n = {
month: e.selectionMonthsMode,
year: e.selectionYearsMode
};
Be.forEach((a) => {
n[a] && t.target && ((e, t, n) => {
let a = t.target, l = a.closest(`[data-vc="${n}"]`), o = ((e, t) => {
let n = t.closest(Ue);
return n ? Array.from(e.context.mainElement.querySelectorAll(Ue)).indexOf(n) : 0;
})(e, a), r = {
year: () => Xe(e, o, () => Ce(e, a)),
month: () => Xe(e, o, () => Te(e, a))
};
if (l && e.onClickTitle && e.onClickTitle(e, t), l && e.context.currentType !== n) {
let t = a.closest(Ue);
return r[n](), ((e, t, n) => {
var a;
return null == (a = (null == n ? e.context.mainElement : n).querySelector(`[data-vc-${t}s-${t}][tabindex="0"]`)) ? void 0 : a.focus();
})(e, n, t);
}
let i = a.closest(`[data-vc-${n}s-${n}]`);
if (i) return ((e, t, n, a) => {
({
year: () => {
var t;
if ("multiple" === e.type) return null == (t = u(e).months) ? void 0 : t.select(e, "year", a);
g(e, "selectedYear", Number(a.dataset.vcYearsYear));
},
month: () => {
var t;
if ("multiple" === e.type) return null == (t = u(e).months) ? void 0 : t.select(e, "month", a);
g(e, "selectedMonth", Number(a.dataset.vcMonthsMonth));
}
})[n](), {
year: () => {
var n;
return null == (n = e.onClickYear) ? void 0 : n.call(e, e, t);
},
month: () => {
var n;
return null == (n = e.onClickMonth) ? void 0 : n.call(e, e, t);
}
}[n](), e.context.currentType === e.type ? we(e, a, n, !0, !0) : Ge(e, n);
})(e, t, n, i);
let s = a.closest("[data-vc=\"grid\"]"), c = a.closest("[data-vc=\"column\"]");
(e.context.currentType === n && l || "multiple" === e.type && e.context.currentType === n && s && !c) && Ge(e, n);
})(e, t, a);
});
})(e, t), null == (a = u(e).weeks) || a.collapseClick(e, t);
};
return e.context.mainElement.addEventListener("click", t), () => e.context.mainElement.removeEventListener("click", t);
};
var Ve = /* @__PURE__ */ new WeakMap();
var Je = (e, t) => {
let a = e[t].map((e) => e instanceof Date ? e.getTime() : e), l = Ve.get(e), o = null == l ? void 0 : l[t];
if (o && a.length === o.values.length) {
let e = 0;
for (; e < a.length && a[e] === o.values[e];) e++;
if (e === a.length && o.timezone === new Intl.DateTimeFormat().resolvedOptions().timeZone) return o.dates.slice();
}
let r = n(e[t]);
if (r.length > 1 && b(r), r.length > 128 && r.length <= 1e4 && a.length <= 1e4) {
let n = null == l ? {} : l;
n[t] = {
values: a,
dates: r.slice(),
timezone: new Intl.DateTimeFormat().resolvedOptions().timeZone
}, Ve.set(e, n);
} else l && delete l[t];
return r;
};
var Qe = (e, t) => "today" === e ? (() => {
let e = /* @__PURE__ */ new Date();
/* @__PURE__ */
return (/* @__PURE__ */ new Date(e.getTime() - 6e4 * e.getTimezoneOffset())).toISOString().substring(0, 10);
})() : e instanceof Date || "number" == typeof e || "string" == typeof e ? n([e])[0] : t;
var et = (e, t, n) => {
g(e, "selectedMonth", t), g(e, "selectedYear", n), g(e, "displayYear", n);
};
var tt = (t) => {
var a, l;
if (t.enableCollapse && !["default", "week"].includes(t.type)) throw Error("The «enableCollapse» parameter is only supported by the «default» and «week» calendar types.");
g(t, "currentType", t.type), ((e) => {
if ("multiple" === e.type && (e.displayMonthsCount <= 1 || e.displayMonthsCount > 12) || "multiple" !== e.type && e.displayMonthsCount > 1) throw Error("For the «multiple» calendar type, the «displayMonthsCount» parameter can have a value from 2 to 12, and for all others it cannot be greater than 1.");
g(e, "displayMonthsCount", e.displayMonthsCount ? e.displayMonthsCount : "multiple" === e.type ? 2 : 1);
})(t), ((t) => {
var n, a, l;
let o = Qe(t.dateMin, t.dateMin), r = Qe(t.dateMax, t.dateMax), i = Qe(t.displayDateMin, o), s = Qe(t.displayDateMax, r);
if (g(t, "dateToday", Qe(t.dateToday, t.dateToday)), g(t, "displayDateMin", i ? e(o) >= e(i) ? o : i : o), g(t, "displayDateMax", s ? e(r) <= e(s) ? r : s : r), g(t, "displayDateMin", t.disableDatesPast && !t.disableAllDates && e(i) < e(t.context.dateToday) || t.disableAllDates ? t.context.dateToday : i), g(t, "displayDateMax", t.disableAllDates ? t.context.dateToday : s), g(t, "disableDates", t.disableDates[0] && !t.disableAllDates ? Je(t, "disableDates") : t.disableAllDates ? [t.context.displayDateMin] : []), g(t, "enableDates", t.enableDates[0] ? Je(t, "enableDates") : []), null != (n = t.context.enableDates) && n[0] && null != (a = t.context.disableDates) && a[0]) {
let e = new Set(t.context.enableDates);
g(t, "disableDates", t.context.disableDates.filter((t) => !e.has(t)));
}
null != (l = t.context.enableDates) && l[0] && t.disableAllDates && (g(t, "displayDateMin", t.context.enableDates[0]), g(t, "displayDateMax", t.context.enableDates[t.context.enableDates.length - 1])), g(t, "dateMin", t.displayDisabledDates ? o : t.context.displayDateMin), g(t, "dateMax", t.displayDisabledDates ? r : t.context.displayDateMax);
})(t), ((t) => {
var a;
if (t.enableJumpToSelectedDate && null != (a = t.selectedDates) && a[0] && void 0 === t.selectedMonth && void 0 === t.selectedYear) {
let a = e(n(t.selectedDates)[0]);
et(t, a.getMonth(), a.getFullYear());
return;
}
if (((t) => {
let a = (e) => {
let n = new Date(e);
et(t, n.getMonth(), n.getFullYear());
};
return t.displayDateMin && "today" !== t.displayDateMin && (l = t.displayDateMin, o = /* @__PURE__ */ new Date(), new Date(l).getTime() > o.getTime()) ? (a(e(Qe(t.selectedDates.length && t.selectedDates[0] ? n(t.selectedDates)[0] : t.displayDateMin, t.displayDateMin))), !0) : !(!t.displayDateMax || "today" === t.displayDateMax || !((e, t) => new Date(e).getTime() < t.getTime())(t.displayDateMax, /* @__PURE__ */ new Date()) || (a(e(Qe(t.selectedDates.length && t.selectedDates[0] ? n(t.selectedDates)[0] : t.displayDateMax, t.displayDateMax))), 0));
var l, o;
})(t)) return;
let l = void 0 !== t.selectedMonth && Number(t.selectedMonth) >= 0 && Number(t.selectedMonth) < 12, o = void 0 !== t.selectedYear && Number(t.selectedYear) >= 0 && Number(t.selectedYear) <= 9999;
et(t, l ? Number(t.selectedMonth) : e(t.context.dateToday).getMonth(), o ? Number(t.selectedYear) : e(t.context.dateToday).getFullYear());
})(t), ((e) => {
var t;
g(e, "selectedDates", null != (t = e.selectedDates) && t[0] ? n(e.selectedDates) : []);
})(t), null == (a = u(t).weeks) || a.init(t), null == (l = u(t).time) || l.init(t);
};
var nt = (e, { year: t, month: n, dates: a, time: l, locale: o }, r = !0, i) => {
var s, c, d, m;
U(e);
let p = u(e);
null == (s = p.motion) || s.reset(e), null == (c = p.time) || c.destroy(e), null == (d = p.annotations) || d.destroy(e), D(e);
let h = {
year: e.selectedYear,
month: e.selectedMonth,
dates: e.selectedDates,
time: e.selectedTime
};
var v;
e.selectedYear = t ? h.year : e.context.selectedYear, e.selectedMonth = n ? h.month : e.context.selectedMonth, e.selectedTime = l ? h.time : e.context.selectedTime, e.selectedDates = "only-first" === a && null != (m = e.context.selectedDates) && m[0] ? [e.context.selectedDates[0]] : !0 === a ? h.dates : e.context.selectedDates, o && g(e, "locale", {
months: {
short: [],
long: []
},
weekdays: {
short: [],
long: []
}
}), tt(e), r && (i && Oe(e), i && i.structure === Z(e) ? ($e(e), null == (v = p.time) || v.render(e), Fe(e, !0)) : qe(e, !1)), e.selectedYear = h.year, e.selectedMonth = h.month, e.selectedDates = h.dates, e.selectedTime = h.time, "multiple-ranged" === e.selectionDatesMode && M(e, null, !!a), r && Q(e, !0);
};
var at = (e, t, n) => {
if (!e.context.isInit) throw Error(F);
m(e), nt(e, Le(Le({}, {
year: !0,
month: !0,
dates: !0,
time: !0,
locale: !0
}), t), !(e.inputMode && !e.context.inputModeInit), n), e.onUpdate && e.onUpdate(e);
};
var lt = [
"extensions",
"context",
"init",
"update",
"destroy",
"show",
"hide",
"set",
"queryAndMemoize"
];
var ot = (e, t, n = !0) => {
let a = Object.keys(t);
for (let l = 0; l < a.length; l++) {
let o = a[l];
"__proto__" !== o && "constructor" !== o && "prototype" !== o && (n && lt.includes(String(o)) || ("object" != typeof e[o] || null === e[o] || "object" != typeof t[o] || null === t[o] || t[o] instanceof Date || Array.isArray(t[o]) ? void 0 !== t[o] && (e[o] = t[o]) : ot(e[o], t[o], !1)));
}
};
var rt = {
application: "Calendar",
navigation: "Calendar Navigation",
arrowNext: {
month: "Next month",
year: "Next list of years",
week: "Next week"
},
arrowPrev: {
month: "Previous month",
year: "Previous list of years",
week: "Previous week"
},
month: "Select month, current selected month:",
months: "List of months",
year: "Select year, current selected year:",
years: "List of years",
week: "Days of the week",
weekNumber: "Numbers of weeks in a year",
collapse: "Collapse to a single week",
expand: "Expand to the whole month",
dates: "Dates in the current month",
selectingTime: "Selecting a time ",
inputHour: "Hours",
inputMinute: "Minutes",
rangeHour: "Slider for selecting hours",
rangeMinute: "Slider for selecting minutes",
btnKeeping: "Switch AM/PM, current position:"
};
var it = {
calendar: "vc",
controls: "vc-controls",
grid: "vc-grid",
column: "vc-column",
header: "vc-header",
headerContent: "vc-header__content",
month: "vc-month",
year: "vc-year",
arrowPrev: "vc-arrow vc-arrow_prev",
arrowNext: "vc-arrow vc-arrow_next",
wrapper: "vc-wrapper",
content: "vc-content",
months: "vc-months",
monthsRow: "vc-months__row",
monthsCell: "vc-months__cell",
monthsMonth: "vc-months__month",
years: "vc-years",
yearsRow: "vc-years__row",
yearsCell: "vc-years__cell",
yearsYear: "vc-years__year",
week: "vc-week",
weekDay: "vc-week__day",
weekDayBtn: "vc-week__day-btn",
weekNumbers: "vc-week-numbers",
weekNumbersTitle: "vc-week-numbers__title",
weekNumbersContent: "vc-week-numbers__content",
weekNumber: "vc-week-number",
collapse: "vc-collapse",
dates: "vc-dates",
datesRow: "vc-dates__row",
date: "vc-date",
dateBtn: "vc-date__btn",
datePopup: "vc-date__popup",
dateRangeTooltip: "vc-date-range-tooltip",
time: "vc-time",
timeContent: "vc-time__content",
timeHour: "vc-time__hour",
timeMinute: "vc-time__minute",
timeKeeping: "vc-time__keeping",
timeRanges: "vc-time__ranges",
timeRange: "vc-time__range"
};
var st = class {
constructor() {
Ne(this, "type", "default"), Ne(this, "inputMode", !1), Ne(this, "openOnFocus", !0), Ne(this, "positionToInput", "left"), Ne(this, "animation", !1), Ne(this, "firstWeekday", 1), Ne(this, "monthsToSwitch", 1), Ne(this, "themeAttrDetect", "html[data-theme]"), Ne(this, "locale", "en"), Ne(this, "dateToday", "today"), Ne(this, "dateMin", "1970-01-01"), Ne(this, "dateMax", "2470-12-31"), Ne(this, "displayDateMin", void 0), Ne(this, "displayDateMax", void 0), Ne(this, "displayDatesOutside", !0), Ne(this, "displayDisabledDates", !1), Ne(this, "displayMonthsCount", void 0), Ne(this, "disableDates", []), Ne(this, "disableAllDates", !1), Ne(this, "disableDatesPast", !1), Ne(this, "disableDatesGaps", !1), Ne(this, "disableWeekdays", []), Ne(this, "disableToday", !1), Ne(this, "enableDates", []), Ne(this, "enableEdgeDatesOnly", !0), Ne(this, "enableDateToggle", !0), Ne(this, "enableWeekNumbers", !1), Ne(this, "enableMonthChangeOnDayClick", !0), Ne(this, "enableJumpToSelectedDate", !1), Ne(this, "enableCollapse", !1), Ne(this, "enableSwipe", !1), Ne(this, "selectionDatesMode", "single"), Ne(this, "selectionMonthsMode", !0), Ne(this, "selectionYearsMode", !0), Ne(this, "selectionTimeMode", !1), Ne(this, "selectedDates", []), Ne(this, "selectedMonth", void 0), Ne(this, "selectedYear", void 0), Ne(this, "selectedHolidays", []), Ne(this, "selectedWeekends", [0, 6]), Ne(this, "selectedTime", void 0), Ne(this, "selectedTheme", "system"), Ne(this, "timeMinHour", 0), Ne(this, "timeMaxHour", 23), Ne(this, "timeMinMinute", 0), Ne(this, "timeMaxMinute", 59), Ne(this, "timeControls", "all"), Ne(this, "timeStepHour", 1), Ne(this, "timeStepMinute", 1), Ne(this, "sanitizerHTML", z), Ne(this, "onClickDate", void 0), Ne(this, "onClickWeekDay", void 0), Ne(this, "onClickWeekNumber", void 0), Ne(this, "onClickTitle", void 0), Ne(this, "onClickMonth", void 0), Ne(this, "onClickYear", void 0), Ne(this, "onClickArrow", void 0), Ne(this, "onChangeTime", void 0), Ne(this, "onChangeToInput", void 0), Ne(this, "onCreateDateRangeTooltip", void 0), Ne(this, "onCreateDateEls", void 0), Ne(this, "onCreateMonthEls", void 0), Ne(this, "onCreateYearEls", void 0), Ne(this, "onInit", void 0), Ne(this, "onUpdate", void 0), Ne(this, "onDestroy", void 0), Ne(this, "onShow", void 0), Ne(this, "onHide", void 0), Ne(this, "popups", {}), Ne(this, "labels", Le(Le({}, rt), {}, {
arrowNext: Le({}, rt.arrowNext),
arrowPrev: Le({}, rt.arrowPrev)
})), Ne(this, "layouts", {
default: "",
multiple: "",
month: "",
year: "",
week: ""
}), Ne(this, "styles", Le({}, it));
}
};
var pt = (e, t) => {
var n;
if ("multiple" !== e.type) return {
currentValue: null,
columnID: 0
};
let a = e.context.mainElement.querySelectorAll("[data-vc=\"column\"]"), l = Array.from(a).findIndex((e) => e.closest(`[data-vc-column="${t}"]`));
return {
currentValue: l >= 0 ? Number(null == (n = a[l].querySelector(`[data-vc="${t}"]`)) ? void 0 : n.getAttribute(`data-vc-${t}`)) : null,
columnID: Math.max(l, 0)
};
};
var ht = (e, t, n) => {
let { currentValue: a, columnID: l } = pt(e, t);
return "month" === e.context.currentType && l >= 0 ? n - l : "year" === e.context.currentType && e.context.selectedYear !== a ? n - 1 : n;
};
var vt = /* @__PURE__ */ Object.freeze({
name: "months",
layout: (e) => `\n \n <#ArrowPrev [month] />\n <#ArrowNext [month] />\n
\n \n <#Multiple>\n
\n \n
\n <#WeekNumbers />\n
\n <#Week />\n <#Dates />\n
\n
\n
\n <#/Multiple>\n <#DateRangeTooltip />\n
\n <#ControlTime />\n`,
render: (e, t) => {
var n;
if ("multiple" === e.context.currentType) return null == (n = u(e).time) || n.destroy(e), e.context.mainElement.innerHTML = e.sanitizerHTML(((e, t) => t.replace(RegExp("<#Multiple>(.*?)<#\\/Multiple>", "gs"), (t, n) => {
let a = Array(e.context.displayMonthsCount).fill(n).join("");
return e.sanitizerHTML(a);
}).replace(/[\n\t]/g, ""))(e, fe(e, e.layouts.multiple))), !0;
if ("multiple" !== e.type || !t) return !1;
let a = e.context.mainElement.querySelector("[data-vc=\"controls\"]"), l = e.context.mainElement.querySelector("[data-vc=\"grid\"]"), o = t.closest("[data-vc=\"column\"]");
return a && a.remove(), l && (l.dataset.vcGrid = "hidden"), o && (o.dataset.vcColumn = e.context.currentType), o && (o.innerHTML = e.sanitizerHTML(fe(e, e.layouts[e.context.currentType]))), !0;
},
column: pt,
select: (t, n, a) => "month" === n ? ((t, n) => {
let a = n.closest("[data-vc-column=\"month\"]").querySelector("[data-vc=\"year\"]"), l = ht(t, "month", Number(n.dataset.vcMonthsMonth)), o = Number(a.dataset.vcYear), r = e(t.context.dateMin), i = e(t.context.dateMax), s = l < r.getMonth() && o <= r.getFullYear(), c = l > i.getMonth() && o >= i.getFullYear();
g(t, "selectedYear", o), g(t, "selectedMonth", s ? r.getMonth() : c ? i.getMonth() : l);
})(t, a) : ((t, n) => {
let a = ht(t, "year", Number(n.dataset.vcYearsYear)), l = e(t.context.dateMin), o = e(t.context.dateMax), r = t.context.displayMonthsCount - 1, { columnID: i } = pt(t, "year"), s = t.context.selectedMonth < l.getMonth() && a <= l.getFullYear(), c = t.context.selectedMonth > o.getMonth() - r + i && a >= o.getFullYear(), d = a < l.getFullYear(), u = a > o.getFullYear(), m = s || d ? l.getFullYear() : c || u ? o.getFullYear() : a, p = s || d ? l.getMonth() : c || u ? o.getMonth() - r + i : t.context.selectedMonth;
g(t, "selectedYear", m), g(t, "selectedMonth", p);
})(t, a),
rotate: (e, t) => {
var n;
let a = 12 * e.context.selectedYear + e.context.selectedMonth - t.month;
if (!a || Math.abs(a) >= t.count) return;
let l = Array.from(e.context.mainElement.querySelectorAll("[data-vc=\"column\"]")), o = null == (n = l[0]) ? void 0 : n.parentElement;
if (!o || l.length !== t.count || l.some((e) => e.parentElement !== o) || Array.from(o.childNodes).some((e) => {
var t;
return 1 === e.nodeType ? !l.includes(e) : 3 !== e.nodeType || !(null == (t = e.textContent) || !t.trim());
})) return;
let r = [];
if (a > 0) {
let e = l[l.length - 1].nextSibling;
for (let n = 0; n < a; n++) {
let i = l[n].nextSibling;
3 === (null == i ? void 0 : i.nodeType) && i !== e && o.insertBefore(i, e), o.insertBefore(l[n], e), r.push(t.count - a + n);
}
} else for (let i = t.count + a; i < t.count; i++) {
let e = l[i].previousSibling;
o.insertBefore(l[i], l[0]), 3 === (null == e ? void 0 : e.nodeType) && o.insertBefore(e, l[0]), r.push(i - t.count - a);
}
return r;
}
});
var on = class e extends st {
constructor(t, n) {
var a;
super(), Ne(this, "extensions", void 0), Ne(this, "init", () => ((e) => {
var t;
if (e.context.isInit) throw Error("The calendar has already been initialized, calling init() again is not allowed. Create a new Calendar instance instead.");
if (m(e), g(e, "originalElement", e.context.mainElement.cloneNode(!0)), g(e, "isInit", !0), e.inputMode) {
let t = ((e) => {
g(e, "inputElement", e.context.mainElement);
let t = e.context.inputElement;
[
"input",
"button",
"textarea"
].includes(t.localName) && (t.setAttribute("aria-haspopup", "dialog"), ("button" === t.localName || "combobox" === t.getAttribute("role")) && t.setAttribute("aria-expanded", "false"));
let n = () => {
e.context.inputModeInit ? O(e) : ((e) => {
var t;
let n = document.createElement("div");
n.className = e.styles.calendar, n.dataset.vc = "calendar", n.dataset.vcInput = "", n.dataset.vcCalendarHidden = "", Object.assign(n.style, {
left: "0",
top: "0"
}), S(n);
let a = w(e.context.mainElement), l = a === document ? document.body : a;
g(e, "inputModeInit", !0), g(e, "isShowInInputMode", !1), g(e, "mainElement", n), l.appendChild(e.context.mainElement), nt(e, {
year: !0,
month: !0,
dates: !0,
time: !0,
locale: !0
}), O(e), e.onInit && e.onInit(e), e.context.isDestroyed || (Pe(e), null == (t = u(e).motion) || t.bind(e), Ze(e));
})(e);
};
e.context.inputElement.addEventListener("click", n);
let a = "function" == typeof e.openOnFocus || !0 === e.openOnFocus, l = () => {
((e) => E.has(e))(e) ? ((e) => {
E.delete(e);
})(e) : ((e) => f(e, e.openOnFocus))(e) && n();
};
a && e.context.inputElement.addEventListener("focus", l);
let o = (t) => {
let n = "Tab" === t.key && !t.shiftKey, a = [
"ArrowUp",
"ArrowDown",
"ArrowLeft",
"ArrowRight"
].includes(t.key);
(n || a) && ((t) => {
var n;
if (!e.context.isShowInInputMode || w(e.context.mainElement).activeElement !== e.context.inputElement) return !1;
let a = (e) => e.tabIndex >= 0 && !e.hasAttribute("disabled") && "true" !== e.getAttribute("aria-disabled"), l = null == (n = document.createTreeWalker(e.context.mainElement, NodeFilter.SHOW_ELEMENT, { acceptNode: (e) => a(e) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP }).nextNode()) ? a(e.context.mainElement) ? e.context.mainElement : null : n;
!l || l.tabIndex < 0 || (t.preventDefault(), l.focus());
})(t);
};
return e.context.inputElement.addEventListener("keydown", o), () => {
t.removeEventListener("click", n), a && t.removeEventListener("focus", l), t.removeEventListener("keydown", o);
};
})(e);
return g(e, "cleanupInput", t), t;
}
if (tt(e), qe(e), "multiple-ranged" === e.selectionDatesMode && 1 === e.context.selectedDates.length && (M(e, null), Fe(e)), e.onInit && e.onInit(e), !e.context.isDestroyed) return Pe(e), null == (t = u(e).motion) || t.bind(e), Ze(e);
})(this)), Ne(this, "update", (e) => at(this, e)), Ne(this, "destroy", () => {
let t = this.inputMode ? this.context.inputElement : this.context.mainElement;
if (((e) => {
var t, n, a, o, r, i, s, c;
if (!e.context.isInit) throw Error(F);
if (e.context.isDestroyed) throw Error("The calendar has already been destroyed, calling destroy() again is not allowed.");
B(e);
let d = u(e);
var m, p, h, v, y;
null == (t = d.motion) || t.destroy(e), null == (n = d.time) || n.destroy(e), null == (a = d.annotations) || a.destroy(e), D(e), ((e) => {
l.delete(e);
})(e), H(e), null == (o = (r = e.context).cleanupInput) || o.call(r), g(e, "cleanupInput", void 0), null == (i = e.context.cleanupHandlers) || i.forEach((e) => e()), g(e, "cleanupHandlers", []), g(e, "isShowInInputMode", !1), null == (s = (c = e.context).cleanupSystemTheme) || s.call(c), e.inputMode ? (e.context.mainElement !== e.context.inputElement && (null == (h = e.context.mainElement.parentElement) || h.removeChild(e.context.mainElement)), null == (m = e.context.inputElement) || null == (p = m.replaceWith) || p.call(m, e.context.originalElement), g(e, "inputElement", void 0)) : null == (v = (y = e.context.mainElement).replaceWith) || v.call(y, e.context.originalElement), g(e, "mainElement", e.context.originalElement), g(e, "isDestroyed", !0), e.onDestroy && e.onDestroy(e);
})(this), t) for (let [n, a] of e.memoizedElements) a === t && e.memoizedElements.delete(n);
}), Ne(this, "show", () => q(this)), Ne(this, "hide", () => $(this)), Ne(this, "set", (e, t) => ((e, t, n) => {
m(e, t);
let a = Object.keys(t);
t.extensions && a.splice(a.indexOf("extensions"), 1);
let l = 1 === a.length && "selectedDates" === a[0] ? J(e) : void 0;
ot(e, t), e.context.isInit && at(e, n, l);
})(this, e, t)), Ne(this, "context", void 0), this.context = Le(Le({}, this.context), {}, { locale: {
months: {
short: [],
long: []
},
weekdays: {
short: [],
long: []
}
} }), g(this, "mainElement", "string" == typeof t ? null == (a = e.memoizedElements.get(t)) ? this.queryAndMemoize(t) : a : t);
let o = null == n ? void 0 : n.extensions;
this.extensions = null != o && o.length ? Object.freeze(Array.from(new Set(o))) : d, ((e) => {
if (!e.extensions.length) return;
let t = {};
for (let n of e.extensions) {
let e = n, a = e.name;
if (!i.includes(a)) throw Error("Unknown calendar extension.");
if (t[a] && t[a] !== e) throw Error(`Conflicting calendar extension: ${a}.`);
Object.assign(t, { [a]: e });
}
s.set(e, t);
})(this), n && ot(this, n);
}
queryAndMemoize(t) {
let n = document.querySelector(t);
if (!n) throw Error(((e) => `${e} is not found, check the first argument passed to new Calendar. If the element lives inside a Shadow DOM, a string selector can't reach it - resolve the element yourself (e.g. shadowRoot.querySelector(...)) and pass it directly instead.`)(t));
return e.memoizedElements.set(t, n), n;
}
};
Ne(on, "memoizedElements", /* @__PURE__ */ new Map());
//#endregion
//#region js/src/datepicker.ts
/**
* --------------------------------------------------------------------------
* Bootstrap datepicker.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$14 = "datepicker";
const EVENT_KEY$11 = `.bs.datepicker`;
const DATA_API_KEY$6 = ".data-api";
const EVENT_CHANGE$1 = `change${EVENT_KEY$11}`;
const EVENT_SHOW$3 = `show${EVENT_KEY$11}`;
const EVENT_SHOWN$3 = `shown${EVENT_KEY$11}`;
const EVENT_HIDE$3 = `hide${EVENT_KEY$11}`;
const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$11}`;
const EVENT_FOCUSIN$3 = `focusin${EVENT_KEY$11}`;
const EVENT_POINTERDOWN$2 = `pointerdown${EVENT_KEY$11}`;
const EVENT_CLICK$4 = `click${EVENT_KEY$11}`;
const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$11}${DATA_API_KEY$6}`;
const EVENT_FOCUSIN_DATA_API = `focusin${EVENT_KEY$11}${DATA_API_KEY$6}`;
const SELECTOR_DATA_TOGGLE$6 = "[data-bs-toggle=\"datepicker\"]";
const EVENT_KEYDOWN$2 = `keydown${EVENT_KEY$11}`;
const FOCUSABLE = "a[href], button, input, select, textarea, [tabindex], [contenteditable=\"true\"]";
const Default$13 = {
datepickerTheme: null,
dateMin: null,
dateMax: null,
dateFormat: null,
displayElement: null,
displayMonthsCount: 1,
firstWeekday: 1,
invalidDateMessage: "Enter a valid date available in the calendar.",
inline: false,
showOnFocus: true,
toggleElement: null,
locale: "default",
positionElement: null,
selectedDates: [],
selectionMode: "single",
rangeEndMessage: "Choose an end date.",
placement: "left",
vcpOptions: {}
};
const DefaultType$13 = {
datepickerTheme: "(null|string)",
dateMin: "(null|string|number|object)",
dateMax: "(null|string|number|object)",
dateFormat: "(null|object|function)",
displayElement: "(null|string|element|boolean)",
displayMonthsCount: "number",
firstWeekday: "number",
inline: "boolean",
invalidDateMessage: "string",
showOnFocus: "boolean",
toggleElement: "(null|string|element)",
locale: "string",
positionElement: "(null|string|element)",
selectedDates: "array",
selectionMode: "string",
placement: "string",
rangeEndMessage: "string",
vcpOptions: "object"
};
const formBindings = /* @__PURE__ */ new WeakMap();
const bindFormData = (form, key, serialize) => {
let binding = formBindings.get(form);
if (!binding) {
const state = {
controls: /* @__PURE__ */ new Map(),
handler() {}
};
state.handler = (event) => {
const entries = [];
for (const [name, value] of event.formData) {
const control = state.controls.get(name);
if (!control) {
entries.push([name, value]);
continue;
}
const entry = control();
if (entry) entries.push(entry);
}
for (const name of new Set(event.formData.keys())) event.formData.delete(name);
for (const [name, value] of entries) event.formData.append(name, value);
};
binding = state;
formBindings.set(form, binding);
form.addEventListener("formdata", binding.handler, true);
}
binding.controls.set(key, serialize);
return () => {
binding.controls.delete(key);
if (binding.controls.size === 0) {
form.removeEventListener("formdata", binding.handler, true);
formBindings.delete(form);
}
};
};
/**
* Class definition
*/
var Datepicker = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._calendar = null;
this._toggleElement = null;
this._returnFocusElement = this._element;
this._originalToggleAria = /* @__PURE__ */ new Map();
this._popup = null;
this._isShown = false;
this._floatingCleanup = null;
this._resetTimeouts = /* @__PURE__ */ new Set();
this._suppressFocus = false;
this._positionGeneration = 0;
this._showGeneration = 0;
this._inputName = null;
this._inputObserver = null;
this._form = null;
this._formCleanup = null;
this._dialog = null;
this._initialDates = [];
this._rangeDates = [];
this._pendingRange = false;
this._rangeStatus = null;
this._inputError = null;
this._inputErrorMessage = "";
this._originalInvalid = null;
this._eventPending = false;
this._originalAria = new Map([
"aria-haspopup",
"aria-expanded",
"aria-controls"
].map((name) => [name, this._element.getAttribute(name)]));
try {
this._initCalendar();
} catch (error) {
this.dispose();
throw error;
}
}
static get Default() {
return Default$13;
}
static get DefaultType() {
return DefaultType$13;
}
static get NAME() {
return NAME$14;
}
toggle(relatedTarget) {
if (this._isInline) return Promise.resolve();
return this._isShown ? this.hide() : this.show(relatedTarget);
}
async show(relatedTarget) {
if (this._skipFocusTrigger(relatedTarget)) return;
if (!this._calendar || this._isInline || this._isShown || this._eventPending || this._suppressFocus || isDisabled(this._element) || this._element.matches(":disabled")) return;
if (this._triggerLifecycleEvent(EVENT_SHOW$3).defaultPrevented || !this._calendar || this._isShown) return;
this._popup.style.removeProperty("max-inline-size");
this._popup.style.removeProperty("max-block-size");
this._returnFocusElement = relatedTarget || this._element;
const generation = ++this._showGeneration;
this._isShown = true;
const popup = this._popup;
this._mountPopup();
this._syncDisplayMonths();
this._syncPopupState(this._calendar);
popup.removeAttribute("data-vc-calendar-closing");
if (typeof popup.showPopover === "function" && !popup.matches(":popover-open")) popup.showPopover();
this._element.setAttribute("aria-expanded", "true");
await this._updatePosition();
if (!this._isCurrentOpening(generation)) return;
this._floatingCleanup?.();
this._floatingCleanup = autoUpdate(this._positionElement, popup, () => {
this._syncDisplayMonths();
this._updatePosition();
});
if (!this._isInput || relatedTarget && relatedTarget !== this._element) this._focusCalendarDate();
await this._queueCallback(() => {
if (this._isCurrentOpening(generation)) EventHandler.trigger(this._element, EVENT_SHOWN$3);
}, popup, getTransitionDurationFromElement(popup) > 0);
}
async hide() {
if (!this._calendar || this._isInline || !this._isShown || this._eventPending) return;
if (this._triggerLifecycleEvent(EVENT_HIDE$3).defaultPrevented || !this._calendar) return;
const popup = this._popup;
const animated = getTransitionDurationFromElement(popup) > 0;
this._closePopup(animated);
const generation = this._showGeneration;
await this._queueCallback(() => {
if (this._calendar && !this._isShown && generation === this._showGeneration) {
this._finishPopupClose();
EventHandler.trigger(this._element, EVENT_HIDDEN$3);
}
}, popup, animated);
}
_triggerLifecycleEvent(name) {
this._eventPending = true;
try {
return EventHandler.trigger(this._element, name);
} finally {
this._eventPending = false;
}
}
_closePopup(animated = false) {
this._showGeneration++;
this._isShown = false;
this._positionGeneration++;
if (animated) this._popup?.setAttribute("data-vc-calendar-closing", "");
else this._finishPopupClose();
if (this._calendar) {
this._cancelPendingRange();
this._syncPopupState(this._calendar);
}
this._element?.setAttribute("aria-expanded", "false");
}
_finishPopupClose() {
this._floatingCleanup?.();
this._floatingCleanup = null;
if (this._popup?.matches(":popover-open")) this._popup.hidePopover();
this._popup?.removeAttribute("data-vc-calendar-closing");
}
dispose() {
this._syncBoundInput();
this._setInputError("");
if (this._onInvalid) this._element.removeEventListener("invalid", this._onInvalid);
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._closePopup();
this._themeObserver?.disconnect();
this._inputObserver?.disconnect();
this._formCleanup?.();
if (this._form && this._onReset) EventHandler.off(this._form, `reset${EVENT_KEY$11}`, this._onReset);
if (this._onOutside) {
EventHandler.off(document, EVENT_FOCUSIN$3, this._onOutside);
EventHandler.off(document, EVENT_POINTERDOWN$2, this._onOutside);
}
if (this._onKeydown) {
EventHandler.off(this._element, EVENT_KEYDOWN$2, this._onKeydown);
this._popup?.removeEventListener("keydown", this._onKeydown, true);
}
if (this._toggleElement) {
EventHandler.off(this._toggleElement, EVENT_CLICK$4, this._onToggleClick);
EventHandler.off(this._toggleElement, EVENT_KEYDOWN$2, this._onKeydown);
this._restoreAria(this._toggleElement, this._originalToggleAria);
}
if (this._onTriggerClick) EventHandler.off(this._positionElement, EVENT_CLICK$4, this._onTriggerClick);
if (this._dialog) EventHandler.off(this._dialog, "close", this._onDialogClose);
if (this._calendar?.context.isInit) {
this._calendar.destroy();
this._calendar.context.mainElement.remove();
} else this._popup?.remove();
if (this._inputName !== null) {
this._element.setAttribute("name", this._inputName);
this._boundInput?.remove();
}
this._restoreAria(this._element, this._originalAria);
this._calendar = null;
super.dispose();
}
getSelectedDates() {
const dates = this._config?.selectionMode === "multiple-ranged" ? this._rangeDates : this._calendar?.context.selectedDates;
return dates ? [...dates] : [];
}
setSelectedDates(dates) {
if (this._calendar) {
for (const date of dates) if (typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date) && !this._parseIsoDate(date)) throw new TypeError("Invalid ISO date");
this._pendingRange = false;
this._calendar.set({ selectedDates: dates });
this._rangeDates = [...this._calendar.context.selectedDates];
this._syncSelectedDates(this.getSelectedDates());
}
}
_getConfig(config) {
return super._getConfig({
vcpOptions: Default$13.vcpOptions,
...config
});
}
_isCurrentOpening(generation) {
return Boolean(this._calendar) && this._isShown && generation === this._showGeneration;
}
_skipFocusTrigger(relatedTarget) {
return this._isInput && relatedTarget === this._element && !this._config.showOnFocus;
}
_containsTrigger(target) {
return this._positionElement.contains(target) || this._element.contains(target) || Boolean(this._toggleElement?.contains(target));
}
_restoreAria(element, original) {
for (const [name, value] of original) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
}
_initCalendar() {
this._isInput = this._element.tagName === "INPUT";
this._isInline = this._config.inline;
if (this._isInline && !this._isInput) this._boundInput = this._element.querySelector("input[type=\"hidden\"], input[name]");
if (this._isInput && !this._isInline && this._config.toggleElement) {
const root = this._element.getRootNode();
this._toggleElement = typeof this._config.toggleElement === "string" ? root.querySelector(this._config.toggleElement) : this._config.toggleElement;
if (this._toggleElement === this._element) throw new TypeError("The Datepicker toggle must be separate from its input");
if (this._toggleElement) this._originalToggleAria = new Map([
"aria-haspopup",
"aria-expanded",
"aria-controls"
].map((name) => [name, this._toggleElement.getAttribute(name)]));
}
this._positionElement = this._resolvePositionElement();
this._displayElement = this._resolveDisplayElement();
const display = this._displayElement;
this._displayPlaceholder = display && this._element.contains(display) && display.hasAttribute("data-bs-datepicker-display") ? display.textContent : "";
this._popup = document.createElement("div");
if (this._isInline) this._element.append(this._popup);
else {
this._popup.id = getUID("bs-datepicker-calendar-");
this._popup.setAttribute("popover", "manual");
this._element.setAttribute("aria-haspopup", "dialog");
this._element.setAttribute("aria-expanded", "false");
this._element.setAttribute("aria-controls", this._popup.id);
if (this._toggleElement) {
this._toggleElement.setAttribute("aria-haspopup", "dialog");
this._toggleElement.setAttribute("aria-controls", this._popup.id);
}
this._mountPopup();
}
this._calendar = new on(this._popup, this._buildCalendarOptions());
this._calendar.init();
this._rangeDates = [...this._calendar.context.selectedDates];
if (this._isInput && this._element.value && (!this._element.readOnly || !this._rangeDates.length)) this._parseInputValue();
this._initialDates = this.getSelectedDates();
if (this._isInput && !this._isInline) {
this._createBoundInput();
this._bindInputForm();
EventHandler.on(this._element, `input${EVENT_KEY$11}`, () => this._parseInputValue());
this._onInvalid = () => this._showInputError();
EventHandler.on(this._element, `blur${EVENT_KEY$11}`, this._onInvalid);
this._element.addEventListener("invalid", this._onInvalid);
}
this._updateDisplayWithSelectedDates();
if (this._isInline && this._boundInput) this._bindInputForm();
this._setupThemeObserver();
this._setupDismiss();
}
_createBoundInput() {
const name = this._element.getAttribute("name");
if (!name) return;
this._inputName = name;
this._boundInput = document.createElement("input");
this._boundInput.type = "hidden";
this._boundInput.id = getUID("bs-datepicker-");
this._boundInput.name = this._boundInput.id;
this._element.before(this._boundInput);
this._element.removeAttribute("name");
this._syncBoundInput();
this._inputObserver = new MutationObserver(() => {
this._syncBoundInput();
this._bindInputForm();
});
this._inputObserver.observe(this._element, {
attributes: true,
attributeFilter: [
"name",
"disabled",
"form"
]
});
}
_syncBoundInput() {
if (this._inputName === null || !this._boundInput) return;
const name = this._element.getAttribute("name");
if (name !== null) {
this._inputName = name;
this._element.removeAttribute("name");
}
const form = this._element.getAttribute("form");
if (form === null) this._boundInput.removeAttribute("form");
else this._boundInput.setAttribute("form", form);
this._boundInput.value = this.getSelectedDates().join(",");
}
_bindInputForm() {
const form = this._isInput ? this._element.form : this._boundInput?.form ?? null;
if (form === this._form) return;
this._formCleanup?.();
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._resetTimeouts.clear();
if (this._form) EventHandler.off(this._form, `reset${EVENT_KEY$11}`, this._onReset);
this._form = form;
if (!form) return;
if (this._inputName !== null && this._boundInput) this._formCleanup = bindFormData(form, this._boundInput.name, () => {
this._syncBoundInput();
return this._element.matches(":disabled") || isDisabled(this._element) || !this._inputName ? null : [this._inputName, this.getSelectedDates().join(",")];
});
this._onReset = (event) => {
const timeout = setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!event.defaultPrevented && this._calendar && event.target === this._form) this.setSelectedDates(this._initialDates);
}, 0);
this._resetTimeouts.add(timeout);
};
EventHandler.on(form, `reset${EVENT_KEY$11}`, this._onReset);
}
_mountPopup() {
let ancestor = this._element;
let dialog = null;
while (ancestor && !dialog) {
dialog = ancestor.closest("dialog[open]");
const root = ancestor.getRootNode();
ancestor = root instanceof ShadowRoot ? root.host : null;
}
if (dialog !== this._dialog) {
if (this._dialog) EventHandler.off(this._dialog, "close", this._onDialogClose);
this._dialog = dialog;
this._onDialogClose = () => this._closePopup();
if (dialog) EventHandler.on(dialog, "close", this._onDialogClose);
}
const root = this._element.getRootNode();
const parent = root instanceof ShadowRoot ? root : dialog || document.body;
if (this._popup.parentNode !== parent) parent.append(this._popup);
}
async _updatePosition() {
const popup = this._popup;
if (!popup || !this._isShown && !popup.hasAttribute("data-vc-calendar-closing")) return;
const generation = ++this._positionGeneration;
const left = popup.dir === "rtl" ? "-end" : "-start";
const right = popup.dir === "rtl" ? "-start" : "-end";
const alignment = this._config.placement === "center" ? "" : this._config.placement === "right" ? right : left;
const result = await computePosition(this._positionElement, popup, {
placement: `bottom${alignment}`,
strategy: "fixed",
middleware: [
offset(4),
flip({ padding: 8 }),
shift({
padding: 8,
crossAxis: true
}),
size({
padding: 8,
apply: ({ availableWidth, availableHeight, elements }) => {
if (generation === this._positionGeneration) Object.assign(elements.floating.style, {
maxInlineSize: `${Math.max(0, availableWidth)}px`,
maxBlockSize: `${Math.max(0, availableHeight)}px`
});
}
})
]
});
if (generation !== this._positionGeneration || !this._isShown && !popup.hasAttribute("data-vc-calendar-closing")) return;
Object.assign(popup.style, {
position: result.strategy,
left: `${result.x}px`,
top: `${result.y}px`
});
popup.dataset.vcPosition = result.placement.startsWith("top") ? "top" : "bottom";
}
_getCalendarLabel() {
const root = this._element.getRootNode();
const label = this._element.getAttribute("aria-labelledby")?.trim().split(/\s+/).map((id) => {
const label = root.getElementById?.(id);
return label?.hasAttribute("data-bs-datepicker-display") ? "" : label?.textContent.trim();
}).filter(Boolean).join(" ") || this._element.getAttribute("aria-label");
if (label) return label;
if (this._isInput) return [...this._element.labels || []].map((label) => label.textContent.trim()).filter(Boolean).join(" ");
return "";
}
_getDisplayMonths() {
const { displayMonthsCount } = this._config;
return displayMonthsCount > 1 && !this._isInline && window.matchMedia("(width < 576px)").matches ? 1 : displayMonthsCount;
}
_syncDisplayMonths() {
const calendar = this._calendar;
const count = this._getDisplayMonths();
if (!calendar || calendar.displayMonthsCount === count) return;
const root = this._popup.getRootNode();
const hadFocus = this._popup.contains(root.activeElement);
calendar.set({
type: count > 1 ? "multiple" : "default",
displayMonthsCount: count,
selectedDates: [...calendar.context.selectedDates]
}, {
month: false,
year: false
});
if (hadFocus) this._focusCalendarDate();
}
_syncPopupState(self) {
this._normalizeRangeDates(self);
const popup = self.context.mainElement;
if (!this._isInline) {
popup.dataset.vcInput = "";
popup.role = "dialog";
const label = this._getCalendarLabel();
if (label) popup.setAttribute("aria-label", label);
popup.toggleAttribute("data-vc-calendar-hidden", !this._isShown);
popup.inert = !this._isShown;
popup.setAttribute("aria-hidden", String(!this._isShown));
this._toggleElement?.setAttribute("aria-expanded", String(this._isShown));
}
if (this._config.selectionMode === "multiple-ranged") {
this._rangeStatus ??= document.createElement("span");
if (!popup.contains(this._rangeStatus)) {
this._rangeStatus.className = "visually-hidden";
this._rangeStatus.setAttribute("role", "status");
popup.append(this._rangeStatus);
}
this._updateRangeStatus();
}
this._syncThemeAttribute(popup);
}
_updateRangeStatus() {
const message = this._pendingRange ? this._config.rangeEndMessage : "";
if (this._rangeStatus && this._rangeStatus.textContent !== message) this._rangeStatus.textContent = message;
}
_updateDisplayWithSelectedDates() {
const selectedDates = this.getSelectedDates();
if (selectedDates.length > 0) this._syncSelectedDates(selectedDates);
}
_syncSelectedDates(selectedDates) {
this._setInputError("");
const formattedDate = this._formatDateForInput(selectedDates);
if (this._isInput) this._element.value = formattedDate;
if (this._boundInput) {
this._boundInput.value = selectedDates.join(",");
this._syncBoundInput();
}
this._syncDisplay(selectedDates, formattedDate);
}
_syncDisplay(selectedDates, formattedDate = this._formatDateForInput(selectedDates)) {
if (this._displayElement) {
const endPlaceholder = this._displayElement.dataset.bsDatepickerEndPlaceholder;
const partialRange = this._config.selectionMode === "multiple-ranged" && selectedDates.length === 1;
this._displayElement.textContent = partialRange && endPlaceholder ? `${formattedDate} – ${endPlaceholder}` : selectedDates.length ? formattedDate : this._displayPlaceholder;
}
}
_resolvePositionElement() {
let { positionElement } = this._config;
if (typeof positionElement === "string") positionElement = this._element.getRootNode().querySelector(positionElement);
if (!positionElement && this._isInput && !this._isInline) {
const parent = this._element.closest(".form-adorn");
if (parent) positionElement = parent;
}
return positionElement || this._element;
}
_resolveDisplayElement() {
const { displayElement } = this._config;
if (typeof displayElement === "string") return this._element.getRootNode().querySelector(displayElement);
if (displayElement === true || displayElement === null && !this._isInput && !this._isInline) return this._element.querySelector("[data-bs-datepicker-display]") || this._element;
return displayElement;
}
_getThemeAncestor() {
return this._element.closest("[data-bs-theme]");
}
_getEffectiveTheme() {
return this._config.datepickerTheme || this._getThemeAncestor()?.getAttribute("data-bs-theme") || null;
}
_syncThemeAttribute(element) {
if (!element) return;
const theme = this._getEffectiveTheme();
if (theme) element.setAttribute("data-bs-theme", theme);
else element.removeAttribute("data-bs-theme");
const computed = getComputedStyle(this._element);
element.dir = computed.direction;
const explicit = this._config.datepickerTheme;
element.style.colorScheme = explicit === "auto" ? "light dark" : explicit === "light" || explicit === "dark" ? explicit : computed.colorScheme;
if (!this._isInline) for (const prefix of ["", "bs-"]) for (const role of [
"base",
"bg",
"bg-subtle",
"bg-muted",
"fg",
"fg-emphasis",
"contrast",
"border",
"focus-ring"
]) {
const property = `--${prefix}theme-${role}`;
const value = computed.getPropertyValue(property);
if (value) element.style.setProperty(property, value);
else element.style.removeProperty(property);
}
}
_setupThemeObserver() {
this._themeObserver = new MutationObserver((records) => {
if (records.some((record) => {
if (!(record.target instanceof Element)) return false;
let node = this._element;
while (node) {
if (record.target.contains(node)) return true;
const root = node.getRootNode();
node = root instanceof ShadowRoot ? root.host : null;
}
return false;
})) this._syncThemeAttribute(this._popup ?? void 0);
});
const root = this._element.getRootNode();
const options = {
subtree: true,
attributes: true,
attributeFilter: [
"data-bs-theme",
"class",
"style",
"dir"
]
};
this._themeObserver.observe(document.documentElement, options);
if (root instanceof ShadowRoot) this._themeObserver.observe(root, options);
}
_setupDismiss() {
this._onKeydown = (event) => this._handleKeydown(event);
this._popup?.addEventListener("keydown", this._onKeydown, true);
if (this._isInline) return;
this._onTriggerClick = (event) => {
if (event.target instanceof Node && this._toggleElement?.contains(event.target)) return;
if (this._isInput) this.show(this._element);
else if (this._element.dataset.bsToggle !== NAME$14) this.toggle();
};
EventHandler.on(this._positionElement, EVENT_CLICK$4, this._onTriggerClick);
if (this._isInput) EventHandler.on(this._element, EVENT_FOCUSIN$3, () => this.show(this._element));
this._onOutside = (event) => {
if (!this._isShown) return;
if (!event.composedPath().some((node) => node instanceof Node && (this._positionElement.contains(node) || this._element.contains(node) || this._toggleElement?.contains(node) || this._popup?.contains(node)))) this.hide();
};
EventHandler.on(document, EVENT_FOCUSIN$3, this._onOutside);
EventHandler.on(document, EVENT_POINTERDOWN$2, this._onOutside);
EventHandler.on(this._element, EVENT_KEYDOWN$2, this._onKeydown);
if (this._toggleElement) {
this._onToggleClick = () => {
if (!isDisabled(this._toggleElement) && !this._toggleElement.matches(":disabled")) this.toggle(this._toggleElement);
};
EventHandler.on(this._toggleElement, EVENT_CLICK$4, this._onToggleClick);
EventHandler.on(this._toggleElement, EVENT_KEYDOWN$2, this._onKeydown);
}
}
_focusCalendarDate() {
for (const selector of [
"[data-vc-date-selected] [data-vc-date-btn]",
"[data-vc-date-today] [data-vc-date-btn]",
"[data-vc-date-btn][tabindex=\"0\"]",
"button"
]) {
const control = [...this._popup?.querySelectorAll(selector) || []].find((element) => !isDisabled(element) && isVisible(element));
if (control) {
control.focus();
return;
}
}
}
_focusTrigger() {
if (!this._element) return;
this._suppressFocus = true;
(this._returnFocusElement?.isConnected ? this._returnFocusElement : this._element).focus();
this._suppressFocus = false;
}
_handleKeydown(event) {
const { target } = event;
if (!this._isShown && !this._isInline || !(target instanceof Node) || !this._containsTrigger(target) && !this._popup?.contains(target)) return;
if (this._handleCalendarNavigation(event)) {
event.preventDefault();
event.stopPropagation();
return;
}
if (this._isInline) {
this._handleInlineEscape(event);
return;
}
if (event.key === "Escape") {
event.preventDefault();
event.stopPropagation();
this.hide();
if (!this._isShown) this._focusTrigger();
return;
}
if (event.key !== "Tab") return;
const controls = [...this._popup.querySelectorAll(FOCUSABLE)].filter((element) => element.tabIndex >= 0 && !isDisabled(element) && isVisible(element));
if (this._containsTrigger(target)) {
if (!event.shiftKey && controls[0]) {
event.preventDefault();
controls[0].focus();
} else this.hide();
return;
}
if (target === (event.shiftKey ? controls[0] : controls.at(-1))) {
this.hide();
if (this._isShown) event.preventDefault();
else {
this._focusTrigger();
if (event.shiftKey) event.preventDefault();
}
}
}
_handleInlineEscape(event) {
if (event.key !== "Escape" || !this._pendingRange) return;
event.preventDefault();
event.stopPropagation();
const date = event.target.closest("[data-vc-date]")?.dataset.vcDate;
this._cancelPendingRange();
const control = date && this._findCalendarDay(date);
if (control) this._focusDay(control);
else this._focusCalendarDate();
}
_findCalendarDay(date) {
return this._popup?.querySelector(`[data-vc-date="${date}"][data-vc-date-month="current"] [data-vc-date-btn]:not(:disabled)`) ?? null;
}
_focusDay(day) {
day.closest("[role=\"grid\"]")?.querySelectorAll("[data-vc-date-btn][tabindex=\"0\"]").forEach((control) => {
control.tabIndex = -1;
});
day.tabIndex = 0;
day.focus();
}
_handleCalendarNavigation(event) {
const { target } = event;
if (!this._calendar || !(target instanceof HTMLElement) || !target.matches("[data-vc-date-btn]") || event.altKey || event.ctrlKey || event.metaKey) return false;
const day = target.closest("[data-vc-date]");
const date = this._parseIsoDate(day?.dataset.vcDate || "");
if (!date) return false;
const { key } = event;
const page = key === "PageUp" || key === "PageDown";
const week = key === "Home" || key === "End";
if (!page && !week && !key.startsWith("Arrow")) return false;
const currentMonth = date.getMonth();
let direction;
if (page) {
direction = key === "PageUp" ? -1 : 1;
const dayOfMonth = date.getDate();
date.setDate(1);
date.setMonth(currentMonth + (event.shiftKey ? 12 : 1) * direction);
const monthEnd = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
date.setDate(Math.min(dayOfMonth, monthEnd));
} else if (week) {
const weekday = (date.getDay() - this._config.firstWeekday + 7) % 7;
date.setDate(date.getDate() + (key === "Home" ? -weekday : 6 - weekday));
direction = key === "Home" ? 1 : -1;
} else {
const rtl = this._popup?.dir === "rtl";
const step = {
ArrowLeft: rtl ? 1 : -1,
ArrowRight: rtl ? -1 : 1,
ArrowUp: -7,
ArrowDown: 7
}[key];
if (!step) return false;
date.setDate(date.getDate() + step);
if (date.getMonth() === currentMonth && day?.dataset.vcDateMonth === "current") return false;
direction = Math.sign(step);
}
this._focusNavigationDate(date, direction, target);
return true;
}
_focusNavigationDate(date, direction, target) {
const calendar = this._calendar;
const { displayDateMin, displayDateMax } = calendar.context;
let iso = this._toIsoDate(date);
if (iso < displayDateMin) iso = displayDateMin;
else if (iso > displayDateMax) iso = displayDateMax;
date = this._parseIsoDate(iso) || date;
const month = date.getMonth();
if (!this._findCalendarDay(iso) && (month !== calendar.context.selectedMonth || date.getFullYear() !== calendar.context.selectedYear)) calendar.set({
selectedMonth: month,
selectedYear: date.getFullYear(),
selectedDates: [...calendar.context.selectedDates]
});
let control = this._findCalendarDay(iso);
while (!control && date.getMonth() === month) {
date.setDate(date.getDate() + direction);
if (date.getMonth() === month) control = this._findCalendarDay(this._toIsoDate(date));
}
if (control) this._focusDay(control);
else if (!target.isConnected) this._focusCalendarDate();
}
_buildCalendarOptions() {
const theme = this._getEffectiveTheme();
const vcpTheme = !theme || theme === "auto" ? "system" : theme;
const displayMonthsCount = this._getDisplayMonths();
const calendarOptions = {
...this._config.vcpOptions,
extensions: [vt],
inputMode: false,
positionToInput: this._config.placement,
firstWeekday: this._config.firstWeekday,
locale: this._config.vcpOptions.locale ?? this._config.locale,
selectionDatesMode: this._config.selectionMode,
selectedDates: this._config.selectedDates,
displayMonthsCount,
type: displayMonthsCount > 1 ? "multiple" : "default",
selectedTheme: vcpTheme,
themeAttrDetect: "[data-bs-theme]",
onClickDate: (self, event) => this._handleDateClick(self, event),
onInit: (self) => this._syncPopupState(self),
onUpdate: (self) => this._syncPopupState(self)
};
if (this._config.selectedDates.length > 0) {
const firstDate = this._parseIsoDate(this._config.selectedDates[0]);
if (!firstDate) throw new TypeError("Invalid ISO date");
calendarOptions.selectedMonth = firstDate.getMonth();
calendarOptions.selectedYear = firstDate.getFullYear();
}
if (this._config.dateMin) calendarOptions.dateMin = this._config.dateMin;
if (this._config.dateMax) calendarOptions.dateMax = this._config.dateMax;
return calendarOptions;
}
_normalizeRangeDates(self) {
if (this._config.selectionMode === "multiple-ranged" && self.context.selectedDates.length && !self.context.selectedDates[0]) self.context.selectedDates.length = 0;
}
_cancelPendingRange() {
if (!this._pendingRange || !this._calendar) return;
this._pendingRange = false;
this._calendar.set({ selectedDates: this._rangeDates }, {
month: false,
year: false
});
this._syncDisplay(this._rangeDates);
}
_handleDateClick(self, event) {
this._normalizeRangeDates(self);
const selectedDates = [...self.context.selectedDates];
if (this._config.selectionMode === "multiple-ranged") {
if (selectedDates.length === 1) {
this._pendingRange = true;
this._updateRangeStatus();
this._syncDisplay(selectedDates);
return;
}
if (this._pendingRange && selectedDates.length === 0) {
this._cancelPendingRange();
return;
}
this._pendingRange = false;
this._rangeDates = selectedDates;
this._updateRangeStatus();
}
this._syncSelectedDates(selectedDates);
EventHandler.trigger(this._element, EVENT_CHANGE$1, {
dates: selectedDates,
event
});
if (this._calendar && this._element) this._maybeHideAfterSelection(selectedDates);
}
_maybeHideAfterSelection(selectedDates) {
if (this._isInline) return;
if (this._config.selectionMode === "single" && selectedDates.length > 0 || this._config.selectionMode === "multiple-ranged" && selectedDates.length >= 2) {
const root = this._popup.getRootNode();
const wasInCalendar = this._popup?.contains(root.activeElement);
this.hide();
const active = root.activeElement;
if (!this._isShown && this._calendar && wasInCalendar && (active === document.body || this._popup?.contains(active))) this._focusTrigger();
}
}
_parseIsoDate(value) {
const parts = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
if (!parts) return null;
const year = Number(parts[1]);
const month = Number(parts[2]) - 1;
const day = Number(parts[3]);
const date = /* @__PURE__ */ new Date(0);
date.setHours(0, 0, 0, 0);
date.setFullYear(year, month, day);
return date.getFullYear() === year && date.getMonth() === month && date.getDate() === day ? date : null;
}
_parseDate(value) {
return this._parseIsoDate(value) ?? /* @__PURE__ */ new Date(NaN);
}
_toIsoDate(date) {
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
}
_formatDate(dateStr) {
const date = this._parseDate(dateStr);
const locale = this._config.locale === "default" ? void 0 : this._config.locale;
const { dateFormat } = this._config;
if (typeof dateFormat === "function") return dateFormat(date, locale);
if (dateFormat && typeof dateFormat === "object") return new Intl.DateTimeFormat(locale, dateFormat).format(date);
return date.toLocaleDateString(locale);
}
_formatDateForInput(dates) {
if (dates.length === 0) return "";
if (dates.length === 1) return this._formatDate(dates[0]);
const separator = this._config.selectionMode === "multiple-ranged" ? " – " : ", ";
return dates.map((d) => this._formatDate(d)).join(separator);
}
_setInputError(message) {
if (!this._isInput) return;
const input = this._element;
if (!input.validity.customError || input.validationMessage === this._inputErrorMessage) input.setCustomValidity(message);
this._inputErrorMessage = message;
if (!message && this._inputError) {
const descriptions = (input.getAttribute("aria-describedby") || "").split(/\s+/).filter((id) => id && id !== this._inputError.id);
if (descriptions.length) input.setAttribute("aria-describedby", descriptions.join(" "));
else input.removeAttribute("aria-describedby");
if (this._originalInvalid === null) input.removeAttribute("aria-invalid");
else input.setAttribute("aria-invalid", this._originalInvalid);
this._inputError.remove();
this._inputError = null;
}
}
_showInputError() {
if (!this._inputErrorMessage || this._inputError) return;
const error = document.createElement("div");
error.id = getUID("bs-datepicker-error-");
error.className = "form-text fg-danger";
error.setAttribute("role", "status");
this._positionElement.after(error);
error.textContent = this._inputErrorMessage;
this._inputError = error;
this._originalInvalid = this._element.getAttribute("aria-invalid");
this._element.setAttribute("aria-invalid", "true");
const describedBy = this._element.getAttribute("aria-describedby");
this._element.setAttribute("aria-describedby", describedBy ? `${describedBy} ${error.id}` : error.id);
}
_parseInputValue() {
this._pendingRange = false;
const value = this._element.value.trim();
let date = this._parseIsoDate(value);
if (!date && !/^\d{4}-/.test(value) && typeof this._config.dateFormat !== "function") {
const numbers = value.match(/\d+/g);
const locale = this._config.locale === "default" ? void 0 : this._config.locale;
const order = new Intl.DateTimeFormat(locale, this._config.dateFormat ?? void 0).formatToParts(new Date(2e3, 0, 1)).filter((part) => [
"year",
"month",
"day"
].includes(part.type));
if (numbers?.length === 3 && order.length === 3) {
const parts = Object.fromEntries(order.map((part, index) => [part.type, numbers[index]]));
if (parts.year.length === 4) {
const iso = `${parts.year}-${parts.month.padStart(2, "0")}-${parts.day.padStart(2, "0")}`;
const candidate = this._parseIsoDate(iso);
if (candidate && this._formatDate(iso) === value) date = candidate;
}
}
}
const dates = date && this._config.selectionMode !== "multiple-ranged" ? [this._toIsoDate(date)] : [];
this._calendar?.set({
selectedDates: dates,
...date ? {
selectedMonth: date.getMonth(),
selectedYear: date.getFullYear()
} : {}
});
if (dates.length && this._calendar) {
const button = this._popup?.querySelector(`[data-vc-date="${dates[0]}"] [data-vc-date-btn]`);
if (!button || isDisabled(button)) this._calendar.set({ selectedDates: [] });
}
this._rangeDates = [...this._calendar?.context.selectedDates || []];
this._setInputError(this._element.value && this.getSelectedDates().length === 0 ? this._config.invalidDateMessage : "");
this._syncBoundInput();
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$6, function(event) {
if (this.tagName === "INPUT" || this.dataset.bsInline === "true") return;
event.preventDefault();
Datepicker.getOrCreateInstance(this).toggle(this);
});
EventHandler.on(document, EVENT_FOCUSIN_DATA_API, SELECTOR_DATA_TOGGLE$6, function() {
if (this.tagName !== "INPUT") return;
Datepicker.getOrCreateInstance(this).show(this);
});
onDocumentReady(`DOMContentLoaded${EVENT_KEY$11}${DATA_API_KEY$6}`, () => {
const selector = [
`${SELECTOR_DATA_TOGGLE$6}[data-bs-inline="true"]`,
`${SELECTOR_DATA_TOGGLE$6}[data-bs-selected-dates]`,
`input${SELECTOR_DATA_TOGGLE$6}[value]:not([value=""])`,
`input${SELECTOR_DATA_TOGGLE$6}[data-bs-toggle-element]`
].join(", ");
for (const element of document.querySelectorAll(selector)) Datepicker.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/scroll-lock.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/scroll-lock.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const CLASS_NAME_OPEN = "dialog-open";
const SELECTOR_FIXED_CONTENT = ".fixed-top, .fixed-bottom, .is-fixed";
const owners = /* @__PURE__ */ new Map();
let restore = null;
let observer = null;
const getStyleChange = (element, property, offset) => {
const value = Number.parseFloat(getComputedStyle(element).getPropertyValue(property)) || 0;
return {
element,
property,
value: element.style.getPropertyValue(property),
priority: element.style.getPropertyPriority(property),
adjustedValue: `${value + offset}px`
};
};
const releaseUnusedLock = () => {
for (const [owner, onDetach] of owners) if (!owner.isConnected) {
owners.delete(owner);
if (onDetach) queueMicrotask(onDetach);
} else if (!owner.open) owners.delete(owner);
if (owners.size === 0 && restore) {
observer?.disconnect();
observer = null;
restore();
restore = null;
}
};
const lockScroll = (owner, onDetach) => {
releaseUnusedLock();
if (owners.has(owner)) return;
owners.set(owner, onDetach);
if (owners.size > 1) return;
const root = document.documentElement;
const alreadyLocked = root.classList.contains(CLASS_NAME_OPEN);
const initialWidth = root.offsetWidth;
const viewportWidth = root.clientWidth;
const initialLeft = root.getBoundingClientRect().left + root.clientLeft + window.scrollX;
const changes = [];
const fixed = SelectorEngine.find(SELECTOR_FIXED_CONTENT).filter((element) => !element.closest("dialog") && getComputedStyle(element).position === "fixed" && element.clientWidth >= viewportWidth).map((element) => ({
element,
width: element.offsetWidth
}));
root.classList.add(CLASS_NAME_OPEN);
const width = Math.max(0, root.offsetWidth - initialWidth);
const side = initialLeft > root.getBoundingClientRect().left + root.clientLeft + window.scrollX ? "left" : "right";
const fixedChanges = fixed.map((item) => ({
element: item.element,
width: Math.max(0, item.element.offsetWidth - item.width)
}));
if (width > 0) changes.push(getStyleChange(root, `padding-${side}`, width));
for (const item of fixedChanges) if (item.width > 0) changes.push(getStyleChange(item.element, `margin-${side}`, item.width));
for (const { element, property, adjustedValue } of changes) element.style.setProperty(property, adjustedValue, "important");
restore = () => {
for (const { element, property, value, priority } of changes) if (value) element.style.setProperty(property, value, priority);
else element.style.removeProperty(property);
if (!alreadyLocked) root.classList.remove(CLASS_NAME_OPEN);
};
observer = new MutationObserver(releaseUnusedLock);
observer.observe(root, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ["open"]
});
};
const unlockScroll = (owner) => {
owners.delete(owner);
releaseUnusedLock();
};
//#endregion
//#region js/src/dialog-base.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dialog-base.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Class definition
*
* Shared base class for Dialog and Drawer components that use
* the native element. Provides common behavior for:
* - Show/hide/toggle lifecycle with events
* - Opening/closing via showModal()/show()/close()
* - Escape key handling (modal and non-modal)
* - Backdrop click handling
* - Static backdrop transition ("bounce")
* - Body scroll prevention
* - Transition coordination
* - Child component cleanup (tooltips, popovers, toasts)
*/
var DialogBase = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._isTransitioning = false;
this._opening = false;
this._active = Boolean(this._element?.open);
this._openedAsModal = Boolean(this._element?.matches(":modal"));
this._operation = 0;
this._returnFocus = null;
this._closedBy = void 0;
this._cancelTransition = null;
this._addDialogListeners();
}
static get NAME() {
return "dialogbase";
}
toggle(relatedTarget) {
return this._element?.open ? this.hide() : this.show(relatedTarget);
}
async show(relatedTarget) {
if (!this._canShow(relatedTarget)) return;
await this._show(relatedTarget);
}
async hide() {
if (!this._canHide()) return;
await this._hide();
}
_canShow(relatedTarget) {
if (this._active && this._element?.isConnected && !this._element.open) {
unlockScroll(this._element);
this._finishHide();
}
if (!this._element?.isConnected || this._element.open || this._isTransitioning) return false;
return !EventHandler.trigger(this._element, this.constructor.eventName("show"), { relatedTarget }).defaultPrevented;
}
async _show(relatedTarget, returnFocus = relatedTarget) {
if (!this._element?.isConnected || this._element.open || this._isTransitioning) return;
const operation = ++this._operation;
this._isTransitioning = true;
this._opening = true;
this._active = true;
const previousFocus = this._element.ownerDocument.activeElement;
this._returnFocus = returnFocus === void 0 && previousFocus instanceof HTMLElement ? previousFocus : returnFocus ?? null;
this._onBeforeShow();
const { modal, preventBodyScroll } = this._getShowOptions();
this._showElement({
modal,
preventBodyScroll
});
if (!this._element || this._operation !== operation) return;
if (!this._element.open) {
this._clearOpenState();
this._active = false;
this._returnFocus = null;
this._isTransitioning = false;
this._opening = false;
return;
}
await this._queueLifecycle(() => {
if (this._operation !== operation || !this._element.open || !this._element.isConnected) return;
this._isTransitioning = false;
this._opening = false;
EventHandler.trigger(this._element, this.constructor.eventName("shown"), { relatedTarget });
}, this._isAnimated());
}
_canHide() {
if (!this._element?.open || this._isTransitioning && !this._opening) return false;
return !EventHandler.trigger(this._element, this.constructor.eventName("hide")).defaultPrevented;
}
async _hide(restoreFocus = true) {
if (!this._element?.open || this._isTransitioning && !this._opening) return;
const operation = ++this._operation;
this._cancelTransition?.();
this._isTransitioning = true;
this._opening = false;
if (!restoreFocus) this._returnFocus = null;
this._hideElement();
await this._queueLifecycle(() => {
if (this._operation === operation) {
this._closeAndCleanup();
if (this._element && !this._element.open && this._operation === operation) this._finishHide();
}
}, this._shouldDeferClose());
}
dispose() {
if (!this._element) return;
this._cancelTransition?.();
if (this._element.open) {
this._hideChildComponents();
this._closeAndCleanup();
}
if (!this._element) return;
unlockScroll(this._element);
this._clearOpenState();
EventHandler.off(this._element, "cancel", this._cancelHandler);
EventHandler.off(this._element, "close", this._closeHandler);
EventHandler.off(this._element, "toggle", this._toggleHandler);
super.dispose();
}
_getShowOptions() {
return {
modal: true,
preventBodyScroll: true
};
}
_onBeforeShow() {}
_onAfterHide() {}
_isAnimated() {
return !this._element.classList.contains(this._getInstantClassName());
}
_getInstantClassName() {
return "dialog-instant";
}
_getStaticClassName() {
return "dialog-static";
}
_onCancel() {}
_showElement({ modal = true, preventBodyScroll = true } = {}) {
this._openedAsModal = modal;
this._closedBy = this._element.getAttribute("closedby");
this._element.setAttribute("closedby", modal && this._config.keyboard ? "closerequest" : "none");
this._element.classList.toggle("dialog-no-backdrop", !this._config.backdrop);
if (modal) this._element.showModal();
else this._element.show();
if (preventBodyScroll && this._element?.open) {
const element = this._element;
lockScroll(element, () => {
if (this._element === element && this._active && !element.isConnected) {
this._hideChildComponents();
this._closeAndCleanup();
this._finishHide();
}
});
}
}
_hideElement() {
this._hideChildComponents();
this._element.classList.add("hiding");
}
_closeAndCleanup() {
const element = this._element;
element.close();
unlockScroll(element);
}
_clearOpenState() {
this._openedAsModal = false;
this._element.classList.remove("hiding", "dialog-no-backdrop", this._getStaticClassName());
if (this._closedBy === null) this._element.removeAttribute("closedby");
else if (this._closedBy !== void 0) this._element.setAttribute("closedby", this._closedBy);
this._closedBy = void 0;
this._onAfterHide();
}
_finishHide() {
const element = this._element;
const trigger = this._returnFocus;
const { activeElement, body } = element.ownerDocument;
const restoreFocus = activeElement === body || element.contains(activeElement);
this._cancelTransition?.();
this._clearOpenState();
this._active = false;
this._returnFocus = null;
this._isTransitioning = false;
this._opening = false;
this._operation++;
if (trigger && restoreFocus && isVisible(trigger)) trigger.focus({ preventScroll: true });
EventHandler.trigger(element, this.constructor.eventName("hidden"));
}
_queueLifecycle(callback, animated) {
if (!animated) {
callback();
return Promise.resolve();
}
return new Promise((resolve) => {
const cancel = executeAfterTransition(() => {
this._cancelTransition = null;
callback();
resolve();
}, this._element);
this._cancelTransition = () => {
cancel?.();
this._cancelTransition = null;
resolve();
};
});
}
_shouldDeferClose() {
return false;
}
_triggerBackdropTransition() {
if (EventHandler.trigger(this._element, this.constructor.eventName("hidePrevented")).defaultPrevented) return;
const staticClass = this._getStaticClassName();
this._element.classList.add(staticClass);
this._queueCallback(() => {
this._element.classList.remove(staticClass);
}, this._element);
}
_hideChildComponents() {
for (const el of SelectorEngine.find("[data-bs-toggle=\"tooltip\"], [data-bs-toggle=\"popover\"], [data-bs-toggle=\"datepicker\"]", this._element)) {
const instance = data_default.get(el, `bs.${el.getAttribute("data-bs-toggle")}`);
if (instance && typeof instance.hide === "function") instance.hide();
}
for (const el of SelectorEngine.find(".toast.show", this._element)) {
const instance = data_default.get(el, "bs.toast");
if (instance && typeof instance.hide === "function") instance.hide();
}
}
_addDialogListeners() {
if (!this._element) return;
const eventKey = this.constructor.EVENT_KEY;
this._closeHandler = () => {
if (!this._element.open) {
unlockScroll(this._element);
if (this._active) {
this._hideChildComponents();
this._finishHide();
}
}
};
EventHandler.on(this._element, "close", this._closeHandler);
this._toggleHandler = () => {
if (this._element.open && !this._active) {
this._active = true;
this._openedAsModal = this._element.matches(":modal");
}
};
EventHandler.on(this._element, "toggle", this._toggleHandler);
this._cancelHandler = (event) => {
if (event.target !== this._element) return;
event.preventDefault();
if (!this._config.keyboard) {
this._triggerBackdropTransition();
return;
}
this._onCancel();
this.hide();
};
EventHandler.on(this._element, "cancel", this._cancelHandler);
EventHandler.on(this._element, `keydown${eventKey}`, (event) => {
if (event.key !== "Escape" || event.defaultPrevented || !this._element.open || event.target.closest("dialog") !== this._element) return;
if (this._openedAsModal && this._config.keyboard) return;
event.preventDefault();
if (!this._config.keyboard) {
if (this._openedAsModal) this._triggerBackdropTransition();
return;
}
this._onCancel();
this.hide();
});
const isOutside = (event) => {
const { left, right, top, bottom } = this._element.getBoundingClientRect();
return event.clientX < left || event.clientX >= right || event.clientY < top || event.clientY >= bottom;
};
let backdropPress = false;
EventHandler.on(this._element, `pointerdown${eventKey}`, (event) => {
backdropPress = event.button === 0 && event.target === this._element && isOutside(event);
});
EventHandler.on(this._element, `pointercancel${eventKey}`, () => {
backdropPress = false;
});
EventHandler.on(this._element, `click${eventKey}`, (event) => {
const startedOutside = backdropPress;
backdropPress = false;
if (!startedOutside || !event.detail || event.target !== this._element || !this._openedAsModal || !isOutside(event)) return;
if (this._config.backdrop === false) return;
if (this._config.backdrop === "static") {
this._triggerBackdropTransition();
return;
}
this.hide();
});
}
};
//#endregion
//#region js/src/dialog.ts
/**
* --------------------------------------------------------------------------
* Bootstrap dialog.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$13 = "dialog";
const EVENT_KEY$10 = `.bs.dialog`;
const DATA_API_KEY$5 = ".data-api";
const EVENT_CANCEL = `cancel${EVENT_KEY$10}`;
const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$10}${DATA_API_KEY$5}`;
const CLASS_NAME_NONMODAL = "dialog-nonmodal";
const CLASS_NAME_INSTANT$1 = "dialog-instant";
const CLASS_NAME_SWAP_IN = "dialog-swap-in";
const SELECTOR_DATA_TOGGLE$5 = "[data-bs-toggle=\"dialog\"]";
const Default$12 = {
backdrop: true,
keyboard: true,
modal: true
};
const DefaultType$12 = {
backdrop: "(boolean|string)",
keyboard: "boolean",
modal: "boolean"
};
/**
* Class definition
*/
var Dialog = class Dialog extends DialogBase {
constructor(element, config) {
super(element, config);
}
static get Default() {
return Default$12;
}
static get DefaultType() {
return DefaultType$12;
}
static get NAME() {
return NAME$13;
}
static {
EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$5, function(event) {
Dialog._handleDataApiClick(this, event);
});
}
static _handleDataApiClick(trigger, event) {
const target = SelectorEngine.getElementFromSelector(trigger);
if (!(target instanceof HTMLDialogElement) || isDisabled(trigger)) return;
if (["A", "AREA"].includes(trigger.tagName)) event.preventDefault();
const config = Manipulator.getDataAttributes(trigger);
const currentDialog = trigger.closest("dialog.dialog[open]");
if (currentDialog === target) return;
if (!(currentDialog && currentDialog !== target)) {
Dialog.getOrCreateInstance(target, config).toggle(trigger);
return;
}
if (currentDialog.classList.contains(CLASS_NAME_SWAP_IN)) return;
const newDialog = Dialog.getOrCreateInstance(target, config);
const currentInstance = Dialog.getOrCreateInstance(currentDialog);
if (!newDialog._canShow(trigger) || !currentInstance._canHide()) return;
const returnFocus = currentInstance._returnFocus;
const wasInstant = currentDialog.classList.contains(CLASS_NAME_INSTANT$1);
target.classList.add(CLASS_NAME_SWAP_IN);
newDialog._show(trigger, returnFocus).finally(() => {
target.classList.remove(CLASS_NAME_SWAP_IN);
});
if (target.open) {
currentDialog.classList.add(CLASS_NAME_INSTANT$1);
currentInstance._hide(false).finally(() => {
if (!wasInstant) currentDialog.classList.remove(CLASS_NAME_INSTANT$1);
});
}
}
handleUpdate() {}
_getShowOptions() {
return {
modal: this._config.modal,
preventBodyScroll: this._config.modal
};
}
_onBeforeShow() {
if (!this._config.modal) this._element.classList.add(CLASS_NAME_NONMODAL);
}
_onAfterHide() {
this._element.classList.remove(CLASS_NAME_NONMODAL);
}
_shouldDeferClose() {
return this._isAnimated();
}
_onCancel() {
EventHandler.trigger(this._element, EVENT_CANCEL);
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Dialog);
//#endregion
//#region js/src/util/sanitizer.ts
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
const DefaultAllowlist = {
"*": [
"class",
"dir",
"id",
"lang",
"role",
ARIA_ATTRIBUTE_PATTERN
],
a: [
"target",
"href",
"title",
"rel"
],
area: [],
b: [],
br: [],
col: [],
code: [],
dd: [],
div: [],
dl: [],
dt: [],
em: [],
hr: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
i: [],
img: [
"src",
"srcset",
"alt",
"title",
"width",
"height"
],
li: [],
ol: [],
p: [],
pre: [],
s: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
u: [],
ul: []
};
/**
* Allowlist for icon HTML options (NavOverflow `moreIcon`,
* and markup supplied via `[data-bs-overflow-icon]`). Covers the default SVG
* icons plus common inline-icon markup. Event-handler attributes and tags not
* listed here are stripped by `sanitizeHtml`.
*/
const DefaultIconAllowlist = {
"*": [
"class",
"role",
ARIA_ATTRIBUTE_PATTERN
],
svg: [
"xmlns",
"width",
"height",
"viewbox",
"fill",
"stroke",
"stroke-width",
"stroke-linecap",
"stroke-linejoin",
"focusable"
],
path: [
"d",
"fill",
"stroke",
"stroke-width",
"fill-rule",
"clip-rule"
],
line: [
"x1",
"y1",
"x2",
"y2",
"stroke",
"stroke-width",
"stroke-linecap"
],
circle: [
"cx",
"cy",
"r",
"fill",
"stroke",
"stroke-width"
],
rect: [
"x",
"y",
"width",
"height",
"rx",
"ry",
"fill",
"stroke",
"stroke-width"
],
polyline: [
"points",
"fill",
"stroke",
"stroke-width"
],
polygon: [
"points",
"fill",
"stroke",
"stroke-width"
],
g: [
"fill",
"stroke",
"stroke-width",
"transform"
],
span: [],
i: []
};
const uriAttributes = /* @__PURE__ */ new Set([
"background",
"cite",
"href",
"itemtype",
"longdesc",
"poster",
"src",
"xlink:href"
]);
/**
* A pattern that recognizes URLs that are safe wrt. XSS in URL navigation
* contexts.
*
* Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L38
*/
const SAFE_URL_PATTERN = /^(?!(?:javascript|data|vbscript):)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/i;
/**
* A pattern that matches safe data URLs. Only matches image, video and audio
* types — notably NOT `data:text/html`, which is an XSS vector.
*
* Shout-out to Angular https://github.com/angular/angular/blob/15.2.8/packages/core/src/sanitization/url_sanitizer.ts#L49
*/
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z=]+$/i;
const allowedAttribute = (attribute, allowedAttributeList) => {
const attributeName = attribute.nodeName.toLowerCase();
if (allowedAttributeList.includes(attributeName)) {
if (uriAttributes.has(attributeName)) return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue));
return true;
}
return allowedAttributeList.filter((attributeRegex) => attributeRegex instanceof RegExp).some((regex) => regex.test(attributeName));
};
function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) {
if (!unsafeHtml.length) return unsafeHtml;
if (sanitizeFunction && typeof sanitizeFunction === "function") return sanitizeFunction(unsafeHtml);
const createdDocument = new window.DOMParser().parseFromString(unsafeHtml, "text/html");
const elements = [...createdDocument.body.querySelectorAll("*")];
for (const element of elements) {
const elementName = element.nodeName.toLowerCase();
if (!Object.keys(allowList).includes(elementName)) {
element.remove();
continue;
}
const attributeList = [...element.attributes];
const allowedAttributes = [...allowList["*"] || [], ...allowList[elementName] || []];
for (const attribute of attributeList) if (!allowedAttribute(attribute, allowedAttributes)) element.removeAttribute(attribute.nodeName);
}
return createdDocument.body.innerHTML;
}
//#endregion
//#region js/src/nav-overflow.ts
/**
* --------------------------------------------------------------------------
* Bootstrap nav-overflow.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$12 = "navoverflow";
const EVENT_KEY$9 = `.bs.navoverflow`;
const EVENT_UPDATE = `update${EVENT_KEY$9}`;
const EVENT_OVERFLOW = `overflow${EVENT_KEY$9}`;
const EVENT_RESIZE$2 = `resize${EVENT_KEY$9}`;
const CLASS_NAME_OVERFLOW = "nav-overflow";
const CLASS_NAME_OVERFLOW_MENU = "nav-overflow-menu";
const CLASS_NAME_HIDDEN = "d-none";
const CLASS_NAME_KEEP = "nav-overflow-keep";
const CLASS_NAME_INITIALIZED = "nav-overflow-initialized";
const CLASS_NAME_SUBMENU = "submenu";
const CLASS_NAME_SHOW$3 = "show";
const SELECTOR_NAV = ".nav";
const SELECTOR_NAV_ITEM = ".nav-item";
const SELECTOR_NAV_LINK = ".nav-link";
const SELECTOR_OVERFLOW_TOGGLE = ".nav-overflow-toggle";
const SELECTOR_OVERFLOW_MENU = ".nav-overflow-menu";
const SELECTOR_CUSTOM_ICON = "[data-bs-overflow-icon]";
const SELECTOR_MENU$1 = ".menu";
const SELECTOR_MENU_TOGGLE$2 = "[data-bs-toggle=\"menu\"]";
const DEFAULT_TEXT = "More";
const Default$11 = {
collapseBelow: 0,
iconPlacement: "start",
menuPlacement: "bottom-end",
menuStrategy: "absolute",
moreText: DEFAULT_TEXT,
moreIcon: " ",
threshold: 0
};
const DefaultType$11 = {
collapseBelow: "(number|string)",
iconPlacement: "string",
menuPlacement: "string",
menuStrategy: "string",
moreText: "(string|boolean)",
moreIcon: "string",
threshold: "number"
};
/**
* Class definition
*/
var NavOverflow = class extends BaseComponent {
constructor(element, config) {
super(element, config);
const nav = SelectorEngine.findOne(SELECTOR_NAV, this._element);
if (!nav) throw new TypeError(`${this._element.outerHTML} has no child ${SELECTOR_NAV} to collapse`);
this._nav = nav;
this._items = [];
this._overflowItems = [];
this._overflowMenu = null;
this._overflowToggle = null;
this._resizeObserver = null;
this._resizeHandler = null;
this._collapseBelow = 0;
this._itemMenus = /* @__PURE__ */ new Map();
this._relocatedMenus = /* @__PURE__ */ new Map();
this._init();
}
static get Default() {
return Default$11;
}
static get DefaultType() {
return DefaultType$11;
}
static get NAME() {
return NAME$12;
}
update() {
this._calculateOverflow();
EventHandler.trigger(this._element, EVENT_UPDATE);
}
dispose() {
if (this._resizeObserver) this._resizeObserver.disconnect();
if (this._resizeHandler) EventHandler.off(window, EVENT_RESIZE$2, this._resizeHandler);
this._restoreItems();
if (this._overflowToggle && this._overflowToggle.parentElement) this._overflowToggle.parentElement.remove();
super.dispose();
}
_init() {
this._element.classList.add(CLASS_NAME_OVERFLOW);
this._items = SelectorEngine.find(SELECTOR_NAV_ITEM, this._nav).filter((item) => !item.querySelector(SELECTOR_OVERFLOW_TOGGLE));
for (const [index, item] of this._items.entries()) {
item.dataset.bsNavOrder = index;
const link = SelectorEngine.findOne(SELECTOR_NAV_LINK, item);
if (link?.matches(SELECTOR_MENU_TOGGLE$2)) this._findItemMenu(item, link);
}
this._collapseBelow = this._resolveCollapseBelow();
this._createOverflowMenu();
this._setupResizeObserver();
this._calculateOverflow();
this._element.classList.add(CLASS_NAME_INITIALIZED);
}
_createOverflowMenu() {
this._overflowToggle = SelectorEngine.findOne(SELECTOR_OVERFLOW_TOGGLE, this._element);
if (this._overflowToggle) {
this._overflowMenu = SelectorEngine.findOne(SELECTOR_OVERFLOW_MENU, this._element);
return;
}
const { moreText } = this._config;
const label = typeof moreText === "string" ? moreText : "";
const overflowItem = document.createElement("li");
overflowItem.className = "nav-item nav-overflow-item";
const button = document.createElement("button");
button.type = "button";
button.className = "nav-link nav-overflow-toggle";
button.setAttribute("data-bs-toggle", "menu");
button.setAttribute("data-bs-placement", this._config.menuPlacement);
button.setAttribute("data-bs-strategy", this._config.menuStrategy);
button.setAttribute("aria-expanded", "false");
if (label === "") button.setAttribute("aria-label", DEFAULT_TEXT);
const iconSpan = document.createElement("span");
iconSpan.className = "nav-overflow-icon";
iconSpan.innerHTML = sanitizeHtml(this._resolveIcon(), DefaultIconAllowlist);
if (label === "") button.append(iconSpan);
else {
const textSpan = document.createElement("span");
textSpan.className = "nav-overflow-text";
textSpan.textContent = label;
if (this._config.iconPlacement === "end") button.append(textSpan, iconSpan);
else button.append(iconSpan, textSpan);
}
const menu = document.createElement("div");
menu.className = `${CLASS_NAME_OVERFLOW_MENU} menu`;
overflowItem.append(button, menu);
this._nav.append(overflowItem);
this._overflowToggle = button;
this._overflowMenu = menu;
}
_resolveIcon() {
const customIconElement = SelectorEngine.findOne(SELECTOR_CUSTOM_ICON, this._element);
if (!customIconElement) return this._config.moreIcon;
const iconClone = customIconElement.cloneNode(true);
iconClone.removeAttribute("data-bs-overflow-icon");
const iconHtml = iconClone.outerHTML;
customIconElement.remove();
return iconHtml;
}
_resolveCollapseBelow() {
const value = this._config.collapseBelow;
if (typeof value === "number") return value;
if (typeof value === "string" && value !== "") {
const cssValue = getComputedStyle(document.documentElement).getPropertyValue(`--bs-breakpoint-${value}`);
return Number.parseFloat(cssValue) || 0;
}
return 0;
}
_setupResizeObserver() {
if (typeof ResizeObserver === "undefined") {
this._resizeHandler = () => this._calculateOverflow();
EventHandler.on(window, EVENT_RESIZE$2, this._resizeHandler);
return;
}
this._resizeObserver = new ResizeObserver(() => {
this._calculateOverflow();
});
this._resizeObserver.observe(this._element);
}
_availableWidth() {
const { paddingInlineStart, paddingInlineEnd } = getComputedStyle(this._element);
const padding = (Number.parseFloat(paddingInlineStart) || 0) + (Number.parseFloat(paddingInlineEnd) || 0);
return this._element.clientWidth - padding;
}
_navGap() {
return Number.parseFloat(getComputedStyle(this._nav).columnGap) || 0;
}
_calculateOverflow() {
this._restoreItems();
const availableWidth = this._availableWidth();
const overflowItem = this._overflowToggle?.closest(SELECTOR_NAV_ITEM) ?? null;
const candidates = this._items.filter((item) => !item.classList.contains(CLASS_NAME_KEEP));
if (this._collapseBelow > 0 && availableWidth < this._collapseBelow) {
this._applyOverflow(candidates, overflowItem);
return;
}
const gap = this._navGap();
const widthOf = (items) => items.reduce((sum, item) => sum + item.offsetWidth + gap, 0);
const space = availableWidth - widthOf(this._items.filter((item) => item.classList.contains(CLASS_NAME_KEEP))) + gap;
if (widthOf(candidates) <= space + 1) {
this._applyOverflow([], overflowItem);
return;
}
const limit = space - (overflowItem ? overflowItem.offsetWidth + gap : 0);
let usedWidth = 0;
let itemsToOverflow = [];
for (const item of candidates) {
usedWidth += item.offsetWidth + gap;
if (usedWidth > limit + 1) itemsToOverflow.push(item);
}
if (this._items.length - itemsToOverflow.length < this._config.threshold && this._items.length > this._config.threshold) itemsToOverflow = this._items.slice(this._config.threshold).filter((item) => !item.classList.contains(CLASS_NAME_KEEP));
this._applyOverflow(itemsToOverflow, overflowItem);
}
_applyOverflow(items, overflowItem) {
this._moveToOverflow(items);
overflowItem?.classList.toggle(CLASS_NAME_HIDDEN, items.length === 0);
if (items.length > 0) EventHandler.trigger(this._element, EVENT_OVERFLOW, {
overflowCount: items.length,
visibleCount: this._items.length - items.length
});
}
_moveToOverflow(items) {
if (!this._overflowMenu) return;
this._overflowMenu.replaceChildren();
this._overflowItems = [];
for (const item of items) {
const link = SelectorEngine.findOne(SELECTOR_NAV_LINK, item);
if (!link) continue;
const menu = this._findItemMenu(item, link);
if (menu && link.matches(SELECTOR_MENU_TOGGLE$2)) this._overflowMenu.append(this._relocateAsSubmenu(item, link, menu));
else this._overflowMenu.append(this._cloneAsMenuItem(link));
item.classList.add(CLASS_NAME_HIDDEN);
item.dataset.bsNavOverflow = "true";
this._overflowItems.push(item);
}
}
_relocateAsSubmenu(item, link, menu) {
this._resetMenu(link, menu);
item.classList.remove(CLASS_NAME_SHOW$3);
this._relocatedMenus.set(item, {
menu,
parent: menu.parentNode,
nextSibling: menu.nextSibling
});
const submenu = document.createElement("div");
submenu.className = CLASS_NAME_SUBMENU;
submenu.append(this._cloneAsMenuItem(link, true), menu);
return submenu;
}
_cloneAsMenuItem(link, submenu = false) {
const clonedLink = link.cloneNode(true);
clonedLink.className = "menu-item";
clonedLink.removeAttribute("id");
if (link.classList.contains("active")) clonedLink.classList.add("active");
if (link.classList.contains("disabled") || link.hasAttribute("disabled")) clonedLink.classList.add("disabled");
if (submenu) {
for (const name of clonedLink.getAttributeNames()) if (name.startsWith("data-bs-") && name !== "data-bs-theme") clonedLink.removeAttribute(name);
clonedLink.removeAttribute("href");
clonedLink.setAttribute("aria-haspopup", "true");
clonedLink.setAttribute("aria-expanded", "false");
if (clonedLink.tagName === "A") {
clonedLink.setAttribute("role", "button");
if (!clonedLink.hasAttribute("tabindex")) clonedLink.setAttribute("tabindex", "0");
}
}
return clonedLink;
}
_findItemMenu(item, link) {
const sibling = SelectorEngine.next(link, SELECTOR_MENU$1)[0];
if (sibling && !sibling.classList.contains(CLASS_NAME_OVERFLOW_MENU)) {
this._itemMenus.set(item, sibling);
return sibling;
}
const nested = SelectorEngine.findOne(SELECTOR_MENU$1, item);
if (nested && !nested.classList.contains(CLASS_NAME_OVERFLOW_MENU)) {
this._itemMenus.set(item, nested);
return nested;
}
const cached = this._itemMenus.get(item);
if (cached?.isConnected) return cached;
this._itemMenus.delete(item);
return null;
}
_resetMenu(toggle, menu) {
Menu.getInstance(toggle)?.dispose();
toggle.classList.remove(CLASS_NAME_SHOW$3);
toggle.setAttribute("aria-expanded", "false");
toggle.parentElement?.classList.remove(CLASS_NAME_SHOW$3);
menu.classList.remove(CLASS_NAME_SHOW$3);
}
_restoreRelocatedMenus() {
for (const { menu, parent, nextSibling } of this._relocatedMenus.values()) if (nextSibling) nextSibling.before(menu);
else parent.append(menu);
this._relocatedMenus.clear();
}
_restoreItems() {
if (this._overflowToggle && this._overflowMenu) {
this._resetMenu(this._overflowToggle, this._overflowMenu);
this._overflowToggle.closest(SELECTOR_NAV_ITEM)?.classList.remove(CLASS_NAME_SHOW$3);
}
this._restoreRelocatedMenus();
for (const item of this._items) {
item.classList.remove(CLASS_NAME_HIDDEN);
delete item.dataset.bsNavOverflow;
}
this._overflowToggle?.closest(SELECTOR_NAV_ITEM)?.classList.remove(CLASS_NAME_HIDDEN);
this._overflowMenu?.replaceChildren();
this._overflowItems = [];
}
};
/**
* Data API implementation
*/
onDocumentReady("DOMContentLoaded", () => {
for (const element of SelectorEngine.find("[data-bs-toggle=\"nav-overflow\"]")) NavOverflow.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/swipe.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/swipe.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$11 = "swipe";
const EVENT_KEY$8 = ".bs.swipe";
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$8}`;
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$8}`;
const EVENT_TOUCHEND = `touchend${EVENT_KEY$8}`;
const EVENT_TOUCHCANCEL = `touchcancel${EVENT_KEY$8}`;
const EVENT_POINTERDOWN$1 = `pointerdown${EVENT_KEY$8}`;
const EVENT_POINTERUP$1 = `pointerup${EVENT_KEY$8}`;
const EVENT_POINTERCANCEL = `pointercancel${EVENT_KEY$8}`;
const POINTER_TYPE_TOUCH = "touch";
const POINTER_TYPE_PEN = "pen";
const CLASS_NAME_POINTER_EVENT = "pointer-event";
const SWIPE_THRESHOLD = 40;
const Default$10 = {
endCallback: null,
leftCallback: null,
rightCallback: null,
upCallback: null,
downCallback: null
};
const DefaultType$10 = {
endCallback: "(function|null)",
leftCallback: "(function|null)",
rightCallback: "(function|null)",
upCallback: "(function|null)",
downCallback: "(function|null)"
};
/**
* Class definition
*/
var Swipe = class Swipe extends Config {
constructor(element, config) {
super();
this._element = element;
if (!element || !Swipe.isSupported()) return;
this._config = this._getConfig(config);
this._deltaX = 0;
this._deltaY = 0;
this._pointerId = null;
this._touchStart = null;
this._supportPointerEvents = Boolean(window.PointerEvent);
this._initEvents();
}
static get Default() {
return Default$10;
}
static get DefaultType() {
return DefaultType$10;
}
static get NAME() {
return NAME$11;
}
dispose() {
EventHandler.off(this._element, EVENT_KEY$8);
this._element?.classList.remove(CLASS_NAME_POINTER_EVENT);
}
_start(event) {
if (!this._supportPointerEvents) {
this._touchStart = event.touches.length === 1 ? event.touches[0] : null;
this._deltaX = 0;
this._deltaY = 0;
return;
}
if (this._eventIsPointerPenTouch(event)) {
this._pointerId = event.pointerId;
this._deltaX = event.clientX;
this._deltaY = event.clientY;
}
}
_end(event) {
if (this._supportPointerEvents) {
if (!this._eventIsPointerPenTouch(event) || this._pointerId !== event.pointerId) return;
this._pointerId = null;
this._deltaX = event.clientX - this._deltaX;
this._deltaY = event.clientY - this._deltaY;
} else if (!this._touchStart) return;
this._touchStart = null;
this._handleSwipe();
execute(this._config.endCallback);
}
_move(event) {
if (event.touches.length !== 1) this._touchStart = null;
if (!this._touchStart) return;
this._deltaX = event.touches[0].clientX - this._touchStart.clientX;
this._deltaY = event.touches[0].clientY - this._touchStart.clientY;
}
_handleSwipe() {
const absDeltaX = Math.abs(this._deltaX);
const absDeltaY = Math.abs(this._deltaY);
if (absDeltaY > absDeltaX && absDeltaY > SWIPE_THRESHOLD) {
const direction = this._deltaY > 0 ? "down" : "up";
this._deltaX = 0;
this._deltaY = 0;
execute(direction === "down" ? this._config.downCallback : this._config.upCallback);
return;
}
if (absDeltaX > SWIPE_THRESHOLD) {
const direction = absDeltaX / this._deltaX;
this._deltaX = 0;
this._deltaY = 0;
if (!direction) return;
execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback);
return;
}
this._deltaX = 0;
this._deltaY = 0;
}
_initEvents() {
if (this._supportPointerEvents) {
EventHandler.on(this._element, EVENT_POINTERDOWN$1, (event) => this._start(event));
EventHandler.on(this._element, EVENT_POINTERUP$1, (event) => this._end(event));
EventHandler.on(this._element, EVENT_POINTERCANCEL, (event) => {
if (this._pointerId === event.pointerId) this._pointerId = null;
});
this._element.classList.add(CLASS_NAME_POINTER_EVENT);
} else {
EventHandler.on(this._element, EVENT_TOUCHSTART, (event) => this._start(event));
EventHandler.on(this._element, EVENT_TOUCHMOVE, (event) => this._move(event));
EventHandler.on(this._element, EVENT_TOUCHEND, (event) => this._end(event));
EventHandler.on(this._element, EVENT_TOUCHCANCEL, () => {
this._touchStart = null;
});
}
}
_eventIsPointerPenTouch(event) {
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
}
static isSupported() {
return "ontouchstart" in document.documentElement || navigator.maxTouchPoints > 0;
}
};
//#endregion
//#region js/src/drawer.ts
/**
* --------------------------------------------------------------------------
* Bootstrap drawer.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$10 = "drawer";
const EVENT_KEY$7 = `.bs.drawer`;
const DATA_API_KEY$4 = ".data-api";
const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$7}${DATA_API_KEY$4}`;
const EVENT_RESIZE$1 = `resize${EVENT_KEY$7}`;
const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`;
const SELECTOR_DATA_TOGGLE$4 = "[data-bs-toggle=\"drawer\"]";
const SELECTOR_RESPONSIVE = "dialog[class*=\"\\:drawer\"]";
const SELECTOR_OPEN = "dialog.drawer[open], dialog[open][class*=\"\\:drawer\"]";
const SELECTOR_RESIZE = `${SELECTOR_OPEN}, ${SELECTOR_RESPONSIVE}`;
const inlineAttributes = /* @__PURE__ */ new WeakMap();
const drawerIsInline = (element) => element.matches(SELECTOR_RESPONSIVE) && getComputedStyle(element).getPropertyValue("--drawer-inline").trim() === "1";
const syncInlineSemantics = (element, inline) => {
const saved = inlineAttributes.get(element);
if (inline && !saved) {
const attributes = /* @__PURE__ */ new Map();
for (const name of [
"role",
"aria-label",
"aria-labelledby",
"aria-describedby",
"aria-modal"
]) {
attributes.set(name, element.getAttribute(name));
element.removeAttribute(name);
}
element.setAttribute("role", "presentation");
inlineAttributes.set(element, attributes);
} else if (!inline && saved) {
for (const [name, value] of saved) if (value === null) element.removeAttribute(name);
else element.setAttribute(name, value);
inlineAttributes.delete(element);
}
};
const Default$9 = {
backdrop: true,
keyboard: true,
scroll: false
};
const DefaultType$9 = {
backdrop: "(boolean|string)",
keyboard: "boolean",
scroll: "boolean"
};
/**
* Class definition
*/
var Drawer = class Drawer extends DialogBase {
constructor(element, config) {
super(element, config);
this._swipeHelper = null;
this._resizeObserver = null;
this._resizeFrame = null;
this._initResizeObserver();
}
static get Default() {
return Default$9;
}
static get DefaultType() {
return DefaultType$9;
}
static get NAME() {
return NAME$10;
}
static {
EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$4, function(event) {
const target = SelectorEngine.getElementFromSelector(this);
if (!(target instanceof HTMLDialogElement) || isDisabled(this)) return;
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
Drawer._toggleDrawer(target, this);
});
}
static _toggleDrawer(target, trigger) {
const drawer = Drawer.getOrCreateInstance(target, Manipulator.getDataAttributes(trigger));
if (target.open) {
drawer.hide();
return;
}
const other = SelectorEngine.findOne(SELECTOR_OPEN);
if (!other) {
drawer.show(trigger);
return;
}
const source = Drawer.getOrCreateInstance(other);
if (!drawer._canShow(trigger) || !source._canHide()) return;
const returnFocus = other.contains(trigger) ? source._returnFocus : trigger;
drawer._show(trigger, returnFocus);
if (target.open) source._hide(false);
}
dispose() {
if (this._swipeHelper) this._swipeHelper.dispose();
if (this._resizeObserver) this._resizeObserver.disconnect();
if (this._resizeFrame !== null) cancelAnimationFrame(this._resizeFrame);
super.dispose();
}
_getShowOptions() {
return {
modal: Boolean(this._config.backdrop) || !this._config.scroll,
preventBodyScroll: !this._config.scroll
};
}
_onBeforeShow() {
this._swipeHelper?.dispose();
this._swipeHelper = null;
this._initSwipe();
}
_canShow(relatedTarget) {
return !this._isInline() && super._canShow(relatedTarget);
}
async _show(relatedTarget, returnFocus = relatedTarget) {
if (this._isInline()) return;
await super._show(relatedTarget, returnFocus);
if (this._element?.open && this._isInline()) await this.hide();
}
_onAfterHide() {
syncInlineSemantics(this._element, this._isInline());
}
_isInline() {
return Boolean(this._element && drawerIsInline(this._element));
}
_getInstantClassName() {
return "drawer-instant";
}
_getStaticClassName() {
return "drawer-static";
}
_shouldDeferClose() {
return this._isAnimated();
}
_initResizeObserver() {
const navbar = this._element?.closest(".navbar");
if (!navbar || typeof ResizeObserver === "undefined") return;
this._resizeObserver = new ResizeObserver(() => {
if (this._resizeFrame !== null) cancelAnimationFrame(this._resizeFrame);
this._resizeFrame = requestAnimationFrame(() => {
this._resizeFrame = null;
if (this._element.open && getComputedStyle(this._element).position !== "fixed") this.hide();
});
});
this._resizeObserver.observe(navbar);
}
_initSwipe() {
if (this._swipeHelper || !Swipe.isSupported()) return;
const swipeConfig = {};
const element = this._element;
const rtl = element.matches(":dir(rtl)");
if (element.classList.contains("drawer-bottom")) swipeConfig.downCallback = () => this.hide();
else if (element.classList.contains("drawer-top")) swipeConfig.upCallback = () => this.hide();
else if (element.classList.contains("drawer-end")) if (rtl) swipeConfig.leftCallback = () => this.hide();
else swipeConfig.rightCallback = () => this.hide();
else if (rtl) swipeConfig.rightCallback = () => this.hide();
else swipeConfig.leftCallback = () => this.hide();
this._swipeHelper = new Swipe(SelectorEngine.findOne(".drawer-header", element) || element, swipeConfig);
}
};
/**
* Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
for (const element of SelectorEngine.find(SELECTOR_OPEN)) Drawer.getOrCreateInstance(element);
});
onDocumentReady(`DOMContentLoaded${EVENT_KEY$7}${DATA_API_KEY$4}`, () => {
for (const element of SelectorEngine.find(SELECTOR_RESPONSIVE)) syncInlineSemantics(element, !element.open && drawerIsInline(element));
});
document.addEventListener("beforetoggle", (event) => {
if (event.target instanceof HTMLDialogElement && event.newState === "open") syncInlineSemantics(event.target, false);
}, true);
document.addEventListener("close", (event) => {
if (event.target instanceof HTMLDialogElement && event.target.matches(SELECTOR_RESPONSIVE)) syncInlineSemantics(event.target, !event.target.open && drawerIsInline(event.target));
}, true);
EventHandler.on(window, EVENT_RESIZE$1, () => {
for (const element of SelectorEngine.find(SELECTOR_RESIZE)) {
const inline = drawerIsInline(element);
syncInlineSemantics(element, !element.open && inline);
if (element.open && (inline || getComputedStyle(element).position !== "fixed")) Drawer.getOrCreateInstance(element).hide();
}
});
enableDismissTrigger(Drawer);
//#endregion
//#region js/src/strength.ts
/**
* --------------------------------------------------------------------------
* Bootstrap strength.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$9 = "strength";
const EVENT_KEY$6 = `.bs.strength`;
const DATA_API_KEY$3 = ".data-api";
const EVENT_STRENGTH_CHANGE = `strengthChange${EVENT_KEY$6}`;
const SELECTOR_DATA_STRENGTH = "[data-bs-strength]";
const STRENGTH_LEVELS = [
"weak",
"fair",
"good",
"strong"
];
const Default$8 = {
input: null,
minLength: 8,
messages: {
weak: "Weak",
fair: "Fair",
good: "Good",
strong: "Strong"
},
weights: {
minLength: 1,
extraLength: 1,
lowercase: 1,
uppercase: 1,
numbers: 1,
special: 1,
multipleSpecial: 1,
longPassword: 1
},
thresholds: [
2,
4,
6
],
scorer: null
};
const DefaultType$8 = {
input: "(string|element|null)",
minLength: "number",
messages: "object",
weights: "object",
thresholds: "array",
scorer: "(function|null)"
};
/**
* Class definition
*/
var Strength = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._input = this._getInput();
this._segments = SelectorEngine.find(".strength-segment", this._element);
this._textElement = SelectorEngine.findOne(".strength-text", this._element.parentElement);
this._currentStrength = null;
if (this._input) {
this._addEventListeners();
this._evaluate();
}
}
static get Default() {
return Default$8;
}
static get DefaultType() {
return DefaultType$8;
}
static get NAME() {
return NAME$9;
}
getStrength() {
return this._currentStrength;
}
evaluate() {
this._evaluate();
}
dispose() {
EventHandler.off(this._input, EVENT_KEY$6);
super.dispose();
}
_getInput() {
if (this._config.input) return typeof this._config.input === "string" ? SelectorEngine.findOne(this._config.input) : this._config.input;
const parent = this._element.parentElement;
return SelectorEngine.findOne("input[type=\"password\"]", parent);
}
_addEventListeners() {
EventHandler.on(this._input, `input${EVENT_KEY$6}`, () => this._evaluate());
EventHandler.on(this._input, `change${EVENT_KEY$6}`, () => this._evaluate());
}
_evaluate() {
const password = this._input.value;
const score = this._calculateScore(password);
const strength = this._scoreToStrength(score);
if (strength !== this._currentStrength) {
this._currentStrength = strength;
this._updateUI(strength);
EventHandler.trigger(this._element, EVENT_STRENGTH_CHANGE, {
strength,
score,
password: password.length > 0 ? "***" : ""
});
}
}
_calculateScore(password) {
if (!password) return 0;
if (typeof this._config.scorer === "function") return this._config.scorer(password);
const { weights } = this._config;
let score = 0;
if (password.length >= this._config.minLength) score += weights.minLength;
if (password.length >= this._config.minLength + 4) score += weights.extraLength;
if (/[a-z]/.test(password)) score += weights.lowercase;
if (/[A-Z]/.test(password)) score += weights.uppercase;
if (/\d/.test(password)) score += weights.numbers;
const specialCount = password.match(/[ \p{P}\p{S}]/gu)?.length ?? 0;
if (specialCount >= 1) score += weights.special;
if (specialCount >= 2) score += weights.multipleSpecial;
if (password.length >= 16) score += weights.longPassword;
return score;
}
_scoreToStrength(score) {
if (score === 0) return null;
const [weak, fair, good] = this._config.thresholds;
if (score <= weak) return "weak";
if (score <= fair) return "fair";
if (score <= good) return "good";
return "strong";
}
_updateUI(strength) {
if (strength) this._element.dataset.bsStrength = strength;
else delete this._element.dataset.bsStrength;
const strengthIndex = strength ? STRENGTH_LEVELS.indexOf(strength) : -1;
for (const [index, segment] of this._segments.entries()) if (index <= strengthIndex) segment.classList.add("active");
else segment.classList.remove("active");
if (this._textElement) if (strength && this._config.messages[strength]) {
this._textElement.textContent = this._config.messages[strength];
this._textElement.dataset.bsStrength = strength;
} else {
this._textElement.textContent = "";
delete this._textElement.dataset.bsStrength;
}
}
};
/**
* Data API implementation
*/
onDocumentReady(`DOMContentLoaded${EVENT_KEY$6}${DATA_API_KEY$3}`, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_STRENGTH)) Strength.getOrCreateInstance(element);
});
//#endregion
//#region js/src/otp-input.ts
/**
* --------------------------------------------------------------------------
* Bootstrap otp-input.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$8 = "otpInput";
const EVENT_KEY$5 = `.bs.otpInput`;
const DATA_API_KEY$2 = ".data-api";
const EVENT_COMPLETE = `complete${EVENT_KEY$5}`;
const EVENT_INPUT$1 = `input${EVENT_KEY$5}`;
const EVENT_DOMCONTENT_LOADED = `DOMContentLoaded${EVENT_KEY$5}${DATA_API_KEY$2}`;
const SELECTOR_DATA_OTP = "[data-bs-otp]";
const SELECTOR_INPUT$1 = "input";
const CLASS_NAME_INPUT = "otp-input";
const CLASS_NAME_RENDERED = "otp-rendered";
const CLASS_NAME_SLOTS = "otp-slots";
const CLASS_NAME_SLOT = "otp-slot";
const CLASS_NAME_SLOT_FILLED = "otp-slot-filled";
const CLASS_NAME_SLOT_ACTIVE = "otp-slot-active";
const CLASS_NAME_SLOT_SELECTED = "otp-slot-selected";
const CLASS_NAME_SEPARATOR = "otp-separator";
const MASK_CHARACTER = "•";
const TYPES = {
numeric: {
inputmode: "numeric",
pattern: "[0-9]*",
filter: /[^0-9]/g
},
alphanumeric: {
inputmode: "text",
pattern: "[A-Za-z0-9]*",
filter: /[^A-Za-z0-9]/g
},
alpha: {
inputmode: "text",
pattern: "[A-Za-z]*",
filter: /[^A-Za-z]/g
}
};
const Default$7 = {
groups: null,
length: null,
mask: false,
pasteTransformer: null,
separator: "·",
type: "numeric"
};
const DefaultType$7 = {
groups: "(array|null)",
length: "(number|null)",
mask: "boolean",
pasteTransformer: "(function|null)",
separator: "string",
type: "string"
};
/**
* Class definition
*/
var OtpInput = class extends BaseComponent {
constructor(element, config) {
super(element, config);
const input = SelectorEngine.findOne(SELECTOR_INPUT$1, this._element);
if (!input) return;
this._input = input;
this._type = TYPES[this._config.type] || TYPES.numeric;
this._length = this._resolveLength();
this._slots = [];
this._pointerActive = false;
this._pointerIndex = 0;
this._touchPointer = false;
this._setupInput();
this._lastCompleteValue = null;
this._renderSlots();
this._addEventListeners();
this._render();
}
static get Default() {
return Default$7;
}
static get DefaultType() {
return DefaultType$7;
}
static get NAME() {
return NAME$8;
}
getValue() {
return this._input.value;
}
setValue(value) {
this._input.value = this._sanitize(String(value));
this._render();
this._checkComplete();
}
clear() {
this._input.value = "";
this._lastCompleteValue = null;
this._render();
this._input.focus();
}
focus() {
this._input.focus();
this._selectSlot(this._firstEmptyIndex());
this._render();
}
dispose() {
for (const [type, listener] of Object.entries(this._inputListeners ?? {})) EventHandler.off(this._input, type, listener);
EventHandler.off(document, "selectionchange", this._onSelectionChange);
document.removeEventListener("reset", this._onReset, true);
for (const [attribute, value] of this._inputDefaults ?? []) if (this._input.getAttribute(attribute) === value) this._input.removeAttribute(attribute);
this._slotsContainer?.remove();
this._element.classList.remove(CLASS_NAME_RENDERED);
super.dispose();
}
_resolveLength() {
if (this._config.length) return this._config.length;
const maxLength = Number.parseInt(this._input.getAttribute("maxlength"), 10);
return Number.isNaN(maxLength) || maxLength < 1 ? 6 : maxLength;
}
_setupInput() {
const input = this._input;
if (input.type === "number" || input.type === "password") input.type = "text";
input.classList.add(CLASS_NAME_INPUT);
input.setAttribute("maxlength", String(this._length));
this._inputDefaults = /* @__PURE__ */ new Map();
const pattern = input.minLength > 0 ? `${this._type.pattern.slice(0, -1)}{${input.minLength},}` : this._type.pattern;
const defaults = {
inputmode: this._type.inputmode,
pattern,
spellcheck: "false"
};
for (const [attribute, value] of Object.entries(defaults)) if (!input.hasAttribute(attribute)) {
input.setAttribute(attribute, value);
this._inputDefaults.set(attribute, value);
}
if (!input.getAttribute("autocomplete")) input.setAttribute("autocomplete", "one-time-code");
if (input.value) input.value = this._sanitize(input.value);
}
_renderSlots() {
const container = document.createElement("div");
container.className = CLASS_NAME_SLOTS;
container.setAttribute("aria-hidden", "true");
const { groups } = this._config;
let groupIndex = 0;
let inGroup = 0;
for (let i = 0; i < this._length; i++) {
const slot = document.createElement("div");
slot.className = CLASS_NAME_SLOT;
container.append(slot);
this._slots.push(slot);
if (Array.isArray(groups) && groups.length > 0) {
inGroup++;
if (inGroup === groups[groupIndex] && i < this._length - 1) {
const separator = document.createElement("div");
separator.className = CLASS_NAME_SEPARATOR;
separator.textContent = this._config.separator;
container.append(separator);
groupIndex = Math.min(groupIndex + 1, groups.length - 1);
inGroup = 0;
}
}
}
this._slotsContainer = container;
this._element.append(container);
this._element.classList.add(CLASS_NAME_RENDERED);
}
_addEventListeners() {
this._inputListeners = {
input: (event) => this._handleInput(event),
compositionend: () => this._handleInput(),
beforeinput: (event) => this._handleBeforeInput(event),
keydown: (event) => this._handleKeydown(event),
paste: (event) => this._handlePaste(event),
pointerdown: (event) => this._handlePointerDown(event),
pointercancel: () => {
this._touchPointer = false;
},
click: (event) => this._handleClick(event)
};
this._inputListeners.focus = () => {
if (this._pointerActive) {
this._pointerActive = false;
this._selectSlot(this._pointerIndex);
this._render();
return;
}
this._selectSlot(this._firstEmptyIndex());
this._render();
};
const onSync = () => this._render();
this._onSelectionChange = () => {
if (document.activeElement === this._input) this._render();
};
for (const type of [
"blur",
"keyup",
"select"
]) this._inputListeners[type] = onSync;
for (const [type, listener] of Object.entries(this._inputListeners)) EventHandler.on(this._input, type, listener);
EventHandler.on(document, "selectionchange", this._onSelectionChange);
this._onReset = (event) => {
if (event.target !== this._input.form) return;
setTimeout(() => {
if (event.defaultPrevented || event.target !== this._input?.form) return;
const sanitized = this._sanitize(this._input.value);
if (sanitized !== this._input.value) this._input.value = sanitized;
this._lastCompleteValue = null;
this._render();
});
};
document.addEventListener("reset", this._onReset, true);
}
_handleInput(event) {
if (event?.isComposing) return;
const { value, selectionStart } = this._input;
const sanitized = this._sanitize(value);
if (sanitized !== value) this._input.value = sanitized;
if (document.activeElement === this._input) {
const inputType = event?.inputType;
if (inputType === "insertText" || inputType?.startsWith("delete")) {
const caret = selectionStart ?? sanitized.length;
this._selectSlot(this._sanitize(value.slice(0, caret)).length);
} else if (!inputType || inputType === "insertReplacementText") this._selectSlot(this._firstEmptyIndex());
}
this._afterValueChange();
}
_handlePaste(event) {
const pastedValue = event.clipboardData?.getData("text");
if (!pastedValue || !this._isEditable()) return;
const transformed = this._config.pasteTransformer?.(pastedValue) ?? pastedValue;
const sanitized = this._sanitize(transformed);
let start = this._input.selectionStart ?? this._input.value.length;
let end = this._input.selectionEnd ?? start;
if (sanitized.length === this._length) {
start = 0;
end = this._input.value.length;
}
const inserted = sanitized.slice(0, this._length - this._input.value.length + end - start);
if (start === this._input.selectionStart && end === this._input.selectionEnd && inserted === pastedValue) return;
event.preventDefault();
if (!inserted) return;
const input = this._input;
if (input.matches(":focus")) {
input.setSelectionRange(start, end);
if (input.ownerDocument.execCommand("insertText", false, inserted)) return;
}
input.setRangeText(inserted, start, end, "end");
input.dispatchEvent(new InputEvent("input", {
bubbles: true,
composed: true,
inputType: "insertFromPaste",
data: inserted
}));
}
_handleBeforeInput(event) {
const { inputType, data, isComposing } = event;
if (inputType !== "insertText" || isComposing || data?.length !== 1 || !this._isEditable()) return;
if (!this._sanitize(data)) {
event.preventDefault();
return;
}
if (this._input.selectionStart === this._input.selectionEnd) this._selectSlot(this._input.selectionStart ?? 0);
}
_handleKeydown(event) {
const { key, altKey, ctrlKey, metaKey, shiftKey, isComposing, defaultPrevented } = event;
if (defaultPrevented || isComposing || altKey || ctrlKey || metaKey || shiftKey || key !== "ArrowLeft" && key !== "ArrowRight") return;
if (getComputedStyle(this._slotsContainer).direction !== "rtl") return;
const start = this._input.selectionStart ?? 0;
const end = this._input.selectionEnd ?? start;
const isMovingRight = key === "ArrowRight";
const rangeEdge = isMovingRight ? start : end;
const nextSlot = start + (isMovingRight ? -1 : 1);
const index = end - start > 1 ? rangeEdge : nextSlot;
event.preventDefault();
this._selectSlot(Math.min(index, this._firstEmptyIndex()));
this._render();
}
_handleClick(event) {
if (!this._touchPointer) return;
this._touchPointer = false;
const index = this._slotIndexFromPoint(event.clientX);
if (index === null) return;
requestAnimationFrame(() => {
if (this._input && document.activeElement === this._input) {
this._selectSlot(Math.min(index, this._firstEmptyIndex()));
this._render();
}
});
}
_handlePointerDown(event) {
if (event.button !== 0 || this._input.matches(":disabled")) return;
this._touchPointer = event.pointerType === "touch";
const index = this._slotIndexFromPoint(event.clientX);
if (index === null) return;
const target = Math.min(index, this._firstEmptyIndex());
if (document.activeElement === this._input) {
if (!this._touchPointer) {
event.preventDefault();
this._selectSlot(target);
this._render();
}
return;
}
this._pointerActive = true;
this._pointerIndex = target;
}
_slotIndexFromPoint(x) {
const rtl = getComputedStyle(this._slotsContainer).direction === "rtl";
for (const [index, slot] of this._slots.entries()) {
const { left, right } = slot.getBoundingClientRect();
if ((rtl ? x >= left : x <= right) || index === this._slots.length - 1) return index;
}
return null;
}
_afterValueChange() {
this._render();
EventHandler.trigger(this._element, EVENT_INPUT$1, { value: this._input.value });
if (this._input) this._checkComplete();
}
_firstEmptyIndex() {
return Math.min(this._input.value.length, this._length - 1);
}
_isEditable() {
return !this._input.readOnly && !this._input.matches(":disabled");
}
_selectSlot(index) {
const clamped = Math.max(0, Math.min(index, this._length - 1));
const end = clamped < this._input.value.length ? clamped + 1 : clamped;
this._input.setSelectionRange(clamped, end);
}
_sanitize(value) {
return value.replace(this._type.filter, "").slice(0, this._length);
}
_render() {
const { value } = this._input;
const isFocused = document.activeElement === this._input;
const start = this._input.selectionStart ?? value.length;
const end = this._input.selectionEnd ?? start;
const caret = Math.min(start, this._length - 1);
for (const [index, slot] of this._slots.entries()) {
const char = value[index] ?? "";
const placeholder = value ? "" : this._input.placeholder[index] ?? "";
const text = char && this._config.mask ? MASK_CHARACTER : char || placeholder;
if (slot.textContent !== text) slot.textContent = text;
slot.classList.toggle(CLASS_NAME_SLOT_FILLED, Boolean(char));
slot.classList.toggle(CLASS_NAME_SLOT_ACTIVE, isFocused && index === caret);
slot.classList.toggle(CLASS_NAME_SLOT_SELECTED, isFocused && end - start > 1 && index >= start && index < end);
}
}
_checkComplete() {
const { value } = this._input;
const completeValue = value.length === this._length ? value : null;
const changed = completeValue !== this._lastCompleteValue;
this._lastCompleteValue = completeValue;
if (completeValue && changed) EventHandler.trigger(this._element, EVENT_COMPLETE, { value });
}
};
/**
* Data API implementation
*/
onDocumentReady(EVENT_DOMCONTENT_LOADED, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_OTP)) OtpInput.getOrCreateInstance(element);
});
//#endregion
//#region js/src/util/template-factory.ts
/**
* --------------------------------------------------------------------------
* Bootstrap util/template-factory.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$7 = "TemplateFactory";
const Default$6 = {
allowList: DefaultAllowlist,
content: {},
extraClass: "",
html: false,
sanitize: true,
sanitizeFn: null,
template: "
"
};
const DefaultType$6 = {
allowList: "object",
content: "object",
extraClass: "(string|function)",
html: "boolean",
sanitize: "boolean",
sanitizeFn: "(null|function)",
template: "string"
};
const DefaultContentType = {
entry: "(string|element|function|null)",
selector: "(string|element)"
};
/**
* Class definition
*/
var TemplateFactory = class extends Config {
constructor(config) {
super();
this._config = this._getConfig(config);
}
static get Default() {
return Default$6;
}
static get DefaultType() {
return DefaultType$6;
}
static get NAME() {
return NAME$7;
}
getContent() {
return Object.values(this._config.content).map((config) => this._resolvePossibleFunction(config)).filter(Boolean);
}
hasContent() {
return this.getContent().length > 0;
}
changeContent(content) {
this._checkContent(content);
this._config.content = {
...this._config.content,
...content
};
return this;
}
toHtml() {
const templateWrapper = document.createElement("div");
templateWrapper.innerHTML = this._maybeSanitize(this._config.template);
for (const [selector, text] of Object.entries(this._config.content)) this._setContent(templateWrapper, text, selector);
const template = templateWrapper.children[0];
const extraClass = this._resolvePossibleFunction(this._config.extraClass);
if (extraClass) template.classList.add(...extraClass.split(" "));
return template;
}
_typeCheckConfig(config) {
super._typeCheckConfig(config);
this._checkContent(config.content);
}
_checkContent(arg) {
for (const [selector, content] of Object.entries(arg)) super._typeCheckConfig({
selector,
entry: content
}, DefaultContentType);
}
_setContent(template, content, selector) {
const templateElement = SelectorEngine.findOne(selector, template);
if (!templateElement) return;
content = this._resolvePossibleFunction(content);
if (!content) {
templateElement.remove();
return;
}
if (isElement$1(content)) {
this._putElementInTemplate(getElement(content), templateElement);
return;
}
if (this._config.html) {
templateElement.innerHTML = this._maybeSanitize(content);
return;
}
templateElement.textContent = content;
}
_maybeSanitize(arg) {
return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg;
}
_resolvePossibleFunction(arg) {
return execute(arg, [void 0, this]);
}
_putElementInTemplate(element, templateElement) {
if (this._config.html) {
templateElement.innerHTML = "";
templateElement.append(element);
return;
}
templateElement.textContent = element.textContent;
}
};
//#endregion
//#region js/src/tooltip.ts
/**
* --------------------------------------------------------------------------
* Bootstrap tooltip.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$6 = "tooltip";
const DISALLOWED_ATTRIBUTES$1 = /* @__PURE__ */ new Set([
"sanitize",
"allowList",
"sanitizeFn"
]);
const ESCAPE_KEY = "Escape";
const CLASS_NAME_SHOW$2 = "show";
const SELECTOR_TOOLTIP_INNER = ".tooltip-inner";
const SELECTOR_DATA_TOGGLE$3 = "[data-bs-toggle=\"tooltip\"]";
const TRIGGER_HOVER = "hover";
const TRIGGER_FOCUS = "focus";
const TRIGGER_CLICK = "click";
const TRIGGER_MANUAL = "manual";
const EVENT_HIDE$2 = "hide";
const EVENT_HIDDEN$2 = "hidden";
const EVENT_SHOW$2 = "show";
const EVENT_SHOWN$2 = "shown";
const EVENT_INSERTED = "inserted";
const EVENT_CLICK$3 = "click";
const EVENT_FOCUSIN$2 = "focusin";
const EVENT_FOCUSOUT$1 = "focusout";
const EVENT_MOUSEENTER$1 = "mouseenter";
const EVENT_MOUSELEAVE = "mouseleave";
const EVENT_POINTERDOWN = "pointerdown";
const EVENT_POINTERUP = "pointerup";
const EVENT_KEYDOWN$1 = "keydown";
const AttachmentMap = {
AUTO: "auto",
TOP: "top",
RIGHT: isRTL$1() ? "left" : "right",
BOTTOM: "bottom",
LEFT: isRTL$1() ? "right" : "left"
};
const Default$5 = {
allowList: DefaultAllowlist,
animation: true,
boundary: "clippingParents",
container: false,
customClass: "",
delay: 0,
fallbackPlacements: [
"top",
"right",
"bottom",
"left"
],
html: false,
offset: [0, 6],
placement: "top",
floatingConfig: null,
sanitize: true,
sanitizeFn: null,
selector: false,
template: "",
title: "",
trigger: "hover focus"
};
const DefaultType$5 = {
allowList: "object",
animation: "boolean",
boundary: "(string|element)",
container: "(string|element|boolean)",
customClass: "(string|function)",
delay: "(number|object)",
fallbackPlacements: "array",
html: "boolean",
offset: "(array|string|function)",
placement: "(string|function)",
floatingConfig: "(null|object|function)",
sanitize: "boolean",
sanitizeFn: "(null|function)",
selector: "(string|boolean)",
template: "string",
title: "(string|element|function)",
trigger: "string"
};
/**
* Class definition
*/
var Tooltip = class extends BaseComponent {
constructor(element, config) {
if (typeof computePosition === "undefined") throw new TypeError("Bootstrap's tooltips require Floating UI (https://floating-ui.com)");
super(element, config);
this._isEnabled = true;
this._timeout = 0;
this._resolveTimeout = null;
this._isHovered = null;
this._activeTrigger = {};
this._floatingCleanup = null;
this._keydownHandler = null;
this._tipEventOut = null;
this._outsidePointerHandler = null;
this._tipPointerUpHandler = null;
this._tipPointerDown = false;
this._templateFactory = null;
this._newContent = null;
this._mediaQueryListeners = [];
this._responsivePlacements = null;
this.tip = null;
this._parseResponsivePlacements();
this._setListeners();
if (!this._config.selector) this._fixTitle();
}
static get Default() {
return Default$5;
}
static get DefaultType() {
return DefaultType$5;
}
static get NAME() {
return NAME$6;
}
enable() {
this._isEnabled = true;
}
disable() {
this._isEnabled = false;
}
toggleEnabled() {
this._isEnabled = !this._isEnabled;
}
toggle() {
if (!this._isEnabled) return Promise.resolve();
return this._isShown() ? this._leave() : this._enter();
}
dispose() {
this._clearTimeout();
this._removeEscapeListener();
this._removeFocusOutsideListener();
if (this._element.getAttribute("data-bs-original-title")) this._element.setAttribute("title", this._element.getAttribute("data-bs-original-title"));
this._disposeFloating();
this._disposeMediaQueryListeners();
super.dispose();
}
async show() {
if (this._element.style.display === "none") throw new Error("Please use show on visible elements");
if (!(this._isWithContent() && this._isEnabled)) return;
const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2));
const isInTheDom = (findShadowRoot(this._element) || this._element.ownerDocument.documentElement).contains(this._element);
if (showEvent.defaultPrevented || !isInTheDom) {
this._isHovered = false;
return;
}
this._disposeFloating();
const tip = this._getTipElement();
this._element.setAttribute("aria-describedby", tip.getAttribute("id"));
let { container } = this._config;
const closestDialog = this._element.closest("dialog[open]");
if (closestDialog && container === document.body) container = closestDialog;
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
container.append(tip);
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
this._setTipListeners(tip);
}
await this._createFloating(tip);
tip.classList.add(CLASS_NAME_SHOW$2);
this._setEscapeListener();
this._setFocusOutsideListener();
if ("ontouchstart" in document.documentElement) for (const element of document.body.children) EventHandler.on(element, "mouseover", noop);
const complete = () => {
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2));
if (this._isHovered === false) this._leave();
this._isHovered = null;
};
await this._queueCallback(complete, this.tip, this._isAnimated());
}
async hide() {
if (!this._isShown()) return;
if (EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2)).defaultPrevented) return;
this._removeEscapeListener();
this._removeFocusOutsideListener();
this._getTipElement().classList.remove(CLASS_NAME_SHOW$2);
if ("ontouchstart" in document.documentElement) for (const element of document.body.children) EventHandler.off(element, "mouseover", noop);
this._activeTrigger[TRIGGER_CLICK] = false;
this._activeTrigger[TRIGGER_FOCUS] = false;
this._activeTrigger[TRIGGER_HOVER] = false;
this._isHovered = null;
const complete = () => {
if (this._isWithActiveTrigger()) return;
if (!this._isHovered) this._disposeFloating();
this._element.removeAttribute("aria-describedby");
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2));
};
await this._queueCallback(complete, this.tip, this._isAnimated());
}
update() {
if (this._floatingCleanup && this.tip) this._updateFloatingPosition();
}
_isWithContent() {
return Boolean(this._getTitle()) || this._hasNewContent();
}
_hasNewContent() {
return Boolean(this._newContent) && Object.values(this._newContent).some(Boolean);
}
_getTipElement() {
if (!this.tip) this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
return this.tip;
}
_createTipElement(content) {
const tip = this._getTemplateFactory(content).toHtml();
tip.classList.remove(CLASS_NAME_SHOW$2);
tip.classList.add(`bs-${this.constructor.NAME}-auto`);
const tipId = getUID(this.constructor.NAME).toString();
tip.setAttribute("id", tipId);
if (!this._config.animation) tip.classList.add(this._getInstantClassName());
this._setFocusTipListeners(tip);
return tip;
}
setContent(content) {
this._newContent = content;
if (this._isShown()) {
this._disposeFloating();
this.show();
}
}
_getTemplateFactory(content) {
if (this._templateFactory) this._templateFactory.changeContent(content);
else this._templateFactory = new TemplateFactory({
...this._config,
content,
extraClass: this._resolvePossibleFunction(this._config.customClass)
});
return this._templateFactory;
}
_getContentForTemplate() {
return { [SELECTOR_TOOLTIP_INNER]: this._getTitle() };
}
_getTitle() {
return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute("data-bs-original-title");
}
_initializeOnDelegatedTarget(event) {
return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
}
_getInstantClassName() {
return `${this.constructor.NAME}-instant`;
}
_isAnimated() {
return getTransitionDurationFromElement(this.tip) > 0;
}
_isShown() {
return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2);
}
_getPlacement(tip) {
if (this._responsivePlacements) {
const placement = getResponsivePlacement(this._responsivePlacements, "top");
return AttachmentMap[placement.toUpperCase()] || placement;
}
const placement = execute(this._config.placement, [
this,
tip,
this._element
]);
return AttachmentMap[placement.toUpperCase()] || placement;
}
_parseResponsivePlacements() {
if (typeof this._config.placement !== "string") {
this._responsivePlacements = null;
return;
}
this._responsivePlacements = parseResponsivePlacement(this._config.placement, "top");
if (this._responsivePlacements) this._setupMediaQueryListeners();
}
_setupMediaQueryListeners() {
this._disposeMediaQueryListeners();
this._mediaQueryListeners = createBreakpointListeners(() => {
if (this._isShown()) this._updateFloatingPosition();
});
}
_disposeMediaQueryListeners() {
disposeBreakpointListeners(this._mediaQueryListeners);
this._mediaQueryListeners = [];
}
async _createFloating(tip) {
const placement = this._getPlacement(tip);
const arrowElement = tip.querySelector(`.${this.constructor.NAME}-arrow`);
await this._updateFloatingPosition(tip, placement, arrowElement);
this._floatingCleanup = autoUpdate(this._element, tip, () => this._updateFloatingPosition(tip, null, arrowElement));
}
async _updateFloatingPosition(tip = this.tip, placement = null, arrowElement = null) {
if (!tip) return;
if (!placement) placement = this._getPlacement(tip);
if (!arrowElement) arrowElement = tip.querySelector(`.${this.constructor.NAME}-arrow`);
const middleware = this._getFloatingMiddleware(arrowElement);
const floatingConfig = this._getFloatingConfig(placement, middleware);
const { x, y, placement: finalPlacement, middlewareData } = await computePosition(this._element, tip, floatingConfig);
Object.assign(tip.style, {
position: "absolute",
left: `${x}px`,
top: `${y}px`
});
if (arrowElement) arrowElement.style.position = "absolute";
Manipulator.setDataAttribute(tip, "placement", finalPlacement);
if (arrowElement && middlewareData.arrow) {
const { x: arrowX, y: arrowY } = middlewareData.arrow;
const isVertical = finalPlacement.startsWith("top") || finalPlacement.startsWith("bottom");
Object.assign(arrowElement.style, {
left: isVertical && arrowX !== void 0 ? `${arrowX}px` : "",
top: !isVertical && arrowY !== void 0 ? `${arrowY}px` : "",
right: "",
bottom: ""
});
}
}
_getOffset() {
const { offset } = this._config;
if (typeof offset === "string") return offset.split(",").map((value) => Number.parseInt(value, 10));
if (typeof offset === "function") return ({ placement, rects }) => {
return toFloatingOffset(offset({
placement,
reference: rects.reference,
floating: rects.floating
}, this._element));
};
return offset;
}
_resolvePossibleFunction(arg) {
return execute(arg, [this._element, this._element]);
}
_getFloatingMiddleware(arrowElement) {
const offsetValue = this._getOffset();
const middleware = [
offset(typeof offsetValue === "function" ? offsetValue : toFloatingOffset(offsetValue)),
flip({ fallbackPlacements: this._config.fallbackPlacements }),
shift({ boundary: this._config.boundary === "clippingParents" ? "clippingAncestors" : this._config.boundary })
];
if (arrowElement) middleware.push(arrow({ element: arrowElement }));
return middleware;
}
_getFloatingConfig(placement, middleware) {
const defaultConfig = {
placement,
middleware
};
return {
...defaultConfig,
...execute(this._config.floatingConfig, [void 0, defaultConfig])
};
}
_setListeners() {
const triggers = this._config.trigger.split(" ");
for (const trigger of triggers) if (trigger === "click") EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$3), this._config.selector, (event) => {
const context = this._initializeOnDelegatedTarget(event);
context._activeTrigger[TRIGGER_CLICK] = !(context._isShown() && context._activeTrigger[TRIGGER_CLICK]);
context.toggle();
});
else if (trigger !== TRIGGER_MANUAL) {
const [eventIn, eventOut] = this._getTriggerEvents(trigger);
EventHandler.on(this._element, eventIn, this._config.selector, (event) => {
const context = this._initializeOnDelegatedTarget(event);
context._activeTrigger[event.type === "focusin" ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
context._enter();
});
EventHandler.on(this._element, eventOut, this._config.selector, (event) => {
const context = this._initializeOnDelegatedTarget(event);
if (event.type === "focusout") context._activeTrigger[TRIGGER_FOCUS] = context._isInside(event.relatedTarget) || context._tipPointerDown;
else context._activeTrigger[TRIGGER_HOVER] = context._isInside(event.relatedTarget);
context._leave();
});
}
}
_setTipListeners(tip) {
const trigger = this._getTrigger();
if (trigger === TRIGGER_MANUAL || trigger.includes(TRIGGER_CLICK)) return;
this._tipEventOut = (event) => {
this._activeTrigger[event.type === "focusout" ? TRIGGER_FOCUS : TRIGGER_HOVER] = this._isInside(event.relatedTarget);
this._leave();
};
for (const name of trigger.split(" ")) if (name === TRIGGER_HOVER || name === TRIGGER_FOCUS) {
const [, eventOut] = this._getTriggerEvents(name);
EventHandler.on(tip, eventOut, this._tipEventOut);
}
}
_removeTipListeners(tip) {
if (!this._tipEventOut) return;
const trigger = this._getTrigger();
for (const name of trigger.split(" ")) if (name === TRIGGER_HOVER || name === TRIGGER_FOCUS) {
const [, eventOut] = this._getTriggerEvents(name);
EventHandler.off(tip, eventOut, this._tipEventOut);
}
this._tipEventOut = null;
}
_isInside(target) {
return target instanceof Node && (this._element.contains(target) || Boolean(this.tip?.contains(target)));
}
_getTrigger() {
return this._config._trigger;
}
_getTriggerEvents(trigger) {
return {
[TRIGGER_HOVER]: [this.constructor.eventName(EVENT_MOUSEENTER$1), this.constructor.eventName(EVENT_MOUSELEAVE)],
[TRIGGER_FOCUS]: [this.constructor.eventName(EVENT_FOCUSIN$2), this.constructor.eventName(EVENT_FOCUSOUT$1)]
}[trigger];
}
_hasFocusTrigger() {
return this._getTrigger().split(" ").includes(TRIGGER_FOCUS);
}
_setFocusTipListeners(tip) {
if (!this._hasFocusTrigger()) return;
EventHandler.on(tip, this.constructor.eventName(EVENT_POINTERDOWN), () => {
this._tipPointerDown = true;
this._activeTrigger[TRIGGER_FOCUS] = true;
});
EventHandler.on(tip, this.constructor.eventName(EVENT_FOCUSIN$2), () => {
this._activeTrigger[TRIGGER_FOCUS] = true;
});
EventHandler.on(tip, this.constructor.eventName(EVENT_FOCUSOUT$1), (event) => {
this._activeTrigger[TRIGGER_FOCUS] = this._isInside(event.relatedTarget) || this._tipPointerDown;
this._leave();
});
}
_setFocusOutsideListener() {
if (this._outsidePointerHandler || !this._hasFocusTrigger()) return;
this._tipPointerUpHandler = () => {
this._tipPointerDown = false;
};
this._outsidePointerHandler = (event) => {
if (!this._isShown() || this._isInside(event.target)) return;
this._activeTrigger[TRIGGER_FOCUS] = false;
this.hide();
};
const doc = this._element.ownerDocument;
doc.addEventListener(EVENT_POINTERUP, this._tipPointerUpHandler, true);
doc.addEventListener(EVENT_POINTERDOWN, this._outsidePointerHandler, true);
}
_removeFocusOutsideListener() {
const doc = this._element?.ownerDocument;
if (this._tipPointerUpHandler && doc) doc.removeEventListener(EVENT_POINTERUP, this._tipPointerUpHandler, true);
if (this._outsidePointerHandler && doc) doc.removeEventListener(EVENT_POINTERDOWN, this._outsidePointerHandler, true);
this._tipPointerUpHandler = null;
this._outsidePointerHandler = null;
this._tipPointerDown = false;
}
_setEscapeListener() {
if (this._keydownHandler) return;
this._keydownHandler = (event) => {
if (event.key !== ESCAPE_KEY || !this._isShown() || !this.tip.isConnected) return;
event.preventDefault();
event.stopPropagation();
this.hide();
};
this._element.ownerDocument.addEventListener(EVENT_KEYDOWN$1, this._keydownHandler, true);
}
_removeEscapeListener() {
if (!this._keydownHandler) return;
this._element.ownerDocument.removeEventListener(EVENT_KEYDOWN$1, this._keydownHandler, true);
this._keydownHandler = null;
}
_fixTitle() {
const title = this._element.getAttribute("title");
if (!title) return;
if (!this._element.getAttribute("aria-label") && !this._element.textContent.trim()) this._element.setAttribute("aria-label", title);
this._element.setAttribute("data-bs-original-title", title);
this._element.removeAttribute("title");
}
_enter() {
if (this._isShown() || this._isHovered) {
this._isHovered = true;
return Promise.resolve();
}
this._isHovered = true;
return this._setTimeout(() => this._isHovered ? this.show() : void 0, this._config.delay.show);
}
_leave() {
if (this._isWithActiveTrigger()) return Promise.resolve();
this._isHovered = false;
return this._setTimeout(() => this._isHovered ? void 0 : this.hide(), this._config.delay.hide);
}
_setTimeout(handler, timeout) {
this._clearTimeout();
return new Promise((resolve) => {
this._resolveTimeout = resolve;
this._timeout = setTimeout(() => {
this._resolveTimeout = null;
resolve(handler());
}, timeout);
});
}
_clearTimeout() {
clearTimeout(this._timeout);
if (this._resolveTimeout) {
this._resolveTimeout();
this._resolveTimeout = null;
}
}
_isWithActiveTrigger() {
return Object.values(this._activeTrigger).includes(true);
}
_getConfig(config) {
const dataAttributes = Manipulator.getDataAttributes(this._element);
for (const dataAttribute of Object.keys(dataAttributes)) if (DISALLOWED_ATTRIBUTES$1.has(dataAttribute)) delete dataAttributes[dataAttribute];
if (this._element.getAttribute("data-bs-title") !== null) dataAttributes.title = this._element.getAttribute("data-bs-title");
if (this._element.getAttribute("data-bs-content") !== null) dataAttributes.content = this._element.getAttribute("data-bs-content");
config = {
...dataAttributes,
...typeof config === "object" && config ? config : {}
};
config = this._mergeConfigObj(config);
config = this._configAfterMerge(config);
this._typeCheckConfig(config);
return config;
}
_configAfterMerge(config) {
config.container = config.container === false ? document.body : getElement(config.container);
config._trigger = config._trigger || config.trigger;
if (typeof config.delay === "number") config.delay = {
show: config.delay,
hide: config.delay
};
if (config.title === null) config.title = "";
else if (typeof config.title === "number" || typeof config.title === "boolean") config.title = config.title.toString();
if (config.content === null) config.content = "";
else if (typeof config.content === "number" || typeof config.content === "boolean") config.content = config.content.toString();
return config;
}
_getDelegateConfig() {
const config = {};
for (const [key, value] of Object.entries(this._config)) if (this.constructor.Default[key] !== value) config[key] = value;
config.selector = false;
config.trigger = "manual";
return config;
}
_disposeFloating() {
if (this._floatingCleanup) {
this._floatingCleanup();
this._floatingCleanup = null;
}
if (this.tip) {
this._removeTipListeners(this.tip);
EventHandler.off(this.tip, this.constructor.EVENT_KEY);
this.tip.remove();
this.tip = null;
}
}
};
/**
* Data API implementation - auto-initialize tooltips
*/
const initTooltip = (event) => {
const target = event.target.closest(SELECTOR_DATA_TOGGLE$3);
if (!target) return;
Tooltip.getOrCreateInstance(target);
};
EventHandler.on(document, EVENT_FOCUSIN$2, SELECTOR_DATA_TOGGLE$3, initTooltip);
EventHandler.on(document, EVENT_MOUSEENTER$1, SELECTOR_DATA_TOGGLE$3, initTooltip);
//#endregion
//#region js/src/popover.ts
/**
* --------------------------------------------------------------------------
* Bootstrap popover.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$5 = "popover";
const SELECTOR_TITLE = ".popover-header";
const SELECTOR_CONTENT = ".popover-body";
const SELECTOR_DATA_TOGGLE$2 = "[data-bs-toggle=\"popover\"]";
const EVENT_CLICK$2 = "click";
const EVENT_FOCUSIN$1 = "focusin";
const EVENT_MOUSEENTER = "mouseenter";
const Default$4 = {
...Tooltip.Default,
content: "",
offset: [0, 8],
placement: "right",
template: "",
trigger: "click"
};
const DefaultType$4 = {
...Tooltip.DefaultType,
content: "(null|string|element|function)"
};
/**
* Class definition
*/
var Popover = class extends Tooltip {
constructor(element, config) {
super(element, config);
}
static get Default() {
return Default$4;
}
static get DefaultType() {
return DefaultType$4;
}
static get NAME() {
return NAME$5;
}
_isWithContent() {
return Boolean(this._getTitle() || this._getContent()) || this._hasNewContent();
}
_getContentForTemplate() {
return {
[SELECTOR_TITLE]: this._getTitle(),
[SELECTOR_CONTENT]: this._getContent()
};
}
_getContent() {
return this._resolvePossibleFunction(this._config.content);
}
};
/**
* Data API implementation - auto-initialize popovers
*/
const initPopover = (event) => {
const target = event.target.closest(SELECTOR_DATA_TOGGLE$2);
if (!target) return;
const popover = Popover.getOrCreateInstance(target);
if (event.type === "click" && popover._getTrigger().split(" ").includes("click")) event.preventDefault();
};
EventHandler.on(document, EVENT_CLICK$2, SELECTOR_DATA_TOGGLE$2, initPopover);
EventHandler.on(document, EVENT_FOCUSIN$1, SELECTOR_DATA_TOGGLE$2, initPopover);
EventHandler.on(document, EVENT_MOUSEENTER, SELECTOR_DATA_TOGGLE$2, initPopover);
//#endregion
//#region js/src/range.ts
/**
* --------------------------------------------------------------------------
* Bootstrap range.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$4 = "range";
const EVENT_KEY$4 = `.bs.range`;
const DATA_API_KEY$1 = ".data-api";
const EVENT_CHANGED = `changed${EVENT_KEY$4}`;
const EVENT_DOM_CONTENT_LOADED = `DOMContentLoaded${EVENT_KEY$4}${DATA_API_KEY$1}`;
const EVENT_INPUT = "input";
const EVENT_CHANGE = "change";
const EVENT_RESET = "reset";
const SELECTOR_RANGE = ".form-range";
const SELECTOR_INPUT = ".form-range-input";
const CLASS_NAME_BUBBLE = "form-range-bubble";
const CLASS_NAME_TICKS = "form-range-ticks";
const CLASS_NAME_TICK = "form-range-tick";
const CLASS_NAME_TICK_LABEL = "form-range-tick-label";
const PROPERTY_FILL = "--bs-range-fill";
const Default$3 = {
bubble: false,
formatter: null
};
const DefaultType$3 = {
bubble: "(boolean|null)",
formatter: "(function|null)"
};
/**
* Class definition
*/
var Range = class extends BaseComponent {
constructor(element, config) {
super(element, config);
if (!this._element) return;
this._input = SelectorEngine.findOne(SELECTOR_INPUT, this._element);
if (!this._input) return;
this._bubble = null;
this._bubbleText = null;
this._ticks = null;
this._updateHandler = () => this._update();
this._initialConfig = { ...config };
this._form = null;
this._resetTimeouts = /* @__PURE__ */ new Set();
this._resetHandler = (event) => {
const timeout = window.setTimeout(() => {
this._resetTimeouts.delete(timeout);
if (!event.defaultPrevented) this._update();
}, 0);
this._resetTimeouts.add(timeout);
};
this._syncBubble();
this._syncForm();
this._createTicks();
this._addEventListeners();
this._update();
}
static get Default() {
return Default$3;
}
static get DefaultType() {
return DefaultType$3;
}
static get NAME() {
return NAME$4;
}
update() {
if (!this._input) return;
this._config = this._getConfig(this._initialConfig);
this._syncBubble();
this._ticks?.remove();
this._ticks = null;
this._createTicks();
this._syncForm();
this._update();
}
dispose() {
EventHandler.off(this._input, EVENT_INPUT, this._updateHandler);
EventHandler.off(this._input, EVENT_CHANGE, this._updateHandler);
EventHandler.off(this._form, EVENT_RESET, this._resetHandler);
this._resetTimeouts?.forEach((timeout) => clearTimeout(timeout));
this._bubble?.remove();
this._ticks?.remove();
super.dispose();
}
_configAfterMerge(config) {
if (config.bubble === null) config.bubble = true;
return config;
}
_syncBubble() {
if (this._config.bubble) {
if (!this._bubble) this._createBubble();
} else {
this._bubble?.remove();
this._bubble = null;
this._bubbleText = null;
}
}
_syncForm() {
const { form } = this._input;
if (form === this._form) return;
EventHandler.off(this._form, EVENT_RESET, this._resetHandler);
this._resetTimeouts.forEach((timeout) => clearTimeout(timeout));
this._resetTimeouts.clear();
this._form = form;
EventHandler.on(this._form, EVENT_RESET, this._resetHandler);
}
_addEventListeners() {
EventHandler.on(this._input, EVENT_INPUT, this._updateHandler);
EventHandler.on(this._input, EVENT_CHANGE, this._updateHandler);
}
_min() {
return this._input.min === "" ? 0 : Number.parseFloat(this._input.min);
}
_max() {
return this._input.max === "" ? 100 : Number.parseFloat(this._input.max);
}
_value() {
return Number.parseFloat(this._input.value);
}
_ratio() {
const span = this._max() - this._min();
return span > 0 ? (this._value() - this._min()) / span : 0;
}
_update() {
this._element.style.setProperty(PROPERTY_FILL, `${this._ratio()}`);
if (this._bubbleText) this._bubbleText.textContent = this._format(this._value());
EventHandler.trigger(this._input, EVENT_CHANGED, { value: this._value() });
}
_format(value) {
return typeof this._config.formatter === "function" ? this._config.formatter(value) : String(value);
}
_createBubble() {
this._bubble = document.createElement("div");
this._bubble.className = `${CLASS_NAME_BUBBLE} tooltip bs-tooltip-top show`;
this._bubble.setAttribute("aria-hidden", "true");
const arrow = document.createElement("div");
arrow.className = "tooltip-arrow";
this._bubbleText = document.createElement("div");
this._bubbleText.className = "tooltip-inner";
this._bubble.append(arrow, this._bubbleText);
this._input.insertAdjacentElement("afterend", this._bubble);
}
_createTicks() {
const listId = this._input.getAttribute("list");
const datalist = listId ? document.getElementById(listId) : null;
if (!datalist) return;
const min = this._min();
const span = this._max() - min || 1;
const points = [];
for (const option of SelectorEngine.find("option", datalist)) {
const value = Number.parseFloat(option.value);
if (!Number.isNaN(value)) {
const ratio = Math.min(Math.max((value - min) / span, 0), 1);
points.push({
ratio,
label: option.label
});
}
}
if (points.length === 0) return;
points.sort((a, b) => a.ratio - b.ratio);
this._ticks = document.createElement("div");
this._ticks.className = CLASS_NAME_TICKS;
this._ticks.setAttribute("aria-hidden", "true");
const stops = [
0,
...points.map((point) => point.ratio),
1
];
this._ticks.style.gridTemplateColumns = stops.slice(1).map((stop, index) => `${stop - stops[index]}fr`).join(" ");
for (const [index, point] of points.entries()) {
const tick = document.createElement("span");
tick.className = CLASS_NAME_TICK;
tick.style.gridColumnStart = `${index + 2}`;
if (point.label) {
const label = document.createElement("span");
label.className = CLASS_NAME_TICK_LABEL;
label.textContent = point.label;
tick.append(label);
}
this._ticks.append(tick);
}
this._element.append(this._ticks);
}
};
/**
* Data API implementation
*/
onDocumentReady(EVENT_DOM_CONTENT_LOADED, () => {
for (const element of SelectorEngine.find(SELECTOR_RANGE)) Range.getOrCreateInstance(element);
});
//#endregion
//#region js/src/scrollspy.ts
/**
* --------------------------------------------------------------------------
* Bootstrap scrollspy.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$3 = "scrollspy";
const EVENT_KEY$3 = `.bs.scrollspy`;
const DATA_API_KEY = ".data-api";
const EVENT_ACTIVATE = `activate${EVENT_KEY$3}`;
const EVENT_CLICK$1 = `click${EVENT_KEY$3}`;
const EVENT_SCROLL = `scroll${EVENT_KEY$3}`;
const EVENT_SCROLLEND = `scrollend${EVENT_KEY$3}`;
const EVENT_RESIZE = `resize${EVENT_KEY$3}`;
const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$3}${DATA_API_KEY}`;
const CLASS_NAME_MENU_ITEM = "menu-item";
const CLASS_NAME_ACTIVE$1 = "active";
const SELECTOR_DATA_SPY = "[data-bs-spy=\"scroll\"]";
const SELECTOR_TARGET_LINKS = "[href]";
const SELECTOR_NAV_LIST_GROUP = ".nav, .list-group";
const SELECTOR_NAV_LINKS = ".nav-link";
const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, .nav-item > ${SELECTOR_NAV_LINKS}, .list-group-item`;
const SELECTOR_MENU_TOGGLE$1 = "[data-bs-toggle=\"menu\"]";
const SCROLL_IDLE_TIMEOUT = 100;
const RESIZE_DEBOUNCE = 100;
const Default$2 = {
rootMargin: null,
smoothScroll: false,
target: null,
threshold: [0],
topMargin: "12%"
};
const DefaultType$2 = {
rootMargin: "(string|null)",
smoothScroll: "boolean",
target: "element",
threshold: "array",
topMargin: "string"
};
/**
* Class definition
*/
var ScrollSpy = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._sections = [];
this._linkBySection = /* @__PURE__ */ new Map();
this._sectionByLink = /* @__PURE__ */ new Map();
this._intersecting = /* @__PURE__ */ new Set();
this._activeTarget = null;
this._lastActive = null;
this._atBottom = false;
this._rootElement = getComputedStyle(this._element).overflowY === "visible" ? null : this._element;
this._observer = null;
this._sentinel = null;
this._sentinelObserver = null;
this._pendingNavigation = null;
this._settleTimeout = null;
this._settleHandler = null;
this._scrollIdleHandler = null;
this._resizeHandler = null;
this._resizeTimeout = null;
this.refresh();
}
static get Default() {
return Default$2;
}
static get DefaultType() {
return DefaultType$2;
}
static get NAME() {
return NAME$3;
}
refresh() {
this._initializeTargetsAndObservables();
this._maybeEnableSmoothScroll();
this._observer?.disconnect();
this._intersecting.clear();
this._observer = this._getNewObserver();
for (const section of this._sections) this._observer.observe(section);
this._setUpSentinel();
this._maybeAddResizeListener();
}
dispose() {
this._observer?.disconnect();
this._teardownSentinel();
this._disarmSettle();
this._removeResizeListener();
EventHandler.off(this._config.target, EVENT_CLICK$1);
super.dispose();
}
_configAfterMerge(config) {
config.target = getElement(config.target) || document.body;
if (typeof config.threshold === "string") config.threshold = config.threshold.split(",").map((value) => Number.parseFloat(value));
return config;
}
_getNewObserver() {
const options = {
root: this._rootElement,
threshold: this._config.threshold,
rootMargin: this._config.rootMargin ?? this._getDerivedRootMargin()
};
return new IntersectionObserver((entries) => this._onIntersect(entries), options);
}
_onIntersect(entries) {
for (const entry of entries) if (entry.isIntersecting) this._intersecting.add(entry.target);
else this._intersecting.delete(entry.target);
this._computeActive();
}
_computeActive() {
if (!this._element?.isConnected || this._sections.length === 0) return;
let active = null;
if (this._atBottom) active = this._sections.at(-1);
else {
for (const section of this._sections) if (this._intersecting.has(section)) active = section;
active ||= this._lastActive ?? this._sections.at(0);
}
if (!active) return;
this._lastActive = active;
const link = this._linkBySection.get(active);
if (link) this._process(link);
}
_parseTopMargin() {
const value = String(this._config.topMargin);
return {
value: Number.parseFloat(value) || 0,
unit: value.endsWith("%") ? "%" : "px"
};
}
_getDerivedRootMargin() {
const { value, unit } = this._parseTopMargin();
let percent = value;
if (unit === "px") {
const rootHeight = this._rootElement ? this._rootElement.clientHeight : document.documentElement.clientHeight || window.innerHeight;
percent = rootHeight ? value / rootHeight * 100 : 12;
}
return `0px 0px -${Math.min(Math.max(100 - percent, 0), 100)}% 0px`;
}
_usesPixelMargin() {
return !this._config.rootMargin && this._parseTopMargin().unit === "px";
}
_setUpSentinel() {
this._teardownSentinel();
if (this._sections.length === 0) return;
const sentinel = document.createElement("div");
sentinel.setAttribute("aria-hidden", "true");
sentinel.style.cssText = "position:relative;width:0;height:0;margin:0;padding:0;border:0;visibility:hidden;";
this._element.append(sentinel);
this._sentinel = sentinel;
this._sentinelObserver = new IntersectionObserver((entries) => this._onSentinel(entries), {
root: this._rootElement,
threshold: [0]
});
this._sentinelObserver.observe(sentinel);
}
_onSentinel(entries) {
const entry = entries.at(-1);
this._atBottom = Boolean(entry?.isIntersecting) && this._isOverflowing();
this._computeActive();
}
_isOverflowing() {
const scroller = this._rootElement || document.scrollingElement || document.documentElement;
return scroller.scrollHeight > scroller.clientHeight;
}
_teardownSentinel() {
this._sentinelObserver?.disconnect();
this._sentinelObserver = null;
this._sentinel?.remove();
this._sentinel = null;
this._atBottom = false;
}
_maybeAddResizeListener() {
this._removeResizeListener();
if (!this._usesPixelMargin()) return;
this._resizeHandler = () => {
clearTimeout(this._resizeTimeout);
this._resizeTimeout = setTimeout(() => this._rebuildObserver(), RESIZE_DEBOUNCE);
};
EventHandler.on(window, EVENT_RESIZE, this._resizeHandler);
}
_removeResizeListener() {
clearTimeout(this._resizeTimeout);
this._resizeTimeout = null;
if (this._resizeHandler) {
EventHandler.off(window, EVENT_RESIZE, this._resizeHandler);
this._resizeHandler = null;
}
}
_rebuildObserver() {
if (!this._observer) return;
this._observer.disconnect();
this._intersecting.clear();
this._observer = this._getNewObserver();
for (const section of this._sections) this._observer.observe(section);
}
_maybeEnableSmoothScroll() {
if (!this._config.smoothScroll) return;
EventHandler.off(this._config.target, EVENT_CLICK$1);
EventHandler.on(this._config.target, EVENT_CLICK$1, SELECTOR_TARGET_LINKS, (event) => {
const link = event.target.closest(SELECTOR_TARGET_LINKS);
const section = link && this._sectionByLink.get(link);
if (!section || !this._element) return;
event.preventDefault();
const root = this._rootElement || window;
const height = section.offsetTop - this._element.offsetTop;
const currentTop = this._rootElement ? this._rootElement.scrollTop : window.scrollY ?? window.pageYOffset;
if (matchMedia("(prefers-reduced-motion: reduce)").matches || Math.abs(currentTop - height) <= 2) {
if (root.scrollTo) root.scrollTo({
top: height,
behavior: "auto"
});
else root.scrollTop = height;
this._settleNavigation(link.hash, section);
return;
}
this._pendingNavigation = {
hash: link.hash,
section
};
this._armSettle();
if (root.scrollTo) root.scrollTo({
top: height,
behavior: "smooth"
});
else root.scrollTop = height;
});
}
_armSettle() {
this._disarmSettle();
const target = this._getSettleTarget();
this._settleHandler = () => this._onSettle();
this._scrollIdleHandler = () => {
clearTimeout(this._settleTimeout);
this._settleTimeout = setTimeout(() => this._onSettle(), SCROLL_IDLE_TIMEOUT);
};
EventHandler.on(target, EVENT_SCROLLEND, this._settleHandler);
EventHandler.on(target, EVENT_SCROLL, this._scrollIdleHandler);
}
_disarmSettle() {
clearTimeout(this._settleTimeout);
this._settleTimeout = null;
const target = this._getSettleTarget();
if (this._settleHandler) {
EventHandler.off(target, EVENT_SCROLLEND, this._settleHandler);
this._settleHandler = null;
}
if (this._scrollIdleHandler) {
EventHandler.off(target, EVENT_SCROLL, this._scrollIdleHandler);
this._scrollIdleHandler = null;
}
}
_getSettleTarget() {
return this._rootElement || document;
}
_onSettle() {
this._disarmSettle();
if (!this._pendingNavigation) return;
const { hash, section } = this._pendingNavigation;
this._settleNavigation(hash, section);
}
_settleNavigation(hash, section) {
this._pendingNavigation = null;
if (window.history?.replaceState) window.history.replaceState(null, "", hash);
if (!section.hasAttribute("tabindex")) section.setAttribute("tabindex", "-1");
section.focus({ preventScroll: true });
}
_initializeTargetsAndObservables() {
this._sections = [];
this._linkBySection = /* @__PURE__ */ new Map();
this._sectionByLink = /* @__PURE__ */ new Map();
const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
const seen = /* @__PURE__ */ new Set();
for (const anchor of targetLinks) {
if (!anchor.hash || isDisabled(anchor)) continue;
const id = decodeFragment(anchor.hash.slice(1));
if (!id) continue;
const section = document.getElementById(id);
if (!section || !this._element.contains(section) || !isVisible(section)) continue;
this._sectionByLink.set(anchor, section);
this._linkBySection.set(section, anchor);
if (!seen.has(section)) {
seen.add(section);
this._sections.push(section);
}
}
this._sections.sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
}
_process(target) {
if (this._activeTarget === target) return;
this._clearActiveClass(this._config.target);
this._activeTarget = target;
target.classList.add(CLASS_NAME_ACTIVE$1);
this._activateParents(target);
EventHandler.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target });
}
_activateParents(target) {
if (target.classList.contains(CLASS_NAME_MENU_ITEM)) {
const menuToggle = target.closest(".menu")?.previousElementSibling;
if (menuToggle?.matches(SELECTOR_MENU_TOGGLE$1)) menuToggle.classList.add(CLASS_NAME_ACTIVE$1);
return;
}
for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) item.classList.add(CLASS_NAME_ACTIVE$1);
}
_clearActiveClass(parent) {
parent.classList.remove(CLASS_NAME_ACTIVE$1);
const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent);
for (const node of activeNodes) node.classList.remove(CLASS_NAME_ACTIVE$1);
}
};
function decodeFragment(hash) {
try {
return decodeURIComponent(hash);
} catch {
return hash;
}
}
/**
* Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) ScrollSpy.getOrCreateInstance(spy);
});
//#endregion
//#region js/src/tab.ts
/**
* --------------------------------------------------------------------------
* Bootstrap tab.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$2 = "tab";
const EVENT_KEY$2 = `.bs.tab`;
const EVENT_HIDE$1 = `hide${EVENT_KEY$2}`;
const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$2}`;
const EVENT_SHOW$1 = `show${EVENT_KEY$2}`;
const EVENT_SHOWN$1 = `shown${EVENT_KEY$2}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY$2}`;
const EVENT_KEYDOWN = `keydown${EVENT_KEY$2}`;
const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}`;
const ARROW_LEFT_KEY = "ArrowLeft";
const ARROW_RIGHT_KEY = "ArrowRight";
const ARROW_UP_KEY = "ArrowUp";
const ARROW_DOWN_KEY = "ArrowDown";
const HOME_KEY = "Home";
const END_KEY = "End";
const CLASS_NAME_ACTIVE = "active";
const CLASS_NAME_SHOW$1 = "show";
const SELECTOR_MENU_TOGGLE = "[data-bs-toggle=\"menu\"]";
const SELECTOR_MENU = ".menu";
const NOT_SELECTOR_MENU_TOGGLE = `:not(${SELECTOR_MENU_TOGGLE})`;
const SELECTOR_TAB_PANEL = ".list-group, .nav, [role=\"tablist\"]";
const SELECTOR_OUTER = ".nav-item, .list-group-item";
const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_MENU_TOGGLE}, .list-group-item${NOT_SELECTOR_MENU_TOGGLE}, [role="tab"]${NOT_SELECTOR_MENU_TOGGLE}`;
const SELECTOR_DATA_TOGGLE$1 = "[data-bs-toggle=\"tab\"]";
const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE$1}`;
const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"]`;
const activationIds = /* @__PURE__ */ new WeakMap();
/**
* Class definition
*/
var Tab = class Tab extends BaseComponent {
constructor(element) {
super(element);
this._parent = this._element.closest(SELECTOR_TAB_PANEL);
if (!this._parent) throw new TypeError(`${this._element.outerHTML} has no valid parent ${SELECTOR_TAB_PANEL}`);
this._setInitialAttributes(this._parent, this._getChildren());
EventHandler.on(this._element, EVENT_KEYDOWN, (event) => this._keydown(event));
}
static get NAME() {
return NAME$2;
}
async show() {
const innerElem = this._element;
if (this._elemIsActive(innerElem)) return;
const active = this._getActiveElem();
const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, { relatedTarget: innerElem }) : null;
if (EventHandler.trigger(innerElem, EVENT_SHOW$1, { relatedTarget: active }).defaultPrevented || hideEvent && hideEvent.defaultPrevented) return;
const activationId = (activationIds.get(this._parent) || 0) + 1;
activationIds.set(this._parent, activationId);
this._deactivate(active, innerElem);
await this._activate(innerElem, active, activationId);
}
async _activate(element, relatedElem, activationId) {
if (!element) return;
element.classList.add(CLASS_NAME_ACTIVE);
if (element.getAttribute("role") !== "tab") {
element.classList.add(CLASS_NAME_SHOW$1);
return;
}
const pane = SelectorEngine.getElementFromSelector(element);
this._activate(pane);
const complete = () => {
if (activationId !== activationIds.get(this._parent) || !this._elemIsActive(element)) return;
element.removeAttribute("tabindex");
setAriaAttribute(element, "aria-selected", true);
this._toggleMenu(element, true);
EventHandler.trigger(element, EVENT_SHOWN$1, { relatedTarget: relatedElem });
};
await this._queueCallback(complete, pane ?? element, getTransitionDurationFromElement(pane) > 0);
}
async _deactivate(element, relatedElem) {
if (!element) return;
element.classList.remove(CLASS_NAME_ACTIVE);
element.blur();
if (element.getAttribute("role") !== "tab") {
element.classList.remove(CLASS_NAME_SHOW$1);
return;
}
this._deactivate(SelectorEngine.getElementFromSelector(element));
const complete = () => {
setAriaAttribute(element, "aria-selected", false);
element.setAttribute("tabindex", "-1");
this._toggleMenu(element, false);
EventHandler.trigger(element, EVENT_HIDDEN$1, { relatedTarget: relatedElem });
};
await this._queueCallback(complete, element, false);
}
_keydown(event) {
if (![
ARROW_LEFT_KEY,
ARROW_RIGHT_KEY,
ARROW_UP_KEY,
ARROW_DOWN_KEY,
HOME_KEY,
END_KEY
].includes(event.key)) return;
if (event.altKey || event.ctrlKey || event.metaKey) return;
event.stopPropagation();
event.preventDefault();
const children = this._getChildren().filter((element) => !isDisabled(element));
let nextActiveElement;
if ([HOME_KEY, END_KEY].includes(event.key)) nextActiveElement = event.key === HOME_KEY ? children[0] : children.at(-1);
else {
const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
nextActiveElement = getNextActiveElement(children, event.target, isNext, true);
}
if (nextActiveElement) {
nextActiveElement.focus({ preventScroll: true });
Tab.getOrCreateInstance(nextActiveElement).show();
}
}
_getChildren() {
return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
}
_getActiveElem() {
return this._getChildren().find((child) => this._elemIsActive(child)) || null;
}
_setInitialAttributes(parent, children) {
this._setAttributeIfNotExists(parent, "role", "tablist");
for (const child of children) this._setInitialAttributesOnChild(child);
}
_setInitialAttributesOnChild(child) {
child = this._getInnerElement(child);
const isActive = this._elemIsActive(child);
const outerElem = this._getOuterElement(child);
setAriaAttribute(child, "aria-selected", isActive);
if (outerElem !== child) this._setAttributeIfNotExists(outerElem, "role", "presentation");
if (!isActive) child.setAttribute("tabindex", "-1");
this._setAttributeIfNotExists(child, "role", "tab");
this._setInitialAttributesOnTargetPanel(child);
}
_setInitialAttributesOnTargetPanel(child) {
const target = SelectorEngine.getElementFromSelector(child);
if (!target) return;
this._setAttributeIfNotExists(target, "role", "tabpanel");
if (child.id) this._setAttributeIfNotExists(target, "aria-labelledby", `${child.id}`);
}
_toggleMenu(element, open) {
const outerElem = this._getOuterElement(element);
const menuToggle = SelectorEngine.findOne(SELECTOR_MENU_TOGGLE, outerElem);
if (!menuToggle) return;
const menu = SelectorEngine.findOne(SELECTOR_MENU, outerElem);
menuToggle.classList.toggle(CLASS_NAME_ACTIVE, open);
if (menu) menu.classList.toggle(CLASS_NAME_SHOW$1, open);
setAriaAttribute(menuToggle, "aria-expanded", open);
}
_setAttributeIfNotExists(element, attribute, value) {
if (!element.hasAttribute(attribute)) element.setAttribute(attribute, value);
}
_elemIsActive(elem) {
return elem.classList.contains(CLASS_NAME_ACTIVE);
}
_getInnerElement(elem) {
return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
}
_getOuterElement(elem) {
return elem.closest(SELECTOR_OUTER) || elem;
}
};
/**
* Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE$1, function(event) {
if (["A", "AREA"].includes(this.tagName)) event.preventDefault();
if (isDisabled(this)) return;
Tab.getOrCreateInstance(this).show();
});
/**
* Initialize on focus
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) Tab.getOrCreateInstance(element);
});
/**
* Find the tab trigger that targets a pane.
*/
const getTabTriggerFromPane = (pane) => {
const labelledBy = pane.getAttribute("aria-labelledby");
if (labelledBy) {
const byLabel = document.getElementById(labelledBy);
if (byLabel?.matches(SELECTOR_DATA_TOGGLE$1)) return byLabel;
}
const { id } = pane;
if (!id) return null;
const escapedId = CSS.escape(id);
return SelectorEngine.findOne(`${SELECTOR_DATA_TOGGLE$1}[data-bs-target="#${escapedId}"], ${SELECTOR_DATA_TOGGLE$1}[href="#${escapedId}"]`);
};
/**
* Open opted-in tab panes when the URL fragment matches their id.
* Put `data-bs-hash` on the tab pane.
*/
enableHashTarget(`${EVENT_KEY$2}.data-api`, {
matches: (element) => Boolean(getTabTriggerFromPane(element)),
getAnchor: getTabTriggerFromPane,
async open(element, done) {
const trigger = getTabTriggerFromPane(element);
if (!trigger) return;
if (trigger.classList.contains(CLASS_NAME_ACTIVE)) {
done();
return;
}
await Tab.getOrCreateInstance(trigger).show();
if (trigger.classList.contains(CLASS_NAME_ACTIVE)) done();
}
});
//#endregion
//#region js/src/toast.ts
/**
* --------------------------------------------------------------------------
* Bootstrap toast.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME$1 = "toast";
const EVENT_KEY$1 = `.bs.toast`;
const EVENT_MOUSEOVER = `mouseover${EVENT_KEY$1}`;
const EVENT_MOUSEOUT = `mouseout${EVENT_KEY$1}`;
const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`;
const EVENT_FOCUSOUT = `focusout${EVENT_KEY$1}`;
const EVENT_HIDE = `hide${EVENT_KEY$1}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY$1}`;
const EVENT_SHOW = `show${EVENT_KEY$1}`;
const EVENT_SHOWN = `shown${EVENT_KEY$1}`;
const CLASS_NAME_INSTANT = "toast-instant";
const CLASS_NAME_SHOW = "show";
const DefaultType$1 = {
autohide: "boolean",
delay: "number"
};
const Default$1 = {
autohide: true,
delay: 5e3
};
/**
* Class definition
*/
var Toast = class extends BaseComponent {
constructor(element, config) {
super(element, config);
this._timeout = null;
this._hasMouseInteraction = false;
this._hasKeyboardInteraction = false;
this._setListeners();
}
static get Default() {
return Default$1;
}
static get DefaultType() {
return DefaultType$1;
}
static get NAME() {
return NAME$1;
}
async show() {
if (EventHandler.trigger(this._element, EVENT_SHOW).defaultPrevented) return;
this._clearTimeout();
const complete = () => {
EventHandler.trigger(this._element, EVENT_SHOWN);
this._maybeScheduleHide();
};
this._element.classList.add(CLASS_NAME_SHOW);
await this._queueCallback(complete, this._element, this._isAnimated());
}
async hide() {
if (!this.isShown()) return;
if (EventHandler.trigger(this._element, EVENT_HIDE).defaultPrevented) return;
const complete = () => {
EventHandler.trigger(this._element, EVENT_HIDDEN);
};
this._element.classList.remove(CLASS_NAME_SHOW);
await this._queueCallback(complete, this._element, this._isAnimated());
}
dispose() {
this._clearTimeout();
if (this.isShown()) this._element.classList.remove(CLASS_NAME_SHOW);
super.dispose();
}
isShown() {
return this._element.classList.contains(CLASS_NAME_SHOW);
}
_isAnimated() {
return !this._element.classList.contains(CLASS_NAME_INSTANT);
}
_maybeScheduleHide() {
if (!this._config.autohide) return;
if (this._hasMouseInteraction || this._hasKeyboardInteraction) return;
this._timeout = setTimeout(() => {
this.hide();
}, this._config.delay);
}
_onInteraction(event, isInteracting) {
switch (event.type) {
case "mouseover":
case "mouseout":
this._hasMouseInteraction = isInteracting;
break;
case "focusin":
case "focusout":
this._hasKeyboardInteraction = isInteracting;
break;
default: break;
}
if (isInteracting) {
this._clearTimeout();
return;
}
const nextElement = event.relatedTarget;
if (this._element === nextElement || this._element.contains(nextElement)) return;
this._maybeScheduleHide();
}
_setListeners() {
EventHandler.on(this._element, EVENT_MOUSEOVER, (event) => this._onInteraction(event, true));
EventHandler.on(this._element, EVENT_MOUSEOUT, (event) => this._onInteraction(event, false));
EventHandler.on(this._element, EVENT_FOCUSIN, (event) => this._onInteraction(event, true));
EventHandler.on(this._element, EVENT_FOCUSOUT, (event) => this._onInteraction(event, false));
}
_clearTimeout() {
clearTimeout(this._timeout);
this._timeout = null;
}
};
/**
* Data API implementation
*/
enableDismissTrigger(Toast);
//#endregion
//#region js/src/toggler.ts
/**
* --------------------------------------------------------------------------
* Bootstrap toggler.ts
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
const NAME = "toggler";
const EVENT_KEY = `.bs.toggler`;
const EVENT_TOGGLE = `toggle${EVENT_KEY}`;
const EVENT_TOGGLED = `toggled${EVENT_KEY}`;
const EVENT_CLICK = "click";
const SELECTOR_DATA_TOGGLE = "[data-bs-toggle=\"toggler\"]";
const EVENT_HANDLER_PATTERN = /^on/i;
const DISALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
"action",
"background",
"data",
"formaction",
"href",
"id",
"poster",
"src",
"srcdoc",
"srcset",
"style",
"xlink:href"
]);
const DefaultType = {
attribute: "string",
value: "(string|number|boolean|null)"
};
const Default = {
attribute: "class",
value: null
};
/**
* Class definition
*/
var Toggler = class extends BaseComponent {
static get Default() {
return Default;
}
static get DefaultType() {
return DefaultType;
}
static get NAME() {
return NAME;
}
toggle() {
if (EventHandler.trigger(this._element, EVENT_TOGGLE).defaultPrevented) return;
this._execute();
EventHandler.trigger(this._element, EVENT_TOGGLED);
}
_execute() {
const { attribute, value } = this._config;
if (EVENT_HANDLER_PATTERN.test(attribute) || DISALLOWED_ATTRIBUTES.has(attribute.toLowerCase())) return;
if (value === null || value === void 0) return;
if (attribute === "class") {
this._element.classList.toggle(value);
return;
}
if (this._element.getAttribute(attribute) === String(value)) {
this._element.removeAttribute(attribute);
return;
}
this._element.setAttribute(attribute, value);
}
};
/**
* Data API implementation
*/
eventActionOnPlugin(Toggler, EVENT_CLICK, SELECTOR_DATA_TOGGLE, "toggle");
//#endregion
export { Alert, Button, Carousel, Collapse, Combobox, Datepicker, Dialog, Drawer, Menu, NavOverflow, OtpInput, Popover, Range, ScrollSpy, Strength, Tab, Toast, Toggler, Tooltip };
//# sourceMappingURL=bootstrap.bundle.js.map