(function() {
    "use strict";
    const elementMap = new Map;
    var Data = {
        set(element, key, instance) {
            if (!elementMap.has(element)) {
                elementMap.set(element, new Map);
            }
            const instanceMap = elementMap.get(element);
            if (!instanceMap.has(key) && instanceMap.size !== 0) {
                console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
                return;
            }
            instanceMap.set(key, instance);
        },
        get(element, key) {
            if (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);
            }
        }
    };
    const MAX_UID = 1e6;
    const MILLISECONDS_MULTIPLIER = 1e3;
    const TRANSITION_END = "transitionend";
    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 === undefined) {
            return `${object}`;
        }
        return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
    };
    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: transitionDuration, transitionDelay: transitionDelay} = window.getComputedStyle(element);
        const floatTransitionDuration = Number.parseFloat(transitionDuration);
        const floatTransitionDelay = Number.parseFloat(transitionDelay);
        if (!floatTransitionDuration && !floatTransitionDelay) {
            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;
        }
        if (typeof object.jquery !== "undefined") {
            object = object[0];
        }
        return typeof object.nodeType !== "undefined";
    };
    const getElement = object => {
        if (isElement$1(object)) {
            return object.jquery ? object[0] : 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;
        }
        if (typeof element.disabled !== "undefined") {
            return element.disabled;
        }
        return element.hasAttribute("disabled") && element.getAttribute("disabled") !== "false";
    };
    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 reflow = element => {
        element.offsetHeight;
    };
    const getjQuery = () => {
        if (window.jQuery && !document.body.hasAttribute("data-bs-no-jquery")) {
            return window.jQuery;
        }
        return null;
    };
    const DOMContentLoadedCallbacks = [];
    const onDOMContentLoaded = callback => {
        if (document.readyState === "loading") {
            if (!DOMContentLoadedCallbacks.length) {
                document.addEventListener("DOMContentLoaded", () => {
                    for (const callback of DOMContentLoadedCallbacks) {
                        callback();
                    }
                });
            }
            DOMContentLoadedCallbacks.push(callback);
        } else {
            callback();
        }
    };
    const isRTL = () => document.documentElement.dir === "rtl";
    const defineJQueryPlugin = plugin => {
        onDOMContentLoaded(() => {
            const $ = getjQuery();
            if ($) {
                const name = plugin.NAME;
                const JQUERY_NO_CONFLICT = $.fn[name];
                $.fn[name] = plugin.jQueryInterface;
                $.fn[name].Constructor = plugin;
                $.fn[name].noConflict = () => {
                    $.fn[name] = JQUERY_NO_CONFLICT;
                    return plugin.jQueryInterface;
                };
            }
        });
    };
    const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => typeof possibleCallback === "function" ? possibleCallback.call(...args) : defaultValue;
    const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
        if (!waitForTransition) {
            execute(callback);
            return;
        }
        const durationPadding = 5;
        const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
        let called = false;
        const handler = ({target: target}) => {
            if (target !== transitionElement) {
                return;
            }
            called = true;
            transitionElement.removeEventListener(TRANSITION_END, handler);
            execute(callback);
        };
        transitionElement.addEventListener(TRANSITION_END, handler);
        setTimeout(() => {
            if (!called) {
                triggerTransitionEnd(transitionElement);
            }
        }, emulatedDuration);
    };
    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;
        {
            index = (index + listLength) % listLength;
        }
        return list[Math.max(0, Math.min(index, listLength - 1))];
    };
    const namespaceRegex = /[^.]*(?=\..*)\.|.*/;
    const stripNameRegex = /\..*/;
    const stripUidRegex = /::\d+$/;
    const eventRegistry = {};
    let uidEvent = 1;
    const customEvents = {
        mouseenter: "mouseover",
        mouseleave: "mouseout"
    };
    const nativeEvents = new Set([ "click", "dblclick", "mouseup", "mousedown", "contextmenu", "mousewheel", "DOMMouseScroll", "mouseover", "mouseout", "mousemove", "selectstart", "selectend", "keydown", "keypress", "keyup", "orientationchange", "touchstart", "touchmove", "touchend", "touchcancel", "pointerdown", "pointermove", "pointerup", "pointerleave", "pointercancel", "gesturestart", "gesturechange", "gestureend", "focus", "blur", "change", "reset", "select", "submit", "focusin", "focusout", "load", "unload", "beforeunload", "resize", "move", "DOMContentLoaded", "readystatechange", "error", "abort", "scroll" ]);
    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 bootstrapHandler(element, fn) {
        return function handler(event) {
            hydrateObj(event, {
                delegateTarget: element
            });
            if (handler.oneOff) {
                EventHandler.off(element, event.type, fn);
            }
            return fn.apply(element, [ event ]);
        };
    }
    function bootstrapDelegationHandler(element, selector, fn) {
        return function handler(event) {
            const domElements = element.querySelectorAll(selector);
            for (let {target: target} = event; target && target !== this; target = target.parentNode) {
                for (const domElement of domElements) {
                    if (domElement !== target) {
                        continue;
                    }
                    hydrateObj(event, {
                        delegateTarget: target
                    });
                    if (handler.oneOff) {
                        EventHandler.off(element, event.type, selector, fn);
                    }
                    return fn.apply(target, [ event ]);
                }
            }
        };
    }
    function findHandler(events, callable, delegationSelector = null) {
        return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector);
    }
    function normalizeParameters(originalTypeEvent, handler, delegationFunction) {
        const isDelegated = typeof handler === "string";
        const callable = isDelegated ? delegationFunction : handler || delegationFunction;
        let typeEvent = getTypeEvent(originalTypeEvent);
        if (!nativeEvents.has(typeEvent)) {
            typeEvent = originalTypeEvent;
        }
        return [ isDelegated, callable, typeEvent ];
    }
    function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) {
        if (typeof originalTypeEvent !== "string" || !element) {
            return;
        }
        let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
        if (originalTypeEvent in customEvents) {
            const wrapFunction = fn => function(event) {
                if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) {
                    return fn.call(this, event);
                }
            };
            callable = wrapFunction(callable);
        }
        const events = getElementEvents(element);
        const handlers = events[typeEvent] || (events[typeEvent] = {});
        const previousFunction = findHandler(handlers, callable, 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) : bootstrapHandler(element, callable);
        fn.delegationSelector = isDelegated ? handler : null;
        fn.callable = callable;
        fn.oneOff = oneOff;
        fn.uidEvent = uid;
        handlers[uid] = fn;
        element.addEventListener(typeEvent, fn, isDelegated);
    }
    function removeHandler(element, events, typeEvent, handler, delegationSelector) {
        const fn = findHandler(events[typeEvent], handler, delegationSelector);
        if (!fn) {
            return;
        }
        element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
        delete events[typeEvent][fn.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.callable, event.delegationSelector);
            }
        }
    }
    function getTypeEvent(event) {
        event = event.replace(stripNameRegex, "");
        return customEvents[event] || event;
    }
    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] = normalizeParameters(originalTypeEvent, handler, delegationFunction);
            const inNamespace = typeEvent !== originalTypeEvent;
            const events = getElementEvents(element);
            const storeElementEvent = events[typeEvent] || {};
            const isNamespace = originalTypeEvent.startsWith(".");
            if (typeof callable !== "undefined") {
                if (!Object.keys(storeElementEvent).length) {
                    return;
                }
                removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null);
                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 (!inNamespace || originalTypeEvent.includes(handlerKey)) {
                    removeHandler(element, events, typeEvent, event.callable, event.delegationSelector);
                }
            }
        },
        trigger(element, event, args) {
            if (typeof event !== "string" || !element) {
                return null;
            }
            const $ = getjQuery();
            const typeEvent = getTypeEvent(event);
            const inNamespace = event !== typeEvent;
            let jQueryEvent = null;
            let bubbles = true;
            let nativeDispatch = true;
            let defaultPrevented = false;
            if (inNamespace && $) {
                jQueryEvent = $.Event(event, args);
                $(element).trigger(jQueryEvent);
                bubbles = !jQueryEvent.isPropagationStopped();
                nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
                defaultPrevented = jQueryEvent.isDefaultPrevented();
            }
            const evt = hydrateObj(new Event(event, {
                bubbles: bubbles,
                cancelable: true
            }), args);
            if (defaultPrevented) {
                evt.preventDefault();
            }
            if (nativeDispatch) {
                element.dispatchEvent(evt);
            }
            if (evt.defaultPrevented && jQueryEvent) {
                jQueryEvent.preventDefault();
            }
            return evt;
        }
    };
    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;
    }
    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)}`));
        }
    };
    class Config {
        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}".`);
                }
            }
        }
    }
    const VERSION = "5.3.8";
    class BaseComponent extends Config {
        constructor(element, config) {
            super();
            element = getElement(element);
            if (!element) {
                return;
            }
            this._element = element;
            this._config = this._getConfig(config);
            Data.set(this._element, this.constructor.DATA_KEY, this);
        }
        dispose() {
            Data.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) {
            executeAfterTransition(callback, element, isAnimated);
        }
        _getConfig(config) {
            config = this._mergeConfigObj(config, this._element);
            config = this._configAfterMerge(config);
            this._typeCheckConfig(config);
            return config;
        }
        static getInstance(element) {
            return Data.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}`;
        }
    }
    const NAME$8 = "button";
    const DATA_KEY$5 = "bs.button";
    const EVENT_KEY$5 = `.${DATA_KEY$5}`;
    const DATA_API_KEY$2 = ".data-api";
    const CLASS_NAME_ACTIVE$1 = "active";
    const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="button"]';
    const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`;
    class Button extends BaseComponent {
        static get NAME() {
            return NAME$8;
        }
        toggle() {
            this._element.setAttribute("aria-pressed", this._element.classList.toggle(CLASS_NAME_ACTIVE$1));
        }
        static jQueryInterface(config) {
            return this.each(function() {
                const data = Button.getOrCreateInstance(this);
                if (config === "toggle") {
                    data[config]();
                }
            });
        }
    }
    EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, event => {
        event.preventDefault();
        const button = event.target.closest(SELECTOR_DATA_TOGGLE$3);
        const data = Button.getOrCreateInstance(button);
        data.toggle();
    });
    defineJQueryPlugin(Button);
    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 [].concat(...Element.prototype.querySelectorAll.call(element, selector));
        },
        findOne(selector, element = document.documentElement) {
            return Element.prototype.querySelector.call(element, selector);
        },
        children(element, selector) {
            return [].concat(...element.children).filter(child => child.matches(selector));
        },
        parents(element, selector) {
            const parents = [];
            let ancestor = element.parentNode.closest(selector);
            while (ancestor) {
                parents.push(ancestor);
                ancestor = ancestor.parentNode.closest(selector);
            }
            return parents;
        },
        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 [];
        },
        focusableChildren(element) {
            const focusables = [ "a", "button", "input", "textarea", "select", "details", "[tabindex]", '[contenteditable="true"]' ].map(selector => `${selector}:not([tabindex^="-"])`).join(",");
            return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
        },
        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) : [];
        }
    };
    const NAME$7 = "collapse";
    const DATA_KEY$4 = "bs.collapse";
    const EVENT_KEY$4 = `.${DATA_KEY$4}`;
    const DATA_API_KEY$1 = ".data-api";
    const EVENT_SHOW$4 = `show${EVENT_KEY$4}`;
    const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`;
    const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`;
    const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`;
    const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$1}`;
    const CLASS_NAME_SHOW$5 = "show";
    const CLASS_NAME_COLLAPSE = "collapse";
    const CLASS_NAME_COLLAPSING = "collapsing";
    const CLASS_NAME_COLLAPSED = "collapsed";
    const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`;
    const CLASS_NAME_HORIZONTAL = "collapse-horizontal";
    const WIDTH = "width";
    const HEIGHT = "height";
    const SELECTOR_ACTIVES = ".collapse.show, .collapse.collapsing";
    const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="collapse"]';
    const Default$6 = {
        parent: null,
        toggle: true
    };
    const DefaultType$6 = {
        parent: "(null|element)",
        toggle: "boolean"
    };
    class Collapse extends BaseComponent {
        constructor(element, config) {
            super(element, config);
            this._isTransitioning = false;
            this._triggerArray = [];
            const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2);
            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._addAriaAndCollapsedClass(this._triggerArray, this._isShown());
            }
            if (this._config.toggle) {
                this.toggle();
            }
        }
        static get Default() {
            return Default$6;
        }
        static get DefaultType() {
            return DefaultType$6;
        }
        static get NAME() {
            return NAME$7;
        }
        toggle() {
            if (this._isShown()) {
                this.hide();
            } else {
                this.show();
            }
        }
        show() {
            if (this._isTransitioning || this._isShown()) {
                return;
            }
            let activeChildren = [];
            if (this._config.parent) {
                activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, {
                    toggle: false
                }));
            }
            if (activeChildren.length && activeChildren[0]._isTransitioning) {
                return;
            }
            const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$4);
            if (startEvent.defaultPrevented) {
                return;
            }
            for (const activeInstance of activeChildren) {
                activeInstance.hide();
            }
            const dimension = this._getDimension();
            this._element.classList.remove(CLASS_NAME_COLLAPSE);
            this._element.classList.add(CLASS_NAME_COLLAPSING);
            this._element.style[dimension] = 0;
            this._addAriaAndCollapsedClass(this._triggerArray, true);
            this._isTransitioning = true;
            const complete = () => {
                this._isTransitioning = false;
                this._element.classList.remove(CLASS_NAME_COLLAPSING);
                this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$5);
                this._element.style[dimension] = "";
                EventHandler.trigger(this._element, EVENT_SHOWN$4);
            };
            const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
            const scrollSize = `scroll${capitalizedDimension}`;
            this._queueCallback(complete, this._element, true);
            this._element.style[dimension] = `${this._element[scrollSize]}px`;
        }
        hide() {
            if (this._isTransitioning || !this._isShown()) {
                return;
            }
            const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
            if (startEvent.defaultPrevented) {
                return;
            }
            const dimension = this._getDimension();
            this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
            reflow(this._element);
            this._element.classList.add(CLASS_NAME_COLLAPSING);
            this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$5);
            for (const trigger of this._triggerArray) {
                const element = SelectorEngine.getElementFromSelector(trigger);
                if (element && !this._isShown(element)) {
                    this._addAriaAndCollapsedClass([ trigger ], false);
                }
            }
            this._isTransitioning = true;
            const complete = () => {
                this._isTransitioning = false;
                this._element.classList.remove(CLASS_NAME_COLLAPSING);
                this._element.classList.add(CLASS_NAME_COLLAPSE);
                EventHandler.trigger(this._element, EVENT_HIDDEN$4);
            };
            this._element.style[dimension] = "";
            this._queueCallback(complete, this._element, true);
        }
        _isShown(element = this._element) {
            return element.classList.contains(CLASS_NAME_SHOW$5);
        }
        _configAfterMerge(config) {
            config.toggle = Boolean(config.toggle);
            config.parent = getElement(config.parent);
            return config;
        }
        _getDimension() {
            return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT;
        }
        _initializeChildren() {
            if (!this._config.parent) {
                return;
            }
            const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$2);
            for (const element of children) {
                const selected = SelectorEngine.getElementFromSelector(element);
                if (selected) {
                    this._addAriaAndCollapsedClass([ 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));
        }
        _addAriaAndCollapsedClass(triggerArray, isOpen) {
            if (!triggerArray.length) {
                return;
            }
            for (const element of triggerArray) {
                element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen);
                element.setAttribute("aria-expanded", isOpen);
            }
        }
        static jQueryInterface(config) {
            const _config = {};
            if (typeof config === "string" && /show|hide/.test(config)) {
                _config.toggle = false;
            }
            return this.each(function() {
                const data = Collapse.getOrCreateInstance(this, _config);
                if (typeof config === "string") {
                    if (typeof data[config] === "undefined") {
                        throw new TypeError(`No method named "${config}"`);
                    }
                    data[config]();
                }
            });
        }
    }
    EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, 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: false
            }).toggle();
        }
    });
    defineJQueryPlugin(Collapse);
    const NAME$6 = "backdrop";
    const CLASS_NAME_FADE$4 = "fade";
    const CLASS_NAME_SHOW$4 = "show";
    const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$6}`;
    const Default$5 = {
        className: "modal-backdrop",
        clickCallback: null,
        isAnimated: false,
        isVisible: true,
        rootElement: "body"
    };
    const DefaultType$5 = {
        className: "string",
        clickCallback: "(function|null)",
        isAnimated: "boolean",
        isVisible: "boolean",
        rootElement: "(element|string)"
    };
    class Backdrop extends Config {
        constructor(config) {
            super();
            this._config = this._getConfig(config);
            this._isAppended = false;
            this._element = null;
        }
        static get Default() {
            return Default$5;
        }
        static get DefaultType() {
            return DefaultType$5;
        }
        static get NAME() {
            return NAME$6;
        }
        show(callback) {
            if (!this._config.isVisible) {
                execute(callback);
                return;
            }
            this._append();
            const element = this._getElement();
            if (this._config.isAnimated) {
                reflow(element);
            }
            element.classList.add(CLASS_NAME_SHOW$4);
            this._emulateAnimation(() => {
                execute(callback);
            });
        }
        hide(callback) {
            if (!this._config.isVisible) {
                execute(callback);
                return;
            }
            this._getElement().classList.remove(CLASS_NAME_SHOW$4);
            this._emulateAnimation(() => {
                this.dispose();
                execute(callback);
            });
        }
        dispose() {
            if (!this._isAppended) {
                return;
            }
            EventHandler.off(this._element, EVENT_MOUSEDOWN);
            this._element.remove();
            this._isAppended = false;
        }
        _getElement() {
            if (!this._element) {
                const backdrop = document.createElement("div");
                backdrop.className = this._config.className;
                if (this._config.isAnimated) {
                    backdrop.classList.add(CLASS_NAME_FADE$4);
                }
                this._element = backdrop;
            }
            return this._element;
        }
        _configAfterMerge(config) {
            config.rootElement = getElement(config.rootElement);
            return config;
        }
        _append() {
            if (this._isAppended) {
                return;
            }
            const element = this._getElement();
            this._config.rootElement.append(element);
            EventHandler.on(element, EVENT_MOUSEDOWN, () => {
                execute(this._config.clickCallback);
            });
            this._isAppended = true;
        }
        _emulateAnimation(callback) {
            executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
        }
    }
    const enableDismissTrigger = (component, method = "hide") => {
        const clickEvent = `click.dismiss${component.EVENT_KEY}`;
        const name = component.NAME;
        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}`);
            const instance = component.getOrCreateInstance(target);
            instance[method]();
        });
    };
    const NAME$5 = "focustrap";
    const DATA_KEY$3 = "bs.focustrap";
    const EVENT_KEY$3 = `.${DATA_KEY$3}`;
    const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$3}`;
    const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$3}`;
    const TAB_KEY = "Tab";
    const TAB_NAV_FORWARD = "forward";
    const TAB_NAV_BACKWARD = "backward";
    const Default$4 = {
        autofocus: true,
        trapElement: null
    };
    const DefaultType$4 = {
        autofocus: "boolean",
        trapElement: "element"
    };
    class FocusTrap extends Config {
        constructor(config) {
            super();
            this._config = this._getConfig(config);
            this._isActive = false;
            this._lastTabNavDirection = null;
        }
        static get Default() {
            return Default$4;
        }
        static get DefaultType() {
            return DefaultType$4;
        }
        static get NAME() {
            return NAME$5;
        }
        activate() {
            if (this._isActive) {
                return;
            }
            if (this._config.autofocus) {
                this._config.trapElement.focus();
            }
            EventHandler.off(document, EVENT_KEY$3);
            EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event));
            EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event));
            this._isActive = true;
        }
        deactivate() {
            if (!this._isActive) {
                return;
            }
            this._isActive = false;
            EventHandler.off(document, EVENT_KEY$3);
        }
        _handleFocusin(event) {
            const {trapElement: trapElement} = this._config;
            if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
                return;
            }
            const elements = SelectorEngine.focusableChildren(trapElement);
            if (elements.length === 0) {
                trapElement.focus();
            } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) {
                elements[elements.length - 1].focus();
            } else {
                elements[0].focus();
            }
        }
        _handleKeydown(event) {
            if (event.key !== TAB_KEY) {
                return;
            }
            this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD;
        }
    }
    const SELECTOR_FIXED_CONTENT = ".fixed-top, .fixed-bottom, .is-fixed, .sticky-top";
    const SELECTOR_STICKY_CONTENT = ".sticky-top";
    const PROPERTY_PADDING = "padding-right";
    const PROPERTY_MARGIN = "margin-right";
    class ScrollBarHelper {
        constructor() {
            this._element = document.body;
        }
        getWidth() {
            const documentWidth = document.documentElement.clientWidth;
            return Math.abs(window.innerWidth - documentWidth);
        }
        hide() {
            const width = this.getWidth();
            this._disableOverFlow();
            this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
            this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width);
            this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width);
        }
        reset() {
            this._resetElementAttributes(this._element, "overflow");
            this._resetElementAttributes(this._element, PROPERTY_PADDING);
            this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING);
            this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN);
        }
        isOverflowing() {
            return this.getWidth() > 0;
        }
        _disableOverFlow() {
            this._saveInitialAttribute(this._element, "overflow");
            this._element.style.overflow = "hidden";
        }
        _setElementAttributes(selector, styleProperty, callback) {
            const scrollbarWidth = this.getWidth();
            const manipulationCallBack = element => {
                if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
                    return;
                }
                this._saveInitialAttribute(element, styleProperty);
                const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty);
                element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`);
            };
            this._applyManipulationCallback(selector, manipulationCallBack);
        }
        _saveInitialAttribute(element, styleProperty) {
            const actualValue = element.style.getPropertyValue(styleProperty);
            if (actualValue) {
                Manipulator.setDataAttribute(element, styleProperty, actualValue);
            }
        }
        _resetElementAttributes(selector, styleProperty) {
            const manipulationCallBack = element => {
                const value = Manipulator.getDataAttribute(element, styleProperty);
                if (value === null) {
                    element.style.removeProperty(styleProperty);
                    return;
                }
                Manipulator.removeDataAttribute(element, styleProperty);
                element.style.setProperty(styleProperty, value);
            };
            this._applyManipulationCallback(selector, manipulationCallBack);
        }
        _applyManipulationCallback(selector, callBack) {
            if (isElement$1(selector)) {
                callBack(selector);
                return;
            }
            for (const sel of SelectorEngine.find(selector, this._element)) {
                callBack(sel);
            }
        }
    }
    const NAME$4 = "modal";
    const DATA_KEY$2 = "bs.modal";
    const EVENT_KEY$2 = `.${DATA_KEY$2}`;
    const DATA_API_KEY = ".data-api";
    const ESCAPE_KEY = "Escape";
    const EVENT_HIDE$3 = `hide${EVENT_KEY$2}`;
    const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$2}`;
    const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$2}`;
    const EVENT_SHOW$3 = `show${EVENT_KEY$2}`;
    const EVENT_SHOWN$3 = `shown${EVENT_KEY$2}`;
    const EVENT_RESIZE = `resize${EVENT_KEY$2}`;
    const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$2}`;
    const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$2}`;
    const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$2}`;
    const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$2}${DATA_API_KEY}`;
    const CLASS_NAME_OPEN = "modal-open";
    const CLASS_NAME_FADE$3 = "fade";
    const CLASS_NAME_SHOW$3 = "show";
    const CLASS_NAME_STATIC = "modal-static";
    const OPEN_SELECTOR = ".modal.show";
    const SELECTOR_DIALOG = ".modal-dialog";
    const SELECTOR_MODAL_BODY = ".modal-body";
    const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="modal"]';
    const Default$3 = {
        backdrop: true,
        focus: true,
        keyboard: true
    };
    const DefaultType$3 = {
        backdrop: "(boolean|string)",
        focus: "boolean",
        keyboard: "boolean"
    };
    class Modal extends BaseComponent {
        constructor(element, config) {
            super(element, config);
            this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
            this._backdrop = this._initializeBackDrop();
            this._focustrap = this._initializeFocusTrap();
            this._isShown = false;
            this._isTransitioning = false;
            this._scrollBar = new ScrollBarHelper;
            this._addEventListeners();
        }
        static get Default() {
            return Default$3;
        }
        static get DefaultType() {
            return DefaultType$3;
        }
        static get NAME() {
            return NAME$4;
        }
        toggle(relatedTarget) {
            return this._isShown ? this.hide() : this.show(relatedTarget);
        }
        show(relatedTarget) {
            if (this._isShown || this._isTransitioning) {
                return;
            }
            const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
                relatedTarget: relatedTarget
            });
            if (showEvent.defaultPrevented) {
                return;
            }
            this._isShown = true;
            this._isTransitioning = true;
            this._scrollBar.hide();
            document.body.classList.add(CLASS_NAME_OPEN);
            this._adjustDialog();
            this._backdrop.show(() => this._showElement(relatedTarget));
        }
        hide() {
            if (!this._isShown || this._isTransitioning) {
                return;
            }
            const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3);
            if (hideEvent.defaultPrevented) {
                return;
            }
            this._isShown = false;
            this._isTransitioning = true;
            this._focustrap.deactivate();
            this._element.classList.remove(CLASS_NAME_SHOW$3);
            this._queueCallback(() => this._hideModal(), this._element, this._isAnimated());
        }
        dispose() {
            EventHandler.off(window, EVENT_KEY$2);
            EventHandler.off(this._dialog, EVENT_KEY$2);
            this._backdrop.dispose();
            this._focustrap.deactivate();
            super.dispose();
        }
        handleUpdate() {
            this._adjustDialog();
        }
        _initializeBackDrop() {
            return new Backdrop({
                isVisible: Boolean(this._config.backdrop),
                isAnimated: this._isAnimated()
            });
        }
        _initializeFocusTrap() {
            return new FocusTrap({
                trapElement: this._element
            });
        }
        _showElement(relatedTarget) {
            if (!document.body.contains(this._element)) {
                document.body.append(this._element);
            }
            this._element.style.display = "block";
            this._element.removeAttribute("aria-hidden");
            this._element.setAttribute("aria-modal", true);
            this._element.setAttribute("role", "dialog");
            this._element.scrollTop = 0;
            const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
            if (modalBody) {
                modalBody.scrollTop = 0;
            }
            reflow(this._element);
            this._element.classList.add(CLASS_NAME_SHOW$3);
            const transitionComplete = () => {
                if (this._config.focus) {
                    this._focustrap.activate();
                }
                this._isTransitioning = false;
                EventHandler.trigger(this._element, EVENT_SHOWN$3, {
                    relatedTarget: relatedTarget
                });
            };
            this._queueCallback(transitionComplete, this._dialog, this._isAnimated());
        }
        _addEventListeners() {
            EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => {
                if (event.key !== ESCAPE_KEY) {
                    return;
                }
                if (this._config.keyboard) {
                    this.hide();
                    return;
                }
                this._triggerBackdropTransition();
            });
            EventHandler.on(window, EVENT_RESIZE, () => {
                if (this._isShown && !this._isTransitioning) {
                    this._adjustDialog();
                }
            });
            EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => {
                EventHandler.one(this._element, EVENT_CLICK_DISMISS, event2 => {
                    if (this._element !== event.target || this._element !== event2.target) {
                        return;
                    }
                    if (this._config.backdrop === "static") {
                        this._triggerBackdropTransition();
                        return;
                    }
                    if (this._config.backdrop) {
                        this.hide();
                    }
                });
            });
        }
        _hideModal() {
            this._element.style.display = "none";
            this._element.setAttribute("aria-hidden", true);
            this._element.removeAttribute("aria-modal");
            this._element.removeAttribute("role");
            this._isTransitioning = false;
            this._backdrop.hide(() => {
                document.body.classList.remove(CLASS_NAME_OPEN);
                this._resetAdjustments();
                this._scrollBar.reset();
                EventHandler.trigger(this._element, EVENT_HIDDEN$3);
            });
        }
        _isAnimated() {
            return this._element.classList.contains(CLASS_NAME_FADE$3);
        }
        _triggerBackdropTransition() {
            const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED);
            if (hideEvent.defaultPrevented) {
                return;
            }
            const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
            const initialOverflowY = this._element.style.overflowY;
            if (initialOverflowY === "hidden" || this._element.classList.contains(CLASS_NAME_STATIC)) {
                return;
            }
            if (!isModalOverflowing) {
                this._element.style.overflowY = "hidden";
            }
            this._element.classList.add(CLASS_NAME_STATIC);
            this._queueCallback(() => {
                this._element.classList.remove(CLASS_NAME_STATIC);
                this._queueCallback(() => {
                    this._element.style.overflowY = initialOverflowY;
                }, this._dialog);
            }, this._dialog);
            this._element.focus();
        }
        _adjustDialog() {
            const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
            const scrollbarWidth = this._scrollBar.getWidth();
            const isBodyOverflowing = scrollbarWidth > 0;
            if (isBodyOverflowing && !isModalOverflowing) {
                const property = isRTL() ? "paddingLeft" : "paddingRight";
                this._element.style[property] = `${scrollbarWidth}px`;
            }
            if (!isBodyOverflowing && isModalOverflowing) {
                const property = isRTL() ? "paddingRight" : "paddingLeft";
                this._element.style[property] = `${scrollbarWidth}px`;
            }
        }
        _resetAdjustments() {
            this._element.style.paddingLeft = "";
            this._element.style.paddingRight = "";
        }
        static jQueryInterface(config, relatedTarget) {
            return this.each(function() {
                const data = Modal.getOrCreateInstance(this, config);
                if (typeof config !== "string") {
                    return;
                }
                if (typeof data[config] === "undefined") {
                    throw new TypeError(`No method named "${config}"`);
                }
                data[config](relatedTarget);
            });
        }
    }
    EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function(event) {
        const target = SelectorEngine.getElementFromSelector(this);
        if ([ "A", "AREA" ].includes(this.tagName)) {
            event.preventDefault();
        }
        EventHandler.one(target, EVENT_SHOW$3, showEvent => {
            if (showEvent.defaultPrevented) {
                return;
            }
            EventHandler.one(target, EVENT_HIDDEN$3, () => {
                if (isVisible(this)) {
                    this.focus();
                }
            });
        });
        const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR);
        if (alreadyOpen) {
            Modal.getInstance(alreadyOpen).hide();
        }
        const data = Modal.getOrCreateInstance(target);
        data.toggle(this);
    });
    enableDismissTrigger(Modal);
    defineJQueryPlugin(Modal);
    const NAME$3 = "tab";
    const DATA_KEY$1 = "bs.tab";
    const EVENT_KEY$1 = `.${DATA_KEY$1}`;
    const EVENT_HIDE$2 = `hide${EVENT_KEY$1}`;
    const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$1}`;
    const EVENT_SHOW$2 = `show${EVENT_KEY$1}`;
    const EVENT_SHOWN$2 = `shown${EVENT_KEY$1}`;
    const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`;
    const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`;
    const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`;
    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_FADE$2 = "fade";
    const CLASS_NAME_SHOW$2 = "show";
    const CLASS_DROPDOWN = "dropdown";
    const SELECTOR_DROPDOWN_TOGGLE = ".dropdown-toggle";
    const SELECTOR_DROPDOWN_MENU = ".dropdown-menu";
    const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_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_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
    const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
    const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
    const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
    class Tab extends BaseComponent {
        constructor(element) {
            super(element);
            this._parent = this._element.closest(SELECTOR_TAB_PANEL);
            if (!this._parent) {
                return;
            }
            this._setInitialAttributes(this._parent, this._getChildren());
            EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
        }
        static get NAME() {
            return NAME$3;
        }
        show() {
            const innerElem = this._element;
            if (this._elemIsActive(innerElem)) {
                return;
            }
            const active = this._getActiveElem();
            const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$2, {
                relatedTarget: innerElem
            }) : null;
            const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$2, {
                relatedTarget: active
            });
            if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
                return;
            }
            this._deactivate(active, innerElem);
            this._activate(innerElem, active);
        }
        _activate(element, relatedElem) {
            if (!element) {
                return;
            }
            element.classList.add(CLASS_NAME_ACTIVE);
            this._activate(SelectorEngine.getElementFromSelector(element));
            const complete = () => {
                if (element.getAttribute("role") !== "tab") {
                    element.classList.add(CLASS_NAME_SHOW$2);
                    return;
                }
                element.removeAttribute("tabindex");
                element.setAttribute("aria-selected", true);
                this._toggleDropDown(element, true);
                EventHandler.trigger(element, EVENT_SHOWN$2, {
                    relatedTarget: relatedElem
                });
            };
            this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$2));
        }
        _deactivate(element, relatedElem) {
            if (!element) {
                return;
            }
            element.classList.remove(CLASS_NAME_ACTIVE);
            element.blur();
            this._deactivate(SelectorEngine.getElementFromSelector(element));
            const complete = () => {
                if (element.getAttribute("role") !== "tab") {
                    element.classList.remove(CLASS_NAME_SHOW$2);
                    return;
                }
                element.setAttribute("aria-selected", false);
                element.setAttribute("tabindex", "-1");
                this._toggleDropDown(element, false);
                EventHandler.trigger(element, EVENT_HIDDEN$2, {
                    relatedTarget: relatedElem
                });
            };
            this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$2));
        }
        _keydown(event) {
            if (![ ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY, HOME_KEY, END_KEY ].includes(event.key)) {
                return;
            }
            event.stopPropagation();
            event.preventDefault();
            const children = this._getChildren().filter(element => !isDisabled(element));
            let nextActiveElement;
            if ([ HOME_KEY, END_KEY ].includes(event.key)) {
                nextActiveElement = children[event.key === HOME_KEY ? 0 : children.length - 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);
            child.setAttribute("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}`);
            }
        }
        _toggleDropDown(element, open) {
            const outerElem = this._getOuterElement(element);
            if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
                return;
            }
            const toggle = (selector, className) => {
                const element = SelectorEngine.findOne(selector, outerElem);
                if (element) {
                    element.classList.toggle(className, open);
                }
            };
            toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
            toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$2);
            outerElem.setAttribute("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;
        }
        static jQueryInterface(config) {
            return this.each(function() {
                const data = Tab.getOrCreateInstance(this);
                if (typeof config !== "string") {
                    return;
                }
                if (data[config] === undefined || config.startsWith("_") || config === "constructor") {
                    throw new TypeError(`No method named "${config}"`);
                }
                data[config]();
            });
        }
    }
    EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function(event) {
        if ([ "A", "AREA" ].includes(this.tagName)) {
            event.preventDefault();
        }
        if (isDisabled(this)) {
            return;
        }
        Tab.getOrCreateInstance(this).show();
    });
    EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
        for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
            Tab.getOrCreateInstance(element);
        }
    });
    defineJQueryPlugin(Tab);
    const NAME$2 = "toast";
    const DATA_KEY = "bs.toast";
    const EVENT_KEY = `.${DATA_KEY}`;
    const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
    const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
    const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY}`;
    const EVENT_FOCUSOUT$1 = `focusout${EVENT_KEY}`;
    const EVENT_HIDE$1 = `hide${EVENT_KEY}`;
    const EVENT_HIDDEN$1 = `hidden${EVENT_KEY}`;
    const EVENT_SHOW$1 = `show${EVENT_KEY}`;
    const EVENT_SHOWN$1 = `shown${EVENT_KEY}`;
    const CLASS_NAME_FADE$1 = "fade";
    const CLASS_NAME_HIDE = "hide";
    const CLASS_NAME_SHOW$1 = "show";
    const CLASS_NAME_SHOWING = "showing";
    const DefaultType$2 = {
        animation: "boolean",
        autohide: "boolean",
        delay: "number"
    };
    const Default$2 = {
        animation: true,
        autohide: true,
        delay: 5e3
    };
    class Toast extends BaseComponent {
        constructor(element, config) {
            super(element, config);
            this._timeout = null;
            this._hasMouseInteraction = false;
            this._hasKeyboardInteraction = false;
            this._setListeners();
        }
        static get Default() {
            return Default$2;
        }
        static get DefaultType() {
            return DefaultType$2;
        }
        static get NAME() {
            return NAME$2;
        }
        show() {
            const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1);
            if (showEvent.defaultPrevented) {
                return;
            }
            this._clearTimeout();
            if (this._config.animation) {
                this._element.classList.add(CLASS_NAME_FADE$1);
            }
            const complete = () => {
                this._element.classList.remove(CLASS_NAME_SHOWING);
                EventHandler.trigger(this._element, EVENT_SHOWN$1);
                this._maybeScheduleHide();
            };
            this._element.classList.remove(CLASS_NAME_HIDE);
            reflow(this._element);
            this._element.classList.add(CLASS_NAME_SHOW$1, CLASS_NAME_SHOWING);
            this._queueCallback(complete, this._element, this._config.animation);
        }
        hide() {
            if (!this.isShown()) {
                return;
            }
            const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$1);
            if (hideEvent.defaultPrevented) {
                return;
            }
            const complete = () => {
                this._element.classList.add(CLASS_NAME_HIDE);
                this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW$1);
                EventHandler.trigger(this._element, EVENT_HIDDEN$1);
            };
            this._element.classList.add(CLASS_NAME_SHOWING);
            this._queueCallback(complete, this._element, this._config.animation);
        }
        dispose() {
            this._clearTimeout();
            if (this.isShown()) {
                this._element.classList.remove(CLASS_NAME_SHOW$1);
            }
            super.dispose();
        }
        isShown() {
            return this._element.classList.contains(CLASS_NAME_SHOW$1);
        }
        _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;
                }
            }
            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$1, event => this._onInteraction(event, true));
            EventHandler.on(this._element, EVENT_FOCUSOUT$1, event => this._onInteraction(event, false));
        }
        _clearTimeout() {
            clearTimeout(this._timeout);
            this._timeout = null;
        }
        static jQueryInterface(config) {
            return this.each(function() {
                const data = Toast.getOrCreateInstance(this, config);
                if (typeof config === "string") {
                    if (typeof data[config] === "undefined") {
                        throw new TypeError(`No method named "${config}"`);
                    }
                    data[config](this);
                }
            });
        }
    }
    enableDismissTrigger(Toast);
    defineJQueryPlugin(Toast);
    var top = "top";
    var bottom = "bottom";
    var right = "right";
    var left = "left";
    var auto = "auto";
    var basePlacements = [ top, bottom, right, left ];
    var start = "start";
    var end = "end";
    var clippingParents = "clippingParents";
    var viewport = "viewport";
    var popper = "popper";
    var reference = "reference";
    var variationPlacements = basePlacements.reduce(function(acc, placement) {
        return acc.concat([ placement + "-" + start, placement + "-" + end ]);
    }, []);
    var placements = [].concat(basePlacements, [ auto ]).reduce(function(acc, placement) {
        return acc.concat([ placement, placement + "-" + start, placement + "-" + end ]);
    }, []);
    var beforeRead = "beforeRead";
    var read = "read";
    var afterRead = "afterRead";
    var beforeMain = "beforeMain";
    var main = "main";
    var afterMain = "afterMain";
    var beforeWrite = "beforeWrite";
    var write = "write";
    var afterWrite = "afterWrite";
    var modifierPhases = [ beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite ];
    function getNodeName(element) {
        return element ? (element.nodeName || "").toLowerCase() : null;
    }
    function getWindow(node) {
        if (node == null) {
            return window;
        }
        if (node.toString() !== "[object Window]") {
            var ownerDocument = node.ownerDocument;
            return ownerDocument ? ownerDocument.defaultView || window : window;
        }
        return node;
    }
    function isElement(node) {
        var OwnElement = getWindow(node).Element;
        return node instanceof OwnElement || node instanceof Element;
    }
    function isHTMLElement(node) {
        var OwnElement = getWindow(node).HTMLElement;
        return node instanceof OwnElement || node instanceof HTMLElement;
    }
    function isShadowRoot(node) {
        if (typeof ShadowRoot === "undefined") {
            return false;
        }
        var OwnElement = getWindow(node).ShadowRoot;
        return node instanceof OwnElement || node instanceof ShadowRoot;
    }
    function applyStyles(_ref) {
        var state = _ref.state;
        Object.keys(state.elements).forEach(function(name) {
            var style = state.styles[name] || {};
            var attributes = state.attributes[name] || {};
            var element = state.elements[name];
            if (!isHTMLElement(element) || !getNodeName(element)) {
                return;
            }
            Object.assign(element.style, style);
            Object.keys(attributes).forEach(function(name) {
                var value = attributes[name];
                if (value === false) {
                    element.removeAttribute(name);
                } else {
                    element.setAttribute(name, value === true ? "" : value);
                }
            });
        });
    }
    function effect$2(_ref2) {
        var state = _ref2.state;
        var initialStyles = {
            popper: {
                position: state.options.strategy,
                left: "0",
                top: "0",
                margin: "0"
            },
            arrow: {
                position: "absolute"
            },
            reference: {}
        };
        Object.assign(state.elements.popper.style, initialStyles.popper);
        state.styles = initialStyles;
        if (state.elements.arrow) {
            Object.assign(state.elements.arrow.style, initialStyles.arrow);
        }
        return function() {
            Object.keys(state.elements).forEach(function(name) {
                var element = state.elements[name];
                var attributes = state.attributes[name] || {};
                var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
                var style = styleProperties.reduce(function(style, property) {
                    style[property] = "";
                    return style;
                }, {});
                if (!isHTMLElement(element) || !getNodeName(element)) {
                    return;
                }
                Object.assign(element.style, style);
                Object.keys(attributes).forEach(function(attribute) {
                    element.removeAttribute(attribute);
                });
            });
        };
    }
    var applyStyles$1 = {
        name: "applyStyles",
        enabled: true,
        phase: "write",
        fn: applyStyles,
        effect: effect$2,
        requires: [ "computeStyles" ]
    };
    function getBasePlacement(placement) {
        return placement.split("-")[0];
    }
    var max = Math.max;
    var min = Math.min;
    var round = Math.round;
    function getUAString() {
        var uaData = navigator.userAgentData;
        if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
            return uaData.brands.map(function(item) {
                return item.brand + "/" + item.version;
            }).join(" ");
        }
        return navigator.userAgent;
    }
    function isLayoutViewport() {
        return !/^((?!chrome|android).)*safari/i.test(getUAString());
    }
    function getBoundingClientRect(element, includeScale, isFixedStrategy) {
        if (includeScale === void 0) {
            includeScale = false;
        }
        if (isFixedStrategy === void 0) {
            isFixedStrategy = false;
        }
        var clientRect = element.getBoundingClientRect();
        var scaleX = 1;
        var scaleY = 1;
        if (includeScale && isHTMLElement(element)) {
            scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
            scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
        }
        var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
        var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
        var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
        var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
        var width = clientRect.width / scaleX;
        var height = clientRect.height / scaleY;
        return {
            width: width,
            height: height,
            top: y,
            right: x + width,
            bottom: y + height,
            left: x,
            x: x,
            y: y
        };
    }
    function getLayoutRect(element) {
        var clientRect = getBoundingClientRect(element);
        var width = element.offsetWidth;
        var height = element.offsetHeight;
        if (Math.abs(clientRect.width - width) <= 1) {
            width = clientRect.width;
        }
        if (Math.abs(clientRect.height - height) <= 1) {
            height = clientRect.height;
        }
        return {
            x: element.offsetLeft,
            y: element.offsetTop,
            width: width,
            height: height
        };
    }
    function contains(parent, child) {
        var rootNode = child.getRootNode && child.getRootNode();
        if (parent.contains(child)) {
            return true;
        } else if (rootNode && isShadowRoot(rootNode)) {
            var next = child;
            do {
                if (next && parent.isSameNode(next)) {
                    return true;
                }
                next = next.parentNode || next.host;
            } while (next);
        }
        return false;
    }
    function getComputedStyle$1(element) {
        return getWindow(element).getComputedStyle(element);
    }
    function isTableElement(element) {
        return [ "table", "td", "th" ].indexOf(getNodeName(element)) >= 0;
    }
    function getDocumentElement(element) {
        return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
    }
    function getParentNode(element) {
        if (getNodeName(element) === "html") {
            return element;
        }
        return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
    }
    function getTrueOffsetParent(element) {
        if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
            return null;
        }
        return element.offsetParent;
    }
    function getContainingBlock(element) {
        var isFirefox = /firefox/i.test(getUAString());
        var isIE = /Trident/i.test(getUAString());
        if (isIE && isHTMLElement(element)) {
            var elementCss = getComputedStyle$1(element);
            if (elementCss.position === "fixed") {
                return null;
            }
        }
        var currentNode = getParentNode(element);
        if (isShadowRoot(currentNode)) {
            currentNode = currentNode.host;
        }
        while (isHTMLElement(currentNode) && [ "html", "body" ].indexOf(getNodeName(currentNode)) < 0) {
            var css = getComputedStyle$1(currentNode);
            if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || [ "transform", "perspective" ].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
                return currentNode;
            } else {
                currentNode = currentNode.parentNode;
            }
        }
        return null;
    }
    function getOffsetParent(element) {
        var window = getWindow(element);
        var offsetParent = getTrueOffsetParent(element);
        while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
            offsetParent = getTrueOffsetParent(offsetParent);
        }
        if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
            return window;
        }
        return offsetParent || getContainingBlock(element) || window;
    }
    function getMainAxisFromPlacement(placement) {
        return [ "top", "bottom" ].indexOf(placement) >= 0 ? "x" : "y";
    }
    function within(min$1, value, max$1) {
        return max(min$1, min(value, max$1));
    }
    function withinMaxClamp(min, value, max) {
        var v = within(min, value, max);
        return v > max ? max : v;
    }
    function getFreshSideObject() {
        return {
            top: 0,
            right: 0,
            bottom: 0,
            left: 0
        };
    }
    function mergePaddingObject(paddingObject) {
        return Object.assign({}, getFreshSideObject(), paddingObject);
    }
    function expandToHashMap(value, keys) {
        return keys.reduce(function(hashMap, key) {
            hashMap[key] = value;
            return hashMap;
        }, {});
    }
    var toPaddingObject = function toPaddingObject(padding, state) {
        padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
            placement: state.placement
        })) : padding;
        return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
    };
    function arrow(_ref) {
        var _state$modifiersData$;
        var state = _ref.state, name = _ref.name, options = _ref.options;
        var arrowElement = state.elements.arrow;
        var popperOffsets = state.modifiersData.popperOffsets;
        var basePlacement = getBasePlacement(state.placement);
        var axis = getMainAxisFromPlacement(basePlacement);
        var isVertical = [ left, right ].indexOf(basePlacement) >= 0;
        var len = isVertical ? "height" : "width";
        if (!arrowElement || !popperOffsets) {
            return;
        }
        var paddingObject = toPaddingObject(options.padding, state);
        var arrowRect = getLayoutRect(arrowElement);
        var minProp = axis === "y" ? top : left;
        var maxProp = axis === "y" ? bottom : right;
        var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
        var startDiff = popperOffsets[axis] - state.rects.reference[axis];
        var arrowOffsetParent = getOffsetParent(arrowElement);
        var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
        var centerToReference = endDiff / 2 - startDiff / 2;
        var min = paddingObject[minProp];
        var max = clientSize - arrowRect[len] - paddingObject[maxProp];
        var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
        var offset = within(min, center, max);
        var axisProp = axis;
        state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, 
        _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
    }
    function effect$1(_ref2) {
        var state = _ref2.state, options = _ref2.options;
        var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
        if (arrowElement == null) {
            return;
        }
        if (typeof arrowElement === "string") {
            arrowElement = state.elements.popper.querySelector(arrowElement);
            if (!arrowElement) {
                return;
            }
        }
        if (!contains(state.elements.popper, arrowElement)) {
            return;
        }
        state.elements.arrow = arrowElement;
    }
    var arrow$1 = {
        name: "arrow",
        enabled: true,
        phase: "main",
        fn: arrow,
        effect: effect$1,
        requires: [ "popperOffsets" ],
        requiresIfExists: [ "preventOverflow" ]
    };
    function getVariation(placement) {
        return placement.split("-")[1];
    }
    var unsetSides = {
        top: "auto",
        right: "auto",
        bottom: "auto",
        left: "auto"
    };
    function roundOffsetsByDPR(_ref, win) {
        var x = _ref.x, y = _ref.y;
        var dpr = win.devicePixelRatio || 1;
        return {
            x: round(x * dpr) / dpr || 0,
            y: round(y * dpr) / dpr || 0
        };
    }
    function mapToStyles(_ref2) {
        var _Object$assign2;
        var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
        var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
        var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
            x: x,
            y: y
        }) : {
            x: x,
            y: y
        };
        x = _ref3.x;
        y = _ref3.y;
        var hasX = offsets.hasOwnProperty("x");
        var hasY = offsets.hasOwnProperty("y");
        var sideX = left;
        var sideY = top;
        var win = window;
        if (adaptive) {
            var offsetParent = getOffsetParent(popper);
            var heightProp = "clientHeight";
            var widthProp = "clientWidth";
            if (offsetParent === getWindow(popper)) {
                offsetParent = getDocumentElement(popper);
                if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
                    heightProp = "scrollHeight";
                    widthProp = "scrollWidth";
                }
            }
            offsetParent = offsetParent;
            if (placement === top || (placement === left || placement === right) && variation === end) {
                sideY = bottom;
                var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : offsetParent[heightProp];
                y -= offsetY - popperRect.height;
                y *= gpuAcceleration ? 1 : -1;
            }
            if (placement === left || (placement === top || placement === bottom) && variation === end) {
                sideX = right;
                var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : offsetParent[widthProp];
                x -= offsetX - popperRect.width;
                x *= gpuAcceleration ? 1 : -1;
            }
        }
        var commonStyles = Object.assign({
            position: position
        }, adaptive && unsetSides);
        var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
            x: x,
            y: y
        }, getWindow(popper)) : {
            x: x,
            y: y
        };
        x = _ref4.x;
        y = _ref4.y;
        if (gpuAcceleration) {
            var _Object$assign;
            return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", 
            _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", 
            _Object$assign));
        }
        return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", 
        _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
    }
    function computeStyles(_ref5) {
        var state = _ref5.state, options = _ref5.options;
        var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
        var commonStyles = {
            placement: getBasePlacement(state.placement),
            variation: getVariation(state.placement),
            popper: state.elements.popper,
            popperRect: state.rects.popper,
            gpuAcceleration: gpuAcceleration,
            isFixed: state.options.strategy === "fixed"
        };
        if (state.modifiersData.popperOffsets != null) {
            state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
                offsets: state.modifiersData.popperOffsets,
                position: state.options.strategy,
                adaptive: adaptive,
                roundOffsets: roundOffsets
            })));
        }
        if (state.modifiersData.arrow != null) {
            state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
                offsets: state.modifiersData.arrow,
                position: "absolute",
                adaptive: false,
                roundOffsets: roundOffsets
            })));
        }
        state.attributes.popper = Object.assign({}, state.attributes.popper, {
            "data-popper-placement": state.placement
        });
    }
    var computeStyles$1 = {
        name: "computeStyles",
        enabled: true,
        phase: "beforeWrite",
        fn: computeStyles,
        data: {}
    };
    var passive = {
        passive: true
    };
    function effect(_ref) {
        var state = _ref.state, instance = _ref.instance, options = _ref.options;
        var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
        var window = getWindow(state.elements.popper);
        var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
        if (scroll) {
            scrollParents.forEach(function(scrollParent) {
                scrollParent.addEventListener("scroll", instance.update, passive);
            });
        }
        if (resize) {
            window.addEventListener("resize", instance.update, passive);
        }
        return function() {
            if (scroll) {
                scrollParents.forEach(function(scrollParent) {
                    scrollParent.removeEventListener("scroll", instance.update, passive);
                });
            }
            if (resize) {
                window.removeEventListener("resize", instance.update, passive);
            }
        };
    }
    var eventListeners = {
        name: "eventListeners",
        enabled: true,
        phase: "write",
        fn: function fn() {},
        effect: effect,
        data: {}
    };
    var hash$1 = {
        left: "right",
        right: "left",
        bottom: "top",
        top: "bottom"
    };
    function getOppositePlacement(placement) {
        return placement.replace(/left|right|bottom|top/g, function(matched) {
            return hash$1[matched];
        });
    }
    var hash = {
        start: "end",
        end: "start"
    };
    function getOppositeVariationPlacement(placement) {
        return placement.replace(/start|end/g, function(matched) {
            return hash[matched];
        });
    }
    function getWindowScroll(node) {
        var win = getWindow(node);
        var scrollLeft = win.pageXOffset;
        var scrollTop = win.pageYOffset;
        return {
            scrollLeft: scrollLeft,
            scrollTop: scrollTop
        };
    }
    function getWindowScrollBarX(element) {
        return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
    }
    function getViewportRect(element, strategy) {
        var win = getWindow(element);
        var html = getDocumentElement(element);
        var visualViewport = win.visualViewport;
        var width = html.clientWidth;
        var height = html.clientHeight;
        var x = 0;
        var y = 0;
        if (visualViewport) {
            width = visualViewport.width;
            height = visualViewport.height;
            var layoutViewport = isLayoutViewport();
            if (layoutViewport || !layoutViewport && strategy === "fixed") {
                x = visualViewport.offsetLeft;
                y = visualViewport.offsetTop;
            }
        }
        return {
            width: width,
            height: height,
            x: x + getWindowScrollBarX(element),
            y: y
        };
    }
    function getDocumentRect(element) {
        var _element$ownerDocumen;
        var html = getDocumentElement(element);
        var winScroll = getWindowScroll(element);
        var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
        var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
        var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
        var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
        var y = -winScroll.scrollTop;
        if (getComputedStyle$1(body || html).direction === "rtl") {
            x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
        }
        return {
            width: width,
            height: height,
            x: x,
            y: y
        };
    }
    function isScrollParent(element) {
        var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
        return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
    }
    function getScrollParent(node) {
        if ([ "html", "body", "#document" ].indexOf(getNodeName(node)) >= 0) {
            return node.ownerDocument.body;
        }
        if (isHTMLElement(node) && isScrollParent(node)) {
            return node;
        }
        return getScrollParent(getParentNode(node));
    }
    function listScrollParents(element, list) {
        var _element$ownerDocumen;
        if (list === void 0) {
            list = [];
        }
        var scrollParent = getScrollParent(element);
        var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
        var win = getWindow(scrollParent);
        var target = isBody ? [ win ].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
        var updatedList = list.concat(target);
        return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target)));
    }
    function rectToClientRect(rect) {
        return Object.assign({}, rect, {
            left: rect.x,
            top: rect.y,
            right: rect.x + rect.width,
            bottom: rect.y + rect.height
        });
    }
    function getInnerBoundingClientRect(element, strategy) {
        var rect = getBoundingClientRect(element, false, strategy === "fixed");
        rect.top = rect.top + element.clientTop;
        rect.left = rect.left + element.clientLeft;
        rect.bottom = rect.top + element.clientHeight;
        rect.right = rect.left + element.clientWidth;
        rect.width = element.clientWidth;
        rect.height = element.clientHeight;
        rect.x = rect.left;
        rect.y = rect.top;
        return rect;
    }
    function getClientRectFromMixedType(element, clippingParent, strategy) {
        return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
    }
    function getClippingParents(element) {
        var clippingParents = listScrollParents(getParentNode(element));
        var canEscapeClipping = [ "absolute", "fixed" ].indexOf(getComputedStyle$1(element).position) >= 0;
        var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
        if (!isElement(clipperElement)) {
            return [];
        }
        return clippingParents.filter(function(clippingParent) {
            return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
        });
    }
    function getClippingRect(element, boundary, rootBoundary, strategy) {
        var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
        var clippingParents = [].concat(mainClippingParents, [ rootBoundary ]);
        var firstClippingParent = clippingParents[0];
        var clippingRect = clippingParents.reduce(function(accRect, clippingParent) {
            var rect = getClientRectFromMixedType(element, clippingParent, strategy);
            accRect.top = max(rect.top, accRect.top);
            accRect.right = min(rect.right, accRect.right);
            accRect.bottom = min(rect.bottom, accRect.bottom);
            accRect.left = max(rect.left, accRect.left);
            return accRect;
        }, getClientRectFromMixedType(element, firstClippingParent, strategy));
        clippingRect.width = clippingRect.right - clippingRect.left;
        clippingRect.height = clippingRect.bottom - clippingRect.top;
        clippingRect.x = clippingRect.left;
        clippingRect.y = clippingRect.top;
        return clippingRect;
    }
    function computeOffsets(_ref) {
        var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
        var basePlacement = placement ? getBasePlacement(placement) : null;
        var variation = placement ? getVariation(placement) : null;
        var commonX = reference.x + reference.width / 2 - element.width / 2;
        var commonY = reference.y + reference.height / 2 - element.height / 2;
        var offsets;
        switch (basePlacement) {
          case top:
            offsets = {
                x: commonX,
                y: reference.y - element.height
            };
            break;

          case bottom:
            offsets = {
                x: commonX,
                y: reference.y + reference.height
            };
            break;

          case right:
            offsets = {
                x: reference.x + reference.width,
                y: commonY
            };
            break;

          case left:
            offsets = {
                x: reference.x - element.width,
                y: commonY
            };
            break;

          default:
            offsets = {
                x: reference.x,
                y: reference.y
            };
        }
        var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
        if (mainAxis != null) {
            var len = mainAxis === "y" ? "height" : "width";
            switch (variation) {
              case start:
                offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
                break;

              case end:
                offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
                break;
            }
        }
        return offsets;
    }
    function detectOverflow(state, options) {
        if (options === void 0) {
            options = {};
        }
        var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
        var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
        var altContext = elementContext === popper ? reference : popper;
        var popperRect = state.rects.popper;
        var element = state.elements[altBoundary ? altContext : elementContext];
        var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
        var referenceClientRect = getBoundingClientRect(state.elements.reference);
        var popperOffsets = computeOffsets({
            reference: referenceClientRect,
            element: popperRect,
            placement: placement
        });
        var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
        var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
        var overflowOffsets = {
            top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
            bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
            left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
            right: elementClientRect.right - clippingClientRect.right + paddingObject.right
        };
        var offsetData = state.modifiersData.offset;
        if (elementContext === popper && offsetData) {
            var offset = offsetData[placement];
            Object.keys(overflowOffsets).forEach(function(key) {
                var multiply = [ right, bottom ].indexOf(key) >= 0 ? 1 : -1;
                var axis = [ top, bottom ].indexOf(key) >= 0 ? "y" : "x";
                overflowOffsets[key] += offset[axis] * multiply;
            });
        }
        return overflowOffsets;
    }
    function computeAutoPlacement(state, options) {
        if (options === void 0) {
            options = {};
        }
        var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
        var variation = getVariation(placement);
        var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement) {
            return getVariation(placement) === variation;
        }) : basePlacements;
        var allowedPlacements = placements$1.filter(function(placement) {
            return allowedAutoPlacements.indexOf(placement) >= 0;
        });
        if (allowedPlacements.length === 0) {
            allowedPlacements = placements$1;
        }
        var overflows = allowedPlacements.reduce(function(acc, placement) {
            acc[placement] = detectOverflow(state, {
                placement: placement,
                boundary: boundary,
                rootBoundary: rootBoundary,
                padding: padding
            })[getBasePlacement(placement)];
            return acc;
        }, {});
        return Object.keys(overflows).sort(function(a, b) {
            return overflows[a] - overflows[b];
        });
    }
    function getExpandedFallbackPlacements(placement) {
        if (getBasePlacement(placement) === auto) {
            return [];
        }
        var oppositePlacement = getOppositePlacement(placement);
        return [ getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement) ];
    }
    function flip(_ref) {
        var state = _ref.state, options = _ref.options, name = _ref.name;
        if (state.modifiersData[name]._skip) {
            return;
        }
        var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
        var preferredPlacement = state.options.placement;
        var basePlacement = getBasePlacement(preferredPlacement);
        var isBasePlacement = basePlacement === preferredPlacement;
        var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [ getOppositePlacement(preferredPlacement) ] : getExpandedFallbackPlacements(preferredPlacement));
        var placements = [ preferredPlacement ].concat(fallbackPlacements).reduce(function(acc, placement) {
            return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
                placement: placement,
                boundary: boundary,
                rootBoundary: rootBoundary,
                padding: padding,
                flipVariations: flipVariations,
                allowedAutoPlacements: allowedAutoPlacements
            }) : placement);
        }, []);
        var referenceRect = state.rects.reference;
        var popperRect = state.rects.popper;
        var checksMap = new Map;
        var makeFallbackChecks = true;
        var firstFittingPlacement = placements[0];
        for (var i = 0; i < placements.length; i++) {
            var placement = placements[i];
            var _basePlacement = getBasePlacement(placement);
            var isStartVariation = getVariation(placement) === start;
            var isVertical = [ top, bottom ].indexOf(_basePlacement) >= 0;
            var len = isVertical ? "width" : "height";
            var overflow = detectOverflow(state, {
                placement: placement,
                boundary: boundary,
                rootBoundary: rootBoundary,
                altBoundary: altBoundary,
                padding: padding
            });
            var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
            if (referenceRect[len] > popperRect[len]) {
                mainVariationSide = getOppositePlacement(mainVariationSide);
            }
            var altVariationSide = getOppositePlacement(mainVariationSide);
            var checks = [];
            if (checkMainAxis) {
                checks.push(overflow[_basePlacement] <= 0);
            }
            if (checkAltAxis) {
                checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
            }
            if (checks.every(function(check) {
                return check;
            })) {
                firstFittingPlacement = placement;
                makeFallbackChecks = false;
                break;
            }
            checksMap.set(placement, checks);
        }
        if (makeFallbackChecks) {
            var numberOfChecks = flipVariations ? 3 : 1;
            var _loop = function _loop(_i) {
                var fittingPlacement = placements.find(function(placement) {
                    var checks = checksMap.get(placement);
                    if (checks) {
                        return checks.slice(0, _i).every(function(check) {
                            return check;
                        });
                    }
                });
                if (fittingPlacement) {
                    firstFittingPlacement = fittingPlacement;
                    return "break";
                }
            };
            for (var _i = numberOfChecks; _i > 0; _i--) {
                var _ret = _loop(_i);
                if (_ret === "break") break;
            }
        }
        if (state.placement !== firstFittingPlacement) {
            state.modifiersData[name]._skip = true;
            state.placement = firstFittingPlacement;
            state.reset = true;
        }
    }
    var flip$1 = {
        name: "flip",
        enabled: true,
        phase: "main",
        fn: flip,
        requiresIfExists: [ "offset" ],
        data: {
            _skip: false
        }
    };
    function getSideOffsets(overflow, rect, preventedOffsets) {
        if (preventedOffsets === void 0) {
            preventedOffsets = {
                x: 0,
                y: 0
            };
        }
        return {
            top: overflow.top - rect.height - preventedOffsets.y,
            right: overflow.right - rect.width + preventedOffsets.x,
            bottom: overflow.bottom - rect.height + preventedOffsets.y,
            left: overflow.left - rect.width - preventedOffsets.x
        };
    }
    function isAnySideFullyClipped(overflow) {
        return [ top, right, bottom, left ].some(function(side) {
            return overflow[side] >= 0;
        });
    }
    function hide(_ref) {
        var state = _ref.state, name = _ref.name;
        var referenceRect = state.rects.reference;
        var popperRect = state.rects.popper;
        var preventedOffsets = state.modifiersData.preventOverflow;
        var referenceOverflow = detectOverflow(state, {
            elementContext: "reference"
        });
        var popperAltOverflow = detectOverflow(state, {
            altBoundary: true
        });
        var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
        var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
        var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
        var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
        state.modifiersData[name] = {
            referenceClippingOffsets: referenceClippingOffsets,
            popperEscapeOffsets: popperEscapeOffsets,
            isReferenceHidden: isReferenceHidden,
            hasPopperEscaped: hasPopperEscaped
        };
        state.attributes.popper = Object.assign({}, state.attributes.popper, {
            "data-popper-reference-hidden": isReferenceHidden,
            "data-popper-escaped": hasPopperEscaped
        });
    }
    var hide$1 = {
        name: "hide",
        enabled: true,
        phase: "main",
        requiresIfExists: [ "preventOverflow" ],
        fn: hide
    };
    function distanceAndSkiddingToXY(placement, rects, offset) {
        var basePlacement = getBasePlacement(placement);
        var invertDistance = [ left, top ].indexOf(basePlacement) >= 0 ? -1 : 1;
        var _ref = typeof offset === "function" ? offset(Object.assign({}, rects, {
            placement: placement
        })) : offset, skidding = _ref[0], distance = _ref[1];
        skidding = skidding || 0;
        distance = (distance || 0) * invertDistance;
        return [ left, right ].indexOf(basePlacement) >= 0 ? {
            x: distance,
            y: skidding
        } : {
            x: skidding,
            y: distance
        };
    }
    function offset(_ref2) {
        var state = _ref2.state, options = _ref2.options, name = _ref2.name;
        var _options$offset = options.offset, offset = _options$offset === void 0 ? [ 0, 0 ] : _options$offset;
        var data = placements.reduce(function(acc, placement) {
            acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
            return acc;
        }, {});
        var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
        if (state.modifiersData.popperOffsets != null) {
            state.modifiersData.popperOffsets.x += x;
            state.modifiersData.popperOffsets.y += y;
        }
        state.modifiersData[name] = data;
    }
    var offset$1 = {
        name: "offset",
        enabled: true,
        phase: "main",
        requires: [ "popperOffsets" ],
        fn: offset
    };
    function popperOffsets(_ref) {
        var state = _ref.state, name = _ref.name;
        state.modifiersData[name] = computeOffsets({
            reference: state.rects.reference,
            element: state.rects.popper,
            placement: state.placement
        });
    }
    var popperOffsets$1 = {
        name: "popperOffsets",
        enabled: true,
        phase: "read",
        fn: popperOffsets,
        data: {}
    };
    function getAltAxis(axis) {
        return axis === "x" ? "y" : "x";
    }
    function preventOverflow(_ref) {
        var state = _ref.state, options = _ref.options, name = _ref.name;
        var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
        var overflow = detectOverflow(state, {
            boundary: boundary,
            rootBoundary: rootBoundary,
            padding: padding,
            altBoundary: altBoundary
        });
        var basePlacement = getBasePlacement(state.placement);
        var variation = getVariation(state.placement);
        var isBasePlacement = !variation;
        var mainAxis = getMainAxisFromPlacement(basePlacement);
        var altAxis = getAltAxis(mainAxis);
        var popperOffsets = state.modifiersData.popperOffsets;
        var referenceRect = state.rects.reference;
        var popperRect = state.rects.popper;
        var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
            placement: state.placement
        })) : tetherOffset;
        var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
            mainAxis: tetherOffsetValue,
            altAxis: tetherOffsetValue
        } : Object.assign({
            mainAxis: 0,
            altAxis: 0
        }, tetherOffsetValue);
        var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
        var data = {
            x: 0,
            y: 0
        };
        if (!popperOffsets) {
            return;
        }
        if (checkMainAxis) {
            var _offsetModifierState$;
            var mainSide = mainAxis === "y" ? top : left;
            var altSide = mainAxis === "y" ? bottom : right;
            var len = mainAxis === "y" ? "height" : "width";
            var offset = popperOffsets[mainAxis];
            var min$1 = offset + overflow[mainSide];
            var max$1 = offset - overflow[altSide];
            var additive = tether ? -popperRect[len] / 2 : 0;
            var minLen = variation === start ? referenceRect[len] : popperRect[len];
            var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
            var arrowElement = state.elements.arrow;
            var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
                width: 0,
                height: 0
            };
            var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
            var arrowPaddingMin = arrowPaddingObject[mainSide];
            var arrowPaddingMax = arrowPaddingObject[altSide];
            var arrowLen = within(0, referenceRect[len], arrowRect[len]);
            var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
            var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
            var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
            var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
            var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
            var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
            var tetherMax = offset + maxOffset - offsetModifierValue;
            var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
            popperOffsets[mainAxis] = preventedOffset;
            data[mainAxis] = preventedOffset - offset;
        }
        if (checkAltAxis) {
            var _offsetModifierState$2;
            var _mainSide = mainAxis === "x" ? top : left;
            var _altSide = mainAxis === "x" ? bottom : right;
            var _offset = popperOffsets[altAxis];
            var _len = altAxis === "y" ? "height" : "width";
            var _min = _offset + overflow[_mainSide];
            var _max = _offset - overflow[_altSide];
            var isOriginSide = [ top, left ].indexOf(basePlacement) !== -1;
            var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
            var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
            var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
            var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
            popperOffsets[altAxis] = _preventedOffset;
            data[altAxis] = _preventedOffset - _offset;
        }
        state.modifiersData[name] = data;
    }
    var preventOverflow$1 = {
        name: "preventOverflow",
        enabled: true,
        phase: "main",
        fn: preventOverflow,
        requiresIfExists: [ "offset" ]
    };
    function getHTMLElementScroll(element) {
        return {
            scrollLeft: element.scrollLeft,
            scrollTop: element.scrollTop
        };
    }
    function getNodeScroll(node) {
        if (node === getWindow(node) || !isHTMLElement(node)) {
            return getWindowScroll(node);
        } else {
            return getHTMLElementScroll(node);
        }
    }
    function isElementScaled(element) {
        var rect = element.getBoundingClientRect();
        var scaleX = round(rect.width) / element.offsetWidth || 1;
        var scaleY = round(rect.height) / element.offsetHeight || 1;
        return scaleX !== 1 || scaleY !== 1;
    }
    function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
        if (isFixed === void 0) {
            isFixed = false;
        }
        var isOffsetParentAnElement = isHTMLElement(offsetParent);
        var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
        var documentElement = getDocumentElement(offsetParent);
        var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
        var scroll = {
            scrollLeft: 0,
            scrollTop: 0
        };
        var offsets = {
            x: 0,
            y: 0
        };
        if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
            if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
                scroll = getNodeScroll(offsetParent);
            }
            if (isHTMLElement(offsetParent)) {
                offsets = getBoundingClientRect(offsetParent, true);
                offsets.x += offsetParent.clientLeft;
                offsets.y += offsetParent.clientTop;
            } else if (documentElement) {
                offsets.x = getWindowScrollBarX(documentElement);
            }
        }
        return {
            x: rect.left + scroll.scrollLeft - offsets.x,
            y: rect.top + scroll.scrollTop - offsets.y,
            width: rect.width,
            height: rect.height
        };
    }
    function order(modifiers) {
        var map = new Map;
        var visited = new Set;
        var result = [];
        modifiers.forEach(function(modifier) {
            map.set(modifier.name, modifier);
        });
        function sort(modifier) {
            visited.add(modifier.name);
            var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
            requires.forEach(function(dep) {
                if (!visited.has(dep)) {
                    var depModifier = map.get(dep);
                    if (depModifier) {
                        sort(depModifier);
                    }
                }
            });
            result.push(modifier);
        }
        modifiers.forEach(function(modifier) {
            if (!visited.has(modifier.name)) {
                sort(modifier);
            }
        });
        return result;
    }
    function orderModifiers(modifiers) {
        var orderedModifiers = order(modifiers);
        return modifierPhases.reduce(function(acc, phase) {
            return acc.concat(orderedModifiers.filter(function(modifier) {
                return modifier.phase === phase;
            }));
        }, []);
    }
    function debounce$1(fn) {
        var pending;
        return function() {
            if (!pending) {
                pending = new Promise(function(resolve) {
                    Promise.resolve().then(function() {
                        pending = undefined;
                        resolve(fn());
                    });
                });
            }
            return pending;
        };
    }
    function mergeByName(modifiers) {
        var merged = modifiers.reduce(function(merged, current) {
            var existing = merged[current.name];
            merged[current.name] = existing ? Object.assign({}, existing, current, {
                options: Object.assign({}, existing.options, current.options),
                data: Object.assign({}, existing.data, current.data)
            }) : current;
            return merged;
        }, {});
        return Object.keys(merged).map(function(key) {
            return merged[key];
        });
    }
    var DEFAULT_OPTIONS = {
        placement: "bottom",
        modifiers: [],
        strategy: "absolute"
    };
    function areValidElements() {
        for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
        }
        return !args.some(function(element) {
            return !(element && typeof element.getBoundingClientRect === "function");
        });
    }
    function popperGenerator(generatorOptions) {
        if (generatorOptions === void 0) {
            generatorOptions = {};
        }
        var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
        return function createPopper(reference, popper, options) {
            if (options === void 0) {
                options = defaultOptions;
            }
            var state = {
                placement: "bottom",
                orderedModifiers: [],
                options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
                modifiersData: {},
                elements: {
                    reference: reference,
                    popper: popper
                },
                attributes: {},
                styles: {}
            };
            var effectCleanupFns = [];
            var isDestroyed = false;
            var instance = {
                state: state,
                setOptions: function setOptions(setOptionsAction) {
                    var options = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
                    cleanupModifierEffects();
                    state.options = Object.assign({}, defaultOptions, state.options, options);
                    state.scrollParents = {
                        reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
                        popper: listScrollParents(popper)
                    };
                    var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
                    state.orderedModifiers = orderedModifiers.filter(function(m) {
                        return m.enabled;
                    });
                    runModifierEffects();
                    return instance.update();
                },
                forceUpdate: function forceUpdate() {
                    if (isDestroyed) {
                        return;
                    }
                    var _state$elements = state.elements, reference = _state$elements.reference, popper = _state$elements.popper;
                    if (!areValidElements(reference, popper)) {
                        return;
                    }
                    state.rects = {
                        reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === "fixed"),
                        popper: getLayoutRect(popper)
                    };
                    state.reset = false;
                    state.placement = state.options.placement;
                    state.orderedModifiers.forEach(function(modifier) {
                        return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
                    });
                    for (var index = 0; index < state.orderedModifiers.length; index++) {
                        if (state.reset === true) {
                            state.reset = false;
                            index = -1;
                            continue;
                        }
                        var _state$orderedModifie = state.orderedModifiers[index], fn = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
                        if (typeof fn === "function") {
                            state = fn({
                                state: state,
                                options: _options,
                                name: name,
                                instance: instance
                            }) || state;
                        }
                    }
                },
                update: debounce$1(function() {
                    return new Promise(function(resolve) {
                        instance.forceUpdate();
                        resolve(state);
                    });
                }),
                destroy: function destroy() {
                    cleanupModifierEffects();
                    isDestroyed = true;
                }
            };
            if (!areValidElements(reference, popper)) {
                return instance;
            }
            instance.setOptions(options).then(function(state) {
                if (!isDestroyed && options.onFirstUpdate) {
                    options.onFirstUpdate(state);
                }
            });
            function runModifierEffects() {
                state.orderedModifiers.forEach(function(_ref) {
                    var name = _ref.name, _ref$options = _ref.options, options = _ref$options === void 0 ? {} : _ref$options, effect = _ref.effect;
                    if (typeof effect === "function") {
                        var cleanupFn = effect({
                            state: state,
                            name: name,
                            instance: instance,
                            options: options
                        });
                        var noopFn = function noopFn() {};
                        effectCleanupFns.push(cleanupFn || noopFn);
                    }
                });
            }
            function cleanupModifierEffects() {
                effectCleanupFns.forEach(function(fn) {
                    return fn();
                });
                effectCleanupFns = [];
            }
            return instance;
        };
    }
    var defaultModifiers = [ eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1 ];
    var createPopper = popperGenerator({
        defaultModifiers: defaultModifiers
    });
    var Popper = Object.freeze({
        __proto__: null,
        afterMain: afterMain,
        afterRead: afterRead,
        afterWrite: afterWrite,
        applyStyles: applyStyles$1,
        arrow: arrow$1,
        auto: auto,
        basePlacements: basePlacements,
        beforeMain: beforeMain,
        beforeRead: beforeRead,
        beforeWrite: beforeWrite,
        bottom: bottom,
        clippingParents: clippingParents,
        computeStyles: computeStyles$1,
        createPopper: createPopper,
        detectOverflow: detectOverflow,
        end: end,
        eventListeners: eventListeners,
        flip: flip$1,
        hide: hide$1,
        left: left,
        main: main,
        modifierPhases: modifierPhases,
        offset: offset$1,
        placements: placements,
        popper: popper,
        popperGenerator: popperGenerator,
        popperOffsets: popperOffsets$1,
        preventOverflow: preventOverflow$1,
        read: read,
        reference: reference,
        right: right,
        start: start,
        top: top,
        variationPlacements: variationPlacements,
        viewport: viewport,
        write: write
    });
    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: []
    };
    const uriAttributes = new Set([ "background", "cite", "href", "itemtype", "longdesc", "poster", "src", "xlink:href" ]);
    const SAFE_URL_PATTERN = /^(?!javascript:)(?:[a-z0-9+.-]+:|[^&:/?#]*(?:[/?#]|$))/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));
            }
            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 domParser = new window.DOMParser;
        const createdDocument = domParser.parseFromString(unsafeHtml, "text/html");
        const elements = [].concat(...createdDocument.body.querySelectorAll("*"));
        for (const element of elements) {
            const elementName = element.nodeName.toLowerCase();
            if (!Object.keys(allowList).includes(elementName)) {
                element.remove();
                continue;
            }
            const attributeList = [].concat(...element.attributes);
            const allowedAttributes = [].concat(allowList["*"] || [], allowList[elementName] || []);
            for (const attribute of attributeList) {
                if (!allowedAttribute(attribute, allowedAttributes)) {
                    element.removeAttribute(attribute.nodeName);
                }
            }
        }
        return createdDocument.body.innerHTML;
    }
    const NAME$1 = "TemplateFactory";
    const Default$1 = {
        allowList: DefaultAllowlist,
        content: {},
        extraClass: "",
        html: false,
        sanitize: true,
        sanitizeFn: null,
        template: "<div></div>"
    };
    const DefaultType$1 = {
        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 TemplateFactory extends Config {
        constructor(config) {
            super();
            this._config = this._getConfig(config);
        }
        static get Default() {
            return Default$1;
        }
        static get DefaultType() {
            return DefaultType$1;
        }
        static get NAME() {
            return NAME$1;
        }
        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: 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, [ undefined, this ]);
        }
        _putElementInTemplate(element, templateElement) {
            if (this._config.html) {
                templateElement.innerHTML = "";
                templateElement.append(element);
                return;
            }
            templateElement.textContent = element.textContent;
        }
    }
    const NAME = "tooltip";
    const DISALLOWED_ATTRIBUTES = new Set([ "sanitize", "allowList", "sanitizeFn" ]);
    const CLASS_NAME_FADE = "fade";
    const CLASS_NAME_MODAL = "modal";
    const CLASS_NAME_SHOW = "show";
    const SELECTOR_TOOLTIP_INNER = ".tooltip-inner";
    const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
    const EVENT_MODAL_HIDE = "hide.bs.modal";
    const TRIGGER_HOVER = "hover";
    const TRIGGER_FOCUS = "focus";
    const TRIGGER_CLICK = "click";
    const TRIGGER_MANUAL = "manual";
    const EVENT_HIDE = "hide";
    const EVENT_HIDDEN = "hidden";
    const EVENT_SHOW = "show";
    const EVENT_SHOWN = "shown";
    const EVENT_INSERTED = "inserted";
    const EVENT_CLICK = "click";
    const EVENT_FOCUSIN = "focusin";
    const EVENT_FOCUSOUT = "focusout";
    const EVENT_MOUSEENTER = "mouseenter";
    const EVENT_MOUSELEAVE = "mouseleave";
    const AttachmentMap = {
        AUTO: "auto",
        TOP: "top",
        RIGHT: isRTL() ? "left" : "right",
        BOTTOM: "bottom",
        LEFT: isRTL() ? "right" : "left"
    };
    const Default = {
        allowList: DefaultAllowlist,
        animation: true,
        boundary: "clippingParents",
        container: false,
        customClass: "",
        delay: 0,
        fallbackPlacements: [ "top", "right", "bottom", "left" ],
        html: false,
        offset: [ 0, 6 ],
        placement: "top",
        popperConfig: null,
        sanitize: true,
        sanitizeFn: null,
        selector: false,
        template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + "</div>",
        title: "",
        trigger: "hover focus"
    };
    const DefaultType = {
        allowList: "object",
        animation: "boolean",
        boundary: "(string|element)",
        container: "(string|element|boolean)",
        customClass: "(string|function)",
        delay: "(number|object)",
        fallbackPlacements: "array",
        html: "boolean",
        offset: "(array|string|function)",
        placement: "(string|function)",
        popperConfig: "(null|object|function)",
        sanitize: "boolean",
        sanitizeFn: "(null|function)",
        selector: "(string|boolean)",
        template: "string",
        title: "(string|element|function)",
        trigger: "string"
    };
    class Tooltip extends BaseComponent {
        constructor(element, config) {
            if (typeof Popper === "undefined") {
                throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org/docs/v2/)");
            }
            super(element, config);
            this._isEnabled = true;
            this._timeout = 0;
            this._isHovered = null;
            this._activeTrigger = {};
            this._popper = null;
            this._templateFactory = null;
            this._newContent = null;
            this.tip = null;
            this._setListeners();
            if (!this._config.selector) {
                this._fixTitle();
            }
        }
        static get Default() {
            return Default;
        }
        static get DefaultType() {
            return DefaultType;
        }
        static get NAME() {
            return NAME;
        }
        enable() {
            this._isEnabled = true;
        }
        disable() {
            this._isEnabled = false;
        }
        toggleEnabled() {
            this._isEnabled = !this._isEnabled;
        }
        toggle() {
            if (!this._isEnabled) {
                return;
            }
            if (this._isShown()) {
                this._leave();
                return;
            }
            this._enter();
        }
        dispose() {
            clearTimeout(this._timeout);
            EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
            if (this._element.getAttribute("data-bs-original-title")) {
                this._element.setAttribute("title", this._element.getAttribute("data-bs-original-title"));
            }
            this._disposePopper();
            super.dispose();
        }
        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));
            const shadowRoot = findShadowRoot(this._element);
            const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
            if (showEvent.defaultPrevented || !isInTheDom) {
                return;
            }
            this._disposePopper();
            const tip = this._getTipElement();
            this._element.setAttribute("aria-describedby", tip.getAttribute("id"));
            const {container: container} = this._config;
            if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
                container.append(tip);
                EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
            }
            this._popper = this._createPopper(tip);
            tip.classList.add(CLASS_NAME_SHOW);
            if ("ontouchstart" in document.documentElement) {
                for (const element of [].concat(...document.body.children)) {
                    EventHandler.on(element, "mouseover", noop);
                }
            }
            const complete = () => {
                EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN));
                if (this._isHovered === false) {
                    this._leave();
                }
                this._isHovered = false;
            };
            this._queueCallback(complete, this.tip, this._isAnimated());
        }
        hide() {
            if (!this._isShown()) {
                return;
            }
            const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE));
            if (hideEvent.defaultPrevented) {
                return;
            }
            const tip = this._getTipElement();
            tip.classList.remove(CLASS_NAME_SHOW);
            if ("ontouchstart" in document.documentElement) {
                for (const element of [].concat(...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._disposePopper();
                }
                this._element.removeAttribute("aria-describedby");
                EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN));
            };
            this._queueCallback(complete, this.tip, this._isAnimated());
        }
        update() {
            if (this._popper) {
                this._popper.update();
            }
        }
        _isWithContent() {
            return Boolean(this._getTitle());
        }
        _getTipElement() {
            if (!this.tip) {
                this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
            }
            return this.tip;
        }
        _createTipElement(content) {
            const tip = this._getTemplateFactory(content).toHtml();
            if (!tip) {
                return null;
            }
            tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
            tip.classList.add(`bs-${this.constructor.NAME}-auto`);
            const tipId = getUID(this.constructor.NAME).toString();
            tip.setAttribute("id", tipId);
            if (this._isAnimated()) {
                tip.classList.add(CLASS_NAME_FADE);
            }
            return tip;
        }
        setContent(content) {
            this._newContent = content;
            if (this._isShown()) {
                this._disposePopper();
                this.show();
            }
        }
        _getTemplateFactory(content) {
            if (this._templateFactory) {
                this._templateFactory.changeContent(content);
            } else {
                this._templateFactory = new TemplateFactory({
                    ...this._config,
                    content: 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());
        }
        _isAnimated() {
            return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE);
        }
        _isShown() {
            return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW);
        }
        _createPopper(tip) {
            const placement = execute(this._config.placement, [ this, tip, this._element ]);
            const attachment = AttachmentMap[placement.toUpperCase()];
            return createPopper(this._element, tip, this._getPopperConfig(attachment));
        }
        _getOffset() {
            const {offset: offset} = this._config;
            if (typeof offset === "string") {
                return offset.split(",").map(value => Number.parseInt(value, 10));
            }
            if (typeof offset === "function") {
                return popperData => offset(popperData, this._element);
            }
            return offset;
        }
        _resolvePossibleFunction(arg) {
            return execute(arg, [ this._element, this._element ]);
        }
        _getPopperConfig(attachment) {
            const defaultBsPopperConfig = {
                placement: attachment,
                modifiers: [ {
                    name: "flip",
                    options: {
                        fallbackPlacements: this._config.fallbackPlacements
                    }
                }, {
                    name: "offset",
                    options: {
                        offset: this._getOffset()
                    }
                }, {
                    name: "preventOverflow",
                    options: {
                        boundary: this._config.boundary
                    }
                }, {
                    name: "arrow",
                    options: {
                        element: `.${this.constructor.NAME}-arrow`
                    }
                }, {
                    name: "preSetPlacement",
                    enabled: true,
                    phase: "beforeMain",
                    fn: data => {
                        this._getTipElement().setAttribute("data-popper-placement", data.state.placement);
                    }
                } ]
            };
            return {
                ...defaultBsPopperConfig,
                ...execute(this._config.popperConfig, [ undefined, defaultBsPopperConfig ])
            };
        }
        _setListeners() {
            const triggers = this._config.trigger.split(" ");
            for (const trigger of triggers) {
                if (trigger === "click") {
                    EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), 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 = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN);
                    const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT);
                    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);
                        context._activeTrigger[event.type === "focusout" ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
                        context._leave();
                    });
                }
            }
            this._hideModalHandler = () => {
                if (this._element) {
                    this.hide();
                }
            };
            EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
        }
        _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;
            }
            this._isHovered = true;
            this._setTimeout(() => {
                if (this._isHovered) {
                    this.show();
                }
            }, this._config.delay.show);
        }
        _leave() {
            if (this._isWithActiveTrigger()) {
                return;
            }
            this._isHovered = false;
            this._setTimeout(() => {
                if (!this._isHovered) {
                    this.hide();
                }
            }, this._config.delay.hide);
        }
        _setTimeout(handler, timeout) {
            clearTimeout(this._timeout);
            this._timeout = setTimeout(handler, timeout);
        }
        _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.has(dataAttribute)) {
                    delete dataAttributes[dataAttribute];
                }
            }
            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);
            if (typeof config.delay === "number") {
                config.delay = {
                    show: config.delay,
                    hide: config.delay
                };
            }
            if (typeof config.title === "number") {
                config.title = config.title.toString();
            }
            if (typeof config.content === "number") {
                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;
        }
        _disposePopper() {
            if (this._popper) {
                this._popper.destroy();
                this._popper = null;
            }
            if (this.tip) {
                this.tip.remove();
                this.tip = null;
            }
        }
        static jQueryInterface(config) {
            return this.each(function() {
                const data = Tooltip.getOrCreateInstance(this, config);
                if (typeof config !== "string") {
                    return;
                }
                if (typeof data[config] === "undefined") {
                    throw new TypeError(`No method named "${config}"`);
                }
                data[config]();
            });
        }
    }
    defineJQueryPlugin(Tooltip);
    var bsqrcdr$1 = {
        Button: Button,
        Collapse: Collapse,
        Modal: Modal,
        Tab: Tab,
        Toast: Toast,
        Tooltip: Tooltip
    };
    const Coloris$1 = (() => ((window, document, Math, undefined$1) => {
        const ctx = document.createElement("canvas").getContext("2d");
        const currentColor = {
            r: 0,
            g: 0,
            b: 0,
            h: 0,
            s: 0,
            v: 0,
            a: 1
        };
        let container, picker, colorArea, colorMarker, colorPreview, colorValue, clearButton, closeButton, hueSlider, hueMarker, alphaSlider, alphaMarker, currentEl, currentFormat, oldColor, keyboardNav, colorAreaDims = {};
        const settings = {
            el: "[data-coloris]",
            parent: "body",
            theme: "default",
            themeMode: "light",
            rtl: false,
            wrap: true,
            margin: 2,
            format: "hex",
            formatToggle: false,
            swatches: [],
            swatchesOnly: false,
            alpha: true,
            forceAlpha: false,
            focusInput: true,
            selectInput: false,
            inline: false,
            defaultColor: "#000000",
            clearButton: false,
            clearLabel: "Clear",
            closeButton: false,
            closeLabel: "Close",
            onChange: () => undefined$1,
            a11y: {
                open: "Open color picker",
                close: "Close color picker",
                clear: "Clear the selected color",
                marker: "Saturation: {s}. Brightness: {v}.",
                hueSlider: "Hue slider",
                alphaSlider: "Opacity slider",
                input: "Color value field",
                format: "Color format",
                swatch: "Color swatch",
                instruction: "Saturation and brightness selector. Use up, down, left and right arrow keys to select."
            }
        };
        const instances = {};
        let currentInstanceId = "";
        let defaultInstance = {};
        let hasInstance = false;
        function configure(options) {
            if (typeof options !== "object") {
                return;
            }
            for (const key in options) {
                switch (key) {
                  case "el":
                    bindFields(options.el);
                    if (options.wrap !== false) {
                        wrapFields(options.el);
                    }
                    break;

                  case "parent":
                    container = options.parent instanceof HTMLElement ? options.parent : document.querySelector(options.parent);
                    if (container) {
                        container.appendChild(picker);
                        settings.parent = options.parent;
                        if (container === document.body) {
                            container = undefined$1;
                        }
                    }
                    break;

                  case "themeMode":
                    settings.themeMode = options.themeMode;
                    if (options.themeMode === "auto" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
                        settings.themeMode = "dark";
                    }

                  case "theme":
                    if (options.theme) {
                        settings.theme = options.theme;
                    }
                    picker.className = `clr-picker clr-${settings.theme} clr-${settings.themeMode}`;
                    if (settings.inline) {
                        updatePickerPosition();
                    }
                    break;

                  case "rtl":
                    settings.rtl = !!options.rtl;
                    Array.from(document.getElementsByClassName("clr-field")).forEach(field => field.classList.toggle("clr-rtl", settings.rtl));
                    break;

                  case "margin":
                    options.margin *= 1;
                    settings.margin = !isNaN(options.margin) ? options.margin : settings.margin;
                    break;

                  case "wrap":
                    if (options.el && options.wrap) {
                        wrapFields(options.el);
                    }
                    break;

                  case "formatToggle":
                    settings.formatToggle = !!options.formatToggle;
                    getEl("clr-format").style.display = settings.formatToggle ? "block" : "none";
                    if (settings.formatToggle) {
                        settings.format = "auto";
                    }
                    break;

                  case "swatches":
                    if (Array.isArray(options.swatches)) {
                        const swatchesContainer = getEl("clr-swatches");
                        const swatches = document.createElement("div");
                        swatchesContainer.textContent = "";
                        options.swatches.forEach((swatch, i) => {
                            const button = document.createElement("button");
                            button.setAttribute("type", `button`);
                            button.setAttribute("id", `clr-swatch-${i}`);
                            button.setAttribute("aria-labelledby", `clr-swatch-label clr-swatch-${i}`);
                            button.style.color = swatch;
                            button.textContent = swatch;
                            swatches.appendChild(button);
                        });
                        if (options.swatches.length) {
                            swatchesContainer.appendChild(swatches);
                        }
                        settings.swatches = options.swatches.slice();
                    }
                    break;

                  case "swatchesOnly":
                    settings.swatchesOnly = !!options.swatchesOnly;
                    picker.setAttribute("data-minimal", settings.swatchesOnly);
                    break;

                  case "alpha":
                    settings.alpha = !!options.alpha;
                    picker.setAttribute("data-alpha", settings.alpha);
                    break;

                  case "inline":
                    settings.inline = !!options.inline;
                    picker.setAttribute("data-inline", settings.inline);
                    if (settings.inline) {
                        const defaultColor = options.defaultColor || settings.defaultColor;
                        currentFormat = getColorFormatFromStr(defaultColor);
                        updatePickerPosition();
                        setColorFromStr(defaultColor);
                    }
                    break;

                  case "clearButton":
                    if (typeof options.clearButton === "object") {
                        if (options.clearButton.label) {
                            settings.clearLabel = options.clearButton.label;
                            clearButton.innerHTML = settings.clearLabel;
                        }
                        options.clearButton = options.clearButton.show;
                    }
                    settings.clearButton = !!options.clearButton;
                    clearButton.style.display = settings.clearButton ? "block" : "none";
                    break;

                  case "clearLabel":
                    settings.clearLabel = options.clearLabel;
                    clearButton.innerHTML = settings.clearLabel;
                    break;

                  case "closeButton":
                    settings.closeButton = !!options.closeButton;
                    if (settings.closeButton) {
                        picker.insertBefore(closeButton, colorPreview);
                    } else {
                        colorPreview.appendChild(closeButton);
                    }
                    break;

                  case "closeLabel":
                    settings.closeLabel = options.closeLabel;
                    closeButton.innerHTML = settings.closeLabel;
                    break;

                  case "a11y":
                    const labels = options.a11y;
                    let update = false;
                    if (typeof labels === "object") {
                        for (const label in labels) {
                            if (labels[label] && settings.a11y[label]) {
                                settings.a11y[label] = labels[label];
                                update = true;
                            }
                        }
                    }
                    if (update) {
                        const openLabel = getEl("clr-open-label");
                        const swatchLabel = getEl("clr-swatch-label");
                        openLabel.innerHTML = settings.a11y.open;
                        swatchLabel.innerHTML = settings.a11y.swatch;
                        closeButton.setAttribute("aria-label", settings.a11y.close);
                        clearButton.setAttribute("aria-label", settings.a11y.clear);
                        hueSlider.setAttribute("aria-label", settings.a11y.hueSlider);
                        alphaSlider.setAttribute("aria-label", settings.a11y.alphaSlider);
                        colorValue.setAttribute("aria-label", settings.a11y.input);
                        colorArea.setAttribute("aria-label", settings.a11y.instruction);
                    }
                    break;

                  default:
                    settings[key] = options[key];
                }
            }
        }
        function setVirtualInstance(selector, options) {
            if (typeof selector === "string" && typeof options === "object") {
                instances[selector] = options;
                hasInstance = true;
            }
        }
        function removeVirtualInstance(selector) {
            delete instances[selector];
            if (Object.keys(instances).length === 0) {
                hasInstance = false;
                if (selector === currentInstanceId) {
                    resetVirtualInstance();
                }
            }
        }
        function attachVirtualInstance(element) {
            if (hasInstance) {
                const unsupportedOptions = [ "el", "wrap", "rtl", "inline", "defaultColor", "a11y" ];
                for (let selector in instances) {
                    const options = instances[selector];
                    if (element.matches(selector)) {
                        currentInstanceId = selector;
                        defaultInstance = {};
                        unsupportedOptions.forEach(option => delete options[option]);
                        for (let option in options) {
                            defaultInstance[option] = Array.isArray(settings[option]) ? settings[option].slice() : settings[option];
                        }
                        configure(options);
                        break;
                    }
                }
            }
        }
        function resetVirtualInstance() {
            if (Object.keys(defaultInstance).length > 0) {
                configure(defaultInstance);
                currentInstanceId = "";
                defaultInstance = {};
            }
        }
        function bindFields(selector) {
            if (selector instanceof HTMLElement) {
                selector = [ selector ];
            }
            if (Array.isArray(selector)) {
                selector.forEach(field => {
                    addListener(field, "click", openPicker);
                    addListener(field, "input", updateColorPreview);
                });
            } else {
                addListener(document, "click", selector, openPicker);
                addListener(document, "input", selector, updateColorPreview);
            }
        }
        function openPicker(event) {
            if (settings.inline) {
                return;
            }
            attachVirtualInstance(event.target);
            currentEl = event.target;
            oldColor = currentEl.value;
            currentFormat = getColorFormatFromStr(oldColor);
            picker.classList.add("clr-open");
            updatePickerPosition();
            setColorFromStr(oldColor);
            if (settings.focusInput || settings.selectInput) {
                colorValue.focus({
                    preventScroll: true
                });
                colorValue.setSelectionRange(currentEl.selectionStart, currentEl.selectionEnd);
            }
            if (settings.selectInput) {
                colorValue.select();
            }
            if (keyboardNav || settings.swatchesOnly) {
                getFocusableElements().shift().focus();
            }
            currentEl.dispatchEvent(new Event("open", {
                bubbles: false
            }));
        }
        function updatePickerPosition() {
            if (!picker || !currentEl && !settings.inline) return;
            const parent = container;
            const scrollY = window.scrollY;
            const pickerWidth = picker.offsetWidth;
            const pickerHeight = picker.offsetHeight;
            const reposition = {
                left: false,
                top: false
            };
            let parentStyle, parentMarginTop, parentBorderTop;
            let offset = {
                x: 0,
                y: 0
            };
            if (parent) {
                parentStyle = window.getComputedStyle(parent);
                parentMarginTop = parseFloat(parentStyle.marginTop);
                parentBorderTop = parseFloat(parentStyle.borderTopWidth);
                offset = parent.getBoundingClientRect();
                offset.y += parentBorderTop + scrollY;
            }
            if (!settings.inline) {
                const coords = currentEl.getBoundingClientRect();
                let left = coords.x;
                let top = scrollY + coords.y + coords.height + settings.margin;
                if (parent) {
                    left -= offset.x;
                    top -= offset.y;
                    if (left + pickerWidth > parent.clientWidth) {
                        left += coords.width - pickerWidth;
                        reposition.left = true;
                    }
                    if (top + pickerHeight > parent.clientHeight - parentMarginTop) {
                        if (pickerHeight + settings.margin <= coords.top - (offset.y - scrollY)) {
                            top -= coords.height + pickerHeight + settings.margin * 2;
                            reposition.top = true;
                        }
                    }
                    top += parent.scrollTop;
                } else {
                    if (left + pickerWidth > document.documentElement.clientWidth) {
                        left += coords.width - pickerWidth;
                        reposition.left = true;
                    }
                    if (top + pickerHeight - scrollY > document.documentElement.clientHeight) {
                        if (pickerHeight + settings.margin <= coords.top) {
                            top = scrollY + coords.y - pickerHeight - settings.margin;
                            reposition.top = true;
                        }
                    }
                }
                picker.classList.toggle("clr-left", reposition.left);
                picker.classList.toggle("clr-top", reposition.top);
                picker.style.left = `${left}px`;
                picker.style.top = `${top}px`;
                offset.x += picker.offsetLeft;
                offset.y += picker.offsetTop;
            }
            colorAreaDims = {
                width: colorArea.offsetWidth,
                height: colorArea.offsetHeight,
                x: colorArea.offsetLeft + offset.x,
                y: colorArea.offsetTop + offset.y
            };
        }
        function wrapFields(selector) {
            if (selector instanceof HTMLElement) {
                wrapColorField(selector);
            } else if (Array.isArray(selector)) {
                selector.forEach(wrapColorField);
            } else {
                document.querySelectorAll(selector).forEach(wrapColorField);
            }
        }
        function wrapColorField(field) {
            const parentNode = field.parentNode;
            if (!parentNode.classList.contains("clr-field")) {
                const wrapper = document.createElement("div");
                let classes = "clr-field";
                if (settings.rtl || field.classList.contains("clr-rtl")) {
                    classes += " clr-rtl";
                }
                wrapper.innerHTML = '<button type="button" aria-labelledby="clr-open-label"></button>';
                parentNode.insertBefore(wrapper, field);
                wrapper.className = classes;
                wrapper.style.color = field.value;
                wrapper.appendChild(field);
            }
        }
        function updateColorPreview(event) {
            const parent = event.target.parentNode;
            if (parent.classList.contains("clr-field")) {
                parent.style.color = event.target.value;
            }
        }
        function closePicker(revert) {
            if (currentEl && !settings.inline) {
                const prevEl = currentEl;
                if (revert) {
                    currentEl = undefined$1;
                    if (oldColor !== prevEl.value) {
                        prevEl.value = oldColor;
                        prevEl.dispatchEvent(new Event("input", {
                            bubbles: true
                        }));
                    }
                }
                setTimeout(() => {
                    if (oldColor !== prevEl.value) {
                        prevEl.dispatchEvent(new Event("change", {
                            bubbles: true
                        }));
                    }
                });
                picker.classList.remove("clr-open");
                if (hasInstance) {
                    resetVirtualInstance();
                }
                prevEl.dispatchEvent(new Event("close", {
                    bubbles: false
                }));
                if (settings.focusInput) {
                    prevEl.focus({
                        preventScroll: true
                    });
                }
                currentEl = undefined$1;
            }
        }
        function setColorFromStr(str) {
            const rgba = strToRGBA(str);
            const hsva = RGBAtoHSVA(rgba);
            updateMarkerA11yLabel(hsva.s, hsva.v);
            updateColor(rgba, hsva);
            hueSlider.value = hsva.h;
            picker.style.color = `hsl(${hsva.h}, 100%, 50%)`;
            hueMarker.style.left = `${hsva.h / 360 * 100}%`;
            colorMarker.style.left = `${colorAreaDims.width * hsva.s / 100}px`;
            colorMarker.style.top = `${colorAreaDims.height - colorAreaDims.height * hsva.v / 100}px`;
            alphaSlider.value = hsva.a * 100;
            alphaMarker.style.left = `${hsva.a * 100}%`;
        }
        function getColorFormatFromStr(str) {
            const format = str.substring(0, 3).toLowerCase();
            if (format === "rgb" || format === "hsl") {
                return format;
            }
            return "hex";
        }
        function pickColor(color) {
            color = color !== undefined$1 ? color : colorValue.value;
            if (currentEl) {
                currentEl.value = color;
                currentEl.dispatchEvent(new Event("input", {
                    bubbles: true
                }));
            }
            if (settings.onChange) {
                settings.onChange.call(window, color, currentEl);
            }
            document.dispatchEvent(new CustomEvent("coloris:pick", {
                detail: {
                    color: color,
                    currentEl: currentEl
                }
            }));
        }
        function setColorAtPosition(x, y) {
            const hsva = {
                h: hueSlider.value * 1,
                s: x / colorAreaDims.width * 100,
                v: 100 - y / colorAreaDims.height * 100,
                a: alphaSlider.value / 100
            };
            const rgba = HSVAtoRGBA(hsva);
            updateMarkerA11yLabel(hsva.s, hsva.v);
            updateColor(rgba, hsva);
            pickColor();
        }
        function updateMarkerA11yLabel(saturation, value) {
            let label = settings.a11y.marker;
            saturation = saturation.toFixed(1) * 1;
            value = value.toFixed(1) * 1;
            label = label.replace("{s}", saturation);
            label = label.replace("{v}", value);
            colorMarker.setAttribute("aria-label", label);
        }
        function getPointerPosition(event) {
            return {
                pageX: event.changedTouches ? event.changedTouches[0].pageX : event.pageX,
                pageY: event.changedTouches ? event.changedTouches[0].pageY : event.pageY
            };
        }
        function moveMarker(event) {
            const pointer = getPointerPosition(event);
            let x = pointer.pageX - colorAreaDims.x;
            let y = pointer.pageY - colorAreaDims.y;
            if (container) {
                y += container.scrollTop;
            }
            setMarkerPosition(x, y);
            event.preventDefault();
            event.stopPropagation();
        }
        function moveMarkerOnKeydown(offsetX, offsetY) {
            let x = colorMarker.style.left.replace("px", "") * 1 + offsetX;
            let y = colorMarker.style.top.replace("px", "") * 1 + offsetY;
            setMarkerPosition(x, y);
        }
        function setMarkerPosition(x, y) {
            x = x < 0 ? 0 : x > colorAreaDims.width ? colorAreaDims.width : x;
            y = y < 0 ? 0 : y > colorAreaDims.height ? colorAreaDims.height : y;
            colorMarker.style.left = `${x}px`;
            colorMarker.style.top = `${y}px`;
            setColorAtPosition(x, y);
            colorMarker.focus();
        }
        function updateColor(rgba, hsva) {
            if (rgba === void 0) {
                rgba = {};
            }
            if (hsva === void 0) {
                hsva = {};
            }
            let format = settings.format;
            for (const key in rgba) {
                currentColor[key] = rgba[key];
            }
            for (const key in hsva) {
                currentColor[key] = hsva[key];
            }
            const hex = RGBAToHex(currentColor);
            const opaqueHex = hex.substring(0, 7);
            colorMarker.style.color = opaqueHex;
            alphaMarker.parentNode.style.color = opaqueHex;
            alphaMarker.style.color = hex;
            colorPreview.style.color = hex;
            colorArea.style.display = "none";
            colorArea.offsetHeight;
            colorArea.style.display = "";
            alphaMarker.nextElementSibling.style.display = "none";
            alphaMarker.nextElementSibling.offsetHeight;
            alphaMarker.nextElementSibling.style.display = "";
            if (format === "mixed") {
                format = currentColor.a === 1 ? "hex" : "rgb";
            } else if (format === "auto") {
                format = currentFormat;
            }
            switch (format) {
              case "hex":
                colorValue.value = hex;
                break;

              case "rgb":
                colorValue.value = RGBAToStr(currentColor);
                break;

              case "hsl":
                colorValue.value = HSLAToStr(HSVAtoHSLA(currentColor));
                break;
            }
            document.querySelector(`.clr-format [value="${format}"]`).checked = true;
        }
        function setHue() {
            const hue = hueSlider.value * 1;
            const x = colorMarker.style.left.replace("px", "") * 1;
            const y = colorMarker.style.top.replace("px", "") * 1;
            picker.style.color = `hsl(${hue}, 100%, 50%)`;
            hueMarker.style.left = `${hue / 360 * 100}%`;
            setColorAtPosition(x, y);
        }
        function setAlpha() {
            const alpha = alphaSlider.value / 100;
            alphaMarker.style.left = `${alpha * 100}%`;
            updateColor({
                a: alpha
            });
            pickColor();
        }
        function HSVAtoRGBA(hsva) {
            const saturation = hsva.s / 100;
            const value = hsva.v / 100;
            let chroma = saturation * value;
            let hueBy60 = hsva.h / 60;
            let x = chroma * (1 - Math.abs(hueBy60 % 2 - 1));
            let m = value - chroma;
            chroma = chroma + m;
            x = x + m;
            const index = Math.floor(hueBy60) % 6;
            const red = [ chroma, x, m, m, x, chroma ][index];
            const green = [ x, chroma, chroma, x, m, m ][index];
            const blue = [ m, m, x, chroma, chroma, x ][index];
            return {
                r: Math.round(red * 255),
                g: Math.round(green * 255),
                b: Math.round(blue * 255),
                a: hsva.a
            };
        }
        function HSVAtoHSLA(hsva) {
            const value = hsva.v / 100;
            const lightness = value * (1 - hsva.s / 100 / 2);
            let saturation;
            if (lightness > 0 && lightness < 1) {
                saturation = Math.round((value - lightness) / Math.min(lightness, 1 - lightness) * 100);
            }
            return {
                h: hsva.h,
                s: saturation || 0,
                l: Math.round(lightness * 100),
                a: hsva.a
            };
        }
        function RGBAtoHSVA(rgba) {
            const red = rgba.r / 255;
            const green = rgba.g / 255;
            const blue = rgba.b / 255;
            const xmax = Math.max(red, green, blue);
            const xmin = Math.min(red, green, blue);
            const chroma = xmax - xmin;
            const value = xmax;
            let hue = 0;
            let saturation = 0;
            if (chroma) {
                if (xmax === red) {
                    hue = (green - blue) / chroma;
                }
                if (xmax === green) {
                    hue = 2 + (blue - red) / chroma;
                }
                if (xmax === blue) {
                    hue = 4 + (red - green) / chroma;
                }
                if (xmax) {
                    saturation = chroma / xmax;
                }
            }
            hue = Math.floor(hue * 60);
            return {
                h: hue < 0 ? hue + 360 : hue,
                s: Math.round(saturation * 100),
                v: Math.round(value * 100),
                a: rgba.a
            };
        }
        function strToRGBA(str) {
            const regex = /^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;
            let match, rgba;
            ctx.fillStyle = "#000";
            ctx.fillStyle = str;
            match = regex.exec(ctx.fillStyle);
            if (match) {
                rgba = {
                    r: match[3] * 1,
                    g: match[4] * 1,
                    b: match[5] * 1,
                    a: match[6] * 1
                };
            } else {
                match = ctx.fillStyle.replace("#", "").match(/.{2}/g).map(h => parseInt(h, 16));
                rgba = {
                    r: match[0],
                    g: match[1],
                    b: match[2],
                    a: 1
                };
            }
            return rgba;
        }
        function RGBAToHex(rgba) {
            let R = rgba.r.toString(16);
            let G = rgba.g.toString(16);
            let B = rgba.b.toString(16);
            let A = "";
            if (rgba.r < 16) {
                R = "0" + R;
            }
            if (rgba.g < 16) {
                G = "0" + G;
            }
            if (rgba.b < 16) {
                B = "0" + B;
            }
            if (settings.alpha && (rgba.a < 1 || settings.forceAlpha)) {
                const alpha = rgba.a * 255 | 0;
                A = alpha.toString(16);
                if (alpha < 16) {
                    A = "0" + A;
                }
            }
            return "#" + R + G + B + A;
        }
        function RGBAToStr(rgba) {
            if (!settings.alpha || rgba.a === 1 && !settings.forceAlpha) {
                return `rgb(${rgba.r}, ${rgba.g}, ${rgba.b})`;
            } else {
                return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`;
            }
        }
        function HSLAToStr(hsla) {
            if (!settings.alpha || hsla.a === 1 && !settings.forceAlpha) {
                return `hsl(${hsla.h}, ${hsla.s}%, ${hsla.l}%)`;
            } else {
                return `hsla(${hsla.h}, ${hsla.s}%, ${hsla.l}%, ${hsla.a})`;
            }
        }
        function init() {
            if (document.getElementById("clr-picker")) return;
            container = undefined$1;
            picker = document.createElement("div");
            picker.setAttribute("id", "clr-picker");
            picker.className = "clr-picker";
            picker.innerHTML = `<input id="clr-color-value" name="clr-color-value" class="clr-color" type="text" value="" spellcheck="false" aria-label="${settings.a11y.input}">` + `<div id="clr-color-area" class="clr-gradient" role="application" aria-label="${settings.a11y.instruction}">` + '<div id="clr-color-marker" class="clr-marker" tabindex="0"></div>' + "</div>" + '<div class="clr-hue">' + `<input id="clr-hue-slider" name="clr-hue-slider" type="range" min="0" max="360" step="1" aria-label="${settings.a11y.hueSlider}">` + '<div id="clr-hue-marker"></div>' + "</div>" + '<div class="clr-alpha">' + `<input id="clr-alpha-slider" name="clr-alpha-slider" type="range" min="0" max="100" step="1" aria-label="${settings.a11y.alphaSlider}">` + '<div id="clr-alpha-marker"></div>' + "<span></span>" + "</div>" + '<div id="clr-format" class="clr-format">' + '<fieldset class="clr-segmented">' + `<legend>${settings.a11y.format}</legend>` + '<input id="clr-f1" type="radio" name="clr-format" value="hex">' + '<label for="clr-f1">Hex</label>' + '<input id="clr-f2" type="radio" name="clr-format" value="rgb">' + '<label for="clr-f2">RGB</label>' + '<input id="clr-f3" type="radio" name="clr-format" value="hsl">' + '<label for="clr-f3">HSL</label>' + "<span></span>" + "</fieldset>" + "</div>" + '<div id="clr-swatches" class="clr-swatches"></div>' + `<button type="button" id="clr-clear" class="clr-clear" aria-label="${settings.a11y.clear}">${settings.clearLabel}</button>` + '<div id="clr-color-preview" class="clr-preview">' + `<button type="button" id="clr-close" class="clr-close" aria-label="${settings.a11y.close}">${settings.closeLabel}</button>` + "</div>" + `<span id="clr-open-label" hidden>${settings.a11y.open}</span>` + `<span id="clr-swatch-label" hidden>${settings.a11y.swatch}</span>`;
            document.body.appendChild(picker);
            colorArea = getEl("clr-color-area");
            colorMarker = getEl("clr-color-marker");
            clearButton = getEl("clr-clear");
            closeButton = getEl("clr-close");
            colorPreview = getEl("clr-color-preview");
            colorValue = getEl("clr-color-value");
            hueSlider = getEl("clr-hue-slider");
            hueMarker = getEl("clr-hue-marker");
            alphaSlider = getEl("clr-alpha-slider");
            alphaMarker = getEl("clr-alpha-marker");
            bindFields(settings.el);
            wrapFields(settings.el);
            addListener(picker, "mousedown", event => {
                picker.classList.remove("clr-keyboard-nav");
                event.stopPropagation();
            });
            addListener(colorArea, "mousedown", event => {
                addListener(document, "mousemove", moveMarker);
            });
            addListener(colorArea, "contextmenu", event => {
                event.preventDefault();
            });
            addListener(colorArea, "touchstart", event => {
                document.addEventListener("touchmove", moveMarker, {
                    passive: false
                });
            });
            addListener(colorMarker, "mousedown", event => {
                addListener(document, "mousemove", moveMarker);
            });
            addListener(colorMarker, "touchstart", event => {
                document.addEventListener("touchmove", moveMarker, {
                    passive: false
                });
            });
            addListener(colorValue, "change", event => {
                const value = colorValue.value;
                if (currentEl || settings.inline) {
                    const color = value === "" ? value : setColorFromStr(value);
                    pickColor(color);
                }
            });
            addListener(clearButton, "click", event => {
                pickColor("");
                closePicker();
            });
            addListener(closeButton, "click", event => {
                pickColor();
                closePicker();
            });
            addListener(getEl("clr-format"), "click", ".clr-format input", event => {
                currentFormat = event.target.value;
                updateColor();
                pickColor();
            });
            addListener(picker, "click", ".clr-swatches button", event => {
                setColorFromStr(event.target.textContent);
                pickColor();
                if (settings.swatchesOnly) {
                    closePicker();
                }
            });
            addListener(document, "mouseup", event => {
                document.removeEventListener("mousemove", moveMarker);
            });
            addListener(document, "touchend", event => {
                document.removeEventListener("touchmove", moveMarker);
            });
            addListener(document, "mousedown", event => {
                keyboardNav = false;
                picker.classList.remove("clr-keyboard-nav");
                closePicker();
            });
            addListener(document, "keydown", event => {
                const key = event.key;
                const target = event.target;
                const shiftKey = event.shiftKey;
                const navKeys = [ "Tab", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight" ];
                if (key === "Escape") {
                    closePicker(true);
                    return;
                } else if (key === "Enter" && target.tagName !== "BUTTON") {
                    closePicker();
                    return;
                } else if (navKeys.includes(key)) {
                    keyboardNav = true;
                    picker.classList.add("clr-keyboard-nav");
                }
                if (key === "Tab" && target.matches(".clr-picker *")) {
                    const focusables = getFocusableElements();
                    const firstFocusable = focusables.shift();
                    const lastFocusable = focusables.pop();
                    if (shiftKey && target === firstFocusable) {
                        lastFocusable.focus();
                        event.preventDefault();
                    } else if (!shiftKey && target === lastFocusable) {
                        firstFocusable.focus();
                        event.preventDefault();
                    }
                }
            });
            addListener(document, "click", ".clr-field button", event => {
                if (hasInstance) {
                    resetVirtualInstance();
                }
                event.target.nextElementSibling.dispatchEvent(new Event("click", {
                    bubbles: true
                }));
            });
            addListener(colorMarker, "keydown", event => {
                const movements = {
                    ArrowUp: [ 0, -1 ],
                    ArrowDown: [ 0, 1 ],
                    ArrowLeft: [ -1, 0 ],
                    ArrowRight: [ 1, 0 ]
                };
                if (Object.keys(movements).includes(event.key)) {
                    moveMarkerOnKeydown(...movements[event.key]);
                    event.preventDefault();
                }
            });
            addListener(colorArea, "click", moveMarker);
            addListener(hueSlider, "input", setHue);
            addListener(alphaSlider, "input", setAlpha);
        }
        function getFocusableElements() {
            const controls = Array.from(picker.querySelectorAll("input, button"));
            const focusables = controls.filter(node => !!node.offsetWidth);
            return focusables;
        }
        function getEl(id) {
            return document.getElementById(id);
        }
        function addListener(context, type, selector, fn) {
            const matches = Element.prototype.matches || Element.prototype.msMatchesSelector;
            if (typeof selector === "string") {
                context.addEventListener(type, event => {
                    if (matches.call(event.target, selector)) {
                        fn.call(event.target, event);
                    }
                });
            } else {
                fn = selector;
                context.addEventListener(type, fn);
            }
        }
        function DOMReady(fn, args) {
            args = args !== undefined$1 ? args : [];
            if (document.readyState !== "loading") {
                fn(...args);
            } else {
                document.addEventListener("DOMContentLoaded", () => {
                    fn(...args);
                });
            }
        }
        if (NodeList !== undefined$1 && NodeList.prototype && !NodeList.prototype.forEach) {
            NodeList.prototype.forEach = Array.prototype.forEach;
        }
        function setColor(color, target) {
            currentEl = target;
            oldColor = currentEl.value;
            attachVirtualInstance(target);
            currentFormat = getColorFormatFromStr(color);
            updatePickerPosition();
            setColorFromStr(color);
            pickColor();
            if (oldColor !== color) {
                currentEl.dispatchEvent(new Event("change", {
                    bubbles: true
                }));
            }
        }
        const Coloris = (() => {
            const methods = {
                init: init,
                set: configure,
                wrap: wrapFields,
                close: closePicker,
                setInstance: setVirtualInstance,
                setColor: setColor,
                removeInstance: removeVirtualInstance,
                updatePosition: updatePickerPosition,
                ready: DOMReady
            };
            function Coloris(options) {
                DOMReady(() => {
                    if (options) {
                        if (typeof options === "string") {
                            bindFields(options);
                        } else {
                            configure(options);
                        }
                    }
                });
            }
            for (const key in methods) {
                Coloris[key] = function() {
                    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
                        args[_key] = arguments[_key];
                    }
                    DOMReady(methods[key], args);
                };
            }
            DOMReady(() => {
                window.addEventListener("resize", event => {
                    Coloris.updatePosition();
                });
                window.addEventListener("scroll", event => {
                    Coloris.updatePosition();
                });
            });
            return Coloris;
        })();
        Coloris.coloris = Coloris;
        return Coloris;
    })(window, document, Math))();
    Coloris$1.coloris;
    Coloris$1.init;
    Coloris$1.set;
    Coloris$1.wrap;
    Coloris$1.close;
    Coloris$1.setInstance;
    Coloris$1.removeInstance;
    Coloris$1.updatePosition;
    var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
    function getDefaultExportFromCjs(x) {
        return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
    }
    var croppie = {
        exports: {}
    };
    (function(module, exports$1) {
        (function(root, factory) {
            if (typeof exports$1.nodeName !== "string") {
                module.exports = factory();
            } else {
                root.Croppie = factory();
            }
        })(typeof self !== "undefined" ? self : commonjsGlobal, function() {
            if (typeof Promise !== "function") {
                !function(a) {
                    function b(a, b) {
                        return function() {
                            a.apply(b, arguments);
                        };
                    }
                    function c(a) {
                        if ("object" !== typeof this) throw new TypeError("Promises must be constructed via new");
                        if ("function" !== typeof a) throw new TypeError("not a function");
                        this._state = null, this._value = null, this._deferreds = [], i(a, b(e, this), b(f, this));
                    }
                    function d(a) {
                        var b = this;
                        return null === this._state ? void this._deferreds.push(a) : void k(function() {
                            var c = b._state ? a.onFulfilled : a.onRejected;
                            if (null === c) return void (b._state ? a.resolve : a.reject)(b._value);
                            var d;
                            try {
                                d = c(b._value);
                            } catch (e) {
                                return void a.reject(e);
                            }
                            a.resolve(d);
                        });
                    }
                    function e(a) {
                        try {
                            if (a === this) throw new TypeError("A promise cannot be resolved with itself.");
                            if (a && ("object" === typeof a || "function" === typeof a)) {
                                var c = a.then;
                                if ("function" === typeof c) return void i(b(c, a), b(e, this), b(f, this));
                            }
                            this._state = !0, this._value = a, g.call(this);
                        } catch (d) {
                            f.call(this, d);
                        }
                    }
                    function f(a) {
                        this._state = false, this._value = a, g.call(this);
                    }
                    function g() {
                        for (var a = 0, b = this._deferreds.length; b > a; a++) d.call(this, this._deferreds[a]);
                        this._deferreds = null;
                    }
                    function h(a, b, c, d) {
                        this.onFulfilled = "function" === typeof a ? a : null, this.onRejected = "function" === typeof b ? b : null, 
                        this.resolve = c, this.reject = d;
                    }
                    function i(a, b, c) {
                        var d = false;
                        try {
                            a(function(a) {
                                d || (d = !0, b(a));
                            }, function(a) {
                                d || (d = !0, c(a));
                            });
                        } catch (e) {
                            if (d) return;
                            d = true, c(e);
                        }
                    }
                    var j = setTimeout, k = "function" === typeof setImmediate && setImmediate || function(a) {
                        j(a, 1);
                    }, l = Array.isArray || function(a) {
                        return "[object Array]" === Object.prototype.toString.call(a);
                    };
                    c.prototype["catch"] = function(a) {
                        return this.then(null, a);
                    }, c.prototype.then = function(a, b) {
                        var e = this;
                        return new c(function(c, f) {
                            d.call(e, new h(a, b, c, f));
                        });
                    }, c.all = function() {
                        var a = Array.prototype.slice.call(1 === arguments.length && l(arguments[0]) ? arguments[0] : arguments);
                        return new c(function(b, c) {
                            function d(f, g) {
                                try {
                                    if (g && ("object" === typeof g || "function" === typeof g)) {
                                        var h = g.then;
                                        if ("function" === typeof h) return void h.call(g, function(a) {
                                            d(f, a);
                                        }, c);
                                    }
                                    a[f] = g, 0 === --e && b(a);
                                } catch (i) {
                                    c(i);
                                }
                            }
                            if (0 === a.length) return b([]);
                            for (var e = a.length, f = 0; f < a.length; f++) d(f, a[f]);
                        });
                    }, c.resolve = function(a) {
                        return a && "object" === typeof a && a.constructor === c ? a : new c(function(b) {
                            b(a);
                        });
                    }, c.reject = function(a) {
                        return new c(function(b, c) {
                            c(a);
                        });
                    }, c.race = function(a) {
                        return new c(function(b, c) {
                            for (var d = 0, e = a.length; e > d; d++) a[d].then(b, c);
                        });
                    }, c._setImmediateFn = function(a) {
                        k = a;
                    }, module.exports ? module.exports = c : a.Promise || (a.Promise = c);
                }(this);
            }
            if (typeof window !== "undefined" && typeof window.CustomEvent !== "function") {
                (function() {
                    function CustomEvent(event, params) {
                        params = params || {
                            bubbles: false,
                            cancelable: false,
                            detail: undefined
                        };
                        var evt = document.createEvent("CustomEvent");
                        evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
                        return evt;
                    }
                    CustomEvent.prototype = window.Event.prototype;
                    window.CustomEvent = CustomEvent;
                })();
            }
            if (typeof HTMLCanvasElement !== "undefined" && !HTMLCanvasElement.prototype.toBlob) {
                Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", {
                    value: function(callback, type, quality) {
                        var binStr = atob(this.toDataURL(type, quality).split(",")[1]), len = binStr.length, arr = new Uint8Array(len);
                        for (var i = 0; i < len; i++) {
                            arr[i] = binStr.charCodeAt(i);
                        }
                        callback(new Blob([ arr ], {
                            type: type || "image/png"
                        }));
                    }
                });
            }
            var cssPrefixes = [ "Webkit", "Moz", "ms" ], emptyStyles = typeof document !== "undefined" ? document.createElement("div").style : {}, EXIF_NORM = [ 1, 8, 3, 6 ], EXIF_FLIP = [ 2, 7, 4, 5 ], CSS_TRANS_ORG, CSS_TRANSFORM, CSS_USERSELECT;
            function vendorPrefix(prop) {
                if (prop in emptyStyles) {
                    return prop;
                }
                var capProp = prop[0].toUpperCase() + prop.slice(1), i = cssPrefixes.length;
                while (i--) {
                    prop = cssPrefixes[i] + capProp;
                    if (prop in emptyStyles) {
                        return prop;
                    }
                }
            }
            CSS_TRANSFORM = vendorPrefix("transform");
            CSS_TRANS_ORG = vendorPrefix("transformOrigin");
            CSS_USERSELECT = vendorPrefix("userSelect");
            function getExifOffset(ornt, rotate) {
                var arr = EXIF_NORM.indexOf(ornt) > -1 ? EXIF_NORM : EXIF_FLIP, index = arr.indexOf(ornt), offset = rotate / 90 % arr.length;
                return arr[(arr.length + index + offset % arr.length) % arr.length];
            }
            function deepExtend(destination, source) {
                destination = destination || {};
                for (var property in source) {
                    if (source[property] && source[property].constructor && source[property].constructor === Object) {
                        destination[property] = destination[property] || {};
                        deepExtend(destination[property], source[property]);
                    } else {
                        destination[property] = source[property];
                    }
                }
                return destination;
            }
            function clone(object) {
                return deepExtend({}, object);
            }
            function debounce(func, wait, immediate) {
                var timeout;
                return function() {
                    var context = this, args = arguments;
                    var later = function() {
                        timeout = null;
                        func.apply(context, args);
                    };
                    clearTimeout(timeout);
                    timeout = setTimeout(later, wait);
                };
            }
            function dispatchChange(element) {
                if ("createEvent" in document) {
                    var evt = document.createEvent("HTMLEvents");
                    evt.initEvent("change", false, true);
                    element.dispatchEvent(evt);
                } else {
                    element.fireEvent("onchange");
                }
            }
            function css(el, styles, val) {
                if (typeof styles === "string") {
                    var tmp = styles;
                    styles = {};
                    styles[tmp] = val;
                }
                for (var prop in styles) {
                    el.style[prop] = styles[prop];
                }
            }
            function addClass(el, c) {
                if (el.classList) {
                    el.classList.add(c);
                } else {
                    el.className += " " + c;
                }
            }
            function removeClass(el, c) {
                if (el.classList) {
                    el.classList.remove(c);
                } else {
                    el.className = el.className.replace(c, "");
                }
            }
            function setAttributes(el, attrs) {
                for (var key in attrs) {
                    el.setAttribute(key, attrs[key]);
                }
            }
            function num(v) {
                return parseInt(v, 10);
            }
            function loadImage(src, doExif) {
                if (!src) {
                    throw "Source image missing";
                }
                var img = new Image;
                img.style.opacity = "0";
                return new Promise(function(resolve, reject) {
                    function _resolve() {
                        img.style.opacity = "1";
                        setTimeout(function() {
                            resolve(img);
                        }, 1);
                    }
                    img.removeAttribute("crossOrigin");
                    if (src.match(/^https?:\/\/|^\/\//)) {
                        img.setAttribute("crossOrigin", "anonymous");
                    }
                    img.onload = function() {
                        if (doExif) {
                            EXIF.getData(img, function() {
                                _resolve();
                            });
                        } else {
                            _resolve();
                        }
                    };
                    img.onerror = function(ev) {
                        img.style.opacity = 1;
                        setTimeout(function() {
                            reject(ev);
                        }, 1);
                    };
                    img.src = src;
                });
            }
            function naturalImageDimensions(img, ornt) {
                var w = img.naturalWidth;
                var h = img.naturalHeight;
                var orient = ornt || getExifOrientation(img);
                if (orient && orient >= 5) {
                    var x = w;
                    w = h;
                    h = x;
                }
                return {
                    width: w,
                    height: h
                };
            }
            var TRANSLATE_OPTS = {
                translate3d: {
                    suffix: ", 0px"
                },
                translate: {
                    suffix: ""
                }
            };
            var Transform = function(x, y, scale) {
                this.x = parseFloat(x);
                this.y = parseFloat(y);
                this.scale = parseFloat(scale);
            };
            Transform.parse = function(v) {
                if (v.style) {
                    return Transform.parse(v.style[CSS_TRANSFORM]);
                } else if (v.indexOf("matrix") > -1 || v.indexOf("none") > -1) {
                    return Transform.fromMatrix(v);
                } else {
                    return Transform.fromString(v);
                }
            };
            Transform.fromMatrix = function(v) {
                var vals = v.substring(7).split(",");
                if (!vals.length || v === "none") {
                    vals = [ 1, 0, 0, 1, 0, 0 ];
                }
                return new Transform(num(vals[4]), num(vals[5]), parseFloat(vals[0]));
            };
            Transform.fromString = function(v) {
                var values = v.split(") "), translate = values[0].substring(Croppie.globals.translate.length + 1).split(","), scale = values.length > 1 ? values[1].substring(6) : 1, x = translate.length > 1 ? translate[0] : 0, y = translate.length > 1 ? translate[1] : 0;
                return new Transform(x, y, scale);
            };
            Transform.prototype.toString = function() {
                var suffix = TRANSLATE_OPTS[Croppie.globals.translate].suffix || "";
                return Croppie.globals.translate + "(" + this.x + "px, " + this.y + "px" + suffix + ") scale(" + this.scale + ")";
            };
            var TransformOrigin = function(el) {
                if (!el || !el.style[CSS_TRANS_ORG]) {
                    this.x = 0;
                    this.y = 0;
                    return;
                }
                var css = el.style[CSS_TRANS_ORG].split(" ");
                this.x = parseFloat(css[0]);
                this.y = parseFloat(css[1]);
            };
            TransformOrigin.prototype.toString = function() {
                return this.x + "px " + this.y + "px";
            };
            function getExifOrientation(img) {
                return img.exifdata && img.exifdata.Orientation ? num(img.exifdata.Orientation) : 1;
            }
            function drawCanvas(canvas, img, orientation) {
                var width = img.width, height = img.height, ctx = canvas.getContext("2d");
                canvas.width = img.width;
                canvas.height = img.height;
                ctx.save();
                switch (orientation) {
                  case 2:
                    ctx.translate(width, 0);
                    ctx.scale(-1, 1);
                    break;

                  case 3:
                    ctx.translate(width, height);
                    ctx.rotate(180 * Math.PI / 180);
                    break;

                  case 4:
                    ctx.translate(0, height);
                    ctx.scale(1, -1);
                    break;

                  case 5:
                    canvas.width = height;
                    canvas.height = width;
                    ctx.rotate(90 * Math.PI / 180);
                    ctx.scale(1, -1);
                    break;

                  case 6:
                    canvas.width = height;
                    canvas.height = width;
                    ctx.rotate(90 * Math.PI / 180);
                    ctx.translate(0, -height);
                    break;

                  case 7:
                    canvas.width = height;
                    canvas.height = width;
                    ctx.rotate(-90 * Math.PI / 180);
                    ctx.translate(-width, height);
                    ctx.scale(1, -1);
                    break;

                  case 8:
                    canvas.width = height;
                    canvas.height = width;
                    ctx.translate(0, width);
                    ctx.rotate(-90 * Math.PI / 180);
                    break;
                }
                ctx.drawImage(img, 0, 0, width, height);
                ctx.restore();
            }
            function _create() {
                var self = this, contClass = "croppie-container", customViewportClass = self.options.viewport.type ? "cr-vp-" + self.options.viewport.type : null, boundary, img, viewport, overlay, bw, bh;
                self.options.useCanvas = self.options.enableOrientation || _hasExif.call(self);
                self.data = {};
                self.elements = {};
                boundary = self.elements.boundary = document.createElement("div");
                viewport = self.elements.viewport = document.createElement("div");
                img = self.elements.img = document.createElement("img");
                overlay = self.elements.overlay = document.createElement("div");
                if (self.options.useCanvas) {
                    self.elements.canvas = document.createElement("canvas");
                    self.elements.preview = self.elements.canvas;
                } else {
                    self.elements.preview = img;
                }
                addClass(boundary, "cr-boundary");
                boundary.setAttribute("aria-dropeffect", "none");
                bw = self.options.boundary.width;
                bh = self.options.boundary.height;
                css(boundary, {
                    width: bw + (isNaN(bw) ? "" : "px"),
                    height: bh + (isNaN(bh) ? "" : "px")
                });
                addClass(viewport, "cr-viewport");
                if (customViewportClass) {
                    addClass(viewport, customViewportClass);
                }
                css(viewport, {
                    width: self.options.viewport.width + "px",
                    height: self.options.viewport.height + "px"
                });
                viewport.setAttribute("tabindex", 0);
                addClass(self.elements.preview, "cr-image");
                setAttributes(self.elements.preview, {
                    alt: "preview",
                    "aria-grabbed": "false"
                });
                addClass(overlay, "cr-overlay");
                self.element.appendChild(boundary);
                boundary.appendChild(self.elements.preview);
                boundary.appendChild(viewport);
                boundary.appendChild(overlay);
                addClass(self.element, contClass);
                if (self.options.customClass) {
                    addClass(self.element, self.options.customClass);
                }
                _initDraggable.call(this);
                if (self.options.enableZoom) {
                    _initializeZoom.call(self);
                }
                if (self.options.enableResize) {
                    _initializeResize.call(self);
                }
            }
            function _hasExif() {
                return this.options.enableExif && window.EXIF;
            }
            function _initializeResize() {
                var self = this;
                var wrap = document.createElement("div");
                var isDragging = false;
                var direction;
                var originalX;
                var originalY;
                var minSize = 50;
                var maxWidth;
                var maxHeight;
                var vr;
                var hr;
                addClass(wrap, "cr-resizer");
                css(wrap, {
                    width: this.options.viewport.width + "px",
                    height: this.options.viewport.height + "px"
                });
                if (this.options.resizeControls.height) {
                    vr = document.createElement("div");
                    addClass(vr, "cr-resizer-vertical");
                    wrap.appendChild(vr);
                }
                if (this.options.resizeControls.width) {
                    hr = document.createElement("div");
                    addClass(hr, "cr-resizer-horisontal");
                    wrap.appendChild(hr);
                }
                function mouseDown(ev) {
                    if (ev.button !== undefined && ev.button !== 0) return;
                    ev.preventDefault();
                    if (isDragging) {
                        return;
                    }
                    var overlayRect = self.elements.overlay.getBoundingClientRect();
                    isDragging = true;
                    originalX = ev.pageX;
                    originalY = ev.pageY;
                    direction = ev.currentTarget.className.indexOf("vertical") !== -1 ? "v" : "h";
                    maxWidth = overlayRect.width;
                    maxHeight = overlayRect.height;
                    if (ev.touches) {
                        var touches = ev.touches[0];
                        originalX = touches.pageX;
                        originalY = touches.pageY;
                    }
                    window.addEventListener("mousemove", mouseMove);
                    window.addEventListener("touchmove", mouseMove);
                    window.addEventListener("mouseup", mouseUp);
                    window.addEventListener("touchend", mouseUp);
                    document.body.style[CSS_USERSELECT] = "none";
                }
                function mouseMove(ev) {
                    var pageX = ev.pageX;
                    var pageY = ev.pageY;
                    ev.preventDefault();
                    if (ev.touches) {
                        var touches = ev.touches[0];
                        pageX = touches.pageX;
                        pageY = touches.pageY;
                    }
                    var deltaX = pageX - originalX;
                    var deltaY = pageY - originalY;
                    var newHeight = self.options.viewport.height + deltaY;
                    var newWidth = self.options.viewport.width + deltaX;
                    if (direction === "v" && newHeight >= minSize && newHeight <= maxHeight) {
                        css(wrap, {
                            height: newHeight + "px"
                        });
                        self.options.boundary.height += deltaY;
                        css(self.elements.boundary, {
                            height: self.options.boundary.height + "px"
                        });
                        self.options.viewport.height += deltaY;
                        css(self.elements.viewport, {
                            height: self.options.viewport.height + "px"
                        });
                    } else if (direction === "h" && newWidth >= minSize && newWidth <= maxWidth) {
                        css(wrap, {
                            width: newWidth + "px"
                        });
                        self.options.boundary.width += deltaX;
                        css(self.elements.boundary, {
                            width: self.options.boundary.width + "px"
                        });
                        self.options.viewport.width += deltaX;
                        css(self.elements.viewport, {
                            width: self.options.viewport.width + "px"
                        });
                    }
                    _updateOverlay.call(self);
                    _updateZoomLimits.call(self);
                    _updateCenterPoint.call(self);
                    _triggerUpdate.call(self);
                    originalY = pageY;
                    originalX = pageX;
                }
                function mouseUp() {
                    isDragging = false;
                    window.removeEventListener("mousemove", mouseMove);
                    window.removeEventListener("touchmove", mouseMove);
                    window.removeEventListener("mouseup", mouseUp);
                    window.removeEventListener("touchend", mouseUp);
                    document.body.style[CSS_USERSELECT] = "";
                }
                if (vr) {
                    vr.addEventListener("mousedown", mouseDown);
                    vr.addEventListener("touchstart", mouseDown);
                }
                if (hr) {
                    hr.addEventListener("mousedown", mouseDown);
                    hr.addEventListener("touchstart", mouseDown);
                }
                this.elements.boundary.appendChild(wrap);
            }
            function _setZoomerVal(v) {
                if (this.options.enableZoom) {
                    var z = this.elements.zoomer, val = fix(v, 4);
                    z.value = Math.max(parseFloat(z.min), Math.min(parseFloat(z.max), val)).toString();
                }
            }
            function _initializeZoom() {
                var self = this, wrap = self.elements.zoomerWrap = document.createElement("div"), zoomer = self.elements.zoomer = document.createElement("input");
                addClass(wrap, "cr-slider-wrap");
                addClass(zoomer, "cr-slider");
                zoomer.type = "range";
                zoomer.step = "0.0001";
                zoomer.value = "1";
                zoomer.style.display = self.options.showZoomer ? "" : "none";
                zoomer.setAttribute("aria-label", "zoom");
                self.element.appendChild(wrap);
                wrap.appendChild(zoomer);
                self._currentZoom = 1;
                function change() {
                    _onZoom.call(self, {
                        value: parseFloat(zoomer.value),
                        origin: new TransformOrigin(self.elements.preview),
                        viewportRect: self.elements.viewport.getBoundingClientRect(),
                        transform: Transform.parse(self.elements.preview)
                    });
                }
                function scroll(ev) {
                    var delta, targetZoom;
                    if (self.options.mouseWheelZoom === "ctrl" && ev.ctrlKey !== true) {
                        return 0;
                    } else if (ev.wheelDelta) {
                        delta = ev.wheelDelta / 1200;
                    } else if (ev.deltaY) {
                        delta = ev.deltaY / 1060;
                    } else if (ev.detail) {
                        delta = ev.detail / -60;
                    } else {
                        delta = 0;
                    }
                    targetZoom = self._currentZoom + delta * self._currentZoom;
                    ev.preventDefault();
                    _setZoomerVal.call(self, targetZoom);
                    change.call(self);
                }
                self.elements.zoomer.addEventListener("input", change);
                self.elements.zoomer.addEventListener("change", change);
                if (self.options.mouseWheelZoom) {
                    self.elements.boundary.addEventListener("mousewheel", scroll);
                    self.elements.boundary.addEventListener("DOMMouseScroll", scroll);
                }
            }
            function _onZoom(ui) {
                var self = this, transform = ui ? ui.transform : Transform.parse(self.elements.preview), vpRect = ui ? ui.viewportRect : self.elements.viewport.getBoundingClientRect(), origin = ui ? ui.origin : new TransformOrigin(self.elements.preview);
                function applyCss() {
                    var transCss = {};
                    transCss[CSS_TRANSFORM] = transform.toString();
                    transCss[CSS_TRANS_ORG] = origin.toString();
                    css(self.elements.preview, transCss);
                }
                self._currentZoom = ui ? ui.value : self._currentZoom;
                transform.scale = self._currentZoom;
                self.elements.zoomer.setAttribute("aria-valuenow", self._currentZoom);
                applyCss();
                if (self.options.enforceBoundary) {
                    var boundaries = _getVirtualBoundaries.call(self, vpRect), transBoundaries = boundaries.translate, oBoundaries = boundaries.origin;
                    if (transform.x >= transBoundaries.maxX) {
                        origin.x = oBoundaries.minX;
                        transform.x = transBoundaries.maxX;
                    }
                    if (transform.x <= transBoundaries.minX) {
                        origin.x = oBoundaries.maxX;
                        transform.x = transBoundaries.minX;
                    }
                    if (transform.y >= transBoundaries.maxY) {
                        origin.y = oBoundaries.minY;
                        transform.y = transBoundaries.maxY;
                    }
                    if (transform.y <= transBoundaries.minY) {
                        origin.y = oBoundaries.maxY;
                        transform.y = transBoundaries.minY;
                    }
                }
                applyCss();
                _debouncedOverlay.call(self);
                _triggerUpdate.call(self);
            }
            function _getVirtualBoundaries(viewport) {
                var self = this, scale = self._currentZoom, vpWidth = viewport.width, vpHeight = viewport.height, centerFromBoundaryX = self.elements.boundary.clientWidth / 2, centerFromBoundaryY = self.elements.boundary.clientHeight / 2, imgRect = self.elements.preview.getBoundingClientRect(), curImgWidth = imgRect.width, curImgHeight = imgRect.height, halfWidth = vpWidth / 2, halfHeight = vpHeight / 2;
                var maxX = (halfWidth / scale - centerFromBoundaryX) * -1;
                var minX = maxX - (curImgWidth * (1 / scale) - vpWidth * (1 / scale));
                var maxY = (halfHeight / scale - centerFromBoundaryY) * -1;
                var minY = maxY - (curImgHeight * (1 / scale) - vpHeight * (1 / scale));
                var originMinX = 1 / scale * halfWidth;
                var originMaxX = curImgWidth * (1 / scale) - originMinX;
                var originMinY = 1 / scale * halfHeight;
                var originMaxY = curImgHeight * (1 / scale) - originMinY;
                return {
                    translate: {
                        maxX: maxX,
                        minX: minX,
                        maxY: maxY,
                        minY: minY
                    },
                    origin: {
                        maxX: originMaxX,
                        minX: originMinX,
                        maxY: originMaxY,
                        minY: originMinY
                    }
                };
            }
            function _updateCenterPoint(rotate) {
                var self = this, scale = self._currentZoom, data = self.elements.preview.getBoundingClientRect(), vpData = self.elements.viewport.getBoundingClientRect(), transform = Transform.parse(self.elements.preview.style[CSS_TRANSFORM]), pc = new TransformOrigin(self.elements.preview), top = vpData.top - data.top + vpData.height / 2, left = vpData.left - data.left + vpData.width / 2, center = {}, adj = {};
                if (rotate) {
                    var cx = pc.x;
                    var cy = pc.y;
                    var tx = transform.x;
                    var ty = transform.y;
                    center.y = cx;
                    center.x = cy;
                    transform.y = tx;
                    transform.x = ty;
                } else {
                    center.y = top / scale;
                    center.x = left / scale;
                    adj.y = (center.y - pc.y) * (1 - scale);
                    adj.x = (center.x - pc.x) * (1 - scale);
                    transform.x -= adj.x;
                    transform.y -= adj.y;
                }
                var newCss = {};
                newCss[CSS_TRANS_ORG] = center.x + "px " + center.y + "px";
                newCss[CSS_TRANSFORM] = transform.toString();
                css(self.elements.preview, newCss);
            }
            function _initDraggable() {
                var self = this, isDragging = false, originalX, originalY, originalDistance, vpRect, transform;
                function assignTransformCoordinates(deltaX, deltaY) {
                    var imgRect = self.elements.preview.getBoundingClientRect(), top = transform.y + deltaY, left = transform.x + deltaX;
                    if (self.options.enforceBoundary) {
                        if (vpRect.top > imgRect.top + deltaY && vpRect.bottom < imgRect.bottom + deltaY) {
                            transform.y = top;
                        }
                        if (vpRect.left > imgRect.left + deltaX && vpRect.right < imgRect.right + deltaX) {
                            transform.x = left;
                        }
                    } else {
                        transform.y = top;
                        transform.x = left;
                    }
                }
                function toggleGrabState(isDragging) {
                    self.elements.preview.setAttribute("aria-grabbed", isDragging);
                    self.elements.boundary.setAttribute("aria-dropeffect", isDragging ? "move" : "none");
                }
                function keyDown(ev) {
                    var LEFT_ARROW = 37, UP_ARROW = 38, RIGHT_ARROW = 39, DOWN_ARROW = 40;
                    if (ev.shiftKey && (ev.keyCode === UP_ARROW || ev.keyCode === DOWN_ARROW)) {
                        var zoom;
                        if (ev.keyCode === UP_ARROW) {
                            zoom = parseFloat(self.elements.zoomer.value) + parseFloat(self.elements.zoomer.step);
                        } else {
                            zoom = parseFloat(self.elements.zoomer.value) - parseFloat(self.elements.zoomer.step);
                        }
                        self.setZoom(zoom);
                    } else if (self.options.enableKeyMovement && (ev.keyCode >= 37 && ev.keyCode <= 40)) {
                        ev.preventDefault();
                        var movement = parseKeyDown(ev.keyCode);
                        transform = Transform.parse(self.elements.preview);
                        document.body.style[CSS_USERSELECT] = "none";
                        vpRect = self.elements.viewport.getBoundingClientRect();
                        keyMove(movement);
                    }
                    function parseKeyDown(key) {
                        switch (key) {
                          case LEFT_ARROW:
                            return [ 1, 0 ];

                          case UP_ARROW:
                            return [ 0, 1 ];

                          case RIGHT_ARROW:
                            return [ -1, 0 ];

                          case DOWN_ARROW:
                            return [ 0, -1 ];
                        }
                    }
                }
                function keyMove(movement) {
                    var deltaX = movement[0], deltaY = movement[1], newCss = {};
                    assignTransformCoordinates(deltaX, deltaY);
                    newCss[CSS_TRANSFORM] = transform.toString();
                    css(self.elements.preview, newCss);
                    _updateOverlay.call(self);
                    document.body.style[CSS_USERSELECT] = "";
                    _updateCenterPoint.call(self);
                    _triggerUpdate.call(self);
                    originalDistance = 0;
                }
                function mouseDown(ev) {
                    if (ev.button !== undefined && ev.button !== 0) return;
                    ev.preventDefault();
                    if (isDragging) return;
                    isDragging = true;
                    originalX = ev.pageX;
                    originalY = ev.pageY;
                    if (ev.touches) {
                        var touches = ev.touches[0];
                        originalX = touches.pageX;
                        originalY = touches.pageY;
                    }
                    toggleGrabState(isDragging);
                    transform = Transform.parse(self.elements.preview);
                    window.addEventListener("mousemove", mouseMove);
                    window.addEventListener("touchmove", mouseMove);
                    window.addEventListener("mouseup", mouseUp);
                    window.addEventListener("touchend", mouseUp);
                    document.body.style[CSS_USERSELECT] = "none";
                    vpRect = self.elements.viewport.getBoundingClientRect();
                }
                function mouseMove(ev) {
                    ev.preventDefault();
                    var pageX = ev.pageX, pageY = ev.pageY;
                    if (ev.touches) {
                        var touches = ev.touches[0];
                        pageX = touches.pageX;
                        pageY = touches.pageY;
                    }
                    var deltaX = pageX - originalX, deltaY = pageY - originalY, newCss = {};
                    if (ev.type === "touchmove") {
                        if (ev.touches.length > 1) {
                            var touch1 = ev.touches[0];
                            var touch2 = ev.touches[1];
                            var dist = Math.sqrt((touch1.pageX - touch2.pageX) * (touch1.pageX - touch2.pageX) + (touch1.pageY - touch2.pageY) * (touch1.pageY - touch2.pageY));
                            if (!originalDistance) {
                                originalDistance = dist / self._currentZoom;
                            }
                            var scale = dist / originalDistance;
                            _setZoomerVal.call(self, scale);
                            dispatchChange(self.elements.zoomer);
                            return;
                        }
                    }
                    assignTransformCoordinates(deltaX, deltaY);
                    newCss[CSS_TRANSFORM] = transform.toString();
                    css(self.elements.preview, newCss);
                    _updateOverlay.call(self);
                    originalY = pageY;
                    originalX = pageX;
                }
                function mouseUp() {
                    isDragging = false;
                    toggleGrabState(isDragging);
                    window.removeEventListener("mousemove", mouseMove);
                    window.removeEventListener("touchmove", mouseMove);
                    window.removeEventListener("mouseup", mouseUp);
                    window.removeEventListener("touchend", mouseUp);
                    document.body.style[CSS_USERSELECT] = "";
                    _updateCenterPoint.call(self);
                    _triggerUpdate.call(self);
                    originalDistance = 0;
                }
                self.elements.overlay.addEventListener("mousedown", mouseDown);
                self.elements.viewport.addEventListener("keydown", keyDown);
                self.elements.overlay.addEventListener("touchstart", mouseDown);
            }
            function _updateOverlay() {
                if (!this.elements) return;
                var self = this, boundRect = self.elements.boundary.getBoundingClientRect(), imgData = self.elements.preview.getBoundingClientRect();
                css(self.elements.overlay, {
                    width: imgData.width + "px",
                    height: imgData.height + "px",
                    top: imgData.top - boundRect.top + "px",
                    left: imgData.left - boundRect.left + "px"
                });
            }
            var _debouncedOverlay = debounce(_updateOverlay, 500);
            function _triggerUpdate() {
                var self = this, data = self.get();
                if (!_isVisible.call(self)) {
                    return;
                }
                self.options.update.call(self, data);
                if (self.$ && typeof Prototype === "undefined") {
                    self.$(self.element).trigger("update.croppie", data);
                } else {
                    var ev;
                    if (window.CustomEvent) {
                        ev = new CustomEvent("update", {
                            detail: data
                        });
                    } else {
                        ev = document.createEvent("CustomEvent");
                        ev.initCustomEvent("update", true, true, data);
                    }
                    self.element.dispatchEvent(ev);
                }
            }
            function _isVisible() {
                return this.elements.preview.offsetHeight > 0 && this.elements.preview.offsetWidth > 0;
            }
            function _updatePropertiesFromImage() {
                var self = this, initialZoom = 1, cssReset = {}, img = self.elements.preview, imgData, transformReset = new Transform(0, 0, initialZoom), originReset = new TransformOrigin, isVisible = _isVisible.call(self);
                if (!isVisible || self.data.bound) {
                    return;
                }
                self.data.bound = true;
                cssReset[CSS_TRANSFORM] = transformReset.toString();
                cssReset[CSS_TRANS_ORG] = originReset.toString();
                cssReset["opacity"] = 1;
                css(img, cssReset);
                imgData = self.elements.preview.getBoundingClientRect();
                self._originalImageWidth = imgData.width;
                self._originalImageHeight = imgData.height;
                self.data.orientation = _hasExif.call(self) ? getExifOrientation(self.elements.img) : self.data.orientation;
                if (self.options.enableZoom) {
                    _updateZoomLimits.call(self, true);
                } else {
                    self._currentZoom = initialZoom;
                }
                transformReset.scale = self._currentZoom;
                cssReset[CSS_TRANSFORM] = transformReset.toString();
                css(img, cssReset);
                if (self.data.points.length) {
                    _bindPoints.call(self, self.data.points);
                } else {
                    _centerImage.call(self);
                }
                _updateCenterPoint.call(self);
                _updateOverlay.call(self);
            }
            function _updateZoomLimits(initial) {
                var self = this, minZoom = Math.max(self.options.minZoom, 0) || 0, maxZoom = self.options.maxZoom || 1.5, initialZoom, defaultInitialZoom, zoomer = self.elements.zoomer, scale = parseFloat(zoomer.value), boundaryData = self.elements.boundary.getBoundingClientRect(), imgData = naturalImageDimensions(self.elements.img, self.data.orientation), vpData = self.elements.viewport.getBoundingClientRect(), minW, minH;
                if (self.options.enforceBoundary) {
                    minW = vpData.width / imgData.width;
                    minH = vpData.height / imgData.height;
                    minZoom = Math.max(minW, minH);
                }
                if (minZoom >= maxZoom) {
                    maxZoom = minZoom + 1;
                }
                zoomer.min = fix(minZoom, 4);
                zoomer.max = fix(maxZoom, 4);
                if (!initial && (scale < zoomer.min || scale > zoomer.max)) {
                    _setZoomerVal.call(self, scale < zoomer.min ? zoomer.min : zoomer.max);
                } else if (initial) {
                    defaultInitialZoom = Math.max(boundaryData.width / imgData.width, boundaryData.height / imgData.height);
                    initialZoom = self.data.boundZoom !== null ? self.data.boundZoom : defaultInitialZoom;
                    _setZoomerVal.call(self, initialZoom);
                }
                dispatchChange(zoomer);
            }
            function _bindPoints(points) {
                if (points.length !== 4) {
                    throw "Croppie - Invalid number of points supplied: " + points;
                }
                var self = this, pointsWidth = points[2] - points[0], vpData = self.elements.viewport.getBoundingClientRect(), boundRect = self.elements.boundary.getBoundingClientRect(), vpOffset = {
                    left: vpData.left - boundRect.left,
                    top: vpData.top - boundRect.top
                }, scale = vpData.width / pointsWidth, originTop = points[1], originLeft = points[0], transformTop = -1 * points[1] + vpOffset.top, transformLeft = -1 * points[0] + vpOffset.left, newCss = {};
                newCss[CSS_TRANS_ORG] = originLeft + "px " + originTop + "px";
                newCss[CSS_TRANSFORM] = new Transform(transformLeft, transformTop, scale).toString();
                css(self.elements.preview, newCss);
                _setZoomerVal.call(self, scale);
                self._currentZoom = scale;
            }
            function _centerImage() {
                var self = this, imgDim = self.elements.preview.getBoundingClientRect(), vpDim = self.elements.viewport.getBoundingClientRect(), boundDim = self.elements.boundary.getBoundingClientRect(), vpLeft = vpDim.left - boundDim.left, vpTop = vpDim.top - boundDim.top, w = vpLeft - (imgDim.width - vpDim.width) / 2, h = vpTop - (imgDim.height - vpDim.height) / 2, transform = new Transform(w, h, self._currentZoom);
                css(self.elements.preview, CSS_TRANSFORM, transform.toString());
            }
            function _transferImageToCanvas(customOrientation) {
                var self = this, canvas = self.elements.canvas, img = self.elements.img, ctx = canvas.getContext("2d");
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                canvas.width = img.width;
                canvas.height = img.height;
                var orientation = self.options.enableOrientation && customOrientation || getExifOrientation(img);
                drawCanvas(canvas, img, orientation);
            }
            function _getCanvas(data) {
                var self = this, points = data.points, left = num(points[0]), top = num(points[1]), right = num(points[2]), bottom = num(points[3]), width = right - left, height = bottom - top, circle = data.circle, canvas = document.createElement("canvas"), ctx = canvas.getContext("2d"), canvasWidth = data.outputWidth || width, canvasHeight = data.outputHeight || height;
                canvas.width = canvasWidth;
                canvas.height = canvasHeight;
                if (data.backgroundColor) {
                    ctx.fillStyle = data.backgroundColor;
                    ctx.fillRect(0, 0, canvasWidth, canvasHeight);
                }
                var sx = left, sy = top, sWidth = width, sHeight = height, dx = 0, dy = 0, dWidth = canvasWidth, dHeight = canvasHeight;
                if (left < 0) {
                    sx = 0;
                    dx = Math.abs(left) / width * canvasWidth;
                }
                if (sWidth + sx > self._originalImageWidth) {
                    sWidth = self._originalImageWidth - sx;
                    dWidth = sWidth / width * canvasWidth;
                }
                if (top < 0) {
                    sy = 0;
                    dy = Math.abs(top) / height * canvasHeight;
                }
                if (sHeight + sy > self._originalImageHeight) {
                    sHeight = self._originalImageHeight - sy;
                    dHeight = sHeight / height * canvasHeight;
                }
                ctx.drawImage(this.elements.preview, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
                if (circle) {
                    ctx.fillStyle = "#fff";
                    ctx.globalCompositeOperation = "destination-in";
                    ctx.beginPath();
                    ctx.arc(canvas.width / 2, canvas.height / 2, canvas.width / 2, 0, Math.PI * 2, true);
                    ctx.closePath();
                    ctx.fill();
                }
                return canvas;
            }
            function _getHtmlResult(data) {
                var points = data.points, div = document.createElement("div"), img = document.createElement("img"), width = points[2] - points[0], height = points[3] - points[1];
                addClass(div, "croppie-result");
                div.appendChild(img);
                css(img, {
                    left: -1 * points[0] + "px",
                    top: -1 * points[1] + "px"
                });
                img.src = data.url;
                css(div, {
                    width: width + "px",
                    height: height + "px"
                });
                return div;
            }
            function _getBase64Result(data) {
                return _getCanvas.call(this, data).toDataURL(data.format, data.quality);
            }
            function _getBlobResult(data) {
                var self = this;
                return new Promise(function(resolve) {
                    _getCanvas.call(self, data).toBlob(function(blob) {
                        resolve(blob);
                    }, data.format, data.quality);
                });
            }
            function _replaceImage(img) {
                if (this.elements.img.parentNode) {
                    Array.prototype.forEach.call(this.elements.img.classList, function(c) {
                        img.classList.add(c);
                    });
                    this.elements.img.parentNode.replaceChild(img, this.elements.img);
                    this.elements.preview = img;
                }
                this.elements.img = img;
            }
            function _bind(options, cb) {
                var self = this, url, points = [], zoom = null, hasExif = _hasExif.call(self);
                if (typeof options === "string") {
                    url = options;
                    options = {};
                } else if (Array.isArray(options)) {
                    points = options.slice();
                } else if (typeof options === "undefined" && self.data.url) {
                    _updatePropertiesFromImage.call(self);
                    _triggerUpdate.call(self);
                    return null;
                } else {
                    url = options.url;
                    points = options.points || [];
                    zoom = typeof options.zoom === "undefined" ? null : options.zoom;
                }
                self.data.bound = false;
                self.data.url = url || self.data.url;
                self.data.boundZoom = zoom;
                return loadImage(url, hasExif).then(function(img) {
                    _replaceImage.call(self, img);
                    if (!points.length) {
                        var natDim = naturalImageDimensions(img);
                        var rect = self.elements.viewport.getBoundingClientRect();
                        var aspectRatio = rect.width / rect.height;
                        var imgAspectRatio = natDim.width / natDim.height;
                        var width, height;
                        if (imgAspectRatio > aspectRatio) {
                            height = natDim.height;
                            width = height * aspectRatio;
                        } else {
                            width = natDim.width;
                            height = natDim.height / aspectRatio;
                        }
                        var x0 = (natDim.width - width) / 2;
                        var y0 = (natDim.height - height) / 2;
                        var x1 = x0 + width;
                        var y1 = y0 + height;
                        self.data.points = [ x0, y0, x1, y1 ];
                    } else if (self.options.relative) {
                        points = [ points[0] * img.naturalWidth / 100, points[1] * img.naturalHeight / 100, points[2] * img.naturalWidth / 100, points[3] * img.naturalHeight / 100 ];
                    }
                    self.data.orientation = options.orientation || 1;
                    self.data.points = points.map(function(p) {
                        return parseFloat(p);
                    });
                    if (self.options.useCanvas) {
                        _transferImageToCanvas.call(self, self.data.orientation);
                    }
                    _updatePropertiesFromImage.call(self);
                    _triggerUpdate.call(self);
                    cb && cb();
                });
            }
            function fix(v, decimalPoints) {
                return parseFloat(v).toFixed(decimalPoints || 0);
            }
            function _get() {
                var self = this, imgData = self.elements.preview.getBoundingClientRect(), vpData = self.elements.viewport.getBoundingClientRect(), x1 = vpData.left - imgData.left, y1 = vpData.top - imgData.top, widthDiff = (vpData.width - self.elements.viewport.offsetWidth) / 2, heightDiff = (vpData.height - self.elements.viewport.offsetHeight) / 2, x2 = x1 + self.elements.viewport.offsetWidth + widthDiff, y2 = y1 + self.elements.viewport.offsetHeight + heightDiff, scale = self._currentZoom;
                if (scale === Infinity || isNaN(scale)) {
                    scale = 1;
                }
                var max = self.options.enforceBoundary ? 0 : Number.NEGATIVE_INFINITY;
                x1 = Math.max(max, x1 / scale);
                y1 = Math.max(max, y1 / scale);
                x2 = Math.max(max, x2 / scale);
                y2 = Math.max(max, y2 / scale);
                return {
                    points: [ fix(x1), fix(y1), fix(x2), fix(y2) ],
                    zoom: scale,
                    orientation: self.data.orientation
                };
            }
            var RESULT_DEFAULTS = {
                type: "canvas",
                format: "png",
                quality: 1
            }, RESULT_FORMATS = [ "jpeg", "webp", "png" ];
            function _result(options) {
                var self = this, data = _get.call(self), opts = deepExtend(clone(RESULT_DEFAULTS), clone(options)), resultType = typeof options === "string" ? options : opts.type || "base64", size = opts.size || "viewport", format = opts.format, quality = opts.quality, backgroundColor = opts.backgroundColor, circle = typeof opts.circle === "boolean" ? opts.circle : self.options.viewport.type === "circle", vpRect = self.elements.viewport.getBoundingClientRect(), ratio = vpRect.width / vpRect.height, prom;
                if (size === "viewport") {
                    data.outputWidth = vpRect.width;
                    data.outputHeight = vpRect.height;
                } else if (typeof size === "object") {
                    if (size.width && size.height) {
                        data.outputWidth = size.width;
                        data.outputHeight = size.height;
                    } else if (size.width) {
                        data.outputWidth = size.width;
                        data.outputHeight = size.width / ratio;
                    } else if (size.height) {
                        data.outputWidth = size.height * ratio;
                        data.outputHeight = size.height;
                    }
                }
                if (RESULT_FORMATS.indexOf(format) > -1) {
                    data.format = "image/" + format;
                    data.quality = quality;
                }
                data.circle = circle;
                data.url = self.data.url;
                data.backgroundColor = backgroundColor;
                prom = new Promise(function(resolve) {
                    switch (resultType.toLowerCase()) {
                      case "rawcanvas":
                        resolve(_getCanvas.call(self, data));
                        break;

                      case "canvas":
                      case "base64":
                        resolve(_getBase64Result.call(self, data));
                        break;

                      case "blob":
                        _getBlobResult.call(self, data).then(resolve);
                        break;

                      default:
                        resolve(_getHtmlResult.call(self, data));
                        break;
                    }
                });
                return prom;
            }
            function _refresh() {
                _updatePropertiesFromImage.call(this);
            }
            function _rotate(deg) {
                if (!this.options.useCanvas || !this.options.enableOrientation) {
                    throw "Croppie: Cannot rotate without enableOrientation && EXIF.js included";
                }
                var self = this, canvas = self.elements.canvas;
                self.data.orientation = getExifOffset(self.data.orientation, deg);
                drawCanvas(canvas, self.elements.img, self.data.orientation);
                _updateCenterPoint.call(self, true);
                _updateZoomLimits.call(self);
                if (Math.abs(deg) / 90 % 2 === 1) {
                    var oldHeight = self._originalImageHeight;
                    var oldWidth = self._originalImageWidth;
                    self._originalImageWidth = oldHeight;
                    self._originalImageHeight = oldWidth;
                }
            }
            function _destroy() {
                var self = this;
                self.element.removeChild(self.elements.boundary);
                removeClass(self.element, "croppie-container");
                if (self.options.enableZoom) {
                    self.element.removeChild(self.elements.zoomerWrap);
                }
                delete self.elements;
            }
            if (typeof window !== "undefined" && window.jQuery) {
                var $ = window.jQuery;
                $.fn.croppie = function(opts) {
                    var ot = typeof opts;
                    if (ot === "string") {
                        var args = Array.prototype.slice.call(arguments, 1);
                        var singleInst = $(this).data("croppie");
                        if (opts === "get") {
                            return singleInst.get();
                        } else if (opts === "result") {
                            return singleInst.result.apply(singleInst, args);
                        } else if (opts === "bind") {
                            return singleInst.bind.apply(singleInst, args);
                        }
                        return this.each(function() {
                            var i = $(this).data("croppie");
                            if (!i) return;
                            var method = i[opts];
                            if ($.isFunction(method)) {
                                method.apply(i, args);
                                if (opts === "destroy") {
                                    $(this).removeData("croppie");
                                }
                            } else {
                                throw "Croppie " + opts + " method not found";
                            }
                        });
                    } else {
                        return this.each(function() {
                            var i = new Croppie(this, opts);
                            i.$ = $;
                            $(this).data("croppie", i);
                        });
                    }
                };
            }
            function Croppie(element, opts) {
                if (element.className.indexOf("croppie-container") > -1) {
                    throw new Error("Croppie: Can't initialize croppie more than once");
                }
                this.element = element;
                this.options = deepExtend(clone(Croppie.defaults), opts);
                if (this.element.tagName.toLowerCase() === "img") {
                    var origImage = this.element;
                    addClass(origImage, "cr-original-image");
                    setAttributes(origImage, {
                        "aria-hidden": "true",
                        alt: ""
                    });
                    var replacementDiv = document.createElement("div");
                    this.element.parentNode.appendChild(replacementDiv);
                    replacementDiv.appendChild(origImage);
                    this.element = replacementDiv;
                    this.options.url = this.options.url || origImage.src;
                }
                _create.call(this);
                if (this.options.url) {
                    var bindOpts = {
                        url: this.options.url,
                        points: this.options.points
                    };
                    delete this.options["url"];
                    delete this.options["points"];
                    _bind.call(this, bindOpts);
                }
            }
            Croppie.defaults = {
                viewport: {
                    width: 100,
                    height: 100,
                    type: "square"
                },
                boundary: {},
                orientationControls: {
                    enabled: true,
                    leftClass: "",
                    rightClass: ""
                },
                resizeControls: {
                    width: true,
                    height: true
                },
                customClass: "",
                showZoomer: true,
                enableZoom: true,
                enableResize: false,
                mouseWheelZoom: true,
                enableExif: false,
                enforceBoundary: true,
                enableOrientation: false,
                enableKeyMovement: true,
                update: function() {}
            };
            Croppie.globals = {
                translate: "translate3d"
            };
            deepExtend(Croppie.prototype, {
                bind: function(options, cb) {
                    return _bind.call(this, options, cb);
                },
                get: function() {
                    var data = _get.call(this);
                    var points = data.points;
                    if (this.options.relative) {
                        points[0] /= this.elements.img.naturalWidth / 100;
                        points[1] /= this.elements.img.naturalHeight / 100;
                        points[2] /= this.elements.img.naturalWidth / 100;
                        points[3] /= this.elements.img.naturalHeight / 100;
                    }
                    return data;
                },
                result: function(type) {
                    return _result.call(this, type);
                },
                refresh: function() {
                    return _refresh.call(this);
                },
                setZoom: function(v) {
                    _setZoomerVal.call(this, v);
                    dispatchChange(this.elements.zoomer);
                },
                rotate: function(deg) {
                    _rotate.call(this, deg);
                },
                destroy: function() {
                    return _destroy.call(this);
                }
            });
            return Croppie;
        });
    })(croppie, croppie.exports);
    var croppieExports = croppie.exports;
    var Croppie$1 = getDefaultExportFromCjs(croppieExports);
    var HOOKS = [ "onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange", "onPreCalendarPosition" ];
    var defaults = {
        _disable: [],
        allowInput: false,
        allowInvalidPreload: false,
        altFormat: "F j, Y",
        altInput: false,
        altInputClass: "form-control input",
        animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
        ariaDateFormat: "F j, Y",
        autoFillDefaultTime: true,
        clickOpens: true,
        closeOnSelect: true,
        conjunction: ", ",
        dateFormat: "Y-m-d",
        defaultHour: 12,
        defaultMinute: 0,
        defaultSeconds: 0,
        disable: [],
        disableMobile: false,
        enableSeconds: false,
        enableTime: false,
        errorHandler: function(err) {
            return typeof console !== "undefined" && console.warn(err);
        },
        getWeek: function(givenDate) {
            var date = new Date(givenDate.getTime());
            date.setHours(0, 0, 0, 0);
            date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
            var week1 = new Date(date.getFullYear(), 0, 4);
            return 1 + Math.round(((date.getTime() - week1.getTime()) / 864e5 - 3 + (week1.getDay() + 6) % 7) / 7);
        },
        hourIncrement: 1,
        ignoredFocusElements: [],
        inline: false,
        locale: "default",
        minuteIncrement: 5,
        mode: "single",
        monthSelectorType: "dropdown",
        nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
        noCalendar: false,
        now: new Date,
        onChange: [],
        onClose: [],
        onDayCreate: [],
        onDestroy: [],
        onKeyDown: [],
        onMonthChange: [],
        onOpen: [],
        onParseConfig: [],
        onReady: [],
        onValueUpdate: [],
        onYearChange: [],
        onPreCalendarPosition: [],
        plugins: [],
        position: "auto",
        positionElement: undefined,
        prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
        shorthandCurrentMonth: false,
        showMonths: 1,
        static: false,
        time_24hr: false,
        weekNumbers: false,
        wrap: false
    };
    var english = {
        weekdays: {
            shorthand: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
            longhand: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
        },
        months: {
            shorthand: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ],
            longhand: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
        },
        daysInMonth: [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ],
        firstDayOfWeek: 0,
        ordinal: function(nth) {
            var s = nth % 100;
            if (s > 3 && s < 21) return "th";
            switch (s % 10) {
              case 1:
                return "st";

              case 2:
                return "nd";

              case 3:
                return "rd";

              default:
                return "th";
            }
        },
        rangeSeparator: " to ",
        weekAbbreviation: "Wk",
        scrollTitle: "Scroll to increment",
        toggleTitle: "Click to toggle",
        amPM: [ "AM", "PM" ],
        yearAriaLabel: "Year",
        monthAriaLabel: "Month",
        hourAriaLabel: "Hour",
        minuteAriaLabel: "Minute",
        time_24hr: false
    };
    var pad = function(number, length) {
        if (length === void 0) {
            length = 2;
        }
        return ("000" + number).slice(length * -1);
    };
    var int = function(bool) {
        return bool === true ? 1 : 0;
    };
    function debounce(fn, wait) {
        var t;
        return function() {
            var _this = this;
            var args = arguments;
            clearTimeout(t);
            t = setTimeout(function() {
                return fn.apply(_this, args);
            }, wait);
        };
    }
    var arrayify = function(obj) {
        return obj instanceof Array ? obj : [ obj ];
    };
    function toggleClass(elem, className, bool) {
        if (bool === true) return elem.classList.add(className);
        elem.classList.remove(className);
    }
    function createElement(tag, className, content) {
        var e = window.document.createElement(tag);
        className = className || "";
        content = content || "";
        e.className = className;
        if (content !== undefined) e.textContent = content;
        return e;
    }
    function clearNode(node) {
        while (node.firstChild) node.removeChild(node.firstChild);
    }
    function findParent(node, condition) {
        if (condition(node)) return node; else if (node.parentNode) return findParent(node.parentNode, condition);
        return undefined;
    }
    function createNumberInput(inputClassName, opts) {
        var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
        if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
            numInput.type = "number";
        } else {
            numInput.type = "text";
            numInput.pattern = "\\d*";
        }
        if (opts !== undefined) for (var key in opts) numInput.setAttribute(key, opts[key]);
        wrapper.appendChild(numInput);
        wrapper.appendChild(arrowUp);
        wrapper.appendChild(arrowDown);
        return wrapper;
    }
    function getEventTarget(event) {
        try {
            if (typeof event.composedPath === "function") {
                var path = event.composedPath();
                return path[0];
            }
            return event.target;
        } catch (error) {
            return event.target;
        }
    }
    var doNothing = function() {
        return undefined;
    };
    var monthToStr = function(monthNumber, shorthand, locale) {
        return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
    };
    var revFormat = {
        D: doNothing,
        F: function(dateObj, monthName, locale) {
            dateObj.setMonth(locale.months.longhand.indexOf(monthName));
        },
        G: function(dateObj, hour) {
            dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
        },
        H: function(dateObj, hour) {
            dateObj.setHours(parseFloat(hour));
        },
        J: function(dateObj, day) {
            dateObj.setDate(parseFloat(day));
        },
        K: function(dateObj, amPM, locale) {
            dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
        },
        M: function(dateObj, shortMonth, locale) {
            dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
        },
        S: function(dateObj, seconds) {
            dateObj.setSeconds(parseFloat(seconds));
        },
        U: function(_, unixSeconds) {
            return new Date(parseFloat(unixSeconds) * 1e3);
        },
        W: function(dateObj, weekNum, locale) {
            var weekNumber = parseInt(weekNum);
            var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
            date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
            return date;
        },
        Y: function(dateObj, year) {
            dateObj.setFullYear(parseFloat(year));
        },
        Z: function(_, ISODate) {
            return new Date(ISODate);
        },
        d: function(dateObj, day) {
            dateObj.setDate(parseFloat(day));
        },
        h: function(dateObj, hour) {
            dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
        },
        i: function(dateObj, minutes) {
            dateObj.setMinutes(parseFloat(minutes));
        },
        j: function(dateObj, day) {
            dateObj.setDate(parseFloat(day));
        },
        l: doNothing,
        m: function(dateObj, month) {
            dateObj.setMonth(parseFloat(month) - 1);
        },
        n: function(dateObj, month) {
            dateObj.setMonth(parseFloat(month) - 1);
        },
        s: function(dateObj, seconds) {
            dateObj.setSeconds(parseFloat(seconds));
        },
        u: function(_, unixMillSeconds) {
            return new Date(parseFloat(unixMillSeconds));
        },
        w: doNothing,
        y: function(dateObj, year) {
            dateObj.setFullYear(2e3 + parseFloat(year));
        }
    };
    var tokenRegex = {
        D: "",
        F: "",
        G: "(\\d\\d|\\d)",
        H: "(\\d\\d|\\d)",
        J: "(\\d\\d|\\d)\\w+",
        K: "",
        M: "",
        S: "(\\d\\d|\\d)",
        U: "(.+)",
        W: "(\\d\\d|\\d)",
        Y: "(\\d{4})",
        Z: "(.+)",
        d: "(\\d\\d|\\d)",
        h: "(\\d\\d|\\d)",
        i: "(\\d\\d|\\d)",
        j: "(\\d\\d|\\d)",
        l: "",
        m: "(\\d\\d|\\d)",
        n: "(\\d\\d|\\d)",
        s: "(\\d\\d|\\d)",
        u: "(.+)",
        w: "(\\d\\d|\\d)",
        y: "(\\d{2})"
    };
    var formats = {
        Z: function(date) {
            return date.toISOString();
        },
        D: function(date, locale, options) {
            return locale.weekdays.shorthand[formats.w(date, locale, options)];
        },
        F: function(date, locale, options) {
            return monthToStr(formats.n(date, locale, options) - 1, false, locale);
        },
        G: function(date, locale, options) {
            return pad(formats.h(date, locale, options));
        },
        H: function(date) {
            return pad(date.getHours());
        },
        J: function(date, locale) {
            return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
        },
        K: function(date, locale) {
            return locale.amPM[int(date.getHours() > 11)];
        },
        M: function(date, locale) {
            return monthToStr(date.getMonth(), true, locale);
        },
        S: function(date) {
            return pad(date.getSeconds());
        },
        U: function(date) {
            return date.getTime() / 1e3;
        },
        W: function(date, _, options) {
            return options.getWeek(date);
        },
        Y: function(date) {
            return pad(date.getFullYear(), 4);
        },
        d: function(date) {
            return pad(date.getDate());
        },
        h: function(date) {
            return date.getHours() % 12 ? date.getHours() % 12 : 12;
        },
        i: function(date) {
            return pad(date.getMinutes());
        },
        j: function(date) {
            return date.getDate();
        },
        l: function(date, locale) {
            return locale.weekdays.longhand[date.getDay()];
        },
        m: function(date) {
            return pad(date.getMonth() + 1);
        },
        n: function(date) {
            return date.getMonth() + 1;
        },
        s: function(date) {
            return date.getSeconds();
        },
        u: function(date) {
            return date.getTime();
        },
        w: function(date) {
            return date.getDay();
        },
        y: function(date) {
            return String(date.getFullYear()).substring(2);
        }
    };
    var createDateFormatter = function(_a) {
        var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
        return function(dateObj, frmt, overrideLocale) {
            var locale = overrideLocale || l10n;
            if (config.formatDate !== undefined && !isMobile) {
                return config.formatDate(dateObj, frmt, locale);
            }
            return frmt.split("").map(function(c, i, arr) {
                return formats[c] && arr[i - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "";
            }).join("");
        };
    };
    var createDateParser = function(_a) {
        var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
        return function(date, givenFormat, timeless, customLocale) {
            if (date !== 0 && !date) return undefined;
            var locale = customLocale || l10n;
            var parsedDate;
            var dateOrig = date;
            if (date instanceof Date) parsedDate = new Date(date.getTime()); else if (typeof date !== "string" && date.toFixed !== undefined) parsedDate = new Date(date); else if (typeof date === "string") {
                var format = givenFormat || (config || defaults).dateFormat;
                var datestr = String(date).trim();
                if (datestr === "today") {
                    parsedDate = new Date;
                    timeless = true;
                } else if (config && config.parseDate) {
                    parsedDate = config.parseDate(date, format);
                } else if (/Z$/.test(datestr) || /GMT$/.test(datestr)) {
                    parsedDate = new Date(date);
                } else {
                    var matched = void 0, ops = [];
                    for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
                        var token = format[i];
                        var isBackSlash = token === "\\";
                        var escaped = format[i - 1] === "\\" || isBackSlash;
                        if (tokenRegex[token] && !escaped) {
                            regexStr += tokenRegex[token];
                            var match = new RegExp(regexStr).exec(date);
                            if (match && (matched = true)) {
                                ops[token !== "Y" ? "push" : "unshift"]({
                                    fn: revFormat[token],
                                    val: match[++matchIndex]
                                });
                            }
                        } else if (!isBackSlash) regexStr += ".";
                    }
                    parsedDate = !config || !config.noCalendar ? new Date((new Date).getFullYear(), 0, 1, 0, 0, 0, 0) : new Date((new Date).setHours(0, 0, 0, 0));
                    ops.forEach(function(_a) {
                        var fn = _a.fn, val = _a.val;
                        return parsedDate = fn(parsedDate, val, locale) || parsedDate;
                    });
                    parsedDate = matched ? parsedDate : undefined;
                }
            }
            if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
                config.errorHandler(new Error("Invalid date provided: " + dateOrig));
                return undefined;
            }
            if (timeless === true) parsedDate.setHours(0, 0, 0, 0);
            return parsedDate;
        };
    };
    function compareDates(date1, date2, timeless) {
        if (timeless === void 0) {
            timeless = true;
        }
        if (timeless !== false) {
            return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
        }
        return date1.getTime() - date2.getTime();
    }
    var isBetween = function(ts, ts1, ts2) {
        return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
    };
    var calculateSecondsSinceMidnight = function(hours, minutes, seconds) {
        return hours * 3600 + minutes * 60 + seconds;
    };
    var parseSeconds = function(secondsSinceMidnight) {
        var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
        return [ hours, minutes, secondsSinceMidnight - hours * 3600 - minutes * 60 ];
    };
    var duration = {
        DAY: 864e5
    };
    function getDefaultHours(config) {
        var hours = config.defaultHour;
        var minutes = config.defaultMinute;
        var seconds = config.defaultSeconds;
        if (config.minDate !== undefined) {
            var minHour = config.minDate.getHours();
            var minMinutes = config.minDate.getMinutes();
            var minSeconds = config.minDate.getSeconds();
            if (hours < minHour) {
                hours = minHour;
            }
            if (hours === minHour && minutes < minMinutes) {
                minutes = minMinutes;
            }
            if (hours === minHour && minutes === minMinutes && seconds < minSeconds) seconds = config.minDate.getSeconds();
        }
        if (config.maxDate !== undefined) {
            var maxHr = config.maxDate.getHours();
            var maxMinutes = config.maxDate.getMinutes();
            hours = Math.min(hours, maxHr);
            if (hours === maxHr) minutes = Math.min(maxMinutes, minutes);
            if (hours === maxHr && minutes === maxMinutes) seconds = config.maxDate.getSeconds();
        }
        return {
            hours: hours,
            minutes: minutes,
            seconds: seconds
        };
    }
    if (typeof Object.assign !== "function") {
        Object.assign = function(target) {
            var args = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                args[_i - 1] = arguments[_i];
            }
            if (!target) {
                throw TypeError("Cannot convert undefined or null to object");
            }
            var _loop_1 = function(source) {
                if (source) {
                    Object.keys(source).forEach(function(key) {
                        return target[key] = source[key];
                    });
                }
            };
            for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
                var source = args_1[_a];
                _loop_1(source);
            }
            return target;
        };
    }
    var __assign = window && window.__assign || function() {
        __assign = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    var __spreadArrays = window && window.__spreadArrays || function() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, 
        k++) r[k] = a[j];
        return r;
    };
    var DEBOUNCED_CHANGE_MS = 300;
    function FlatpickrInstance(element, instanceConfig) {
        var self = {
            config: __assign(__assign({}, defaults), flatpickr.defaultConfig),
            l10n: english
        };
        self.parseDate = createDateParser({
            config: self.config,
            l10n: self.l10n
        });
        self._handlers = [];
        self.pluginElements = [];
        self.loadedPlugins = [];
        self._bind = bind;
        self._setHoursFromDate = setHoursFromDate;
        self._positionCalendar = positionCalendar;
        self.changeMonth = changeMonth;
        self.changeYear = changeYear;
        self.clear = clear;
        self.close = close;
        self.onMouseOver = onMouseOver;
        self._createElement = createElement;
        self.createDay = createDay;
        self.destroy = destroy;
        self.isEnabled = isEnabled;
        self.jumpToDate = jumpToDate;
        self.updateValue = updateValue;
        self.open = open;
        self.redraw = redraw;
        self.set = set;
        self.setDate = setDate;
        self.toggle = toggle;
        function setupHelperFunctions() {
            self.utils = {
                getDaysInMonth: function(month, yr) {
                    if (month === void 0) {
                        month = self.currentMonth;
                    }
                    if (yr === void 0) {
                        yr = self.currentYear;
                    }
                    if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0)) return 29;
                    return self.l10n.daysInMonth[month];
                }
            };
        }
        function init() {
            self.element = self.input = element;
            self.isOpen = false;
            parseConfig();
            setupLocale();
            setupInputs();
            setupDates();
            setupHelperFunctions();
            if (!self.isMobile) build();
            bindEvents();
            if (self.selectedDates.length || self.config.noCalendar) {
                if (self.config.enableTime) {
                    setHoursFromDate(self.config.noCalendar ? self.latestSelectedDateObj : undefined);
                }
                updateValue(false);
            }
            setCalendarWidth();
            var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
            if (!self.isMobile && isSafari) {
                positionCalendar();
            }
            triggerEvent("onReady");
        }
        function getClosestActiveElement() {
            var _a;
            return ((_a = self.calendarContainer) === null || _a === void 0 ? void 0 : _a.getRootNode()).activeElement || document.activeElement;
        }
        function bindToInstance(fn) {
            return fn.bind(self);
        }
        function setCalendarWidth() {
            var config = self.config;
            if (config.weekNumbers === false && config.showMonths === 1) {
                return;
            } else if (config.noCalendar !== true) {
                window.requestAnimationFrame(function() {
                    if (self.calendarContainer !== undefined) {
                        self.calendarContainer.style.visibility = "hidden";
                        self.calendarContainer.style.display = "block";
                    }
                    if (self.daysContainer !== undefined) {
                        var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
                        self.daysContainer.style.width = daysWidth + "px";
                        self.calendarContainer.style.width = daysWidth + (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) + "px";
                        self.calendarContainer.style.removeProperty("visibility");
                        self.calendarContainer.style.removeProperty("display");
                    }
                });
            }
        }
        function updateTime(e) {
            if (self.selectedDates.length === 0) {
                var defaultDate = self.config.minDate === undefined || compareDates(new Date, self.config.minDate) >= 0 ? new Date : new Date(self.config.minDate.getTime());
                var defaults = getDefaultHours(self.config);
                defaultDate.setHours(defaults.hours, defaults.minutes, defaults.seconds, defaultDate.getMilliseconds());
                self.selectedDates = [ defaultDate ];
                self.latestSelectedDateObj = defaultDate;
            }
            if (e !== undefined && e.type !== "blur") {
                timeWrapper(e);
            }
            var prevValue = self._input.value;
            setHoursFromInputs();
            updateValue();
            if (self._input.value !== prevValue) {
                self._debouncedChange();
            }
        }
        function ampm2military(hour, amPM) {
            return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
        }
        function military2ampm(hour) {
            switch (hour % 24) {
              case 0:
              case 12:
                return 12;

              default:
                return hour % 12;
            }
        }
        function setHoursFromInputs() {
            if (self.hourElement === undefined || self.minuteElement === undefined) return;
            var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined ? (parseInt(self.secondElement.value, 10) || 0) % 60 : 0;
            if (self.amPM !== undefined) {
                hours = ampm2military(hours, self.amPM.textContent);
            }
            var limitMinHours = self.config.minTime !== undefined || self.config.minDate && self.minDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.minDate, true) === 0;
            var limitMaxHours = self.config.maxTime !== undefined || self.config.maxDate && self.maxDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.maxDate, true) === 0;
            if (self.config.maxTime !== undefined && self.config.minTime !== undefined && self.config.minTime > self.config.maxTime) {
                var minBound = calculateSecondsSinceMidnight(self.config.minTime.getHours(), self.config.minTime.getMinutes(), self.config.minTime.getSeconds());
                var maxBound = calculateSecondsSinceMidnight(self.config.maxTime.getHours(), self.config.maxTime.getMinutes(), self.config.maxTime.getSeconds());
                var currentTime = calculateSecondsSinceMidnight(hours, minutes, seconds);
                if (currentTime > maxBound && currentTime < minBound) {
                    var result = parseSeconds(minBound);
                    hours = result[0];
                    minutes = result[1];
                    seconds = result[2];
                }
            } else {
                if (limitMaxHours) {
                    var maxTime = self.config.maxTime !== undefined ? self.config.maxTime : self.config.maxDate;
                    hours = Math.min(hours, maxTime.getHours());
                    if (hours === maxTime.getHours()) minutes = Math.min(minutes, maxTime.getMinutes());
                    if (minutes === maxTime.getMinutes()) seconds = Math.min(seconds, maxTime.getSeconds());
                }
                if (limitMinHours) {
                    var minTime = self.config.minTime !== undefined ? self.config.minTime : self.config.minDate;
                    hours = Math.max(hours, minTime.getHours());
                    if (hours === minTime.getHours() && minutes < minTime.getMinutes()) minutes = minTime.getMinutes();
                    if (minutes === minTime.getMinutes()) seconds = Math.max(seconds, minTime.getSeconds());
                }
            }
            setHours(hours, minutes, seconds);
        }
        function setHoursFromDate(dateObj) {
            var date = dateObj || self.latestSelectedDateObj;
            if (date && date instanceof Date) {
                setHours(date.getHours(), date.getMinutes(), date.getSeconds());
            }
        }
        function setHours(hours, minutes, seconds) {
            if (self.latestSelectedDateObj !== undefined) {
                self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
            }
            if (!self.hourElement || !self.minuteElement || self.isMobile) return;
            self.hourElement.value = pad(!self.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours);
            self.minuteElement.value = pad(minutes);
            if (self.amPM !== undefined) self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
            if (self.secondElement !== undefined) self.secondElement.value = pad(seconds);
        }
        function onYearInput(event) {
            var eventTarget = getEventTarget(event);
            var year = parseInt(eventTarget.value) + (event.delta || 0);
            if (year / 1e3 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) {
                changeYear(year);
            }
        }
        function bind(element, event, handler, options) {
            if (event instanceof Array) return event.forEach(function(ev) {
                return bind(element, ev, handler, options);
            });
            if (element instanceof Array) return element.forEach(function(el) {
                return bind(el, event, handler, options);
            });
            element.addEventListener(event, handler, options);
            self._handlers.push({
                remove: function() {
                    return element.removeEventListener(event, handler, options);
                }
            });
        }
        function triggerChange() {
            triggerEvent("onChange");
        }
        function bindEvents() {
            if (self.config.wrap) {
                [ "open", "close", "toggle", "clear" ].forEach(function(evt) {
                    Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function(el) {
                        return bind(el, "click", self[evt]);
                    });
                });
            }
            if (self.isMobile) {
                setupMobile();
                return;
            }
            var debouncedResize = debounce(onResize, 50);
            self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
            if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent)) bind(self.daysContainer, "mouseover", function(e) {
                if (self.config.mode === "range") onMouseOver(getEventTarget(e));
            });
            bind(self._input, "keydown", onKeyDown);
            if (self.calendarContainer !== undefined) {
                bind(self.calendarContainer, "keydown", onKeyDown);
            }
            if (!self.config.inline && !self.config.static) bind(window, "resize", debouncedResize);
            if (window.ontouchstart !== undefined) bind(window.document, "touchstart", documentClick); else bind(window.document, "mousedown", documentClick);
            bind(window.document, "focus", documentClick, {
                capture: true
            });
            if (self.config.clickOpens === true) {
                bind(self._input, "focus", self.open);
                bind(self._input, "click", self.open);
            }
            if (self.daysContainer !== undefined) {
                bind(self.monthNav, "click", onMonthNavClick);
                bind(self.monthNav, [ "keyup", "increment" ], onYearInput);
                bind(self.daysContainer, "click", selectDate);
            }
            if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
                var selText = function(e) {
                    return getEventTarget(e).select();
                };
                bind(self.timeContainer, [ "increment" ], updateTime);
                bind(self.timeContainer, "blur", updateTime, {
                    capture: true
                });
                bind(self.timeContainer, "click", timeIncrement);
                bind([ self.hourElement, self.minuteElement ], [ "focus", "click" ], selText);
                if (self.secondElement !== undefined) bind(self.secondElement, "focus", function() {
                    return self.secondElement && self.secondElement.select();
                });
                if (self.amPM !== undefined) {
                    bind(self.amPM, "click", function(e) {
                        updateTime(e);
                    });
                }
            }
            if (self.config.allowInput) {
                bind(self._input, "blur", onBlur);
            }
        }
        function jumpToDate(jumpDate, triggerChange) {
            var jumpTo = jumpDate !== undefined ? self.parseDate(jumpDate) : self.latestSelectedDateObj || (self.config.minDate && self.config.minDate > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate < self.now ? self.config.maxDate : self.now);
            var oldYear = self.currentYear;
            var oldMonth = self.currentMonth;
            try {
                if (jumpTo !== undefined) {
                    self.currentYear = jumpTo.getFullYear();
                    self.currentMonth = jumpTo.getMonth();
                }
            } catch (e) {
                e.message = "Invalid date supplied: " + jumpTo;
                self.config.errorHandler(e);
            }
            if (triggerChange && self.currentYear !== oldYear) {
                triggerEvent("onYearChange");
                buildMonthSwitch();
            }
            if (triggerChange && (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
                triggerEvent("onMonthChange");
            }
            self.redraw();
        }
        function timeIncrement(e) {
            var eventTarget = getEventTarget(e);
            if (~eventTarget.className.indexOf("arrow")) incrementNumInput(e, eventTarget.classList.contains("arrowUp") ? 1 : -1);
        }
        function incrementNumInput(e, delta, inputElem) {
            var target = e && getEventTarget(e);
            var input = inputElem || target && target.parentNode && target.parentNode.firstChild;
            var event = createEvent("increment");
            event.delta = delta;
            input && input.dispatchEvent(event);
        }
        function build() {
            var fragment = window.document.createDocumentFragment();
            self.calendarContainer = createElement("div", "flatpickr-calendar");
            self.calendarContainer.tabIndex = -1;
            if (!self.config.noCalendar) {
                fragment.appendChild(buildMonthNav());
                self.innerContainer = createElement("div", "flatpickr-innerContainer");
                if (self.config.weekNumbers) {
                    var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
                    self.innerContainer.appendChild(weekWrapper);
                    self.weekNumbers = weekNumbers;
                    self.weekWrapper = weekWrapper;
                }
                self.rContainer = createElement("div", "flatpickr-rContainer");
                self.rContainer.appendChild(buildWeekdays());
                if (!self.daysContainer) {
                    self.daysContainer = createElement("div", "flatpickr-days");
                    self.daysContainer.tabIndex = -1;
                }
                buildDays();
                self.rContainer.appendChild(self.daysContainer);
                self.innerContainer.appendChild(self.rContainer);
                fragment.appendChild(self.innerContainer);
            }
            if (self.config.enableTime) {
                fragment.appendChild(buildTime());
            }
            toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
            toggleClass(self.calendarContainer, "animate", self.config.animate === true);
            toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
            self.calendarContainer.appendChild(fragment);
            var customAppend = self.config.appendTo !== undefined && self.config.appendTo.nodeType !== undefined;
            if (self.config.inline || self.config.static) {
                self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
                if (self.config.inline) {
                    if (!customAppend && self.element.parentNode) self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling); else if (self.config.appendTo !== undefined) self.config.appendTo.appendChild(self.calendarContainer);
                }
                if (self.config.static) {
                    var wrapper = createElement("div", "flatpickr-wrapper");
                    if (self.element.parentNode) self.element.parentNode.insertBefore(wrapper, self.element);
                    wrapper.appendChild(self.element);
                    if (self.altInput) wrapper.appendChild(self.altInput);
                    wrapper.appendChild(self.calendarContainer);
                }
            }
            if (!self.config.static && !self.config.inline) (self.config.appendTo !== undefined ? self.config.appendTo : window.document.body).appendChild(self.calendarContainer);
        }
        function createDay(className, date, _dayNumber, i) {
            var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", className, date.getDate().toString());
            dayElement.dateObj = date;
            dayElement.$i = i;
            dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
            if (className.indexOf("hidden") === -1 && compareDates(date, self.now) === 0) {
                self.todayDateElem = dayElement;
                dayElement.classList.add("today");
                dayElement.setAttribute("aria-current", "date");
            }
            if (dateIsEnabled) {
                dayElement.tabIndex = -1;
                if (isDateSelected(date)) {
                    dayElement.classList.add("selected");
                    self.selectedDateElem = dayElement;
                    if (self.config.mode === "range") {
                        toggleClass(dayElement, "startRange", self.selectedDates[0] && compareDates(date, self.selectedDates[0], true) === 0);
                        toggleClass(dayElement, "endRange", self.selectedDates[1] && compareDates(date, self.selectedDates[1], true) === 0);
                        if (className === "nextMonthDay") dayElement.classList.add("inRange");
                    }
                }
            } else {
                dayElement.classList.add("flatpickr-disabled");
            }
            if (self.config.mode === "range") {
                if (isDateInRange(date) && !isDateSelected(date)) dayElement.classList.add("inRange");
            }
            if (self.weekNumbers && self.config.showMonths === 1 && className !== "prevMonthDay" && i % 7 === 6) {
                self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
            }
            triggerEvent("onDayCreate", dayElement);
            return dayElement;
        }
        function focusOnDayElem(targetNode) {
            targetNode.focus();
            if (self.config.mode === "range") onMouseOver(targetNode);
        }
        function getFirstAvailableDay(delta) {
            var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
            var endMonth = delta > 0 ? self.config.showMonths : -1;
            for (var m = startMonth; m != endMonth; m += delta) {
                var month = self.daysContainer.children[m];
                var startIndex = delta > 0 ? 0 : month.children.length - 1;
                var endIndex = delta > 0 ? month.children.length : -1;
                for (var i = startIndex; i != endIndex; i += delta) {
                    var c = month.children[i];
                    if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) return c;
                }
            }
            return undefined;
        }
        function getNextAvailableDay(current, delta) {
            var givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self.currentMonth;
            var endMonth = delta > 0 ? self.config.showMonths : -1;
            var loopDelta = delta > 0 ? 1 : -1;
            for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
                var month = self.daysContainer.children[m];
                var startIndex = givenMonth - self.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
                var numMonthDays = month.children.length;
                for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
                    var c = month.children[i];
                    if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta)) return focusOnDayElem(c);
                }
            }
            self.changeMonth(loopDelta);
            focusOnDay(getFirstAvailableDay(loopDelta), 0);
            return undefined;
        }
        function focusOnDay(current, offset) {
            var activeElement = getClosestActiveElement();
            var dayFocused = isInView(activeElement || document.body);
            var startElem = current !== undefined ? current : dayFocused ? activeElement : self.selectedDateElem !== undefined && isInView(self.selectedDateElem) ? self.selectedDateElem : self.todayDateElem !== undefined && isInView(self.todayDateElem) ? self.todayDateElem : getFirstAvailableDay(offset > 0 ? 1 : -1);
            if (startElem === undefined) {
                self._input.focus();
            } else if (!dayFocused) {
                focusOnDayElem(startElem);
            } else {
                getNextAvailableDay(startElem, offset);
            }
        }
        function buildMonthDays(year, month) {
            var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
            var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12, year);
            var daysInMonth = self.utils.getDaysInMonth(month, year), days = window.document.createDocumentFragment(), isMultiMonth = self.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
            var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
            for (;dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
                days.appendChild(createDay("flatpickr-day " + prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
            }
            for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
                days.appendChild(createDay("flatpickr-day", new Date(year, month, dayNumber), dayNumber, dayIndex));
            }
            for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, 
            dayIndex++) {
                days.appendChild(createDay("flatpickr-day " + nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
            }
            var dayContainer = createElement("div", "dayContainer");
            dayContainer.appendChild(days);
            return dayContainer;
        }
        function buildDays() {
            if (self.daysContainer === undefined) {
                return;
            }
            clearNode(self.daysContainer);
            if (self.weekNumbers) clearNode(self.weekNumbers);
            var frag = document.createDocumentFragment();
            for (var i = 0; i < self.config.showMonths; i++) {
                var d = new Date(self.currentYear, self.currentMonth, 1);
                d.setMonth(self.currentMonth + i);
                frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
            }
            self.daysContainer.appendChild(frag);
            self.days = self.daysContainer.firstChild;
            if (self.config.mode === "range" && self.selectedDates.length === 1) {
                onMouseOver();
            }
        }
        function buildMonthSwitch() {
            if (self.config.showMonths > 1 || self.config.monthSelectorType !== "dropdown") return;
            var shouldBuildMonth = function(month) {
                if (self.config.minDate !== undefined && self.currentYear === self.config.minDate.getFullYear() && month < self.config.minDate.getMonth()) {
                    return false;
                }
                return !(self.config.maxDate !== undefined && self.currentYear === self.config.maxDate.getFullYear() && month > self.config.maxDate.getMonth());
            };
            self.monthsDropdownContainer.tabIndex = -1;
            self.monthsDropdownContainer.innerHTML = "";
            for (var i = 0; i < 12; i++) {
                if (!shouldBuildMonth(i)) continue;
                var month = createElement("option", "flatpickr-monthDropdown-month");
                month.value = new Date(self.currentYear, i).getMonth().toString();
                month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
                month.tabIndex = -1;
                if (self.currentMonth === i) {
                    month.selected = true;
                }
                self.monthsDropdownContainer.appendChild(month);
            }
        }
        function buildMonth() {
            var container = createElement("div", "flatpickr-month");
            var monthNavFragment = window.document.createDocumentFragment();
            var monthElement;
            if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
                monthElement = createElement("span", "cur-month");
            } else {
                self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
                self.monthsDropdownContainer.setAttribute("aria-label", self.l10n.monthAriaLabel);
                bind(self.monthsDropdownContainer, "change", function(e) {
                    var target = getEventTarget(e);
                    var selectedMonth = parseInt(target.value, 10);
                    self.changeMonth(selectedMonth - self.currentMonth);
                    triggerEvent("onMonthChange");
                });
                buildMonthSwitch();
                monthElement = self.monthsDropdownContainer;
            }
            var yearInput = createNumberInput("cur-year", {
                tabindex: "-1"
            });
            var yearElement = yearInput.getElementsByTagName("input")[0];
            yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
            if (self.config.minDate) {
                yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
            }
            if (self.config.maxDate) {
                yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
                yearElement.disabled = !!self.config.minDate && self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
            }
            var currentMonth = createElement("div", "flatpickr-current-month");
            currentMonth.appendChild(monthElement);
            currentMonth.appendChild(yearInput);
            monthNavFragment.appendChild(currentMonth);
            container.appendChild(monthNavFragment);
            return {
                container: container,
                yearElement: yearElement,
                monthElement: monthElement
            };
        }
        function buildMonths() {
            clearNode(self.monthNav);
            self.monthNav.appendChild(self.prevMonthNav);
            if (self.config.showMonths) {
                self.yearElements = [];
                self.monthElements = [];
            }
            for (var m = self.config.showMonths; m--; ) {
                var month = buildMonth();
                self.yearElements.push(month.yearElement);
                self.monthElements.push(month.monthElement);
                self.monthNav.appendChild(month.container);
            }
            self.monthNav.appendChild(self.nextMonthNav);
        }
        function buildMonthNav() {
            self.monthNav = createElement("div", "flatpickr-months");
            self.yearElements = [];
            self.monthElements = [];
            self.prevMonthNav = createElement("span", "flatpickr-prev-month");
            self.prevMonthNav.innerHTML = self.config.prevArrow;
            self.nextMonthNav = createElement("span", "flatpickr-next-month");
            self.nextMonthNav.innerHTML = self.config.nextArrow;
            buildMonths();
            Object.defineProperty(self, "_hidePrevMonthArrow", {
                get: function() {
                    return self.__hidePrevMonthArrow;
                },
                set: function(bool) {
                    if (self.__hidePrevMonthArrow !== bool) {
                        toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
                        self.__hidePrevMonthArrow = bool;
                    }
                }
            });
            Object.defineProperty(self, "_hideNextMonthArrow", {
                get: function() {
                    return self.__hideNextMonthArrow;
                },
                set: function(bool) {
                    if (self.__hideNextMonthArrow !== bool) {
                        toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
                        self.__hideNextMonthArrow = bool;
                    }
                }
            });
            self.currentYearElement = self.yearElements[0];
            updateNavigationCurrentMonth();
            return self.monthNav;
        }
        function buildTime() {
            self.calendarContainer.classList.add("hasTime");
            if (self.config.noCalendar) self.calendarContainer.classList.add("noCalendar");
            var defaults = getDefaultHours(self.config);
            self.timeContainer = createElement("div", "flatpickr-time");
            self.timeContainer.tabIndex = -1;
            var separator = createElement("span", "flatpickr-time-separator", ":");
            var hourInput = createNumberInput("flatpickr-hour", {
                "aria-label": self.l10n.hourAriaLabel
            });
            self.hourElement = hourInput.getElementsByTagName("input")[0];
            var minuteInput = createNumberInput("flatpickr-minute", {
                "aria-label": self.l10n.minuteAriaLabel
            });
            self.minuteElement = minuteInput.getElementsByTagName("input")[0];
            self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
            self.hourElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.time_24hr ? defaults.hours : military2ampm(defaults.hours));
            self.minuteElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getMinutes() : defaults.minutes);
            self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
            self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
            self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
            self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
            self.hourElement.setAttribute("maxlength", "2");
            self.minuteElement.setAttribute("min", "0");
            self.minuteElement.setAttribute("max", "59");
            self.minuteElement.setAttribute("maxlength", "2");
            self.timeContainer.appendChild(hourInput);
            self.timeContainer.appendChild(separator);
            self.timeContainer.appendChild(minuteInput);
            if (self.config.time_24hr) self.timeContainer.classList.add("time24hr");
            if (self.config.enableSeconds) {
                self.timeContainer.classList.add("hasSeconds");
                var secondInput = createNumberInput("flatpickr-second");
                self.secondElement = secondInput.getElementsByTagName("input")[0];
                self.secondElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getSeconds() : defaults.seconds);
                self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
                self.secondElement.setAttribute("min", "0");
                self.secondElement.setAttribute("max", "59");
                self.secondElement.setAttribute("maxlength", "2");
                self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
                self.timeContainer.appendChild(secondInput);
            }
            if (!self.config.time_24hr) {
                self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj ? self.hourElement.value : self.config.defaultHour) > 11)]);
                self.amPM.title = self.l10n.toggleTitle;
                self.amPM.tabIndex = -1;
                self.timeContainer.appendChild(self.amPM);
            }
            return self.timeContainer;
        }
        function buildWeekdays() {
            if (!self.weekdayContainer) self.weekdayContainer = createElement("div", "flatpickr-weekdays"); else clearNode(self.weekdayContainer);
            for (var i = self.config.showMonths; i--; ) {
                var container = createElement("div", "flatpickr-weekdaycontainer");
                self.weekdayContainer.appendChild(container);
            }
            updateWeekdays();
            return self.weekdayContainer;
        }
        function updateWeekdays() {
            if (!self.weekdayContainer) {
                return;
            }
            var firstDayOfWeek = self.l10n.firstDayOfWeek;
            var weekdays = __spreadArrays(self.l10n.weekdays.shorthand);
            if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
                weekdays = __spreadArrays(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
            }
            for (var i = self.config.showMonths; i--; ) {
                self.weekdayContainer.children[i].innerHTML = "\n      <span class='flatpickr-weekday'>\n        " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n      </span>\n      ";
            }
        }
        function buildWeeks() {
            self.calendarContainer.classList.add("hasWeeks");
            var weekWrapper = createElement("div", "flatpickr-weekwrapper");
            weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
            var weekNumbers = createElement("div", "flatpickr-weeks");
            weekWrapper.appendChild(weekNumbers);
            return {
                weekWrapper: weekWrapper,
                weekNumbers: weekNumbers
            };
        }
        function changeMonth(value, isOffset) {
            if (isOffset === void 0) {
                isOffset = true;
            }
            var delta = isOffset ? value : value - self.currentMonth;
            if (delta < 0 && self._hidePrevMonthArrow === true || delta > 0 && self._hideNextMonthArrow === true) return;
            self.currentMonth += delta;
            if (self.currentMonth < 0 || self.currentMonth > 11) {
                self.currentYear += self.currentMonth > 11 ? 1 : -1;
                self.currentMonth = (self.currentMonth + 12) % 12;
                triggerEvent("onYearChange");
                buildMonthSwitch();
            }
            buildDays();
            triggerEvent("onMonthChange");
            updateNavigationCurrentMonth();
        }
        function clear(triggerChangeEvent, toInitial) {
            if (triggerChangeEvent === void 0) {
                triggerChangeEvent = true;
            }
            if (toInitial === void 0) {
                toInitial = true;
            }
            self.input.value = "";
            if (self.altInput !== undefined) self.altInput.value = "";
            if (self.mobileInput !== undefined) self.mobileInput.value = "";
            self.selectedDates = [];
            self.latestSelectedDateObj = undefined;
            if (toInitial === true) {
                self.currentYear = self._initialDate.getFullYear();
                self.currentMonth = self._initialDate.getMonth();
            }
            if (self.config.enableTime === true) {
                var _a = getDefaultHours(self.config), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
                setHours(hours, minutes, seconds);
            }
            self.redraw();
            if (triggerChangeEvent) triggerEvent("onChange");
        }
        function close() {
            self.isOpen = false;
            if (!self.isMobile) {
                if (self.calendarContainer !== undefined) {
                    self.calendarContainer.classList.remove("open");
                }
                if (self._input !== undefined) {
                    self._input.classList.remove("active");
                }
            }
            triggerEvent("onClose");
        }
        function destroy() {
            if (self.config !== undefined) triggerEvent("onDestroy");
            for (var i = self._handlers.length; i--; ) {
                self._handlers[i].remove();
            }
            self._handlers = [];
            if (self.mobileInput) {
                if (self.mobileInput.parentNode) self.mobileInput.parentNode.removeChild(self.mobileInput);
                self.mobileInput = undefined;
            } else if (self.calendarContainer && self.calendarContainer.parentNode) {
                if (self.config.static && self.calendarContainer.parentNode) {
                    var wrapper = self.calendarContainer.parentNode;
                    wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
                    if (wrapper.parentNode) {
                        while (wrapper.firstChild) wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
                        wrapper.parentNode.removeChild(wrapper);
                    }
                } else self.calendarContainer.parentNode.removeChild(self.calendarContainer);
            }
            if (self.altInput) {
                self.input.type = "text";
                if (self.altInput.parentNode) self.altInput.parentNode.removeChild(self.altInput);
                delete self.altInput;
            }
            if (self.input) {
                self.input.type = self.input._type;
                self.input.classList.remove("flatpickr-input");
                self.input.removeAttribute("readonly");
            }
            [ "_showTimeInput", "latestSelectedDateObj", "_hideNextMonthArrow", "_hidePrevMonthArrow", "__hideNextMonthArrow", "__hidePrevMonthArrow", "isMobile", "isOpen", "selectedDateElem", "minDateHasTime", "maxDateHasTime", "days", "daysContainer", "_input", "_positionElement", "innerContainer", "rContainer", "monthNav", "todayDateElem", "calendarContainer", "weekdayContainer", "prevMonthNav", "nextMonthNav", "monthsDropdownContainer", "currentMonthElement", "currentYearElement", "navigationCurrentMonth", "selectedDateElem", "config" ].forEach(function(k) {
                try {
                    delete self[k];
                } catch (_) {}
            });
        }
        function isCalendarElem(elem) {
            return self.calendarContainer.contains(elem);
        }
        function documentClick(e) {
            if (self.isOpen && !self.config.inline) {
                var eventTarget_1 = getEventTarget(e);
                var isCalendarElement = isCalendarElem(eventTarget_1);
                var isInput = eventTarget_1 === self.input || eventTarget_1 === self.altInput || self.element.contains(eventTarget_1) || e.path && e.path.indexOf && (~e.path.indexOf(self.input) || ~e.path.indexOf(self.altInput));
                var lostFocus = !isInput && !isCalendarElement && !isCalendarElem(e.relatedTarget);
                var isIgnored = !self.config.ignoredFocusElements.some(function(elem) {
                    return elem.contains(eventTarget_1);
                });
                if (lostFocus && isIgnored) {
                    if (self.config.allowInput) {
                        self.setDate(self._input.value, false, self.config.altInput ? self.config.altFormat : self.config.dateFormat);
                    }
                    if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined && self.input.value !== "" && self.input.value !== undefined) {
                        updateTime();
                    }
                    self.close();
                    if (self.config && self.config.mode === "range" && self.selectedDates.length === 1) self.clear(false);
                }
            }
        }
        function changeYear(newYear) {
            if (!newYear || self.config.minDate && newYear < self.config.minDate.getFullYear() || self.config.maxDate && newYear > self.config.maxDate.getFullYear()) return;
            var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
            self.currentYear = newYearNum || self.currentYear;
            if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
                self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
            } else if (self.config.minDate && self.currentYear === self.config.minDate.getFullYear()) {
                self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
            }
            if (isNewYear) {
                self.redraw();
                triggerEvent("onYearChange");
                buildMonthSwitch();
            }
        }
        function isEnabled(date, timeless) {
            var _a;
            if (timeless === void 0) {
                timeless = true;
            }
            var dateToCheck = self.parseDate(date, undefined, timeless);
            if (self.config.minDate && dateToCheck && compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && dateToCheck && compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
            if (!self.config.enable && self.config.disable.length === 0) return true;
            if (dateToCheck === undefined) return false;
            var bool = !!self.config.enable, array = (_a = self.config.enable) !== null && _a !== void 0 ? _a : self.config.disable;
            for (var i = 0, d = void 0; i < array.length; i++) {
                d = array[i];
                if (typeof d === "function" && d(dateToCheck)) return bool; else if (d instanceof Date && dateToCheck !== undefined && d.getTime() === dateToCheck.getTime()) return bool; else if (typeof d === "string") {
                    var parsed = self.parseDate(d, undefined, true);
                    return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
                } else if (typeof d === "object" && dateToCheck !== undefined && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) return bool;
            }
            return !bool;
        }
        function isInView(elem) {
            if (self.daysContainer !== undefined) return elem.className.indexOf("hidden") === -1 && elem.className.indexOf("flatpickr-disabled") === -1 && self.daysContainer.contains(elem);
            return false;
        }
        function onBlur(e) {
            var isInput = e.target === self._input;
            var valueChanged = self._input.value.trimEnd() !== getDateStr();
            if (isInput && valueChanged && !(e.relatedTarget && isCalendarElem(e.relatedTarget))) {
                self.setDate(self._input.value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
            }
        }
        function onKeyDown(e) {
            var eventTarget = getEventTarget(e);
            var isInput = self.config.wrap ? element.contains(eventTarget) : eventTarget === self._input;
            var allowInput = self.config.allowInput;
            var allowKeydown = self.isOpen && (!allowInput || !isInput);
            var allowInlineKeydown = self.config.inline && isInput && !allowInput;
            if (e.keyCode === 13 && isInput) {
                if (allowInput) {
                    self.setDate(self._input.value, true, eventTarget === self.altInput ? self.config.altFormat : self.config.dateFormat);
                    self.close();
                    return eventTarget.blur();
                } else {
                    self.open();
                }
            } else if (isCalendarElem(eventTarget) || allowKeydown || allowInlineKeydown) {
                var isTimeObj = !!self.timeContainer && self.timeContainer.contains(eventTarget);
                switch (e.keyCode) {
                  case 13:
                    if (isTimeObj) {
                        e.preventDefault();
                        updateTime();
                        focusAndClose();
                    } else selectDate(e);
                    break;

                  case 27:
                    e.preventDefault();
                    focusAndClose();
                    break;

                  case 8:
                  case 46:
                    if (isInput && !self.config.allowInput) {
                        e.preventDefault();
                        self.clear();
                    }
                    break;

                  case 37:
                  case 39:
                    if (!isTimeObj && !isInput) {
                        e.preventDefault();
                        var activeElement = getClosestActiveElement();
                        if (self.daysContainer !== undefined && (allowInput === false || activeElement && isInView(activeElement))) {
                            var delta_1 = e.keyCode === 39 ? 1 : -1;
                            if (!e.ctrlKey) focusOnDay(undefined, delta_1); else {
                                e.stopPropagation();
                                changeMonth(delta_1);
                                focusOnDay(getFirstAvailableDay(1), 0);
                            }
                        }
                    } else if (self.hourElement) self.hourElement.focus();
                    break;

                  case 38:
                  case 40:
                    e.preventDefault();
                    var delta = e.keyCode === 40 ? 1 : -1;
                    if (self.daysContainer && eventTarget.$i !== undefined || eventTarget === self.input || eventTarget === self.altInput) {
                        if (e.ctrlKey) {
                            e.stopPropagation();
                            changeYear(self.currentYear - delta);
                            focusOnDay(getFirstAvailableDay(1), 0);
                        } else if (!isTimeObj) focusOnDay(undefined, delta * 7);
                    } else if (eventTarget === self.currentYearElement) {
                        changeYear(self.currentYear - delta);
                    } else if (self.config.enableTime) {
                        if (!isTimeObj && self.hourElement) self.hourElement.focus();
                        updateTime(e);
                        self._debouncedChange();
                    }
                    break;

                  case 9:
                    if (isTimeObj) {
                        var elems = [ self.hourElement, self.minuteElement, self.secondElement, self.amPM ].concat(self.pluginElements).filter(function(x) {
                            return x;
                        });
                        var i = elems.indexOf(eventTarget);
                        if (i !== -1) {
                            var target = elems[i + (e.shiftKey ? -1 : 1)];
                            e.preventDefault();
                            (target || self._input).focus();
                        }
                    } else if (!self.config.noCalendar && self.daysContainer && self.daysContainer.contains(eventTarget) && e.shiftKey) {
                        e.preventDefault();
                        self._input.focus();
                    }
                    break;
                }
            }
            if (self.amPM !== undefined && eventTarget === self.amPM) {
                switch (e.key) {
                  case self.l10n.amPM[0].charAt(0):
                  case self.l10n.amPM[0].charAt(0).toLowerCase():
                    self.amPM.textContent = self.l10n.amPM[0];
                    setHoursFromInputs();
                    updateValue();
                    break;

                  case self.l10n.amPM[1].charAt(0):
                  case self.l10n.amPM[1].charAt(0).toLowerCase():
                    self.amPM.textContent = self.l10n.amPM[1];
                    setHoursFromInputs();
                    updateValue();
                    break;
                }
            }
            if (isInput || isCalendarElem(eventTarget)) {
                triggerEvent("onKeyDown", e);
            }
        }
        function onMouseOver(elem, cellClass) {
            if (cellClass === void 0) {
                cellClass = "flatpickr-day";
            }
            if (self.selectedDates.length !== 1 || elem && (!elem.classList.contains(cellClass) || elem.classList.contains("flatpickr-disabled"))) return;
            var hoverDate = elem ? elem.dateObj.getTime() : self.days.firstElementChild.dateObj.getTime(), initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(), rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
            var containsDisabled = false;
            var minRange = 0, maxRange = 0;
            for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
                if (!isEnabled(new Date(t), true)) {
                    containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
                    if (t < initialDate && (!minRange || t > minRange)) minRange = t; else if (t > initialDate && (!maxRange || t < maxRange)) maxRange = t;
                }
            }
            var hoverableCells = Array.from(self.rContainer.querySelectorAll("*:nth-child(-n+" + self.config.showMonths + ") > ." + cellClass));
            hoverableCells.forEach(function(dayElem) {
                var date = dayElem.dateObj;
                var timestamp = date.getTime();
                var outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
                if (outOfRange) {
                    dayElem.classList.add("notAllowed");
                    [ "inRange", "startRange", "endRange" ].forEach(function(c) {
                        dayElem.classList.remove(c);
                    });
                    return;
                } else if (containsDisabled && !outOfRange) return;
                [ "startRange", "inRange", "endRange", "notAllowed" ].forEach(function(c) {
                    dayElem.classList.remove(c);
                });
                if (elem !== undefined) {
                    elem.classList.add(hoverDate <= self.selectedDates[0].getTime() ? "startRange" : "endRange");
                    if (initialDate < hoverDate && timestamp === initialDate) dayElem.classList.add("startRange"); else if (initialDate > hoverDate && timestamp === initialDate) dayElem.classList.add("endRange");
                    if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate)) dayElem.classList.add("inRange");
                }
            });
        }
        function onResize() {
            if (self.isOpen && !self.config.static && !self.config.inline) positionCalendar();
        }
        function open(e, positionElement) {
            if (positionElement === void 0) {
                positionElement = self._positionElement;
            }
            if (self.isMobile === true) {
                if (e) {
                    e.preventDefault();
                    var eventTarget = getEventTarget(e);
                    if (eventTarget) {
                        eventTarget.blur();
                    }
                }
                if (self.mobileInput !== undefined) {
                    self.mobileInput.focus();
                    self.mobileInput.click();
                }
                triggerEvent("onOpen");
                return;
            } else if (self._input.disabled || self.config.inline) {
                return;
            }
            var wasOpen = self.isOpen;
            self.isOpen = true;
            if (!wasOpen) {
                self.calendarContainer.classList.add("open");
                self._input.classList.add("active");
                triggerEvent("onOpen");
                positionCalendar(positionElement);
            }
            if (self.config.enableTime === true && self.config.noCalendar === true) {
                if (self.config.allowInput === false && (e === undefined || !self.timeContainer.contains(e.relatedTarget))) {
                    setTimeout(function() {
                        return self.hourElement.select();
                    }, 50);
                }
            }
        }
        function minMaxDateSetter(type) {
            return function(date) {
                var dateObj = self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat);
                var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
                if (dateObj !== undefined) {
                    self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0;
                }
                if (self.selectedDates) {
                    self.selectedDates = self.selectedDates.filter(function(d) {
                        return isEnabled(d);
                    });
                    if (!self.selectedDates.length && type === "min") setHoursFromDate(dateObj);
                    updateValue();
                }
                if (self.daysContainer) {
                    redraw();
                    if (dateObj !== undefined) self.currentYearElement[type] = dateObj.getFullYear().toString(); else self.currentYearElement.removeAttribute(type);
                    self.currentYearElement.disabled = !!inverseDateObj && dateObj !== undefined && inverseDateObj.getFullYear() === dateObj.getFullYear();
                }
            };
        }
        function parseConfig() {
            var boolOpts = [ "wrap", "weekNumbers", "allowInput", "allowInvalidPreload", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile" ];
            var userConfig = __assign(__assign({}, JSON.parse(JSON.stringify(element.dataset || {}))), instanceConfig);
            var formats = {};
            self.config.parseDate = userConfig.parseDate;
            self.config.formatDate = userConfig.formatDate;
            Object.defineProperty(self.config, "enable", {
                get: function() {
                    return self.config._enable;
                },
                set: function(dates) {
                    self.config._enable = parseDateRules(dates);
                }
            });
            Object.defineProperty(self.config, "disable", {
                get: function() {
                    return self.config._disable;
                },
                set: function(dates) {
                    self.config._disable = parseDateRules(dates);
                }
            });
            var timeMode = userConfig.mode === "time";
            if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
                var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
                formats.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
            }
            if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
                var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
                formats.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
            }
            Object.defineProperty(self.config, "minDate", {
                get: function() {
                    return self.config._minDate;
                },
                set: minMaxDateSetter("min")
            });
            Object.defineProperty(self.config, "maxDate", {
                get: function() {
                    return self.config._maxDate;
                },
                set: minMaxDateSetter("max")
            });
            var minMaxTimeSetter = function(type) {
                return function(val) {
                    self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
                };
            };
            Object.defineProperty(self.config, "minTime", {
                get: function() {
                    return self.config._minTime;
                },
                set: minMaxTimeSetter("min")
            });
            Object.defineProperty(self.config, "maxTime", {
                get: function() {
                    return self.config._maxTime;
                },
                set: minMaxTimeSetter("max")
            });
            if (userConfig.mode === "time") {
                self.config.noCalendar = true;
                self.config.enableTime = true;
            }
            Object.assign(self.config, formats, userConfig);
            for (var i = 0; i < boolOpts.length; i++) self.config[boolOpts[i]] = self.config[boolOpts[i]] === true || self.config[boolOpts[i]] === "true";
            HOOKS.filter(function(hook) {
                return self.config[hook] !== undefined;
            }).forEach(function(hook) {
                self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
            });
            self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
            for (var i = 0; i < self.config.plugins.length; i++) {
                var pluginConf = self.config.plugins[i](self) || {};
                for (var key in pluginConf) {
                    if (HOOKS.indexOf(key) > -1) {
                        self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
                    } else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
                }
            }
            if (!userConfig.altInputClass) {
                self.config.altInputClass = getInputElem().className + " " + self.config.altInputClass;
            }
            triggerEvent("onParseConfig");
        }
        function getInputElem() {
            return self.config.wrap ? element.querySelector("[data-input]") : element;
        }
        function setupLocale() {
            if (typeof self.config.locale !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
            self.l10n = __assign(__assign({}, flatpickr.l10ns.default), typeof self.config.locale === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] : undefined);
            tokenRegex.D = "(" + self.l10n.weekdays.shorthand.join("|") + ")";
            tokenRegex.l = "(" + self.l10n.weekdays.longhand.join("|") + ")";
            tokenRegex.M = "(" + self.l10n.months.shorthand.join("|") + ")";
            tokenRegex.F = "(" + self.l10n.months.longhand.join("|") + ")";
            tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
            var userConfig = __assign(__assign({}, instanceConfig), JSON.parse(JSON.stringify(element.dataset || {})));
            if (userConfig.time_24hr === undefined && flatpickr.defaultConfig.time_24hr === undefined) {
                self.config.time_24hr = self.l10n.time_24hr;
            }
            self.formatDate = createDateFormatter(self);
            self.parseDate = createDateParser({
                config: self.config,
                l10n: self.l10n
            });
        }
        function positionCalendar(customPositionElement) {
            if (typeof self.config.position === "function") {
                return void self.config.position(self, customPositionElement);
            }
            if (self.calendarContainer === undefined) return;
            triggerEvent("onPreCalendarPosition");
            var positionElement = customPositionElement || self._positionElement;
            var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function(acc, child) {
                return acc + child.offsetHeight;
            }, 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
            var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
            toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
            toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
            if (self.config.inline) return;
            var left = window.pageXOffset + inputBounds.left;
            var isCenter = false;
            var isRight = false;
            if (configPosHorizontal === "center") {
                left -= (calendarWidth - inputBounds.width) / 2;
                isCenter = true;
            } else if (configPosHorizontal === "right") {
                left -= calendarWidth - inputBounds.width;
                isRight = true;
            }
            toggleClass(self.calendarContainer, "arrowLeft", !isCenter && !isRight);
            toggleClass(self.calendarContainer, "arrowCenter", isCenter);
            toggleClass(self.calendarContainer, "arrowRight", isRight);
            var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
            var rightMost = left + calendarWidth > window.document.body.offsetWidth;
            var centerMost = right + calendarWidth > window.document.body.offsetWidth;
            toggleClass(self.calendarContainer, "rightMost", rightMost);
            if (self.config.static) return;
            self.calendarContainer.style.top = top + "px";
            if (!rightMost) {
                self.calendarContainer.style.left = left + "px";
                self.calendarContainer.style.right = "auto";
            } else if (!centerMost) {
                self.calendarContainer.style.left = "auto";
                self.calendarContainer.style.right = right + "px";
            } else {
                var doc = getDocumentStyleSheet();
                if (doc === undefined) return;
                var bodyWidth = window.document.body.offsetWidth;
                var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
                var centerBefore = ".flatpickr-calendar.centerMost:before";
                var centerAfter = ".flatpickr-calendar.centerMost:after";
                var centerIndex = doc.cssRules.length;
                var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
                toggleClass(self.calendarContainer, "rightMost", false);
                toggleClass(self.calendarContainer, "centerMost", true);
                doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
                self.calendarContainer.style.left = centerLeft + "px";
                self.calendarContainer.style.right = "auto";
            }
        }
        function getDocumentStyleSheet() {
            var editableSheet = null;
            for (var i = 0; i < document.styleSheets.length; i++) {
                var sheet = document.styleSheets[i];
                if (!sheet.cssRules) continue;
                try {
                    sheet.cssRules;
                } catch (err) {
                    continue;
                }
                editableSheet = sheet;
                break;
            }
            return editableSheet != null ? editableSheet : createStyleSheet();
        }
        function createStyleSheet() {
            var style = document.createElement("style");
            document.head.appendChild(style);
            return style.sheet;
        }
        function redraw() {
            if (self.config.noCalendar || self.isMobile) return;
            buildMonthSwitch();
            updateNavigationCurrentMonth();
            buildDays();
        }
        function focusAndClose() {
            self._input.focus();
            if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== undefined) {
                setTimeout(self.close, 0);
            } else {
                self.close();
            }
        }
        function selectDate(e) {
            e.preventDefault();
            e.stopPropagation();
            var isSelectable = function(day) {
                return day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed");
            };
            var t = findParent(getEventTarget(e), isSelectable);
            if (t === undefined) return;
            var target = t;
            var selectedDate = self.latestSelectedDateObj = new Date(target.dateObj.getTime());
            var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth || selectedDate.getMonth() > self.currentMonth + self.config.showMonths - 1) && self.config.mode !== "range";
            self.selectedDateElem = target;
            if (self.config.mode === "single") self.selectedDates = [ selectedDate ]; else if (self.config.mode === "multiple") {
                var selectedIndex = isDateSelected(selectedDate);
                if (selectedIndex) self.selectedDates.splice(parseInt(selectedIndex), 1); else self.selectedDates.push(selectedDate);
            } else if (self.config.mode === "range") {
                if (self.selectedDates.length === 2) {
                    self.clear(false, false);
                }
                self.latestSelectedDateObj = selectedDate;
                self.selectedDates.push(selectedDate);
                if (compareDates(selectedDate, self.selectedDates[0], true) !== 0) self.selectedDates.sort(function(a, b) {
                    return a.getTime() - b.getTime();
                });
            }
            setHoursFromInputs();
            if (shouldChangeMonth) {
                var isNewYear = self.currentYear !== selectedDate.getFullYear();
                self.currentYear = selectedDate.getFullYear();
                self.currentMonth = selectedDate.getMonth();
                if (isNewYear) {
                    triggerEvent("onYearChange");
                    buildMonthSwitch();
                }
                triggerEvent("onMonthChange");
            }
            updateNavigationCurrentMonth();
            buildDays();
            updateValue();
            if (!shouldChangeMonth && self.config.mode !== "range" && self.config.showMonths === 1) focusOnDayElem(target); else if (self.selectedDateElem !== undefined && self.hourElement === undefined) {
                self.selectedDateElem && self.selectedDateElem.focus();
            }
            if (self.hourElement !== undefined) self.hourElement !== undefined && self.hourElement.focus();
            if (self.config.closeOnSelect) {
                var single = self.config.mode === "single" && !self.config.enableTime;
                var range = self.config.mode === "range" && self.selectedDates.length === 2 && !self.config.enableTime;
                if (single || range) {
                    focusAndClose();
                }
            }
            triggerChange();
        }
        var CALLBACKS = {
            locale: [ setupLocale, updateWeekdays ],
            showMonths: [ buildMonths, setCalendarWidth, buildWeekdays ],
            minDate: [ jumpToDate ],
            maxDate: [ jumpToDate ],
            positionElement: [ updatePositionElement ],
            clickOpens: [ function() {
                if (self.config.clickOpens === true) {
                    bind(self._input, "focus", self.open);
                    bind(self._input, "click", self.open);
                } else {
                    self._input.removeEventListener("focus", self.open);
                    self._input.removeEventListener("click", self.open);
                }
            } ]
        };
        function set(option, value) {
            if (option !== null && typeof option === "object") {
                Object.assign(self.config, option);
                for (var key in option) {
                    if (CALLBACKS[key] !== undefined) CALLBACKS[key].forEach(function(x) {
                        return x();
                    });
                }
            } else {
                self.config[option] = value;
                if (CALLBACKS[option] !== undefined) CALLBACKS[option].forEach(function(x) {
                    return x();
                }); else if (HOOKS.indexOf(option) > -1) self.config[option] = arrayify(value);
            }
            self.redraw();
            updateValue(true);
        }
        function setSelectedDate(inputDate, format) {
            var dates = [];
            if (inputDate instanceof Array) dates = inputDate.map(function(d) {
                return self.parseDate(d, format);
            }); else if (inputDate instanceof Date || typeof inputDate === "number") dates = [ self.parseDate(inputDate, format) ]; else if (typeof inputDate === "string") {
                switch (self.config.mode) {
                  case "single":
                  case "time":
                    dates = [ self.parseDate(inputDate, format) ];
                    break;

                  case "multiple":
                    dates = inputDate.split(self.config.conjunction).map(function(date) {
                        return self.parseDate(date, format);
                    });
                    break;

                  case "range":
                    dates = inputDate.split(self.l10n.rangeSeparator).map(function(date) {
                        return self.parseDate(date, format);
                    });
                    break;
                }
            } else self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
            self.selectedDates = self.config.allowInvalidPreload ? dates : dates.filter(function(d) {
                return d instanceof Date && isEnabled(d, false);
            });
            if (self.config.mode === "range") self.selectedDates.sort(function(a, b) {
                return a.getTime() - b.getTime();
            });
        }
        function setDate(date, triggerChange, format) {
            if (triggerChange === void 0) {
                triggerChange = false;
            }
            if (format === void 0) {
                format = self.config.dateFormat;
            }
            if (date !== 0 && !date || date instanceof Array && date.length === 0) return self.clear(triggerChange);
            setSelectedDate(date, format);
            self.latestSelectedDateObj = self.selectedDates[self.selectedDates.length - 1];
            self.redraw();
            jumpToDate(undefined, triggerChange);
            setHoursFromDate();
            if (self.selectedDates.length === 0) {
                self.clear(false);
            }
            updateValue(triggerChange);
            if (triggerChange) triggerEvent("onChange");
        }
        function parseDateRules(arr) {
            return arr.slice().map(function(rule) {
                if (typeof rule === "string" || typeof rule === "number" || rule instanceof Date) {
                    return self.parseDate(rule, undefined, true);
                } else if (rule && typeof rule === "object" && rule.from && rule.to) return {
                    from: self.parseDate(rule.from, undefined),
                    to: self.parseDate(rule.to, undefined)
                };
                return rule;
            }).filter(function(x) {
                return x;
            });
        }
        function setupDates() {
            self.selectedDates = [];
            self.now = self.parseDate(self.config.now) || new Date;
            var preloadedDate = self.config.defaultDate || ((self.input.nodeName === "INPUT" || self.input.nodeName === "TEXTAREA") && self.input.placeholder && self.input.value === self.input.placeholder ? null : self.input.value);
            if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
            self._initialDate = self.selectedDates.length > 0 ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now.getTime() ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now.getTime() ? self.config.maxDate : self.now;
            self.currentYear = self._initialDate.getFullYear();
            self.currentMonth = self._initialDate.getMonth();
            if (self.selectedDates.length > 0) self.latestSelectedDateObj = self.selectedDates[0];
            if (self.config.minTime !== undefined) self.config.minTime = self.parseDate(self.config.minTime, "H:i");
            if (self.config.maxTime !== undefined) self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
            self.minDateHasTime = !!self.config.minDate && (self.config.minDate.getHours() > 0 || self.config.minDate.getMinutes() > 0 || self.config.minDate.getSeconds() > 0);
            self.maxDateHasTime = !!self.config.maxDate && (self.config.maxDate.getHours() > 0 || self.config.maxDate.getMinutes() > 0 || self.config.maxDate.getSeconds() > 0);
        }
        function setupInputs() {
            self.input = getInputElem();
            if (!self.input) {
                self.config.errorHandler(new Error("Invalid input element specified"));
                return;
            }
            self.input._type = self.input.type;
            self.input.type = "text";
            self.input.classList.add("flatpickr-input");
            self._input = self.input;
            if (self.config.altInput) {
                self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
                self._input = self.altInput;
                self.altInput.placeholder = self.input.placeholder;
                self.altInput.disabled = self.input.disabled;
                self.altInput.required = self.input.required;
                self.altInput.tabIndex = self.input.tabIndex;
                self.altInput.type = "text";
                self.input.setAttribute("type", "hidden");
                if (!self.config.static && self.input.parentNode) self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
            }
            if (!self.config.allowInput) self._input.setAttribute("readonly", "readonly");
            updatePositionElement();
        }
        function updatePositionElement() {
            self._positionElement = self.config.positionElement || self._input;
        }
        function setupMobile() {
            var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
            self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
            self.mobileInput.tabIndex = 1;
            self.mobileInput.type = inputType;
            self.mobileInput.disabled = self.input.disabled;
            self.mobileInput.required = self.input.required;
            self.mobileInput.placeholder = self.input.placeholder;
            self.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
            if (self.selectedDates.length > 0) {
                self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
            }
            if (self.config.minDate) self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
            if (self.config.maxDate) self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
            if (self.input.getAttribute("step")) self.mobileInput.step = String(self.input.getAttribute("step"));
            self.input.type = "hidden";
            if (self.altInput !== undefined) self.altInput.type = "hidden";
            try {
                if (self.input.parentNode) self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
            } catch (_a) {}
            bind(self.mobileInput, "change", function(e) {
                self.setDate(getEventTarget(e).value, false, self.mobileFormatStr);
                triggerEvent("onChange");
                triggerEvent("onClose");
            });
        }
        function toggle(e) {
            if (self.isOpen === true) return self.close();
            self.open(e);
        }
        function triggerEvent(event, data) {
            if (self.config === undefined) return;
            var hooks = self.config[event];
            if (hooks !== undefined && hooks.length > 0) {
                for (var i = 0; hooks[i] && i < hooks.length; i++) hooks[i](self.selectedDates, self.input.value, self, data);
            }
            if (event === "onChange") {
                self.input.dispatchEvent(createEvent("change"));
                self.input.dispatchEvent(createEvent("input"));
            }
        }
        function createEvent(name) {
            var e = document.createEvent("Event");
            e.initEvent(name, true, true);
            return e;
        }
        function isDateSelected(date) {
            for (var i = 0; i < self.selectedDates.length; i++) {
                var selectedDate = self.selectedDates[i];
                if (selectedDate instanceof Date && compareDates(selectedDate, date) === 0) return "" + i;
            }
            return false;
        }
        function isDateInRange(date) {
            if (self.config.mode !== "range" || self.selectedDates.length < 2) return false;
            return compareDates(date, self.selectedDates[0]) >= 0 && compareDates(date, self.selectedDates[1]) <= 0;
        }
        function updateNavigationCurrentMonth() {
            if (self.config.noCalendar || self.isMobile || !self.monthNav) return;
            self.yearElements.forEach(function(yearElement, i) {
                var d = new Date(self.currentYear, self.currentMonth, 1);
                d.setMonth(self.currentMonth + i);
                if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
                    self.monthElements[i].textContent = monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
                } else {
                    self.monthsDropdownContainer.value = d.getMonth().toString();
                }
                yearElement.value = d.getFullYear().toString();
            });
            self._hidePrevMonthArrow = self.config.minDate !== undefined && (self.currentYear === self.config.minDate.getFullYear() ? self.currentMonth <= self.config.minDate.getMonth() : self.currentYear < self.config.minDate.getFullYear());
            self._hideNextMonthArrow = self.config.maxDate !== undefined && (self.currentYear === self.config.maxDate.getFullYear() ? self.currentMonth + 1 > self.config.maxDate.getMonth() : self.currentYear > self.config.maxDate.getFullYear());
        }
        function getDateStr(specificFormat) {
            var format = specificFormat || (self.config.altInput ? self.config.altFormat : self.config.dateFormat);
            return self.selectedDates.map(function(dObj) {
                return self.formatDate(dObj, format);
            }).filter(function(d, i, arr) {
                return self.config.mode !== "range" || self.config.enableTime || arr.indexOf(d) === i;
            }).join(self.config.mode !== "range" ? self.config.conjunction : self.l10n.rangeSeparator);
        }
        function updateValue(triggerChange) {
            if (triggerChange === void 0) {
                triggerChange = true;
            }
            if (self.mobileInput !== undefined && self.mobileFormatStr) {
                self.mobileInput.value = self.latestSelectedDateObj !== undefined ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr) : "";
            }
            self.input.value = getDateStr(self.config.dateFormat);
            if (self.altInput !== undefined) {
                self.altInput.value = getDateStr(self.config.altFormat);
            }
            if (triggerChange !== false) triggerEvent("onValueUpdate");
        }
        function onMonthNavClick(e) {
            var eventTarget = getEventTarget(e);
            var isPrevMonth = self.prevMonthNav.contains(eventTarget);
            var isNextMonth = self.nextMonthNav.contains(eventTarget);
            if (isPrevMonth || isNextMonth) {
                changeMonth(isPrevMonth ? -1 : 1);
            } else if (self.yearElements.indexOf(eventTarget) >= 0) {
                eventTarget.select();
            } else if (eventTarget.classList.contains("arrowUp")) {
                self.changeYear(self.currentYear + 1);
            } else if (eventTarget.classList.contains("arrowDown")) {
                self.changeYear(self.currentYear - 1);
            }
        }
        function timeWrapper(e) {
            e.preventDefault();
            var isKeyDown = e.type === "keydown", eventTarget = getEventTarget(e), input = eventTarget;
            if (self.amPM !== undefined && eventTarget === self.amPM) {
                self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
            }
            var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta || (isKeyDown ? e.which === 38 ? 1 : -1 : 0);
            var newValue = curValue + step * delta;
            if (typeof input.value !== "undefined" && input.value.length === 2) {
                var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
                if (newValue < min) {
                    newValue = max + newValue + int(!isHourElem) + (int(isHourElem) && int(!self.amPM));
                    if (isMinuteElem) incrementNumInput(undefined, -1, self.hourElement);
                } else if (newValue > max) {
                    newValue = input === self.hourElement ? newValue - max - int(!self.amPM) : min;
                    if (isMinuteElem) incrementNumInput(undefined, 1, self.hourElement);
                }
                if (self.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) {
                    self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
                }
                input.value = pad(newValue);
            }
        }
        init();
        return self;
    }
    function _flatpickr(nodeList, config) {
        var nodes = Array.prototype.slice.call(nodeList).filter(function(x) {
            return x instanceof HTMLElement;
        });
        var instances = [];
        for (var i = 0; i < nodes.length; i++) {
            var node = nodes[i];
            try {
                if (node.getAttribute("data-fp-omit") !== null) continue;
                if (node._flatpickr !== undefined) {
                    node._flatpickr.destroy();
                    node._flatpickr = undefined;
                }
                node._flatpickr = FlatpickrInstance(node, config || {});
                instances.push(node._flatpickr);
            } catch (e) {
                console.error(e);
            }
        }
        return instances.length === 1 ? instances[0] : instances;
    }
    if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") {
        HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function(config) {
            return _flatpickr(this, config);
        };
        HTMLElement.prototype.flatpickr = function(config) {
            return _flatpickr([ this ], config);
        };
    }
    var flatpickr = function(selector, config) {
        if (typeof selector === "string") {
            return _flatpickr(window.document.querySelectorAll(selector), config);
        } else if (selector instanceof Node) {
            return _flatpickr([ selector ], config);
        } else {
            return _flatpickr(selector, config);
        }
    };
    flatpickr.defaultConfig = {};
    flatpickr.l10ns = {
        en: __assign({}, english),
        default: __assign({}, english)
    };
    flatpickr.localize = function(l10n) {
        flatpickr.l10ns.default = __assign(__assign({}, flatpickr.l10ns.default), l10n);
    };
    flatpickr.setDefaults = function(config) {
        flatpickr.defaultConfig = __assign(__assign({}, flatpickr.defaultConfig), config);
    };
    flatpickr.parseDate = createDateParser({});
    flatpickr.formatDate = createDateFormatter({});
    flatpickr.compareDates = compareDates;
    if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
        jQuery.fn.flatpickr = function(config) {
            return _flatpickr(this, config);
        };
    }
    Date.prototype.fp_incr = function(days) {
        return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
    };
    if (typeof window !== "undefined") {
        window.flatpickr = flatpickr;
    }
    let bsqrcdr;
    let Coloris;
    let Croppie;
    let Flatpickr;
    const input_event = new Event("input", {
        bubbles: true
    });
    const change_event = new Event("change", {
        bubbles: true
    });
    const svgIcon = QRCDR.icons.svg;
    const pngIcon = QRCDR.icons.png;
    const pdfIcon = QRCDR.icons.pdf;
    const printIcon = QRCDR.icons.print;
    const loadIcon = '<div class="spinner-border" role="status"><span class="visually-hidden">Loading...</span></div>';
    function maxLength(input) {
        const maxLengthSpan = document.createElement("div");
        maxLengthSpan.classList.add("small");
        const max = input.maxLength;
        input.after(maxLengthSpan);
        maxLengthSpan.innerText = input.value.length + "/" + max;
        input.addEventListener("input", function() {
            maxLengthSpan.innerText = input.value.length + "/" + max;
        });
    }
    function rangeSlider(theslider) {
        const sliderval = theslider.querySelector(".qrcdr-slider-value");
        const sliderinput = theslider.querySelector(".qrcdr-slider-input");
        const unit = sliderinput.dataset.qrcdrUnit || "";
        sliderval.innerText = sliderinput.value + unit;
        sliderinput.addEventListener("input", function() {
            sliderval.innerText = sliderinput.value + unit;
        });
    }
    function initColorPickers() {
        Coloris.init();
        Coloris({
            el: ".qrcolorpicker",
            theme: "default",
            themeMode: "light",
            format: "hex",
            alpha: false,
            forceAlpha: false,
            focusInput: true,
            selectInput: false
        });
    }
    function setupQrcdr(obj) {
        const debouncedContentUpdate = window.QRCdr_API.debounce(() => {
            get_content.dispatchEvent(change_event);
        }, window.QRCdr_API.defaults.updateDelay);
        const debouncedStyleUpdate = window.QRCdr_API.debounce(() => {
            get_style.dispatchEvent(change_event);
        }, window.QRCdr_API.defaults.updateDelay);
        const maxls = obj.querySelectorAll("[maxlength]");
        maxls.forEach(maxl => {
            maxLength(maxl);
        });
        const sliders = obj.querySelectorAll(".qrcdr-slider");
        sliders.forEach(slider => {
            rangeSlider(slider);
        });
        initColorPickers();
        const collapse_controls = obj.querySelectorAll('*[data-qrcdr-toggle="collapse"]');
        collapse_controls.forEach(collapse_control => {
            collapseCheckbox(obj, collapse_control, false);
        });
        const updateBtns = obj.querySelectorAll(".update-qrcode");
        updateBtns.forEach(updateBtn => {
            updateBtn.addEventListener("click", function() {
                if (event.defaultPrevented || event.cancelBubble) {
                    return;
                }
                updateQr(obj);
            });
        });
        const saveBtns = obj.querySelectorAll(".save-qrcode");
        saveBtns.forEach(saveBtn => {
            saveBtn.addEventListener("click", function() {
                saveCode();
            });
        });
        const closestWrapper = obj.closest(".qrcdr-wrapper");
        const holdresult = obj.querySelector(".holdresult");
        const preloader = obj.querySelector(".qrcdr-preloader");
        const get_content = obj.querySelector(".send-qrcdr-content");
        const get_style = obj.querySelector(".send-qrcdr-style");
        const resultholder = obj.querySelector(".resultholder");
        const myToastEl = closestWrapper.querySelector(".qrcdr_alert_placeholder");
        const alert_placeholder = myToastEl.querySelector(".toast-body");
        const myToast = bsqrcdr.Toast.getOrCreateInstance(myToastEl);
        const linksholder = obj.querySelector(".linksholder");
        const image_croppers = obj.querySelectorAll(".qrcdr-image-crop");
        if (typeof window.qrcdrProHasAdvancedButtonsLogic === "undefined") {
            if (get_content && get_style) {
                get_content.addEventListener("change", function() {
                    if (get_content.value.length) {
                        updateBtns.forEach(updateBtn => {
                            updateBtn.disabled = false;
                        });
                        saveBtns.forEach(saveBtn => {
                            saveBtn.disabled = true;
                        });
                        linksholder.innerHTML = "";
                    }
                });
                get_style.addEventListener("change", function() {
                    if (get_content.value.length) {
                        updateBtns.forEach(updateBtn => {
                            updateBtn.disabled = false;
                        });
                        saveBtns.forEach(saveBtn => {
                            saveBtn.disabled = true;
                        });
                        linksholder.innerHTML = "";
                    }
                });
            }
        }
        loadGeolocator();
        updateTabs(obj);
        initContentInputs(obj);
        initStyleInputs(obj);
        image_croppers.forEach(image_cropper => {
            if (image_cropper.dataset.initialized === "true") {
                return;
            }
            initCropper(image_cropper);
            image_cropper.dataset.initialized = "true";
        });
        function syncSectionJSON(section_el, hidden_input, section_name = null) {
            if (!section_el) {
                return;
            }
            let data = {};
            try {
                if (hidden_input.value) {
                    data = JSON.parse(hidden_input.value);
                }
            } catch (e) {
                data = {};
            }
            const inputs = section_el.querySelectorAll("input:not(.nopreview), textarea:not(.nopreview), select:not(.nopreview)");
            inputs.forEach(input => {
                if (!input.name) return;
                if (input.type === "radio" || input.type === "checkbox") {
                    if (input.checked) {
                        data[input.name] = input.value;
                    } else {
                        if (input.type === "checkbox") {
                            delete data[input.name];
                        }
                    }
                    return;
                }
                data[input.name] = input.value;
            });
            if (section_name) data.section = section_name;
            const sortedData = Object.keys(data).sort().reduce((acc, key) => {
                acc[key] = data[key];
                return acc;
            }, {});
            hidden_input.value = JSON.stringify(sortedData);
        }
        function initCropper(image_cropper) {
            if (!image_cropper) {
                return false;
            }
            const imageeditor = image_cropper.querySelector(".qrcdr-image-editor");
            const removebg = image_cropper.querySelector(".qrcdr-remove-bg-image");
            const exportbg = image_cropper.querySelector(".qrcdr-export-bg-image");
            const cropinput = image_cropper.querySelector(".qrcdr-image-input");
            const imagefield = image_cropper.querySelector(".qrcdr-bg-image");
            const selectbg = image_cropper.querySelector(".qrcdr-select-image-btn");
            const image_preview = selectbg.querySelector("img");
            const default_image_btn = image_preview.src;
            var croppie = new Croppie(imageeditor, {
                viewport: {
                    width: 100,
                    height: 100,
                    type: "square"
                },
                boundary: {
                    width: 150,
                    height: 150
                },
                mouseWheelZoom: false
            });
            cropinput.addEventListener("change", function(event) {
                const file = event.target.files[0];
                if (!file) {
                    return;
                }
                const reader = new FileReader;
                reader.onload = () => {
                    imageeditor.classList.remove("d-none");
                    croppie.bind({
                        url: reader.result
                    });
                    exportbg.classList.remove("d-none");
                };
                reader.onerror = () => {
                    console.log("Error reading the file. Please try again.");
                    removebg.classList.add("d-none");
                    exportbg.classList.add("d-none");
                    imageeditor.classList.add("d-none");
                };
                reader.readAsDataURL(file);
            });
            image_preview.addEventListener("click", function() {
                cropinput.click();
            });
            exportbg.addEventListener("click", function() {
                croppie.result("base64").then(function(imageData) {
                    image_preview.src = imageData;
                    imagefield.value = imageData;
                    removebg.classList.remove("d-none");
                    imagefield.dispatchEvent(input_event);
                });
            });
            removebg.addEventListener("click", function() {
                removebg.classList.add("d-none");
                exportbg.classList.add("d-none");
                imageeditor.classList.add("d-none");
                imagefield.value = "";
                imagefield.dispatchEvent(input_event);
                image_preview.src = default_image_btn;
            });
        }
        function collapseCheckbox(obj, collapse_control, reverse = false) {
            let checkbox = collapse_control;
            if (collapse_control.type !== "checkbox") {
                checkbox = collapse_control.querySelector('input[type="checkbox"]');
            }
            if (!checkbox) {
                console.warn("collapseCheckbox: Nessun checkbox trovato per", collapse_control);
                return;
            }
            const targetSelector = collapse_control.dataset.qrcdrTarget || checkbox.dataset.qrcdrTarget;
            if (!targetSelector) return;
            const collapses = obj.querySelectorAll(targetSelector);
            const syncCollapse = () => {
                const isChecked = checkbox.checked;
                const shouldOpen = reverse ? !isChecked : isChecked;
                collapses.forEach(collapse => {
                    if (shouldOpen) {
                        collapse.classList.add("open");
                    } else {
                        collapse.classList.remove("open");
                    }
                });
            };
            syncCollapse();
            checkbox.addEventListener("change", syncCollapse);
        }
        function updateTabs(obj) {
            const features_nav = obj.querySelector(".qrcdr-features");
            const step_nav = obj.querySelector(".qrcdr-step-nav");
            const resizemap_btn = obj.querySelector(".qrcdr-resize-map");
            if (step_nav) {
                const steplinks = step_nav.querySelectorAll(".nav-link");
                steplinks.forEach(steplink => {
                    steplink.addEventListener("shown.bs.tab", event => {
                        if (resizemap_btn) {
                            resizemap_btn.click();
                        }
                    });
                });
            }
            const tablinks = features_nav ? features_nav.querySelectorAll(".nav-link") : [];
            tablinks.forEach(tablink => {
                tablink.addEventListener("show.bs.tab", event => {
                    if (typeof window.qrcdrProHasAdvancedButtonsLogic !== "undefined") return;
                    const tab = obj.querySelector(tablink.dataset.bsTarget);
                    if (tab) {
                        const forminputs = tab.querySelectorAll("input:not(.nopreview), textarea:not(.nopreview), select:not(.nopreview)");
                        forminputs.forEach(forminput => {
                            forminput.value = "";
                            if (forminput.type == "checkbox") {
                                forminput.checked = false;
                            }
                        });
                    }
                });
                tablink.addEventListener("shown.bs.tab", event => {
                    if (typeof window.qrcdrProHasAdvancedButtonsLogic !== "undefined") return;
                    const tab = obj.querySelector(tablink.dataset.bsTarget);
                    if (tab) {
                        if (get_content.value.length) {
                            const getinputs = JSON.parse(get_content.value);
                            const content_section = getinputs.section;
                            if (tab.dataset.qrcdrSection == content_section) {
                                Object.keys(getinputs).forEach(key => {
                                    const input = tab.querySelector('*[name="' + key + '"]');
                                    if (input) {
                                        input.value = getinputs[key];
                                    }
                                });
                            }
                        }
                    }
                });
            });
            if (location.hash) {
                const hash = location.href.split("#");
                var findtab = features_nav ? features_nav.querySelector('.nav-link[data-bs-target="#' + hash[1] + '"]') : null;
                if (findtab) {
                    bsqrcdr.Tab.getOrCreateInstance(findtab).show();
                }
            }
        }
        function printIt(url) {
            var infopanel = "";
            var win = window.open("about:blank", "_new");
            win.document.open();
            win.document.write('<html><head></head><body onload="window.print()" onafterprint="window.close()"><img src="' + url + '"/>' + infopanel + "</body></html>");
            win.document.close();
        }
        function saveCode() {
            if (!holdresult.value.length) {
                return false;
            }
            saveBtns.forEach(saveBtn => {
                saveBtn.disabled = true;
            });
            preloader.classList.add("qrcdr-active");
            let contentVal = get_content.value;
            let styleVal = get_style.value;
            let styleObj = {};
            if (styleVal && styleVal.trim() !== "") {
                try {
                    styleObj = JSON.parse(styleVal);
                } catch (e) {
                    console.error("Failed to parse style JSON:", e);
                    preloader.classList.remove("qrcdr-active");
                    saveBtns.forEach(saveBtn => {
                        saveBtn.disabled = false;
                    });
                    alert("Error in style data.");
                    return;
                }
            }
            const formData = new FormData;
            formData.append("action", "qrcdr_svg");
            formData.append("qrcdr_nonce", QRCDR.nonce);
            formData.append("content", contentVal);
            if (styleObj.bg_image && styleObj.bg_image.startsWith("data:")) {
                const blob = b64toBlob(styleObj.bg_image, "image/png");
                formData.append("qrcdr_bg_image", blob, "bg_image.png");
                styleObj.bg_image = "__FILE_UPLOAD__";
            }
            if (styleObj.optionlogo && typeof styleObj.optionlogo === "string" && styleObj.optionlogo.startsWith("data:")) {
                let type = "image/png";
                let ext = "png";
                if (styleObj.optionlogo.indexOf("image/svg+xml") > -1) {
                    type = "image/svg+xml";
                    ext = "svg";
                }
                const blob = b64toBlob(styleObj.optionlogo, type);
                formData.append("qrcdr_custom_logo", blob, "custom_logo." + ext);
                styleObj.optionlogo = "__FILE_UPLOAD__";
            }
            let svgContentToSend = JSON.parse(holdresult.value).content;
            if (formData.has("qrcdr_bg_image")) {
                const currentBase64BG = JSON.parse(get_style.value).bg_image;
                if (currentBase64BG && currentBase64BG.startsWith("data:")) {
                    svgContentToSend = svgContentToSend.split(currentBase64BG).join("__FILE_BG_UPLOAD__");
                }
            }
            if (formData.has("qrcdr_custom_logo")) {
                const currentBase64Logo = JSON.parse(get_style.value).optionlogo;
                if (currentBase64Logo && currentBase64Logo.startsWith("data:")) {
                    svgContentToSend = svgContentToSend.split(currentBase64Logo).join("__FILE_LOGO_UPLOAD__");
                }
            }
            formData.append("content", svgContentToSend);
            formData.append("basename", JSON.parse(holdresult.value).basename);
            var xhttp = new XMLHttpRequest;
            xhttp.onreadystatechange = function() {
                if (xhttp.readyState == 4) {
                    if (xhttp.status == 200) {
                        if (xhttp.response) {
                            var getdata = JSON.parse(xhttp.response);
                            if (!getdata.success) {
                                alert_placeholder.innerHTML = getdata.message;
                                myToast.show();
                                saveBtns.forEach(saveBtn => {
                                    saveBtn.disabled = false;
                                });
                            } else {
                                let downloadlinks = '<button type="button" class="btn btn-default svgtopng" data-url="' + getdata.data.url + '" data-path="' + getdata.data.filedir + '" data-basename="' + getdata.data.basename + '">' + pngIcon + "</button>";
                                downloadlinks += '<a class="d-none preload-png" href="#">' + loadIcon + "</a>";
                                downloadlinks += '<a class="serve-png d-none" href="' + getdata.data.filedir + "/" + getdata.data.basename + '.png" download="' + getdata.data.basename + '.png">PNG</a>';
                                downloadlinks += '<a class="btn btn-default serve-svg" href="' + getdata.data.filedir + "/" + getdata.data.basename + '.svg" download="' + getdata.data.basename + '.svg">' + svgIcon + "</a>";
                                const nopdfValue = resultholder.dataset.nopdf;
                                if (nopdfValue === "false" || nopdfValue === "0" || nopdfValue === "") {
                                    if (getdata.data.pdf_base_url && getdata.data.pdf_nonce) {
                                        const prettyDownloadUrl = getdata.data.pdf_base_url + "?_wpnonce=" + getdata.data.pdf_nonce;
                                        downloadlinks += '<a target="_blank" class="btn btn-default" href="' + prettyDownloadUrl + '">' + pdfIcon + "</a>";
                                    }
                                }
                                downloadlinks += '<button type="button" class="btn btn-default qrcdr-print">' + printIcon + "</button>";
                                linksholder.innerHTML = downloadlinks;
                                saveBtns.forEach(saveBtn => {
                                    saveBtn.disabled = true;
                                });
                                linksholder.querySelector(".qrcdr-print").addEventListener("click", function() {
                                    printIt(getdata.data.filedir + "/" + getdata.data.basename + ".svg");
                                });
                                createPng(linksholder);
                            }
                        }
                    }
                    preloader.classList.remove("qrcdr-active");
                }
            };
            xhttp.ontimeout = e => {
                console.log("Timeout");
            };
            xhttp.open("POST", QRCDR.ajax_url, true);
            xhttp.send(formData);
        }
        function createPng(linksholder) {
            const svgtopng = linksholder.querySelector(".svgtopng");
            const servePng = linksholder.querySelector(".serve-png");
            const fake = linksholder.querySelector(".preload-png");
            svgtopng.addEventListener("click", function() {
                const filename = servePng.download;
                svgtopng.dataset.basename;
                const svg_url = svgtopng.dataset.url;
                const filepath = svgtopng.dataset.path;
                svgtopng.classList.add("d-none");
                fake.classList.remove("d-none");
                const newImg = new Image;
                newImg.crossOrigin = "Anonymous";
                newImg.onload = function() {
                    const canva = document.createElement("canvas");
                    const ctx = canva.getContext("2d");
                    setTimeout(function() {
                        var newImgW = newImg.width * 2;
                        var newImgH = newImg.height * 2;
                        canva.width = newImgW;
                        canva.height = newImgH;
                        ctx.drawImage(newImg, 0, 0, newImgW, newImgH);
                        var dataURL = canva.toDataURL();
                        var xhttp = new XMLHttpRequest;
                        xhttp.onreadystatechange = function() {
                            if (xhttp.readyState == 4) {
                                if (xhttp.status == 200) {
                                    const result = JSON.parse(xhttp.response);
                                    if (result.error) {
                                        alert_placeholder.innerHTML = result.error;
                                        resultholder.innerHTML = '<img src="' + result.placeholder + '">';
                                        myToast.show();
                                    } else {
                                        servePng.click();
                                    }
                                }
                                svgtopng.classList.remove("d-none");
                                fake.classList.add("d-none");
                                preloader.classList.remove("qrcdr-active");
                            }
                        };
                        xhttp.ontimeout = e => {
                            console.log("Timeout");
                        };
                        const formData = new FormData;
                        formData.append("action", "qrcdr_png");
                        formData.append("qrcdr_nonce", QRCDR.nonce);
                        formData.append("imgdata", dataURL);
                        formData.append("filename", filename);
                        formData.append("filepath", filepath);
                        xhttp.open("POST", QRCDR.ajax_url, true);
                        xhttp.send(formData);
                    }, window.QRCdr_API.defaults.uiDelay);
                };
                newImg.src = svg_url + "?t=" + Date.now();
            });
        }
        function updateQr(obj) {
            debouncedStyleUpdate.cancel();
            debouncedContentUpdate.cancel();
            const style_el = obj.querySelector(".qrcdr-options-section");
            const content_pane = obj.querySelector(".qrcdr-features-section .tab-pane.active");
            if (style_el) syncSectionJSON(style_el, get_style);
            if (content_pane) syncSectionJSON(content_pane, get_content, content_pane.dataset.qrcdrSection);
            updateBtns.forEach(btn => btn.disabled = true);
            saveBtns.forEach(btn => btn.disabled = true);
            if (get_content && get_style) {
                preloader.classList.add("qrcdr-active");
                resultholder.dataset.nopdf = false;
                linksholder.innerHTML = "";
                let styleObj = JSON.parse(get_style.value);
                let localBgImage = null, localCustomLogo = null;
                if (styleObj.bg_image?.startsWith("data:")) {
                    localBgImage = styleObj.bg_image;
                    styleObj.bg_image = "__BG_PLACEHOLDER__";
                }
                if (styleObj.optionlogo && typeof styleObj.optionlogo === "string" && styleObj.optionlogo.startsWith("data:")) {
                    localCustomLogo = styleObj.optionlogo;
                    styleObj.optionlogo = "__LOGO_PLACEHOLDER__";
                }
                var xhttp = new XMLHttpRequest;
                xhttp.onreadystatechange = function() {
                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                        const response = JSON.parse(xhttp.response);
                        const result = response.data;
                        if (response.success) {
                            let svgContent = result.content;
                            if (localBgImage) svgContent = svgContent.replace('href="__BG_PLACEHOLDER__"', 'href="' + localBgImage + '"');
                            if (localCustomLogo) svgContent = svgContent.replace('href="__LOGO_PLACEHOLDER__"', 'href="' + localCustomLogo + '"');
                            holdresult.value = JSON.stringify({
                                basename: result.basename,
                                content: svgContent,
                                nopdf: result.nopdf
                            });
                            resultholder.innerHTML = svgContent;
                            resultholder.dataset.nopdf = result.nopdf;
                            saveBtns.forEach(btn => btn.disabled = false);
                        } else {
                            alert_placeholder.innerHTML = response.data.error || "Error";
                            resultholder.innerHTML = '<img src="' + result.placeholder + '">';
                            myToast.show();
                        }
                        preloader.classList.remove("qrcdr-active");
                    }
                };
                const formData = new FormData;
                formData.append("action", "qrcdr_process");
                formData.append("qrcdr_nonce", QRCDR.nonce);
                formData.append("content", get_content.value);
                formData.append("style", JSON.stringify(styleObj));
                xhttp.open("POST", QRCDR.ajax_url, true);
                xhttp.send(formData);
            }
        }
        function initContentInputs(obj) {
            const section_el = obj.querySelector(".qrcdr-features-section");
            if (!section_el) return;
            section_el.addEventListener("input", function(e) {
                const pane = e.target.closest(".tab-pane");
                if (!pane) return;
                syncSectionJSON(pane, get_content, pane.dataset.qrcdrSection);
                if (typeof window.qrcdrProHasAdvancedButtonsLogic !== "undefined") return;
                debouncedContentUpdate();
            });
        }
        function initStyleInputs(obj) {
            const section_el = obj.querySelector(".qrcdr-options-section");
            if (!section_el) return;
            section_el.addEventListener("input", handleStyleChange);
            section_el.addEventListener("change", handleStyleChange);
            function handleStyleChange(e) {
                if (e.target.classList.contains("nopreview")) return;
                syncSectionJSON(section_el, get_style);
                if (typeof window.qrcdrProHasAdvancedButtonsLogic !== "undefined") return;
                debouncedStyleUpdate();
            }
        }
        const upmarkers = obj.querySelectorAll(".qrcdr-upmarker");
        upmarkers.forEach(upmarker => {
            initUpmarker(upmarker);
        });
        function initUpmarker(upwrapper) {
            const upmarker = upwrapper.querySelector('input[type="file"]');
            const upselect = upwrapper.querySelector('input[type="radio"]');
            upmarker.addEventListener("click", function(e) {
                upselect.checked = true;
            });
            upmarker.addEventListener("change", function(e) {
                if (!upmarker.files[0]) {
                    return;
                }
                upmarker.classList.remove("is-invalid");
                if (upmarker.files[0].type.match("image.*")) {
                    const file = upmarker.files[0];
                    const newimg = new Image;
                    newimg.crossOrigin = "Anonymous";
                    const reader = new FileReader;
                    let isSvg = file.type.indexOf("svg") > 0 ? "svg" : "no";
                    reader.onload = function(e) {
                        const out = document.createElement("img");
                        out.classList.add("user_watermark");
                        out.src = e.target.result;
                        const logolabels = upwrapper.querySelectorAll(".logoselecta label");
                        logolabels.forEach(logolabel => {
                            logolabel.classList.remove("active");
                            const logoinput = logolabel.querySelector("input");
                            if (logoinput) {
                                logoinput.checked = false;
                            }
                        });
                        const hold_custom_watermark = upwrapper.querySelector(".hold-custom-watermark");
                        if (hold_custom_watermark) {
                            hold_custom_watermark.innerHTML = "";
                            hold_custom_watermark.appendChild(out);
                        }
                        const customlogo_input = upwrapper.querySelector(".custom-watermark-input");
                        const customImage = upwrapper.querySelector(".hold-custom-watermark img");
                        customlogo_input.value = e.target.result;
                        customlogo_input.checked = true;
                        if (isSvg === "svg") {
                            customlogo_input.dispatchEvent(change_event);
                        }
                        newimg.onload = function() {
                            var canvas = document.createElement("canvas");
                            var MAX_WIDTH = 400;
                            var MAX_HEIGHT = 400;
                            var width = this.width;
                            var height = this.height;
                            if (isSvg !== "svg") {
                                if (width == 0 || height == 0) {
                                    upmarker.classList.add("is-invalid");
                                    if (logolabels.length > 0) {
                                        logolabels[logolabels.length - 1].remove();
                                    }
                                    return false;
                                }
                                if (width > height) {
                                    height *= MAX_WIDTH / width;
                                    width = MAX_WIDTH;
                                } else {
                                    width *= MAX_HEIGHT / height;
                                    height = MAX_HEIGHT;
                                }
                                canvas.width = width;
                                canvas.height = height;
                                var ctx = canvas.getContext("2d");
                                ctx.drawImage(newimg, 0, 0, width, height);
                                var dataurl = canvas.toDataURL();
                                customImage.src = dataurl;
                                customlogo_input.value = dataurl;
                                customlogo_input.dispatchEvent(change_event);
                            }
                        };
                        newimg.src = customImage.src;
                    };
                    reader.readAsDataURL(file);
                } else {
                    upmarker.classList.add("is-invalid");
                }
            });
        }
        const datepickers = obj.querySelectorAll(".qrcdr-datepicker");
        datepickers.forEach(datepicker => {
            const targetInput = obj.querySelector(datepicker.dataset.timestamp);
            if (!targetInput) return;
            const fpInstance = Flatpickr(datepicker, {
                enableTime: true,
                dateFormat: "m/d/Y H:i",
                onChange: function(selectedDates, dateStr, instance) {
                    if (selectedDates.length > 0) {
                        const timestamp = Math.round(selectedDates[0].getTime() / 1e3);
                        if (targetInput.value !== timestamp.toString()) {
                            targetInput.value = timestamp;
                            targetInput.dispatchEvent(input_event);
                        }
                    }
                },
                onClose: function(selectedDates, dateStr, instance) {
                    if (dateStr === "") {
                        if (targetInput.value !== "") {
                            targetInput.value = "";
                            targetInput.dispatchEvent(input_event);
                        }
                    }
                }
            });
            targetInput.addEventListener("change", function() {
                const timestamp = parseInt(targetInput.value, 10);
                if (timestamp && !isNaN(timestamp)) {
                    const dateObject = new Date(timestamp * 1e3);
                    fpInstance.setDate(dateObject, false);
                } else {
                    fpInstance.clear(false);
                }
            });
        });
        function loadGeolocator() {
            const locationtab = obj.querySelector(".qrcdr-location");
            if (!locationtab) {
                return false;
            }
            const qrcdrmap = locationtab.querySelector(".qrcdr-map");
            const getlat = locationtab.querySelector(".qrcdr-get-lat");
            const getlon = locationtab.querySelector(".qrcdr-get-lon");
            if (typeof ol_qrcdr === "undefined" || ol_qrcdr === null) {
                console.log("WARNING: Custom OpenLayers Library (ol_qrcdr) not loaded");
                return false;
            }
            const initialCoords = ol_qrcdr.proj.fromLonLat([ parseFloat(qrcdrmap.dataset.lng), parseFloat(qrcdrmap.dataset.lat) ]);
            class Drag extends ol_qrcdr.interaction.Pointer {
                constructor() {
                    super({
                        handleDownEvent: handleDownEvent,
                        handleDragEvent: handleDragEvent,
                        handleUpEvent: handleUpEvent
                    });
                    this.coordinate_ = null;
                    this.feature_ = null;
                    this.cursor_ = "pointer";
                    this.previousCursor_ = undefined;
                }
            }
            function handleDownEvent(evt) {
                const map = evt.map;
                const feature = map.forEachFeatureAtPixel(evt.pixel, function(feature) {
                    return feature;
                });
                if (feature) {
                    this.coordinate_ = evt.coordinate;
                    this.feature_ = feature;
                }
                return !!feature;
            }
            function handleDragEvent(evt) {
                const deltaX = evt.coordinate[0] - this.coordinate_[0];
                const deltaY = evt.coordinate[1] - this.coordinate_[1];
                const geometry = this.feature_.getGeometry();
                geometry.translate(deltaX, deltaY);
                this.coordinate_[0] = evt.coordinate[0];
                this.coordinate_[1] = evt.coordinate[1];
            }
            function handleUpEvent(evt) {
                if (this.feature_) {
                    const geometry = this.feature_.getGeometry();
                    const coordinates = geometry.getCoordinates();
                    const lonlat = ol_qrcdr.proj.toLonLat(coordinates);
                    getlat.value = lonlat[1];
                    getlon.value = lonlat[0];
                    const input_event = new Event("input", {
                        bubbles: true
                    });
                    getlat.dispatchEvent(input_event);
                    getlon.dispatchEvent(input_event);
                }
                this.coordinate_ = null;
                this.feature_ = null;
                return false;
            }
            const pointFeature = new ol_qrcdr.Feature(new ol_qrcdr.geom.Point(initialCoords));
            const markerStyle = new ol_qrcdr.style.Style({
                image: new ol_qrcdr.style.Circle({
                    radius: 16,
                    fill: new ol_qrcdr.style.Fill({
                        color: "rgba(255, 177, 8,0.5)"
                    }),
                    stroke: new ol_qrcdr.style.Stroke({
                        color: "#ffffff",
                        width: 2
                    })
                })
            });
            pointFeature.setStyle(markerStyle);
            const vectorSource = new ol_qrcdr.source.Vector({
                features: [ pointFeature ]
            });
            const vectorLayer = new ol_qrcdr.layer.Vector({
                source: vectorSource,
                zIndex: 999
            });
            const view = new ol_qrcdr.View({
                center: initialCoords,
                zoom: 4
            });
            qrcdrmap.innerHTML = "";
            const map = new ol_qrcdr.Map({
                target: qrcdrmap,
                view: view,
                layers: [ new ol_qrcdr.layer.Tile({
                    source: new ol_qrcdr.source.OSM
                }), vectorLayer ],
                interactions: ol_qrcdr.interaction.defaults({
                    mouseWheelZoom: false
                }).extend([ new Drag ]),
                controls: ol_qrcdr.control.defaults({
                    attributionOptions: {
                        collapsible: true
                    }
                })
            });
            map.on("pointermove", function(evt) {
                const pixel = map.getEventPixel(evt.originalEvent);
                const hit = map.hasFeatureAtPixel(pixel);
                map.getTargetElement().style.cursor = hit ? "grab" : "";
            });
            function updateMarkerPosition(lat, lng, zoomLevel = null) {
                const newcoord = ol_qrcdr.proj.fromLonLat([ parseFloat(lng), parseFloat(lat) ]);
                pointFeature.getGeometry().setCoordinates(newcoord);
                view.setCenter(newcoord);
                if (zoomLevel) {
                    view.setZoom(zoomLevel);
                }
            }
            var georesponse = function(res) {
                const response = JSON.parse(res);
                if (response && response.length > 0) {
                    var lat = response[0].lat;
                    var lon = response[0].lon;
                    getlat.value = lat;
                    getlon.value = lon;
                    const input_event = new Event("input", {
                        bubbles: true
                    });
                    getlat.dispatchEvent(input_event);
                    getlon.dispatchEvent(input_event);
                    updateMarkerPosition(lat, lon, 15);
                }
            };
            function updatePosistionFromInput() {
                const lat = getlat.value.length ? getlat.value : qrcdrmap.dataset.lat;
                const lng = getlon.value.length ? getlon.value : qrcdrmap.dataset.lng;
                updateMarkerPosition(lat, lng);
            }
            const getcoords = locationtab.querySelector(".qrcdr-get-coordinates");
            getcoords.addEventListener("click", function() {
                const address = locationtab.querySelector(".qrcdr-set-address");
                if (address && address.value.length > 3) {
                    getcoords.classList.add("d-none");
                    let xhttp = new XMLHttpRequest;
                    xhttp.onreadystatechange = function() {
                        if (xhttp.readyState == 4) {
                            if (xhttp.status == 200) {
                                georesponse(xhttp.response);
                            }
                            getcoords.classList.remove("d-none");
                        }
                    };
                    xhttp.ontimeout = e => {
                        console.log("Timeout");
                    };
                    xhttp.open("GET", "https://nominatim.openstreetmap.org/search?q=" + encodeURIComponent(address.value) + "&format=json", true);
                    xhttp.send();
                }
            });
            const resizemap_btn = document.createElement("div");
            resizemap_btn.classList.add("qrcdr-resize-map");
            resizemap_btn.addEventListener("click", function() {
                updatePosistionFromInput();
                map.updateSize();
            });
            locationtab.appendChild(resizemap_btn);
        }
        function updateScrollNavUI(component) {
            const container = component.querySelector(".qrcdr-scrolling-nav");
            const wrapper = component.querySelector(".qrcdr-scrolling-nav-wrapper");
            if (!container || !wrapper) return;
            setTimeout(() => {
                const isOverflowing = container.scrollWidth > container.clientWidth;
                if (!isOverflowing) {
                    wrapper.classList.remove("show-left-fade", "show-right-fade", "show-left-btn", "show-right-btn");
                    return;
                }
                const scrollLeft = container.scrollLeft;
                const maxScroll = container.scrollWidth - container.clientWidth;
                wrapper.classList.toggle("show-left-fade", scrollLeft > 0);
                wrapper.classList.toggle("show-left-btn", scrollLeft > 0);
                wrapper.classList.toggle("show-right-fade", scrollLeft < maxScroll - 1);
                wrapper.classList.toggle("show-right-btn", scrollLeft < maxScroll - 1);
            }, window.QRCdr_API.defaults.uiDelay);
        }
        function setupSingleScrollNav(component) {
            const container = component.querySelector(".qrcdr-scrolling-nav");
            const leftBtn = component.querySelector(".qrcdr-scroll-btn-left");
            const rightBtn = component.querySelector(".qrcdr-scroll-btn-right");
            if (!container || !leftBtn || !rightBtn) {
                console.error("Struttura HTML del componente scroll nav incompleta.", component);
                return;
            }
            component.dataset.scrollNavInitialized = "true";
            const SCROLL_AMOUNT = 300;
            rightBtn.addEventListener("click", () => {
                container.scrollBy({
                    left: SCROLL_AMOUNT,
                    behavior: "smooth"
                });
            });
            leftBtn.addEventListener("click", () => {
                container.scrollBy({
                    left: -SCROLL_AMOUNT,
                    behavior: "smooth"
                });
            });
            container.addEventListener("scroll", () => updateScrollNavUI(component), {
                passive: true
            });
            window.addEventListener("resize", () => updateScrollNavUI(component));
        }
        function initializeVisibleScrollingNavs(scope = document) {
            const allNavComponents = scope.querySelectorAll(".qrcdr-scrolling-nav-component");
            allNavComponents.forEach(component => {
                const isInitialized = component.dataset.scrollNavInitialized === "true";
                const isVisible = component.getBoundingClientRect().width > 0;
                if (isVisible) {
                    if (!isInitialized) {
                        setupSingleScrollNav(component);
                    }
                    updateScrollNavUI(component);
                }
            });
        }
        initializeVisibleScrollingNavs(obj);
        function enableUpdateOnStyleChange() {
            get_style.addEventListener("change", function(e) {
                if (get_content.value.length) {
                    updateBtns.forEach(updateBtn => {
                        updateBtn.disabled = false;
                    });
                }
            });
        }
        if (typeof window.qrcdrProHasAdvancedButtonsLogic === "undefined") {
            enableUpdateOnStyleChange();
        }
        document.addEventListener("shown.bs.tab", function(event) {
            const targetPaneSelector = event.target.dataset.bsTarget || event.target.getAttribute("href");
            if (targetPaneSelector) {
                const targetPane = document.querySelector(targetPaneSelector);
                if (targetPane) {
                    initializeVisibleScrollingNavs(targetPane);
                }
            }
        }, {
            passive: true
        });
        document.addEventListener("shown.bs.collapse", function(event) {
            const targetPane = event.target;
            if (targetPane) {
                initializeVisibleScrollingNavs(targetPane);
            }
        }, {
            passive: true
        });
    }
    function init() {
        var qrcdrs = document.querySelectorAll(".qrcdr-app");
        qrcdrs.forEach(gen => {
            if (!gen.hasAttribute("data-qrcdr")) {
                gen.setAttribute("data-qrcdr", "1");
                setupQrcdr(gen);
            }
        });
    }
    const initialize = dependencies => {
        bsqrcdr = dependencies.bsqrcdr;
        Coloris = dependencies.Coloris;
        Croppie = dependencies.Croppie;
        Flatpickr = dependencies.Flatpickr;
        init();
    };
    function b64toBlob(b64Data, contentType = "", sliceSize = 512) {
        const byteCharacters = atob(b64Data.split(",")[1]);
        const byteArrays = [];
        for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
            const slice = byteCharacters.slice(offset, offset + sliceSize);
            const byteNumbers = new Array(slice.length);
            for (let i = 0; i < slice.length; i++) {
                byteNumbers[i] = slice.charCodeAt(i);
            }
            const byteArray = new Uint8Array(byteNumbers);
            byteArrays.push(byteArray);
        }
        const blob = new Blob(byteArrays, {
            type: contentType
        });
        return blob;
    }
    document.addEventListener("DOMContentLoaded", function() {
        initialize({
            Coloris: Coloris$1,
            bsqrcdr: bsqrcdr$1,
            Croppie: Croppie$1,
            Flatpickr: flatpickr
        });
    });
    window.QRCdr_API = {
        bsqrcdr: bsqrcdr$1,
        Coloris: Coloris$1,
        Croppie: Croppie$1,
        Flatpickr: flatpickr,
        init: initialize,
        defaults: {
            updateDelay: 500,
            uiDelay: 100,
            transitionDelay: 250
        },
        debounce: function(func, wait) {
            let timeout;
            const debounced = function(...args) {
                const context = this;
                clearTimeout(timeout);
                timeout = setTimeout(() => func.apply(context, args), wait);
            };
            debounced.cancel = function() {
                clearTimeout(timeout);
                timeout = null;
            };
            return debounced;
        },
        throttle: function(func, limit) {
            let inThrottle;
            return function(...args) {
                const context = this;
                if (!inThrottle) {
                    func.apply(context, args);
                    inThrottle = true;
                    setTimeout(() => inThrottle = false, limit);
                }
            };
        },
        resetForm: function(container, silent = true) {
            if (!container) return;
            container.querySelectorAll("input, select, textarea").forEach(input => {
                if (input.classList.contains("nopreview")) return;
                const type = input.type;
                const tagName = input.tagName.toLowerCase();
                const defaultValue = input.getAttribute("data-qrcdr-default");
                const hasDefault = defaultValue !== null;
                if (type === "checkbox" || type === "radio") {
                    if (hasDefault) {
                        if (type === "checkbox") {
                            input.checked = defaultValue === "true" || defaultValue === "1" || defaultValue === "checked";
                        } else if (type === "radio") {
                            input.checked = defaultValue === input.value;
                        }
                    } else {
                        input.checked = false;
                    }
                } else if (tagName === "select") {
                    if (hasDefault) {
                        input.value = defaultValue;
                    } else {
                        input.selectedIndex = 0;
                    }
                } else {
                    input.value = hasDefault ? defaultValue : "";
                }
                if (!silent) {
                    input.dispatchEvent(new Event("input", {
                        bubbles: true
                    }));
                    input.dispatchEvent(new Event("change", {
                        bubbles: true
                    }));
                }
            });
        }
    };
})();
