}\n *\n * @example\n * ```js\n * const example = new Choices(element);\n *\n * example.setChoices([\n * {value: 'One', label: 'Label One', disabled: true},\n * {value: 'Two', label: 'Label Two', selected: true},\n * {value: 'Three', label: 'Label Three'},\n * ], 'value', 'label', false);\n * ```\n *\n * @example\n * ```js\n * const example = new Choices(element);\n *\n * example.setChoices(async () => {\n * try {\n * const items = await fetch('/items');\n * return items.json()\n * } catch(err) {\n * console.error(err)\n * }\n * });\n * ```\n *\n * @example\n * ```js\n * const example = new Choices(element);\n *\n * example.setChoices([{\n * label: 'Group one',\n * id: 1,\n * disabled: false,\n * choices: [\n * {value: 'Child One', label: 'Child One', selected: true},\n * {value: 'Child Two', label: 'Child Two', disabled: true},\n * {value: 'Child Three', label: 'Child Three'},\n * ]\n * },\n * {\n * label: 'Group two',\n * id: 2,\n * disabled: false,\n * choices: [\n * {value: 'Child Four', label: 'Child Four', disabled: true},\n * {value: 'Child Five', label: 'Child Five'},\n * {value: 'Child Six', label: 'Child Six', customProperties: {\n * description: 'Custom description about child six',\n * random: 'Another random custom property'\n * }},\n * ]\n * }], 'value', 'label', false);\n * ```\n */\n ;\n\n _proto.setChoices = function setChoices(choicesArrayOrFetcher, value, label, replaceChoices) {\n var _this11 = this;\n\n if (choicesArrayOrFetcher === void 0) {\n choicesArrayOrFetcher = [];\n }\n\n if (value === void 0) {\n value = 'value';\n }\n\n if (label === void 0) {\n label = 'label';\n }\n\n if (replaceChoices === void 0) {\n replaceChoices = false;\n }\n\n if (!this.initialised) {\n throw new ReferenceError(\"setChoices was called on a non-initialized instance of Choices\");\n }\n\n if (!this._isSelectElement) {\n throw new TypeError(\"setChoices can't be used with INPUT based Choices\");\n }\n\n if (typeof value !== 'string' || !value) {\n throw new TypeError(\"value parameter must be a name of 'value' field in passed objects\");\n } // Clear choices if needed\n\n\n if (replaceChoices) {\n this.clearChoices();\n }\n\n if (typeof choicesArrayOrFetcher === 'function') {\n // it's a choices fetcher function\n var fetcher = choicesArrayOrFetcher(this);\n\n if (typeof Promise === 'function' && fetcher instanceof Promise) {\n // that's a promise\n // eslint-disable-next-line compat/compat\n return new Promise(function (resolve) {\n return requestAnimationFrame(resolve);\n }).then(function () {\n return _this11._handleLoadingState(true);\n }).then(function () {\n return fetcher;\n }).then(function (data) {\n return _this11.setChoices(data, value, label, replaceChoices);\n }).catch(function (err) {\n if (!_this11.config.silent) {\n console.error(err);\n }\n }).then(function () {\n return _this11._handleLoadingState(false);\n }).then(function () {\n return _this11;\n });\n } // function returned something else than promise, let's check if it's an array of choices\n\n\n if (!Array.isArray(fetcher)) {\n throw new TypeError(\".setChoices first argument function must return either array of choices or Promise, got: \" + _typeof(fetcher));\n } // recursion with results, it's sync and choices were cleared already\n\n\n return this.setChoices(fetcher, value, label, false);\n }\n\n if (!Array.isArray(choicesArrayOrFetcher)) {\n throw new TypeError(\".setChoices must be called either with array of choices with a function resulting into Promise of array of choices\");\n }\n\n this.containerOuter.removeLoadingState();\n\n this._startLoading();\n\n choicesArrayOrFetcher.forEach(function (groupOrChoice) {\n if (groupOrChoice.choices) {\n _this11._addGroup({\n id: parseInt(groupOrChoice.id, 10) || null,\n group: groupOrChoice,\n valueKey: value,\n labelKey: label\n });\n } else {\n _this11._addChoice({\n value: groupOrChoice[value],\n label: groupOrChoice[label],\n isSelected: groupOrChoice.selected,\n isDisabled: groupOrChoice.disabled,\n customProperties: groupOrChoice.customProperties,\n placeholder: groupOrChoice.placeholder\n });\n }\n });\n\n this._stopLoading();\n\n return this;\n };\n\n _proto.clearChoices = function clearChoices() {\n this._store.dispatch(choices_clearChoices());\n\n return this;\n };\n\n _proto.clearStore = function clearStore() {\n this._store.dispatch(clearAll());\n\n return this;\n };\n\n _proto.clearInput = function clearInput() {\n var shouldSetInputWidth = !this._isSelectOneElement;\n this.input.clear(shouldSetInputWidth);\n\n if (!this._isTextElement && this._canSearch) {\n this._isSearching = false;\n\n this._store.dispatch(choices_activateChoices(true));\n }\n\n return this;\n };\n\n _proto._render = function _render() {\n if (this._store.isLoading()) {\n return;\n }\n\n this._currentState = this._store.state;\n var stateChanged = this._currentState.choices !== this._prevState.choices || this._currentState.groups !== this._prevState.groups || this._currentState.items !== this._prevState.items;\n var shouldRenderChoices = this._isSelectElement;\n var shouldRenderItems = this._currentState.items !== this._prevState.items;\n\n if (!stateChanged) {\n return;\n }\n\n if (shouldRenderChoices) {\n this._renderChoices();\n }\n\n if (shouldRenderItems) {\n this._renderItems();\n }\n\n this._prevState = this._currentState;\n };\n\n _proto._renderChoices = function _renderChoices() {\n var _this12 = this;\n\n var _this$_store = this._store,\n activeGroups = _this$_store.activeGroups,\n activeChoices = _this$_store.activeChoices;\n var choiceListFragment = document.createDocumentFragment();\n this.choiceList.clear();\n\n if (this.config.resetScrollPosition) {\n requestAnimationFrame(function () {\n return _this12.choiceList.scrollToTop();\n });\n } // If we have grouped options\n\n\n if (activeGroups.length >= 1 && !this._isSearching) {\n // If we have a placeholder choice along with groups\n var activePlaceholders = activeChoices.filter(function (activeChoice) {\n return activeChoice.placeholder === true && activeChoice.groupId === -1;\n });\n\n if (activePlaceholders.length >= 1) {\n choiceListFragment = this._createChoicesFragment(activePlaceholders, choiceListFragment);\n }\n\n choiceListFragment = this._createGroupsFragment(activeGroups, activeChoices, choiceListFragment);\n } else if (activeChoices.length >= 1) {\n choiceListFragment = this._createChoicesFragment(activeChoices, choiceListFragment);\n } // If we have choices to show\n\n\n if (choiceListFragment.childNodes && choiceListFragment.childNodes.length > 0) {\n var activeItems = this._store.activeItems;\n\n var canAddItem = this._canAddItem(activeItems, this.input.value); // ...and we can select them\n\n\n if (canAddItem.response) {\n // ...append them and highlight the first choice\n this.choiceList.append(choiceListFragment);\n\n this._highlightChoice();\n } else {\n // ...otherwise show a notice\n this.choiceList.append(this._getTemplate('notice', canAddItem.notice));\n }\n } else {\n // Otherwise show a notice\n var dropdownItem;\n var notice;\n\n if (this._isSearching) {\n notice = typeof this.config.noResultsText === 'function' ? this.config.noResultsText() : this.config.noResultsText;\n dropdownItem = this._getTemplate('notice', notice, 'no-results');\n } else {\n notice = typeof this.config.noChoicesText === 'function' ? this.config.noChoicesText() : this.config.noChoicesText;\n dropdownItem = this._getTemplate('notice', notice, 'no-choices');\n }\n\n this.choiceList.append(dropdownItem);\n }\n };\n\n _proto._renderItems = function _renderItems() {\n var activeItems = this._store.activeItems || [];\n this.itemList.clear(); // Create a fragment to store our list items\n // (so we don't have to update the DOM for each item)\n\n var itemListFragment = this._createItemsFragment(activeItems); // If we have items to add, append them\n\n\n if (itemListFragment.childNodes) {\n this.itemList.append(itemListFragment);\n }\n };\n\n _proto._createGroupsFragment = function _createGroupsFragment(groups, choices, fragment) {\n var _this13 = this;\n\n if (fragment === void 0) {\n fragment = document.createDocumentFragment();\n }\n\n var getGroupChoices = function getGroupChoices(group) {\n return choices.filter(function (choice) {\n if (_this13._isSelectOneElement) {\n return choice.groupId === group.id;\n }\n\n return choice.groupId === group.id && (_this13.config.renderSelectedChoices === 'always' || !choice.selected);\n });\n }; // If sorting is enabled, filter groups\n\n\n if (this.config.shouldSort) {\n groups.sort(this.config.sorter);\n }\n\n groups.forEach(function (group) {\n var groupChoices = getGroupChoices(group);\n\n if (groupChoices.length >= 1) {\n var dropdownGroup = _this13._getTemplate('choiceGroup', group);\n\n fragment.appendChild(dropdownGroup);\n\n _this13._createChoicesFragment(groupChoices, fragment, true);\n }\n });\n return fragment;\n };\n\n _proto._createChoicesFragment = function _createChoicesFragment(choices, fragment, withinGroup) {\n var _this14 = this;\n\n if (fragment === void 0) {\n fragment = document.createDocumentFragment();\n }\n\n if (withinGroup === void 0) {\n withinGroup = false;\n } // Create a fragment to store our list items (so we don't have to update the DOM for each item)\n\n\n var _this$config = this.config,\n renderSelectedChoices = _this$config.renderSelectedChoices,\n searchResultLimit = _this$config.searchResultLimit,\n renderChoiceLimit = _this$config.renderChoiceLimit;\n var filter = this._isSearching ? sortByScore : this.config.sorter;\n\n var appendChoice = function appendChoice(choice) {\n var shouldRender = renderSelectedChoices === 'auto' ? _this14._isSelectOneElement || !choice.selected : true;\n\n if (shouldRender) {\n var dropdownItem = _this14._getTemplate('choice', choice, _this14.config.itemSelectText);\n\n fragment.appendChild(dropdownItem);\n }\n };\n\n var rendererableChoices = choices;\n\n if (renderSelectedChoices === 'auto' && !this._isSelectOneElement) {\n rendererableChoices = choices.filter(function (choice) {\n return !choice.selected;\n });\n } // Split array into placeholders and \"normal\" choices\n\n\n var _rendererableChoices$ = rendererableChoices.reduce(function (acc, choice) {\n if (choice.placeholder) {\n acc.placeholderChoices.push(choice);\n } else {\n acc.normalChoices.push(choice);\n }\n\n return acc;\n }, {\n placeholderChoices: [],\n normalChoices: []\n }),\n placeholderChoices = _rendererableChoices$.placeholderChoices,\n normalChoices = _rendererableChoices$.normalChoices; // If sorting is enabled or the user is searching, filter choices\n\n\n if (this.config.shouldSort || this._isSearching) {\n normalChoices.sort(filter);\n }\n\n var choiceLimit = rendererableChoices.length; // Prepend placeholeder\n\n var sortedChoices = this._isSelectOneElement ? [].concat(placeholderChoices, normalChoices) : normalChoices;\n\n if (this._isSearching) {\n choiceLimit = searchResultLimit;\n } else if (renderChoiceLimit && renderChoiceLimit > 0 && !withinGroup) {\n choiceLimit = renderChoiceLimit;\n } // Add each choice to dropdown within range\n\n\n for (var i = 0; i < choiceLimit; i += 1) {\n if (sortedChoices[i]) {\n appendChoice(sortedChoices[i]);\n }\n }\n\n return fragment;\n };\n\n _proto._createItemsFragment = function _createItemsFragment(items, fragment) {\n var _this15 = this;\n\n if (fragment === void 0) {\n fragment = document.createDocumentFragment();\n } // Create fragment to add elements to\n\n\n var _this$config2 = this.config,\n shouldSortItems = _this$config2.shouldSortItems,\n sorter = _this$config2.sorter,\n removeItemButton = _this$config2.removeItemButton; // If sorting is enabled, filter items\n\n if (shouldSortItems && !this._isSelectOneElement) {\n items.sort(sorter);\n }\n\n if (this._isTextElement) {\n // Update the value of the hidden input\n this.passedElement.value = items;\n } else {\n // Update the options of the hidden input\n this.passedElement.options = items;\n }\n\n var addItemToFragment = function addItemToFragment(item) {\n // Create new list element\n var listItem = _this15._getTemplate('item', item, removeItemButton); // Append it to list\n\n\n fragment.appendChild(listItem);\n }; // Add each list item to list\n\n\n items.forEach(addItemToFragment);\n return fragment;\n };\n\n _proto._triggerChange = function _triggerChange(value) {\n if (value === undefined || value === null) {\n return;\n }\n\n this.passedElement.triggerEvent(EVENTS.change, {\n value: value\n });\n };\n\n _proto._selectPlaceholderChoice = function _selectPlaceholderChoice() {\n var placeholderChoice = this._store.placeholderChoice;\n\n if (placeholderChoice) {\n this._addItem({\n value: placeholderChoice.value,\n label: placeholderChoice.label,\n choiceId: placeholderChoice.id,\n groupId: placeholderChoice.groupId,\n placeholder: placeholderChoice.placeholder\n });\n\n this._triggerChange(placeholderChoice.value);\n }\n };\n\n _proto._handleButtonAction = function _handleButtonAction(activeItems, element) {\n if (!activeItems || !element || !this.config.removeItems || !this.config.removeItemButton) {\n return;\n }\n\n var itemId = element.parentNode.getAttribute('data-id');\n var itemToRemove = activeItems.find(function (item) {\n return item.id === parseInt(itemId, 10);\n }); // Remove item associated with button\n\n this._removeItem(itemToRemove);\n\n this._triggerChange(itemToRemove.value);\n\n if (this._isSelectOneElement) {\n this._selectPlaceholderChoice();\n }\n };\n\n _proto._handleItemAction = function _handleItemAction(activeItems, element, hasShiftKey) {\n var _this16 = this;\n\n if (hasShiftKey === void 0) {\n hasShiftKey = false;\n }\n\n if (!activeItems || !element || !this.config.removeItems || this._isSelectOneElement) {\n return;\n }\n\n var passedId = element.getAttribute('data-id'); // We only want to select one item with a click\n // so we deselect any items that aren't the target\n // unless shift is being pressed\n\n activeItems.forEach(function (item) {\n if (item.id === parseInt(passedId, 10) && !item.highlighted) {\n _this16.highlightItem(item);\n } else if (!hasShiftKey && item.highlighted) {\n _this16.unhighlightItem(item);\n }\n }); // Focus input as without focus, a user cannot do anything with a\n // highlighted item\n\n this.input.focus();\n };\n\n _proto._handleChoiceAction = function _handleChoiceAction(activeItems, element) {\n if (!activeItems || !element) {\n return;\n } // If we are clicking on an option\n\n\n var id = element.dataset.id;\n\n var choice = this._store.getChoiceById(id);\n\n if (!choice) {\n return;\n }\n\n var passedKeyCode = activeItems[0] && activeItems[0].keyCode ? activeItems[0].keyCode : null;\n var hasActiveDropdown = this.dropdown.isActive; // Update choice keyCode\n\n choice.keyCode = passedKeyCode;\n this.passedElement.triggerEvent(EVENTS.choice, {\n choice: choice\n });\n\n if (!choice.selected && !choice.disabled) {\n var canAddItem = this._canAddItem(activeItems, choice.value);\n\n if (canAddItem.response) {\n this._addItem({\n value: choice.value,\n label: choice.label,\n choiceId: choice.id,\n groupId: choice.groupId,\n customProperties: choice.customProperties,\n placeholder: choice.placeholder,\n keyCode: choice.keyCode\n });\n\n this._triggerChange(choice.value);\n }\n }\n\n this.clearInput(); // We want to close the dropdown if we are dealing with a single select box\n\n if (hasActiveDropdown && this._isSelectOneElement) {\n this.hideDropdown(true);\n this.containerOuter.focus();\n }\n };\n\n _proto._handleBackspace = function _handleBackspace(activeItems) {\n if (!this.config.removeItems || !activeItems) {\n return;\n }\n\n var lastItem = activeItems[activeItems.length - 1];\n var hasHighlightedItems = activeItems.some(function (item) {\n return item.highlighted;\n }); // If editing the last item is allowed and there are not other selected items,\n // we can edit the item value. Otherwise if we can remove items, remove all selected items\n\n if (this.config.editItems && !hasHighlightedItems && lastItem) {\n this.input.value = lastItem.value;\n this.input.setWidth();\n\n this._removeItem(lastItem);\n\n this._triggerChange(lastItem.value);\n } else {\n if (!hasHighlightedItems) {\n // Highlight last item if none already highlighted\n this.highlightItem(lastItem, false);\n }\n\n this.removeHighlightedItems(true);\n }\n };\n\n _proto._startLoading = function _startLoading() {\n this._store.dispatch(setIsLoading(true));\n };\n\n _proto._stopLoading = function _stopLoading() {\n this._store.dispatch(setIsLoading(false));\n };\n\n _proto._handleLoadingState = function _handleLoadingState(setLoading) {\n if (setLoading === void 0) {\n setLoading = true;\n }\n\n var placeholderItem = this.itemList.getChild(\".\" + this.config.classNames.placeholder);\n\n if (setLoading) {\n this.disable();\n this.containerOuter.addLoadingState();\n\n if (this._isSelectOneElement) {\n if (!placeholderItem) {\n placeholderItem = this._getTemplate('placeholder', this.config.loadingText);\n this.itemList.append(placeholderItem);\n } else {\n placeholderItem.innerHTML = this.config.loadingText;\n }\n } else {\n this.input.placeholder = this.config.loadingText;\n }\n } else {\n this.enable();\n this.containerOuter.removeLoadingState();\n\n if (this._isSelectOneElement) {\n placeholderItem.innerHTML = this._placeholderValue || '';\n } else {\n this.input.placeholder = this._placeholderValue || '';\n }\n }\n };\n\n _proto._handleSearch = function _handleSearch(value) {\n if (!value || !this.input.isFocussed) {\n return;\n }\n\n var choices = this._store.choices;\n var _this$config3 = this.config,\n searchFloor = _this$config3.searchFloor,\n searchChoices = _this$config3.searchChoices;\n var hasUnactiveChoices = choices.some(function (option) {\n return !option.active;\n }); // Check that we have a value to search and the input was an alphanumeric character\n\n if (value && value.length >= searchFloor) {\n var resultCount = searchChoices ? this._searchChoices(value) : 0; // Trigger search event\n\n this.passedElement.triggerEvent(EVENTS.search, {\n value: value,\n resultCount: resultCount\n });\n } else if (hasUnactiveChoices) {\n // Otherwise reset choices to active\n this._isSearching = false;\n\n this._store.dispatch(choices_activateChoices(true));\n }\n };\n\n _proto._canAddItem = function _canAddItem(activeItems, value) {\n var canAddItem = true;\n var notice = typeof this.config.addItemText === 'function' ? this.config.addItemText(value) : this.config.addItemText;\n\n if (!this._isSelectOneElement) {\n var isDuplicateValue = existsInArray(activeItems, value);\n\n if (this.config.maxItemCount > 0 && this.config.maxItemCount <= activeItems.length) {\n // If there is a max entry limit and we have reached that limit\n // don't update\n canAddItem = false;\n notice = typeof this.config.maxItemText === 'function' ? this.config.maxItemText(this.config.maxItemCount) : this.config.maxItemText;\n }\n\n if (!this.config.duplicateItemsAllowed && isDuplicateValue && canAddItem) {\n canAddItem = false;\n notice = typeof this.config.uniqueItemText === 'function' ? this.config.uniqueItemText(value) : this.config.uniqueItemText;\n }\n\n if (this._isTextElement && this.config.addItems && canAddItem && typeof this.config.addItemFilter === 'function' && !this.config.addItemFilter(value)) {\n canAddItem = false;\n notice = typeof this.config.customAddItemText === 'function' ? this.config.customAddItemText(value) : this.config.customAddItemText;\n }\n }\n\n return {\n response: canAddItem,\n notice: notice\n };\n };\n\n _proto._searchChoices = function _searchChoices(value) {\n var newValue = typeof value === 'string' ? value.trim() : value;\n var currentValue = typeof this._currentValue === 'string' ? this._currentValue.trim() : this._currentValue;\n\n if (newValue.length < 1 && newValue === currentValue + \" \") {\n return 0;\n } // If new value matches the desired length and is not the same as the current value with a space\n\n\n var haystack = this._store.searchableChoices;\n var needle = newValue;\n var keys = [].concat(this.config.searchFields);\n var options = Object.assign(this.config.fuseOptions, {\n keys: keys\n });\n var fuse = new fuse_default.a(haystack, options);\n var results = fuse.search(needle);\n this._currentValue = newValue;\n this._highlightPosition = 0;\n this._isSearching = true;\n\n this._store.dispatch(choices_filterChoices(results));\n\n return results.length;\n };\n\n _proto._addEventListeners = function _addEventListeners() {\n var _document = document,\n documentElement = _document.documentElement; // capture events - can cancel event processing or propagation\n\n documentElement.addEventListener('touchend', this._onTouchEnd, true);\n this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true);\n this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation`\n\n documentElement.addEventListener('click', this._onClick, {\n passive: true\n });\n documentElement.addEventListener('touchmove', this._onTouchMove, {\n passive: true\n });\n this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {\n passive: true\n });\n\n if (this._isSelectOneElement) {\n this.containerOuter.element.addEventListener('focus', this._onFocus, {\n passive: true\n });\n this.containerOuter.element.addEventListener('blur', this._onBlur, {\n passive: true\n });\n }\n\n this.input.element.addEventListener('keyup', this._onKeyUp, {\n passive: true\n });\n this.input.element.addEventListener('focus', this._onFocus, {\n passive: true\n });\n this.input.element.addEventListener('blur', this._onBlur, {\n passive: true\n });\n\n if (this.input.element.form) {\n this.input.element.form.addEventListener('reset', this._onFormReset, {\n passive: true\n });\n }\n\n this.input.addEventListeners();\n };\n\n _proto._removeEventListeners = function _removeEventListeners() {\n var _document2 = document,\n documentElement = _document2.documentElement;\n documentElement.removeEventListener('touchend', this._onTouchEnd, true);\n this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true);\n this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true);\n documentElement.removeEventListener('click', this._onClick);\n documentElement.removeEventListener('touchmove', this._onTouchMove);\n this.dropdown.element.removeEventListener('mouseover', this._onMouseOver);\n\n if (this._isSelectOneElement) {\n this.containerOuter.element.removeEventListener('focus', this._onFocus);\n this.containerOuter.element.removeEventListener('blur', this._onBlur);\n }\n\n this.input.element.removeEventListener('keyup', this._onKeyUp);\n this.input.element.removeEventListener('focus', this._onFocus);\n this.input.element.removeEventListener('blur', this._onBlur);\n\n if (this.input.element.form) {\n this.input.element.form.removeEventListener('reset', this._onFormReset);\n }\n\n this.input.removeEventListeners();\n }\n /**\n * @param {KeyboardEvent} event\n */\n ;\n\n _proto._onKeyDown = function _onKeyDown(event) {\n var _keyDownActions;\n\n var target = event.target,\n keyCode = event.keyCode,\n ctrlKey = event.ctrlKey,\n metaKey = event.metaKey;\n var activeItems = this._store.activeItems;\n var hasFocusedInput = this.input.isFocussed;\n var hasActiveDropdown = this.dropdown.isActive;\n var hasItems = this.itemList.hasChildren();\n var keyString = String.fromCharCode(keyCode);\n var BACK_KEY = KEY_CODES.BACK_KEY,\n DELETE_KEY = KEY_CODES.DELETE_KEY,\n ENTER_KEY = KEY_CODES.ENTER_KEY,\n A_KEY = KEY_CODES.A_KEY,\n ESC_KEY = KEY_CODES.ESC_KEY,\n UP_KEY = KEY_CODES.UP_KEY,\n DOWN_KEY = KEY_CODES.DOWN_KEY,\n PAGE_UP_KEY = KEY_CODES.PAGE_UP_KEY,\n PAGE_DOWN_KEY = KEY_CODES.PAGE_DOWN_KEY;\n var hasCtrlDownKeyPressed = ctrlKey || metaKey; // If a user is typing and the dropdown is not active\n\n if (!this._isTextElement && /[a-zA-Z0-9-_ ]/.test(keyString)) {\n this.showDropdown();\n } // Map keys to key actions\n\n\n var keyDownActions = (_keyDownActions = {}, _keyDownActions[A_KEY] = this._onAKey, _keyDownActions[ENTER_KEY] = this._onEnterKey, _keyDownActions[ESC_KEY] = this._onEscapeKey, _keyDownActions[UP_KEY] = this._onDirectionKey, _keyDownActions[PAGE_UP_KEY] = this._onDirectionKey, _keyDownActions[DOWN_KEY] = this._onDirectionKey, _keyDownActions[PAGE_DOWN_KEY] = this._onDirectionKey, _keyDownActions[DELETE_KEY] = this._onDeleteKey, _keyDownActions[BACK_KEY] = this._onDeleteKey, _keyDownActions); // If keycode has a function, run it\n\n if (keyDownActions[keyCode]) {\n keyDownActions[keyCode]({\n event: event,\n target: target,\n keyCode: keyCode,\n metaKey: metaKey,\n activeItems: activeItems,\n hasFocusedInput: hasFocusedInput,\n hasActiveDropdown: hasActiveDropdown,\n hasItems: hasItems,\n hasCtrlDownKeyPressed: hasCtrlDownKeyPressed\n });\n }\n };\n\n _proto._onKeyUp = function _onKeyUp(_ref2) {\n var target = _ref2.target,\n keyCode = _ref2.keyCode;\n var value = this.input.value;\n var activeItems = this._store.activeItems;\n\n var canAddItem = this._canAddItem(activeItems, value);\n\n var backKey = KEY_CODES.BACK_KEY,\n deleteKey = KEY_CODES.DELETE_KEY; // We are typing into a text input and have a value, we want to show a dropdown\n // notice. Otherwise hide the dropdown\n\n if (this._isTextElement) {\n var canShowDropdownNotice = canAddItem.notice && value;\n\n if (canShowDropdownNotice) {\n var dropdownItem = this._getTemplate('notice', canAddItem.notice);\n\n this.dropdown.element.innerHTML = dropdownItem.outerHTML;\n this.showDropdown(true);\n } else {\n this.hideDropdown(true);\n }\n } else {\n var userHasRemovedValue = (keyCode === backKey || keyCode === deleteKey) && !target.value;\n var canReactivateChoices = !this._isTextElement && this._isSearching;\n var canSearch = this._canSearch && canAddItem.response;\n\n if (userHasRemovedValue && canReactivateChoices) {\n this._isSearching = false;\n\n this._store.dispatch(choices_activateChoices(true));\n } else if (canSearch) {\n this._handleSearch(this.input.value);\n }\n }\n\n this._canSearch = this.config.searchEnabled;\n };\n\n _proto._onAKey = function _onAKey(_ref3) {\n var hasItems = _ref3.hasItems,\n hasCtrlDownKeyPressed = _ref3.hasCtrlDownKeyPressed; // If CTRL + A or CMD + A have been pressed and there are items to select\n\n if (hasCtrlDownKeyPressed && hasItems) {\n this._canSearch = false;\n var shouldHightlightAll = this.config.removeItems && !this.input.value && this.input.element === document.activeElement;\n\n if (shouldHightlightAll) {\n this.highlightAll();\n }\n }\n };\n\n _proto._onEnterKey = function _onEnterKey(_ref4) {\n var event = _ref4.event,\n target = _ref4.target,\n activeItems = _ref4.activeItems,\n hasActiveDropdown = _ref4.hasActiveDropdown;\n var enterKey = KEY_CODES.ENTER_KEY;\n var targetWasButton = target.hasAttribute('data-button');\n\n if (this._isTextElement && target.value) {\n var value = this.input.value;\n\n var canAddItem = this._canAddItem(activeItems, value);\n\n if (canAddItem.response) {\n this.hideDropdown(true);\n\n this._addItem({\n value: value\n });\n\n this._triggerChange(value);\n\n this.clearInput();\n }\n }\n\n if (targetWasButton) {\n this._handleButtonAction(activeItems, target);\n\n event.preventDefault();\n }\n\n if (hasActiveDropdown) {\n var highlightedChoice = this.dropdown.getChild(\".\" + this.config.classNames.highlightedState);\n\n if (highlightedChoice) {\n // add enter keyCode value\n if (activeItems[0]) {\n activeItems[0].keyCode = enterKey; // eslint-disable-line no-param-reassign\n }\n\n this._handleChoiceAction(activeItems, highlightedChoice);\n }\n\n event.preventDefault();\n } else if (this._isSelectOneElement) {\n this.showDropdown();\n event.preventDefault();\n }\n };\n\n _proto._onEscapeKey = function _onEscapeKey(_ref5) {\n var hasActiveDropdown = _ref5.hasActiveDropdown;\n\n if (hasActiveDropdown) {\n this.hideDropdown(true);\n this.containerOuter.focus();\n }\n };\n\n _proto._onDirectionKey = function _onDirectionKey(_ref6) {\n var event = _ref6.event,\n hasActiveDropdown = _ref6.hasActiveDropdown,\n keyCode = _ref6.keyCode,\n metaKey = _ref6.metaKey;\n var downKey = KEY_CODES.DOWN_KEY,\n pageUpKey = KEY_CODES.PAGE_UP_KEY,\n pageDownKey = KEY_CODES.PAGE_DOWN_KEY; // If up or down key is pressed, traverse through options\n\n if (hasActiveDropdown || this._isSelectOneElement) {\n this.showDropdown();\n this._canSearch = false;\n var directionInt = keyCode === downKey || keyCode === pageDownKey ? 1 : -1;\n var skipKey = metaKey || keyCode === pageDownKey || keyCode === pageUpKey;\n var selectableChoiceIdentifier = '[data-choice-selectable]';\n var nextEl;\n\n if (skipKey) {\n if (directionInt > 0) {\n nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier + \":last-of-type\");\n } else {\n nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier);\n }\n } else {\n var currentEl = this.dropdown.element.querySelector(\".\" + this.config.classNames.highlightedState);\n\n if (currentEl) {\n nextEl = getAdjacentEl(currentEl, selectableChoiceIdentifier, directionInt);\n } else {\n nextEl = this.dropdown.element.querySelector(selectableChoiceIdentifier);\n }\n }\n\n if (nextEl) {\n // We prevent default to stop the cursor moving\n // when pressing the arrow\n if (!isScrolledIntoView(nextEl, this.choiceList.element, directionInt)) {\n this.choiceList.scrollToChildElement(nextEl, directionInt);\n }\n\n this._highlightChoice(nextEl);\n } // Prevent default to maintain cursor position whilst\n // traversing dropdown options\n\n\n event.preventDefault();\n }\n };\n\n _proto._onDeleteKey = function _onDeleteKey(_ref7) {\n var event = _ref7.event,\n target = _ref7.target,\n hasFocusedInput = _ref7.hasFocusedInput,\n activeItems = _ref7.activeItems; // If backspace or delete key is pressed and the input has no value\n\n if (hasFocusedInput && !target.value && !this._isSelectOneElement) {\n this._handleBackspace(activeItems);\n\n event.preventDefault();\n }\n };\n\n _proto._onTouchMove = function _onTouchMove() {\n if (this._wasTap) {\n this._wasTap = false;\n }\n };\n\n _proto._onTouchEnd = function _onTouchEnd(event) {\n var _ref8 = event || event.touches[0],\n target = _ref8.target;\n\n var touchWasWithinContainer = this._wasTap && this.containerOuter.element.contains(target);\n\n if (touchWasWithinContainer) {\n var containerWasExactTarget = target === this.containerOuter.element || target === this.containerInner.element;\n\n if (containerWasExactTarget) {\n if (this._isTextElement) {\n this.input.focus();\n } else if (this._isSelectMultipleElement) {\n this.showDropdown();\n }\n } // Prevents focus event firing\n\n\n event.stopPropagation();\n }\n\n this._wasTap = true;\n }\n /**\n * Handles mousedown event in capture mode for containetOuter.element\n * @param {MouseEvent} event\n */\n ;\n\n _proto._onMouseDown = function _onMouseDown(event) {\n var target = event.target;\n\n if (!(target instanceof HTMLElement)) {\n return;\n } // If we have our mouse down on the scrollbar and are on IE11...\n\n\n if (IS_IE11 && this.choiceList.element.contains(target)) {\n // check if click was on a scrollbar area\n var firstChoice =\n /** @type {HTMLElement} */\n this.choiceList.element.firstElementChild;\n var isOnScrollbar = this._direction === 'ltr' ? event.offsetX >= firstChoice.offsetWidth : event.offsetX < firstChoice.offsetLeft;\n this._isScrollingOnIe = isOnScrollbar;\n }\n\n if (target === this.input.element) {\n return;\n }\n\n var item = target.closest('[data-button],[data-item],[data-choice]');\n\n if (item instanceof HTMLElement) {\n var hasShiftKey = event.shiftKey;\n var activeItems = this._store.activeItems;\n var dataset = item.dataset;\n\n if ('button' in dataset) {\n this._handleButtonAction(activeItems, item);\n } else if ('item' in dataset) {\n this._handleItemAction(activeItems, item, hasShiftKey);\n } else if ('choice' in dataset) {\n this._handleChoiceAction(activeItems, item);\n }\n }\n\n event.preventDefault();\n }\n /**\n * Handles mouseover event over this.dropdown\n * @param {MouseEvent} event\n */\n ;\n\n _proto._onMouseOver = function _onMouseOver(_ref9) {\n var target = _ref9.target;\n\n if (target instanceof HTMLElement && 'choice' in target.dataset) {\n this._highlightChoice(target);\n }\n };\n\n _proto._onClick = function _onClick(_ref10) {\n var target = _ref10.target;\n var clickWasWithinContainer = this.containerOuter.element.contains(target);\n\n if (clickWasWithinContainer) {\n if (!this.dropdown.isActive && !this.containerOuter.isDisabled) {\n if (this._isTextElement) {\n if (document.activeElement !== this.input.element) {\n this.input.focus();\n }\n } else {\n this.showDropdown();\n this.containerOuter.focus();\n }\n } else if (this._isSelectOneElement && target !== this.input.element && !this.dropdown.element.contains(target)) {\n this.hideDropdown();\n }\n } else {\n var hasHighlightedItems = this._store.highlightedActiveItems.length > 0;\n\n if (hasHighlightedItems) {\n this.unhighlightAll();\n }\n\n this.containerOuter.removeFocusState();\n this.hideDropdown(true);\n }\n };\n\n _proto._onFocus = function _onFocus(_ref11) {\n var _this17 = this,\n _focusActions;\n\n var target = _ref11.target;\n var focusWasWithinContainer = this.containerOuter.element.contains(target);\n\n if (!focusWasWithinContainer) {\n return;\n }\n\n var focusActions = (_focusActions = {}, _focusActions[TEXT_TYPE] = function () {\n if (target === _this17.input.element) {\n _this17.containerOuter.addFocusState();\n }\n }, _focusActions[SELECT_ONE_TYPE] = function () {\n _this17.containerOuter.addFocusState();\n\n if (target === _this17.input.element) {\n _this17.showDropdown(true);\n }\n }, _focusActions[SELECT_MULTIPLE_TYPE] = function () {\n if (target === _this17.input.element) {\n _this17.showDropdown(true); // If element is a select box, the focused element is the container and the dropdown\n // isn't already open, focus and show dropdown\n\n\n _this17.containerOuter.addFocusState();\n }\n }, _focusActions);\n focusActions[this.passedElement.element.type]();\n };\n\n _proto._onBlur = function _onBlur(_ref12) {\n var _this18 = this;\n\n var target = _ref12.target;\n var blurWasWithinContainer = this.containerOuter.element.contains(target);\n\n if (blurWasWithinContainer && !this._isScrollingOnIe) {\n var _blurActions;\n\n var activeItems = this._store.activeItems;\n var hasHighlightedItems = activeItems.some(function (item) {\n return item.highlighted;\n });\n var blurActions = (_blurActions = {}, _blurActions[TEXT_TYPE] = function () {\n if (target === _this18.input.element) {\n _this18.containerOuter.removeFocusState();\n\n if (hasHighlightedItems) {\n _this18.unhighlightAll();\n }\n\n _this18.hideDropdown(true);\n }\n }, _blurActions[SELECT_ONE_TYPE] = function () {\n _this18.containerOuter.removeFocusState();\n\n if (target === _this18.input.element || target === _this18.containerOuter.element && !_this18._canSearch) {\n _this18.hideDropdown(true);\n }\n }, _blurActions[SELECT_MULTIPLE_TYPE] = function () {\n if (target === _this18.input.element) {\n _this18.containerOuter.removeFocusState();\n\n _this18.hideDropdown(true);\n\n if (hasHighlightedItems) {\n _this18.unhighlightAll();\n }\n }\n }, _blurActions);\n blurActions[this.passedElement.element.type]();\n } else {\n // On IE11, clicking the scollbar blurs our input and thus\n // closes the dropdown. To stop this, we refocus our input\n // if we know we are on IE *and* are scrolling.\n this._isScrollingOnIe = false;\n this.input.element.focus();\n }\n };\n\n _proto._onFormReset = function _onFormReset() {\n this._store.dispatch(resetTo(this._initialState));\n };\n\n _proto._highlightChoice = function _highlightChoice(el) {\n var _this19 = this;\n\n if (el === void 0) {\n el = null;\n }\n\n var choices = Array.from(this.dropdown.element.querySelectorAll('[data-choice-selectable]'));\n\n if (!choices.length) {\n return;\n }\n\n var passedEl = el;\n var highlightedChoices = Array.from(this.dropdown.element.querySelectorAll(\".\" + this.config.classNames.highlightedState)); // Remove any highlighted choices\n\n highlightedChoices.forEach(function (choice) {\n choice.classList.remove(_this19.config.classNames.highlightedState);\n choice.setAttribute('aria-selected', 'false');\n });\n\n if (passedEl) {\n this._highlightPosition = choices.indexOf(passedEl);\n } else {\n // Highlight choice based on last known highlight location\n if (choices.length > this._highlightPosition) {\n // If we have an option to highlight\n passedEl = choices[this._highlightPosition];\n } else {\n // Otherwise highlight the option before\n passedEl = choices[choices.length - 1];\n }\n\n if (!passedEl) {\n passedEl = choices[0];\n }\n }\n\n passedEl.classList.add(this.config.classNames.highlightedState);\n passedEl.setAttribute('aria-selected', 'true');\n this.passedElement.triggerEvent(EVENTS.highlightChoice, {\n el: passedEl\n });\n\n if (this.dropdown.isActive) {\n // IE11 ignores aria-label and blocks virtual keyboard\n // if aria-activedescendant is set without a dropdown\n this.input.setActiveDescendant(passedEl.id);\n this.containerOuter.setActiveDescendant(passedEl.id);\n }\n };\n\n _proto._addItem = function _addItem(_ref13) {\n var value = _ref13.value,\n _ref13$label = _ref13.label,\n label = _ref13$label === void 0 ? null : _ref13$label,\n _ref13$choiceId = _ref13.choiceId,\n choiceId = _ref13$choiceId === void 0 ? -1 : _ref13$choiceId,\n _ref13$groupId = _ref13.groupId,\n groupId = _ref13$groupId === void 0 ? -1 : _ref13$groupId,\n _ref13$customProperti = _ref13.customProperties,\n customProperties = _ref13$customProperti === void 0 ? null : _ref13$customProperti,\n _ref13$placeholder = _ref13.placeholder,\n placeholder = _ref13$placeholder === void 0 ? false : _ref13$placeholder,\n _ref13$keyCode = _ref13.keyCode,\n keyCode = _ref13$keyCode === void 0 ? null : _ref13$keyCode;\n var passedValue = typeof value === 'string' ? value.trim() : value;\n var passedKeyCode = keyCode;\n var passedCustomProperties = customProperties;\n var items = this._store.items;\n var passedLabel = label || passedValue;\n var passedOptionId = choiceId || -1;\n var group = groupId >= 0 ? this._store.getGroupById(groupId) : null;\n var id = items ? items.length + 1 : 1; // If a prepended value has been passed, prepend it\n\n if (this.config.prependValue) {\n passedValue = this.config.prependValue + passedValue.toString();\n } // If an appended value has been passed, append it\n\n\n if (this.config.appendValue) {\n passedValue += this.config.appendValue.toString();\n }\n\n this._store.dispatch(items_addItem({\n value: passedValue,\n label: passedLabel,\n id: id,\n choiceId: passedOptionId,\n groupId: groupId,\n customProperties: customProperties,\n placeholder: placeholder,\n keyCode: passedKeyCode\n }));\n\n if (this._isSelectOneElement) {\n this.removeActiveItems(id);\n } // Trigger change event\n\n\n this.passedElement.triggerEvent(EVENTS.addItem, {\n id: id,\n value: passedValue,\n label: passedLabel,\n customProperties: passedCustomProperties,\n groupValue: group && group.value ? group.value : undefined,\n keyCode: passedKeyCode\n });\n return this;\n };\n\n _proto._removeItem = function _removeItem(item) {\n if (!item || !isType('Object', item)) {\n return this;\n }\n\n var id = item.id,\n value = item.value,\n label = item.label,\n choiceId = item.choiceId,\n groupId = item.groupId;\n var group = groupId >= 0 ? this._store.getGroupById(groupId) : null;\n\n this._store.dispatch(items_removeItem(id, choiceId));\n\n if (group && group.value) {\n this.passedElement.triggerEvent(EVENTS.removeItem, {\n id: id,\n value: value,\n label: label,\n groupValue: group.value\n });\n } else {\n this.passedElement.triggerEvent(EVENTS.removeItem, {\n id: id,\n value: value,\n label: label\n });\n }\n\n return this;\n };\n\n _proto._addChoice = function _addChoice(_ref14) {\n var value = _ref14.value,\n _ref14$label = _ref14.label,\n label = _ref14$label === void 0 ? null : _ref14$label,\n _ref14$isSelected = _ref14.isSelected,\n isSelected = _ref14$isSelected === void 0 ? false : _ref14$isSelected,\n _ref14$isDisabled = _ref14.isDisabled,\n isDisabled = _ref14$isDisabled === void 0 ? false : _ref14$isDisabled,\n _ref14$groupId = _ref14.groupId,\n groupId = _ref14$groupId === void 0 ? -1 : _ref14$groupId,\n _ref14$customProperti = _ref14.customProperties,\n customProperties = _ref14$customProperti === void 0 ? null : _ref14$customProperti,\n _ref14$placeholder = _ref14.placeholder,\n placeholder = _ref14$placeholder === void 0 ? false : _ref14$placeholder,\n _ref14$keyCode = _ref14.keyCode,\n keyCode = _ref14$keyCode === void 0 ? null : _ref14$keyCode;\n\n if (typeof value === 'undefined' || value === null) {\n return;\n } // Generate unique id\n\n\n var choices = this._store.choices;\n var choiceLabel = label || value;\n var choiceId = choices ? choices.length + 1 : 1;\n var choiceElementId = this._baseId + \"-\" + this._idNames.itemChoice + \"-\" + choiceId;\n\n this._store.dispatch(choices_addChoice({\n id: choiceId,\n groupId: groupId,\n elementId: choiceElementId,\n value: value,\n label: choiceLabel,\n disabled: isDisabled,\n customProperties: customProperties,\n placeholder: placeholder,\n keyCode: keyCode\n }));\n\n if (isSelected) {\n this._addItem({\n value: value,\n label: choiceLabel,\n choiceId: choiceId,\n customProperties: customProperties,\n placeholder: placeholder,\n keyCode: keyCode\n });\n }\n };\n\n _proto._addGroup = function _addGroup(_ref15) {\n var _this20 = this;\n\n var group = _ref15.group,\n id = _ref15.id,\n _ref15$valueKey = _ref15.valueKey,\n valueKey = _ref15$valueKey === void 0 ? 'value' : _ref15$valueKey,\n _ref15$labelKey = _ref15.labelKey,\n labelKey = _ref15$labelKey === void 0 ? 'label' : _ref15$labelKey;\n var groupChoices = isType('Object', group) ? group.choices : Array.from(group.getElementsByTagName('OPTION'));\n var groupId = id || Math.floor(new Date().valueOf() * Math.random());\n var isDisabled = group.disabled ? group.disabled : false;\n\n if (groupChoices) {\n this._store.dispatch(groups_addGroup({\n value: group.label,\n id: groupId,\n active: true,\n disabled: isDisabled\n }));\n\n var addGroupChoices = function addGroupChoices(choice) {\n var isOptDisabled = choice.disabled || choice.parentNode && choice.parentNode.disabled;\n\n _this20._addChoice({\n value: choice[valueKey],\n label: isType('Object', choice) ? choice[labelKey] : choice.innerHTML,\n isSelected: choice.selected,\n isDisabled: isOptDisabled,\n groupId: groupId,\n customProperties: choice.customProperties,\n placeholder: choice.placeholder\n });\n };\n\n groupChoices.forEach(addGroupChoices);\n } else {\n this._store.dispatch(groups_addGroup({\n value: group.label,\n id: group.id,\n active: false,\n disabled: group.disabled\n }));\n }\n };\n\n _proto._getTemplate = function _getTemplate(template) {\n var _this$_templates$temp;\n\n if (!template) {\n return null;\n }\n\n var classNames = this.config.classNames;\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n return (_this$_templates$temp = this._templates[template]).call.apply(_this$_templates$temp, [this, classNames].concat(args));\n };\n\n _proto._createTemplates = function _createTemplates() {\n var callbackOnCreateTemplates = this.config.callbackOnCreateTemplates;\n var userTemplates = {};\n\n if (callbackOnCreateTemplates && typeof callbackOnCreateTemplates === 'function') {\n userTemplates = callbackOnCreateTemplates.call(this, strToEl);\n }\n\n this._templates = cjs_default()(TEMPLATES, userTemplates);\n };\n\n _proto._createElements = function _createElements() {\n this.containerOuter = new container_Container({\n element: this._getTemplate('containerOuter', this._direction, this._isSelectElement, this._isSelectOneElement, this.config.searchEnabled, this.passedElement.element.type),\n classNames: this.config.classNames,\n type: this.passedElement.element.type,\n position: this.config.position\n });\n this.containerInner = new container_Container({\n element: this._getTemplate('containerInner'),\n classNames: this.config.classNames,\n type: this.passedElement.element.type,\n position: this.config.position\n });\n this.input = new input_Input({\n element: this._getTemplate('input', this._placeholderValue),\n classNames: this.config.classNames,\n type: this.passedElement.element.type,\n preventPaste: !this.config.paste\n });\n this.choiceList = new list_List({\n element: this._getTemplate('choiceList', this._isSelectOneElement)\n });\n this.itemList = new list_List({\n element: this._getTemplate('itemList', this._isSelectOneElement)\n });\n this.dropdown = new Dropdown({\n element: this._getTemplate('dropdown'),\n classNames: this.config.classNames,\n type: this.passedElement.element.type\n });\n };\n\n _proto._createStructure = function _createStructure() {\n // Hide original element\n this.passedElement.conceal(); // Wrap input in container preserving DOM ordering\n\n this.containerInner.wrap(this.passedElement.element); // Wrapper inner container with outer container\n\n this.containerOuter.wrap(this.containerInner.element);\n\n if (this._isSelectOneElement) {\n this.input.placeholder = this.config.searchPlaceholderValue || '';\n } else if (this._placeholderValue) {\n this.input.placeholder = this._placeholderValue;\n this.input.setWidth();\n }\n\n this.containerOuter.element.appendChild(this.containerInner.element);\n this.containerOuter.element.appendChild(this.dropdown.element);\n this.containerInner.element.appendChild(this.itemList.element);\n\n if (!this._isTextElement) {\n this.dropdown.element.appendChild(this.choiceList.element);\n }\n\n if (!this._isSelectOneElement) {\n this.containerInner.element.appendChild(this.input.element);\n } else if (this.config.searchEnabled) {\n this.dropdown.element.insertBefore(this.input.element, this.dropdown.element.firstChild);\n }\n\n if (this._isSelectElement) {\n this._highlightPosition = 0;\n this._isSearching = false;\n\n this._startLoading();\n\n if (this._presetGroups.length) {\n this._addPredefinedGroups(this._presetGroups);\n } else {\n this._addPredefinedChoices(this._presetChoices);\n }\n\n this._stopLoading();\n }\n\n if (this._isTextElement) {\n this._addPredefinedItems(this._presetItems);\n }\n };\n\n _proto._addPredefinedGroups = function _addPredefinedGroups(groups) {\n var _this21 = this; // If we have a placeholder option\n\n\n var placeholderChoice = this.passedElement.placeholderOption;\n\n if (placeholderChoice && placeholderChoice.parentNode.tagName === 'SELECT') {\n this._addChoice({\n value: placeholderChoice.value,\n label: placeholderChoice.innerHTML,\n isSelected: placeholderChoice.selected,\n isDisabled: placeholderChoice.disabled,\n placeholder: true\n });\n }\n\n groups.forEach(function (group) {\n return _this21._addGroup({\n group: group,\n id: group.id || null\n });\n });\n };\n\n _proto._addPredefinedChoices = function _addPredefinedChoices(choices) {\n var _this22 = this; // If sorting is enabled or the user is searching, filter choices\n\n\n if (this.config.shouldSort) {\n choices.sort(this.config.sorter);\n }\n\n var hasSelectedChoice = choices.some(function (choice) {\n return choice.selected;\n });\n var firstEnabledChoiceIndex = choices.findIndex(function (choice) {\n return choice.disabled === undefined || !choice.disabled;\n });\n choices.forEach(function (choice, index) {\n var value = choice.value,\n label = choice.label,\n customProperties = choice.customProperties,\n placeholder = choice.placeholder;\n\n if (_this22._isSelectElement) {\n // If the choice is actually a group\n if (choice.choices) {\n _this22._addGroup({\n group: choice,\n id: choice.id || null\n });\n } else {\n /**\n * If there is a selected choice already or the choice is not the first in\n * the array, add each choice normally.\n *\n * Otherwise we pre-select the first enabled choice in the array (\"select-one\" only)\n */\n var shouldPreselect = _this22._isSelectOneElement && !hasSelectedChoice && index === firstEnabledChoiceIndex;\n var isSelected = shouldPreselect ? true : choice.selected;\n var isDisabled = choice.disabled;\n\n _this22._addChoice({\n value: value,\n label: label,\n isSelected: isSelected,\n isDisabled: isDisabled,\n customProperties: customProperties,\n placeholder: placeholder\n });\n }\n } else {\n _this22._addChoice({\n value: value,\n label: label,\n isSelected: choice.selected,\n isDisabled: choice.disabled,\n customProperties: customProperties,\n placeholder: placeholder\n });\n }\n });\n }\n /**\n * @param {Item[]} items\n */\n ;\n\n _proto._addPredefinedItems = function _addPredefinedItems(items) {\n var _this23 = this;\n\n items.forEach(function (item) {\n if (_typeof(item) === 'object' && item.value) {\n _this23._addItem({\n value: item.value,\n label: item.label,\n choiceId: item.id,\n customProperties: item.customProperties,\n placeholder: item.placeholder\n });\n }\n\n if (typeof item === 'string') {\n _this23._addItem({\n value: item\n });\n }\n });\n };\n\n _proto._setChoiceOrItem = function _setChoiceOrItem(item) {\n var _this24 = this;\n\n var itemType = getType(item).toLowerCase();\n var handleType = {\n object: function object() {\n if (!item.value) {\n return;\n } // If we are dealing with a select input, we need to create an option first\n // that is then selected. For text inputs we can just add items normally.\n\n\n if (!_this24._isTextElement) {\n _this24._addChoice({\n value: item.value,\n label: item.label,\n isSelected: true,\n isDisabled: false,\n customProperties: item.customProperties,\n placeholder: item.placeholder\n });\n } else {\n _this24._addItem({\n value: item.value,\n label: item.label,\n choiceId: item.id,\n customProperties: item.customProperties,\n placeholder: item.placeholder\n });\n }\n },\n string: function string() {\n if (!_this24._isTextElement) {\n _this24._addChoice({\n value: item,\n label: item,\n isSelected: true,\n isDisabled: false\n });\n } else {\n _this24._addItem({\n value: item\n });\n }\n }\n };\n handleType[itemType]();\n };\n\n _proto._findAndSelectChoiceByValue = function _findAndSelectChoiceByValue(val) {\n var _this25 = this;\n\n var choices = this._store.choices; // Check 'value' property exists and the choice isn't already selected\n\n var foundChoice = choices.find(function (choice) {\n return _this25.config.valueComparer(choice.value, val);\n });\n\n if (foundChoice && !foundChoice.selected) {\n this._addItem({\n value: foundChoice.value,\n label: foundChoice.label,\n choiceId: foundChoice.id,\n groupId: foundChoice.groupId,\n customProperties: foundChoice.customProperties,\n placeholder: foundChoice.placeholder,\n keyCode: foundChoice.keyCode\n });\n }\n };\n\n _proto._generatePlaceholderValue = function _generatePlaceholderValue() {\n if (this._isSelectElement) {\n var placeholderOption = this.passedElement.placeholderOption;\n return placeholderOption ? placeholderOption.text : false;\n }\n\n var _this$config4 = this.config,\n placeholder = _this$config4.placeholder,\n placeholderValue = _this$config4.placeholderValue;\n var dataset = this.passedElement.element.dataset;\n\n if (placeholder) {\n if (placeholderValue) {\n return placeholderValue;\n }\n\n if (dataset.placeholder) {\n return dataset.placeholder;\n }\n }\n\n return false;\n };\n\n return Choices;\n }();\n /* harmony default export */\n\n\n var scripts_choices = __webpack_exports__[\"default\"] = choices_Choices;\n /***/\n }\n /******/\n ])[\"default\"]\n );\n});","var Cookie = {\n get: (key) => {\n let cookie = document.cookie.split('; ').find(row => row.startsWith(key))\n let value = null\n\n if (cookie) {\n value = cookie.split('=')[1]\n }\n\n return value\n },\n\n set: (key, value, days=null) => {\n let cookie = `${key}=${value}; path=/`\n\n if (days) {\n let date = new Date()\n date.setDate(date.getDate() + days)\n cookie += `; expires=${date.toUTCString()}`\n }\n\n document.cookie = cookie\n },\n\n delete: (key) => {\n document.cookie = `${key}=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;`\n }\n}\n\nmodule.exports = Cookie\n","module.exports = function (module) {\n if (!module.webpackPolyfill) {\n module.deprecate = function () {};\n\n module.paths = []; // module.parent = undefined by default\n\n if (!module.children) module.children = [];\n Object.defineProperty(module, \"loaded\", {\n enumerable: true,\n get: function get() {\n return module.l;\n }\n });\n Object.defineProperty(module, \"id\", {\n enumerable: true,\n get: function get() {\n return module.i;\n }\n });\n module.webpackPolyfill = 1;\n }\n\n return module;\n};","class Toast {\n static success(message, duration) {\n Toast.showAndHide(\"success\", message, duration)\n }\n\n static warning(message){\n Toast.showAndHide(\"warning\", message)\n }\n\n static error(message) {\n Toast.showAndHide(\"error\", message)\n }\n\n static show(type, message) {\n const toast = document.createElement(\"div\")\n toast.classList.add(\"toast\")\n toast.classList.add(\"toast-\" + type)\n toast.animateCSS(\"slideInDown\", \"faster\")\n toast.innerText = message\n document.body.appendChild(toast)\n }\n\n static showAndHide(type, message, duration = 2000) {\n Toast.show(type, message)\n setTimeout(function() {\n Toast.hide()\n }, duration)\n }\n\n static hide() {\n toast = $(\".toast\")\n toast.animateCSS(\"fadeOut\")\n\n toast.addEventListener('animationend', () => {\n toast.parentNode.removeChild(toast)\n });\n }\n}\n\nmodule.exports = Toast\n","var jstz = require(\"jstimezonedetect\");\n\nvar EmailBox = {\n posted_email: \"\",\n input: null,\n button: null,\n error: null,\n\n init: function (input = null, button = null, error = null) {\n EmailBox.input = input || $(\"#email-field\");\n EmailBox.button = button || $(\"#subscribe-button\");\n EmailBox.error = error || $(\".email-box #subscribe-button-error\");\n\n EmailBox.error.style.display = \"none\";\n\n EmailBox.bindFields();\n },\n\n bindFields: function () {\n EmailBox.input.addEventListener(\"keyup\", (e) => {\n if (e.keyCode == 13) {\n EmailBox.button.click();\n }\n });\n\n EmailBox.button.addEventListener(\"click\", () => {\n SmartButton.disable(EmailBox.button);\n EmailBox.subscribe();\n });\n },\n\n show: function () {\n $$(\".boxes\").forEach((node) => {\n node.style.display = \"none\";\n });\n $(\".email-box\").style.display = null;\n $(\".email-box\").animateCSS(\"fadeIn\");\n },\n\n trackingProperties: function () {\n return {\n step: EmailBox.trackingStep(),\n };\n },\n\n trackingStep: function () {\n return \"email\";\n },\n\n subscribe: function () {\n var ref_publication_slug = $(\"#ref_publication_slug\").value;\n var ref = $(\"#ref\").value;\n var conversion_data = conversion_tracker.getConversionTags();\n var verify_email = \"true\";\n\n if (EmailBox.posted_email == EmailBox.input.value) {\n // The person got a suggestion from Mailgun but insisted on submitting their initial email. In good faith, let's assume Mailgun wrongly flagged the email.\n verify_email = \"false\";\n }\n\n ajax\n .post(Routes.users_path(), {\n user: {\n email: EmailBox.input.value,\n time_zone: jstz.determine().name(),\n },\n verify_email: verify_email,\n ref_publication_slug: ref_publication_slug,\n ref: ref,\n conversion_data: conversion_data,\n })\n .then((response) => response.json())\n .then((data) => {\n conversion_tracker.clearConversionTags();\n PaywallManager.clearCookie();\n EmailBox.subscribed(data);\n\n data.followed_publications.forEach((followed_publication) => {\n $$(\".publishers .publisher-button\").forEach((node) => {\n if (node.getAttribute(\"data-id\") == followed_publication) {\n node.setAttribute(\"data-following-enabled\", \"true\");\n node.classList.add(\"following\");\n node.innerText = \"Following\";\n }\n });\n });\n })\n .catch((response) =>\n response.json().then((data) => {\n EmailBox.error.style.display = null;\n\n if (data.error === \"Email has already been taken\") {\n EmailBox.error.innerHTML = `You already have an account. Log in?`;\n } else if (data.suggestion != null) {\n EmailBox.posted_email = EmailBox.input.value;\n EmailBox.error.innerHTML =\n \"Did you mean \" +\n data.suggestion +\n \"?\";\n } else if (data.error != null) {\n EmailBox.error.innerText = data.error;\n }\n\n SmartButton.enable(EmailBox.button);\n })\n );\n },\n\n subscribed: function (data) {\n EVERY.fb_track(\"Lead\");\n if (typeof gtag === \"function\") {\n gtag(\"event\", \"conversion\", {\n send_to: \"AW-1056773772/kPNGCKnUk9YDEIyt9PcD\",\n });\n }\n\n if (data.paid_acquisition == true) {\n // Switch steps 2 & 3 in the subscribe flow\n BoxNavigator.switchToPaidAcquisitionFlow();\n BoxNavigator.next();\n } else {\n user_id = data.user.id;\n user_email = data.user.email;\n EmailBox.error.style.display = \"none\";\n if ($(\".payment-box\")) {\n BoxNavigator.next();\n SmartButton.enable(EmailBox.button);\n } else {\n this.button.innerText = \"Thank you!\";\n this.button.disabled = true;\n window.location = \"/subscribe\";\n }\n // Update follow buttons now that we have a user id\n $$(\".publisher-button\").forEach((node) => {\n node.setAttribute(\"data-current-user-id\", user_id);\n });\n }\n },\n};\n\nvar PaymentBox = {\n posted_email: \"\",\n applePaymentRequest: null,\n applePaymentAvailable: false,\n\n init: function () {\n PaymentBox.bindFields();\n },\n\n bindFields: function () {\n var stripeScript = document.createElement(\"script\");\n stripeScript.src = \"https://js.stripe.com/v3/\";\n stripeScript.addEventListener(\"load\", () => {\n PaymentBox.initStripe();\n });\n document.body.appendChild(stripeScript);\n },\n\n show: function () {\n if ($$(\".boxes\")) {\n $$(\".boxes\").forEach((node) => {\n if (node) {\n node.style.display = \"none\";\n }\n });\n }\n\n if ($(\".payment-box\")) {\n $(\".payment-box\").style.display = null;\n $(\".payment-box\").animateCSS(\"fadeIn\");\n } else {\n window.location = redirect_url;\n }\n },\n\n trackingProperties: function () {\n let properties = {\n step: PaymentBox.trackingStep(),\n };\n\n if (hash) {\n properties[\"hash\"] = hash;\n }\n\n return properties;\n },\n\n trackingStep: function () {\n return \"payment\";\n },\n\n initStripe: function () {\n // Init variables\n var stripe = Stripe(stripe_publishable_key);\n var elements = stripe.elements();\n var style = {\n base: {\n color: \"#222\",\n fontSize: \"16px\",\n color: \"white\",\n },\n };\n var form = document.getElementById(\"payment-form\");\n var card = elements.create(\"card\", { style: style });\n const displayError = document.getElementById(\"card-errors\");\n\n const token = redirect_url\n ? redirect_url.split(\"/payment/\")[1] &&\n redirect_url.split(\"/payment/\")[1].split(\"/\")[0]\n : null;\n\n // Mount Stripe widget\n card.mount(\"#card-element\");\n\n // Add listener for error messages\n card.addEventListener(\"change\", ({ error }) => {\n if (error) {\n displayError.innerText = error.message;\n } else {\n displayError.innerText = \"\";\n }\n });\n\n // Add form callbacks\n form.addEventListener(\"submit\", function (ev) {\n ev.preventDefault();\n PaymentBox.handlePayment(stripe, card);\n });\n\n // Apple Pay\n if ($(\"#payment-request-button\")) {\n PaymentBox.applePaymentRequest = stripe.paymentRequest({\n country: \"US\",\n currency: \"usd\",\n total: {\n label: \"$1 for 2 weeks, then $200 per year\",\n amount: 100,\n },\n });\n var prButton = elements.create(\"paymentRequestButton\", {\n paymentRequest: PaymentBox.applePaymentRequest,\n });\n\n // Check the availability of the Payment Request API first.\n PaymentBox.applePaymentRequest.canMakePayment().then(function (result) {\n if (result) {\n prButton.mount(\"#payment-request-button\");\n $(\".apple-pay-container\").style.display = \"block\";\n if (enable_trial) $(\"#button-text\").innerText = \"Start a trial\";\n PaymentBox.applePaymentAvailable = true;\n EVERY.track(\"Viewed wallet button\");\n }\n });\n\n PaymentBox.applePaymentRequest.on(\"paymentmethod\", function (event) {\n const displayError = document.getElementById(\"card-errors\");\n const buttonText = document.getElementById(\"button-text\");\n const loadingSpinner = document.getElementById(\"loading-spinner\");\n const applePayContainer = document.querySelector(\n \".apple-pay-container\"\n );\n const payButton = document.getElementById(\"pay-button\");\n\n // Show loading state and disable regular payment\n payButton.disabled = true;\n payButton.classList.add(\"opacity-75\");\n buttonText.innerText = \"Processing payment...\";\n loadingSpinner.classList.remove(\"hidden\");\n\n const resetButtonState = () => {\n payButton.disabled = false;\n payButton.classList.remove(\"opacity-75\");\n buttonText.innerText =\n user_plan === yearly_plan ? \"Start a Trial\" : \"Subscribe\";\n loadingSpinner.classList.add(\"hidden\");\n };\n\n const handleError = (message) => {\n displayError.innerText =\n message.includes(\"DOCTYPE\") || !message\n ? \"Error occurred. Please try again or contact us at hello@every.to\"\n : message;\n resetButtonState();\n event.complete(\"fail\");\n };\n\n var conversion_data = conversion_tracker.getConversionTags();\n // Extract token from redirect_url if present\n const token = redirect_url\n ? redirect_url.split(\"/payment/\")[1] &&\n redirect_url.split(\"/payment/\")[1].split(\"/\")[0]\n : null;\n\n ajax\n .post(Routes.subscriptions_path(), {\n hash: hash,\n token: token,\n payment_method: event.paymentMethod.id,\n plan: user_plan,\n coupon: coupon_id,\n type: \"apple_pay\",\n conversion_data: conversion_data,\n referral: window.Rewardful && window.Rewardful.referral,\n subscription_source: window.subscription_source || \"every\",\n })\n .then((response) => response.json())\n .then((data) => {\n if (data.error) {\n handleError(data.error);\n return;\n }\n\n conversion_tracker.clearConversionTags();\n PaywallManager.clearCookie();\n\n event.complete(\"success\");\n EVERY.track(\"Paid account created\", { period: data.plan.period });\n EVERY.ga_event(\n \"every.to\",\n \"Paid account created\",\n data.plan.period\n );\n PaymentBox.paymentSuccess(data);\n })\n .catch(function (error) {\n handleError(error.message);\n });\n });\n }\n },\n\n switch: function (period) {\n if (period == \"monthly\") {\n user_plan = monthly_plan;\n $(\"#button-text\").innerText = \"Subscribe\";\n PaymentBox.applePaymentRequest.update({\n total: {\n label: \"$20 per month\",\n amount: 2000,\n },\n });\n } else {\n user_plan = yearly_plan;\n $(\"#button-text\").innerText = window.enable_trial\n ? \"Start a Trial\"\n : \"Subscribe\";\n PaymentBox.applePaymentRequest.update({\n total: {\n label: window.enable_trial\n ? \"$1 for 2 weeks, then $200 per year\"\n : \"$200 per year\",\n amount: window.enable_trial ? 100 : 20000,\n },\n });\n }\n },\n\n handleFreeAccount: function () {\n ajax\n .post(Routes.subscriptions_path(), {\n hash: hash,\n payment_method: null,\n })\n .then((response) => response.json())\n .then((data) => {\n EVERY.track(\"Free account created\");\n EVERY.ga_event(\"every.to\", \"Free account created\");\n BoxNavigator.next();\n });\n },\n\n handlePayment: function (stripe, card) {\n const displayError = document.getElementById(\"card-errors\");\n const buttonText = document.getElementById(\"button-text\");\n const loadingSpinner = document.getElementById(\"loading-spinner\");\n const applePayContainer = document.querySelector(\".apple-pay-container\");\n const payButton = document.getElementById(\"pay-button\");\n\n // Extract token from redirect_url if present\n const token = redirect_url\n ? redirect_url.split(\"/payment/\")[1] &&\n redirect_url.split(\"/payment/\")[1].split(\"/\")[0]\n : null;\n\n // Show loading state\n payButton.disabled = true;\n payButton.classList.add(\"opacity-75\");\n buttonText.innerText = \"Processing payment...\";\n loadingSpinner.classList.remove(\"hidden\");\n\n // Disable Apple Pay during processing\n if (applePayContainer) {\n applePayContainer.classList.add(\"opacity-50\", \"pointer-events-none\");\n }\n\n const resetButtonState = () => {\n payButton.disabled = false;\n payButton.classList.remove(\"opacity-75\");\n buttonText.innerText =\n user_plan === yearly_plan && window.enable_trial\n ? \"Start a Trial\"\n : \"Subscribe\";\n loadingSpinner.classList.add(\"hidden\");\n if (applePayContainer) {\n applePayContainer.classList.remove(\"opacity-50\", \"pointer-events-none\");\n }\n };\n\n const handleError = (message) => {\n displayError.innerText =\n message.includes(\"DOCTYPE\") || !message\n ? \"Error occurred. Please try again or contact us at hello@every.to\"\n : message;\n resetButtonState();\n };\n\n stripe\n .createPaymentMethod({\n type: \"card\",\n card: card,\n billing_details: {\n email: user_email,\n },\n })\n .then(function (result) {\n if (result.error) {\n handleError(result.error.message);\n } else {\n var conversion_data = conversion_tracker.getConversionTags();\n ajax\n .post(Routes.subscriptions_path(), {\n hash: hash,\n token: token,\n payment_method: result.paymentMethod.id,\n plan: user_plan,\n coupon: coupon_id,\n conversion_data: conversion_data,\n referral: window.Rewardful && window.Rewardful.referral,\n subscription_source: window.subscription_source || \"every\",\n })\n .then((response) => response.json())\n .then((data) => {\n if (data.error) {\n handleError(data.error);\n return;\n }\n\n conversion_tracker.clearConversionTags();\n PaywallManager.clearCookie();\n const payment_intent = data.payment_intent;\n\n if (payment_intent) {\n const { client_secret, status } = payment_intent;\n\n if (status === \"requires_action\") {\n stripe\n .confirmCardPayment(client_secret)\n .then(function (result) {\n if (result.error) {\n handleError(result.error.message);\n } else {\n ajax.patch(Routes.verify_subscriptions_path(), {\n user_id: user_id,\n });\n EVERY.track(\"Paid account created\", {\n period: data.plan.period,\n });\n EVERY.ga_event(\n \"every.to\",\n \"Paid account created\",\n data.plan.period\n );\n PaymentBox.paymentSuccess(data);\n }\n })\n .catch(function (error) {\n handleError(error.message);\n });\n } else {\n EVERY.track(\"Paid account created\", {\n period: data.plan.period,\n });\n EVERY.ga_event(\n \"every.to\",\n \"Paid account created\",\n data.plan.period\n );\n PaymentBox.paymentSuccess(data);\n }\n }\n })\n .catch(function (error) {\n handleError(error.message);\n });\n }\n })\n .catch(function (error) {\n handleError(error.message);\n });\n },\n\n paymentSuccess: function (data) {\n if (user_plan == yearly_plan) {\n EVERY.fb_track(\"StartTrial\", { value: \"1.00\", currency: \"USD\" });\n\n if (typeof window[\"posthog\"] !== \"undefined\") {\n window.posthog.capture(\"start_trial\");\n }\n } else if (user_plan == monthly_plan) {\n EVERY.fb_track(\"Subscribe\", { value: \"20.00\", currency: \"USD\" });\n\n if (typeof window[\"posthog\"] !== \"undefined\") {\n window.posthog.capture(\"subscribe\");\n }\n }\n\n // Check if we need to redirect (product payment page) or continue with flow (regular subscription)\n if (redirect_url) {\n // Product payment page case - redirect with subscription info\n window.location =\n redirect_url +\n (redirect_url.includes(\"?\") ? \"&\" : \"?\") +\n `stripe_subscription_id=${data.subscription.id}&stripe_customer_id=${data.subscription.customer}`;\n } else {\n // Regular subscription flow - continue to next step\n BoxNavigator.next();\n }\n },\n};\n\nvar PublishersBox = {\n init: function () {\n let proceedFromPublishersButton = document.querySelector(\n \".publishers-box .proceed button\"\n );\n let ckFormContainer = document.querySelector(\"#ck-form-container\");\n\n const proceedFromPublishers = () => {\n if (ckFormContainer && ckFormContainer.querySelector(\"form\")) {\n let ckForm = ckFormContainer.querySelector(\"form\");\n let ckEmail = ckForm.querySelector(\"input[name='email_address']\");\n let ckSubmitButton = ckForm.querySelector(\"button\");\n ckEmail.value = user_email;\n document.body.addEventListener(\"ckjs:submission:complete\", (e) =>\n BoxNavigator.next()\n );\n ckSubmitButton.click();\n } else {\n BoxNavigator.next();\n }\n };\n\n proceedFromPublishersButton.addEventListener(\n \"click\",\n proceedFromPublishers\n );\n },\n\n show: function () {\n $$(\".boxes\").forEach((node) => {\n node.style.display = \"none\";\n });\n $(\".publishers-box\").style.display = null;\n $(\".publishers-box\").animateCSS(\"fadeIn\");\n },\n\n trackingProperties: function () {\n return {\n step: PublishersBox.trackingStep(),\n };\n },\n\n trackingStep: function () {\n return \"publications\";\n },\n};\n\nvar SurveyBox = {\n init: function () {\n $(\"#submit-survey\").addEventListener(\"click\", (e) => {\n SurveyBox.submit(e.target);\n });\n $(\".survey-box\").style.display = \"none\";\n },\n\n show: function () {\n $$(\".boxes\").forEach((node) => {\n node.style.display = \"none\";\n });\n $(\".survey-box\").style.display = null;\n $(\".survey-box\").animateCSS(\"fadeIn\");\n },\n\n trackingProperties: function () {\n return {\n step: SurveyBox.trackingStep(),\n };\n },\n\n trackingStep: function () {\n return \"survey\";\n },\n\n submit: function (button) {\n SmartButton.disable(button);\n const fname = $(\"#first-name\").value;\n const lname = $(\"#last-name\").value;\n const jobLevel = $(\"#job-level\").value;\n const industry = $(\"#industry\").value;\n const companyName = $(\"#company-name\").value;\n const companySize = $(\"#company-size\").value;\n const postalCode = $(\"#postal-code\").value;\n const consultingInterest = $(\n \"input[type='radio'][name=consulting-interest]:checked\"\n ).value;\n const speakingInterest = $(\n \"input[type='radio'][name=speaking-interest]:checked\"\n ).value;\n const earlyAdopter = $(\n \"input[type='radio'][name=early-adopter]:checked\"\n ).value;\n\n if (postalCode && postalCode.toString().length < 5) {\n alert(\"Please, enter correct postal code or leave the field empty.\");\n return;\n }\n\n ajax\n .post(Routes.surveys_path(), {\n survey: {\n fname,\n lname,\n jobLevel,\n industry,\n companyName,\n companySize,\n postalCode,\n consultingInterest,\n speakingInterest,\n earlyAdopter,\n },\n })\n .then((response) => response.json())\n .then((data) => {\n SurveyBox.submitted();\n });\n },\n\n submitted: function () {\n window.location = redirect_url;\n },\n};\n\nvar BoxNavigator = {\n all: [EmailBox, PaymentBox, SurveyBox],\n _current: 0,\n\n init: function (box) {\n BoxNavigator._current = BoxNavigator.all.indexOf(box);\n\n box.show();\n BoxNavigator.track();\n },\n\n next: function () {\n BoxNavigator.increment();\n let box = BoxNavigator.all[BoxNavigator._current];\n\n box.show();\n BoxNavigator.track();\n },\n\n increment: function () {\n BoxNavigator._current = BoxNavigator._current + 1;\n },\n\n track: function () {\n let step_number = BoxNavigator._current + 1;\n let box = BoxNavigator.all[BoxNavigator._current];\n let properties = box.trackingProperties();\n let tracking_step = box.trackingStep();\n\n EVERY.track(\"Subscribe Flow - Step \" + step_number, properties);\n EVERY.ga_event(\n \"every.to\",\n \"Subscribe Flow - Step \" + step_number,\n tracking_step\n );\n EVERY.ga_pageview(Routes.subscribe_path() + \"/step-\" + step_number);\n },\n\n switchToPaidAcquisitionFlow: function () {\n BoxNavigator.all = [EmailBox, PaymentBox, SurveyBox];\n },\n};\n\nconst paymentPlanCardsContainerClickHandler = (e) => {\n let cardsContainer = e.currentTarget;\n\n if (e.target === cardsContainer)\n //when empty space between the cards is clicked do nothing\n return;\n\n let planCards = cardsContainer.querySelectorAll(\".payment-plan-card\");\n let planButtons = cardsContainer.querySelectorAll(\".payment-plan-button\");\n let clickedCard = e.target.closest(\".payment-plan-button\");\n\n //handle setting the green border and expanding the card for mobile UI\n planCards.forEach((card) => {\n if (card && card.dataset.planType === clickedCard.dataset.planType) {\n card.classList.add(\"selected\");\n } else {\n card.classList.remove(\"selected\");\n }\n });\n\n planButtons.forEach((card) => {\n if (card.dataset.planType === clickedCard.dataset.planType) {\n card.classList.add(\"selected\");\n } else {\n card.classList.remove(\"selected\");\n }\n });\n\n let planType = clickedCard.dataset.planType;\n\n if (planType !== \"free\") {\n //set plan type when the selected plan is not free\n PaymentBox.switch(planType);\n\n // toggle display of stripe widget and continue-free button\n $(\".credit-card\").style.display = \"block\";\n if (PaymentBox.applePaymentAvailable) {\n $(\".apple-pay-container\").style.display = \"block\";\n }\n } else {\n //when plan selected is free\n // toggle display of stripe widget and continue-free button\n $(\".credit-card\").style.display = \"none\";\n if (PaymentBox.applePaymentAvailable) {\n $(\".apple-pay-container\").style.display = \"none\";\n }\n }\n};\n\nwindow.addEventListener(\"DOMContentLoaded\", (event) => {\n const paymentPlanCardsContainer = $(\"#payment-plan-cards-container\");\n if (paymentPlanCardsContainer) {\n paymentPlanCardsContainer.addEventListener(\n \"click\",\n paymentPlanCardsContainerClickHandler\n );\n if ($(\".continue-free-btn\")) {\n $(\".continue-free-btn\").addEventListener(\n \"click\",\n PaymentBox.handleFreeAccount\n );\n }\n }\n});\n\nmodule.exports = {\n EmailBox: EmailBox,\n PaymentBox: PaymentBox,\n PublishersBox: PublishersBox,\n SurveyBox: SurveyBox,\n BoxNavigator: BoxNavigator,\n};\n","export default function getBoundingClientRect(element) {\n var rect = element.getBoundingClientRect();\n return {\n width: rect.width,\n height: rect.height,\n top: rect.top,\n right: rect.right,\n bottom: rect.bottom,\n left: rect.left,\n x: rect.left,\n y: rect.top\n };\n}","/*:: import type { Window } from '../types'; */\n\n/*:: declare function getWindow(node: Node | Window): Window; */\nexport default function getWindow(node) {\n if (node.toString() !== '[object Window]') {\n var ownerDocument = node.ownerDocument;\n return ownerDocument ? ownerDocument.defaultView || window : window;\n }\n\n return node;\n}","import getWindow from \"./getWindow.js\";\nexport default function getWindowScroll(node) {\n var win = getWindow(node);\n var scrollLeft = win.pageXOffset;\n var scrollTop = win.pageYOffset;\n return {\n scrollLeft: scrollLeft,\n scrollTop: scrollTop\n };\n}","import getWindow from \"./getWindow.js\";\n/*:: declare function isElement(node: mixed): boolean %checks(node instanceof\n Element); */\n\nfunction isElement(node) {\n var OwnElement = getWindow(node).Element;\n return node instanceof OwnElement || node instanceof Element;\n}\n/*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof\n HTMLElement); */\n\n\nfunction isHTMLElement(node) {\n var OwnElement = getWindow(node).HTMLElement;\n return node instanceof OwnElement || node instanceof HTMLElement;\n}\n/*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof\n ShadowRoot); */\n\n\nfunction isShadowRoot(node) {\n var OwnElement = getWindow(node).ShadowRoot;\n return node instanceof OwnElement || node instanceof ShadowRoot;\n}\n\nexport { isElement, isHTMLElement, isShadowRoot };","export default function getNodeName(element) {\n return element ? (element.nodeName || '').toLowerCase() : null;\n}","import { isElement } from \"./instanceOf.js\";\nexport default function getDocumentElement(element) {\n // $FlowFixMe: assume body is always available\n return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;\n}","import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScroll from \"./getWindowScroll.js\";\nexport default function getWindowScrollBarX(element) {\n // If has a CSS width greater than the viewport, then this will be\n // incorrect for RTL.\n // Popper 1 is broken in this case and never had a bug report so let's assume\n // it's not an issue. I don't think anyone ever specifies width on \n // anyway.\n // Browsers where the left scrollbar doesn't cause an issue report `0` for\n // this (e.g. Edge 2019, IE11, Safari)\n return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;\n}","import getWindow from \"./getWindow.js\";\nexport default function getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}","import getComputedStyle from \"./getComputedStyle.js\";\nexport default function isScrollParent(element) {\n // Firefox wants us to check `-x` and `-y` variations as well\n var _getComputedStyle = getComputedStyle(element),\n overflow = _getComputedStyle.overflow,\n overflowX = _getComputedStyle.overflowX,\n overflowY = _getComputedStyle.overflowY;\n\n return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);\n}","import getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getNodeScroll from \"./getNodeScroll.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport isScrollParent from \"./isScrollParent.js\"; // Returns the composite rect of an element relative to its offsetParent.\n// Composite means it takes into account transforms as well as layout.\n\nexport default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {\n if (isFixed === void 0) {\n isFixed = false;\n }\n\n var documentElement = getDocumentElement(offsetParent);\n var rect = getBoundingClientRect(elementOrVirtualElement);\n var isOffsetParentAnElement = isHTMLElement(offsetParent);\n var scroll = {\n scrollLeft: 0,\n scrollTop: 0\n };\n var offsets = {\n x: 0,\n y: 0\n };\n\n if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078\n isScrollParent(documentElement)) {\n scroll = getNodeScroll(offsetParent);\n }\n\n if (isHTMLElement(offsetParent)) {\n offsets = getBoundingClientRect(offsetParent);\n offsets.x += offsetParent.clientLeft;\n offsets.y += offsetParent.clientTop;\n } else if (documentElement) {\n offsets.x = getWindowScrollBarX(documentElement);\n }\n }\n\n return {\n x: rect.left + scroll.scrollLeft - offsets.x,\n y: rect.top + scroll.scrollTop - offsets.y,\n width: rect.width,\n height: rect.height\n };\n}","import getWindowScroll from \"./getWindowScroll.js\";\nimport getWindow from \"./getWindow.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport getHTMLElementScroll from \"./getHTMLElementScroll.js\";\nexport default function getNodeScroll(node) {\n if (node === getWindow(node) || !isHTMLElement(node)) {\n return getWindowScroll(node);\n } else {\n return getHTMLElementScroll(node);\n }\n}","export default function getHTMLElementScroll(element) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n}","// Returns the layout rect of an element relative to its offsetParent. Layout\n// means it doesn't take into account transforms.\nexport default function getLayoutRect(element) {\n return {\n x: element.offsetLeft,\n y: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight\n };\n}","import getNodeName from \"./getNodeName.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nexport default function getParentNode(element) {\n if (getNodeName(element) === 'html') {\n return element;\n }\n\n return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle\n element.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n element.parentNode || // DOM Element detected\n // $FlowFixMe: need a better way to handle this...\n element.host || // ShadowRoot detected\n // $FlowFixMe: HTMLElement is a Node\n getDocumentElement(element) // fallback\n\n );\n}","import getParentNode from \"./getParentNode.js\";\nimport isScrollParent from \"./isScrollParent.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nexport default function getScrollParent(node) {\n if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {\n // $FlowFixMe: assume body is always available\n return node.ownerDocument.body;\n }\n\n if (isHTMLElement(node) && isScrollParent(node)) {\n return node;\n }\n\n return getScrollParent(getParentNode(node));\n}","import getScrollParent from \"./getScrollParent.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport getWindow from \"./getWindow.js\";\nimport isScrollParent from \"./isScrollParent.js\";\n/*\ngiven a DOM element, return the list of all scroll parents, up the list of ancesors\nuntil we get to the top window object. This list is what we attach scroll listeners\nto, because if any of these parent elements scroll, we'll need to re-calculate the \nreference element's position.\n*/\n\nexport default function listScrollParents(element, list) {\n if (list === void 0) {\n list = [];\n }\n\n var scrollParent = getScrollParent(element);\n var isBody = getNodeName(scrollParent) === 'body';\n var win = getWindow(scrollParent);\n var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;\n var updatedList = list.concat(target);\n return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here\n updatedList.concat(listScrollParents(getParentNode(target)));\n}","import getNodeName from \"./getNodeName.js\";\nexport default function isTableElement(element) {\n return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;\n}","import getWindow from \"./getWindow.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isHTMLElement } from \"./instanceOf.js\";\nimport isTableElement from \"./isTableElement.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\n\nfunction getTrueOffsetParent(element) {\n if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837\n getComputedStyle(element).position === 'fixed') {\n return null;\n }\n\n var offsetParent = element.offsetParent;\n\n if (offsetParent) {\n var html = getDocumentElement(offsetParent);\n\n if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {\n return html;\n }\n }\n\n return offsetParent;\n} // `.offsetParent` reports `null` for fixed elements, while absolute elements\n// return the containing block\n\n\nfunction getContainingBlock(element) {\n var currentNode = getParentNode(element);\n\n while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {\n var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that\n // create a containing block.\n\n if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {\n return currentNode;\n } else {\n currentNode = currentNode.parentNode;\n }\n }\n\n return null;\n} // Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\n\n\nexport default function getOffsetParent(element) {\n var window = getWindow(element);\n var offsetParent = getTrueOffsetParent(element);\n\n while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {\n offsetParent = getTrueOffsetParent(offsetParent);\n }\n\n if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {\n return window;\n }\n\n return offsetParent || getContainingBlock(element) || window;\n}","export var top = 'top';\nexport var bottom = 'bottom';\nexport var right = 'right';\nexport var left = 'left';\nexport var auto = 'auto';\nexport var basePlacements = [top, bottom, right, left];\nexport var start = 'start';\nexport var end = 'end';\nexport var clippingParents = 'clippingParents';\nexport var viewport = 'viewport';\nexport var popper = 'popper';\nexport var reference = 'reference';\nexport var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {\n return acc.concat([placement + \"-\" + start, placement + \"-\" + end]);\n}, []);\nexport var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {\n return acc.concat([placement, placement + \"-\" + start, placement + \"-\" + end]);\n}, []); // modifiers that need to read the DOM\n\nexport var beforeRead = 'beforeRead';\nexport var read = 'read';\nexport var afterRead = 'afterRead'; // pure-logic modifiers\n\nexport var beforeMain = 'beforeMain';\nexport var main = 'main';\nexport var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)\n\nexport var beforeWrite = 'beforeWrite';\nexport var write = 'write';\nexport var afterWrite = 'afterWrite';\nexport var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];","import { modifierPhases } from \"../enums.js\"; // source: https://stackoverflow.com/questions/49875255\n\nfunction order(modifiers) {\n var map = new Map();\n var visited = new Set();\n var result = [];\n modifiers.forEach(function (modifier) {\n map.set(modifier.name, modifier);\n }); // On visiting object, check for its dependencies and visit them recursively\n\n function sort(modifier) {\n visited.add(modifier.name);\n var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);\n requires.forEach(function (dep) {\n if (!visited.has(dep)) {\n var depModifier = map.get(dep);\n\n if (depModifier) {\n sort(depModifier);\n }\n }\n });\n result.push(modifier);\n }\n\n modifiers.forEach(function (modifier) {\n if (!visited.has(modifier.name)) {\n // check for visited object\n sort(modifier);\n }\n });\n return result;\n}\n\nexport default function orderModifiers(modifiers) {\n // order based on dependencies\n var orderedModifiers = order(modifiers); // order based on phase\n\n return modifierPhases.reduce(function (acc, phase) {\n return acc.concat(orderedModifiers.filter(function (modifier) {\n return modifier.phase === phase;\n }));\n }, []);\n}","import getCompositeRect from \"./dom-utils/getCompositeRect.js\";\nimport getLayoutRect from \"./dom-utils/getLayoutRect.js\";\nimport listScrollParents from \"./dom-utils/listScrollParents.js\";\nimport getOffsetParent from \"./dom-utils/getOffsetParent.js\";\nimport getComputedStyle from \"./dom-utils/getComputedStyle.js\";\nimport orderModifiers from \"./utils/orderModifiers.js\";\nimport debounce from \"./utils/debounce.js\";\nimport validateModifiers from \"./utils/validateModifiers.js\";\nimport uniqueBy from \"./utils/uniqueBy.js\";\nimport getBasePlacement from \"./utils/getBasePlacement.js\";\nimport mergeByName from \"./utils/mergeByName.js\";\nimport detectOverflow from \"./utils/detectOverflow.js\";\nimport { isElement } from \"./dom-utils/instanceOf.js\";\nimport { auto } from \"./enums.js\";\nvar INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';\nvar INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';\nvar DEFAULT_OPTIONS = {\n placement: 'bottom',\n modifiers: [],\n strategy: 'absolute'\n};\n\nfunction areValidElements() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return !args.some(function (element) {\n return !(element && typeof element.getBoundingClientRect === 'function');\n });\n}\n\nexport function popperGenerator(generatorOptions) {\n if (generatorOptions === void 0) {\n generatorOptions = {};\n }\n\n var _generatorOptions = generatorOptions,\n _generatorOptions$def = _generatorOptions.defaultModifiers,\n defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,\n _generatorOptions$def2 = _generatorOptions.defaultOptions,\n defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;\n return function createPopper(reference, popper, options) {\n if (options === void 0) {\n options = defaultOptions;\n }\n\n var state = {\n placement: 'bottom',\n orderedModifiers: [],\n options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),\n modifiersData: {},\n elements: {\n reference: reference,\n popper: popper\n },\n attributes: {},\n styles: {}\n };\n var effectCleanupFns = [];\n var isDestroyed = false;\n var instance = {\n state: state,\n setOptions: function setOptions(options) {\n cleanupModifierEffects();\n state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);\n state.scrollParents = {\n reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],\n popper: listScrollParents(popper)\n }; // Orders the modifiers based on their dependencies and `phase`\n // properties\n\n var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers\n\n state.orderedModifiers = orderedModifiers.filter(function (m) {\n return m.enabled;\n }); // Validate the provided modifiers so that the consumer will get warned\n // if one of the modifiers is invalid for any reason\n\n if (process.env.NODE_ENV !== \"production\") {\n var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {\n var name = _ref.name;\n return name;\n });\n validateModifiers(modifiers);\n\n if (getBasePlacement(state.options.placement) === auto) {\n var flipModifier = state.orderedModifiers.find(function (_ref2) {\n var name = _ref2.name;\n return name === 'flip';\n });\n\n if (!flipModifier) {\n console.error(['Popper: \"auto\" placements require the \"flip\" modifier be', 'present and enabled to work.'].join(' '));\n }\n }\n\n var _getComputedStyle = getComputedStyle(popper),\n marginTop = _getComputedStyle.marginTop,\n marginRight = _getComputedStyle.marginRight,\n marginBottom = _getComputedStyle.marginBottom,\n marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can\n // cause bugs with positioning, so we'll warn the consumer\n\n\n if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {\n return parseFloat(margin);\n })) {\n console.warn(['Popper: CSS \"margin\" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));\n }\n }\n\n runModifierEffects();\n return instance.update();\n },\n // Sync update – it will always be executed, even if not necessary. This\n // is useful for low frequency updates where sync behavior simplifies the\n // logic.\n // For high frequency updates (e.g. `resize` and `scroll` events), always\n // prefer the async Popper#update method\n forceUpdate: function forceUpdate() {\n if (isDestroyed) {\n return;\n }\n\n var _state$elements = state.elements,\n reference = _state$elements.reference,\n popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements\n // anymore\n\n if (!areValidElements(reference, popper)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(INVALID_ELEMENT_ERROR);\n }\n\n return;\n } // Store the reference and popper rects to be read by modifiers\n\n\n state.rects = {\n reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),\n popper: getLayoutRect(popper)\n }; // Modifiers have the ability to reset the current update cycle. The\n // most common use case for this is the `flip` modifier changing the\n // placement, which then needs to re-run all the modifiers, because the\n // logic was previously ran for the previous placement and is therefore\n // stale/incorrect\n\n state.reset = false;\n state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier\n // is filled with the initial data specified by the modifier. This means\n // it doesn't persist and is fresh on each update.\n // To ensure persistent data, use `${name}#persistent`\n\n state.orderedModifiers.forEach(function (modifier) {\n return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);\n });\n var __debug_loops__ = 0;\n\n for (var index = 0; index < state.orderedModifiers.length; index++) {\n if (process.env.NODE_ENV !== \"production\") {\n __debug_loops__ += 1;\n\n if (__debug_loops__ > 100) {\n console.error(INFINITE_LOOP_ERROR);\n break;\n }\n }\n\n if (state.reset === true) {\n state.reset = false;\n index = -1;\n continue;\n }\n\n var _state$orderedModifie = state.orderedModifiers[index],\n fn = _state$orderedModifie.fn,\n _state$orderedModifie2 = _state$orderedModifie.options,\n _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,\n name = _state$orderedModifie.name;\n\n if (typeof fn === 'function') {\n state = fn({\n state: state,\n options: _options,\n name: name,\n instance: instance\n }) || state;\n }\n }\n },\n // Async and optimistically optimized update – it will not be executed if\n // not necessary (debounced to run at most once-per-tick)\n update: debounce(function () {\n return new Promise(function (resolve) {\n instance.forceUpdate();\n resolve(state);\n });\n }),\n destroy: function destroy() {\n cleanupModifierEffects();\n isDestroyed = true;\n }\n };\n\n if (!areValidElements(reference, popper)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(INVALID_ELEMENT_ERROR);\n }\n\n return instance;\n }\n\n instance.setOptions(options).then(function (state) {\n if (!isDestroyed && options.onFirstUpdate) {\n options.onFirstUpdate(state);\n }\n }); // Modifiers have the ability to execute arbitrary code before the first\n // update cycle runs. They will be executed in the same order as the update\n // cycle. This is useful when a modifier adds some persistent data that\n // other modifiers need to use, but the modifier is run after the dependent\n // one.\n\n function runModifierEffects() {\n state.orderedModifiers.forEach(function (_ref3) {\n var name = _ref3.name,\n _ref3$options = _ref3.options,\n options = _ref3$options === void 0 ? {} : _ref3$options,\n effect = _ref3.effect;\n\n if (typeof effect === 'function') {\n var cleanupFn = effect({\n state: state,\n name: name,\n instance: instance,\n options: options\n });\n\n var noopFn = function noopFn() {};\n\n effectCleanupFns.push(cleanupFn || noopFn);\n }\n });\n }\n\n function cleanupModifierEffects() {\n effectCleanupFns.forEach(function (fn) {\n return fn();\n });\n effectCleanupFns = [];\n }\n\n return instance;\n };\n}\nexport var createPopper = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules\n\nexport { detectOverflow };","export default function debounce(fn) {\n var pending;\n return function () {\n if (!pending) {\n pending = new Promise(function (resolve) {\n Promise.resolve().then(function () {\n pending = undefined;\n resolve(fn());\n });\n });\n }\n\n return pending;\n };\n}","export default function mergeByName(modifiers) {\n var merged = modifiers.reduce(function (merged, current) {\n var existing = merged[current.name];\n merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {\n options: Object.assign(Object.assign({}, existing.options), current.options),\n data: Object.assign(Object.assign({}, existing.data), current.data)\n }) : current;\n return merged;\n }, {}); // IE11 does not support Object.values\n\n return Object.keys(merged).map(function (key) {\n return merged[key];\n });\n}","import getWindow from \"../dom-utils/getWindow.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar passive = {\n passive: true\n};\n\nfunction effect(_ref) {\n var state = _ref.state,\n instance = _ref.instance,\n options = _ref.options;\n var _options$scroll = options.scroll,\n scroll = _options$scroll === void 0 ? true : _options$scroll,\n _options$resize = options.resize,\n resize = _options$resize === void 0 ? true : _options$resize;\n var window = getWindow(state.elements.popper);\n var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);\n\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.addEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.addEventListener('resize', instance.update, passive);\n }\n\n return function () {\n if (scroll) {\n scrollParents.forEach(function (scrollParent) {\n scrollParent.removeEventListener('scroll', instance.update, passive);\n });\n }\n\n if (resize) {\n window.removeEventListener('resize', instance.update, passive);\n }\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'eventListeners',\n enabled: true,\n phase: 'write',\n fn: function fn() {},\n effect: effect,\n data: {}\n};","import { auto } from \"../enums.js\";\nexport default function getBasePlacement(placement) {\n return placement.split('-')[0];\n}","export default function getVariation(placement) {\n return placement.split('-')[1];\n}","export default function getMainAxisFromPlacement(placement) {\n return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';\n}","import getBasePlacement from \"./getBasePlacement.js\";\nimport getVariation from \"./getVariation.js\";\nimport getMainAxisFromPlacement from \"./getMainAxisFromPlacement.js\";\nimport { top, right, bottom, left, start, end } from \"../enums.js\";\nexport default function computeOffsets(_ref) {\n var reference = _ref.reference,\n element = _ref.element,\n placement = _ref.placement;\n var basePlacement = placement ? getBasePlacement(placement) : null;\n var variation = placement ? getVariation(placement) : null;\n var commonX = reference.x + reference.width / 2 - element.width / 2;\n var commonY = reference.y + reference.height / 2 - element.height / 2;\n var offsets;\n\n switch (basePlacement) {\n case top:\n offsets = {\n x: commonX,\n y: reference.y - element.height\n };\n break;\n\n case bottom:\n offsets = {\n x: commonX,\n y: reference.y + reference.height\n };\n break;\n\n case right:\n offsets = {\n x: reference.x + reference.width,\n y: commonY\n };\n break;\n\n case left:\n offsets = {\n x: reference.x - element.width,\n y: commonY\n };\n break;\n\n default:\n offsets = {\n x: reference.x,\n y: reference.y\n };\n }\n\n var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;\n\n if (mainAxis != null) {\n var len = mainAxis === 'y' ? 'height' : 'width';\n\n switch (variation) {\n case start:\n offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);\n break;\n\n case end:\n offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);\n break;\n\n default:\n }\n }\n\n return offsets;\n}","import computeOffsets from \"../utils/computeOffsets.js\";\n\nfunction popperOffsets(_ref) {\n var state = _ref.state,\n name = _ref.name; // Offsets are the actual position the popper needs to have to be\n // properly positioned near its reference element\n // This is the most basic placement, and will be adjusted by\n // the modifiers in the next step\n\n state.modifiersData[name] = computeOffsets({\n reference: state.rects.reference,\n element: state.rects.popper,\n strategy: 'absolute',\n placement: state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'popperOffsets',\n enabled: true,\n phase: 'read',\n fn: popperOffsets,\n data: {}\n};","import { top, left, right, bottom } from \"../enums.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getWindow from \"../dom-utils/getWindow.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport getComputedStyle from \"../dom-utils/getComputedStyle.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\"; // eslint-disable-next-line import/no-unused-modules\n\nvar unsetSides = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto'\n}; // Round the offsets to the nearest suitable subpixel based on the DPR.\n// Zooming can change the DPR, but it seems to report a value that will\n// cleanly divide the values into the appropriate subpixels.\n\nfunction roundOffsets(_ref) {\n var x = _ref.x,\n y = _ref.y;\n var win = window;\n var dpr = win.devicePixelRatio || 1;\n return {\n x: Math.round(x * dpr) / dpr || 0,\n y: Math.round(y * dpr) / dpr || 0\n };\n}\n\nexport function mapToStyles(_ref2) {\n var _Object$assign2;\n\n var popper = _ref2.popper,\n popperRect = _ref2.popperRect,\n placement = _ref2.placement,\n offsets = _ref2.offsets,\n position = _ref2.position,\n gpuAcceleration = _ref2.gpuAcceleration,\n adaptive = _ref2.adaptive;\n\n var _roundOffsets = roundOffsets(offsets),\n x = _roundOffsets.x,\n y = _roundOffsets.y;\n\n var hasX = offsets.hasOwnProperty('x');\n var hasY = offsets.hasOwnProperty('y');\n var sideX = left;\n var sideY = top;\n var win = window;\n\n if (adaptive) {\n var offsetParent = getOffsetParent(popper);\n\n if (offsetParent === getWindow(popper)) {\n offsetParent = getDocumentElement(popper);\n } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it\n\n /*:: offsetParent = (offsetParent: Element); */\n\n\n if (placement === top) {\n sideY = bottom;\n y -= offsetParent.clientHeight - popperRect.height;\n y *= gpuAcceleration ? 1 : -1;\n }\n\n if (placement === left) {\n sideX = right;\n x -= offsetParent.clientWidth - popperRect.width;\n x *= gpuAcceleration ? 1 : -1;\n }\n }\n\n var commonStyles = Object.assign({\n position: position\n }, adaptive && unsetSides);\n\n if (gpuAcceleration) {\n var _Object$assign;\n\n return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? \"translate(\" + x + \"px, \" + y + \"px)\" : \"translate3d(\" + x + \"px, \" + y + \"px, 0)\", _Object$assign));\n }\n\n return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + \"px\" : '', _Object$assign2[sideX] = hasX ? x + \"px\" : '', _Object$assign2.transform = '', _Object$assign2));\n}\n\nfunction computeStyles(_ref3) {\n var state = _ref3.state,\n options = _ref3.options;\n var _options$gpuAccelerat = options.gpuAcceleration,\n gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,\n _options$adaptive = options.adaptive,\n adaptive = _options$adaptive === void 0 ? true : _options$adaptive;\n\n if (process.env.NODE_ENV !== \"production\") {\n var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';\n\n if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {\n return transitionProperty.indexOf(property) >= 0;\n })) {\n console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: \"transform\", \"top\", \"right\", \"bottom\", \"left\".', '\\n\\n', 'Disable the \"computeStyles\" modifier\\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\\n\\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));\n }\n }\n\n var commonStyles = {\n placement: getBasePlacement(state.placement),\n popper: state.elements.popper,\n popperRect: state.rects.popper,\n gpuAcceleration: gpuAcceleration\n };\n\n if (state.modifiersData.popperOffsets != null) {\n state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {\n offsets: state.modifiersData.popperOffsets,\n position: state.options.strategy,\n adaptive: adaptive\n })));\n }\n\n if (state.modifiersData.arrow != null) {\n state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {\n offsets: state.modifiersData.arrow,\n position: 'absolute',\n adaptive: false\n })));\n }\n\n state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {\n 'data-popper-placement': state.placement\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'computeStyles',\n enabled: true,\n phase: 'beforeWrite',\n fn: computeStyles,\n data: {}\n};","import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport { top, left, right, placements } from \"../enums.js\";\nexport function distanceAndSkiddingToXY(placement, rects, offset) {\n var basePlacement = getBasePlacement(placement);\n var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;\n\n var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {\n placement: placement\n })) : offset,\n skidding = _ref[0],\n distance = _ref[1];\n\n skidding = skidding || 0;\n distance = (distance || 0) * invertDistance;\n return [left, right].indexOf(basePlacement) >= 0 ? {\n x: distance,\n y: skidding\n } : {\n x: skidding,\n y: distance\n };\n}\n\nfunction offset(_ref2) {\n var state = _ref2.state,\n options = _ref2.options,\n name = _ref2.name;\n var _options$offset = options.offset,\n offset = _options$offset === void 0 ? [0, 0] : _options$offset;\n var data = placements.reduce(function (acc, placement) {\n acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);\n return acc;\n }, {});\n var _data$state$placement = data[state.placement],\n x = _data$state$placement.x,\n y = _data$state$placement.y;\n\n if (state.modifiersData.popperOffsets != null) {\n state.modifiersData.popperOffsets.x += x;\n state.modifiersData.popperOffsets.y += y;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'offset',\n enabled: true,\n phase: 'main',\n requires: ['popperOffsets'],\n fn: offset\n};","var hash = {\n left: 'right',\n right: 'left',\n bottom: 'top',\n top: 'bottom'\n};\nexport default function getOppositePlacement(placement) {\n return placement.replace(/left|right|bottom|top/g, function (matched) {\n return hash[matched];\n });\n}","var hash = {\n start: 'end',\n end: 'start'\n};\nexport default function getOppositeVariationPlacement(placement) {\n return placement.replace(/start|end/g, function (matched) {\n return hash[matched];\n });\n}","import { isShadowRoot } from \"./instanceOf.js\";\nexport default function contains(parent, child) {\n var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method\n\n if (parent.contains(child)) {\n return true;\n } // then fallback to custom implementation with Shadow DOM support\n else if (isShadowRoot(rootNode)) {\n var next = child;\n\n do {\n if (next && parent.isSameNode(next)) {\n return true;\n } // $FlowFixMe: need a better way to handle this...\n\n\n next = next.parentNode || next.host;\n } while (next);\n } // Give up, the result is false\n\n\n return false;\n}","export default function rectToClientRect(rect) {\n return Object.assign(Object.assign({}, rect), {}, {\n left: rect.x,\n top: rect.y,\n right: rect.x + rect.width,\n bottom: rect.y + rect.height\n });\n}","import { viewport } from \"../enums.js\";\nimport getViewportRect from \"./getViewportRect.js\";\nimport getDocumentRect from \"./getDocumentRect.js\";\nimport listScrollParents from \"./listScrollParents.js\";\nimport getOffsetParent from \"./getOffsetParent.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport { isElement, isHTMLElement } from \"./instanceOf.js\";\nimport getBoundingClientRect from \"./getBoundingClientRect.js\";\nimport getParentNode from \"./getParentNode.js\";\nimport contains from \"./contains.js\";\nimport getNodeName from \"./getNodeName.js\";\nimport rectToClientRect from \"../utils/rectToClientRect.js\";\n\nfunction getInnerBoundingClientRect(element) {\n var rect = getBoundingClientRect(element);\n rect.top = rect.top + element.clientTop;\n rect.left = rect.left + element.clientLeft;\n rect.bottom = rect.top + element.clientHeight;\n rect.right = rect.left + element.clientWidth;\n rect.width = element.clientWidth;\n rect.height = element.clientHeight;\n rect.x = rect.left;\n rect.y = rect.top;\n return rect;\n}\n\nfunction getClientRectFromMixedType(element, clippingParent) {\n return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));\n} // A \"clipping parent\" is an overflowable container with the characteristic of\n// clipping (or hiding) overflowing elements with a position different from\n// `initial`\n\n\nfunction getClippingParents(element) {\n var clippingParents = listScrollParents(getParentNode(element));\n var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;\n var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;\n\n if (!isElement(clipperElement)) {\n return [];\n } // $FlowFixMe: https://github.com/facebook/flow/issues/1414\n\n\n return clippingParents.filter(function (clippingParent) {\n return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';\n });\n} // Gets the maximum area that the element is visible in due to any number of\n// clipping parents\n\n\nexport default function getClippingRect(element, boundary, rootBoundary) {\n var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);\n var clippingParents = [].concat(mainClippingParents, [rootBoundary]);\n var firstClippingParent = clippingParents[0];\n var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {\n var rect = getClientRectFromMixedType(element, clippingParent);\n accRect.top = Math.max(rect.top, accRect.top);\n accRect.right = Math.min(rect.right, accRect.right);\n accRect.bottom = Math.min(rect.bottom, accRect.bottom);\n accRect.left = Math.max(rect.left, accRect.left);\n return accRect;\n }, getClientRectFromMixedType(element, firstClippingParent));\n clippingRect.width = clippingRect.right - clippingRect.left;\n clippingRect.height = clippingRect.bottom - clippingRect.top;\n clippingRect.x = clippingRect.left;\n clippingRect.y = clippingRect.top;\n return clippingRect;\n}","import getWindow from \"./getWindow.js\";\nimport getDocumentElement from \"./getDocumentElement.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nexport default function getViewportRect(element) {\n var win = getWindow(element);\n var html = getDocumentElement(element);\n var visualViewport = win.visualViewport;\n var width = html.clientWidth;\n var height = html.clientHeight;\n var x = 0;\n var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper\n // can be obscured underneath it.\n // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even\n // if it isn't open, so if this isn't available, the popper will be detected\n // to overflow the bottom of the screen too early.\n\n if (visualViewport) {\n width = visualViewport.width;\n height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)\n // In Chrome, it returns a value very close to 0 (+/-) but contains rounding\n // errors due to floating point numbers, so we need to check precision.\n // Safari returns a number <= 0, usually < -1 when pinch-zoomed\n // Feature detection fails in mobile emulation mode in Chrome.\n // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <\n // 0.001\n // Fallback here: \"Not Safari\" userAgent\n\n if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n x = visualViewport.offsetLeft;\n y = visualViewport.offsetTop;\n }\n }\n\n return {\n width: width,\n height: height,\n x: x + getWindowScrollBarX(element),\n y: y\n };\n}","import getDocumentElement from \"./getDocumentElement.js\";\nimport getComputedStyle from \"./getComputedStyle.js\";\nimport getWindowScrollBarX from \"./getWindowScrollBarX.js\";\nimport getWindowScroll from \"./getWindowScroll.js\"; // Gets the entire size of the scrollable document area, even extending outside\n// of the `` and `` rect bounds if horizontally scrollable\n\nexport default function getDocumentRect(element) {\n var html = getDocumentElement(element);\n var winScroll = getWindowScroll(element);\n var body = element.ownerDocument.body;\n var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);\n var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);\n var x = -winScroll.scrollLeft + getWindowScrollBarX(element);\n var y = -winScroll.scrollTop;\n\n if (getComputedStyle(body || html).direction === 'rtl') {\n x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;\n }\n\n return {\n width: width,\n height: height,\n x: x,\n y: y\n };\n}","import getFreshSideObject from \"./getFreshSideObject.js\";\nexport default function mergePaddingObject(paddingObject) {\n return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);\n}","export default function getFreshSideObject() {\n return {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n };\n}","export default function expandToHashMap(value, keys) {\n return keys.reduce(function (hashMap, key) {\n hashMap[key] = value;\n return hashMap;\n }, {});\n}","import getBoundingClientRect from \"../dom-utils/getBoundingClientRect.js\";\nimport getClippingRect from \"../dom-utils/getClippingRect.js\";\nimport getDocumentElement from \"../dom-utils/getDocumentElement.js\";\nimport computeOffsets from \"./computeOffsets.js\";\nimport rectToClientRect from \"./rectToClientRect.js\";\nimport { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from \"../enums.js\";\nimport { isElement } from \"../dom-utils/instanceOf.js\";\nimport mergePaddingObject from \"./mergePaddingObject.js\";\nimport expandToHashMap from \"./expandToHashMap.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport default function detectOverflow(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n _options$placement = _options.placement,\n placement = _options$placement === void 0 ? state.placement : _options$placement,\n _options$boundary = _options.boundary,\n boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,\n _options$rootBoundary = _options.rootBoundary,\n rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,\n _options$elementConte = _options.elementContext,\n elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,\n _options$altBoundary = _options.altBoundary,\n altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,\n _options$padding = _options.padding,\n padding = _options$padding === void 0 ? 0 : _options$padding;\n var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));\n var altContext = elementContext === popper ? reference : popper;\n var referenceElement = state.elements.reference;\n var popperRect = state.rects.popper;\n var element = state.elements[altBoundary ? altContext : elementContext];\n var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);\n var referenceClientRect = getBoundingClientRect(referenceElement);\n var popperOffsets = computeOffsets({\n reference: referenceClientRect,\n element: popperRect,\n strategy: 'absolute',\n placement: placement\n });\n var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));\n var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect\n // 0 or negative = within the clipping rect\n\n var overflowOffsets = {\n top: clippingClientRect.top - elementClientRect.top + paddingObject.top,\n bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,\n left: clippingClientRect.left - elementClientRect.left + paddingObject.left,\n right: elementClientRect.right - clippingClientRect.right + paddingObject.right\n };\n var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element\n\n if (elementContext === popper && offsetData) {\n var offset = offsetData[placement];\n Object.keys(overflowOffsets).forEach(function (key) {\n var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;\n var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';\n overflowOffsets[key] += offset[axis] * multiply;\n });\n }\n\n return overflowOffsets;\n}","export default function within(min, value, max) {\n return Math.max(min, Math.min(value, max));\n}","import { top, bottom, left, right } from \"../enums.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\n\nfunction getSideOffsets(overflow, rect, preventedOffsets) {\n if (preventedOffsets === void 0) {\n preventedOffsets = {\n x: 0,\n y: 0\n };\n }\n\n return {\n top: overflow.top - rect.height - preventedOffsets.y,\n right: overflow.right - rect.width + preventedOffsets.x,\n bottom: overflow.bottom - rect.height + preventedOffsets.y,\n left: overflow.left - rect.width - preventedOffsets.x\n };\n}\n\nfunction isAnySideFullyClipped(overflow) {\n return [top, right, bottom, left].some(function (side) {\n return overflow[side] >= 0;\n });\n}\n\nfunction hide(_ref) {\n var state = _ref.state,\n name = _ref.name;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var preventedOffsets = state.modifiersData.preventOverflow;\n var referenceOverflow = detectOverflow(state, {\n elementContext: 'reference'\n });\n var popperAltOverflow = detectOverflow(state, {\n altBoundary: true\n });\n var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);\n var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);\n var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);\n var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);\n state.modifiersData[name] = {\n referenceClippingOffsets: referenceClippingOffsets,\n popperEscapeOffsets: popperEscapeOffsets,\n isReferenceHidden: isReferenceHidden,\n hasPopperEscaped: hasPopperEscaped\n };\n state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {\n 'data-popper-reference-hidden': isReferenceHidden,\n 'data-popper-escaped': hasPopperEscaped\n });\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'hide',\n enabled: true,\n phase: 'main',\n requiresIfExists: ['preventOverflow'],\n fn: hide\n};","import { popperGenerator, detectOverflow } from \"./createPopper.js\";\nimport eventListeners from \"./modifiers/eventListeners.js\";\nimport popperOffsets from \"./modifiers/popperOffsets.js\";\nimport computeStyles from \"./modifiers/computeStyles.js\";\nimport applyStyles from \"./modifiers/applyStyles.js\";\nimport offset from \"./modifiers/offset.js\";\nimport flip from \"./modifiers/flip.js\";\nimport preventOverflow from \"./modifiers/preventOverflow.js\";\nimport arrow from \"./modifiers/arrow.js\";\nimport hide from \"./modifiers/hide.js\";\nvar defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles, offset, flip, preventOverflow, arrow, hide];\nvar createPopper = /*#__PURE__*/popperGenerator({\n defaultModifiers: defaultModifiers\n}); // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper, popperGenerator, defaultModifiers, detectOverflow }; // eslint-disable-next-line import/no-unused-modules\n\nexport { createPopper as createPopperLite } from \"./popper-lite.js\"; // eslint-disable-next-line import/no-unused-modules\n\nexport * from \"./modifiers/index.js\";","import getNodeName from \"../dom-utils/getNodeName.js\";\nimport { isHTMLElement } from \"../dom-utils/instanceOf.js\"; // This modifier takes the styles prepared by the `computeStyles` modifier\n// and applies them to the HTMLElements such as popper and arrow\n\nfunction applyStyles(_ref) {\n var state = _ref.state;\n Object.keys(state.elements).forEach(function (name) {\n var style = state.styles[name] || {};\n var attributes = state.attributes[name] || {};\n var element = state.elements[name]; // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n } // Flow doesn't support to extend this property, but it's the most\n // effective way to apply styles to an HTMLElement\n // $FlowFixMe\n\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (name) {\n var value = attributes[name];\n\n if (value === false) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value === true ? '' : value);\n }\n });\n });\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state;\n var initialStyles = {\n popper: {\n position: state.options.strategy,\n left: '0',\n top: '0',\n margin: '0'\n },\n arrow: {\n position: 'absolute'\n },\n reference: {}\n };\n Object.assign(state.elements.popper.style, initialStyles.popper);\n\n if (state.elements.arrow) {\n Object.assign(state.elements.arrow.style, initialStyles.arrow);\n }\n\n return function () {\n Object.keys(state.elements).forEach(function (name) {\n var element = state.elements[name];\n var attributes = state.attributes[name] || {};\n var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them\n\n var style = styleProperties.reduce(function (style, property) {\n style[property] = '';\n return style;\n }, {}); // arrow is optional + virtual elements\n\n if (!isHTMLElement(element) || !getNodeName(element)) {\n return;\n } // Flow doesn't support to extend this property, but it's the most\n // effective way to apply styles to an HTMLElement\n // $FlowFixMe\n\n\n Object.assign(element.style, style);\n Object.keys(attributes).forEach(function (attribute) {\n element.removeAttribute(attribute);\n });\n });\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'applyStyles',\n enabled: true,\n phase: 'write',\n fn: applyStyles,\n effect: effect,\n requires: ['computeStyles']\n};","import getOppositePlacement from \"../utils/getOppositePlacement.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getOppositeVariationPlacement from \"../utils/getOppositeVariationPlacement.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport computeAutoPlacement from \"../utils/computeAutoPlacement.js\";\nimport { bottom, top, start, right, left, auto } from \"../enums.js\";\nimport getVariation from \"../utils/getVariation.js\"; // eslint-disable-next-line import/no-unused-modules\n\nfunction getExpandedFallbackPlacements(placement) {\n if (getBasePlacement(placement) === auto) {\n return [];\n }\n\n var oppositePlacement = getOppositePlacement(placement);\n return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];\n}\n\nfunction flip(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n\n if (state.modifiersData[name]._skip) {\n return;\n }\n\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,\n specifiedFallbackPlacements = options.fallbackPlacements,\n padding = options.padding,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n _options$flipVariatio = options.flipVariations,\n flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,\n allowedAutoPlacements = options.allowedAutoPlacements;\n var preferredPlacement = state.options.placement;\n var basePlacement = getBasePlacement(preferredPlacement);\n var isBasePlacement = basePlacement === preferredPlacement;\n var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));\n var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {\n return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n flipVariations: flipVariations,\n allowedAutoPlacements: allowedAutoPlacements\n }) : placement);\n }, []);\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var checksMap = new Map();\n var makeFallbackChecks = true;\n var firstFittingPlacement = placements[0];\n\n for (var i = 0; i < placements.length; i++) {\n var placement = placements[i];\n\n var _basePlacement = getBasePlacement(placement);\n\n var isStartVariation = getVariation(placement) === start;\n var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;\n var len = isVertical ? 'width' : 'height';\n var overflow = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n altBoundary: altBoundary,\n padding: padding\n });\n var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;\n\n if (referenceRect[len] > popperRect[len]) {\n mainVariationSide = getOppositePlacement(mainVariationSide);\n }\n\n var altVariationSide = getOppositePlacement(mainVariationSide);\n var checks = [];\n\n if (checkMainAxis) {\n checks.push(overflow[_basePlacement] <= 0);\n }\n\n if (checkAltAxis) {\n checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);\n }\n\n if (checks.every(function (check) {\n return check;\n })) {\n firstFittingPlacement = placement;\n makeFallbackChecks = false;\n break;\n }\n\n checksMap.set(placement, checks);\n }\n\n if (makeFallbackChecks) {\n // `2` may be desired in some cases – research later\n var numberOfChecks = flipVariations ? 3 : 1;\n\n var _loop = function _loop(_i) {\n var fittingPlacement = placements.find(function (placement) {\n var checks = checksMap.get(placement);\n\n if (checks) {\n return checks.slice(0, _i).every(function (check) {\n return check;\n });\n }\n });\n\n if (fittingPlacement) {\n firstFittingPlacement = fittingPlacement;\n return \"break\";\n }\n };\n\n for (var _i = numberOfChecks; _i > 0; _i--) {\n var _ret = _loop(_i);\n\n if (_ret === \"break\") break;\n }\n }\n\n if (state.placement !== firstFittingPlacement) {\n state.modifiersData[name]._skip = true;\n state.placement = firstFittingPlacement;\n state.reset = true;\n }\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'flip',\n enabled: true,\n phase: 'main',\n fn: flip,\n requiresIfExists: ['offset'],\n data: {\n _skip: false\n }\n};","import getVariation from \"./getVariation.js\";\nimport { variationPlacements, basePlacements, placements as allPlacements } from \"../enums.js\";\nimport detectOverflow from \"./detectOverflow.js\";\nimport getBasePlacement from \"./getBasePlacement.js\";\n/*:: type OverflowsMap = { [ComputedPlacement]: number }; */\n\n/*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */\n\nexport default function computeAutoPlacement(state, options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n placement = _options.placement,\n boundary = _options.boundary,\n rootBoundary = _options.rootBoundary,\n padding = _options.padding,\n flipVariations = _options.flipVariations,\n _options$allowedAutoP = _options.allowedAutoPlacements,\n allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;\n var variation = getVariation(placement);\n var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {\n return getVariation(placement) === variation;\n }) : basePlacements; // $FlowFixMe\n\n var allowedPlacements = placements.filter(function (placement) {\n return allowedAutoPlacements.indexOf(placement) >= 0;\n });\n\n if (allowedPlacements.length === 0) {\n allowedPlacements = placements;\n\n if (process.env.NODE_ENV !== \"production\") {\n console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, \"auto\" cannot be used to allow \"bottom-start\".', 'Use \"auto-start\" instead.'].join(' '));\n }\n } // $FlowFixMe: Flow seems to have problems with two array unions...\n\n\n var overflows = allowedPlacements.reduce(function (acc, placement) {\n acc[placement] = detectOverflow(state, {\n placement: placement,\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding\n })[getBasePlacement(placement)];\n return acc;\n }, {});\n return Object.keys(overflows).sort(function (a, b) {\n return overflows[a] - overflows[b];\n });\n}","import { top, left, right, bottom, start } from \"../enums.js\";\nimport getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport getAltAxis from \"../utils/getAltAxis.js\";\nimport within from \"../utils/within.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport detectOverflow from \"../utils/detectOverflow.js\";\nimport getVariation from \"../utils/getVariation.js\";\nimport getFreshSideObject from \"../utils/getFreshSideObject.js\";\n\nfunction preventOverflow(_ref) {\n var state = _ref.state,\n options = _ref.options,\n name = _ref.name;\n var _options$mainAxis = options.mainAxis,\n checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,\n _options$altAxis = options.altAxis,\n checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,\n boundary = options.boundary,\n rootBoundary = options.rootBoundary,\n altBoundary = options.altBoundary,\n padding = options.padding,\n _options$tether = options.tether,\n tether = _options$tether === void 0 ? true : _options$tether,\n _options$tetherOffset = options.tetherOffset,\n tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;\n var overflow = detectOverflow(state, {\n boundary: boundary,\n rootBoundary: rootBoundary,\n padding: padding,\n altBoundary: altBoundary\n });\n var basePlacement = getBasePlacement(state.placement);\n var variation = getVariation(state.placement);\n var isBasePlacement = !variation;\n var mainAxis = getMainAxisFromPlacement(basePlacement);\n var altAxis = getAltAxis(mainAxis);\n var popperOffsets = state.modifiersData.popperOffsets;\n var referenceRect = state.rects.reference;\n var popperRect = state.rects.popper;\n var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {\n placement: state.placement\n })) : tetherOffset;\n var data = {\n x: 0,\n y: 0\n };\n\n if (!popperOffsets) {\n return;\n }\n\n if (checkMainAxis) {\n var mainSide = mainAxis === 'y' ? top : left;\n var altSide = mainAxis === 'y' ? bottom : right;\n var len = mainAxis === 'y' ? 'height' : 'width';\n var offset = popperOffsets[mainAxis];\n var min = popperOffsets[mainAxis] + overflow[mainSide];\n var max = popperOffsets[mainAxis] - overflow[altSide];\n var additive = tether ? -popperRect[len] / 2 : 0;\n var minLen = variation === start ? referenceRect[len] : popperRect[len];\n var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go\n // outside the reference bounds\n\n var arrowElement = state.elements.arrow;\n var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {\n width: 0,\n height: 0\n };\n var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();\n var arrowPaddingMin = arrowPaddingObject[mainSide];\n var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want\n // to include its full size in the calculation. If the reference is small\n // and near the edge of a boundary, the popper can overflow even if the\n // reference is not overflowing as well (e.g. virtual elements with no\n // width or height)\n\n var arrowLen = within(0, referenceRect[len], arrowRect[len]);\n var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;\n var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;\n var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);\n var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;\n var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;\n var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;\n var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;\n var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);\n popperOffsets[mainAxis] = preventedOffset;\n data[mainAxis] = preventedOffset - offset;\n }\n\n if (checkAltAxis) {\n var _mainSide = mainAxis === 'x' ? top : left;\n\n var _altSide = mainAxis === 'x' ? bottom : right;\n\n var _offset = popperOffsets[altAxis];\n\n var _min = _offset + overflow[_mainSide];\n\n var _max = _offset - overflow[_altSide];\n\n var _preventedOffset = within(_min, _offset, _max);\n\n popperOffsets[altAxis] = _preventedOffset;\n data[altAxis] = _preventedOffset - _offset;\n }\n\n state.modifiersData[name] = data;\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'preventOverflow',\n enabled: true,\n phase: 'main',\n fn: preventOverflow,\n requiresIfExists: ['offset']\n};","export default function getAltAxis(axis) {\n return axis === 'x' ? 'y' : 'x';\n}","import getBasePlacement from \"../utils/getBasePlacement.js\";\nimport getLayoutRect from \"../dom-utils/getLayoutRect.js\";\nimport contains from \"../dom-utils/contains.js\";\nimport getOffsetParent from \"../dom-utils/getOffsetParent.js\";\nimport getMainAxisFromPlacement from \"../utils/getMainAxisFromPlacement.js\";\nimport within from \"../utils/within.js\";\nimport mergePaddingObject from \"../utils/mergePaddingObject.js\";\nimport expandToHashMap from \"../utils/expandToHashMap.js\";\nimport { left, right, basePlacements, top, bottom } from \"../enums.js\";\nimport { isHTMLElement } from \"../dom-utils/instanceOf.js\"; // eslint-disable-next-line import/no-unused-modules\n\nfunction arrow(_ref) {\n var _state$modifiersData$;\n\n var state = _ref.state,\n name = _ref.name;\n var arrowElement = state.elements.arrow;\n var popperOffsets = state.modifiersData.popperOffsets;\n var basePlacement = getBasePlacement(state.placement);\n var axis = getMainAxisFromPlacement(basePlacement);\n var isVertical = [left, right].indexOf(basePlacement) >= 0;\n var len = isVertical ? 'height' : 'width';\n\n if (!arrowElement || !popperOffsets) {\n return;\n }\n\n var paddingObject = state.modifiersData[name + \"#persistent\"].padding;\n var arrowRect = getLayoutRect(arrowElement);\n var minProp = axis === 'y' ? top : left;\n var maxProp = axis === 'y' ? bottom : right;\n var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];\n var startDiff = popperOffsets[axis] - state.rects.reference[axis];\n var arrowOffsetParent = getOffsetParent(arrowElement);\n var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;\n var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is\n // outside of the popper bounds\n\n var min = paddingObject[minProp];\n var max = clientSize - arrowRect[len] - paddingObject[maxProp];\n var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;\n var offset = within(min, center, max); // Prevents breaking syntax highlighting...\n\n var axisProp = axis;\n state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);\n}\n\nfunction effect(_ref2) {\n var state = _ref2.state,\n options = _ref2.options,\n name = _ref2.name;\n var _options$element = options.element,\n arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,\n _options$padding = options.padding,\n padding = _options$padding === void 0 ? 0 : _options$padding;\n\n if (arrowElement == null) {\n return;\n } // CSS selector\n\n\n if (typeof arrowElement === 'string') {\n arrowElement = state.elements.popper.querySelector(arrowElement);\n\n if (!arrowElement) {\n return;\n }\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!isHTMLElement(arrowElement)) {\n console.error(['Popper: \"arrow\" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));\n }\n }\n\n if (!contains(state.elements.popper, arrowElement)) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(['Popper: \"arrow\" modifier\\'s `element` must be a child of the popper', 'element.'].join(' '));\n }\n\n return;\n }\n\n state.elements.arrow = arrowElement;\n state.modifiersData[name + \"#persistent\"] = {\n padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))\n };\n} // eslint-disable-next-line import/no-unused-modules\n\n\nexport default {\n name: 'arrow',\n enabled: true,\n phase: 'main',\n fn: arrow,\n effect: effect,\n requires: ['popperOffsets'],\n requiresIfExists: ['preventOverflow']\n};","/**!\n* tippy.js v6.2.7\n* (c) 2017-2020 atomiks\n* MIT License\n*/\nimport { createPopper } from '@popperjs/core';\nvar ROUND_ARROW = '';\nvar BOX_CLASS = \"tippy-box\";\nvar CONTENT_CLASS = \"tippy-content\";\nvar BACKDROP_CLASS = \"tippy-backdrop\";\nvar ARROW_CLASS = \"tippy-arrow\";\nvar SVG_ARROW_CLASS = \"tippy-svg-arrow\";\nvar TOUCH_OPTIONS = {\n passive: true,\n capture: true\n};\n\nfunction hasOwnProperty(obj, key) {\n return {}.hasOwnProperty.call(obj, key);\n}\n\nfunction getValueAtIndexOrReturn(value, index, defaultValue) {\n if (Array.isArray(value)) {\n var v = value[index];\n return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;\n }\n\n return value;\n}\n\nfunction isType(value, type) {\n var str = {}.toString.call(value);\n return str.indexOf('[object') === 0 && str.indexOf(type + \"]\") > -1;\n}\n\nfunction invokeWithArgsOrReturn(value, args) {\n return typeof value === 'function' ? value.apply(void 0, args) : value;\n}\n\nfunction debounce(fn, ms) {\n // Avoid wrapping in `setTimeout` if ms is 0 anyway\n if (ms === 0) {\n return fn;\n }\n\n var timeout;\n return function (arg) {\n clearTimeout(timeout);\n timeout = setTimeout(function () {\n fn(arg);\n }, ms);\n };\n}\n\nfunction removeProperties(obj, keys) {\n var clone = Object.assign({}, obj);\n keys.forEach(function (key) {\n delete clone[key];\n });\n return clone;\n}\n\nfunction splitBySpaces(value) {\n return value.split(/\\s+/).filter(Boolean);\n}\n\nfunction normalizeToArray(value) {\n return [].concat(value);\n}\n\nfunction pushIfUnique(arr, value) {\n if (arr.indexOf(value) === -1) {\n arr.push(value);\n }\n}\n\nfunction unique(arr) {\n return arr.filter(function (item, index) {\n return arr.indexOf(item) === index;\n });\n}\n\nfunction getBasePlacement(placement) {\n return placement.split('-')[0];\n}\n\nfunction arrayFrom(value) {\n return [].slice.call(value);\n}\n\nfunction removeUndefinedProps(obj) {\n return Object.keys(obj).reduce(function (acc, key) {\n if (obj[key] !== undefined) {\n acc[key] = obj[key];\n }\n\n return acc;\n }, {});\n}\n\nfunction div() {\n return document.createElement('div');\n}\n\nfunction isElement(value) {\n return ['Element', 'Fragment'].some(function (type) {\n return isType(value, type);\n });\n}\n\nfunction isNodeList(value) {\n return isType(value, 'NodeList');\n}\n\nfunction isMouseEvent(value) {\n return isType(value, 'MouseEvent');\n}\n\nfunction isReferenceElement(value) {\n return !!(value && value._tippy && value._tippy.reference === value);\n}\n\nfunction getArrayOfElements(value) {\n if (isElement(value)) {\n return [value];\n }\n\n if (isNodeList(value)) {\n return arrayFrom(value);\n }\n\n if (Array.isArray(value)) {\n return value;\n }\n\n return arrayFrom(document.querySelectorAll(value));\n}\n\nfunction setTransitionDuration(els, value) {\n els.forEach(function (el) {\n if (el) {\n el.style.transitionDuration = value + \"ms\";\n }\n });\n}\n\nfunction setVisibilityState(els, state) {\n els.forEach(function (el) {\n if (el) {\n el.setAttribute('data-state', state);\n }\n });\n}\n\nfunction getOwnerDocument(elementOrElements) {\n var _normalizeToArray = normalizeToArray(elementOrElements),\n element = _normalizeToArray[0];\n\n return element ? element.ownerDocument || document : document;\n}\n\nfunction isCursorOutsideInteractiveBorder(popperTreeData, event) {\n var clientX = event.clientX,\n clientY = event.clientY;\n return popperTreeData.every(function (_ref) {\n var popperRect = _ref.popperRect,\n popperState = _ref.popperState,\n props = _ref.props;\n var interactiveBorder = props.interactiveBorder;\n var basePlacement = getBasePlacement(popperState.placement);\n var offsetData = popperState.modifiersData.offset;\n\n if (!offsetData) {\n return true;\n }\n\n var topDistance = basePlacement === 'bottom' ? offsetData.top.y : 0;\n var bottomDistance = basePlacement === 'top' ? offsetData.bottom.y : 0;\n var leftDistance = basePlacement === 'right' ? offsetData.left.x : 0;\n var rightDistance = basePlacement === 'left' ? offsetData.right.x : 0;\n var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;\n var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;\n var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;\n var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;\n return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;\n });\n}\n\nfunction updateTransitionEndListener(box, action, listener) {\n var method = action + \"EventListener\"; // some browsers apparently support `transition` (unprefixed) but only fire\n // `webkitTransitionEnd`...\n\n ['transitionend', 'webkitTransitionEnd'].forEach(function (event) {\n box[method](event, listener);\n });\n}\n\nvar currentInput = {\n isTouch: false\n};\nvar lastMouseMoveTime = 0;\n/**\n * When a `touchstart` event is fired, it's assumed the user is using touch\n * input. We'll bind a `mousemove` event listener to listen for mouse input in\n * the future. This way, the `isTouch` property is fully dynamic and will handle\n * hybrid devices that use a mix of touch + mouse input.\n */\n\nfunction onDocumentTouchStart() {\n if (currentInput.isTouch) {\n return;\n }\n\n currentInput.isTouch = true;\n\n if (window.performance) {\n document.addEventListener('mousemove', onDocumentMouseMove);\n }\n}\n/**\n * When two `mousemove` event are fired consecutively within 20ms, it's assumed\n * the user is using mouse input again. `mousemove` can fire on touch devices as\n * well, but very rarely that quickly.\n */\n\n\nfunction onDocumentMouseMove() {\n var now = performance.now();\n\n if (now - lastMouseMoveTime < 20) {\n currentInput.isTouch = false;\n document.removeEventListener('mousemove', onDocumentMouseMove);\n }\n\n lastMouseMoveTime = now;\n}\n/**\n * When an element is in focus and has a tippy, leaving the tab/window and\n * returning causes it to show again. For mouse users this is unexpected, but\n * for keyboard use it makes sense.\n * TODO: find a better technique to solve this problem\n */\n\n\nfunction onWindowBlur() {\n var activeElement = document.activeElement;\n\n if (isReferenceElement(activeElement)) {\n var instance = activeElement._tippy;\n\n if (activeElement.blur && !instance.state.isVisible) {\n activeElement.blur();\n }\n }\n}\n\nfunction bindGlobalEventListeners() {\n document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);\n window.addEventListener('blur', onWindowBlur);\n}\n\nvar isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\nvar ua = isBrowser ? navigator.userAgent : '';\nvar isIE = /MSIE |Trident\\//.test(ua);\n\nfunction createMemoryLeakWarning(method) {\n var txt = method === 'destroy' ? 'n already-' : ' ';\n return [method + \"() was called on a\" + txt + \"destroyed instance. This is a no-op but\", 'indicates a potential memory leak.'].join(' ');\n}\n\nfunction clean(value) {\n var spacesAndTabs = /[ \\t]{2,}/g;\n var lineStartWithSpaces = /^[ \\t]*/gm;\n return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();\n}\n\nfunction getDevMessage(message) {\n return clean(\"\\n %ctippy.js\\n\\n %c\" + clean(message) + \"\\n\\n %c\\uD83D\\uDC77\\u200D This is a development-only message. It will be removed in production.\\n \");\n}\n\nfunction getFormattedMessage(message) {\n return [getDevMessage(message), // title\n 'color: #00C584; font-size: 1.3em; font-weight: bold;', // message\n 'line-height: 1.5', // footer\n 'color: #a6a095;'];\n} // Assume warnings and errors never have the same message\n\n\nvar visitedMessages;\n\nif (process.env.NODE_ENV !== \"production\") {\n resetVisitedMessages();\n}\n\nfunction resetVisitedMessages() {\n visitedMessages = new Set();\n}\n\nfunction warnWhen(condition, message) {\n if (condition && !visitedMessages.has(message)) {\n var _console;\n\n visitedMessages.add(message);\n\n (_console = console).warn.apply(_console, getFormattedMessage(message));\n }\n}\n\nfunction errorWhen(condition, message) {\n if (condition && !visitedMessages.has(message)) {\n var _console2;\n\n visitedMessages.add(message);\n\n (_console2 = console).error.apply(_console2, getFormattedMessage(message));\n }\n}\n\nfunction validateTargets(targets) {\n var didPassFalsyValue = !targets;\n var didPassPlainObject = Object.prototype.toString.call(targets) === '[object Object]' && !targets.addEventListener;\n errorWhen(didPassFalsyValue, ['tippy() was passed', '`' + String(targets) + '`', 'as its targets (first) argument. Valid types are: String, Element,', 'Element[], or NodeList.'].join(' '));\n errorWhen(didPassPlainObject, ['tippy() was passed a plain object which is not supported as an argument', 'for virtual positioning. Use props.getReferenceClientRect instead.'].join(' '));\n}\n\nvar pluginProps = {\n animateFill: false,\n followCursor: false,\n inlinePositioning: false,\n sticky: false\n};\nvar renderProps = {\n allowHTML: false,\n animation: 'fade',\n arrow: true,\n content: '',\n inertia: false,\n maxWidth: 350,\n role: 'tooltip',\n theme: '',\n zIndex: 9999\n};\nvar defaultProps = Object.assign({\n appendTo: function appendTo() {\n return document.body;\n },\n aria: {\n content: 'auto',\n expanded: 'auto'\n },\n delay: 0,\n duration: [300, 250],\n getReferenceClientRect: null,\n hideOnClick: true,\n ignoreAttributes: false,\n interactive: false,\n interactiveBorder: 2,\n interactiveDebounce: 0,\n moveTransition: '',\n offset: [0, 10],\n onAfterUpdate: function onAfterUpdate() {},\n onBeforeUpdate: function onBeforeUpdate() {},\n onCreate: function onCreate() {},\n onDestroy: function onDestroy() {},\n onHidden: function onHidden() {},\n onHide: function onHide() {},\n onMount: function onMount() {},\n onShow: function onShow() {},\n onShown: function onShown() {},\n onTrigger: function onTrigger() {},\n onUntrigger: function onUntrigger() {},\n onClickOutside: function onClickOutside() {},\n placement: 'top',\n plugins: [],\n popperOptions: {},\n render: null,\n showOnCreate: false,\n touch: true,\n trigger: 'mouseenter focus',\n triggerTarget: null\n}, pluginProps, {}, renderProps);\nvar defaultKeys = Object.keys(defaultProps);\n\nvar setDefaultProps = function setDefaultProps(partialProps) {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n validateProps(partialProps, []);\n }\n\n var keys = Object.keys(partialProps);\n keys.forEach(function (key) {\n defaultProps[key] = partialProps[key];\n });\n};\n\nfunction getExtendedPassedProps(passedProps) {\n var plugins = passedProps.plugins || [];\n var pluginProps = plugins.reduce(function (acc, plugin) {\n var name = plugin.name,\n defaultValue = plugin.defaultValue;\n\n if (name) {\n acc[name] = passedProps[name] !== undefined ? passedProps[name] : defaultValue;\n }\n\n return acc;\n }, {});\n return Object.assign({}, passedProps, {}, pluginProps);\n}\n\nfunction getDataAttributeProps(reference, plugins) {\n var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {\n plugins: plugins\n }))) : defaultKeys;\n var props = propKeys.reduce(function (acc, key) {\n var valueAsString = (reference.getAttribute(\"data-tippy-\" + key) || '').trim();\n\n if (!valueAsString) {\n return acc;\n }\n\n if (key === 'content') {\n acc[key] = valueAsString;\n } else {\n try {\n acc[key] = JSON.parse(valueAsString);\n } catch (e) {\n acc[key] = valueAsString;\n }\n }\n\n return acc;\n }, {});\n return props;\n}\n\nfunction evaluateProps(reference, props) {\n var out = Object.assign({}, props, {\n content: invokeWithArgsOrReturn(props.content, [reference])\n }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));\n out.aria = Object.assign({}, defaultProps.aria, {}, out.aria);\n out.aria = {\n expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,\n content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content\n };\n return out;\n}\n\nfunction validateProps(partialProps, plugins) {\n if (partialProps === void 0) {\n partialProps = {};\n }\n\n if (plugins === void 0) {\n plugins = [];\n }\n\n var keys = Object.keys(partialProps);\n keys.forEach(function (prop) {\n var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps));\n var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); // Check if the prop exists in `plugins`\n\n if (didPassUnknownProp) {\n didPassUnknownProp = plugins.filter(function (plugin) {\n return plugin.name === prop;\n }).length === 0;\n }\n\n warnWhen(didPassUnknownProp, [\"`\" + prop + \"`\", \"is not a valid prop. You may have spelled it incorrectly, or if it's\", 'a plugin, forgot to pass it in an array as props.plugins.', '\\n\\n', 'All props: https://atomiks.github.io/tippyjs/v6/all-props/\\n', 'Plugins: https://atomiks.github.io/tippyjs/v6/plugins/'].join(' '));\n });\n}\n\nvar innerHTML = function innerHTML() {\n return 'innerHTML';\n};\n\nfunction dangerouslySetInnerHTML(element, html) {\n element[innerHTML()] = html;\n}\n\nfunction createArrowElement(value) {\n var arrow = div();\n\n if (value === true) {\n arrow.className = ARROW_CLASS;\n } else {\n arrow.className = SVG_ARROW_CLASS;\n\n if (isElement(value)) {\n arrow.appendChild(value);\n } else {\n dangerouslySetInnerHTML(arrow, value);\n }\n }\n\n return arrow;\n}\n\nfunction setContent(content, props) {\n if (isElement(props.content)) {\n dangerouslySetInnerHTML(content, '');\n content.appendChild(props.content);\n } else if (typeof props.content !== 'function') {\n if (props.allowHTML) {\n dangerouslySetInnerHTML(content, props.content);\n } else {\n content.textContent = props.content;\n }\n }\n}\n\nfunction getChildren(popper) {\n var box = popper.firstElementChild;\n var boxChildren = arrayFrom(box.children);\n return {\n box: box,\n content: boxChildren.find(function (node) {\n return node.classList.contains(CONTENT_CLASS);\n }),\n arrow: boxChildren.find(function (node) {\n return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);\n }),\n backdrop: boxChildren.find(function (node) {\n return node.classList.contains(BACKDROP_CLASS);\n })\n };\n}\n\nfunction render(instance) {\n var popper = div();\n var box = div();\n box.className = BOX_CLASS;\n box.setAttribute('data-state', 'hidden');\n box.setAttribute('tabindex', '-1');\n var content = div();\n content.className = CONTENT_CLASS;\n content.setAttribute('data-state', 'hidden');\n setContent(content, instance.props);\n popper.appendChild(box);\n box.appendChild(content);\n onUpdate(instance.props, instance.props);\n\n function onUpdate(prevProps, nextProps) {\n var _getChildren = getChildren(popper),\n box = _getChildren.box,\n content = _getChildren.content,\n arrow = _getChildren.arrow;\n\n if (nextProps.theme) {\n box.setAttribute('data-theme', nextProps.theme);\n } else {\n box.removeAttribute('data-theme');\n }\n\n if (typeof nextProps.animation === 'string') {\n box.setAttribute('data-animation', nextProps.animation);\n } else {\n box.removeAttribute('data-animation');\n }\n\n if (nextProps.inertia) {\n box.setAttribute('data-inertia', '');\n } else {\n box.removeAttribute('data-inertia');\n }\n\n box.style.maxWidth = typeof nextProps.maxWidth === 'number' ? nextProps.maxWidth + \"px\" : nextProps.maxWidth;\n\n if (nextProps.role) {\n box.setAttribute('role', nextProps.role);\n } else {\n box.removeAttribute('role');\n }\n\n if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {\n setContent(content, instance.props);\n }\n\n if (nextProps.arrow) {\n if (!arrow) {\n box.appendChild(createArrowElement(nextProps.arrow));\n } else if (prevProps.arrow !== nextProps.arrow) {\n box.removeChild(arrow);\n box.appendChild(createArrowElement(nextProps.arrow));\n }\n } else if (arrow) {\n box.removeChild(arrow);\n }\n }\n\n return {\n popper: popper,\n onUpdate: onUpdate\n };\n} // Runtime check to identify if the render function is the default one; this\n// way we can apply default CSS transitions logic and it can be tree-shaken away\n\n\nrender.$$tippy = true;\nvar idCounter = 1;\nvar mouseMoveListeners = []; // Used by `hideAll()`\n\nvar mountedInstances = [];\n\nfunction createTippy(reference, passedProps) {\n var props = evaluateProps(reference, Object.assign({}, defaultProps, {}, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================\n // 🔒 Private members\n // ===========================================================================\n\n var showTimeout;\n var hideTimeout;\n var scheduleHideAnimationFrame;\n var isVisibleFromClick = false;\n var didHideDueToDocumentMouseDown = false;\n var didTouchMove = false;\n var ignoreOnFirstUpdate = false;\n var lastTriggerEvent;\n var currentTransitionEndListener;\n var onFirstUpdate;\n var listeners = [];\n var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);\n var currentTarget; // ===========================================================================\n // 🔑 Public members\n // ===========================================================================\n\n var id = idCounter++;\n var popperInstance = null;\n var plugins = unique(props.plugins);\n var state = {\n // Is the instance currently enabled?\n isEnabled: true,\n // Is the tippy currently showing and not transitioning out?\n isVisible: false,\n // Has the instance been destroyed?\n isDestroyed: false,\n // Is the tippy currently mounted to the DOM?\n isMounted: false,\n // Has the tippy finished transitioning in?\n isShown: false\n };\n var instance = {\n // properties\n id: id,\n reference: reference,\n popper: div(),\n popperInstance: popperInstance,\n props: props,\n state: state,\n plugins: plugins,\n // methods\n clearDelayTimeouts: clearDelayTimeouts,\n setProps: setProps,\n setContent: setContent,\n show: show,\n hide: hide,\n hideWithInteractivity: hideWithInteractivity,\n enable: enable,\n disable: disable,\n unmount: unmount,\n destroy: destroy\n }; // TODO: Investigate why this early return causes a TDZ error in the tests —\n // it doesn't seem to happen in the browser\n\n /* istanbul ignore if */\n\n if (!props.render) {\n if (process.env.NODE_ENV !== \"production\") {\n errorWhen(true, 'render() function has not been supplied.');\n }\n\n return instance;\n } // ===========================================================================\n // Initial mutations\n // ===========================================================================\n\n\n var _props$render = props.render(instance),\n popper = _props$render.popper,\n onUpdate = _props$render.onUpdate;\n\n popper.setAttribute('data-tippy-root', '');\n popper.id = \"tippy-\" + instance.id;\n instance.popper = popper;\n reference._tippy = instance;\n popper._tippy = instance;\n var pluginsHooks = plugins.map(function (plugin) {\n return plugin.fn(instance);\n });\n var hasAriaExpanded = reference.hasAttribute('aria-expanded');\n addListeners();\n handleAriaExpandedAttribute();\n handleStyles();\n invokeHook('onCreate', [instance]);\n\n if (props.showOnCreate) {\n scheduleShow();\n } // Prevent a tippy with a delay from hiding if the cursor left then returned\n // before it started hiding\n\n\n popper.addEventListener('mouseenter', function () {\n if (instance.props.interactive && instance.state.isVisible) {\n instance.clearDelayTimeouts();\n }\n });\n popper.addEventListener('mouseleave', function (event) {\n if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {\n getDocument().addEventListener('mousemove', debouncedOnMouseMove);\n debouncedOnMouseMove(event);\n }\n });\n return instance; // ===========================================================================\n // 🔒 Private methods\n // ===========================================================================\n\n function getNormalizedTouchSettings() {\n var touch = instance.props.touch;\n return Array.isArray(touch) ? touch : [touch, 0];\n }\n\n function getIsCustomTouchBehavior() {\n return getNormalizedTouchSettings()[0] === 'hold';\n }\n\n function getIsDefaultRenderFn() {\n var _instance$props$rende; // @ts-ignore\n\n\n return !!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy);\n }\n\n function getCurrentTarget() {\n return currentTarget || reference;\n }\n\n function getDocument() {\n var parent = getCurrentTarget().parentNode;\n return parent ? getOwnerDocument(parent) : document;\n }\n\n function getDefaultTemplateChildren() {\n return getChildren(popper);\n }\n\n function getDelay(isShow) {\n // For touch or keyboard input, force `0` delay for UX reasons\n // Also if the instance is mounted but not visible (transitioning out),\n // ignore delay\n if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === 'focus') {\n return 0;\n }\n\n return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);\n }\n\n function handleStyles() {\n popper.style.pointerEvents = instance.props.interactive && instance.state.isVisible ? '' : 'none';\n popper.style.zIndex = \"\" + instance.props.zIndex;\n }\n\n function invokeHook(hook, args, shouldInvokePropsHook) {\n if (shouldInvokePropsHook === void 0) {\n shouldInvokePropsHook = true;\n }\n\n pluginsHooks.forEach(function (pluginHooks) {\n if (pluginHooks[hook]) {\n pluginHooks[hook].apply(void 0, args);\n }\n });\n\n if (shouldInvokePropsHook) {\n var _instance$props;\n\n (_instance$props = instance.props)[hook].apply(_instance$props, args);\n }\n }\n\n function handleAriaContentAttribute() {\n var aria = instance.props.aria;\n\n if (!aria.content) {\n return;\n }\n\n var attr = \"aria-\" + aria.content;\n var id = popper.id;\n var nodes = normalizeToArray(instance.props.triggerTarget || reference);\n nodes.forEach(function (node) {\n var currentValue = node.getAttribute(attr);\n\n if (instance.state.isVisible) {\n node.setAttribute(attr, currentValue ? currentValue + \" \" + id : id);\n } else {\n var nextValue = currentValue && currentValue.replace(id, '').trim();\n\n if (nextValue) {\n node.setAttribute(attr, nextValue);\n } else {\n node.removeAttribute(attr);\n }\n }\n });\n }\n\n function handleAriaExpandedAttribute() {\n if (hasAriaExpanded || !instance.props.aria.expanded) {\n return;\n }\n\n var nodes = normalizeToArray(instance.props.triggerTarget || reference);\n nodes.forEach(function (node) {\n if (instance.props.interactive) {\n node.setAttribute('aria-expanded', instance.state.isVisible && node === getCurrentTarget() ? 'true' : 'false');\n } else {\n node.removeAttribute('aria-expanded');\n }\n });\n }\n\n function cleanupInteractiveMouseListeners() {\n getDocument().removeEventListener('mousemove', debouncedOnMouseMove);\n mouseMoveListeners = mouseMoveListeners.filter(function (listener) {\n return listener !== debouncedOnMouseMove;\n });\n }\n\n function onDocumentPress(event) {\n // Moved finger to scroll instead of an intentional tap outside\n if (currentInput.isTouch) {\n if (didTouchMove || event.type === 'mousedown') {\n return;\n }\n } // Clicked on interactive popper\n\n\n if (instance.props.interactive && popper.contains(event.target)) {\n return;\n } // Clicked on the event listeners target\n\n\n if (getCurrentTarget().contains(event.target)) {\n if (currentInput.isTouch) {\n return;\n }\n\n if (instance.state.isVisible && instance.props.trigger.indexOf('click') >= 0) {\n return;\n }\n } else {\n invokeHook('onClickOutside', [instance, event]);\n }\n\n if (instance.props.hideOnClick === true) {\n instance.clearDelayTimeouts();\n instance.hide(); // `mousedown` event is fired right before `focus` if pressing the\n // currentTarget. This lets a tippy with `focus` trigger know that it\n // should not show\n\n didHideDueToDocumentMouseDown = true;\n setTimeout(function () {\n didHideDueToDocumentMouseDown = false;\n }); // The listener gets added in `scheduleShow()`, but this may be hiding it\n // before it shows, and hide()'s early bail-out behavior can prevent it\n // from being cleaned up\n\n if (!instance.state.isMounted) {\n removeDocumentPress();\n }\n }\n }\n\n function onTouchMove() {\n didTouchMove = true;\n }\n\n function onTouchStart() {\n didTouchMove = false;\n }\n\n function addDocumentPress() {\n var doc = getDocument();\n doc.addEventListener('mousedown', onDocumentPress, true);\n doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);\n doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);\n doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);\n }\n\n function removeDocumentPress() {\n var doc = getDocument();\n doc.removeEventListener('mousedown', onDocumentPress, true);\n doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);\n doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);\n doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);\n }\n\n function onTransitionedOut(duration, callback) {\n onTransitionEnd(duration, function () {\n if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {\n callback();\n }\n });\n }\n\n function onTransitionedIn(duration, callback) {\n onTransitionEnd(duration, callback);\n }\n\n function onTransitionEnd(duration, callback) {\n var box = getDefaultTemplateChildren().box;\n\n function listener(event) {\n if (event.target === box) {\n updateTransitionEndListener(box, 'remove', listener);\n callback();\n }\n } // Make callback synchronous if duration is 0\n // `transitionend` won't fire otherwise\n\n\n if (duration === 0) {\n return callback();\n }\n\n updateTransitionEndListener(box, 'remove', currentTransitionEndListener);\n updateTransitionEndListener(box, 'add', listener);\n currentTransitionEndListener = listener;\n }\n\n function on(eventType, handler, options) {\n if (options === void 0) {\n options = false;\n }\n\n var nodes = normalizeToArray(instance.props.triggerTarget || reference);\n nodes.forEach(function (node) {\n node.addEventListener(eventType, handler, options);\n listeners.push({\n node: node,\n eventType: eventType,\n handler: handler,\n options: options\n });\n });\n }\n\n function addListeners() {\n if (getIsCustomTouchBehavior()) {\n on('touchstart', onTrigger, {\n passive: true\n });\n on('touchend', onMouseLeave, {\n passive: true\n });\n }\n\n splitBySpaces(instance.props.trigger).forEach(function (eventType) {\n if (eventType === 'manual') {\n return;\n }\n\n on(eventType, onTrigger);\n\n switch (eventType) {\n case 'mouseenter':\n on('mouseleave', onMouseLeave);\n break;\n\n case 'focus':\n on(isIE ? 'focusout' : 'blur', onBlurOrFocusOut);\n break;\n\n case 'focusin':\n on('focusout', onBlurOrFocusOut);\n break;\n }\n });\n }\n\n function removeListeners() {\n listeners.forEach(function (_ref) {\n var node = _ref.node,\n eventType = _ref.eventType,\n handler = _ref.handler,\n options = _ref.options;\n node.removeEventListener(eventType, handler, options);\n });\n listeners = [];\n }\n\n function onTrigger(event) {\n var _lastTriggerEvent;\n\n var shouldScheduleClickHide = false;\n\n if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {\n return;\n }\n\n var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === 'focus';\n lastTriggerEvent = event;\n currentTarget = event.currentTarget;\n handleAriaExpandedAttribute();\n\n if (!instance.state.isVisible && isMouseEvent(event)) {\n // If scrolling, `mouseenter` events can be fired if the cursor lands\n // over a new target, but `mousemove` events don't get fired. This\n // causes interactive tooltips to get stuck open until the cursor is\n // moved\n mouseMoveListeners.forEach(function (listener) {\n return listener(event);\n });\n } // Toggle show/hide when clicking click-triggered tooltips\n\n\n if (event.type === 'click' && (instance.props.trigger.indexOf('mouseenter') < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {\n shouldScheduleClickHide = true;\n } else {\n scheduleShow(event);\n }\n\n if (event.type === 'click') {\n isVisibleFromClick = !shouldScheduleClickHide;\n }\n\n if (shouldScheduleClickHide && !wasFocused) {\n scheduleHide(event);\n }\n }\n\n function onMouseMove(event) {\n var target = event.target;\n var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target);\n\n if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {\n return;\n }\n\n var popperTreeData = getNestedPopperTree().concat(popper).map(function (popper) {\n var _instance$popperInsta;\n\n var instance = popper._tippy;\n var state = (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.state;\n\n if (state) {\n return {\n popperRect: popper.getBoundingClientRect(),\n popperState: state,\n props: props\n };\n }\n\n return null;\n }).filter(Boolean);\n\n if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {\n cleanupInteractiveMouseListeners();\n scheduleHide(event);\n }\n }\n\n function onMouseLeave(event) {\n var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick;\n\n if (shouldBail) {\n return;\n }\n\n if (instance.props.interactive) {\n instance.hideWithInteractivity(event);\n return;\n }\n\n scheduleHide(event);\n }\n\n function onBlurOrFocusOut(event) {\n if (instance.props.trigger.indexOf('focusin') < 0 && event.target !== getCurrentTarget()) {\n return;\n } // If focus was moved to within the popper\n\n\n if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {\n return;\n }\n\n scheduleHide(event);\n }\n\n function isEventListenerStopped(event) {\n return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0 : false;\n }\n\n function createPopperInstance() {\n destroyPopperInstance();\n var _instance$props2 = instance.props,\n popperOptions = _instance$props2.popperOptions,\n placement = _instance$props2.placement,\n offset = _instance$props2.offset,\n getReferenceClientRect = _instance$props2.getReferenceClientRect,\n moveTransition = _instance$props2.moveTransition;\n var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;\n var computedReference = getReferenceClientRect ? {\n getBoundingClientRect: getReferenceClientRect,\n contextElement: getReferenceClientRect.contextElement || getCurrentTarget()\n } : reference;\n var tippyModifier = {\n name: '$$tippy',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles'],\n fn: function fn(_ref2) {\n var state = _ref2.state;\n\n if (getIsDefaultRenderFn()) {\n var _getDefaultTemplateCh = getDefaultTemplateChildren(),\n box = _getDefaultTemplateCh.box;\n\n ['placement', 'reference-hidden', 'escaped'].forEach(function (attr) {\n if (attr === 'placement') {\n box.setAttribute('data-placement', state.placement);\n } else {\n if (state.attributes.popper[\"data-popper-\" + attr]) {\n box.setAttribute(\"data-\" + attr, '');\n } else {\n box.removeAttribute(\"data-\" + attr);\n }\n }\n });\n state.attributes.popper = {};\n }\n }\n };\n var modifiers = [{\n name: 'offset',\n options: {\n offset: offset\n }\n }, {\n name: 'preventOverflow',\n options: {\n padding: {\n top: 2,\n bottom: 2,\n left: 5,\n right: 5\n }\n }\n }, {\n name: 'flip',\n options: {\n padding: 5\n }\n }, {\n name: 'computeStyles',\n options: {\n adaptive: !moveTransition\n }\n }, tippyModifier];\n\n if (getIsDefaultRenderFn() && arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrow,\n padding: 3\n }\n });\n }\n\n modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);\n instance.popperInstance = createPopper(computedReference, popper, Object.assign({}, popperOptions, {\n placement: placement,\n onFirstUpdate: onFirstUpdate,\n modifiers: modifiers\n }));\n }\n\n function destroyPopperInstance() {\n if (instance.popperInstance) {\n instance.popperInstance.destroy();\n instance.popperInstance = null;\n }\n }\n\n function mount() {\n var appendTo = instance.props.appendTo;\n var parentNode; // By default, we'll append the popper to the triggerTargets's parentNode so\n // it's directly after the reference element so the elements inside the\n // tippy can be tabbed to\n // If there are clipping issues, the user can specify a different appendTo\n // and ensure focus management is handled correctly manually\n\n var node = getCurrentTarget();\n\n if (instance.props.interactive && appendTo === defaultProps.appendTo || appendTo === 'parent') {\n parentNode = node.parentNode;\n } else {\n parentNode = invokeWithArgsOrReturn(appendTo, [node]);\n } // The popper element needs to exist on the DOM before its position can be\n // updated as Popper needs to read its dimensions\n\n\n if (!parentNode.contains(popper)) {\n parentNode.appendChild(popper);\n }\n\n createPopperInstance();\n /* istanbul ignore else */\n\n if (process.env.NODE_ENV !== \"production\") {\n // Accessibility check\n warnWhen(instance.props.interactive && appendTo === defaultProps.appendTo && node.nextElementSibling !== popper, ['Interactive tippy element may not be accessible via keyboard', 'navigation because it is not directly after the reference element', 'in the DOM source order.', '\\n\\n', 'Using a wrapper or tag around the reference element', 'solves this by creating a new parentNode context.', '\\n\\n', 'Specifying `appendTo: document.body` silences this warning, but it', 'assumes you are using a focus management solution to handle', 'keyboard navigation.', '\\n\\n', 'See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity'].join(' '));\n }\n }\n\n function getNestedPopperTree() {\n return arrayFrom(popper.querySelectorAll('[data-tippy-root]'));\n }\n\n function scheduleShow(event) {\n instance.clearDelayTimeouts();\n\n if (event) {\n invokeHook('onTrigger', [instance, event]);\n }\n\n addDocumentPress();\n var delay = getDelay(true);\n\n var _getNormalizedTouchSe = getNormalizedTouchSettings(),\n touchValue = _getNormalizedTouchSe[0],\n touchDelay = _getNormalizedTouchSe[1];\n\n if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {\n delay = touchDelay;\n }\n\n if (delay) {\n showTimeout = setTimeout(function () {\n instance.show();\n }, delay);\n } else {\n instance.show();\n }\n }\n\n function scheduleHide(event) {\n instance.clearDelayTimeouts();\n invokeHook('onUntrigger', [instance, event]);\n\n if (!instance.state.isVisible) {\n removeDocumentPress();\n return;\n } // For interactive tippies, scheduleHide is added to a document.body handler\n // from onMouseLeave so must intercept scheduled hides from mousemove/leave\n // events when trigger contains mouseenter and click, and the tip is\n // currently shown as a result of a click.\n\n\n if (instance.props.trigger.indexOf('mouseenter') >= 0 && instance.props.trigger.indexOf('click') >= 0 && ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 && isVisibleFromClick) {\n return;\n }\n\n var delay = getDelay(false);\n\n if (delay) {\n hideTimeout = setTimeout(function () {\n if (instance.state.isVisible) {\n instance.hide();\n }\n }, delay);\n } else {\n // Fixes a `transitionend` problem when it fires 1 frame too\n // late sometimes, we don't want hide() to be called.\n scheduleHideAnimationFrame = requestAnimationFrame(function () {\n instance.hide();\n });\n }\n } // ===========================================================================\n // 🔑 Public methods\n // ===========================================================================\n\n\n function enable() {\n instance.state.isEnabled = true;\n }\n\n function disable() {\n // Disabling the instance should also hide it\n // https://github.com/atomiks/tippy.js-react/issues/106\n instance.hide();\n instance.state.isEnabled = false;\n }\n\n function clearDelayTimeouts() {\n clearTimeout(showTimeout);\n clearTimeout(hideTimeout);\n cancelAnimationFrame(scheduleHideAnimationFrame);\n }\n\n function setProps(partialProps) {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));\n }\n\n if (instance.state.isDestroyed) {\n return;\n }\n\n invokeHook('onBeforeUpdate', [instance, partialProps]);\n removeListeners();\n var prevProps = instance.props;\n var nextProps = evaluateProps(reference, Object.assign({}, instance.props, {}, partialProps, {\n ignoreAttributes: true\n }));\n instance.props = nextProps;\n addListeners();\n\n if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {\n cleanupInteractiveMouseListeners();\n debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);\n } // Ensure stale aria-expanded attributes are removed\n\n\n if (prevProps.triggerTarget && !nextProps.triggerTarget) {\n normalizeToArray(prevProps.triggerTarget).forEach(function (node) {\n node.removeAttribute('aria-expanded');\n });\n } else if (nextProps.triggerTarget) {\n reference.removeAttribute('aria-expanded');\n }\n\n handleAriaExpandedAttribute();\n handleStyles();\n\n if (onUpdate) {\n onUpdate(prevProps, nextProps);\n }\n\n if (instance.popperInstance) {\n createPopperInstance(); // Fixes an issue with nested tippies if they are all getting re-rendered,\n // and the nested ones get re-rendered first.\n // https://github.com/atomiks/tippyjs-react/issues/177\n // TODO: find a cleaner / more efficient solution(!)\n\n getNestedPopperTree().forEach(function (nestedPopper) {\n // React (and other UI libs likely) requires a rAF wrapper as it flushes\n // its work in one\n requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);\n });\n }\n\n invokeHook('onAfterUpdate', [instance, partialProps]);\n }\n\n function setContent(content) {\n instance.setProps({\n content: content\n });\n }\n\n function show() {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));\n } // Early bail-out\n\n\n var isAlreadyVisible = instance.state.isVisible;\n var isDestroyed = instance.state.isDestroyed;\n var isDisabled = !instance.state.isEnabled;\n var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;\n var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);\n\n if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {\n return;\n } // Normalize `disabled` behavior across browsers.\n // Firefox allows events on disabled elements, but Chrome doesn't.\n // Using a wrapper element (i.e. ) is recommended.\n\n\n if (getCurrentTarget().hasAttribute('disabled')) {\n return;\n }\n\n invokeHook('onShow', [instance], false);\n\n if (instance.props.onShow(instance) === false) {\n return;\n }\n\n instance.state.isVisible = true;\n\n if (getIsDefaultRenderFn()) {\n popper.style.visibility = 'visible';\n }\n\n handleStyles();\n addDocumentPress();\n\n if (!instance.state.isMounted) {\n popper.style.transition = 'none';\n } // If flipping to the opposite side after hiding at least once, the\n // animation will use the wrong placement without resetting the duration\n\n\n if (getIsDefaultRenderFn()) {\n var _getDefaultTemplateCh2 = getDefaultTemplateChildren(),\n box = _getDefaultTemplateCh2.box,\n content = _getDefaultTemplateCh2.content;\n\n setTransitionDuration([box, content], 0);\n }\n\n onFirstUpdate = function onFirstUpdate() {\n if (!instance.state.isVisible || ignoreOnFirstUpdate) {\n return;\n }\n\n ignoreOnFirstUpdate = true; // reflow\n\n void popper.offsetHeight;\n popper.style.transition = instance.props.moveTransition;\n\n if (getIsDefaultRenderFn() && instance.props.animation) {\n var _getDefaultTemplateCh3 = getDefaultTemplateChildren(),\n _box = _getDefaultTemplateCh3.box,\n _content = _getDefaultTemplateCh3.content;\n\n setTransitionDuration([_box, _content], duration);\n setVisibilityState([_box, _content], 'visible');\n }\n\n handleAriaContentAttribute();\n handleAriaExpandedAttribute();\n pushIfUnique(mountedInstances, instance);\n instance.state.isMounted = true;\n invokeHook('onMount', [instance]);\n\n if (instance.props.animation && getIsDefaultRenderFn()) {\n onTransitionedIn(duration, function () {\n instance.state.isShown = true;\n invokeHook('onShown', [instance]);\n });\n }\n };\n\n mount();\n }\n\n function hide() {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));\n } // Early bail-out\n\n\n var isAlreadyHidden = !instance.state.isVisible;\n var isDestroyed = instance.state.isDestroyed;\n var isDisabled = !instance.state.isEnabled;\n var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);\n\n if (isAlreadyHidden || isDestroyed || isDisabled) {\n return;\n }\n\n invokeHook('onHide', [instance], false);\n\n if (instance.props.onHide(instance) === false) {\n return;\n }\n\n instance.state.isVisible = false;\n instance.state.isShown = false;\n ignoreOnFirstUpdate = false;\n isVisibleFromClick = false;\n\n if (getIsDefaultRenderFn()) {\n popper.style.visibility = 'hidden';\n }\n\n cleanupInteractiveMouseListeners();\n removeDocumentPress();\n handleStyles();\n\n if (getIsDefaultRenderFn()) {\n var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),\n box = _getDefaultTemplateCh4.box,\n content = _getDefaultTemplateCh4.content;\n\n if (instance.props.animation) {\n setTransitionDuration([box, content], duration);\n setVisibilityState([box, content], 'hidden');\n }\n }\n\n handleAriaContentAttribute();\n handleAriaExpandedAttribute();\n\n if (instance.props.animation) {\n if (getIsDefaultRenderFn()) {\n onTransitionedOut(duration, instance.unmount);\n }\n } else {\n instance.unmount();\n }\n }\n\n function hideWithInteractivity(event) {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hideWithInteractivity'));\n }\n\n getDocument().addEventListener('mousemove', debouncedOnMouseMove);\n pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);\n debouncedOnMouseMove(event);\n }\n\n function unmount() {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));\n }\n\n if (instance.state.isVisible) {\n instance.hide();\n }\n\n if (!instance.state.isMounted) {\n return;\n }\n\n destroyPopperInstance(); // If a popper is not interactive, it will be appended outside the popper\n // tree by default. This seems mainly for interactive tippies, but we should\n // find a workaround if possible\n\n getNestedPopperTree().forEach(function (nestedPopper) {\n nestedPopper._tippy.unmount();\n });\n\n if (popper.parentNode) {\n popper.parentNode.removeChild(popper);\n }\n\n mountedInstances = mountedInstances.filter(function (i) {\n return i !== instance;\n });\n instance.state.isMounted = false;\n invokeHook('onHidden', [instance]);\n }\n\n function destroy() {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));\n }\n\n if (instance.state.isDestroyed) {\n return;\n }\n\n instance.clearDelayTimeouts();\n instance.unmount();\n removeListeners();\n delete reference._tippy;\n instance.state.isDestroyed = true;\n invokeHook('onDestroy', [instance]);\n }\n}\n\nfunction tippy(targets, optionalProps) {\n if (optionalProps === void 0) {\n optionalProps = {};\n }\n\n var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);\n /* istanbul ignore else */\n\n if (process.env.NODE_ENV !== \"production\") {\n validateTargets(targets);\n validateProps(optionalProps, plugins);\n }\n\n bindGlobalEventListeners();\n var passedProps = Object.assign({}, optionalProps, {\n plugins: plugins\n });\n var elements = getArrayOfElements(targets);\n /* istanbul ignore else */\n\n if (process.env.NODE_ENV !== \"production\") {\n var isSingleContentElement = isElement(passedProps.content);\n var isMoreThanOneReferenceElement = elements.length > 1;\n warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ['tippy() was passed an Element as the `content` prop, but more than', 'one tippy instance was created by this invocation. This means the', 'content element will only be appended to the last tippy instance.', '\\n\\n', 'Instead, pass the .innerHTML of the element, or use a function that', 'returns a cloned version of the element instead.', '\\n\\n', '1) content: element.innerHTML\\n', '2) content: () => element.cloneNode(true)'].join(' '));\n }\n\n var instances = elements.reduce(function (acc, reference) {\n var instance = reference && createTippy(reference, passedProps);\n\n if (instance) {\n acc.push(instance);\n }\n\n return acc;\n }, []);\n return isElement(targets) ? instances[0] : instances;\n}\n\ntippy.defaultProps = defaultProps;\ntippy.setDefaultProps = setDefaultProps;\ntippy.currentInput = currentInput;\n\nvar hideAll = function hideAll(_temp) {\n var _ref = _temp === void 0 ? {} : _temp,\n excludedReferenceOrInstance = _ref.exclude,\n duration = _ref.duration;\n\n mountedInstances.forEach(function (instance) {\n var isExcluded = false;\n\n if (excludedReferenceOrInstance) {\n isExcluded = isReferenceElement(excludedReferenceOrInstance) ? instance.reference === excludedReferenceOrInstance : instance.popper === excludedReferenceOrInstance.popper;\n }\n\n if (!isExcluded) {\n var originalDuration = instance.props.duration;\n instance.setProps({\n duration: duration\n });\n instance.hide();\n\n if (!instance.state.isDestroyed) {\n instance.setProps({\n duration: originalDuration\n });\n }\n }\n });\n};\n\nvar createSingleton = function createSingleton(tippyInstances, optionalProps) {\n if (optionalProps === void 0) {\n optionalProps = {};\n }\n /* istanbul ignore else */\n\n\n if (process.env.NODE_ENV !== \"production\") {\n errorWhen(!Array.isArray(tippyInstances), ['The first argument passed to createSingleton() must be an array of', 'tippy instances. The passed value was', String(tippyInstances)].join(' '));\n }\n\n var individualInstances = tippyInstances;\n var references = [];\n var currentTarget;\n var overrides = optionalProps.overrides;\n var interceptSetPropsCleanups = [];\n\n function setReferences() {\n references = individualInstances.map(function (instance) {\n return instance.reference;\n });\n }\n\n function enableInstances(isEnabled) {\n individualInstances.forEach(function (instance) {\n if (isEnabled) {\n instance.enable();\n } else {\n instance.disable();\n }\n });\n }\n\n function interceptSetProps(singleton) {\n return individualInstances.map(function (instance) {\n var originalSetProps = instance.setProps;\n\n instance.setProps = function (props) {\n originalSetProps(props);\n\n if (instance.reference === currentTarget) {\n singleton.setProps(props);\n }\n };\n\n return function () {\n instance.setProps = originalSetProps;\n };\n });\n }\n\n enableInstances(false);\n setReferences();\n var plugin = {\n fn: function fn() {\n return {\n onDestroy: function onDestroy() {\n enableInstances(true);\n },\n onTrigger: function onTrigger(instance, event) {\n var target = event.currentTarget;\n var index = references.indexOf(target); // bail-out\n\n if (target === currentTarget) {\n return;\n }\n\n currentTarget = target;\n var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {\n acc[prop] = individualInstances[index].props[prop];\n return acc;\n }, {});\n instance.setProps(Object.assign({}, overrideProps, {\n getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {\n return target.getBoundingClientRect();\n }\n }));\n }\n };\n }\n };\n var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ['overrides']), {\n plugins: [plugin].concat(optionalProps.plugins || []),\n triggerTarget: references\n }));\n var originalSetProps = singleton.setProps;\n\n singleton.setProps = function (props) {\n overrides = props.overrides || overrides;\n originalSetProps(props);\n };\n\n singleton.setInstances = function (nextInstances) {\n enableInstances(true);\n interceptSetPropsCleanups.forEach(function (fn) {\n return fn();\n });\n individualInstances = nextInstances;\n enableInstances(false);\n setReferences();\n interceptSetProps(singleton);\n singleton.setProps({\n triggerTarget: references\n });\n };\n\n interceptSetPropsCleanups = interceptSetProps(singleton);\n return singleton;\n};\n\nvar BUBBLING_EVENTS_MAP = {\n mouseover: 'mouseenter',\n focusin: 'focus',\n click: 'click'\n};\n/**\n * Creates a delegate instance that controls the creation of tippy instances\n * for child elements (`target` CSS selector).\n */\n\nfunction delegate(targets, props) {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== \"production\") {\n errorWhen(!(props && props.target), ['You must specity a `target` prop indicating a CSS selector string matching', 'the target elements that should receive a tippy.'].join(' '));\n }\n\n var listeners = [];\n var childTippyInstances = [];\n var disabled = false;\n var target = props.target;\n var nativeProps = removeProperties(props, ['target']);\n var parentProps = Object.assign({}, nativeProps, {\n trigger: 'manual',\n touch: false\n });\n var childProps = Object.assign({}, nativeProps, {\n showOnCreate: true\n });\n var returnValue = tippy(targets, parentProps);\n var normalizedReturnValue = normalizeToArray(returnValue);\n\n function onTrigger(event) {\n if (!event.target || disabled) {\n return;\n }\n\n var targetNode = event.target.closest(target);\n\n if (!targetNode) {\n return;\n } // Get relevant trigger with fallbacks:\n // 1. Check `data-tippy-trigger` attribute on target node\n // 2. Fallback to `trigger` passed to `delegate()`\n // 3. Fallback to `defaultProps.trigger`\n\n\n var trigger = targetNode.getAttribute('data-tippy-trigger') || props.trigger || defaultProps.trigger; // @ts-ignore\n\n if (targetNode._tippy) {\n return;\n }\n\n if (event.type === 'touchstart' && typeof childProps.touch === 'boolean') {\n return;\n }\n\n if (event.type !== 'touchstart' && trigger.indexOf(BUBBLING_EVENTS_MAP[event.type]) < 0) {\n return;\n }\n\n var instance = tippy(targetNode, childProps);\n\n if (instance) {\n childTippyInstances = childTippyInstances.concat(instance);\n }\n }\n\n function on(node, eventType, handler, options) {\n if (options === void 0) {\n options = false;\n }\n\n node.addEventListener(eventType, handler, options);\n listeners.push({\n node: node,\n eventType: eventType,\n handler: handler,\n options: options\n });\n }\n\n function addEventListeners(instance) {\n var reference = instance.reference;\n on(reference, 'touchstart', onTrigger);\n on(reference, 'mouseover', onTrigger);\n on(reference, 'focusin', onTrigger);\n on(reference, 'click', onTrigger);\n }\n\n function removeEventListeners() {\n listeners.forEach(function (_ref) {\n var node = _ref.node,\n eventType = _ref.eventType,\n handler = _ref.handler,\n options = _ref.options;\n node.removeEventListener(eventType, handler, options);\n });\n listeners = [];\n }\n\n function applyMutations(instance) {\n var originalDestroy = instance.destroy;\n var originalEnable = instance.enable;\n var originalDisable = instance.disable;\n\n instance.destroy = function (shouldDestroyChildInstances) {\n if (shouldDestroyChildInstances === void 0) {\n shouldDestroyChildInstances = true;\n }\n\n if (shouldDestroyChildInstances) {\n childTippyInstances.forEach(function (instance) {\n instance.destroy();\n });\n }\n\n childTippyInstances = [];\n removeEventListeners();\n originalDestroy();\n };\n\n instance.enable = function () {\n originalEnable();\n childTippyInstances.forEach(function (instance) {\n return instance.enable();\n });\n disabled = false;\n };\n\n instance.disable = function () {\n originalDisable();\n childTippyInstances.forEach(function (instance) {\n return instance.disable();\n });\n disabled = true;\n };\n\n addEventListeners(instance);\n }\n\n normalizedReturnValue.forEach(applyMutations);\n return returnValue;\n}\n\nvar animateFill = {\n name: 'animateFill',\n defaultValue: false,\n fn: function fn(instance) {\n var _instance$props$rende; // @ts-ignore\n\n\n if (!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy)) {\n if (process.env.NODE_ENV !== \"production\") {\n errorWhen(instance.props.animateFill, 'The `animateFill` plugin requires the default render function.');\n }\n\n return {};\n }\n\n var _getChildren = getChildren(instance.popper),\n box = _getChildren.box,\n content = _getChildren.content;\n\n var backdrop = instance.props.animateFill ? createBackdropElement() : null;\n return {\n onCreate: function onCreate() {\n if (backdrop) {\n box.insertBefore(backdrop, box.firstElementChild);\n box.setAttribute('data-animatefill', '');\n box.style.overflow = 'hidden';\n instance.setProps({\n arrow: false,\n animation: 'shift-away'\n });\n }\n },\n onMount: function onMount() {\n if (backdrop) {\n var transitionDuration = box.style.transitionDuration;\n var duration = Number(transitionDuration.replace('ms', '')); // The content should fade in after the backdrop has mostly filled the\n // tooltip element. `clip-path` is the other alternative but is not\n // well-supported and is buggy on some devices.\n\n content.style.transitionDelay = Math.round(duration / 10) + \"ms\";\n backdrop.style.transitionDuration = transitionDuration;\n setVisibilityState([backdrop], 'visible');\n }\n },\n onShow: function onShow() {\n if (backdrop) {\n backdrop.style.transitionDuration = '0ms';\n }\n },\n onHide: function onHide() {\n if (backdrop) {\n setVisibilityState([backdrop], 'hidden');\n }\n }\n };\n }\n};\n\nfunction createBackdropElement() {\n var backdrop = div();\n backdrop.className = BACKDROP_CLASS;\n setVisibilityState([backdrop], 'hidden');\n return backdrop;\n}\n\nvar mouseCoords = {\n clientX: 0,\n clientY: 0\n};\nvar activeInstances = [];\n\nfunction storeMouseCoords(_ref) {\n var clientX = _ref.clientX,\n clientY = _ref.clientY;\n mouseCoords = {\n clientX: clientX,\n clientY: clientY\n };\n}\n\nfunction addMouseCoordsListener(doc) {\n doc.addEventListener('mousemove', storeMouseCoords);\n}\n\nfunction removeMouseCoordsListener(doc) {\n doc.removeEventListener('mousemove', storeMouseCoords);\n}\n\nvar followCursor = {\n name: 'followCursor',\n defaultValue: false,\n fn: function fn(instance) {\n var reference = instance.reference;\n var doc = getOwnerDocument(instance.props.triggerTarget || reference);\n var isInternalUpdate = false;\n var wasFocusEvent = false;\n var isUnmounted = true;\n var prevProps = instance.props;\n\n function getIsInitialBehavior() {\n return instance.props.followCursor === 'initial' && instance.state.isVisible;\n }\n\n function addListener() {\n doc.addEventListener('mousemove', onMouseMove);\n }\n\n function removeListener() {\n doc.removeEventListener('mousemove', onMouseMove);\n }\n\n function unsetGetReferenceClientRect() {\n isInternalUpdate = true;\n instance.setProps({\n getReferenceClientRect: null\n });\n isInternalUpdate = false;\n }\n\n function onMouseMove(event) {\n // If the instance is interactive, avoid updating the position unless it's\n // over the reference element\n var isCursorOverReference = event.target ? reference.contains(event.target) : true;\n var followCursor = instance.props.followCursor;\n var clientX = event.clientX,\n clientY = event.clientY;\n var rect = reference.getBoundingClientRect();\n var relativeX = clientX - rect.left;\n var relativeY = clientY - rect.top;\n\n if (isCursorOverReference || !instance.props.interactive) {\n instance.setProps({\n getReferenceClientRect: function getReferenceClientRect() {\n var rect = reference.getBoundingClientRect();\n var x = clientX;\n var y = clientY;\n\n if (followCursor === 'initial') {\n x = rect.left + relativeX;\n y = rect.top + relativeY;\n }\n\n var top = followCursor === 'horizontal' ? rect.top : y;\n var right = followCursor === 'vertical' ? rect.right : x;\n var bottom = followCursor === 'horizontal' ? rect.bottom : y;\n var left = followCursor === 'vertical' ? rect.left : x;\n return {\n width: right - left,\n height: bottom - top,\n top: top,\n right: right,\n bottom: bottom,\n left: left\n };\n }\n });\n }\n }\n\n function create() {\n if (instance.props.followCursor) {\n activeInstances.push({\n instance: instance,\n doc: doc\n });\n addMouseCoordsListener(doc);\n }\n }\n\n function destroy() {\n activeInstances = activeInstances.filter(function (data) {\n return data.instance !== instance;\n });\n\n if (activeInstances.filter(function (data) {\n return data.doc === doc;\n }).length === 0) {\n removeMouseCoordsListener(doc);\n }\n }\n\n return {\n onCreate: create,\n onDestroy: destroy,\n onBeforeUpdate: function onBeforeUpdate() {\n prevProps = instance.props;\n },\n onAfterUpdate: function onAfterUpdate(_, _ref2) {\n var followCursor = _ref2.followCursor;\n\n if (isInternalUpdate) {\n return;\n }\n\n if (followCursor !== undefined && prevProps.followCursor !== followCursor) {\n destroy();\n\n if (followCursor) {\n create();\n\n if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {\n addListener();\n }\n } else {\n removeListener();\n unsetGetReferenceClientRect();\n }\n }\n },\n onMount: function onMount() {\n if (instance.props.followCursor && !wasFocusEvent) {\n if (isUnmounted) {\n onMouseMove(mouseCoords);\n isUnmounted = false;\n }\n\n if (!getIsInitialBehavior()) {\n addListener();\n }\n }\n },\n onTrigger: function onTrigger(_, event) {\n if (isMouseEvent(event)) {\n mouseCoords = {\n clientX: event.clientX,\n clientY: event.clientY\n };\n }\n\n wasFocusEvent = event.type === 'focus';\n },\n onHidden: function onHidden() {\n if (instance.props.followCursor) {\n unsetGetReferenceClientRect();\n removeListener();\n isUnmounted = true;\n }\n }\n };\n }\n};\n\nfunction getProps(props, modifier) {\n var _props$popperOptions;\n\n return {\n popperOptions: Object.assign({}, props.popperOptions, {\n modifiers: [].concat((((_props$popperOptions = props.popperOptions) == null ? void 0 : _props$popperOptions.modifiers) || []).filter(function (_ref) {\n var name = _ref.name;\n return name !== modifier.name;\n }), [modifier])\n })\n };\n}\n\nvar inlinePositioning = {\n name: 'inlinePositioning',\n defaultValue: false,\n fn: function fn(instance) {\n var reference = instance.reference;\n\n function isEnabled() {\n return !!instance.props.inlinePositioning;\n }\n\n var placement;\n var cursorRectIndex = -1;\n var isInternalUpdate = false;\n var modifier = {\n name: 'tippyInlinePositioning',\n enabled: true,\n phase: 'afterWrite',\n fn: function fn(_ref2) {\n var state = _ref2.state;\n\n if (isEnabled()) {\n if (placement !== state.placement) {\n instance.setProps({\n getReferenceClientRect: function getReferenceClientRect() {\n return _getReferenceClientRect(state.placement);\n }\n });\n }\n\n placement = state.placement;\n }\n }\n };\n\n function _getReferenceClientRect(placement) {\n return getInlineBoundingClientRect(getBasePlacement(placement), reference.getBoundingClientRect(), arrayFrom(reference.getClientRects()), cursorRectIndex);\n }\n\n function setInternalProps(partialProps) {\n isInternalUpdate = true;\n instance.setProps(partialProps);\n isInternalUpdate = false;\n }\n\n function addModifier() {\n if (!isInternalUpdate) {\n setInternalProps(getProps(instance.props, modifier));\n }\n }\n\n return {\n onCreate: addModifier,\n onAfterUpdate: addModifier,\n onTrigger: function onTrigger(_, event) {\n if (isMouseEvent(event)) {\n var rects = arrayFrom(instance.reference.getClientRects());\n var cursorRect = rects.find(function (rect) {\n return rect.left - 2 <= event.clientX && rect.right + 2 >= event.clientX && rect.top - 2 <= event.clientY && rect.bottom + 2 >= event.clientY;\n });\n cursorRectIndex = rects.indexOf(cursorRect);\n }\n },\n onUntrigger: function onUntrigger() {\n cursorRectIndex = -1;\n }\n };\n }\n};\n\nfunction getInlineBoundingClientRect(currentBasePlacement, boundingRect, clientRects, cursorRectIndex) {\n // Not an inline element, or placement is not yet known\n if (clientRects.length < 2 || currentBasePlacement === null) {\n return boundingRect;\n } // There are two rects and they are disjoined\n\n\n if (clientRects.length === 2 && cursorRectIndex >= 0 && clientRects[0].left > clientRects[1].right) {\n return clientRects[cursorRectIndex] || boundingRect;\n }\n\n switch (currentBasePlacement) {\n case 'top':\n case 'bottom':\n {\n var firstRect = clientRects[0];\n var lastRect = clientRects[clientRects.length - 1];\n var isTop = currentBasePlacement === 'top';\n var top = firstRect.top;\n var bottom = lastRect.bottom;\n var left = isTop ? firstRect.left : lastRect.left;\n var right = isTop ? firstRect.right : lastRect.right;\n var width = right - left;\n var height = bottom - top;\n return {\n top: top,\n bottom: bottom,\n left: left,\n right: right,\n width: width,\n height: height\n };\n }\n\n case 'left':\n case 'right':\n {\n var minLeft = Math.min.apply(Math, clientRects.map(function (rects) {\n return rects.left;\n }));\n var maxRight = Math.max.apply(Math, clientRects.map(function (rects) {\n return rects.right;\n }));\n var measureRects = clientRects.filter(function (rect) {\n return currentBasePlacement === 'left' ? rect.left === minLeft : rect.right === maxRight;\n });\n var _top = measureRects[0].top;\n var _bottom = measureRects[measureRects.length - 1].bottom;\n var _left = minLeft;\n var _right = maxRight;\n\n var _width = _right - _left;\n\n var _height = _bottom - _top;\n\n return {\n top: _top,\n bottom: _bottom,\n left: _left,\n right: _right,\n width: _width,\n height: _height\n };\n }\n\n default:\n {\n return boundingRect;\n }\n }\n}\n\nvar sticky = {\n name: 'sticky',\n defaultValue: false,\n fn: function fn(instance) {\n var reference = instance.reference,\n popper = instance.popper;\n\n function getReference() {\n return instance.popperInstance ? instance.popperInstance.state.elements.reference : reference;\n }\n\n function shouldCheck(value) {\n return instance.props.sticky === true || instance.props.sticky === value;\n }\n\n var prevRefRect = null;\n var prevPopRect = null;\n\n function updatePosition() {\n var currentRefRect = shouldCheck('reference') ? getReference().getBoundingClientRect() : null;\n var currentPopRect = shouldCheck('popper') ? popper.getBoundingClientRect() : null;\n\n if (currentRefRect && areRectsDifferent(prevRefRect, currentRefRect) || currentPopRect && areRectsDifferent(prevPopRect, currentPopRect)) {\n if (instance.popperInstance) {\n instance.popperInstance.update();\n }\n }\n\n prevRefRect = currentRefRect;\n prevPopRect = currentPopRect;\n\n if (instance.state.isMounted) {\n requestAnimationFrame(updatePosition);\n }\n }\n\n return {\n onMount: function onMount() {\n if (instance.props.sticky) {\n updatePosition();\n }\n }\n };\n }\n};\n\nfunction areRectsDifferent(rectA, rectB) {\n if (rectA && rectB) {\n return rectA.top !== rectB.top || rectA.right !== rectB.right || rectA.bottom !== rectB.bottom || rectA.left !== rectB.left;\n }\n\n return true;\n}\n\ntippy.setDefaultProps({\n render: render\n});\nexport default tippy;\nexport { animateFill, createSingleton, delegate, followCursor, hideAll, inlinePositioning, ROUND_ARROW as roundArrow, sticky };"],"sourceRoot":""}