'use strict';
/*!
* Copyright (c) Anaconda, Inc., and Bokeh Contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of Anaconda nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
(function(root, factory) {
factory(root["Bokeh"], "3.6.0");
})(this, function(Bokeh, version) {
let define;
return (function(modules, entry, aliases, externals) {
const bokeh = typeof Bokeh !== "undefined" ? (version != null ? Bokeh[version] : Bokeh) : null;
if (bokeh != null) {
return bokeh.register_plugin(modules, entry, aliases);
} else {
throw new Error("Cannot find Bokeh" + (version != null ? " " + version : "") + ". You have to load it prior to loading plugins.");
}
})
({
598: /* models/widgets/main.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
const tslib_1 = require(1) /* tslib */;
const Widgets = tslib_1.__importStar(require(599) /* ./index */);
exports.Widgets = Widgets;
const base_1 = require(7) /* ../../base */;
(0, base_1.register_models)(Widgets);
},
599: /* models/widgets/index.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
const tslib_1 = require(1) /* tslib */;
var abstract_button_1 = require(600) /* ./abstract_button */;
__esExport("AbstractButton", abstract_button_1.AbstractButton);
var autocomplete_input_1 = require(604) /* ./autocomplete_input */;
__esExport("AutocompleteInput", autocomplete_input_1.AutocompleteInput);
var button_1 = require(610) /* ./button */;
__esExport("Button", button_1.Button);
var checkbox_button_group_1 = require(611) /* ./checkbox_button_group */;
__esExport("CheckboxButtonGroup", checkbox_button_group_1.CheckboxButtonGroup);
var checkbox_group_1 = require(614) /* ./checkbox_group */;
__esExport("CheckboxGroup", checkbox_group_1.CheckboxGroup);
var checkbox_1 = require(617) /* ./checkbox */;
__esExport("Checkbox", checkbox_1.Checkbox);
var color_picker_1 = require(619) /* ./color_picker */;
__esExport("ColorPicker", color_picker_1.ColorPicker);
var date_picker_1 = require(620) /* ./date_picker */;
__esExport("DatePicker", date_picker_1.DatePicker);
var date_range_picker_1 = require(632) /* ./date_range_picker */;
__esExport("DateRangePicker", date_range_picker_1.DateRangePicker);
var datetime_picker_1 = require(633) /* ./datetime_picker */;
__esExport("DatetimePicker", datetime_picker_1.DatetimePicker);
var datetime_range_picker_1 = require(635) /* ./datetime_range_picker */;
__esExport("DatetimeRangePicker", datetime_range_picker_1.DatetimeRangePicker);
var div_1 = require(636) /* ./div */;
__esExport("Div", div_1.Div);
var dropdown_1 = require(639) /* ./dropdown */;
__esExport("Dropdown", dropdown_1.Dropdown);
var file_input_1 = require(641) /* ./file_input */;
__esExport("FileInput", file_input_1.FileInput);
var help_button_1 = require(642) /* ./help_button */;
__esExport("HelpButton", help_button_1.HelpButton);
var input_widget_1 = require(607) /* ./input_widget */;
__esExport("InputWidget", input_widget_1.InputWidget);
var markup_1 = require(637) /* ./markup */;
__esExport("Markup", markup_1.Markup);
var multi_choice_1 = require(643) /* ./multi_choice */;
__esExport("MultiChoice", multi_choice_1.MultiChoice);
var multiselect_1 = require(646) /* ./multiselect */;
__esExport("MultiSelect", multiselect_1.MultiSelect);
var multiple_date_picker_1 = require(647) /* ./multiple_date_picker */;
__esExport("MultipleDatePicker", multiple_date_picker_1.MultipleDatePicker);
var multiple_datetime_picker_1 = require(648) /* ./multiple_datetime_picker */;
__esExport("MultipleDatetimePicker", multiple_datetime_picker_1.MultipleDatetimePicker);
var numeric_input_1 = require(649) /* ./numeric_input */;
__esExport("NumericInput", numeric_input_1.NumericInput);
var palette_select_1 = require(650) /* ./palette_select */;
__esExport("PaletteSelect", palette_select_1.PaletteSelect);
var paragraph_1 = require(656) /* ./paragraph */;
__esExport("Paragraph", paragraph_1.Paragraph);
var password_input_1 = require(657) /* ./password_input */;
__esExport("PasswordInput", password_input_1.PasswordInput);
var pretext_1 = require(659) /* ./pretext */;
__esExport("PreText", pretext_1.PreText);
var radio_button_group_1 = require(660) /* ./radio_button_group */;
__esExport("RadioButtonGroup", radio_button_group_1.RadioButtonGroup);
var radio_group_1 = require(661) /* ./radio_group */;
__esExport("RadioGroup", radio_group_1.RadioGroup);
var select_1 = require(662) /* ./select */;
__esExport("Select", select_1.Select);
var spinner_1 = require(663) /* ./spinner */;
__esExport("Spinner", spinner_1.Spinner);
var switch_1 = require(664) /* ./switch */;
__esExport("Switch", switch_1.Switch);
var textarea_input_1 = require(666) /* ./textarea_input */;
__esExport("TextAreaInput", textarea_input_1.TextAreaInput);
var text_input_1 = require(605) /* ./text_input */;
__esExport("TextInput", text_input_1.TextInput);
var time_picker_1 = require(667) /* ./time_picker */;
__esExport("TimePicker", time_picker_1.TimePicker);
var toggle_1 = require(668) /* ./toggle */;
__esExport("Toggle", toggle_1.Toggle);
var widget_1 = require(707) /* ./widget */;
__esExport("Widget", widget_1.Widget);
tslib_1.__exportStar(require(669) /* ./sliders */, exports);
},
600: /* models/widgets/abstract_button.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const enums_1 = require(20) /* ../../core/enums */;
const dom_1 = require(63) /* ../../core/dom */;
const build_views_1 = require(56) /* ../../core/build_views */;
const types_1 = require(8) /* ../../core/util/types */;
const control_1 = require(601) /* ./control */;
const dom_node_1 = require(125) /* ../dom/dom_node */;
const text_1 = require(321) /* ../dom/text */;
const icon_1 = require(487) /* ../ui/icons/icon */;
const buttons_css_1 = tslib_1.__importStar(require(603) /* ../../styles/buttons.css */), buttons = buttons_css_1;
class AbstractButtonView extends control_1.ControlView {
*controls() {
yield this.button_el;
}
*children() {
yield* super.children();
if (this.label_view != null) {
yield this.label_view;
}
if (this.icon_view != null) {
yield this.icon_view;
}
}
async lazy_initialize() {
await super.lazy_initialize();
await this._rebuild_label();
await this._rebuild_icon();
}
async _rebuild_label() {
this.label_view?.remove();
const label = (() => {
const { label } = this.model;
return (0, types_1.isString)(label) ? new text_1.Text({ content: label }) : label;
})();
this.label_view = await this.owner.build_view(label, this);
}
async _rebuild_icon() {
this.icon_view?.remove();
const { icon } = this.model;
if (icon != null) {
this.icon_view = await (0, build_views_1.build_view)(icon, { parent: this });
}
}
connect_signals() {
super.connect_signals();
const { label, icon, button_type, disabled } = this.model.properties;
this.on_transitive_change(label, async () => {
await this._rebuild_label();
this.render();
});
this.on_transitive_change(icon, async () => {
await this._rebuild_icon();
this.render();
});
this.on_change([button_type, disabled], () => {
this.render();
});
}
remove() {
this.label_view?.remove();
this.icon_view?.remove();
super.remove();
}
stylesheets() {
return [...super.stylesheets(), buttons_css_1.default];
}
_render_button(...children) {
return (0, dom_1.button)({
type: "button",
disabled: this.model.disabled,
class: [buttons.btn, buttons[`btn_${this.model.button_type}`]],
}, ...children);
}
render() {
super.render();
this.label_view?.render();
this.button_el = this._render_button(this.label_view?.el);
this.button_el.addEventListener("click", () => this.click());
if (this.icon_view != null) {
const separator = this.model.label != "" ? (0, dom_1.nbsp)() : (0, dom_1.text)("");
(0, dom_1.prepend)(this.button_el, this.icon_view.el, separator);
this.icon_view.render();
}
this.group_el = (0, dom_1.div)({ class: buttons.btn_group }, this.button_el);
this.shadow_el.append(this.group_el);
}
click() { }
}
exports.AbstractButtonView = AbstractButtonView;
AbstractButtonView.__name__ = "AbstractButtonView";
class AbstractButton extends control_1.Control {
constructor(attrs) {
super(attrs);
}
}
exports.AbstractButton = AbstractButton;
_a = AbstractButton;
AbstractButton.__name__ = "AbstractButton";
(() => {
_a.define(({ Str, Ref, Or, Nullable }) => ({
label: [Or(Ref(dom_node_1.DOMNode), Str), "Button"],
icon: [Nullable(Ref(icon_1.Icon)), null],
button_type: [enums_1.ButtonType, "default"],
}));
})();
},
601: /* models/widgets/control.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
const widget_1 = require(707) /* ./widget */;
const dom_1 = require(63) /* ../../core/dom */;
class ControlView extends widget_1.WidgetView {
connect_signals() {
super.connect_signals();
this.connect(this.disabled, (disabled) => {
for (const el of this.controls()) {
(0, dom_1.toggle_attribute)(el, "disabled", disabled);
}
});
}
}
exports.ControlView = ControlView;
ControlView.__name__ = "ControlView";
class Control extends widget_1.Widget {
constructor(attrs) {
super(attrs);
}
}
exports.Control = Control;
Control.__name__ = "Control";
},
707: /* models/widgets/widget.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const layout_dom_1 = require(406) /* ../layouts/layout_dom */;
const providers_1 = require(182) /* ../text/providers */;
class WidgetView extends layout_dom_1.LayoutDOMView {
get child_models() {
return [];
}
get provider() {
return providers_1.default_provider;
}
async lazy_initialize() {
await super.lazy_initialize();
if (this.provider.status == "not_started") {
await this.provider.fetch();
}
}
_after_layout() {
super._after_layout();
if (this.provider.status == "loading") {
this._has_finished = false;
}
}
process_tex(text) {
if (this.provider.MathJax == null) {
return text;
}
const tex_parts = this.provider.MathJax.find_tex(text);
const processed_text = [];
let last_index = 0;
for (const part of tex_parts) {
processed_text.push(text.slice(last_index, part.start.n));
processed_text.push(this.provider.MathJax.tex2svg(part.math, { display: part.display }).outerHTML);
last_index = part.end.n;
}
if (last_index < text.length) {
processed_text.push(text.slice(last_index));
}
return processed_text.join("");
}
contains_tex_string(text) {
if (this.provider.MathJax == null) {
return false;
}
return this.provider.MathJax.find_tex(text).length > 0;
}
;
}
exports.WidgetView = WidgetView;
WidgetView.__name__ = "WidgetView";
class Widget extends layout_dom_1.LayoutDOM {
constructor(attrs) {
super(attrs);
}
}
exports.Widget = Widget;
_a = Widget;
Widget.__name__ = "Widget";
(() => {
_a.override({
margin: 5,
});
})();
},
603: /* styles/buttons.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.btn = "bk-btn";
exports.active = "bk-active";
exports.btn_default = "bk-btn-default";
exports.btn_primary = "bk-btn-primary";
exports.btn_success = "bk-btn-success";
exports.btn_warning = "bk-btn-warning";
exports.btn_danger = "bk-btn-danger";
exports.btn_light = "bk-btn-light";
exports.btn_group = "bk-btn-group";
exports.vertical = "bk-vertical";
exports.horizontal = "bk-horizontal";
exports.dropdown_toggle = "bk-dropdown-toggle";
exports.default = `.bk-btn,::file-selector-button{height:100%;display:inline-block;text-align:center;vertical-align:middle;white-space:nowrap;cursor:pointer;padding:var(--padding-vertical) var(--padding-horizontal);font-size:var(--font-size);border:1px solid transparent;border-radius:var(--border-radius);outline:0;outline-offset:-5px;user-select:none;-webkit-user-select:none;}.bk-btn:hover,::file-selector-button:hover,.bk-btn:focus,::file-selector-button:focus{text-decoration:none;}.bk-btn:active,::file-selector-button:active,.bk-active.bk-btn,.bk-active::file-selector-button{background-image:none;box-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);}.bk-btn[disabled]{cursor:not-allowed;pointer-events:none;opacity:0.65;box-shadow:none;}::file-selector-button{color:#333;background-color:#fff;border-color:#ccc;}::file-selector-button:hover{background-color:#f5f5f5;border-color:#b8b8b8;}.bk-active::file-selector-button{background-color:#ebebeb;border-color:#adadad;}::file-selector-button[disabled],::file-selector-button[disabled]:hover,::file-selector-button[disabled]:focus,::file-selector-button[disabled]:active,.bk-active::file-selector-button[disabled]{background-color:#e6e6e6;border-color:#ccc;}::file-selector-button:focus,::file-selector-button:active{outline:1px dotted #ccc;}.bk-btn-default{color:#333;background-color:#fff;border-color:#ccc;}.bk-btn-default:hover{background-color:#f5f5f5;border-color:#b8b8b8;}.bk-active.bk-btn-default{background-color:#ebebeb;border-color:#adadad;}.bk-btn-default[disabled],.bk-btn-default[disabled]:hover,.bk-btn-default[disabled]:focus,.bk-btn-default[disabled]:active,.bk-active.bk-btn-default[disabled]{background-color:#e6e6e6;border-color:#ccc;}.bk-btn-default:focus,.bk-btn-default:active{outline:1px dotted #ccc;}.bk-btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd;}.bk-btn-primary:hover{background-color:#3681c1;border-color:#2c699e;}.bk-active.bk-btn-primary{background-color:#3276b1;border-color:#285e8e;}.bk-btn-primary[disabled],.bk-btn-primary[disabled]:hover,.bk-btn-primary[disabled]:focus,.bk-btn-primary[disabled]:active,.bk-active.bk-btn-primary[disabled]{background-color:#506f89;border-color:#357ebd;}.bk-btn-primary:focus,.bk-btn-primary:active{outline:1px dotted #ccc;}.bk-btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c;}.bk-btn-success:hover{background-color:#4eb24e;border-color:#409240;}.bk-active.bk-btn-success{background-color:#47a447;border-color:#398439;}.bk-btn-success[disabled],.bk-btn-success[disabled]:hover,.bk-btn-success[disabled]:focus,.bk-btn-success[disabled]:active,.bk-active.bk-btn-success[disabled]{background-color:#667b66;border-color:#4cae4c;}.bk-btn-success:focus,.bk-btn-success:active{outline:1px dotted #ccc;}.bk-btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236;}.bk-btn-warning:hover{background-color:#eea43b;border-color:#e89014;}.bk-active.bk-btn-warning{background-color:#ed9c28;border-color:#d58512;}.bk-btn-warning[disabled],.bk-btn-warning[disabled]:hover,.bk-btn-warning[disabled]:focus,.bk-btn-warning[disabled]:active,.bk-active.bk-btn-warning[disabled]{background-color:#c89143;border-color:#eea236;}.bk-btn-warning:focus,.bk-btn-warning:active{outline:1px dotted #ccc;}.bk-btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a;}.bk-btn-danger:hover{background-color:#d5433e;border-color:#bd2d29;}.bk-active.bk-btn-danger{background-color:#d2322d;border-color:#ac2925;}.bk-btn-danger[disabled],.bk-btn-danger[disabled]:hover,.bk-btn-danger[disabled]:focus,.bk-btn-danger[disabled]:active,.bk-active.bk-btn-danger[disabled]{background-color:#a55350;border-color:#d43f3a;}.bk-btn-danger:focus,.bk-btn-danger:active{outline:1px dotted #ccc;}.bk-btn-light{color:#333;background-color:#fff;border-color:#ccc;border-color:transparent;}.bk-btn-light:hover{background-color:#f5f5f5;border-color:#b8b8b8;}.bk-active.bk-btn-light{background-color:#ebebeb;border-color:#adadad;}.bk-btn-light[disabled],.bk-btn-light[disabled]:hover,.bk-btn-light[disabled]:focus,.bk-btn-light[disabled]:active,.bk-active.bk-btn-light[disabled]{background-color:#e6e6e6;border-color:#ccc;}.bk-btn-light:focus,.bk-btn-light:active{outline:1px dotted #ccc;}.bk-btn-group{height:100%;display:flex;flex-wrap:nowrap;align-items:center;}.bk-btn-group:not(.bk-vertical),.bk-btn-group.bk-horizontal{flex-direction:row;}.bk-btn-group.bk-vertical{flex-direction:column;}.bk-btn-group > .bk-btn{flex-grow:1;}.bk-btn-group:not(.bk-vertical) > .bk-btn + .bk-btn{margin-left:-1px;}.bk-btn-group.bk-vertical > .bk-btn + .bk-btn{margin-top:-1px;}.bk-btn-group:not(.bk-vertical) > .bk-btn:first-child:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0;}.bk-btn-group.bk-vertical > .bk-btn:first-child:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0;}.bk-btn-group:not(.bk-vertical) > .bk-btn:not(:first-child):last-child{border-bottom-left-radius:0;border-top-left-radius:0;}.bk-btn-group.bk-vertical > .bk-btn:not(:first-child):last-child{border-top-left-radius:0;border-top-right-radius:0;}.bk-btn-group > .bk-btn:not(:first-child):not(:last-child){border-radius:0;}.bk-btn-group.bk-vertical > .bk-btn{width:100%;}.bk-btn-group .bk-dropdown-toggle{flex:0 0 0;padding:var(--padding-vertical) calc(var(--padding-horizontal)/2);}`;
},
604: /* models/widgets/autocomplete_input.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const text_input_1 = require(605) /* ./text_input */;
const dom_1 = require(63) /* ../../core/dom */;
const iterator_1 = require(34) /* ../../core/util/iterator */;
const math_1 = require(11) /* ../../core/util/math */;
const kinds_1 = require(21) /* ../../core/kinds */;
const dropdown_css_1 = tslib_1.__importStar(require(609) /* ../../styles/dropdown.css */), dropdown = dropdown_css_1;
const SearchStrategy = (0, kinds_1.Enum)("starts_with", "includes");
class AutocompleteInputView extends text_input_1.TextInputView {
constructor() {
super(...arguments);
this._open = false;
this._last_value = "";
this._hover_index = 0;
}
stylesheets() {
return [...super.stylesheets(), dropdown_css_1.default];
}
render() {
super.render();
this.input_el.addEventListener("focusin", () => this._toggle_menu());
this.menu = (0, dom_1.div)({ class: [dropdown.menu, dropdown.below] });
this.menu.addEventListener("click", (event) => this._menu_click(event));
this.menu.addEventListener("mouseover", (event) => this._menu_hover(event));
this.shadow_el.appendChild(this.menu);
(0, dom_1.undisplay)(this.menu);
}
change_input() {
if (this._open && this.menu.children.length > 0) {
this.model.value = this.menu.children[this._hover_index].textContent;
this.input_el.focus();
this._hide_menu();
}
else if (!this.model.restrict) {
super.change_input();
}
}
_update_completions(completions) {
(0, dom_1.empty)(this.menu);
const { max_completions } = this.model;
const selected_completions = max_completions != null ? (0, iterator_1.take)(completions, max_completions) : completions;
for (const text of selected_completions) {
const item = (0, dom_1.div)(text);
this.menu.append(item);
}
this.menu.firstElementChild?.classList.add(dropdown.active);
}
compute_completions(value) {
const norm_function = (() => {
const { case_sensitive } = this.model;
return case_sensitive ? (t) => t : (t) => t.toLowerCase();
})();
const search_function = (() => {
switch (this.model.search_strategy) {
case "starts_with": return (t, v) => t.startsWith(v);
case "includes": return (t, v) => t.includes(v);
}
})();
const normalized_value = norm_function(value);
const completions = [];
for (const text of this.model.completions) {
const normalized_text = norm_function(text);
if (search_function(normalized_text, normalized_value)) {
completions.push(text);
}
}
return completions;
}
_toggle_menu() {
const { value } = this.input_el;
if (value.length < this.model.min_characters) {
this._hide_menu();
return;
}
const completions = this.compute_completions(value);
this._update_completions(completions);
if (completions.length == 0) {
this._hide_menu();
}
else {
this._show_menu();
}
}
_show_menu() {
if (!this._open) {
this._open = true;
this._hover_index = 0;
this._last_value = this.model.value;
(0, dom_1.display)(this.menu);
const listener = (event) => {
if (!event.composedPath().includes(this.el)) {
document.removeEventListener("click", listener);
this._hide_menu();
}
};
document.addEventListener("click", listener);
}
}
_hide_menu() {
if (this._open) {
this._open = false;
(0, dom_1.undisplay)(this.menu);
}
}
_menu_click(event) {
if (event.target != event.currentTarget && event.target instanceof Element) {
this.model.value = event.target.textContent;
this.input_el.focus();
this._hide_menu();
}
}
_menu_hover(event) {
if (event.target != event.currentTarget && event.target instanceof Element) {
for (let i = 0; i < this.menu.children.length; i++) {
if (this.menu.children[i].textContent == event.target.textContent) {
this._bump_hover(i);
break;
}
}
}
}
_bump_hover(new_index) {
const n_children = this.menu.children.length;
if (this._open && n_children > 0) {
this.menu.children[this._hover_index].classList.remove(dropdown.active);
this._hover_index = (0, math_1.clamp)(new_index, 0, n_children - 1);
this.menu.children[this._hover_index].classList.add(dropdown.active);
}
}
_keyup(event) {
super._keyup(event);
switch (event.key) {
case "Enter": {
this.change_input();
break;
}
case "Escape": {
this._hide_menu();
break;
}
case "ArrowUp": {
this._bump_hover(this._hover_index - 1);
break;
}
case "ArrowDown": {
this._bump_hover(this._hover_index + 1);
break;
}
default:
this._toggle_menu();
}
}
}
exports.AutocompleteInputView = AutocompleteInputView;
AutocompleteInputView.__name__ = "AutocompleteInputView";
class AutocompleteInput extends text_input_1.TextInput {
constructor(attrs) {
super(attrs);
}
}
exports.AutocompleteInput = AutocompleteInput;
_a = AutocompleteInput;
AutocompleteInput.__name__ = "AutocompleteInput";
(() => {
_a.prototype.default_view = AutocompleteInputView;
_a.define(({ Bool, Int, Str, List, NonNegative, Positive, Nullable }) => ({
completions: [List(Str), []],
min_characters: [NonNegative(Int), 2],
max_completions: [Nullable(Positive(Int)), null],
case_sensitive: [Bool, true],
restrict: [Bool, true],
search_strategy: [SearchStrategy, "starts_with"],
}));
})();
},
605: /* models/widgets/text_input.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const text_like_input_1 = require(606) /* ./text_like_input */;
const dom_1 = require(63) /* ../../core/dom */;
const bokeh_events_1 = require(53) /* ../../core/bokeh_events */;
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
class TextInputView extends text_like_input_1.TextLikeInputView {
connect_signals() {
super.connect_signals();
const { prefix, suffix } = this.model.properties;
this.on_change([prefix, suffix], () => this.render());
}
_render_input() {
this.input_el = (0, dom_1.input)({ type: "text", class: inputs.input });
const { prefix, suffix } = this.model;
const prefix_el = prefix != null ? (0, dom_1.div)({ class: "bk-input-prefix" }, prefix) : null;
const suffix_el = suffix != null ? (0, dom_1.div)({ class: "bk-input-suffix" }, suffix) : null;
const container_el = (0, dom_1.div)({ class: "bk-input-container" }, prefix_el, this.input_el, suffix_el);
return container_el;
}
render() {
super.render();
this.input_el.addEventListener("keyup", (event) => this._keyup(event));
}
_keyup(event) {
if (event.key == "Enter" && !event.shiftKey && !event.ctrlKey && !event.altKey) {
this.model.trigger_event(new bokeh_events_1.ValueSubmit(this.input_el.value));
}
}
}
exports.TextInputView = TextInputView;
TextInputView.__name__ = "TextInputView";
class TextInput extends text_like_input_1.TextLikeInput {
constructor(attrs) {
super(attrs);
}
}
exports.TextInput = TextInput;
_a = TextInput;
TextInput.__name__ = "TextInput";
(() => {
_a.prototype.default_view = TextInputView;
_a.define(({ Str, Nullable }) => ({
prefix: [Nullable(Str), null],
suffix: [Nullable(Str), null],
}));
})();
},
606: /* models/widgets/text_like_input.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const input_widget_1 = require(607) /* ./input_widget */;
class TextLikeInputView extends input_widget_1.InputWidgetView {
connect_signals() {
super.connect_signals();
this.connect(this.model.properties.value.change, () => this.input_el.value = this.model.value);
this.connect(this.model.properties.value_input.change, () => this.input_el.value = this.model.value_input);
this.connect(this.model.properties.disabled.change, () => this.input_el.disabled = this.model.disabled);
this.connect(this.model.properties.placeholder.change, () => this.input_el.placeholder = this.model.placeholder);
this.connect(this.model.properties.max_length.change, () => {
const { max_length } = this.model;
if (max_length != null) {
this.input_el.maxLength = max_length;
}
else {
this.input_el.removeAttribute("maxLength");
}
});
}
render() {
super.render();
const { input_el } = this;
input_el.value = this.model.value;
input_el.disabled = this.model.disabled;
input_el.placeholder = this.model.placeholder;
if (this.model.max_length != null) {
input_el.maxLength = this.model.max_length;
}
input_el.addEventListener("change", () => this.change_input());
input_el.addEventListener("input", () => this.change_input_value());
}
change_input() {
this.model.value = this.input_el.value;
super.change_input();
}
change_input_value() {
this.model.value_input = this.input_el.value;
super.change_input();
}
}
exports.TextLikeInputView = TextLikeInputView;
TextLikeInputView.__name__ = "TextLikeInputView";
class TextLikeInput extends input_widget_1.InputWidget {
constructor(attrs) {
super(attrs);
}
}
exports.TextLikeInput = TextLikeInput;
_a = TextLikeInput;
TextLikeInput.__name__ = "TextLikeInput";
(() => {
_a.define(({ Int, Str, Nullable }) => ({
value: [Str, ""],
value_input: [Str, ""],
placeholder: [Str, ""],
max_length: [Nullable(Int), null],
}));
})();
},
607: /* models/widgets/input_widget.js */ function _(require, module, exports, __esModule, __esExport) {
var _a, _b;
__esModule();
const tslib_1 = require(1) /* tslib */;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ClearInput_1;
const control_1 = require(601) /* ./control */;
const tooltip_1 = require(420) /* ../ui/tooltip */;
const html_1 = require(408) /* ../dom/html */;
const types_1 = require(8) /* ../../core/util/types */;
const build_views_1 = require(56) /* ../../core/build_views */;
const dom_1 = require(63) /* ../../core/dom */;
const view_1 = require(58) /* ../../core/view */;
const bokeh_events_1 = require(53) /* ../../core/bokeh_events */;
const inputs_css_1 = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */), inputs = inputs_css_1;
const icons_css_1 = tslib_1.__importDefault(require(123) /* ../../styles/icons.css */);
let ClearInput = (_a = class ClearInput extends bokeh_events_1.ModelEvent {
constructor(model) {
super();
this.model = model;
this.origin = model;
}
static from_values(values) {
const { model } = values;
return new ClearInput_1(model);
}
},
(() => {
ClearInput_1 = _a;
})(),
_a.__name__ = "ClearInput",
_a);
exports.ClearInput = ClearInput;
exports.ClearInput = ClearInput = ClearInput_1 = __decorate([
(0, bokeh_events_1.server_event)("clear_input")
], ClearInput);
class InputWidgetView extends control_1.ControlView {
constructor() {
super(...arguments);
this.description = null;
this.desc_el = null;
}
*controls() {
yield this.input_el;
}
*children() {
yield* super.children();
const { title, description } = this;
if (title instanceof view_1.View) {
yield title;
}
if (description instanceof view_1.View) {
yield description;
}
}
async lazy_initialize() {
await super.lazy_initialize();
await this._build_title();
await this._build_description();
}
remove() {
const { title, description } = this;
if (title instanceof view_1.View) {
title.remove();
}
if (description instanceof view_1.View) {
description.remove();
}
super.remove();
}
connect_signals() {
super.connect_signals();
const { title, description } = this.model.properties;
this.on_change(title, async () => {
await this._build_title();
this.render();
});
this.on_change(description, async () => {
await this._build_description();
this.render();
});
}
stylesheets() {
return [...super.stylesheets(), inputs_css_1.default, icons_css_1.default];
}
render() {
super.render();
this.desc_el = this._build_description_el();
this.title_el = this._build_title_el();
const input_or_container_el = this._render_input();
this.input_el.id = "input";
this.group_el = (0, dom_1.div)({ class: inputs.input_group }, this.title_el, input_or_container_el);
this.shadow_el.append(this.group_el);
}
_build_description_el() {
const { description } = this;
if (description == null) {
return null;
}
else {
const icon_el = (0, dom_1.div)({ class: inputs.icon });
const desc_el = (0, dom_1.div)({ class: inputs.description }, icon_el);
if ((0, types_1.isString)(description)) {
desc_el.title = description;
}
else {
if (description.model.target == "auto") {
description.target = desc_el;
}
let persistent = false;
const toggle = (visible) => {
description.model.setv({
visible,
closable: persistent,
});
icon_el.classList.toggle(inputs.opaque, visible && persistent);
};
this.on_change(description.model.properties.visible, () => {
const { visible } = description.model;
if (!visible) {
persistent = false;
}
toggle(visible);
});
desc_el.addEventListener("mouseenter", () => {
toggle(true);
});
desc_el.addEventListener("mouseleave", () => {
if (!persistent) {
toggle(false);
}
});
document.addEventListener("mousedown", (event) => {
const path = event.composedPath();
if (path.includes(description.el)) {
return;
}
else if (path.includes(desc_el)) {
persistent = !persistent;
toggle(persistent);
}
else {
persistent = false;
toggle(false);
}
});
window.addEventListener("blur", () => {
persistent = false;
toggle(false);
});
}
return desc_el;
}
}
async _build_title() {
const { title } = this.model;
if (title instanceof html_1.HTML) {
this.title = await (0, build_views_1.build_view)(title, { parent: this });
}
else {
this.title = title;
}
}
async _build_description() {
const { description } = this.model;
if (description instanceof tooltip_1.Tooltip) {
this.description = await (0, build_views_1.build_view)(description, { parent: this });
}
else {
this.description = description;
}
}
_build_title_el() {
const { title } = this;
const content = (() => {
if (title instanceof html_1.HTMLView) {
title.render();
return title.el;
}
else {
return title;
}
})();
const display = title == "" ? "none" : "";
return (0, dom_1.label)({ for: "input", style: { display } }, content, this.desc_el);
}
change_input() { }
}
exports.InputWidgetView = InputWidgetView;
InputWidgetView.__name__ = "InputWidgetView";
class InputWidget extends control_1.Control {
constructor(attrs) {
super(attrs);
}
}
exports.InputWidget = InputWidget;
_b = InputWidget;
InputWidget.__name__ = "InputWidget";
(() => {
_b.define(({ Str, Nullable, Or, Ref }) => ({
title: [Or(Str, Ref(html_1.HTML)), ""],
description: [Nullable(Or(Str, Ref(tooltip_1.Tooltip))), null],
}));
})();
},
608: /* styles/widgets/inputs.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.input = "bk-input";
exports.disabled = "bk-disabled";
exports.input_container = "bk-input-container";
exports.input_prefix = "bk-input-prefix";
exports.input_suffix = "bk-input-suffix";
exports.input_group = "bk-input-group";
exports.inline = "bk-inline";
exports.spin_wrapper = "bk-spin-wrapper";
exports.spin_btn = "bk-spin-btn";
exports.spin_btn_up = "bk-spin-btn-up";
exports.spin_btn_down = "bk-spin-btn-down";
exports.description = "bk-description";
exports.icon = "bk-icon";
exports.opaque = "bk-opaque";
exports.default = `:host{--input-min-height:calc(var(--line-height-computed) + 2*var(--padding-vertical) + 2px);}.bk-input{position:relative;display:inline-block;width:100%;flex-grow:1;min-height:var(--input-min-height);padding:0 var(--padding-horizontal);background-color:#fff;border:1px solid #ccc;border-radius:var(--border-radius);resize:none;}.bk-input:focus{border-color:#66afe9;outline:0;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);}.bk-input::placeholder,.bk-input:-ms-input-placeholder,.bk-input::-moz-placeholder,.bk-input::-webkit-input-placeholder{color:#999;opacity:1;}.bk-input[disabled],.bk-input.bk-disabled{cursor:not-allowed;background-color:#eee;opacity:1;}.bk-input-container{width:100%;height:100%;display:flex;flex-direction:row;flex-wrap:nowrap;}.bk-input-container .bk-input-prefix,.bk-input-container .bk-input-suffix{display:flex;align-items:center;flex:0 1 0;border:1px solid #ccc;border-radius:var(--border-radius);padding:0 var(--padding-horizontal);background-color:#e6e6e6;}.bk-input-container .bk-input-prefix{border-right:none;border-top-right-radius:0;border-bottom-right-radius:0;}.bk-input-container .bk-input-suffix{border-left:none;border-top-left-radius:0;border-bottom-left-radius:0;}.bk-input-container .bk-input{flex:1 0 0;}.bk-input-container .bk-input:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0;}.bk-input-container .bk-input:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0;}input[type=file].bk-input{padding-left:0;}input[type=file]::file-selector-button{box-sizing:inherit;font-family:inherit;font-size:inherit;line-height:inherit;}select:not([multiple]).bk-input,select:not([size]).bk-input{height:auto;appearance:none;-webkit-appearance:none;background-image:url('data:image/svg+xml;utf8,');background-position:right 0.5em center;background-size:8px 6px;background-repeat:no-repeat;padding-right:calc(var(--padding-horizontal) + 8px);}option{padding:0;}select[multiple].bk-input,select[size].bk-input,textarea.bk-input{height:auto;}.bk-input-group{position:relative;width:100%;height:100%;display:inline-flex;flex-wrap:nowrap;align-items:start;flex-direction:column;white-space:nowrap;}.bk-input-group.bk-inline{flex-direction:row;}.bk-input-group.bk-inline > *:not(:first-child){margin-left:5px;}.bk-input-group > .bk-spin-wrapper{display:inherit;width:inherit;height:inherit;position:relative;overflow:hidden;padding:0;vertical-align:middle;}.bk-input-group > .bk-spin-wrapper input{padding-right:20px;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn{position:absolute;display:block;height:50%;min-height:0;min-width:0;width:30px;padding:0;margin:0;right:0;border:none;background:none;cursor:pointer;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn:before{content:"";display:inline-block;transform:translateY(-50%);border-left:5px solid transparent;border-right:5px solid transparent;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-up{top:0;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-up:before{border-bottom:5px solid black;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-up:disabled:before{border-bottom-color:grey;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-down{bottom:0;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-down:before{border-top:5px solid black;}.bk-input-group > .bk-spin-wrapper > .bk-spin-btn.bk-spin-btn-down:disabled:before{border-top-color:grey;}.bk-description{position:relative;display:inline-block;margin-left:0.25em;vertical-align:middle;margin-top:-2px;cursor:pointer;}.bk-description > .bk-icon{opacity:0.5;width:18px;height:18px;background-color:gray;mask-image:var(--bokeh-icon-help);mask-size:contain;mask-repeat:no-repeat;-webkit-mask-image:var(--bokeh-icon-help);-webkit-mask-size:contain;-webkit-mask-repeat:no-repeat;}label:hover > .bk-description > .bk-icon,.bk-icon.bk-opaque{opacity:1;}`;
},
609: /* styles/dropdown.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.menu = "bk-menu";
exports.above = "bk-above";
exports.below = "bk-below";
exports.divider = "bk-divider";
exports.active = "bk-active";
exports.default = `:host{position:relative;}.bk-menu{position:absolute;left:0;width:100%;z-index:var(--bokeh-top-level);cursor:pointer;font-size:var(--font-size);background-color:#fff;border:1px solid #ccc;border-radius:var(--border-radius);box-shadow:0 6px 12px rgba(0, 0, 0, 0.175);}.bk-menu.bk-above{bottom:100%;}.bk-menu.bk-below{top:100%;}.bk-menu > .bk-divider{height:1px;margin:calc(var(--line-height-computed)/2 - 1px) 0;overflow:hidden;background-color:#e5e5e5;}.bk-menu > :not(.bk-divider){padding:var(--padding-vertical) var(--padding-horizontal);}.bk-menu > :not(.bk-divider):hover,.bk-menu > :not(.bk-divider).bk-active{background-color:#e6e6e6;}`;
},
610: /* models/widgets/button.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const abstract_button_1 = require(600) /* ./abstract_button */;
const bokeh_events_1 = require(53) /* ../../core/bokeh_events */;
class ButtonView extends abstract_button_1.AbstractButtonView {
click() {
this.model.trigger_event(new bokeh_events_1.ButtonClick());
super.click();
}
}
exports.ButtonView = ButtonView;
ButtonView.__name__ = "ButtonView";
class Button extends abstract_button_1.AbstractButton {
constructor(attrs) {
super(attrs);
}
on_click(callback) {
this.on_event(bokeh_events_1.ButtonClick, callback);
}
}
exports.Button = Button;
_a = Button;
Button.__name__ = "Button";
(() => {
_a.prototype.default_view = ButtonView;
_a.override({
label: "Button",
});
})();
},
611: /* models/widgets/checkbox_button_group.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const toggle_button_group_1 = require(612) /* ./toggle_button_group */;
const buttons = tslib_1.__importStar(require(603) /* ../../styles/buttons.css */);
class CheckboxButtonGroupView extends toggle_button_group_1.ToggleButtonGroupView {
get active() {
return new Set(this.model.active);
}
change_active(i) {
const { active } = this;
active.has(i) ? active.delete(i) : active.add(i);
this.model.active = [...active].sort();
}
_update_active() {
const { active } = this;
this._buttons.forEach((button_el, i) => {
button_el.classList.toggle(buttons.active, active.has(i));
});
}
}
exports.CheckboxButtonGroupView = CheckboxButtonGroupView;
CheckboxButtonGroupView.__name__ = "CheckboxButtonGroupView";
class CheckboxButtonGroup extends toggle_button_group_1.ToggleButtonGroup {
constructor(attrs) {
super(attrs);
}
}
exports.CheckboxButtonGroup = CheckboxButtonGroup;
_a = CheckboxButtonGroup;
CheckboxButtonGroup.__name__ = "CheckboxButtonGroup";
(() => {
_a.prototype.default_view = CheckboxButtonGroupView;
_a.define(({ Int, List }) => ({
active: [List(Int), []],
}));
})();
},
612: /* models/widgets/toggle_button_group.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const oriented_control_1 = require(613) /* ./oriented_control */;
const bokeh_events_1 = require(53) /* ../../core/bokeh_events */;
const enums_1 = require(20) /* ../../core/enums */;
const dom_1 = require(63) /* ../../core/dom */;
const buttons_css_1 = tslib_1.__importStar(require(603) /* ../../styles/buttons.css */), buttons = buttons_css_1;
class ToggleButtonGroupView extends oriented_control_1.OrientedControlView {
*controls() {
yield* this._buttons; // TODO: HTMLButtonElement[]
}
connect_signals() {
super.connect_signals();
const p = this.model.properties;
this.on_change(p.button_type, () => this.render());
this.on_change(p.labels, () => this.render());
this.on_change(p.active, () => this._update_active());
}
stylesheets() {
return [...super.stylesheets(), buttons_css_1.default];
}
render() {
super.render();
this._buttons = this.model.labels.map((label, i) => {
const button_el = (0, dom_1.button)({
class: [buttons.btn, buttons[`btn_${this.model.button_type}`]],
disabled: this.model.disabled,
}, label);
button_el.addEventListener("click", () => {
this.change_active(i);
this.model.trigger_event(new bokeh_events_1.ButtonClick());
});
return button_el;
});
this._update_active();
const orient = this.model.orientation == "horizontal" ? buttons.horizontal : buttons.vertical;
const group = (0, dom_1.div)({ class: [buttons.btn_group, orient] }, this._buttons);
this.shadow_el.appendChild(group);
}
}
exports.ToggleButtonGroupView = ToggleButtonGroupView;
ToggleButtonGroupView.__name__ = "ToggleButtonGroupView";
class ToggleButtonGroup extends oriented_control_1.OrientedControl {
constructor(attrs) {
super(attrs);
}
}
exports.ToggleButtonGroup = ToggleButtonGroup;
_a = ToggleButtonGroup;
ToggleButtonGroup.__name__ = "ToggleButtonGroup";
(() => {
_a.define(({ Str, List }) => ({
labels: [List(Str), []],
button_type: [enums_1.ButtonType, "default"],
}));
})();
},
613: /* models/widgets/oriented_control.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const control_1 = require(601) /* ./control */;
const enums_1 = require(20) /* ../../core/enums */;
class OrientedControlView extends control_1.ControlView {
}
exports.OrientedControlView = OrientedControlView;
OrientedControlView.__name__ = "OrientedControlView";
class OrientedControl extends control_1.Control {
constructor(attrs) {
super(attrs);
}
}
exports.OrientedControl = OrientedControl;
_a = OrientedControl;
OrientedControl.__name__ = "OrientedControl";
(() => {
_a.define(() => ({
orientation: [enums_1.Orientation, "horizontal"],
}));
})();
},
614: /* models/widgets/checkbox_group.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const toggle_input_group_1 = require(615) /* ./toggle_input_group */;
const dom_1 = require(63) /* ../../core/dom */;
const array_1 = require(10) /* ../../core/util/array */;
const iterator_1 = require(34) /* ../../core/util/iterator */;
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
class CheckboxGroupView extends toggle_input_group_1.ToggleInputGroupView {
get active() {
return new Set(this.model.active);
}
connect_signals() {
super.connect_signals();
const { active } = this.model.properties;
this.on_change(active, () => {
const { active } = this;
for (const [input_el, i] of (0, iterator_1.enumerate)(this._inputs)) {
input_el.checked = active.has(i);
}
});
}
render() {
super.render();
const group = (0, dom_1.div)({ class: [inputs.input_group, this.model.inline ? inputs.inline : null] });
this.shadow_el.appendChild(group);
const { active, labels } = this.model;
this._inputs = [];
for (let i = 0; i < labels.length; i++) {
const checkbox = (0, dom_1.input)({ type: "checkbox", value: `${i}` });
checkbox.addEventListener("change", () => this.change_active(i));
this._inputs.push(checkbox);
if (this.model.disabled) {
checkbox.disabled = true;
}
if ((0, array_1.includes)(active, i)) {
checkbox.checked = true;
}
const label_el = (0, dom_1.label)(checkbox, (0, dom_1.span)(labels[i]));
group.appendChild(label_el);
}
}
change_active(i) {
const { active } = this;
active.has(i) ? active.delete(i) : active.add(i);
this.model.active = [...active].sort();
}
}
exports.CheckboxGroupView = CheckboxGroupView;
CheckboxGroupView.__name__ = "CheckboxGroupView";
class CheckboxGroup extends toggle_input_group_1.ToggleInputGroup {
constructor(attrs) {
super(attrs);
}
}
exports.CheckboxGroup = CheckboxGroup;
_a = CheckboxGroup;
CheckboxGroup.__name__ = "CheckboxGroup";
(() => {
_a.prototype.default_view = CheckboxGroupView;
_a.define(({ Int, List }) => ({
active: [List(Int), []],
}));
})();
},
615: /* models/widgets/toggle_input_group.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const control_1 = require(601) /* ./control */;
const inputs_css_1 = tslib_1.__importDefault(require(608) /* ../../styles/widgets/inputs.css */);
const checkbox_css_1 = tslib_1.__importDefault(require(616) /* ../../styles/widgets/checkbox.css */);
class ToggleInputGroupView extends control_1.ControlView {
*controls() {
yield* this._inputs;
}
connect_signals() {
super.connect_signals();
const { labels, inline } = this.model.properties;
this.on_change([labels, inline], () => this.render());
}
stylesheets() {
return [...super.stylesheets(), inputs_css_1.default, checkbox_css_1.default];
}
}
exports.ToggleInputGroupView = ToggleInputGroupView;
ToggleInputGroupView.__name__ = "ToggleInputGroupView";
class ToggleInputGroup extends control_1.Control {
constructor(attrs) {
super(attrs);
}
}
exports.ToggleInputGroup = ToggleInputGroup;
_a = ToggleInputGroup;
ToggleInputGroup.__name__ = "ToggleInputGroup";
(() => {
_a.define(({ Bool, Str, List }) => ({
labels: [List(Str), []],
inline: [Bool, false],
}));
})();
},
616: /* styles/widgets/checkbox.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.default = `input[type="checkbox"],input[type="radio"]{margin:0;}input[type="checkbox"] + *,input[type="radio"] + *{position:relative;top:-2px;margin-left:3px;}`;
},
617: /* models/widgets/checkbox.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const toggle_input_1 = require(618) /* ./toggle_input */;
const dom_1 = require(63) /* ../../core/dom */;
const checkbox_css_1 = tslib_1.__importDefault(require(616) /* ../../styles/widgets/checkbox.css */);
class CheckboxView extends toggle_input_1.ToggleInputView {
stylesheets() {
return [...super.stylesheets(), checkbox_css_1.default];
}
connect_signals() {
super.connect_signals();
const { label } = this.model.properties;
this.on_change(label, () => this._update_label());
}
render() {
super.render();
this.checkbox_el = (0, dom_1.input)({ type: "checkbox" });
this.label_el = (0, dom_1.span)(this.model.label);
this.checkbox_el.addEventListener("change", () => this._toggle_active());
this._update_active();
this._update_disabled();
this.shadow_el.append(this.checkbox_el, this.label_el);
}
_update_active() {
this.checkbox_el.checked = this.model.active;
}
_update_disabled() {
this.checkbox_el.toggleAttribute("disabled", this.model.disabled);
}
_update_label() {
this.label_el.textContent = this.model.label;
}
}
exports.CheckboxView = CheckboxView;
CheckboxView.__name__ = "CheckboxView";
class Checkbox extends toggle_input_1.ToggleInput {
constructor(attrs) {
super(attrs);
}
}
exports.Checkbox = Checkbox;
_a = Checkbox;
Checkbox.__name__ = "Checkbox";
(() => {
_a.prototype.default_view = CheckboxView;
_a.define(({ Str }) => ({
label: [Str, ""],
}));
})();
},
618: /* models/widgets/toggle_input.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const widget_1 = require(707) /* ./widget */;
class ToggleInputView extends widget_1.WidgetView {
connect_signals() {
super.connect_signals();
const { active, disabled } = this.model.properties;
this.on_change(active, () => this._update_active());
this.on_change(disabled, () => this._update_disabled());
}
_toggle_active() {
if (!this.model.disabled) {
this.model.active = !this.model.active;
}
}
}
exports.ToggleInputView = ToggleInputView;
ToggleInputView.__name__ = "ToggleInputView";
class ToggleInput extends widget_1.Widget {
constructor(attrs) {
super(attrs);
}
}
exports.ToggleInput = ToggleInput;
_a = ToggleInput;
ToggleInput.__name__ = "ToggleInput";
(() => {
_a.define(({ Bool }) => ({
active: [Bool, false],
}));
})();
},
619: /* models/widgets/color_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const input_widget_1 = require(607) /* ./input_widget */;
const dom_1 = require(63) /* ../../core/dom */;
const color_1 = require(22) /* ../../core/util/color */;
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
class ColorPickerView extends input_widget_1.InputWidgetView {
connect_signals() {
super.connect_signals();
this.connect(this.model.properties.name.change, () => this.input_el.name = this.model.name ?? "");
this.connect(this.model.properties.color.change, () => this.input_el.value = (0, color_1.color2hexrgb)(this.model.color));
this.connect(this.model.properties.disabled.change, () => this.input_el.disabled = this.model.disabled);
}
_render_input() {
return this.input_el = (0, dom_1.input)({
type: "color",
class: inputs.input,
name: this.model.name,
value: (0, color_1.color2hexrgb)(this.model.color),
disabled: this.model.disabled,
});
}
render() {
super.render();
this.input_el.addEventListener("change", () => this.change_input());
}
change_input() {
this.model.color = this.input_el.value;
super.change_input();
}
}
exports.ColorPickerView = ColorPickerView;
ColorPickerView.__name__ = "ColorPickerView";
class ColorPicker extends input_widget_1.InputWidget {
constructor(attrs) {
super(attrs);
}
}
exports.ColorPicker = ColorPicker;
_a = ColorPicker;
ColorPicker.__name__ = "ColorPicker";
(() => {
_a.prototype.default_view = ColorPickerView;
_a.define(({ Color }) => ({
color: [Color, "#000000"],
}));
})();
},
620: /* models/widgets/date_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const base_date_picker_1 = require(621) /* ./base_date_picker */;
const assert_1 = require(12) /* ../../core/util/assert */;
class DatePickerView extends base_date_picker_1.BaseDatePickerView {
get flatpickr_options() {
return {
...super.flatpickr_options,
mode: "single",
};
}
_on_change(selected) {
(0, assert_1.assert)(selected.length <= 1);
this.model.value = (() => {
if (selected.length == 0) {
return null;
}
else {
const [datetime] = selected;
const date = this._format_date(datetime);
return date;
}
})();
}
}
exports.DatePickerView = DatePickerView;
DatePickerView.__name__ = "DatePickerView";
class DatePicker extends base_date_picker_1.BaseDatePicker {
constructor(attrs) {
super(attrs);
}
}
exports.DatePicker = DatePicker;
_a = DatePicker;
DatePicker.__name__ = "DatePicker";
(() => {
_a.prototype.default_view = DatePickerView;
_a.define(({ Nullable }) => ({
value: [Nullable(base_date_picker_1.DateLike), null],
}));
})();
},
621: /* models/widgets/base_date_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const picker_base_1 = require(622) /* ./picker_base */;
const types_1 = require(8) /* ../../core/util/types */;
const kinds_1 = require(21) /* ../../core/kinds */;
exports.DateLike = (0, kinds_1.Or)((0, kinds_1.Ref)(Date), kinds_1.Str, kinds_1.Float);
exports.DateLikeList = (0, kinds_1.List)((0, kinds_1.Or)(exports.DateLike, (0, kinds_1.Tuple)(exports.DateLike, exports.DateLike), (0, kinds_1.Struct)({ from: exports.DateLike, to: exports.DateLike })));
class BaseDatePickerView extends picker_base_1.PickerBaseView {
_format_date(date) {
const { picker } = this;
return picker.formatDate(date, picker.config.dateFormat);
}
connect_signals() {
super.connect_signals();
const { value, min_date, max_date, disabled_dates, enabled_dates, date_format } = this.model.properties;
this.connect(value.change, () => {
const { value } = this.model;
if (value != null) {
this.picker.setDate(value);
}
else {
this.picker.clear();
}
});
this.connect(min_date.change, () => this.picker.set("minDate", this.model.min_date));
this.connect(max_date.change, () => this.picker.set("maxDate", this.model.max_date));
this.connect(disabled_dates.change, () => {
const { disabled_dates } = this.model;
this.picker.set("disable", disabled_dates != null ? this._convert_date_list(disabled_dates) : []);
});
this.connect(enabled_dates.change, () => {
const { enabled_dates } = this.model;
if (enabled_dates != null) {
this.picker.set("enable", this._convert_date_list(enabled_dates));
}
else {
// this reimplements `set()` for the `undefined` case
this.picker.config._enable = undefined;
this.picker.redraw();
this.picker.updateValue(true);
}
});
this.connect(date_format.change, () => this.picker.set("altFormat", this.model.date_format));
}
get flatpickr_options() {
const { value, min_date, max_date, disabled_dates, enabled_dates, date_format } = this.model;
const options = super.flatpickr_options;
options.altInput = true;
options.altFormat = date_format;
options.dateFormat = "Y-m-d";
if (value != null) {
options.defaultDate = value;
}
if (min_date != null) {
options.minDate = min_date;
}
if (max_date != null) {
options.maxDate = max_date;
}
if (disabled_dates != null) {
options.disable = this._convert_date_list(disabled_dates);
}
if (enabled_dates != null) {
options.enable = this._convert_date_list(enabled_dates);
}
return options;
}
_convert_date_list(value) {
const result = [];
for (const item of value) {
if ((0, types_1.isArray)(item)) {
const [from, to] = item;
result.push({ from, to });
}
else {
result.push(item);
}
}
return result;
}
}
exports.BaseDatePickerView = BaseDatePickerView;
BaseDatePickerView.__name__ = "BaseDatePickerView";
class BaseDatePicker extends picker_base_1.PickerBase {
constructor(attrs) {
super(attrs);
}
}
exports.BaseDatePicker = BaseDatePicker;
_a = BaseDatePicker;
BaseDatePicker.__name__ = "BaseDatePicker";
(() => {
_a.define(({ Nullable }) => ({
min_date: [Nullable(exports.DateLike), null],
max_date: [Nullable(exports.DateLike), null],
disabled_dates: [Nullable(exports.DateLikeList), null],
enabled_dates: [Nullable(exports.DateLikeList), null],
date_format: [kinds_1.Str, "Y-m-d"],
}));
})();
},
622: /* models/widgets/picker_base.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const flatpickr_1 = tslib_1.__importDefault(require(623) /* flatpickr */);
const input_widget_1 = require(607) /* ./input_widget */;
const dom_1 = require(63) /* ../../core/dom */;
const enums_1 = require(20) /* ../../core/enums */;
const dom_2 = require(63) /* ../../core/dom */;
const assert_1 = require(12) /* ../../core/util/assert */;
const flatpickr_css_1 = tslib_1.__importDefault(require(631) /* ../../styles/widgets/flatpickr.css */);
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
class PickerBaseView extends input_widget_1.InputWidgetView {
get picker() {
(0, assert_1.assert)(this._picker != null);
return this._picker;
}
*controls() {
yield this.picker.altInput ?? this.input_el;
}
remove() {
this._picker?.destroy();
super.remove();
}
stylesheets() {
return [...super.stylesheets(), flatpickr_css_1.default];
}
connect_signals() {
super.connect_signals();
const { inline } = this.model.properties;
this.connect(inline.change, () => this.picker.set("inline", this.model.inline));
}
get flatpickr_options() {
return {
appendTo: this.group_el,
inline: this.model.inline,
position: this._position.bind(this),
onChange: (selected) => {
this._on_change(selected);
this.change_input();
},
};
}
_render_input() {
return this.input_el = (0, dom_1.input)({ type: "text", class: inputs.input, disabled: this.model.disabled });
}
render() {
super.render();
this._picker?.destroy();
const options = this.flatpickr_options;
this._picker = (0, flatpickr_1.default)(this.input_el, options);
}
// https://github.com/flatpickr/flatpickr/pull/2362
_position(self, custom_el) {
const positionElement = custom_el ?? self._positionElement;
const calendarHeight = [...self.calendarContainer.children].reduce((acc, child) => acc + (0, dom_2.bounding_box)(child).height, 0);
const calendarWidth = self.calendarContainer.offsetWidth;
const configPos = this.model.position.split(" ");
const configPosVertical = configPos[0];
const configPosHorizontal = configPos.length > 1 ? configPos[1] : null;
// const inputBounds = positionElement.getBoundingClientRect()
const inputBounds = {
top: positionElement.offsetTop,
bottom: positionElement.offsetTop + positionElement.offsetHeight,
left: positionElement.offsetLeft,
right: positionElement.offsetLeft + positionElement.offsetWidth,
width: positionElement.offsetWidth,
};
const distanceFromBottom = window.innerHeight - inputBounds.bottom;
const showOnTop = configPosVertical === "above" ||
(configPosVertical !== "below" &&
distanceFromBottom < calendarHeight &&
inputBounds.top > calendarHeight);
// const top =
// window.scrollY +
// inputBounds.top +
// (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2)
const top = self.config.appendTo != null
? inputBounds.top +
(!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2)
: window.scrollY +
inputBounds.top +
(!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
self.calendarContainer.classList.toggle("arrowTop", !showOnTop);
self.calendarContainer.classList.toggle("arrowBottom", showOnTop);
if (self.config.inline) {
return;
}
let left = window.scrollX + inputBounds.left;
let isCenter = false;
let isRight = false;
if (configPosHorizontal === "center") {
left -= (calendarWidth - inputBounds.width) / 2;
isCenter = true;
}
else if (configPosHorizontal === "right") {
left -= calendarWidth - inputBounds.width;
isRight = true;
}
self.calendarContainer.classList.toggle("arrowLeft", !isCenter && !isRight);
self.calendarContainer.classList.toggle("arrowCenter", isCenter);
self.calendarContainer.classList.toggle("arrowRight", isRight);
const right = window.document.body.offsetWidth -
(window.scrollX + inputBounds.right);
const rightMost = left + calendarWidth > window.document.body.offsetWidth;
const centerMost = right + calendarWidth > window.document.body.offsetWidth;
self.calendarContainer.classList.toggle("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 {
const css = this.shadow_el.styleSheets[0];
const bodyWidth = window.document.body.offsetWidth;
const centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
const centerBefore = ".flatpickr-calendar.centerMost:before";
const centerAfter = ".flatpickr-calendar.centerMost:after";
const centerIndex = css.cssRules.length;
const centerStyle = `{left:${inputBounds.left}px;right:auto;}`;
self.calendarContainer.classList.toggle("rightMost", false);
self.calendarContainer.classList.toggle("centerMost", true);
css.insertRule(`${centerBefore},${centerAfter}${centerStyle}`, centerIndex);
self.calendarContainer.style.left = `${centerLeft}px`;
self.calendarContainer.style.right = "auto";
}
}
}
exports.PickerBaseView = PickerBaseView;
PickerBaseView.__name__ = "PickerBaseView";
class PickerBase extends input_widget_1.InputWidget {
constructor(attrs) {
super(attrs);
}
}
exports.PickerBase = PickerBase;
_a = PickerBase;
PickerBase.__name__ = "PickerBase";
(() => {
_a.define(({ Bool }) => {
return {
position: [enums_1.CalendarPosition, "auto"],
inline: [Bool, false],
};
});
})();
},
623: /* flatpickr/dist/esm/index.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
const tslib_1 = require(1) /* tslib */;
var __assign = (this && this.__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 = (this && this.__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;
};
const options_1 = require(624) /* ./types/options */;
const default_1 = tslib_1.__importDefault(require(625) /* ./l10n/default */);
const utils_1 = require(626) /* ./utils */;
const dom_1 = require(627) /* ./utils/dom */;
const dates_1 = require(628) /* ./utils/dates */;
const formatting_1 = require(629) /* ./utils/formatting */;
require(630) /* ./utils/polyfills */;
var DEBOUNCED_CHANGE_MS = 300;
function FlatpickrInstance(element, instanceConfig) {
var self = {
config: __assign(__assign({}, options_1.defaults), flatpickr.defaultConfig),
l10n: default_1.default,
};
self.parseDate = (0, dates_1.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 = dom_1.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 ||
(0, dates_1.compareDates)(new Date(), self.config.minDate) >= 0
? new Date()
: new Date(self.config.minDate.getTime());
var defaults = (0, dates_1.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 * (0, utils_1.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 &&
(0, dates_1.compareDates)(self.latestSelectedDateObj, self.config.minDate, true) ===
0);
var limitMaxHours = self.config.maxTime !== undefined ||
(self.config.maxDate &&
self.maxDateHasTime &&
self.latestSelectedDateObj &&
(0, dates_1.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 = (0, dates_1.calculateSecondsSinceMidnight)(self.config.minTime.getHours(), self.config.minTime.getMinutes(), self.config.minTime.getSeconds());
var maxBound = (0, dates_1.calculateSecondsSinceMidnight)(self.config.maxTime.getHours(), self.config.maxTime.getMinutes(), self.config.maxTime.getSeconds());
var currentTime = (0, dates_1.calculateSecondsSinceMidnight)(hours, minutes, seconds);
if (currentTime > maxBound && currentTime < minBound) {
var result = (0, dates_1.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 = (0, utils_1.pad)(!self.config.time_24hr
? ((12 + hours) % 12) + 12 * (0, utils_1.int)(hours % 12 === 0)
: hours);
self.minuteElement.value = (0, utils_1.pad)(minutes);
if (self.amPM !== undefined)
self.amPM.textContent = self.l10n.amPM[(0, utils_1.int)(hours >= 12)];
if (self.secondElement !== undefined)
self.secondElement.value = (0, utils_1.pad)(seconds);
}
function onYearInput(event) {
var eventTarget = (0, dom_1.getEventTarget)(event);
var year = parseInt(eventTarget.value) + (event.delta || 0);
if (year / 1000 > 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 = (0, utils_1.debounce)(onResize, 50);
self._debouncedChange = (0, utils_1.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((0, dom_1.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 (0, dom_1.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 = (0, dom_1.getEventTarget)(e);
if (~eventTarget.className.indexOf("arrow"))
incrementNumInput(e, eventTarget.classList.contains("arrowUp") ? 1 : -1);
}
function incrementNumInput(e, delta, inputElem) {
var target = e && (0, dom_1.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 = (0, dom_1.createElement)("div", "flatpickr-calendar");
self.calendarContainer.tabIndex = -1;
if (!self.config.noCalendar) {
fragment.appendChild(buildMonthNav());
self.innerContainer = (0, dom_1.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 = (0, dom_1.createElement)("div", "flatpickr-rContainer");
self.rContainer.appendChild(buildWeekdays());
if (!self.daysContainer) {
self.daysContainer = (0, dom_1.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());
}
(0, dom_1.toggleClass)(self.calendarContainer, "rangeMode", self.config.mode === "range");
(0, dom_1.toggleClass)(self.calendarContainer, "animate", self.config.animate === true);
(0, dom_1.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 = (0, dom_1.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 = (0, dom_1.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 &&
(0, dates_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") {
(0, dom_1.toggleClass)(dayElement, "startRange", self.selectedDates[0] &&
(0, dates_1.compareDates)(date, self.selectedDates[0], true) === 0);
(0, dom_1.toggleClass)(dayElement, "endRange", self.selectedDates[1] &&
(0, dates_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", "" + self.config.getWeek(date) + "");
}
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 = (0, dom_1.createElement)("div", "dayContainer");
dayContainer.appendChild(days);
return dayContainer;
}
function buildDays() {
if (self.daysContainer === undefined) {
return;
}
(0, dom_1.clearNode)(self.daysContainer);
if (self.weekNumbers)
(0, dom_1.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 = (0, dom_1.createElement)("option", "flatpickr-monthDropdown-month");
month.value = new Date(self.currentYear, i).getMonth().toString();
month.textContent = (0, formatting_1.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 = (0, dom_1.createElement)("div", "flatpickr-month");
var monthNavFragment = window.document.createDocumentFragment();
var monthElement;
if (self.config.showMonths > 1 ||
self.config.monthSelectorType === "static") {
monthElement = (0, dom_1.createElement)("span", "cur-month");
}
else {
self.monthsDropdownContainer = (0, dom_1.createElement)("select", "flatpickr-monthDropdown-months");
self.monthsDropdownContainer.setAttribute("aria-label", self.l10n.monthAriaLabel);
bind(self.monthsDropdownContainer, "change", function (e) {
var target = (0, dom_1.getEventTarget)(e);
var selectedMonth = parseInt(target.value, 10);
self.changeMonth(selectedMonth - self.currentMonth);
triggerEvent("onMonthChange");
});
buildMonthSwitch();
monthElement = self.monthsDropdownContainer;
}
var yearInput = (0, dom_1.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 = (0, dom_1.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() {
(0, dom_1.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 = (0, dom_1.createElement)("div", "flatpickr-months");
self.yearElements = [];
self.monthElements = [];
self.prevMonthNav = (0, dom_1.createElement)("span", "flatpickr-prev-month");
self.prevMonthNav.innerHTML = self.config.prevArrow;
self.nextMonthNav = (0, dom_1.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) {
(0, dom_1.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) {
(0, dom_1.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 = (0, dates_1.getDefaultHours)(self.config);
self.timeContainer = (0, dom_1.createElement)("div", "flatpickr-time");
self.timeContainer.tabIndex = -1;
var separator = (0, dom_1.createElement)("span", "flatpickr-time-separator", ":");
var hourInput = (0, dom_1.createNumberInput)("flatpickr-hour", {
"aria-label": self.l10n.hourAriaLabel,
});
self.hourElement = hourInput.getElementsByTagName("input")[0];
var minuteInput = (0, dom_1.createNumberInput)("flatpickr-minute", {
"aria-label": self.l10n.minuteAriaLabel,
});
self.minuteElement = minuteInput.getElementsByTagName("input")[0];
self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
self.hourElement.value = (0, utils_1.pad)(self.latestSelectedDateObj
? self.latestSelectedDateObj.getHours()
: self.config.time_24hr
? defaults.hours
: military2ampm(defaults.hours));
self.minuteElement.value = (0, utils_1.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 = (0, dom_1.createNumberInput)("flatpickr-second");
self.secondElement = secondInput.getElementsByTagName("input")[0];
self.secondElement.value = (0, utils_1.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((0, dom_1.createElement)("span", "flatpickr-time-separator", ":"));
self.timeContainer.appendChild(secondInput);
}
if (!self.config.time_24hr) {
self.amPM = (0, dom_1.createElement)("span", "flatpickr-am-pm", self.l10n.amPM[(0, utils_1.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 = (0, dom_1.createElement)("div", "flatpickr-weekdays");
else
(0, dom_1.clearNode)(self.weekdayContainer);
for (var i = self.config.showMonths; i--;) {
var container = (0, dom_1.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 \n " + weekdays.join("") + "\n \n ";
}
}
function buildWeeks() {
self.calendarContainer.classList.add("hasWeeks");
var weekWrapper = (0, dom_1.createElement)("div", "flatpickr-weekwrapper");
weekWrapper.appendChild((0, dom_1.createElement)("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
var weekNumbers = (0, dom_1.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 = (0, dates_1.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 = (0, dom_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 &&
(0, dates_1.compareDates)(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
(self.config.maxDate &&
dateToCheck &&
(0, dates_1.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 = (0, dom_1.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;
default:
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 += dates_1.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) &&
(0, dates_1.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 = (0, dom_1.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 || options_1.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 || options_1.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";
options_1.HOOKS.filter(function (hook) { return self.config[hook] !== undefined; }).forEach(function (hook) {
self.config[hook] = (0, utils_1.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 (options_1.HOOKS.indexOf(key) > -1) {
self.config[key] = (0, utils_1.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));
formatting_1.tokenRegex.D = "(" + self.l10n.weekdays.shorthand.join("|") + ")";
formatting_1.tokenRegex.l = "(" + self.l10n.weekdays.longhand.join("|") + ")";
formatting_1.tokenRegex.M = "(" + self.l10n.months.shorthand.join("|") + ")";
formatting_1.tokenRegex.F = "(" + self.l10n.months.longhand.join("|") + ")";
formatting_1.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 = (0, dates_1.createDateFormatter)(self);
self.parseDate = (0, dates_1.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);
(0, dom_1.toggleClass)(self.calendarContainer, "arrowTop", !showOnTop);
(0, dom_1.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;
}
(0, dom_1.toggleClass)(self.calendarContainer, "arrowLeft", !isCenter && !isRight);
(0, dom_1.toggleClass)(self.calendarContainer, "arrowCenter", isCenter);
(0, dom_1.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;
(0, dom_1.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;}";
(0, dom_1.toggleClass)(self.calendarContainer, "rightMost", false);
(0, dom_1.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 = (0, dom_1.findParent)((0, dom_1.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 ((0, dates_1.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 (options_1.HOOKS.indexOf(option) > -1)
self.config[option] = (0, utils_1.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;
default:
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 = (0, dom_1.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 = (0, dom_1.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((0, dom_1.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 &&
(0, dates_1.compareDates)(selectedDate, date) === 0)
return "" + i;
}
return false;
}
function isDateInRange(date) {
if (self.config.mode !== "range" || self.selectedDates.length < 2)
return false;
return ((0, dates_1.compareDates)(date, self.selectedDates[0]) >= 0 &&
(0, dates_1.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 =
(0, formatting_1.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 = (0, dom_1.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 = (0, dom_1.getEventTarget)(e), input = eventTarget;
if (self.amPM !== undefined && eventTarget === self.amPM) {
self.amPM.textContent =
self.l10n.amPM[(0, utils_1.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 +
(0, utils_1.int)(!isHourElem) +
((0, utils_1.int)(isHourElem) && (0, utils_1.int)(!self.amPM));
if (isMinuteElem)
incrementNumInput(undefined, -1, self.hourElement);
}
else if (newValue > max) {
newValue =
input === self.hourElement ? newValue - max - (0, utils_1.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[(0, utils_1.int)(self.amPM.textContent === self.l10n.amPM[0])];
}
input.value = (0, utils_1.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({}, default_1.default),
default: __assign({}, default_1.default),
};
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 = (0, dates_1.createDateParser)({});
flatpickr.formatDate = (0, dates_1.createDateFormatter)({});
flatpickr.compareDates = dates_1.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;
}
exports.default = flatpickr;
},
624: /* flatpickr/dist/esm/types/options.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.HOOKS = [
"onChange",
"onClose",
"onDayCreate",
"onDestroy",
"onKeyDown",
"onMonthChange",
"onOpen",
"onParseConfig",
"onReady",
"onValueUpdate",
"onYearChange",
"onPreCalendarPosition",
];
exports.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()) / 86400000 -
3 +
((week1.getDay() + 6) % 7)) /
7));
},
hourIncrement: 1,
ignoredFocusElements: [],
inline: false,
locale: "default",
minuteIncrement: 5,
mode: "single",
monthSelectorType: "dropdown",
nextArrow: "",
noCalendar: false,
now: new Date(),
onChange: [],
onClose: [],
onDayCreate: [],
onDestroy: [],
onKeyDown: [],
onMonthChange: [],
onOpen: [],
onParseConfig: [],
onReady: [],
onValueUpdate: [],
onYearChange: [],
onPreCalendarPosition: [],
plugins: [],
position: "auto",
positionElement: undefined,
prevArrow: "",
shorthandCurrentMonth: false,
showMonths: 1,
static: false,
time_24hr: false,
weekNumbers: false,
wrap: false,
};
},
625: /* flatpickr/dist/esm/l10n/default.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.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,
};
exports.default = exports.english;
},
626: /* flatpickr/dist/esm/utils/index.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.debounce = debounce;
var pad = function (number, length) {
if (length === void 0) {
length = 2;
}
return ("000" + number).slice(length * -1);
};
exports.pad = pad;
var int = function (bool) { return (bool === true ? 1 : 0); };
exports.int = int;
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];
};
exports.arrayify = arrayify;
},
627: /* flatpickr/dist/esm/utils/dom.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.toggleClass = toggleClass;
exports.createElement = createElement;
exports.clearNode = clearNode;
exports.findParent = findParent;
exports.createNumberInput = createNumberInput;
exports.getEventTarget = getEventTarget;
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;
}
}
},
628: /* flatpickr/dist/esm/utils/dates.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.compareDates = compareDates;
exports.compareTimes = compareTimes;
exports.getDefaultHours = getDefaultHours;
const formatting_1 = require(629) /* ./formatting */;
const options_1 = require(624) /* ../types/options */;
const default_1 = require(625) /* ../l10n/default */;
var createDateFormatter = function (_a) {
var _b = _a.config, config = _b === void 0 ? options_1.defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? default_1.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 formatting_1.formats[c] && arr[i - 1] !== "\\"
? formatting_1.formats[c](dateObj, locale, config)
: c !== "\\"
? c
: "";
})
.join("");
};
};
exports.createDateFormatter = createDateFormatter;
var createDateParser = function (_a) {
var _b = _a.config, config = _b === void 0 ? options_1.defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? default_1.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 || options_1.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 (formatting_1.tokenRegex[token] && !escaped) {
regexStr += formatting_1.tokenRegex[token];
var match = new RegExp(regexStr).exec(date);
if (match && (matched = true)) {
ops[token !== "Y" ? "push" : "unshift"]({
fn: formatting_1.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;
};
};
exports.createDateParser = createDateParser;
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();
}
function compareTimes(date1, date2) {
return (3600 * (date1.getHours() - date2.getHours()) +
60 * (date1.getMinutes() - date2.getMinutes()) +
date1.getSeconds() -
date2.getSeconds());
}
var isBetween = function (ts, ts1, ts2) {
return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
};
exports.isBetween = isBetween;
var calculateSecondsSinceMidnight = function (hours, minutes, seconds) {
return hours * 3600 + minutes * 60 + seconds;
};
exports.calculateSecondsSinceMidnight = calculateSecondsSinceMidnight;
var parseSeconds = function (secondsSinceMidnight) {
var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
return [hours, minutes, secondsSinceMidnight - hours * 3600 - minutes * 60];
};
exports.parseSeconds = parseSeconds;
exports.duration = {
DAY: 86400000,
};
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 };
}
},
629: /* flatpickr/dist/esm/utils/formatting.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
const utils_1 = require(626) /* ../utils */;
var doNothing = function () { return undefined; };
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
exports.monthToStr = monthToStr;
exports.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 * (0, utils_1.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) * 1000); },
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(2000 + parseFloat(year));
},
};
exports.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})",
};
exports.formats = {
Z: function (date) { return date.toISOString(); },
D: function (date, locale, options) {
return locale.weekdays.shorthand[exports.formats.w(date, locale, options)];
},
F: function (date, locale, options) {
return (0, exports.monthToStr)(exports.formats.n(date, locale, options) - 1, false, locale);
},
G: function (date, locale, options) {
return (0, utils_1.pad)(exports.formats.h(date, locale, options));
},
H: function (date) { return (0, utils_1.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[(0, utils_1.int)(date.getHours() > 11)]; },
M: function (date, locale) {
return (0, exports.monthToStr)(date.getMonth(), true, locale);
},
S: function (date) { return (0, utils_1.pad)(date.getSeconds()); },
U: function (date) { return date.getTime() / 1000; },
W: function (date, _, options) {
return options.getWeek(date);
},
Y: function (date) { return (0, utils_1.pad)(date.getFullYear(), 4); },
d: function (date) { return (0, utils_1.pad)(date.getDate()); },
h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
i: function (date) { return (0, utils_1.pad)(date.getMinutes()); },
j: function (date) { return date.getDate(); },
l: function (date, locale) {
return locale.weekdays.longhand[date.getDay()];
},
m: function (date) { return (0, utils_1.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); },
};
},
630: /* flatpickr/dist/esm/utils/polyfills.js */ function _(require, module, exports, __esModule, __esExport) {
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;
};
}
},
631: /* styles/widgets/flatpickr.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.default = `.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6, -1px 0 0 #e6e6e6, 0 1px 0 #e6e6e6, 0 -1px 0 #e6e6e6, 0 3px 13px rgba(0, 0, 0, 0.08);box-shadow:1px 0 0 #e6e6e6, -1px 0 0 #e6e6e6, 0 1px 0 #e6e6e6, 0 -1px 0 #e6e6e6, 0 3px 13px rgba(0, 0, 0, 0.08);}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible;}.flatpickr-calendar.open{display:inline-block;z-index:99999;}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);animation:fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);}.flatpickr-calendar.inline{display:block;position:relative;top:2px;}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px);}.flatpickr-calendar.static.open{z-index:999;display:block;}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important;}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0;}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0;}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6;}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto;}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px;}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px;}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%;}.flatpickr-calendar:before{border-width:5px;margin:0 -5px;}.flatpickr-calendar:after{border-width:4px;margin:0 -4px;}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%;}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6;}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff;}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%;}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6;}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff;}.flatpickr-calendar:focus{outline:0;}.flatpickr-wrapper{position:relative;display:inline-block;}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0, 0, 0, 0.9);fill:rgba(0, 0, 0, 0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0, 0, 0, 0.9);fill:rgba(0, 0, 0, 0.9);}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none;}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative;}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{left:0;}.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{right:0;}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9;}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747;}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px;}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill 0.1s;transition:fill 0.1s;fill:inherit;}.numInputWrapper{position:relative;height:auto;}.numInputWrapper input,.numInputWrapper span{display:inline-block;}.numInputWrapper input{width:100%;}.numInputWrapper input::-ms-clear{display:none;}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57, 57, 57, 0.15);-webkit-box-sizing:border-box;box-sizing:border-box;}.numInputWrapper span:hover{background:rgba(0, 0, 0, 0.1);}.numInputWrapper span:active{background:rgba(0, 0, 0, 0.2);}.numInputWrapper span:after{display:block;content:"";position:absolute;}.numInputWrapper span.arrowUp{top:0;border-bottom:0;}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57, 57, 57, 0.6);top:26%;}.numInputWrapper span.arrowDown{top:50%;}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57, 57, 57, 0.6);top:40%;}.numInputWrapper span svg{width:inherit;height:auto;}.numInputWrapper span svg path{fill:rgba(0, 0, 0, 0.5);}.numInputWrapper:hover{background:rgba(0, 0, 0, 0.05);}.numInputWrapper:hover span{opacity:1;}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0px, 0px, 0px);transform:translate3d(0px, 0px, 0px);}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:0.5ch;padding:0;}.flatpickr-current-month span.cur-month:hover{background:rgba(0, 0, 0, 0.05);}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block;}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0, 0, 0, 0.9);}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0, 0, 0, 0.9);}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 0.5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-current-month input.cur-year:focus{outline:0;}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0, 0, 0, 0.5);background:transparent;pointer-events:none;}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 0.5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto;}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none;}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0, 0, 0, 0.05);}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0;}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px;}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0, 0, 0, 0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder;}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0;}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px;}.flatpickr-days:focus{outline:0;}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0px, 0px, 0px);transform:translate3d(0px, 0px, 0px);opacity:1;}.dayContainer + .dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6;}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6;}.flatpickr-day.today{border-color:#959ea9;}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#959ea9;background:#959ea9;color:#fff;}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7;}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px;}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0;}.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #569ff7;box-shadow:-10px 0 0 #569ff7;}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px;}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;box-shadow:-5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(57, 57, 57, 0.3);background:transparent;border-color:transparent;cursor:default;}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(57, 57, 57, 0.1);}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #569ff7, 5px 0 0 #569ff7;box-shadow:-5px 0 0 #569ff7, 5px 0 0 #569ff7;}.flatpickr-day.hidden{visibility:hidden;}.rangeMode .flatpickr-day{margin-top:1px;}.flatpickr-weekwrapper{float:left;}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 #e6e6e6;box-shadow:1px 0 0 #e6e6e6;}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px;}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(57, 57, 57, 0.3);background:transparent;cursor:default;border:none;}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box;}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.flatpickr-time:after{content:"";display:table;clear:both;}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left;}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#393939;}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#393939;}.flatpickr-time.hasSeconds .numInputWrapper{width:26%;}.flatpickr-time.time24hr .numInputWrapper{width:49%;}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#393939;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-time input.flatpickr-hour{font-weight:bold;}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400;}.flatpickr-time input:focus{outline:0;border:0;}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#393939;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400;}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eee;}.flatpickr-input[readonly]{cursor:pointer;}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0, -20px, 0);transform:translate3d(0, -20px, 0);}to{opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0, -20px, 0);transform:translate3d(0, -20px, 0);}to{opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);}}.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;-webkit-box-shadow:0 3px 13px rgba(0, 0, 0, 0.08);box-shadow:0 3px 13px rgba(0, 0, 0, 0.08);}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible;}.flatpickr-calendar.open{display:inline-block;z-index:99999;}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);animation:fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);}.flatpickr-calendar.inline{display:block;position:relative;top:2px;}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px);}.flatpickr-calendar.static.open{z-index:999;display:block;}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important;}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0;}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0;}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid #eceef1;}.flatpickr-calendar.hasTime .flatpickr-innerContainer{border-bottom:0;}.flatpickr-calendar.hasTime .flatpickr-time{border:1px solid #eceef1;}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto;}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px;}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px;}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%;}.flatpickr-calendar:before{border-width:5px;margin:0 -5px;}.flatpickr-calendar:after{border-width:4px;margin:0 -4px;}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%;}.flatpickr-calendar.arrowTop:before{border-bottom-color:#eceef1;}.flatpickr-calendar.arrowTop:after{border-bottom-color:#eceef1;}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%;}.flatpickr-calendar.arrowBottom:before{border-top-color:#eceef1;}.flatpickr-calendar.arrowBottom:after{border-top-color:#eceef1;}.flatpickr-calendar:focus{outline:0;}.flatpickr-wrapper{position:relative;display:inline-block;}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.flatpickr-months .flatpickr-month{border-radius:5px 5px 0 0;background:#eceef1;color:#5a6171;fill:#5a6171;height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:#5a6171;fill:#5a6171;}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none;}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative;}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{left:0;}.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{right:0;}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#bbb;}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747;}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px;}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill 0.1s;transition:fill 0.1s;fill:inherit;}.numInputWrapper{position:relative;height:auto;}.numInputWrapper input,.numInputWrapper span{display:inline-block;}.numInputWrapper input{width:100%;}.numInputWrapper input::-ms-clear{display:none;}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(72, 72, 72, 0.15);-webkit-box-sizing:border-box;box-sizing:border-box;}.numInputWrapper span:hover{background:rgba(0, 0, 0, 0.1);}.numInputWrapper span:active{background:rgba(0, 0, 0, 0.2);}.numInputWrapper span:after{display:block;content:"";position:absolute;}.numInputWrapper span.arrowUp{top:0;border-bottom:0;}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(72, 72, 72, 0.6);top:26%;}.numInputWrapper span.arrowDown{top:50%;}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(72, 72, 72, 0.6);top:40%;}.numInputWrapper span svg{width:inherit;height:auto;}.numInputWrapper span svg path{fill:rgba(90, 97, 113, 0.5);}.numInputWrapper:hover{background:rgba(0, 0, 0, 0.05);}.numInputWrapper:hover span{opacity:1;}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0px, 0px, 0px);transform:translate3d(0px, 0px, 0px);}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:0.5ch;padding:0;}.flatpickr-current-month span.cur-month:hover{background:rgba(0, 0, 0, 0.05);}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block;}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:#5a6171;}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:#5a6171;}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 0.5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-current-month input.cur-year:focus{outline:0;}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(90, 97, 113, 0.5);background:transparent;pointer-events:none;}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:#eceef1;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 0.5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto;}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none;}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0, 0, 0, 0.05);}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:#eceef1;outline:none;padding:0;}.flatpickr-weekdays{background:#eceef1;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px;}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;}span.flatpickr-weekday{cursor:default;font-size:90%;background:#eceef1;color:#5a6171;line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder;}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0;}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px;border-left:1px solid #eceef1;border-right:1px solid #eceef1;}.flatpickr-days:focus{outline:0;}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0px, 0px, 0px);transform:translate3d(0px, 0px, 0px);opacity:1;}.dayContainer + .dayContainer{-webkit-box-shadow:-1px 0 0 #eceef1;box-shadow:-1px 0 0 #eceef1;}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#484848;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e2e2e2;border-color:#e2e2e2;}.flatpickr-day.today{border-color:#bbb;}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#bbb;background:#bbb;color:#fff;}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#ff5a5f;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#ff5a5f;}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px;}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0;}.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #ff5a5f;box-shadow:-10px 0 0 #ff5a5f;}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px;}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e2e2e2, 5px 0 0 #e2e2e2;box-shadow:-5px 0 0 #e2e2e2, 5px 0 0 #e2e2e2;}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(72, 72, 72, 0.3);background:transparent;border-color:transparent;cursor:default;}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(72, 72, 72, 0.1);}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #ff5a5f, 5px 0 0 #ff5a5f;box-shadow:-5px 0 0 #ff5a5f, 5px 0 0 #ff5a5f;}.flatpickr-day.hidden{visibility:hidden;}.rangeMode .flatpickr-day{margin-top:1px;}.flatpickr-weekwrapper{float:left;}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;border-left:1px solid #eceef1;}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px;}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(72, 72, 72, 0.3);background:transparent;cursor:default;border:none;}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;background:#fff;border-bottom:1px solid #eceef1;}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box;}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background:#fff;border-radius:0 0 5px 5px;}.flatpickr-time:after{content:"";display:table;clear:both;}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left;}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#484848;}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#484848;}.flatpickr-time.hasSeconds .numInputWrapper{width:26%;}.flatpickr-time.time24hr .numInputWrapper{width:49%;}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#484848;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-time input.flatpickr-hour{font-weight:bold;}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400;}.flatpickr-time input:focus{outline:0;border:0;}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#484848;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400;}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eaeaea;}.flatpickr-input[readonly]{cursor:pointer;}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0, -20px, 0);transform:translate3d(0, -20px, 0);}to{opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0, -20px, 0);transform:translate3d(0, -20px, 0);}to{opacity:1;-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);}}span.flatpickr-day.selected{font-weight:bold;}`;
},
632: /* models/widgets/date_range_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const base_date_picker_1 = require(621) /* ./base_date_picker */;
const assert_1 = require(12) /* ../../core/util/assert */;
class DateRangePickerView extends base_date_picker_1.BaseDatePickerView {
get flatpickr_options() {
return {
...super.flatpickr_options,
mode: "range",
};
}
_on_change(selected) {
switch (selected.length) {
case 0:
this.model.value = null;
break;
case 1: {
// Selection in progress, so do nothing and wait for two selected
// dates. Single date selection is still possible and represented
// by [date, date] tuple.
break;
}
case 2: {
const [from, to] = selected;
const from_date = this._format_date(from);
const to_date = this._format_date(to);
this.model.value = [from_date, to_date];
break;
}
default: {
(0, assert_1.assert)(false, "invalid length");
}
}
}
}
exports.DateRangePickerView = DateRangePickerView;
DateRangePickerView.__name__ = "DateRangePickerView";
class DateRangePicker extends base_date_picker_1.BaseDatePicker {
constructor(attrs) {
super(attrs);
}
}
exports.DateRangePicker = DateRangePicker;
_a = DateRangePicker;
DateRangePicker.__name__ = "DateRangePicker";
(() => {
_a.prototype.default_view = DateRangePickerView;
_a.define(({ Tuple, Nullable }) => ({
value: [Nullable(Tuple(base_date_picker_1.DateLike, base_date_picker_1.DateLike)), null],
}));
})();
},
633: /* models/widgets/datetime_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const base_datetime_picker_1 = require(634) /* ./base_datetime_picker */;
const base_date_picker_1 = require(621) /* ./base_date_picker */;
const assert_1 = require(12) /* ../../core/util/assert */;
class DatetimePickerView extends base_datetime_picker_1.BaseDatetimePickerView {
get flatpickr_options() {
return {
...super.flatpickr_options,
mode: "single",
};
}
_on_change(selected) {
(0, assert_1.assert)(selected.length <= 1);
this.model.value = (() => {
if (selected.length == 0) {
return null;
}
else {
const [datetime] = selected;
return this._format_date(datetime);
}
})();
}
}
exports.DatetimePickerView = DatetimePickerView;
DatetimePickerView.__name__ = "DatetimePickerView";
class DatetimePicker extends base_datetime_picker_1.BaseDatetimePicker {
constructor(attrs) {
super(attrs);
}
}
exports.DatetimePicker = DatetimePicker;
_a = DatetimePicker;
DatetimePicker.__name__ = "DatetimePicker";
(() => {
_a.prototype.default_view = DatetimePickerView;
_a.define(({ Nullable }) => ({
value: [Nullable(base_date_picker_1.DateLike), null],
}));
})();
},
634: /* models/widgets/base_datetime_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const base_date_picker_1 = require(621) /* ./base_date_picker */;
const enums_1 = require(20) /* ../../core/enums */;
class BaseDatetimePickerView extends base_date_picker_1.BaseDatePickerView {
connect_signals() {
super.connect_signals();
const { value, hour_increment, minute_increment, second_increment, seconds, clock, } = this.model.properties;
this.connect(value.change, () => {
const { value } = this.model;
if (value != null) {
this.picker.setDate(value);
}
else {
this.picker.clear();
}
});
this.connect(hour_increment.change, () => this.picker.set("hourIncrement", this.model.hour_increment));
this.connect(minute_increment.change, () => this.picker.set("minuteIncrement", this.model.minute_increment));
this.connect(second_increment.change, () => this._update_second_increment());
this.connect(seconds.change, () => this.picker.set("enableSeconds", this.model.seconds));
this.connect(clock.change, () => this.picker.set("time_24hr", this.model.clock == "24h"));
}
get flatpickr_options() {
const { hour_increment, minute_increment, seconds, clock } = this.model;
const options = super.flatpickr_options;
options.enableTime = true;
options.dateFormat = "Y-m-dTH:i:S";
options.hourIncrement = hour_increment;
options.minuteIncrement = minute_increment;
options.enableSeconds = seconds;
options.time_24hr = clock == "24h";
return options;
}
render() {
super.render();
this._update_second_increment();
}
_update_second_increment() {
const { second_increment } = this.model;
this.picker.secondElement?.setAttribute("step", second_increment.toString());
}
}
exports.BaseDatetimePickerView = BaseDatetimePickerView;
BaseDatetimePickerView.__name__ = "BaseDatetimePickerView";
class BaseDatetimePicker extends base_date_picker_1.BaseDatePicker {
constructor(attrs) {
super(attrs);
}
}
exports.BaseDatetimePicker = BaseDatetimePicker;
_a = BaseDatetimePicker;
BaseDatetimePicker.__name__ = "BaseDatetimePicker";
(() => {
_a.define(({ Bool, Positive, Int }) => ({
hour_increment: [Positive(Int), 1],
minute_increment: [Positive(Int), 1],
second_increment: [Positive(Int), 1],
seconds: [Bool, false],
clock: [enums_1.Clock, "24h"],
}));
_a.override({
date_format: "Y-m-d H:i",
});
})();
},
635: /* models/widgets/datetime_range_picker.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const base_datetime_picker_1 = require(634) /* ./base_datetime_picker */;
const base_date_picker_1 = require(621) /* ./base_date_picker */;
const assert_1 = require(12) /* ../../core/util/assert */;
class DatetimeRangePickerView extends base_datetime_picker_1.BaseDatetimePickerView {
get flatpickr_options() {
return {
...super.flatpickr_options,
mode: "range",
};
}
_on_change(selected) {
switch (selected.length) {
case 0:
this.model.value = null;
break;
case 1: {
// Selection in progress, so do nothing and wait for two selected
// datetimes. Single datetime selection is still possible and represented
// by [datetime, datetime] tuple.
break;
}
case 2: {
const [from, to] = selected;
const from_date = this._format_date(from);
const to_date = this._format_date(to);
this.model.value = [from_date, to_date];
break;
}
default: {
(0, assert_1.assert)(false, "invalid length");
}
}
}
}
exports.DatetimeRangePickerView = DatetimeRangePickerView;
DatetimeRangePickerView.__name__ = "DatetimeRangePickerView";
class DatetimeRangePicker extends base_datetime_picker_1.BaseDatetimePicker {
constructor(attrs) {
super(attrs);
}
}
exports.DatetimeRangePicker = DatetimeRangePicker;
_a = DatetimeRangePicker;
DatetimeRangePicker.__name__ = "DatetimeRangePicker";
(() => {
_a.prototype.default_view = DatetimeRangePickerView;
_a.define(({ Nullable, Tuple }) => ({
value: [Nullable(Tuple(base_date_picker_1.DateLike, base_date_picker_1.DateLike)), null],
}));
})();
},
636: /* models/widgets/div.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const markup_1 = require(637) /* ./markup */;
class DivView extends markup_1.MarkupView {
render() {
super.render();
if (this.model.render_as_text) {
this.markup_el.textContent = this.model.text;
}
else {
this.markup_el.innerHTML = this.has_math_disabled() ? this.model.text : this.process_tex(this.model.text);
}
}
}
exports.DivView = DivView;
DivView.__name__ = "DivView";
class Div extends markup_1.Markup {
constructor(attrs) {
super(attrs);
}
}
exports.Div = Div;
_a = Div;
Div.__name__ = "Div";
(() => {
_a.prototype.default_view = DivView;
_a.define(({ Bool }) => ({
render_as_text: [Bool, false],
}));
})();
},
637: /* models/widgets/markup.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const dom_1 = require(63) /* ../../core/dom */;
const widget_1 = require(707) /* ./widget */;
const clearfix_css_1 = tslib_1.__importStar(require(638) /* ../../styles/clearfix.css */);
class MarkupView extends widget_1.WidgetView {
constructor() {
super(...arguments);
this._auto_width = "fit-content";
this._auto_height = "auto";
}
async lazy_initialize() {
await super.lazy_initialize();
if (this.provider.status == "not_started" || this.provider.status == "loading") {
this.provider.ready.connect(() => {
if (this.contains_tex_string(this.model.text)) {
this.rerender();
}
});
}
}
has_math_disabled() {
return this.model.disable_math || !this.contains_tex_string(this.model.text);
}
rerender() {
this.render();
}
connect_signals() {
super.connect_signals();
this.connect(this.model.change, () => {
this.rerender();
});
}
stylesheets() {
return [...super.stylesheets(), clearfix_css_1.default, "p { margin: 0; }"];
}
render() {
super.render();
this.markup_el = (0, dom_1.div)({ class: clearfix_css_1.clearfix, style: { display: "inline-block" } });
this.shadow_el.appendChild(this.markup_el);
if (this.provider.status == "failed" || this.provider.status == "loaded") {
this._has_finished = true;
}
}
}
exports.MarkupView = MarkupView;
MarkupView.__name__ = "MarkupView";
class Markup extends widget_1.Widget {
constructor(attrs) {
super(attrs);
}
}
exports.Markup = Markup;
_a = Markup;
Markup.__name__ = "Markup";
(() => {
_a.define(({ Bool, Str }) => ({
text: [Str, ""],
disable_math: [Bool, false],
}));
})();
},
638: /* styles/clearfix.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.clearfix = "bk-clearfix";
exports.default = `.bk-clearfix:before,.bk-clearfix:after{content:"";display:table;}.bk-clearfix:after{clear:both;}`;
},
639: /* models/widgets/dropdown.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const abstract_button_1 = require(600) /* ./abstract_button */;
const bokeh_events_1 = require(53) /* ../../core/bokeh_events */;
const dom_1 = require(63) /* ../../core/dom */;
const types_1 = require(8) /* ../../core/util/types */;
const callbacks_1 = require(50) /* ../../core/util/callbacks */;
const buttons = tslib_1.__importStar(require(603) /* ../../styles/buttons.css */);
const dropdown_css_1 = tslib_1.__importStar(require(609) /* ../../styles/dropdown.css */), dropdown = dropdown_css_1;
const caret_css_1 = tslib_1.__importStar(require(640) /* ../../styles/caret.css */), carets = caret_css_1;
class DropdownView extends abstract_button_1.AbstractButtonView {
constructor() {
super(...arguments);
this._open = false;
}
stylesheets() {
return [...super.stylesheets(), dropdown_css_1.default, caret_css_1.default];
}
connect_signals() {
super.connect_signals();
const { menu } = this.model.properties;
this.on_change(menu, () => this.rebuild_menu());
}
render() {
super.render();
const caret = (0, dom_1.div)({ class: [carets.caret, carets.down] });
if (!this.model.is_split) {
this.button_el.append(caret);
}
else {
const toggle = this._render_button(caret);
toggle.classList.add(buttons.dropdown_toggle);
toggle.addEventListener("click", () => this._toggle_menu());
this.group_el.append(toggle);
}
this.menu_el = (0, dom_1.div)({ class: [dropdown.menu, dropdown.below] });
this.shadow_el.append(this.menu_el);
this.rebuild_menu();
(0, dom_1.undisplay)(this.menu_el);
}
_show_menu() {
if (!this._open) {
this._open = true;
(0, dom_1.display)(this.menu_el);
const listener = (event) => {
if (!event.composedPath().includes(this.el)) {
document.removeEventListener("click", listener);
this._hide_menu();
}
};
document.addEventListener("click", listener);
}
}
_hide_menu() {
if (this._open) {
this._open = false;
(0, dom_1.undisplay)(this.menu_el);
}
}
_toggle_menu() {
if (this._open) {
this._hide_menu();
}
else {
this._show_menu();
}
}
click() {
if (!this.model.is_split) {
this._toggle_menu();
}
else {
this._hide_menu();
this.model.trigger_event(new bokeh_events_1.ButtonClick());
super.click();
}
}
_item_click(i) {
this._hide_menu();
const item = this.model.menu[i];
if (item != null) {
const value_or_callback = (0, types_1.isString)(item) ? item : item[1];
if ((0, types_1.isString)(value_or_callback)) {
this.model.trigger_event(new bokeh_events_1.MenuItemClick(value_or_callback));
}
else {
void (0, callbacks_1.execute)(value_or_callback, this.model, { index: i });
}
}
}
rebuild_menu() {
(0, dom_1.empty)(this.menu_el);
const items = this.model.menu.map((item, i) => {
if (item == null) {
return (0, dom_1.div)({ class: dropdown.divider });
}
else {
const label = (0, types_1.isString)(item) ? item : item[0];
const el = (0, dom_1.div)(label);
el.addEventListener("click", () => this._item_click(i));
return el;
}
});
this.menu_el.append(...items);
}
}
exports.DropdownView = DropdownView;
DropdownView.__name__ = "DropdownView";
class Dropdown extends abstract_button_1.AbstractButton {
constructor(attrs) {
super(attrs);
}
get is_split() {
return this.split;
}
}
exports.Dropdown = Dropdown;
_a = Dropdown;
Dropdown.__name__ = "Dropdown";
(() => {
_a.prototype.default_view = DropdownView;
_a.define(({ Null, Bool, Str, List, Tuple, Or }) => ({
split: [Bool, false],
menu: [List(Or(Str, Tuple(Str, Or(Str /*TODO*/)), Null)), []],
}));
_a.override({
label: "Dropdown",
});
})();
},
640: /* styles/caret.css.js */ function _(require, module, exports, __esModule, __esExport) {
__esModule();
exports.caret = "bk-caret";
exports.down = "bk-down";
exports.up = "bk-up";
exports.left = "bk-left";
exports.right = "bk-right";
exports.default = `:host{--caret-width:4px;}.bk-caret{display:inline-block;vertical-align:middle;width:0;height:0;margin:0 5px;}.bk-caret.bk-down{border-top:var(--caret-width) solid;}.bk-caret.bk-up{border-bottom:var(--caret-width) solid;}.bk-caret.bk-down,.bk-caret.bk-up{border-right:var(--caret-width) solid transparent;border-left:var(--caret-width) solid transparent;}.bk-caret.bk-left{border-right:var(--caret-width) solid;}.bk-caret.bk-right{border-left:var(--caret-width) solid;}.bk-caret.bk-left,.bk-caret.bk-right{border-top:var(--caret-width) solid transparent;border-bottom:var(--caret-width) solid transparent;}`;
},
641: /* models/widgets/file_input.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const input_widget_1 = require(607) /* ./input_widget */;
const dom_1 = require(63) /* ../../core/dom */;
const types_1 = require(8) /* ../../core/util/types */;
const p = tslib_1.__importStar(require(18) /* ../../core/properties */);
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
const buttons_css_1 = tslib_1.__importDefault(require(603) /* ../../styles/buttons.css */);
class FileInputView extends input_widget_1.InputWidgetView {
connect_signals() {
super.connect_signals();
this.model.on_event(input_widget_1.ClearInput, () => {
this.model.setv({
value: "", // p.unset,
mime_type: "", // p.unset,
filename: "", // p.unset,
});
this.input_el.value = "";
});
}
stylesheets() {
return [...super.stylesheets(), buttons_css_1.default];
}
_render_input() {
const { multiple, disabled, directory } = this.model;
const accept = (() => {
const { accept } = this.model;
return (0, types_1.isString)(accept) ? accept : accept.join(",");
})();
return this.input_el = (0, dom_1.input)({ type: "file", class: inputs.input, multiple, accept, disabled, webkitdirectory: directory });
}
render() {
super.render();
this.input_el.addEventListener("change", async () => {
const { files } = this.input_el;
if (files != null) {
await this.load_files(files);
}
});
}
async load_files(files) {
const values = [];
const filenames = [];
const mime_types = [];
const { directory, multiple } = this.model;
const accept = (() => {
const { accept } = this.model;
return (0, types_1.isString)(accept) ? accept : accept.join(",");
})();
for (const file of files) {
const data_url = await this._read_file(file);
const [, mime_type = "", , value = ""] = data_url.split(/[:;,]/, 4);
if (directory) {
const ext = file.name.split(".").pop();
if ((accept.length > 0 && (0, types_1.isString)(ext)) ? accept.includes(`.${ext}`) : true) {
filenames.push(file.webkitRelativePath);
values.push(value);
mime_types.push(mime_type);
}
}
else {
filenames.push(file.name);
values.push(value);
mime_types.push(mime_type);
}
}
const [value, filename, mime_type] = (() => {
if (directory || multiple) {
return [values, filenames, mime_types];
}
else if (files.length != 0) {
return [values[0], filenames[0], mime_types[0]];
}
else {
return ["", "", ""];
}
})();
this.model.setv({ value, filename, mime_type });
}
_read_file(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const { result } = reader;
if (result != null) {
resolve(result);
}
else {
reject(reader.error ?? new Error(`unable to read '${file.name}'`));
}
};
reader.readAsDataURL(file);
});
}
}
exports.FileInputView = FileInputView;
FileInputView.__name__ = "FileInputView";
class FileInput extends input_widget_1.InputWidget {
constructor(attrs) {
super(attrs);
}
}
exports.FileInput = FileInput;
_a = FileInput;
FileInput.__name__ = "FileInput";
(() => {
_a.prototype.default_view = FileInputView;
_a.define(({ Bool, Str, List, Or }) => ({
value: [Or(Str, List(Str)), p.unset, { readonly: true }],
mime_type: [Or(Str, List(Str)), p.unset, { readonly: true }],
filename: [Or(Str, List(Str)), p.unset, { readonly: true }],
accept: [Or(Str, List(Str)), ""],
multiple: [Bool, false],
directory: [Bool, false],
}));
})();
},
642: /* models/widgets/help_button.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const abstract_button_1 = require(600) /* ./abstract_button */;
const tooltip_1 = require(420) /* ../ui/tooltip */;
const builtin_icon_1 = require(486) /* ../ui/icons/builtin_icon */;
const build_views_1 = require(56) /* ../../core/build_views */;
class HelpButtonView extends abstract_button_1.AbstractButtonView {
*children() {
yield* super.children();
yield this.tooltip;
}
async lazy_initialize() {
await super.lazy_initialize();
const { tooltip } = this.model;
this.tooltip = await (0, build_views_1.build_view)(tooltip, { parent: this });
}
remove() {
this.tooltip.remove();
super.remove();
}
render() {
super.render();
let persistent = false;
const toggle = (visible) => {
this.tooltip.model.setv({
visible,
closable: persistent,
});
//icon_el.style.visibility = visible && persistent ? "visible" : ""
};
this.on_change(this.tooltip.model.properties.visible, () => {
const { visible } = this.tooltip.model;
if (!visible) {
persistent = false;
}
toggle(visible);
});
this.el.addEventListener("mouseenter", () => {
toggle(true);
});
this.el.addEventListener("mouseleave", () => {
if (!persistent) {
toggle(false);
}
});
document.addEventListener("mousedown", (event) => {
const path = event.composedPath();
if (path.includes(this.tooltip.el)) {
return;
}
else if (path.includes(this.el)) {
persistent = !persistent;
toggle(persistent);
}
else {
persistent = false;
toggle(false);
}
});
window.addEventListener("blur", () => {
persistent = false;
toggle(false);
});
}
}
exports.HelpButtonView = HelpButtonView;
HelpButtonView.__name__ = "HelpButtonView";
class HelpButton extends abstract_button_1.AbstractButton {
constructor(attrs) {
super(attrs);
}
}
exports.HelpButton = HelpButton;
_a = HelpButton;
HelpButton.__name__ = "HelpButton";
(() => {
_a.prototype.default_view = HelpButtonView;
_a.define(({ Ref }) => ({
tooltip: [Ref(tooltip_1.Tooltip)],
}));
_a.override({
label: "",
icon: () => new builtin_icon_1.BuiltinIcon({ icon_name: "help", size: 18 }),
button_type: "default",
});
})();
},
643: /* models/widgets/multi_choice.js */ function _(require, module, exports, __esModule, __esExport) {
var _a;
__esModule();
const tslib_1 = require(1) /* tslib */;
const choices_js_1 = tslib_1.__importDefault(require(644) /* choices.js */);
const dom_1 = require(63) /* ../../core/dom */;
const types_1 = require(8) /* ../../core/util/types */;
const eq_1 = require(26) /* ../../core/util/eq */;
const inputs = tslib_1.__importStar(require(608) /* ../../styles/widgets/inputs.css */);
const choices_css_1 = tslib_1.__importDefault(require(645) /* ../../styles/widgets/choices.css */);
const input_widget_1 = require(607) /* ./input_widget */;
function retarget(event) {
Object.defineProperty(event, "target", {
get: () => event.composedPath()[0] ?? null,
configurable: true,
});
return event;
}
class OurChoices extends choices_js_1.default {
_onFocus(event) {
super._onFocus(retarget(event));
}
_onBlur(event) {
super._onBlur(retarget(event));
}
_onKeyUp(event) {
super._onKeyUp(retarget(event));
}
_onKeyDown(event) {
super._onKeyDown(retarget(event));
}
_onClick(event) {
super._onClick(retarget(event));
}
_onTouchEnd(event) {
super._onTouchEnd(retarget(event));
}
_onMouseDown(event) {
super._onMouseDown(retarget(event));
}
_onMouseOver(event) {
super._onMouseOver(retarget(event));
}
}
OurChoices.__name__ = "OurChoices";
class MultiChoiceView extends input_widget_1.InputWidgetView {
connect_signals() {
super.connect_signals();
this.connect(this.model.properties.disabled.change, () => this.set_disabled());
const { value, max_items, option_limit, search_option_limit, delete_button, placeholder, options, name, title } = this.model.properties;
this.on_change([max_items, option_limit, search_option_limit, delete_button, placeholder, options, name, title], () => this.render());
this.on_change(value, () => {
// Detects if value change originated in UI or elsewhere. Choices.js automatically
// updates itself, so we don't have to do anything, and in fact we shouldn't do
// anything, because the component is finicky and hard to update without breaking
// something, loosing focus, etc.
if (!(0, eq_1.is_equal)(this.model.value, this._current_values)) {
this.render();
}
});
}
stylesheets() {
return [...super.stylesheets(), choices_css_1.default];
}
_render_input() {
return this.input_el = (0, dom_1.select)({
multiple: true,
class: inputs.input,
name: this.model.name,
disabled: this.model.disabled,
});
}
render() {
super.render();
const selected = new Set(this.model.value);
const choices = this.model.options.map((opt) => {
let value, label;
if ((0, types_1.isString)(opt)) {
value = label = opt;
}
else {
[value, label] = opt;
}
return { value, label, selected: selected.has(value) };
});
const fill = this.model.solid ? "solid" : "light";
const item = `choices__item ${fill}`;
const button = `choices__button ${fill}`;
const options = {
choices,
itemSelectText: "",
duplicateItemsAllowed: false,
shouldSort: false,
removeItemButton: this.model.delete_button,
classNames: { item, button }, // XXX: missing typings
placeholderValue: this.model.placeholder,
maxItemCount: this.model.max_items ?? -1,
renderChoiceLimit: this.model.option_limit ?? -1,
searchResultLimit: this.model.search_option_limit ?? 4,
};
this.choice_el = new OurChoices(this.input_el, options);
this.input_el.addEventListener("change", () => this.change_input());
}
set_disabled() {
if (this.model.disabled) {
this.choice_el.disable();
}
else {
this.choice_el.enable();
}
}
get _current_values() {
const values = this.choice_el.getValue();
return values.map((item) => item.value);
}
change_input() {
this.model.value = this._current_values;
super.change_input();
}
}
exports.MultiChoiceView = MultiChoiceView;
MultiChoiceView.__name__ = "MultiChoiceView";
class MultiChoice extends input_widget_1.InputWidget {
constructor(attrs) {
super(attrs);
}
}
exports.MultiChoice = MultiChoice;
_a = MultiChoice;
MultiChoice.__name__ = "MultiChoice";
(() => {
_a.prototype.default_view = MultiChoiceView;
_a.define(({ Bool, Int, Str, List, Tuple, Or, Nullable }) => ({
value: [List(Str), []],
options: [List(Or(Str, Tuple(Str, Str))), []],
max_items: [Nullable(Int), null],
delete_button: [Bool, true],
placeholder: [Nullable(Str), null],
option_limit: [Nullable(Int), null],
search_option_limit: [Nullable(Int), null],
solid: [Bool, true],
}));
})();
},
644: /* choices.js/public/assets/scripts/choices.js */ function _(require, module, exports, __esModule, __esExport) {
/*! choices.js v10.2.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if (typeof define === 'function' && define.amd)
define([], factory);
else if (typeof exports === 'object')
exports["Choices"] = factory();
else
root["Choices"] = factory();
})(window, function () {
return /******/ (function () {
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 282:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.clearChoices = exports.activateChoices = exports.filterChoices = exports.addChoice = void 0;
var constants_1 = __webpack_require__(883);
var addChoice = function (_a) {
var value = _a.value, label = _a.label, id = _a.id, groupId = _a.groupId, disabled = _a.disabled, elementId = _a.elementId, customProperties = _a.customProperties, placeholder = _a.placeholder, keyCode = _a.keyCode;
return {
type: constants_1.ACTION_TYPES.ADD_CHOICE,
value: value,
label: label,
id: id,
groupId: groupId,
disabled: disabled,
elementId: elementId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
};
};
exports.addChoice = addChoice;
var filterChoices = function (results) {
return {
type: constants_1.ACTION_TYPES.FILTER_CHOICES,
results: results
};
};
exports.filterChoices = filterChoices;
var activateChoices = function (active) {
if (active === void 0) {
active = true;
}
return {
type: constants_1.ACTION_TYPES.ACTIVATE_CHOICES,
active: active
};
};
exports.activateChoices = activateChoices;
var clearChoices = function () {
return {
type: constants_1.ACTION_TYPES.CLEAR_CHOICES
};
};
exports.clearChoices = clearChoices;
/***/
}),
/***/ 783:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.addGroup = void 0;
var constants_1 = __webpack_require__(883);
var addGroup = function (_a) {
var value = _a.value, id = _a.id, active = _a.active, disabled = _a.disabled;
return {
type: constants_1.ACTION_TYPES.ADD_GROUP,
value: value,
id: id,
active: active,
disabled: disabled
};
};
exports.addGroup = addGroup;
/***/
}),
/***/ 464:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.highlightItem = exports.removeItem = exports.addItem = void 0;
var constants_1 = __webpack_require__(883);
var addItem = function (_a) {
var value = _a.value, label = _a.label, id = _a.id, choiceId = _a.choiceId, groupId = _a.groupId, customProperties = _a.customProperties, placeholder = _a.placeholder, keyCode = _a.keyCode;
return {
type: constants_1.ACTION_TYPES.ADD_ITEM,
value: value,
label: label,
id: id,
choiceId: choiceId,
groupId: groupId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
};
};
exports.addItem = addItem;
var removeItem = function (id, choiceId) {
return {
type: constants_1.ACTION_TYPES.REMOVE_ITEM,
id: id,
choiceId: choiceId
};
};
exports.removeItem = removeItem;
var highlightItem = function (id, highlighted) {
return {
type: constants_1.ACTION_TYPES.HIGHLIGHT_ITEM,
id: id,
highlighted: highlighted
};
};
exports.highlightItem = highlightItem;
/***/
}),
/***/ 137:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.setIsLoading = exports.resetTo = exports.clearAll = void 0;
var constants_1 = __webpack_require__(883);
var clearAll = function () {
return {
type: constants_1.ACTION_TYPES.CLEAR_ALL
};
};
exports.clearAll = clearAll;
var resetTo = function (state) {
return {
type: constants_1.ACTION_TYPES.RESET_TO,
state: state
};
};
exports.resetTo = resetTo;
var setIsLoading = function (isLoading) {
return {
type: constants_1.ACTION_TYPES.SET_IS_LOADING,
isLoading: isLoading
};
};
exports.setIsLoading = setIsLoading;
/***/
}),
/***/ 373:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var deepmerge_1 = __importDefault(__webpack_require__(996));
/* eslint-disable @typescript-eslint/no-explicit-any */
var fuse_js_1 = __importDefault(__webpack_require__(221));
var choices_1 = __webpack_require__(282);
var groups_1 = __webpack_require__(783);
var items_1 = __webpack_require__(464);
var misc_1 = __webpack_require__(137);
var components_1 = __webpack_require__(520);
var constants_1 = __webpack_require__(883);
var defaults_1 = __webpack_require__(789);
var utils_1 = __webpack_require__(799);
var reducers_1 = __webpack_require__(655);
var store_1 = __importDefault(__webpack_require__(744));
var templates_1 = __importDefault(__webpack_require__(686));
/** @see {@link http://browserhacks.com/#hack-acea075d0ac6954f275a70023906050c} */
var IS_IE11 = '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style;
var USER_DEFAULTS = {};
/**
* Choices
* @author Josh Johnson
*/
var Choices = /** @class */ function () {
function Choices(element, userConfig) {
if (element === void 0) {
element = '[data-choice]';
}
if (userConfig === void 0) {
userConfig = {};
}
var _this = this;
if (userConfig.allowHTML === undefined) {
console.warn('Deprecation warning: allowHTML will default to false in a future release. To render HTML in Choices, you will need to set it to true. Setting allowHTML will suppress this message.');
}
this.config = deepmerge_1.default.all([defaults_1.DEFAULT_CONFIG, Choices.defaults.options, userConfig],
// When merging array configs, replace with a copy of the userConfig array,
// instead of concatenating with the default array
{
arrayMerge: function (_, sourceArray) {
return __spreadArray([], sourceArray, true);
}
});
var invalidConfigOptions = (0, utils_1.diff)(this.config, defaults_1.DEFAULT_CONFIG);
if (invalidConfigOptions.length) {
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
}
var passedElement = typeof element === 'string' ? document.querySelector(element) : element;
if (!(passedElement instanceof HTMLInputElement || passedElement instanceof HTMLSelectElement)) {
throw TypeError('Expected one of the following types text|select-one|select-multiple');
}
this._isTextElement = passedElement.type === constants_1.TEXT_TYPE;
this._isSelectOneElement = passedElement.type === constants_1.SELECT_ONE_TYPE;
this._isSelectMultipleElement = passedElement.type === constants_1.SELECT_MULTIPLE_TYPE;
this._isSelectElement = this._isSelectOneElement || this._isSelectMultipleElement;
this.config.searchEnabled = this._isSelectMultipleElement || this.config.searchEnabled;
if (!['auto', 'always'].includes("".concat(this.config.renderSelectedChoices))) {
this.config.renderSelectedChoices = 'auto';
}
if (userConfig.addItemFilter && typeof userConfig.addItemFilter !== 'function') {
var re = userConfig.addItemFilter instanceof RegExp ? userConfig.addItemFilter : new RegExp(userConfig.addItemFilter);
this.config.addItemFilter = re.test.bind(re);
}
if (this._isTextElement) {
this.passedElement = new components_1.WrappedInput({
element: passedElement,
classNames: this.config.classNames,
delimiter: this.config.delimiter
});
}
else {
this.passedElement = new components_1.WrappedSelect({
element: passedElement,
classNames: this.config.classNames,
template: function (data) {
return _this._templates.option(data);
}
});
}
this.initialised = false;
this._store = new store_1.default();
this._initialState = reducers_1.defaultState;
this._currentState = reducers_1.defaultState;
this._prevState = reducers_1.defaultState;
this._currentValue = '';
this._canSearch = !!this.config.searchEnabled;
this._isScrollingOnIe = false;
this._highlightPosition = 0;
this._wasTap = true;
this._placeholderValue = this._generatePlaceholderValue();
this._baseId = (0, utils_1.generateId)(this.passedElement.element, 'choices-');
/**
* setting direction in cases where it's explicitly set on passedElement
* or when calculated direction is different from the document
*/
this._direction = this.passedElement.dir;
if (!this._direction) {
var elementDirection = window.getComputedStyle(this.passedElement.element).direction;
var documentDirection = window.getComputedStyle(document.documentElement).direction;
if (elementDirection !== documentDirection) {
this._direction = elementDirection;
}
}
this._idNames = {
itemChoice: 'item-choice'
};
if (this._isSelectElement) {
// Assign preset groups from passed element
this._presetGroups = this.passedElement.optionGroups;
// Assign preset options from passed element
this._presetOptions = this.passedElement.options;
}
// Assign preset choices from passed object
this._presetChoices = this.config.choices;
// Assign preset items from passed object first
this._presetItems = this.config.items;
// Add any values passed from attribute
if (this.passedElement.value && this._isTextElement) {
var splitValues = this.passedElement.value.split(this.config.delimiter);
this._presetItems = this._presetItems.concat(splitValues);
}
// Create array of choices from option elements
if (this.passedElement.options) {
this.passedElement.options.forEach(function (option) {
_this._presetChoices.push({
value: option.value,
label: option.innerHTML,
selected: !!option.selected,
disabled: option.disabled || option.parentNode.disabled,
placeholder: option.value === '' || option.hasAttribute('placeholder'),
customProperties: (0, utils_1.parseCustomProperties)(option.dataset.customProperties)
});
});
}
this._render = this._render.bind(this);
this._onFocus = this._onFocus.bind(this);
this._onBlur = this._onBlur.bind(this);
this._onKeyUp = this._onKeyUp.bind(this);
this._onKeyDown = this._onKeyDown.bind(this);
this._onClick = this._onClick.bind(this);
this._onTouchMove = this._onTouchMove.bind(this);
this._onTouchEnd = this._onTouchEnd.bind(this);
this._onMouseDown = this._onMouseDown.bind(this);
this._onMouseOver = this._onMouseOver.bind(this);
this._onFormReset = this._onFormReset.bind(this);
this._onSelectKey = this._onSelectKey.bind(this);
this._onEnterKey = this._onEnterKey.bind(this);
this._onEscapeKey = this._onEscapeKey.bind(this);
this._onDirectionKey = this._onDirectionKey.bind(this);
this._onDeleteKey = this._onDeleteKey.bind(this);
// If element has already been initialised with Choices, fail silently
if (this.passedElement.isActive) {
if (!this.config.silent) {
console.warn('Trying to initialise Choices on element already initialised', {
element: element
});
}
this.initialised = true;
return;
}
// Let's go
this.init();
}
Object.defineProperty(Choices, "defaults", {
get: function () {
return Object.preventExtensions({
get options() {
return USER_DEFAULTS;
},
get templates() {
return templates_1.default;
}
});
},
enumerable: false,
configurable: true
});
Choices.prototype.init = function () {
if (this.initialised) {
return;
}
this._createTemplates();
this._createElements();
this._createStructure();
this._store.subscribe(this._render);
this._render();
this._addEventListeners();
var shouldDisable = !this.config.addItems || this.passedElement.element.hasAttribute('disabled');
if (shouldDisable) {
this.disable();
}
this.initialised = true;
var callbackOnInit = this.config.callbackOnInit;
// Run callback if it is a function
if (callbackOnInit && typeof callbackOnInit === 'function') {
callbackOnInit.call(this);
}
};
Choices.prototype.destroy = function () {
if (!this.initialised) {
return;
}
this._removeEventListeners();
this.passedElement.reveal();
this.containerOuter.unwrap(this.passedElement.element);
this.clearStore();
if (this._isSelectElement) {
this.passedElement.options = this._presetOptions;
}
this._templates = templates_1.default;
this.initialised = false;
};
Choices.prototype.enable = function () {
if (this.passedElement.isDisabled) {
this.passedElement.enable();
}
if (this.containerOuter.isDisabled) {
this._addEventListeners();
this.input.enable();
this.containerOuter.enable();
}
return this;
};
Choices.prototype.disable = function () {
if (!this.passedElement.isDisabled) {
this.passedElement.disable();
}
if (!this.containerOuter.isDisabled) {
this._removeEventListeners();
this.input.disable();
this.containerOuter.disable();
}
return this;
};
Choices.prototype.highlightItem = function (item, runEvent) {
if (runEvent === void 0) {
runEvent = true;
}
if (!item || !item.id) {
return this;
}
var id = item.id, _a = item.groupId, groupId = _a === void 0 ? -1 : _a, _b = item.value, value = _b === void 0 ? '' : _b, _c = item.label, label = _c === void 0 ? '' : _c;
var group = groupId >= 0 ? this._store.getGroupById(groupId) : null;
this._store.dispatch((0, items_1.highlightItem)(id, true));
if (runEvent) {
this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, {
id: id,
value: value,
label: label,
groupValue: group && group.value ? group.value : null
});
}
return this;
};
Choices.prototype.unhighlightItem = function (item) {
if (!item || !item.id) {
return this;
}
var id = item.id, _a = item.groupId, groupId = _a === void 0 ? -1 : _a, _b = item.value, value = _b === void 0 ? '' : _b, _c = item.label, label = _c === void 0 ? '' : _c;
var group = groupId >= 0 ? this._store.getGroupById(groupId) : null;
this._store.dispatch((0, items_1.highlightItem)(id, false));
this.passedElement.triggerEvent(constants_1.EVENTS.highlightItem, {
id: id,
value: value,
label: label,
groupValue: group && group.value ? group.value : null
});
return this;
};
Choices.prototype.highlightAll = function () {
var _this = this;
this._store.items.forEach(function (item) {
return _this.highlightItem(item);
});
return this;
};
Choices.prototype.unhighlightAll = function () {
var _this = this;
this._store.items.forEach(function (item) {
return _this.unhighlightItem(item);
});
return this;
};
Choices.prototype.removeActiveItemsByValue = function (value) {
var _this = this;
this._store.activeItems.filter(function (item) {
return item.value === value;
}).forEach(function (item) {
return _this._removeItem(item);
});
return this;
};
Choices.prototype.removeActiveItems = function (excludedId) {
var _this = this;
this._store.activeItems.filter(function (_a) {
var id = _a.id;
return id !== excludedId;
}).forEach(function (item) {
return _this._removeItem(item);
});
return this;
};
Choices.prototype.removeHighlightedItems = function (runEvent) {
var _this = this;
if (runEvent === void 0) {
runEvent = false;
}
this._store.highlightedActiveItems.forEach(function (item) {
_this._removeItem(item);
// If this action was performed by the user
// trigger the event
if (runEvent) {
_this._triggerChange(item.value);
}
});
return this;
};
Choices.prototype.showDropdown = function (preventInputFocus) {
var _this = this;
if (this.dropdown.isActive) {
return this;
}
requestAnimationFrame(function () {
_this.dropdown.show();
_this.containerOuter.open(_this.dropdown.distanceFromTopWindow);
if (!preventInputFocus && _this._canSearch) {
_this.input.focus();
}
_this.passedElement.triggerEvent(constants_1.EVENTS.showDropdown, {});
});
return this;
};
Choices.prototype.hideDropdown = function (preventInputBlur) {
var _this = this;
if (!this.dropdown.isActive) {
return this;
}
requestAnimationFrame(function () {
_this.dropdown.hide();
_this.containerOuter.close();
if (!preventInputBlur && _this._canSearch) {
_this.input.removeActiveDescendant();
_this.input.blur();
}
_this.passedElement.triggerEvent(constants_1.EVENTS.hideDropdown, {});
});
return this;
};
Choices.prototype.getValue = function (valueOnly) {
if (valueOnly === void 0) {
valueOnly = false;
}
var values = this._store.activeItems.reduce(function (selectedItems, item) {
var itemValue = valueOnly ? item.value : item;
selectedItems.push(itemValue);
return selectedItems;
}, []);
return this._isSelectOneElement ? values[0] : values;
};
Choices.prototype.setValue = function (items) {
var _this = this;
if (!this.initialised) {
return this;
}
items.forEach(function (value) {
return _this._setChoiceOrItem(value);
});
return this;
};
Choices.prototype.setChoiceByValue = function (value) {
var _this = this;
if (!this.initialised || this._isTextElement) {
return this;
}
// If only one value has been passed, convert to array
var choiceValue = Array.isArray(value) ? value : [value];
// Loop through each value and
choiceValue.forEach(function (val) {
return _this._findAndSelectChoiceByValue(val);
});
return this;
};
/**
* Set choices of select input via an array of objects (or function that returns array of object or promise of it),
* a value field name and a label field name.
* This behaves the same as passing items via the choices option but can be called after initialising Choices.
* This can also be used to add groups of choices (see example 2); Optionally pass a true `replaceChoices` value to remove any existing choices.
* Optionally pass a `customProperties` object to add additional data to your choices (useful when searching/filtering etc).
*
* **Input types affected:** select-one, select-multiple
*
* @example
* ```js
* const example = new Choices(element);
*
* example.setChoices([
* {value: 'One', label: 'Label One', disabled: true},
* {value: 'Two', label: 'Label Two', selected: true},
* {value: 'Three', label: 'Label Three'},
* ], 'value', 'label', false);
* ```
*
* @example
* ```js
* const example = new Choices(element);
*
* example.setChoices(async () => {
* try {
* const items = await fetch('/items');
* return items.json()
* } catch(err) {
* console.error(err)
* }
* });
* ```
*
* @example
* ```js
* const example = new Choices(element);
*
* example.setChoices([{
* label: 'Group one',
* id: 1,
* disabled: false,
* choices: [
* {value: 'Child One', label: 'Child One', selected: true},
* {value: 'Child Two', label: 'Child Two', disabled: true},
* {value: 'Child Three', label: 'Child Three'},
* ]
* },
* {
* label: 'Group two',
* id: 2,
* disabled: false,
* choices: [
* {value: 'Child Four', label: 'Child Four', disabled: true},
* {value: 'Child Five', label: 'Child Five'},
* {value: 'Child Six', label: 'Child Six', customProperties: {
* description: 'Custom description about child six',
* random: 'Another random custom property'
* }},
* ]
* }], 'value', 'label', false);
* ```
*/
Choices.prototype.setChoices = function (choicesArrayOrFetcher, value, label, replaceChoices) {
var _this = this;
if (choicesArrayOrFetcher === void 0) {
choicesArrayOrFetcher = [];
}
if (value === void 0) {
value = 'value';
}
if (label === void 0) {
label = 'label';
}
if (replaceChoices === void 0) {
replaceChoices = false;
}
if (!this.initialised) {
throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");
}
if (!this._isSelectElement) {
throw new TypeError("setChoices can't be used with INPUT based Choices");
}
if (typeof value !== 'string' || !value) {
throw new TypeError("value parameter must be a name of 'value' field in passed objects");
}
// Clear choices if needed
if (replaceChoices) {
this.clearChoices();
}
if (typeof choicesArrayOrFetcher === 'function') {
// it's a choices fetcher function
var fetcher_1 = choicesArrayOrFetcher(this);
if (typeof Promise === 'function' && fetcher_1 instanceof Promise) {
// that's a promise
// eslint-disable-next-line no-promise-executor-return
return new Promise(function (resolve) {
return requestAnimationFrame(resolve);
}).then(function () {
return _this._handleLoadingState(true);
}).then(function () {
return fetcher_1;
}).then(function (data) {
return _this.setChoices(data, value, label, replaceChoices);
}).catch(function (err) {
if (!_this.config.silent) {
console.error(err);
}
}).then(function () {
return _this._handleLoadingState(false);
}).then(function () {
return _this;
});
}
// function returned something else than promise, let's check if it's an array of choices
if (!Array.isArray(fetcher_1)) {
throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof fetcher_1));
}
// recursion with results, it's sync and choices were cleared already
return this.setChoices(fetcher_1, value, label, false);
}
if (!Array.isArray(choicesArrayOrFetcher)) {
throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");
}
this.containerOuter.removeLoadingState();
this._startLoading();
choicesArrayOrFetcher.forEach(function (groupOrChoice) {
if (groupOrChoice.choices) {
_this._addGroup({
id: groupOrChoice.id ? parseInt("".concat(groupOrChoice.id), 10) : null,
group: groupOrChoice,
valueKey: value,
labelKey: label
});
}
else {
var choice = groupOrChoice;
_this._addChoice({
value: choice[value],
label: choice[label],
isSelected: !!choice.selected,
isDisabled: !!choice.disabled,
placeholder: !!choice.placeholder,
customProperties: choice.customProperties
});
}
});
this._stopLoading();
return this;
};
Choices.prototype.clearChoices = function () {
this._store.dispatch((0, choices_1.clearChoices)());
return this;
};
Choices.prototype.clearStore = function () {
this._store.dispatch((0, misc_1.clearAll)());
return this;
};
Choices.prototype.clearInput = function () {
var shouldSetInputWidth = !this._isSelectOneElement;
this.input.clear(shouldSetInputWidth);
if (!this._isTextElement && this._canSearch) {
this._isSearching = false;
this._store.dispatch((0, choices_1.activateChoices)(true));
}
return this;
};
Choices.prototype._render = function () {
if (this._store.isLoading()) {
return;
}
this._currentState = this._store.state;
var stateChanged = this._currentState.choices !== this._prevState.choices || this._currentState.groups !== this._prevState.groups || this._currentState.items !== this._prevState.items;
var shouldRenderChoices = this._isSelectElement;
var shouldRenderItems = this._currentState.items !== this._prevState.items;
if (!stateChanged) {
return;
}
if (shouldRenderChoices) {
this._renderChoices();
}
if (shouldRenderItems) {
this._renderItems();
}
this._prevState = this._currentState;
};
Choices.prototype._renderChoices = function () {
var _this = this;
var _a = this._store, activeGroups = _a.activeGroups, activeChoices = _a.activeChoices;
var choiceListFragment = document.createDocumentFragment();
this.choiceList.clear();
if (this.config.resetScrollPosition) {
requestAnimationFrame(function () {
return _this.choiceList.scrollToTop();
});
}
// If we have grouped options
if (activeGroups.length >= 1 && !this._isSearching) {
// If we have a placeholder choice along with groups
var activePlaceholders = activeChoices.filter(function (activeChoice) {
return activeChoice.placeholder === true && activeChoice.groupId === -1;
});
if (activePlaceholders.length >= 1) {
choiceListFragment = this._createChoicesFragment(activePlaceholders, choiceListFragment);
}
choiceListFragment = this._createGroupsFragment(activeGroups, activeChoices, choiceListFragment);
}
else if (activeChoices.length >= 1) {
choiceListFragment = this._createChoicesFragment(activeChoices, choiceListFragment);
}
// If we have choices to show
if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) {
var activeItems = this._store.activeItems;
var canAddItem = this._canAddItem(activeItems, this.input.value);
// ...and we can select them
if (canAddItem.response) {
// ...append them and highlight the first choice
this.choiceList.append(choiceListFragment);
this._highlightChoice();
}
else {
var notice = this._getTemplate('notice', canAddItem.notice);
this.choiceList.append(notice);
}
}
else {
// Otherwise show a notice
var dropdownItem = void 0;
var notice = void 0;
if (this._isSearching) {
notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText;
dropdownItem = this._getTemplate('notice', notice, 'no-results');
}
else {
notice = typeof this.config.noChoicesText === 'function' ? this.config.noChoicesText() : this.config.noChoicesText;
dropdownItem = this._getTemplate('notice', notice, 'no-choices');
}
this.choiceList.append(dropdownItem);
}
};
Choices.prototype._renderItems = function () {
var activeItems = this._store.activeItems || [];
this.itemList.clear();
// Create a fragment to store our list items
// (so we don't have to update the DOM for each item)
var itemListFragment = this._createItemsFragment(activeItems);
// If we have items to add, append them
if (itemListFragment.childNodes) {
this.itemList.append(itemListFragment);
}
};
Choices.prototype._createGroupsFragment = function (groups, choices, fragment) {
var _this = this;
if (fragment === void 0) {
fragment = document.createDocumentFragment();
}
var getGroupChoices = function (group) {
return choices.filter(function (choice) {
if (_this._isSelectOneElement) {
return choice.groupId === group.id;
}
return choice.groupId === group.id && (_this.config.renderSelectedChoices === 'always' || !choice.selected);
});
};
// If sorting is enabled, filter groups
if (this.config.shouldSort) {
groups.sort(this.config.sorter);
}
groups.forEach(function (group) {
var groupChoices = getGroupChoices(group);
if (groupChoices.length >= 1) {
var dropdownGroup = _this._getTemplate('choiceGroup', group);
fragment.appendChild(dropdownGroup);
_this._createChoicesFragment(groupChoices, fragment, true);
}
});
return fragment;
};
Choices.prototype._createChoicesFragment = function (choices, fragment, withinGroup) {
var _this = this;
if (fragment === void 0) {
fragment = document.createDocumentFragment();
}
if (withinGroup === void 0) {
withinGroup = false;
}
// Create a fragment to store our list items (so we don't have to update the DOM for each item)
var _a = this.config, renderSelectedChoices = _a.renderSelectedChoices, searchResultLimit = _a.searchResultLimit, renderChoiceLimit = _a.renderChoiceLimit;
var filter = this._isSearching ? utils_1.sortByScore : this.config.sorter;
var appendChoice = function (choice) {
var shouldRender = renderSelectedChoices === 'auto' ? _this._isSelectOneElement || !choice.selected : true;
if (shouldRender) {
var dropdownItem = _this._getTemplate('choice', choice, _this.config.itemSelectText);
fragment.appendChild(dropdownItem);
}
};
var rendererableChoices = choices;
if (renderSelectedChoices === 'auto' && !this._isSelectOneElement) {
rendererableChoices = choices.filter(function (choice) {
return !choice.selected;
});
}
// Split array into placeholders and "normal" choices
var _b = rendererableChoices.reduce(function (acc, choice) {
if (choice.placeholder) {
acc.placeholderChoices.push(choice);
}
else {
acc.normalChoices.push(choice);
}
return acc;
}, {
placeholderChoices: [],
normalChoices: []
}), placeholderChoices = _b.placeholderChoices, normalChoices = _b.normalChoices;
// If sorting is enabled or the user is searching, filter choices
if (this.config.shouldSort || this._isSearching) {
normalChoices.sort(filter);
}
var choiceLimit = rendererableChoices.length;
// Prepend placeholeder
var sortedChoices = this._isSelectOneElement ? __spreadArray(__spreadArray([], placeholderChoices, true), normalChoices, true) : normalChoices;
if (this._isSearching) {
choiceLimit = searchResultLimit;
}
else if (renderChoiceLimit && renderChoiceLimit > 0 && !withinGroup) {
choiceLimit = renderChoiceLimit;
}
// Add each choice to dropdown within range
for (var i = 0; i < choiceLimit; i += 1) {
if (sortedChoices[i]) {
appendChoice(sortedChoices[i]);
}
}
return fragment;
};
Choices.prototype._createItemsFragment = function (items, fragment) {
var _this = this;
if (fragment === void 0) {
fragment = document.createDocumentFragment();
}
// Create fragment to add elements to
var _a = this.config, shouldSortItems = _a.shouldSortItems, sorter = _a.sorter, removeItemButton = _a.removeItemButton;
// If sorting is enabled, filter items
if (shouldSortItems && !this._isSelectOneElement) {
items.sort(sorter);
}
if (this._isTextElement) {
// Update the value of the hidden input
this.passedElement.value = items.map(function (_a) {
var value = _a.value;
return value;
}).join(this.config.delimiter);
}
else {
// Update the options of the hidden input
this.passedElement.options = items;
}
var addItemToFragment = function (item) {
// Create new list element
var listItem = _this._getTemplate('item', item, removeItemButton);
// Append it to list
fragment.appendChild(listItem);
};
// Add each list item to list
items.forEach(addItemToFragment);
return fragment;
};
Choices.prototype._triggerChange = function (value) {
if (value === undefined || value === null) {
return;
}
this.passedElement.triggerEvent(constants_1.EVENTS.change, {
value: value
});
};
Choices.prototype._selectPlaceholderChoice = function (placeholderChoice) {
this._addItem({
value: placeholderChoice.value,
label: placeholderChoice.label,
choiceId: placeholderChoice.id,
groupId: placeholderChoice.groupId,
placeholder: placeholderChoice.placeholder
});
this._triggerChange(placeholderChoice.value);
};
Choices.prototype._handleButtonAction = function (activeItems, element) {
if (!activeItems || !element || !this.config.removeItems || !this.config.removeItemButton) {
return;
}
var itemId = element.parentNode && element.parentNode.dataset.id;
var itemToRemove = itemId && activeItems.find(function (item) {
return item.id === parseInt(itemId, 10);
});
if (!itemToRemove) {
return;
}
// Remove item associated with button
this._removeItem(itemToRemove);
this._triggerChange(itemToRemove.value);
if (this._isSelectOneElement && this._store.placeholderChoice) {
this._selectPlaceholderChoice(this._store.placeholderChoice);
}
};
Choices.prototype._handleItemAction = function (activeItems, element, hasShiftKey) {
var _this = this;
if (hasShiftKey === void 0) {
hasShiftKey = false;
}
if (!activeItems || !element || !this.config.removeItems || this._isSelectOneElement) {
return;
}
var passedId = element.dataset.id;
// We only want to select one item with a click
// so we deselect any items that aren't the target
// unless shift is being pressed
activeItems.forEach(function (item) {
if (item.id === parseInt("".concat(passedId), 10) && !item.highlighted) {
_this.highlightItem(item);
}
else if (!hasShiftKey && item.highlighted) {
_this.unhighlightItem(item);
}
});
// Focus input as without focus, a user cannot do anything with a
// highlighted item
this.input.focus();
};
Choices.prototype._handleChoiceAction = function (activeItems, element) {
if (!activeItems || !element) {
return;
}
// If we are clicking on an option
var id = element.dataset.id;
var choice = id && this._store.getChoiceById(id);
if (!choice) {
return;
}
var passedKeyCode = activeItems[0] && activeItems[0].keyCode ? activeItems[0].keyCode : undefined;
var hasActiveDropdown = this.dropdown.isActive;
// Update choice keyCode
choice.keyCode = passedKeyCode;
this.passedElement.triggerEvent(constants_1.EVENTS.choice, {
choice: choice
});
if (!choice.selected && !choice.disabled) {
var canAddItem = this._canAddItem(activeItems, choice.value);
if (canAddItem.response) {
this._addItem({
value: choice.value,
label: choice.label,
choiceId: choice.id,
groupId: choice.groupId,
customProperties: choice.customProperties,
placeholder: choice.placeholder,
keyCode: choice.keyCode
});
this._triggerChange(choice.value);
}
}
this.clearInput();
// We want to close the dropdown if we are dealing with a single select box
if (hasActiveDropdown && this._isSelectOneElement) {
this.hideDropdown(true);
this.containerOuter.focus();
}
};
Choices.prototype._handleBackspace = function (activeItems) {
if (!this.config.removeItems || !activeItems) {
return;
}
var lastItem = activeItems[activeItems.length - 1];
var hasHighlightedItems = activeItems.some(function (item) {
return item.highlighted;
});
// If editing the last item is allowed and there are not other selected items,
// we can edit the item value. Otherwise if we can remove items, remove all selected items
if (this.config.editItems && !hasHighlightedItems && lastItem) {
this.input.value = lastItem.value;
this.input.setWidth();
this._removeItem(lastItem);
this._triggerChange(lastItem.value);
}
else {
if (!hasHighlightedItems) {
// Highlight last item if none already highlighted
this.highlightItem(lastItem, false);
}
this.removeHighlightedItems(true);
}
};
Choices.prototype._startLoading = function () {
this._store.dispatch((0, misc_1.setIsLoading)(true));
};
Choices.prototype._stopLoading = function () {
this._store.dispatch((0, misc_1.setIsLoading)(false));
};
Choices.prototype._handleLoadingState = function (setLoading) {
if (setLoading === void 0) {
setLoading = true;
}
var placeholderItem = this.itemList.getChild(".".concat(this.config.classNames.placeholder));
if (setLoading) {
this.disable();
this.containerOuter.addLoadingState();
if (this._isSelectOneElement) {
if (!placeholderItem) {
placeholderItem = this._getTemplate('placeholder', this.config.loadingText);
if (placeholderItem) {
this.itemList.append(placeholderItem);
}
}
else {
placeholderItem.innerHTML = this.config.loadingText;
}
}
else {
this.input.placeholder = this.config.loadingText;
}
}
else {
this.enable();
this.containerOuter.removeLoadingState();
if (this._isSelectOneElement) {
if (placeholderItem) {
placeholderItem.innerHTML = this._placeholderValue || '';
}
}
else {
this.input.placeholder = this._placeholderValue || '';
}
}
};
Choices.prototype._handleSearch = function (value) {
if (!this.input.isFocussed) {
return;
}
var choices = this._store.choices;
var _a = this.config, searchFloor = _a.searchFloor, searchChoices = _a.searchChoices;
var hasUnactiveChoices = choices.some(function (option) {
return !option.active;
});
// Check that we have a value to search and the input was an alphanumeric character
if (value !== null && typeof value !== 'undefined' && value.length >= searchFloor) {
var resultCount = searchChoices ? this._searchChoices(value) : 0;
// Trigger search event
this.passedElement.triggerEvent(constants_1.EVENTS.search, {
value: value,
resultCount: resultCount
});
}
else if (hasUnactiveChoices) {
// Otherwise reset choices to active
this._isSearching = false;
this._store.dispatch((0, choices_1.activateChoices)(true));
}
};
Choices.prototype._canAddItem = function (activeItems, value) {
var canAddItem = true;
var notice = typeof this.config.addItemText === 'function' ? this.config.addItemText(value) : this.config.addItemText;
if (!this._isSelectOneElement) {
var isDuplicateValue = (0, utils_1.existsInArray)(activeItems, value);
if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length) {
// If there is a max entry limit and we have reached that limit
// don't update
canAddItem = false;
notice = typeof this.config.maxItemText === 'function' ? this.config.maxItemText(this.config.maxItemCount) : this.config.maxItemText;
}
if (!this.config.duplicateItemsAllowed && isDuplicateValue && canAddItem) {
canAddItem = false;
notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText;
}
if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) {
canAddItem = false;
notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText;
}
}
return {
response: canAddItem,
notice: notice
};
};
Choices.prototype._searchChoices = function (value) {
var newValue = typeof value === 'string' ? value.trim() : value;
var currentValue = typeof this._currentValue === 'string' ? this._currentValue.trim() : this._currentValue;
if (newValue.length < 1 && newValue === "".concat(currentValue, " ")) {
return 0;
}
// If new value matches the desired length and is not the same as the current value with a space
var haystack = this._store.searchableChoices;
var needle = newValue;
var options = Object.assign(this.config.fuseOptions, {
keys: __spreadArray([], this.config.searchFields, true),
includeMatches: true
});
var fuse = new fuse_js_1.default(haystack, options);
var results = fuse.search(needle); // see https://github.com/krisk/Fuse/issues/303
this._currentValue = newValue;
this._highlightPosition = 0;
this._isSearching = true;
this._store.dispatch((0, choices_1.filterChoices)(results));
return results.length;
};
Choices.prototype._addEventListeners = function () {
var documentElement = document.documentElement;
// capture events - can cancel event processing or propagation
documentElement.addEventListener('touchend', this._onTouchEnd, true);
this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true);
this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true);
// passive events - doesn't call `preventDefault` or `stopPropagation`
documentElement.addEventListener('click', this._onClick, {
passive: true
});
documentElement.addEventListener('touchmove', this._onTouchMove, {
passive: true
});
this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {
passive: true
});
if (this._isSelectOneElement) {
this.containerOuter.element.addEventListener('focus', this._onFocus, {
passive: true
});
this.containerOuter.element.addEventListener('blur', this._onBlur, {
passive: true
});
}
this.input.element.addEventListener('keyup', this._onKeyUp, {
passive: true
});
this.input.element.addEventListener('focus', this._onFocus, {
passive: true
});
this.input.element.addEventListener('blur', this._onBlur, {
passive: true
});
if (this.input.element.form) {
this.input.element.form.addEventListener('reset', this._onFormReset, {
passive: true
});
}
this.input.addEventListeners();
};
Choices.prototype._removeEventListeners = function () {
var documentElement = document.documentElement;
documentElement.removeEventListener('touchend', this._onTouchEnd, true);
this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true);
this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true);
documentElement.removeEventListener('click', this._onClick);
documentElement.removeEventListener('touchmove', this._onTouchMove);
this.dropdown.element.removeEventListener('mouseover', this._onMouseOver);
if (this._isSelectOneElement) {
this.containerOuter.element.removeEventListener('focus', this._onFocus);
this.containerOuter.element.removeEventListener('blur', this._onBlur);
}
this.input.element.removeEventListener('keyup', this._onKeyUp);
this.input.element.removeEventListener('focus', this._onFocus);
this.input.element.removeEventListener('blur', this._onBlur);
if (this.input.element.form) {
this.input.element.form.removeEventListener('reset', this._onFormReset);
}
this.input.removeEventListeners();
};
Choices.prototype._onKeyDown = function (event) {
var keyCode = event.keyCode;
var activeItems = this._store.activeItems;
var hasFocusedInput = this.input.isFocussed;
var hasActiveDropdown = this.dropdown.isActive;
var hasItems = this.itemList.hasChildren();
var keyString = String.fromCharCode(keyCode);
// eslint-disable-next-line no-control-regex
var wasPrintableChar = /[^\x00-\x1F]/.test(keyString);
var BACK_KEY = constants_1.KEY_CODES.BACK_KEY, DELETE_KEY = constants_1.KEY_CODES.DELETE_KEY, ENTER_KEY = constants_1.KEY_CODES.ENTER_KEY, A_KEY = constants_1.KEY_CODES.A_KEY, ESC_KEY = constants_1.KEY_CODES.ESC_KEY, UP_KEY = constants_1.KEY_CODES.UP_KEY, DOWN_KEY = constants_1.KEY_CODES.DOWN_KEY, PAGE_UP_KEY = constants_1.KEY_CODES.PAGE_UP_KEY, PAGE_DOWN_KEY = constants_1.KEY_CODES.PAGE_DOWN_KEY;
if (!this._isTextElement && !hasActiveDropdown && wasPrintableChar) {
this.showDropdown();
if (!this.input.isFocussed) {
/*
We update the input value with the pressed key as
the input was not focussed at the time of key press
therefore does not have the value of the key.
*/
this.input.value += event.key.toLowerCase();
}
}
switch (keyCode) {
case A_KEY:
return this._onSelectKey(event, hasItems);
case ENTER_KEY:
return this._onEnterKey(event, activeItems, hasActiveDropdown);
case ESC_KEY:
return this._onEscapeKey(hasActiveDropdown);
case UP_KEY:
case PAGE_UP_KEY:
case DOWN_KEY:
case PAGE_DOWN_KEY:
return this._onDirectionKey(event, hasActiveDropdown);
case DELETE_KEY:
case BACK_KEY:
return this._onDeleteKey(event, activeItems, hasFocusedInput);
default:
}
};
Choices.prototype._onKeyUp = function (_a) {
var target = _a.target, keyCode = _a.keyCode;
var value = this.input.value;
var activeItems = this._store.activeItems;
var canAddItem = this._canAddItem(activeItems, value);
var backKey = constants_1.KEY_CODES.BACK_KEY, deleteKey = constants_1.KEY_CODES.DELETE_KEY;
// We are typing into a text input and have a value, we want to show a dropdown
// notice. Otherwise hide the dropdown
if (this._isTextElement) {
var canShowDropdownNotice = canAddItem.notice && value;
if (canShowDropdownNotice) {
var dropdownItem = this._getTemplate('notice', canAddItem.notice);
this.dropdown.element.innerHTML = dropdownItem.outerHTML;
this.showDropdown(true);
}
else {
this.hideDropdown(true);
}
}
else {
var wasRemovalKeyCode = keyCode === backKey || keyCode === deleteKey;
var userHasRemovedValue = wasRemovalKeyCode && target && !target.value;
var canReactivateChoices = !this._isTextElement && this._isSearching;
var canSearch = this._canSearch && canAddItem.response;
if (userHasRemovedValue && canReactivateChoices) {
this._isSearching = false;
this._store.dispatch((0, choices_1.activateChoices)(true));
}
else if (canSearch) {
this._handleSearch(this.input.rawValue);
}
}
this._canSearch = this.config.searchEnabled;
};
Choices.prototype._onSelectKey = function (event, hasItems) {
var ctrlKey = event.ctrlKey, metaKey = event.metaKey;
var hasCtrlDownKeyPressed = ctrlKey || metaKey;
// If CTRL + A or CMD + A have been pressed and there are items to select
if (hasCtrlDownKeyPressed && hasItems) {
this._canSearch = false;
var shouldHightlightAll = this.config.removeItems && !this.input.value && this.input.element === document.activeElement;
if (shouldHightlightAll) {
this.highlightAll();
}
}
};
Choices.prototype._onEnterKey = function (event, activeItems, hasActiveDropdown) {
var target = event.target;
var enterKey = constants_1.KEY_CODES.ENTER_KEY;
var targetWasButton = target && target.hasAttribute('data-button');
if (this._isTextElement && target && target.value) {
var value = this.input.value;
var canAddItem = this._canAddItem(activeItems, value);
if (canAddItem.response) {
this.hideDropdown(true);
this._addItem({
value: value
});
this._triggerChange(value);
this.clearInput();
}
}
if (targetWasButton) {
this._handleButtonAction(activeItems, target);
event.preventDefault();
}
if (hasActiveDropdown) {
var highlightedChoice = this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));
if (highlightedChoice) {
// add enter keyCode value
if (activeItems[0]) {
activeItems[0].keyCode = enterKey; // eslint-disable-line no-param-reassign
}
this._handleChoiceAction(activeItems, highlightedChoice);
}
event.preventDefault();
}
else if (this._isSelectOneElement) {
this.showDropdown();
event.preventDefault();
}
};
Choices.prototype._onEscapeKey = function (hasActiveDropdown) {
if (hasActiveDropdown) {
this.hideDropdown(true);
this.containerOuter.focus();
}
};
Choices.prototype._onDirectionKey = function (event, hasActiveDropdown) {
var keyCode = event.keyCode, metaKey = event.metaKey;
var downKey = constants_1.KEY_CODES.DOWN_KEY, pageUpKey = constants_1.KEY_CODES.PAGE_UP_KEY, pageDownKey = constants_1.KEY_CODES.PAGE_DOWN_KEY;
// If up or down key is pressed, traverse through options
if (hasActiveDropdown || this._isSelectOneElement) {
this.showDropdown();
this._canSearch = false;
var directionInt = keyCode === downKey || keyCode === pageDownKey ? 1 : -1;
var skipKey = metaKey || keyCode === pageDownKey || keyCode === pageUpKey;
var selectableChoiceIdentifier = '[data-choice-selectable]';
var nextEl = void 0;
if (skipKey) {
if (directionInt > 0) {
nextEl = this.dropdown.element.querySelector("".concat(selectableChoiceIdentifier, ":last-of-type"));
}
else {
nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier);
}
}
else {
var currentEl = this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));
if (currentEl) {
nextEl = (0, utils_1.getAdjacentEl)(currentEl, selectableChoiceIdentifier, directionInt);
}
else {
nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier);
}
}
if (nextEl) {
// We prevent default to stop the cursor moving
// when pressing the arrow
if (!(0, utils_1.isScrolledIntoView)(nextEl, this.choiceList.element, directionInt)) {
this.choiceList.scrollToChildElement(nextEl, directionInt);
}
this._highlightChoice(nextEl);
}
// Prevent default to maintain cursor position whilst
// traversing dropdown options
event.preventDefault();
}
};
Choices.prototype._onDeleteKey = function (event, activeItems, hasFocusedInput) {
var target = event.target;
// If backspace or delete key is pressed and the input has no value
if (!this._isSelectOneElement && !target.value && hasFocusedInput) {
this._handleBackspace(activeItems);
event.preventDefault();
}
};
Choices.prototype._onTouchMove = function () {
if (this._wasTap) {
this._wasTap = false;
}
};
Choices.prototype._onTouchEnd = function (event) {
var target = (event || event.touches[0]).target;
var touchWasWithinContainer = this._wasTap && this.containerOuter.element.contains(target);
if (touchWasWithinContainer) {
var containerWasExactTarget = target === this.containerOuter.element || target === this.containerInner.element;
if (containerWasExactTarget) {
if (this._isTextElement) {
this.input.focus();
}
else if (this._isSelectMultipleElement) {
this.showDropdown();
}
}
// Prevents focus event firing
event.stopPropagation();
}
this._wasTap = true;
};
/**
* Handles mousedown event in capture mode for containetOuter.element
*/
Choices.prototype._onMouseDown = function (event) {
var target = event.target;
if (!(target instanceof HTMLElement)) {
return;
}
// If we have our mouse down on the scrollbar and are on IE11...
if (IS_IE11 && this.choiceList.element.contains(target)) {
// check if click was on a scrollbar area
var firstChoice = this.choiceList.element.firstElementChild;
var isOnScrollbar = this._direction === 'ltr' ? event.offsetX >= firstChoice.offsetWidth : event.offsetX < firstChoice.offsetLeft;
this._isScrollingOnIe = isOnScrollbar;
}
if (target === this.input.element) {
return;
}
var item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
var hasShiftKey = event.shiftKey;
var activeItems = this._store.activeItems;
var dataset = item.dataset;
if ('button' in dataset) {
this._handleButtonAction(activeItems, item);
}
else if ('item' in dataset) {
this._handleItemAction(activeItems, item, hasShiftKey);
}
else if ('choice' in dataset) {
this._handleChoiceAction(activeItems, item);
}
}
event.preventDefault();
};
/**
* Handles mouseover event over this.dropdown
* @param {MouseEvent} event
*/
Choices.prototype._onMouseOver = function (_a) {
var target = _a.target;
if (target instanceof HTMLElement && 'choice' in target.dataset) {
this._highlightChoice(target);
}
};
Choices.prototype._onClick = function (_a) {
var target = _a.target;
var clickWasWithinContainer = this.containerOuter.element.contains(target);
if (clickWasWithinContainer) {
if (!this.dropdown.isActive && !this.containerOuter.isDisabled) {
if (this._isTextElement) {
if (document.activeElement !== this.input.element) {
this.input.focus();
}
}
else {
this.showDropdown();
this.containerOuter.focus();
}
}
else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) {
this.hideDropdown();
}
}
else {
var hasHighlightedItems = this._store.highlightedActiveItems.length > 0;
if (hasHighlightedItems) {
this.unhighlightAll();
}
this.containerOuter.removeFocusState();
this.hideDropdown(true);
}
};
Choices.prototype._onFocus = function (_a) {
var _b;
var _this = this;
var target = _a.target;
var focusWasWithinContainer = target && this.containerOuter.element.contains(target);
if (!focusWasWithinContainer) {
return;
}
var focusActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () {
if (target === _this.input.element) {
_this.containerOuter.addFocusState();
}
}, _b[constants_1.SELECT_ONE_TYPE] = function () {
_this.containerOuter.addFocusState();
if (target === _this.input.element) {
_this.showDropdown(true);
}
}, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () {
if (target === _this.input.element) {
_this.showDropdown(true);
// If element is a select box, the focused element is the container and the dropdown
// isn't already open, focus and show dropdown
_this.containerOuter.addFocusState();
}
}, _b);
focusActions[this.passedElement.element.type]();
};
Choices.prototype._onBlur = function (_a) {
var _b;
var _this = this;
var target = _a.target;
var blurWasWithinContainer = target && this.containerOuter.element.contains(target);
if (blurWasWithinContainer && !this._isScrollingOnIe) {
var activeItems = this._store.activeItems;
var hasHighlightedItems_1 = activeItems.some(function (item) {
return item.highlighted;
});
var blurActions = (_b = {}, _b[constants_1.TEXT_TYPE] = function () {
if (target === _this.input.element) {
_this.containerOuter.removeFocusState();
if (hasHighlightedItems_1) {
_this.unhighlightAll();
}
_this.hideDropdown(true);
}
}, _b[constants_1.SELECT_ONE_TYPE] = function () {
_this.containerOuter.removeFocusState();
if (target === _this.input.element || target === _this.containerOuter.element && !_this._canSearch) {
_this.hideDropdown(true);
}
}, _b[constants_1.SELECT_MULTIPLE_TYPE] = function () {
if (target === _this.input.element) {
_this.containerOuter.removeFocusState();
_this.hideDropdown(true);
if (hasHighlightedItems_1) {
_this.unhighlightAll();
}
}
}, _b);
blurActions[this.passedElement.element.type]();
}
else {
// On IE11, clicking the scollbar blurs our input and thus
// closes the dropdown. To stop this, we refocus our input
// if we know we are on IE *and* are scrolling.
this._isScrollingOnIe = false;
this.input.element.focus();
}
};
Choices.prototype._onFormReset = function () {
this._store.dispatch((0, misc_1.resetTo)(this._initialState));
};
Choices.prototype._highlightChoice = function (el) {
var _this = this;
if (el === void 0) {
el = null;
}
var choices = Array.from(this.dropdown.element.querySelectorAll('[data-choice-selectable]'));
if (!choices.length) {
return;
}
var passedEl = el;
var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState)));
// Remove any highlighted choices
highlightedChoices.forEach(function (choice) {
choice.classList.remove(_this.config.classNames.highlightedState);
choice.setAttribute('aria-selected', 'false');
});
if (passedEl) {
this._highlightPosition = choices.indexOf(passedEl);
}
else {
// Highlight choice based on last known highlight location
if (choices.length > this._highlightPosition) {
// If we have an option to highlight
passedEl = choices[this._highlightPosition];
}
else {
// Otherwise highlight the option before
passedEl = choices[choices.length - 1];
}
if (!passedEl) {
passedEl = choices[0];
}
}
passedEl.classList.add(this.config.classNames.highlightedState);
passedEl.setAttribute('aria-selected', 'true');
this.passedElement.triggerEvent(constants_1.EVENTS.highlightChoice, {
el: passedEl
});
if (this.dropdown.isActive) {
// IE11 ignores aria-label and blocks virtual keyboard
// if aria-activedescendant is set without a dropdown
this.input.setActiveDescendant(passedEl.id);
this.containerOuter.setActiveDescendant(passedEl.id);
}
};
Choices.prototype._addItem = function (_a) {
var value = _a.value, _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.choiceId, choiceId = _c === void 0 ? -1 : _c, _d = _a.groupId, groupId = _d === void 0 ? -1 : _d, _e = _a.customProperties, customProperties = _e === void 0 ? {} : _e, _f = _a.placeholder, placeholder = _f === void 0 ? false : _f, _g = _a.keyCode, keyCode = _g === void 0 ? -1 : _g;
var passedValue = typeof value === 'string' ? value.trim() : value;
var items = this._store.items;
var passedLabel = label || passedValue;
var passedOptionId = choiceId || -1;
var group = groupId >= 0 ? this._store.getGroupById(groupId) : null;
var id = items ? items.length + 1 : 1;
// If a prepended value has been passed, prepend it
if (this.config.prependValue) {
passedValue = this.config.prependValue + passedValue.toString();
}
// If an appended value has been passed, append it
if (this.config.appendValue) {
passedValue += this.config.appendValue.toString();
}
this._store.dispatch((0, items_1.addItem)({
value: passedValue,
label: passedLabel,
id: id,
choiceId: passedOptionId,
groupId: groupId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
}));
if (this._isSelectOneElement) {
this.removeActiveItems(id);
}
// Trigger change event
this.passedElement.triggerEvent(constants_1.EVENTS.addItem, {
id: id,
value: passedValue,
label: passedLabel,
customProperties: customProperties,
groupValue: group && group.value ? group.value : null,
keyCode: keyCode
});
};
Choices.prototype._removeItem = function (item) {
var id = item.id, value = item.value, label = item.label, customProperties = item.customProperties, choiceId = item.choiceId, groupId = item.groupId;
var group = groupId && groupId >= 0 ? this._store.getGroupById(groupId) : null;
if (!id || !choiceId) {
return;
}
this._store.dispatch((0, items_1.removeItem)(id, choiceId));
this.passedElement.triggerEvent(constants_1.EVENTS.removeItem, {
id: id,
value: value,
label: label,
customProperties: customProperties,
groupValue: group && group.value ? group.value : null
});
};
Choices.prototype._addChoice = function (_a) {
var value = _a.value, _b = _a.label, label = _b === void 0 ? null : _b, _c = _a.isSelected, isSelected = _c === void 0 ? false : _c, _d = _a.isDisabled, isDisabled = _d === void 0 ? false : _d, _e = _a.groupId, groupId = _e === void 0 ? -1 : _e, _f = _a.customProperties, customProperties = _f === void 0 ? {} : _f, _g = _a.placeholder, placeholder = _g === void 0 ? false : _g, _h = _a.keyCode, keyCode = _h === void 0 ? -1 : _h;
if (typeof value === 'undefined' || value === null) {
return;
}
// Generate unique id
var choices = this._store.choices;
var choiceLabel = label || value;
var choiceId = choices ? choices.length + 1 : 1;
var choiceElementId = "".concat(this._baseId, "-").concat(this._idNames.itemChoice, "-").concat(choiceId);
this._store.dispatch((0, choices_1.addChoice)({
id: choiceId,
groupId: groupId,
elementId: choiceElementId,
value: value,
label: choiceLabel,
disabled: isDisabled,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
}));
if (isSelected) {
this._addItem({
value: value,
label: choiceLabel,
choiceId: choiceId,
customProperties: customProperties,
placeholder: placeholder,
keyCode: keyCode
});
}
};
Choices.prototype._addGroup = function (_a) {
var _this = this;
var group = _a.group, id = _a.id, _b = _a.valueKey, valueKey = _b === void 0 ? 'value' : _b, _c = _a.labelKey, labelKey = _c === void 0 ? 'label' : _c;
var groupChoices = (0, utils_1.isType)('Object', group) ? group.choices : Array.from(group.getElementsByTagName('OPTION'));
var groupId = id || Math.floor(new Date().valueOf() * Math.random());
var isDisabled = group.disabled ? group.disabled : false;
if (groupChoices) {
this._store.dispatch((0, groups_1.addGroup)({
value: group.label,
id: groupId,
active: true,
disabled: isDisabled
}));
var addGroupChoices = function (choice) {
var isOptDisabled = choice.disabled || choice.parentNode && choice.parentNode.disabled;
_this._addChoice({
value: choice[valueKey],
label: (0, utils_1.isType)('Object', choice) ? choice[labelKey] : choice.innerHTML,
isSelected: choice.selected,
isDisabled: isOptDisabled,
groupId: groupId,
customProperties: choice.customProperties,
placeholder: choice.placeholder
});
};
groupChoices.forEach(addGroupChoices);
}
else {
this._store.dispatch((0, groups_1.addGroup)({
value: group.label,
id: group.id,
active: false,
disabled: group.disabled
}));
}
};
Choices.prototype._getTemplate = function (template) {
var _a;
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return (_a = this._templates[template]).call.apply(_a, __spreadArray([this, this.config], args, false));
};
Choices.prototype._createTemplates = function () {
var callbackOnCreateTemplates = this.config.callbackOnCreateTemplates;
var userTemplates = {};
if (callbackOnCreateTemplates && typeof callbackOnCreateTemplates === 'function') {
userTemplates = callbackOnCreateTemplates.call(this, utils_1.strToEl);
}
this._templates = (0, deepmerge_1.default)(templates_1.default, userTemplates);
};
Choices.prototype._createElements = function () {
this.containerOuter = new components_1.Container({
element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type, this.config.labelId),
classNames: this.config.classNames,
type: this.passedElement.element.type,
position: this.config.position
});
this.containerInner = new components_1.Container({
element: this._getTemplate('containerInner'),
classNames: this.config.classNames,
type: this.passedElement.element.type,
position: this.config.position
});
this.input = new components_1.Input({
element: this._getTemplate('input', this._placeholderValue),
classNames: this.config.classNames,
type: this.passedElement.element.type,
preventPaste: !this.config.paste
});
this.choiceList = new components_1.List({
element: this._getTemplate('choiceList', this._isSelectOneElement)
});
this.itemList = new components_1.List({
element: this._getTemplate('itemList', this._isSelectOneElement)
});
this.dropdown = new components_1.Dropdown({
element: this._getTemplate('dropdown'),
classNames: this.config.classNames,
type: this.passedElement.element.type
});
};
Choices.prototype._createStructure = function () {
// Hide original element
this.passedElement.conceal();
// Wrap input in container preserving DOM ordering
this.containerInner.wrap(this.passedElement.element);
// Wrapper inner container with outer container
this.containerOuter.wrap(this.containerInner.element);
if (this._isSelectOneElement) {
this.input.placeholder = this.config.searchPlaceholderValue || '';
}
else if (this._placeholderValue) {
this.input.placeholder = this._placeholderValue;
this.input.setWidth();
}
this.containerOuter.element.appendChild(this.containerInner.element);
this.containerOuter.element.appendChild(this.dropdown.element);
this.containerInner.element.appendChild(this.itemList.element);
if (!this._isTextElement) {
this.dropdown.element.appendChild(this.choiceList.element);
}
if (!this._isSelectOneElement) {
this.containerInner.element.appendChild(this.input.element);
}
else if (this.config.searchEnabled) {
this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild);
}
if (this._isSelectElement) {
this._highlightPosition = 0;
this._isSearching = false;
this._startLoading();
if (this._presetGroups.length) {
this._addPredefinedGroups(this._presetGroups);
}
else {
this._addPredefinedChoices(this._presetChoices);
}
this._stopLoading();
}
if (this._isTextElement) {
this._addPredefinedItems(this._presetItems);
}
};
Choices.prototype._addPredefinedGroups = function (groups) {
var _this = this;
// If we have a placeholder option
var placeholderChoice = this.passedElement.placeholderOption;
if (placeholderChoice && placeholderChoice.parentNode && placeholderChoice.parentNode.tagName === 'SELECT') {
this._addChoice({
value: placeholderChoice.value,
label: placeholderChoice.innerHTML,
isSelected: placeholderChoice.selected,
isDisabled: placeholderChoice.disabled,
placeholder: true
});
}
groups.forEach(function (group) {
return _this._addGroup({
group: group,
id: group.id || null
});
});
};
Choices.prototype._addPredefinedChoices = function (choices) {
var _this = this;
// If sorting is enabled or the user is searching, filter choices
if (this.config.shouldSort) {
choices.sort(this.config.sorter);
}
var hasSelectedChoice = choices.some(function (choice) {
return choice.selected;
});
var firstEnabledChoiceIndex = choices.findIndex(function (choice) {
return choice.disabled === undefined || !choice.disabled;
});
choices.forEach(function (choice, index) {
var _a = choice.value, value = _a === void 0 ? '' : _a, label = choice.label, customProperties = choice.customProperties, placeholder = choice.placeholder;
if (_this._isSelectElement) {
// If the choice is actually a group
if (choice.choices) {
_this._addGroup({
group: choice,
id: choice.id || null
});
}
else {
/**
* If there is a selected choice already or the choice is not the first in
* the array, add each choice normally.
*
* Otherwise we pre-select the first enabled choice in the array ("select-one" only)
*/
var shouldPreselect = _this._isSelectOneElement && !hasSelectedChoice && index === firstEnabledChoiceIndex;
var isSelected = shouldPreselect ? true : choice.selected;
var isDisabled = choice.disabled;
_this._addChoice({
value: value,
label: label,
isSelected: !!isSelected,
isDisabled: !!isDisabled,
placeholder: !!placeholder,
customProperties: customProperties
});
}
}
else {
_this._addChoice({
value: value,
label: label,
isSelected: !!choice.selected,
isDisabled: !!choice.disabled,
placeholder: !!choice.placeholder,
customProperties: customProperties
});
}
});
};
Choices.prototype._addPredefinedItems = function (items) {
var _this = this;
items.forEach(function (item) {
if (typeof item === 'object' && item.value) {
_this._addItem({
value: item.value,
label: item.label,
choiceId: item.id,
customProperties: item.customProperties,
placeholder: item.placeholder
});
}
if (typeof item === 'string') {
_this._addItem({
value: item
});
}
});
};
Choices.prototype._setChoiceOrItem = function (item) {
var _this = this;
var itemType = (0, utils_1.getType)(item).toLowerCase();
var handleType = {
object: function () {
if (!item.value) {
return;
}
// If we are dealing with a select input, we need to create an option first
// that is then selected. For text inputs we can just add items normally.
if (!_this._isTextElement) {
_this._addChoice({
value: item.value,
label: item.label,
isSelected: true,
isDisabled: false,
customProperties: item.customProperties,
placeholder: item.placeholder
});
}
else {
_this._addItem({
value: item.value,
label: item.label,
choiceId: item.id,
customProperties: item.customProperties,
placeholder: item.placeholder
});
}
},
string: function () {
if (!_this._isTextElement) {
_this._addChoice({
value: item,
label: item,
isSelected: true,
isDisabled: false
});
}
else {
_this._addItem({
value: item
});
}
}
};
handleType[itemType]();
};
Choices.prototype._findAndSelectChoiceByValue = function (value) {
var _this = this;
var choices = this._store.choices;
// Check 'value' property exists and the choice isn't already selected
var foundChoice = choices.find(function (choice) {
return _this.config.valueComparer(choice.value, value);
});
if (foundChoice && !foundChoice.selected) {
this._addItem({
value: foundChoice.value,
label: foundChoice.label,
choiceId: foundChoice.id,
groupId: foundChoice.groupId,
customProperties: foundChoice.customProperties,
placeholder: foundChoice.placeholder,
keyCode: foundChoice.keyCode
});
}
};
Choices.prototype._generatePlaceholderValue = function () {
if (this._isSelectElement && this.passedElement.placeholderOption) {
var placeholderOption = this.passedElement.placeholderOption;
return placeholderOption ? placeholderOption.text : null;
}
var _a = this.config, placeholder = _a.placeholder, placeholderValue = _a.placeholderValue;
var dataset = this.passedElement.element.dataset;
if (placeholder) {
if (placeholderValue) {
return placeholderValue;
}
if (dataset.placeholder) {
return dataset.placeholder;
}
}
return null;
};
return Choices;
}();
exports["default"] = Choices;
/***/
}),
/***/ 613:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var utils_1 = __webpack_require__(799);
var constants_1 = __webpack_require__(883);
var Container = /** @class */ function () {
function Container(_a) {
var element = _a.element, type = _a.type, classNames = _a.classNames, position = _a.position;
this.element = element;
this.classNames = classNames;
this.type = type;
this.position = position;
this.isOpen = false;
this.isFlipped = false;
this.isFocussed = false;
this.isDisabled = false;
this.isLoading = false;
this._onFocus = this._onFocus.bind(this);
this._onBlur = this._onBlur.bind(this);
}
Container.prototype.addEventListeners = function () {
this.element.addEventListener('focus', this._onFocus);
this.element.addEventListener('blur', this._onBlur);
};
Container.prototype.removeEventListeners = function () {
this.element.removeEventListener('focus', this._onFocus);
this.element.removeEventListener('blur', this._onBlur);
};
/**
* Determine whether container should be flipped based on passed
* dropdown position
*/
Container.prototype.shouldFlip = function (dropdownPos) {
if (typeof dropdownPos !== 'number') {
return false;
}
// If flip is enabled and the dropdown bottom position is
// greater than the window height flip the dropdown.
var shouldFlip = false;
if (this.position === 'auto') {
shouldFlip = !window.matchMedia("(min-height: ".concat(dropdownPos + 1, "px)")).matches;
}
else if (this.position === 'top') {
shouldFlip = true;
}
return shouldFlip;
};
Container.prototype.setActiveDescendant = function (activeDescendantID) {
this.element.setAttribute('aria-activedescendant', activeDescendantID);
};
Container.prototype.removeActiveDescendant = function () {
this.element.removeAttribute('aria-activedescendant');
};
Container.prototype.open = function (dropdownPos) {
this.element.classList.add(this.classNames.openState);
this.element.setAttribute('aria-expanded', 'true');
this.isOpen = true;
if (this.shouldFlip(dropdownPos)) {
this.element.classList.add(this.classNames.flippedState);
this.isFlipped = true;
}
};
Container.prototype.close = function () {
this.element.classList.remove(this.classNames.openState);
this.element.setAttribute('aria-expanded', 'false');
this.removeActiveDescendant();
this.isOpen = false;
// A dropdown flips if it does not have space within the page
if (this.isFlipped) {
this.element.classList.remove(this.classNames.flippedState);
this.isFlipped = false;
}
};
Container.prototype.focus = function () {
if (!this.isFocussed) {
this.element.focus();
}
};
Container.prototype.addFocusState = function () {
this.element.classList.add(this.classNames.focusState);
};
Container.prototype.removeFocusState = function () {
this.element.classList.remove(this.classNames.focusState);
};
Container.prototype.enable = function () {
this.element.classList.remove(this.classNames.disabledState);
this.element.removeAttribute('aria-disabled');
if (this.type === constants_1.SELECT_ONE_TYPE) {
this.element.setAttribute('tabindex', '0');
}
this.isDisabled = false;
};
Container.prototype.disable = function () {
this.element.classList.add(this.classNames.disabledState);
this.element.setAttribute('aria-disabled', 'true');
if (this.type === constants_1.SELECT_ONE_TYPE) {
this.element.setAttribute('tabindex', '-1');
}
this.isDisabled = true;
};
Container.prototype.wrap = function (element) {
(0, utils_1.wrap)(element, this.element);
};
Container.prototype.unwrap = function (element) {
if (this.element.parentNode) {
// Move passed element outside this element
this.element.parentNode.insertBefore(element, this.element);
// Remove this element
this.element.parentNode.removeChild(this.element);
}
};
Container.prototype.addLoadingState = function () {
this.element.classList.add(this.classNames.loadingState);
this.element.setAttribute('aria-busy', 'true');
this.isLoading = true;
};
Container.prototype.removeLoadingState = function () {
this.element.classList.remove(this.classNames.loadingState);
this.element.removeAttribute('aria-busy');
this.isLoading = false;
};
Container.prototype._onFocus = function () {
this.isFocussed = true;
};
Container.prototype._onBlur = function () {
this.isFocussed = false;
};
return Container;
}();
exports["default"] = Container;
/***/
}),
/***/ 217:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var Dropdown = /** @class */ function () {
function Dropdown(_a) {
var element = _a.element, type = _a.type, classNames = _a.classNames;
this.element = element;
this.classNames = classNames;
this.type = type;
this.isActive = false;
}
Object.defineProperty(Dropdown.prototype, "distanceFromTopWindow", {
/**
* Bottom position of dropdown in viewport coordinates
*/
get: function () {
return this.element.getBoundingClientRect().bottom;
},
enumerable: false,
configurable: true
});
Dropdown.prototype.getChild = function (selector) {
return this.element.querySelector(selector);
};
/**
* Show dropdown to user by adding active state class
*/
Dropdown.prototype.show = function () {
this.element.classList.add(this.classNames.activeState);
this.element.setAttribute('aria-expanded', 'true');
this.isActive = true;
return this;
};
/**
* Hide dropdown from user
*/
Dropdown.prototype.hide = function () {
this.element.classList.remove(this.classNames.activeState);
this.element.setAttribute('aria-expanded', 'false');
this.isActive = false;
return this;
};
return Dropdown;
}();
exports["default"] = Dropdown;
/***/
}),
/***/ 520:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.WrappedSelect = exports.WrappedInput = exports.List = exports.Input = exports.Container = exports.Dropdown = void 0;
var dropdown_1 = __importDefault(__webpack_require__(217));
exports.Dropdown = dropdown_1.default;
var container_1 = __importDefault(__webpack_require__(613));
exports.Container = container_1.default;
var input_1 = __importDefault(__webpack_require__(11));
exports.Input = input_1.default;
var list_1 = __importDefault(__webpack_require__(624));
exports.List = list_1.default;
var wrapped_input_1 = __importDefault(__webpack_require__(541));
exports.WrappedInput = wrapped_input_1.default;
var wrapped_select_1 = __importDefault(__webpack_require__(982));
exports.WrappedSelect = wrapped_select_1.default;
/***/
}),
/***/ 11:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var utils_1 = __webpack_require__(799);
var constants_1 = __webpack_require__(883);
var Input = /** @class */ function () {
function Input(_a) {
var element = _a.element, type = _a.type, classNames = _a.classNames, preventPaste = _a.preventPaste;
this.element = element;
this.type = type;
this.classNames = classNames;
this.preventPaste = preventPaste;
this.isFocussed = this.element.isEqualNode(document.activeElement);
this.isDisabled = element.disabled;
this._onPaste = this._onPaste.bind(this);
this._onInput = this._onInput.bind(this);
this._onFocus = this._onFocus.bind(this);
this._onBlur = this._onBlur.bind(this);
}
Object.defineProperty(Input.prototype, "placeholder", {
set: function (placeholder) {
this.element.placeholder = placeholder;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Input.prototype, "value", {
get: function () {
return (0, utils_1.sanitise)(this.element.value);
},
set: function (value) {
this.element.value = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Input.prototype, "rawValue", {
get: function () {
return this.element.value;
},
enumerable: false,
configurable: true
});
Input.prototype.addEventListeners = function () {
this.element.addEventListener('paste', this._onPaste);
this.element.addEventListener('input', this._onInput, {
passive: true
});
this.element.addEventListener('focus', this._onFocus, {
passive: true
});
this.element.addEventListener('blur', this._onBlur, {
passive: true
});
};
Input.prototype.removeEventListeners = function () {
this.element.removeEventListener('input', this._onInput);
this.element.removeEventListener('paste', this._onPaste);
this.element.removeEventListener('focus', this._onFocus);
this.element.removeEventListener('blur', this._onBlur);
};
Input.prototype.enable = function () {
this.element.removeAttribute('disabled');
this.isDisabled = false;
};
Input.prototype.disable = function () {
this.element.setAttribute('disabled', '');
this.isDisabled = true;
};
Input.prototype.focus = function () {
if (!this.isFocussed) {
this.element.focus();
}
};
Input.prototype.blur = function () {
if (this.isFocussed) {
this.element.blur();
}
};
Input.prototype.clear = function (setWidth) {
if (setWidth === void 0) {
setWidth = true;
}
if (this.element.value) {
this.element.value = '';
}
if (setWidth) {
this.setWidth();
}
return this;
};
/**
* Set the correct input width based on placeholder
* value or input value
*/
Input.prototype.setWidth = function () {
// Resize input to contents or placeholder
var _a = this.element, style = _a.style, value = _a.value, placeholder = _a.placeholder;
style.minWidth = "".concat(placeholder.length + 1, "ch");
style.width = "".concat(value.length + 1, "ch");
};
Input.prototype.setActiveDescendant = function (activeDescendantID) {
this.element.setAttribute('aria-activedescendant', activeDescendantID);
};
Input.prototype.removeActiveDescendant = function () {
this.element.removeAttribute('aria-activedescendant');
};
Input.prototype._onInput = function () {
if (this.type !== constants_1.SELECT_ONE_TYPE) {
this.setWidth();
}
};
Input.prototype._onPaste = function (event) {
if (this.preventPaste) {
event.preventDefault();
}
};
Input.prototype._onFocus = function () {
this.isFocussed = true;
};
Input.prototype._onBlur = function () {
this.isFocussed = false;
};
return Input;
}();
exports["default"] = Input;
/***/
}),
/***/ 624:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var constants_1 = __webpack_require__(883);
var List = /** @class */ function () {
function List(_a) {
var element = _a.element;
this.element = element;
this.scrollPos = this.element.scrollTop;
this.height = this.element.offsetHeight;
}
List.prototype.clear = function () {
this.element.innerHTML = '';
};
List.prototype.append = function (node) {
this.element.appendChild(node);
};
List.prototype.getChild = function (selector) {
return this.element.querySelector(selector);
};
List.prototype.hasChildren = function () {
return this.element.hasChildNodes();
};
List.prototype.scrollToTop = function () {
this.element.scrollTop = 0;
};
List.prototype.scrollToChildElement = function (element, direction) {
var _this = this;
if (!element) {
return;
}
var listHeight = this.element.offsetHeight;
// Scroll position of dropdown
var listScrollPosition = this.element.scrollTop + listHeight;
var elementHeight = element.offsetHeight;
// Distance from bottom of element to top of parent
var elementPos = element.offsetTop + elementHeight;
// Difference between the element and scroll position
var destination = direction > 0 ? this.element.scrollTop + elementPos - listScrollPosition : element.offsetTop;
requestAnimationFrame(function () {
_this._animateScroll(destination, direction);
});
};
List.prototype._scrollDown = function (scrollPos, strength, destination) {
var easing = (destination - scrollPos) / strength;
var distance = easing > 1 ? easing : 1;
this.element.scrollTop = scrollPos + distance;
};
List.prototype._scrollUp = function (scrollPos, strength, destination) {
var easing = (scrollPos - destination) / strength;
var distance = easing > 1 ? easing : 1;
this.element.scrollTop = scrollPos - distance;
};
List.prototype._animateScroll = function (destination, direction) {
var _this = this;
var strength = constants_1.SCROLLING_SPEED;
var choiceListScrollTop = this.element.scrollTop;
var continueAnimation = false;
if (direction > 0) {
this._scrollDown(choiceListScrollTop, strength, destination);
if (choiceListScrollTop < destination) {
continueAnimation = true;
}
}
else {
this._scrollUp(choiceListScrollTop, strength, destination);
if (choiceListScrollTop > destination) {
continueAnimation = true;
}
}
if (continueAnimation) {
requestAnimationFrame(function () {
_this._animateScroll(destination, direction);
});
}
};
return List;
}();
exports["default"] = List;
/***/
}),
/***/ 730:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var utils_1 = __webpack_require__(799);
var WrappedElement = /** @class */ function () {
function WrappedElement(_a) {
var element = _a.element, classNames = _a.classNames;
this.element = element;
this.classNames = classNames;
if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLSelectElement)) {
throw new TypeError('Invalid element passed');
}
this.isDisabled = false;
}
Object.defineProperty(WrappedElement.prototype, "isActive", {
get: function () {
return this.element.dataset.choice === 'active';
},
enumerable: false,
configurable: true
});
Object.defineProperty(WrappedElement.prototype, "dir", {
get: function () {
return this.element.dir;
},
enumerable: false,
configurable: true
});
Object.defineProperty(WrappedElement.prototype, "value", {
get: function () {
return this.element.value;
},
set: function (value) {
// you must define setter here otherwise it will be readonly property
this.element.value = value;
},
enumerable: false,
configurable: true
});
WrappedElement.prototype.conceal = function () {
// Hide passed input
this.element.classList.add(this.classNames.input);
this.element.hidden = true;
// Remove element from tab index
this.element.tabIndex = -1;
// Backup original styles if any
var origStyle = this.element.getAttribute('style');
if (origStyle) {
this.element.setAttribute('data-choice-orig-style', origStyle);
}
this.element.setAttribute('data-choice', 'active');
};
WrappedElement.prototype.reveal = function () {
// Reinstate passed element
this.element.classList.remove(this.classNames.input);
this.element.hidden = false;
this.element.removeAttribute('tabindex');
// Recover original styles if any
var origStyle = this.element.getAttribute('data-choice-orig-style');
if (origStyle) {
this.element.removeAttribute('data-choice-orig-style');
this.element.setAttribute('style', origStyle);
}
else {
this.element.removeAttribute('style');
}
this.element.removeAttribute('data-choice');
// Re-assign values - this is weird, I know
// @todo Figure out why we need to do this
this.element.value = this.element.value; // eslint-disable-line no-self-assign
};
WrappedElement.prototype.enable = function () {
this.element.removeAttribute('disabled');
this.element.disabled = false;
this.isDisabled = false;
};
WrappedElement.prototype.disable = function () {
this.element.setAttribute('disabled', '');
this.element.disabled = true;
this.isDisabled = true;
};
WrappedElement.prototype.triggerEvent = function (eventType, data) {
(0, utils_1.dispatchEvent)(this.element, eventType, data);
};
return WrappedElement;
}();
exports["default"] = WrappedElement;
/***/
}),
/***/ 541:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __extends = this && this.__extends || function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p];
};
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var wrapped_element_1 = __importDefault(__webpack_require__(730));
var WrappedInput = /** @class */ function (_super) {
__extends(WrappedInput, _super);
function WrappedInput(_a) {
var element = _a.element, classNames = _a.classNames, delimiter = _a.delimiter;
var _this = _super.call(this, {
element: element,
classNames: classNames
}) || this;
_this.delimiter = delimiter;
return _this;
}
Object.defineProperty(WrappedInput.prototype, "value", {
get: function () {
return this.element.value;
},
set: function (value) {
this.element.setAttribute('value', value);
this.element.value = value;
},
enumerable: false,
configurable: true
});
return WrappedInput;
}(wrapped_element_1.default);
exports["default"] = WrappedInput;
/***/
}),
/***/ 982:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __extends = this && this.__extends || function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p];
};
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var wrapped_element_1 = __importDefault(__webpack_require__(730));
var WrappedSelect = /** @class */ function (_super) {
__extends(WrappedSelect, _super);
function WrappedSelect(_a) {
var element = _a.element, classNames = _a.classNames, template = _a.template;
var _this = _super.call(this, {
element: element,
classNames: classNames
}) || this;
_this.template = template;
return _this;
}
Object.defineProperty(WrappedSelect.prototype, "placeholderOption", {
get: function () {
return this.element.querySelector('option[value=""]') ||
// Backward compatibility layer for the non-standard placeholder attribute supported in older versions.
this.element.querySelector('option[placeholder]');
},
enumerable: false,
configurable: true
});
Object.defineProperty(WrappedSelect.prototype, "optionGroups", {
get: function () {
return Array.from(this.element.getElementsByTagName('OPTGROUP'));
},
enumerable: false,
configurable: true
});
Object.defineProperty(WrappedSelect.prototype, "options", {
get: function () {
return Array.from(this.element.options);
},
set: function (options) {
var _this = this;
var fragment = document.createDocumentFragment();
var addOptionToFragment = function (data) {
// Create a standard select option
var option = _this.template(data);
// Append it to fragment
fragment.appendChild(option);
};
// Add each list item to list
options.forEach(function (optionData) {
return addOptionToFragment(optionData);
});
this.appendDocFragment(fragment);
},
enumerable: false,
configurable: true
});
WrappedSelect.prototype.appendDocFragment = function (fragment) {
this.element.innerHTML = '';
this.element.appendChild(fragment);
};
return WrappedSelect;
}(wrapped_element_1.default);
exports["default"] = WrappedSelect;
/***/
}),
/***/ 883:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.SCROLLING_SPEED = exports.SELECT_MULTIPLE_TYPE = exports.SELECT_ONE_TYPE = exports.TEXT_TYPE = exports.KEY_CODES = exports.ACTION_TYPES = exports.EVENTS = void 0;
exports.EVENTS = {
showDropdown: 'showDropdown',
hideDropdown: 'hideDropdown',
change: 'change',
choice: 'choice',
search: 'search',
addItem: 'addItem',
removeItem: 'removeItem',
highlightItem: 'highlightItem',
highlightChoice: 'highlightChoice',
unhighlightItem: 'unhighlightItem'
};
exports.ACTION_TYPES = {
ADD_CHOICE: 'ADD_CHOICE',
FILTER_CHOICES: 'FILTER_CHOICES',
ACTIVATE_CHOICES: 'ACTIVATE_CHOICES',
CLEAR_CHOICES: 'CLEAR_CHOICES',
ADD_GROUP: 'ADD_GROUP',
ADD_ITEM: 'ADD_ITEM',
REMOVE_ITEM: 'REMOVE_ITEM',
HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM',
CLEAR_ALL: 'CLEAR_ALL',
RESET_TO: 'RESET_TO',
SET_IS_LOADING: 'SET_IS_LOADING'
};
exports.KEY_CODES = {
BACK_KEY: 46,
DELETE_KEY: 8,
ENTER_KEY: 13,
A_KEY: 65,
ESC_KEY: 27,
UP_KEY: 38,
DOWN_KEY: 40,
PAGE_UP_KEY: 33,
PAGE_DOWN_KEY: 34
};
exports.TEXT_TYPE = 'text';
exports.SELECT_ONE_TYPE = 'select-one';
exports.SELECT_MULTIPLE_TYPE = 'select-multiple';
exports.SCROLLING_SPEED = 4;
/***/
}),
/***/ 789:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.DEFAULT_CONFIG = exports.DEFAULT_CLASSNAMES = void 0;
var utils_1 = __webpack_require__(799);
exports.DEFAULT_CLASSNAMES = {
containerOuter: 'choices',
containerInner: 'choices__inner',
input: 'choices__input',
inputCloned: 'choices__input--cloned',
list: 'choices__list',
listItems: 'choices__list--multiple',
listSingle: 'choices__list--single',
listDropdown: 'choices__list--dropdown',
item: 'choices__item',
itemSelectable: 'choices__item--selectable',
itemDisabled: 'choices__item--disabled',
itemChoice: 'choices__item--choice',
placeholder: 'choices__placeholder',
group: 'choices__group',
groupHeading: 'choices__heading',
button: 'choices__button',
activeState: 'is-active',
focusState: 'is-focused',
openState: 'is-open',
disabledState: 'is-disabled',
highlightedState: 'is-highlighted',
selectedState: 'is-selected',
flippedState: 'is-flipped',
loadingState: 'is-loading',
noResults: 'has-no-results',
noChoices: 'has-no-choices'
};
exports.DEFAULT_CONFIG = {
items: [],
choices: [],
silent: false,
renderChoiceLimit: -1,
maxItemCount: -1,
addItems: true,
addItemFilter: null,
removeItems: true,
removeItemButton: false,
editItems: false,
allowHTML: true,
duplicateItemsAllowed: true,
delimiter: ',',
paste: true,
searchEnabled: true,
searchChoices: true,
searchFloor: 1,
searchResultLimit: 4,
searchFields: ['label', 'value'],
position: 'auto',
resetScrollPosition: true,
shouldSort: true,
shouldSortItems: false,
sorter: utils_1.sortByAlpha,
placeholder: true,
placeholderValue: null,
searchPlaceholderValue: null,
prependValue: null,
appendValue: null,
renderSelectedChoices: 'auto',
loadingText: 'Loading...',
noResultsText: 'No results found',
noChoicesText: 'No choices to choose from',
itemSelectText: 'Press to select',
uniqueItemText: 'Only unique values can be added',
customAddItemText: 'Only values matching specific conditions can be added',
addItemText: function (value) {
return "Press Enter to add \"".concat((0, utils_1.sanitise)(value), "\"");
},
maxItemText: function (maxItemCount) {
return "Only ".concat(maxItemCount, " values can be added");
},
valueComparer: function (value1, value2) {
return value1 === value2;
},
fuseOptions: {
includeScore: true
},
labelId: '',
callbackOnInit: null,
callbackOnCreateTemplates: null,
classNames: exports.DEFAULT_CLASSNAMES
};
/***/
}),
/***/ 18:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 978:
/***/ (function (__unused_webpack_module, exports) {
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 948:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 359:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 285:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 533:
/***/ (function (__unused_webpack_module, exports) {
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 187:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = {
enumerable: true,
get: function () {
return m[k];
}
};
}
Object.defineProperty(o, k2, desc);
} : function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
__createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
__exportStar(__webpack_require__(18), exports);
__exportStar(__webpack_require__(978), exports);
__exportStar(__webpack_require__(948), exports);
__exportStar(__webpack_require__(359), exports);
__exportStar(__webpack_require__(285), exports);
__exportStar(__webpack_require__(533), exports);
__exportStar(__webpack_require__(287), exports);
__exportStar(__webpack_require__(132), exports);
__exportStar(__webpack_require__(837), exports);
__exportStar(__webpack_require__(598), exports);
__exportStar(__webpack_require__(369), exports);
__exportStar(__webpack_require__(37), exports);
__exportStar(__webpack_require__(47), exports);
__exportStar(__webpack_require__(923), exports);
__exportStar(__webpack_require__(876), exports);
/***/
}),
/***/ 287:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 132:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 837:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 598:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 37:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 369:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 47:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 923:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 876:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/***/
}),
/***/ 799:
/***/ (function (__unused_webpack_module, exports) {
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.parseCustomProperties = exports.diff = exports.cloneObject = exports.existsInArray = exports.dispatchEvent = exports.sortByScore = exports.sortByAlpha = exports.strToEl = exports.sanitise = exports.isScrolledIntoView = exports.getAdjacentEl = exports.wrap = exports.isType = exports.getType = exports.generateId = exports.generateChars = exports.getRandomNumber = void 0;
var getRandomNumber = function (min, max) {
return Math.floor(Math.random() * (max - min) + min);
};
exports.getRandomNumber = getRandomNumber;
var generateChars = function (length) {
return Array.from({
length: length
}, function () {
return (0, exports.getRandomNumber)(0, 36).toString(36);
}).join('');
};
exports.generateChars = generateChars;
var generateId = function (element, prefix) {
var id = element.id || element.name && "".concat(element.name, "-").concat((0, exports.generateChars)(2)) || (0, exports.generateChars)(4);
id = id.replace(/(:|\.|\[|\]|,)/g, '');
id = "".concat(prefix, "-").concat(id);
return id;
};
exports.generateId = generateId;
var getType = function (obj) {
return Object.prototype.toString.call(obj).slice(8, -1);
};
exports.getType = getType;
var isType = function (type, obj) {
return obj !== undefined && obj !== null && (0, exports.getType)(obj) === type;
};
exports.isType = isType;
var wrap = function (element, wrapper) {
if (wrapper === void 0) {
wrapper = document.createElement('div');
}
if (element.parentNode) {
if (element.nextSibling) {
element.parentNode.insertBefore(wrapper, element.nextSibling);
}
else {
element.parentNode.appendChild(wrapper);
}
}
return wrapper.appendChild(element);
};
exports.wrap = wrap;
var getAdjacentEl = function (startEl, selector, direction) {
if (direction === void 0) {
direction = 1;
}
var prop = "".concat(direction > 0 ? 'next' : 'previous', "ElementSibling");
var sibling = startEl[prop];
while (sibling) {
if (sibling.matches(selector)) {
return sibling;
}
sibling = sibling[prop];
}
return sibling;
};
exports.getAdjacentEl = getAdjacentEl;
var isScrolledIntoView = function (element, parent, direction) {
if (direction === void 0) {
direction = 1;
}
if (!element) {
return false;
}
var isVisible;
if (direction > 0) {
// In view from bottom
isVisible = parent.scrollTop + parent.offsetHeight >= element.offsetTop + element.offsetHeight;
}
else {
// In view from top
isVisible = element.offsetTop >= parent.scrollTop;
}
return isVisible;
};
exports.isScrolledIntoView = isScrolledIntoView;
var sanitise = function (value) {
if (typeof value !== 'string') {
return value;
}
return value.replace(/&/g, '&').replace(/>/g, '>').replace(/ -1) {
return state.map(function (obj) {
var choice = obj;
if (choice.id === parseInt("".concat(addItemAction_1.choiceId), 10)) {
choice.selected = true;
}
return choice;
});
}
return state;
}
case 'REMOVE_ITEM':
{
var removeItemAction_1 = action;
// When an item is removed and it has an associated choice,
// we want to re-enable it so it can be chosen again
if (removeItemAction_1.choiceId && removeItemAction_1.choiceId > -1) {
return state.map(function (obj) {
var choice = obj;
if (choice.id === parseInt("".concat(removeItemAction_1.choiceId), 10)) {
choice.selected = false;
}
return choice;
});
}
return state;
}
case 'FILTER_CHOICES':
{
var filterChoicesAction_1 = action;
return state.map(function (obj) {
var choice = obj;
// Set active state based on whether choice is
// within filtered results
choice.active = filterChoicesAction_1.results.some(function (_a) {
var item = _a.item, score = _a.score;
if (item.id === choice.id) {
choice.score = score;
return true;
}
return false;
});
return choice;
});
}
case 'ACTIVATE_CHOICES':
{
var activateChoicesAction_1 = action;
return state.map(function (obj) {
var choice = obj;
choice.active = activateChoicesAction_1.active;
return choice;
});
}
case 'CLEAR_CHOICES':
{
return exports.defaultState;
}
default:
{
return state;
}
}
}
exports["default"] = choices;
/***/
}),
/***/ 871:
/***/ (function (__unused_webpack_module, exports) {
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.defaultState = void 0;
exports.defaultState = [];
function groups(state, action) {
if (state === void 0) {
state = exports.defaultState;
}
if (action === void 0) {
action = {};
}
switch (action.type) {
case 'ADD_GROUP':
{
var addGroupAction = action;
return __spreadArray(__spreadArray([], state, true), [{
id: addGroupAction.id,
value: addGroupAction.value,
active: addGroupAction.active,
disabled: addGroupAction.disabled
}], false);
}
case 'CLEAR_CHOICES':
{
return [];
}
default:
{
return state;
}
}
}
exports["default"] = groups;
/***/
}),
/***/ 655:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.defaultState = void 0;
var redux_1 = __webpack_require__(791);
var items_1 = __importDefault(__webpack_require__(52));
var groups_1 = __importDefault(__webpack_require__(871));
var choices_1 = __importDefault(__webpack_require__(273));
var loading_1 = __importDefault(__webpack_require__(502));
var utils_1 = __webpack_require__(799);
exports.defaultState = {
groups: [],
items: [],
choices: [],
loading: false
};
var appReducer = (0, redux_1.combineReducers)({
items: items_1.default,
groups: groups_1.default,
choices: choices_1.default,
loading: loading_1.default
});
var rootReducer = function (passedState, action) {
var state = passedState;
// If we are clearing all items, groups and options we reassign
// state and then pass that state to our proper reducer. This isn't
// mutating our actual state
// See: http://stackoverflow.com/a/35641992
if (action.type === 'CLEAR_ALL') {
state = exports.defaultState;
}
else if (action.type === 'RESET_TO') {
return (0, utils_1.cloneObject)(action.state);
}
return appReducer(state, action);
};
exports["default"] = rootReducer;
/***/
}),
/***/ 52:
/***/ (function (__unused_webpack_module, exports) {
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.defaultState = void 0;
exports.defaultState = [];
function items(state, action) {
if (state === void 0) {
state = exports.defaultState;
}
if (action === void 0) {
action = {};
}
switch (action.type) {
case 'ADD_ITEM':
{
var addItemAction = action;
// Add object to items array
var newState = __spreadArray(__spreadArray([], state, true), [{
id: addItemAction.id,
choiceId: addItemAction.choiceId,
groupId: addItemAction.groupId,
value: addItemAction.value,
label: addItemAction.label,
active: true,
highlighted: false,
customProperties: addItemAction.customProperties,
placeholder: addItemAction.placeholder || false,
keyCode: null
}], false);
return newState.map(function (obj) {
var item = obj;
item.highlighted = false;
return item;
});
}
case 'REMOVE_ITEM':
{
// Set item to inactive
return state.map(function (obj) {
var item = obj;
if (item.id === action.id) {
item.active = false;
}
return item;
});
}
case 'HIGHLIGHT_ITEM':
{
var highlightItemAction_1 = action;
return state.map(function (obj) {
var item = obj;
if (item.id === highlightItemAction_1.id) {
item.highlighted = highlightItemAction_1.highlighted;
}
return item;
});
}
default:
{
return state;
}
}
}
exports["default"] = items;
/***/
}),
/***/ 502:
/***/ (function (__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.defaultState = void 0;
exports.defaultState = false;
var general = function (state, action) {
if (state === void 0) {
state = exports.defaultState;
}
if (action === void 0) {
action = {};
}
switch (action.type) {
case 'SET_IS_LOADING':
{
return action.isLoading;
}
default:
{
return state;
}
}
};
exports["default"] = general;
/***/
}),
/***/ 744:
/***/ (function (__unused_webpack_module, exports, __webpack_require__) {
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2)
for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar)
ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", ({
value: true
}));
/* eslint-disable @typescript-eslint/no-explicit-any */
var redux_1 = __webpack_require__(791);
var index_1 = __importDefault(__webpack_require__(655));
var Store = /** @class */ function () {
function Store() {
this._store = (0, redux_1.createStore)(index_1.default, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
}
/**
* Subscribe store to function call (wrapped Redux method)
*/
Store.prototype.subscribe = function (onChange) {
this._store.subscribe(onChange);
};
/**
* Dispatch event to store (wrapped Redux method)
*/
Store.prototype.dispatch = function (action) {
this._store.dispatch(action);
};
Object.defineProperty(Store.prototype, "state", {
/**
* Get store object (wrapping Redux method)
*/
get: function () {
return this._store.getState();
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "items", {
/**
* Get items from store
*/
get: function () {
return this.state.items;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "activeItems", {
/**
* Get active items from store
*/
get: function () {
return this.items.filter(function (item) {
return item.active === true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "highlightedActiveItems", {
/**
* Get highlighted items from store
*/
get: function () {
return this.items.filter(function (item) {
return item.active && item.highlighted;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "choices", {
/**
* Get choices from store
*/
get: function () {
return this.state.choices;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "activeChoices", {
/**
* Get active choices from store
*/
get: function () {
return this.choices.filter(function (choice) {
return choice.active === true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "selectableChoices", {
/**
* Get selectable choices from store
*/
get: function () {
return this.choices.filter(function (choice) {
return choice.disabled !== true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "searchableChoices", {
/**
* Get choices that can be searched (excluding placeholders)
*/
get: function () {
return this.selectableChoices.filter(function (choice) {
return choice.placeholder !== true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "placeholderChoice", {
/**
* Get placeholder choice from store
*/
get: function () {
return __spreadArray([], this.choices, true).reverse().find(function (choice) {
return choice.placeholder === true;
});
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "groups", {
/**
* Get groups from store
*/
get: function () {
return this.state.groups;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Store.prototype, "activeGroups", {
/**
* Get active groups from store
*/
get: function () {
var _a = this, groups = _a.groups, choices = _a.choices;
return groups.filter(function (group) {
var isActive = group.active === true && group.disabled === false;
var hasActiveOptions = choices.some(function (choice) {
return choice.active === true && choice.disabled === false;
});
return isActive && hasActiveOptions;
}, []);
},
enumerable: false,
configurable: true
});
/**
* Get loading state from store
*/
Store.prototype.isLoading = function () {
return this.state.loading;
};
/**
* Get single choice by it's ID
*/
Store.prototype.getChoiceById = function (id) {
return this.activeChoices.find(function (choice) {
return choice.id === parseInt(id, 10);
});
};
/**
* Get group by group id
*/
Store.prototype.getGroupById = function (id) {
return this.groups.find(function (group) {
return group.id === id;
});
};
return Store;
}();
exports["default"] = Store;
/***/
}),
/***/ 686:
/***/ (function (__unused_webpack_module, exports) {
/**
* Helpers to create HTML elements used by Choices
* Can be overridden by providing `callbackOnCreateTemplates` option
*/
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var templates = {
containerOuter: function (_a, dir, isSelectElement, isSelectOneElement, searchEnabled, passedElementType, labelId) {
var containerOuter = _a.classNames.containerOuter;
var div = Object.assign(document.createElement('div'), {
className: containerOuter
});
div.dataset.type = passedElementType;
if (dir) {
div.dir = dir;
}
if (isSelectOneElement) {
div.tabIndex = 0;
}
if (isSelectElement) {
div.setAttribute('role', searchEnabled ? 'combobox' : 'listbox');
if (searchEnabled) {
div.setAttribute('aria-autocomplete', 'list');
}
}
div.setAttribute('aria-haspopup', 'true');
div.setAttribute('aria-expanded', 'false');
if (labelId) {
div.setAttribute('aria-labelledby', labelId);
}
return div;
},
containerInner: function (_a) {
var containerInner = _a.classNames.containerInner;
return Object.assign(document.createElement('div'), {
className: containerInner
});
},
itemList: function (_a, isSelectOneElement) {
var _b = _a.classNames, list = _b.list, listSingle = _b.listSingle, listItems = _b.listItems;
return Object.assign(document.createElement('div'), {
className: "".concat(list, " ").concat(isSelectOneElement ? listSingle : listItems)
});
},
placeholder: function (_a, value) {
var _b;
var allowHTML = _a.allowHTML, placeholder = _a.classNames.placeholder;
return Object.assign(document.createElement('div'), (_b = {
className: placeholder
}, _b[allowHTML ? 'innerHTML' : 'innerText'] = value, _b));
},
item: function (_a, _b, removeItemButton) {
var _c, _d;
var allowHTML = _a.allowHTML, _e = _a.classNames, item = _e.item, button = _e.button, highlightedState = _e.highlightedState, itemSelectable = _e.itemSelectable, placeholder = _e.placeholder;
var id = _b.id, value = _b.value, label = _b.label, customProperties = _b.customProperties, active = _b.active, disabled = _b.disabled, highlighted = _b.highlighted, isPlaceholder = _b.placeholder;
var div = Object.assign(document.createElement('div'), (_c = {
className: item
}, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c));
Object.assign(div.dataset, {
item: '',
id: id,
value: value,
customProperties: customProperties
});
if (active) {
div.setAttribute('aria-selected', 'true');
}
if (disabled) {
div.setAttribute('aria-disabled', 'true');
}
if (isPlaceholder) {
div.classList.add(placeholder);
}
div.classList.add(highlighted ? highlightedState : itemSelectable);
if (removeItemButton) {
if (disabled) {
div.classList.remove(itemSelectable);
}
div.dataset.deletable = '';
/** @todo This MUST be localizable, not hardcoded! */
var REMOVE_ITEM_TEXT = 'Remove item';
var removeButton = Object.assign(document.createElement('button'), (_d = {
type: 'button',
className: button
}, _d[allowHTML ? 'innerHTML' : 'innerText'] = REMOVE_ITEM_TEXT, _d));
removeButton.setAttribute('aria-label', "".concat(REMOVE_ITEM_TEXT, ": '").concat(value, "'"));
removeButton.dataset.button = '';
div.appendChild(removeButton);
}
return div;
},
choiceList: function (_a, isSelectOneElement) {
var list = _a.classNames.list;
var div = Object.assign(document.createElement('div'), {
className: list
});
if (!isSelectOneElement) {
div.setAttribute('aria-multiselectable', 'true');
}
div.setAttribute('role', 'listbox');
return div;
},
choiceGroup: function (_a, _b) {
var _c;
var allowHTML = _a.allowHTML, _d = _a.classNames, group = _d.group, groupHeading = _d.groupHeading, itemDisabled = _d.itemDisabled;
var id = _b.id, value = _b.value, disabled = _b.disabled;
var div = Object.assign(document.createElement('div'), {
className: "".concat(group, " ").concat(disabled ? itemDisabled : '')
});
div.setAttribute('role', 'group');
Object.assign(div.dataset, {
group: '',
id: id,
value: value
});
if (disabled) {
div.setAttribute('aria-disabled', 'true');
}
div.appendChild(Object.assign(document.createElement('div'), (_c = {
className: groupHeading
}, _c[allowHTML ? 'innerHTML' : 'innerText'] = value, _c)));
return div;
},
choice: function (_a, _b, selectText) {
var _c;
var allowHTML = _a.allowHTML, _d = _a.classNames, item = _d.item, itemChoice = _d.itemChoice, itemSelectable = _d.itemSelectable, selectedState = _d.selectedState, itemDisabled = _d.itemDisabled, placeholder = _d.placeholder;
var id = _b.id, value = _b.value, label = _b.label, groupId = _b.groupId, elementId = _b.elementId, isDisabled = _b.disabled, isSelected = _b.selected, isPlaceholder = _b.placeholder;
var div = Object.assign(document.createElement('div'), (_c = {
id: elementId
}, _c[allowHTML ? 'innerHTML' : 'innerText'] = label, _c.className = "".concat(item, " ").concat(itemChoice), _c));
if (isSelected) {
div.classList.add(selectedState);
}
if (isPlaceholder) {
div.classList.add(placeholder);
}
div.setAttribute('role', groupId && groupId > 0 ? 'treeitem' : 'option');
Object.assign(div.dataset, {
choice: '',
id: id,
value: value,
selectText: selectText
});
if (isDisabled) {
div.classList.add(itemDisabled);
div.dataset.choiceDisabled = '';
div.setAttribute('aria-disabled', 'true');
}
else {
div.classList.add(itemSelectable);
div.dataset.choiceSelectable = '';
}
return div;
},
input: function (_a, placeholderValue) {
var _b = _a.classNames, input = _b.input, inputCloned = _b.inputCloned;
var inp = Object.assign(document.createElement('input'), {
type: 'search',
name: 'search_terms',
className: "".concat(input, " ").concat(inputCloned),
autocomplete: 'off',
autocapitalize: 'off',
spellcheck: false
});
inp.setAttribute('role', 'textbox');
inp.setAttribute('aria-autocomplete', 'list');
inp.setAttribute('aria-label', placeholderValue);
return inp;
},
dropdown: function (_a) {
var _b = _a.classNames, list = _b.list, listDropdown = _b.listDropdown;
var div = document.createElement('div');
div.classList.add(list, listDropdown);
div.setAttribute('aria-expanded', 'false');
return div;
},
notice: function (_a, innerText, type) {
var _b;
var allowHTML = _a.allowHTML, _c = _a.classNames, item = _c.item, itemChoice = _c.itemChoice, noResults = _c.noResults, noChoices = _c.noChoices;
if (type === void 0) {
type = '';
}
var classes = [item, itemChoice];
if (type === 'no-choices') {
classes.push(noChoices);
}
else if (type === 'no-results') {
classes.push(noResults);
}
return Object.assign(document.createElement('div'), (_b = {}, _b[allowHTML ? 'innerHTML' : 'innerText'] = innerText, _b.className = classes.join(' '), _b));
},
option: function (_a) {
var label = _a.label, value = _a.value, customProperties = _a.customProperties, active = _a.active, disabled = _a.disabled;
var opt = new Option(label, value, false, active);
if (customProperties) {
opt.dataset.customProperties = "".concat(customProperties);
}
opt.disabled = !!disabled;
return opt;
}
};
exports["default"] = templates;
/***/
}),
/***/ 996:
/***/ (function (module) {
var isMergeableObject = function isMergeableObject(value) {
return isNonNullObject(value)
&& !isSpecial(value);
};
function isNonNullObject(value) {
return !!value && typeof value === 'object';
}
function isSpecial(value) {
var stringValue = Object.prototype.toString.call(value);
return stringValue === '[object RegExp]'
|| stringValue === '[object Date]'
|| isReactElement(value);
}
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
function isReactElement(value) {
return value.$$typeof === REACT_ELEMENT_TYPE;
}
function emptyTarget(val) {
return Array.isArray(val) ? [] : {};
}
function cloneUnlessOtherwiseSpecified(value, options) {
return (options.clone !== false && options.isMergeableObject(value))
? deepmerge(emptyTarget(value), value, options)
: value;
}
function defaultArrayMerge(target, source, options) {
return target.concat(source).map(function (element) {
return cloneUnlessOtherwiseSpecified(element, options);
});
}
function getMergeFunction(key, options) {
if (!options.customMerge) {
return deepmerge;
}
var customMerge = options.customMerge(key);
return typeof customMerge === 'function' ? customMerge : deepmerge;
}
function getEnumerableOwnPropertySymbols(target) {
return Object.getOwnPropertySymbols
? Object.getOwnPropertySymbols(target).filter(function (symbol) {
return target.propertyIsEnumerable(symbol);
})
: [];
}
function getKeys(target) {
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
}
function propertyIsOnObject(object, property) {
try {
return property in object;
}
catch (_) {
return false;
}
}
// Protects from prototype poisoning and unexpected merging up the prototype chain.
function propertyIsUnsafe(target, key) {
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
&& Object.propertyIsEnumerable.call(target, key)); // and also unsafe if they're nonenumerable.
}
function mergeObject(target, source, options) {
var destination = {};
if (options.isMergeableObject(target)) {
getKeys(target).forEach(function (key) {
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
});
}
getKeys(source).forEach(function (key) {
if (propertyIsUnsafe(target, key)) {
return;
}
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
}
else {
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
}
});
return destination;
}
function deepmerge(target, source, options) {
options = options || {};
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
// implementations can use it. The caller may not replace it.
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
var sourceIsArray = Array.isArray(source);
var targetIsArray = Array.isArray(target);
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
if (!sourceAndTargetTypesMatch) {
return cloneUnlessOtherwiseSpecified(source, options);
}
else if (sourceIsArray) {
return options.arrayMerge(target, source, options);
}
else {
return mergeObject(target, source, options);
}
}
deepmerge.all = function deepmergeAll(array, options) {
if (!Array.isArray(array)) {
throw new Error('first argument should be an array');
}
return array.reduce(function (prev, next) {
return deepmerge(prev, next, options);
}, {});
};
var deepmerge_1 = deepmerge;
module.exports = deepmerge_1;
/***/
}),
/***/ 221:
/***/ (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function () { return /* binding */ Fuse; }
/* harmony export */
});
/**
* Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2022 Kiro Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
function isArray(value) {
return !Array.isArray
? getTag(value) === '[object Array]'
: Array.isArray(value);
}
// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
const INFINITY = 1 / 0;
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
let result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
function toString(value) {
return value == null ? '' : baseToString(value);
}
function isString(value) {
return typeof value === 'string';
}
function isNumber(value) {
return typeof value === 'number';
}
// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
function isBoolean(value) {
return (value === true ||
value === false ||
(isObjectLike(value) && getTag(value) == '[object Boolean]'));
}
function isObject(value) {
return typeof value === 'object';
}
// Checks if `value` is object-like.
function isObjectLike(value) {
return isObject(value) && value !== null;
}
function isDefined(value) {
return value !== undefined && value !== null;
}
function isBlank(value) {
return !value.trim().length;
}
// Gets the `toStringTag` of `value`.
// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
function getTag(value) {
return value == null
? value === undefined
? '[object Undefined]'
: '[object Null]'
: Object.prototype.toString.call(value);
}
const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) => `Invalid value for key ${key}`;
const PATTERN_LENGTH_TOO_LARGE = (max) => `Pattern length exceeds max of ${max}.`;
const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
const INVALID_KEY_WEIGHT_VALUE = (key) => `Property 'weight' in key '${key}' must be a positive integer`;
const hasOwn = Object.prototype.hasOwnProperty;
class KeyStore {
constructor(keys) {
this._keys = [];
this._keyMap = {};
let totalWeight = 0;
keys.forEach((key) => {
let obj = createKey(key);
totalWeight += obj.weight;
this._keys.push(obj);
this._keyMap[obj.id] = obj;
totalWeight += obj.weight;
});
// Normalize weights so that their sum is equal to 1
this._keys.forEach((key) => {
key.weight /= totalWeight;
});
}
get(keyId) {
return this._keyMap[keyId];
}
keys() {
return this._keys;
}
toJSON() {
return JSON.stringify(this._keys);
}
}
function createKey(key) {
let path = null;
let id = null;
let src = null;
let weight = 1;
let getFn = null;
if (isString(key) || isArray(key)) {
src = key;
path = createKeyPath(key);
id = createKeyId(key);
}
else {
if (!hasOwn.call(key, 'name')) {
throw new Error(MISSING_KEY_PROPERTY('name'));
}
const name = key.name;
src = name;
if (hasOwn.call(key, 'weight')) {
weight = key.weight;
if (weight <= 0) {
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
}
}
path = createKeyPath(name);
id = createKeyId(name);
getFn = key.getFn;
}
return { path, id, weight, src, getFn };
}
function createKeyPath(key) {
return isArray(key) ? key : key.split('.');
}
function createKeyId(key) {
return isArray(key) ? key.join('.') : key;
}
function get(obj, path) {
let list = [];
let arr = false;
const deepGet = (obj, path, index) => {
if (!isDefined(obj)) {
return;
}
if (!path[index]) {
// If there's no path left, we've arrived at the object we care about.
list.push(obj);
}
else {
let key = path[index];
const value = obj[key];
if (!isDefined(value)) {
return;
}
// If we're at the last value in the path, and if it's a string/number/bool,
// add it to the list
if (index === path.length - 1 &&
(isString(value) || isNumber(value) || isBoolean(value))) {
list.push(toString(value));
}
else if (isArray(value)) {
arr = true;
// Search each item in the array.
for (let i = 0, len = value.length; i < len; i += 1) {
deepGet(value[i], path, index + 1);
}
}
else if (path.length) {
// An object. Recurse further.
deepGet(value, path, index + 1);
}
}
};
// Backwards compatibility (since path used to be a string)
deepGet(obj, isString(path) ? path.split('.') : path, 0);
return arr ? list : list[0];
}
const MatchOptions = {
// Whether the matches should be included in the result set. When `true`, each record in the result
// set will include the indices of the matched characters.
// These can consequently be used for highlighting purposes.
includeMatches: false,
// When `true`, the matching function will continue to the end of a search pattern even if
// a perfect match has already been located in the string.
findAllMatches: false,
// Minimum number of characters that must be matched before a result is considered a match
minMatchCharLength: 1
};
const BasicOptions = {
// When `true`, the algorithm continues searching to the end of the input even if a perfect
// match is found before the end of the same input.
isCaseSensitive: false,
// When true, the matching function will continue to the end of a search pattern even if
includeScore: false,
// List of properties that will be searched. This also supports nested properties.
keys: [],
// Whether to sort the result list, by score
shouldSort: true,
// Default sort function: sort by ascending score, ascending index
sortFn: (a, b) => a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
};
const FuzzyOptions = {
// Approximately where in the text is the pattern expected to be found?
location: 0,
// At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
// (of both letters and location), a threshold of '1.0' would match anything.
threshold: 0.6,
// Determines how close the match must be to the fuzzy location (specified above).
// An exact letter match which is 'distance' characters away from the fuzzy location
// would score as a complete mismatch. A distance of '0' requires the match be at
// the exact location specified, a threshold of '1000' would require a perfect match
// to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
distance: 100
};
const AdvancedOptions = {
// When `true`, it enables the use of unix-like search commands
useExtendedSearch: false,
// The get function to use when fetching an object's properties.
// The default will search nested paths *ie foo.bar.baz*
getFn: get,
// When `true`, search will ignore `location` and `distance`, so it won't matter
// where in the string the pattern appears.
// More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
ignoreLocation: false,
// When `true`, the calculation for the relevance score (used for sorting) will
// ignore the field-length norm.
// More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
ignoreFieldNorm: false,
// The weight to determine how much field length norm effects scoring.
fieldNormWeight: 1
};
var Config = {
...BasicOptions,
...MatchOptions,
...FuzzyOptions,
...AdvancedOptions
};
const SPACE = /[^ ]+/g;
// Field-length norm: the shorter the field, the higher the weight.
// Set to 3 decimals to reduce index size.
function norm(weight = 1, mantissa = 3) {
const cache = new Map();
const m = Math.pow(10, mantissa);
return {
get(value) {
const numTokens = value.match(SPACE).length;
if (cache.has(numTokens)) {
return cache.get(numTokens);
}
// Default function is 1/sqrt(x), weight makes that variable
const norm = 1 / Math.pow(numTokens, 0.5 * weight);
// In place of `toFixed(mantissa)`, for faster computation
const n = parseFloat(Math.round(norm * m) / m);
cache.set(numTokens, n);
return n;
},
clear() {
cache.clear();
}
};
}
class FuseIndex {
constructor({ getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) {
this.norm = norm(fieldNormWeight, 3);
this.getFn = getFn;
this.isCreated = false;
this.setIndexRecords();
}
setSources(docs = []) {
this.docs = docs;
}
setIndexRecords(records = []) {
this.records = records;
}
setKeys(keys = []) {
this.keys = keys;
this._keysMap = {};
keys.forEach((key, idx) => {
this._keysMap[key.id] = idx;
});
}
create() {
if (this.isCreated || !this.docs.length) {
return;
}
this.isCreated = true;
// List is Array
if (isString(this.docs[0])) {
this.docs.forEach((doc, docIndex) => {
this._addString(doc, docIndex);
});
}
else {
// List is Array