Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@preline/select

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preline/select - npm Package Compare versions

Comparing version 2.4.1 to 2.5.0

51

index.d.ts

@@ -30,2 +30,9 @@ export interface IBasePlugin<O, E> {

}
export interface IApiFieldMap {
id: string;
title: string;
icon?: string | null;
description?: string | null;
[key: string]: unknown;
}
export interface ISelectOptions {

@@ -40,2 +47,9 @@ value?: string | string[];

wrapperClasses?: string;
apiUrl?: string | null;
apiQuery?: string | null;
apiOptions?: RequestInit | null;
apiDataPart?: string | null;
apiSearchQueryKey?: string | null;
apiFieldsMap?: IApiFieldMap | null;
apiIconTag?: string | null;
toggleTag?: string;

@@ -52,2 +66,3 @@ toggleClasses?: string;

tagsItemClasses?: string;
tagsInputId?: string;
tagsInputClasses?: string;

@@ -61,7 +76,14 @@ dropdownTag?: string;

dropdownSpace: number;
dropdownPlacement: string | null;
dropdownScope: "window" | "parent";
extraMarkup?: string | string[] | null;
searchTemplate?: string;
searchWrapperTemplate?: string;
searchId?: string;
searchLimit?: number | typeof Infinity;
isSearchDirectMatch?: boolean;
searchClasses?: string;
searchWrapperClasses?: string;
searchPlaceholder?: string;
searchNoResultTemplate?: string | null;
searchNoResultText?: string | null;

@@ -96,2 +118,9 @@ searchNoResultClasses?: string | null;

selectedItems: string[];
private readonly apiUrl;
private readonly apiQuery;
private readonly apiOptions;
private readonly apiDataPart;
private readonly apiSearchQueryKey;
private readonly apiFieldsMap;
private readonly apiIconTag;
private readonly toggleTag;

@@ -106,2 +135,3 @@ private readonly toggleClasses;

private readonly tagsItemClasses;
private readonly tagsInputId;
private readonly tagsInputClasses;

@@ -112,6 +142,13 @@ private readonly dropdownTag;

dropdownSpace: number | null;
readonly dropdownPlacement: string | null;
readonly dropdownScope: "window" | "parent";
private readonly searchTemplate;
private readonly searchWrapperTemplate;
private readonly searchPlaceholder;
private readonly searchId;
private readonly searchLimit;
private readonly isSearchDirectMatch;
private readonly searchClasses;
private readonly searchWrapperClasses;
private readonly searchNoResultTemplate;
private readonly searchNoResultText;

@@ -130,2 +167,3 @@ private readonly searchNoResultClasses;

private dropdown;
private popperInstance;
private searchWrapper;

@@ -138,2 +176,4 @@ private search;

private tagsInputHelper;
private remoteOptions;
private optionId;
constructor(el: HTMLElement, options?: ISelectOptions);

@@ -155,4 +195,12 @@ setValue(val: string | string[]): void;

private buildDropdown;
private buildPopper;
private updateDropdownWidth;
private buildSearch;
private buildOption;
private buildOptionFromRemoteData;
private buildOptionsFromRemoteData;
private optionsFromRemoteData;
private apiRequest;
private sortElements;
private remoteSearch;
private destroyOption;

@@ -171,2 +219,4 @@ private buildOriginalOption;

private setNewValue;
private stringFromValueBasic;
private stringFromValueRemoteData;
private stringFromValue;

@@ -179,2 +229,3 @@ private selectSingleItem;

private eraseToggleTitle;
private toggleFn;
destroy(): void;

@@ -181,0 +232,0 @@ open(): boolean;

13

index.js

@@ -1,5 +0,5 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(self,(()=>(()=>{"use strict";var t={223:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BREAKPOINTS=e.COMBO_BOX_ACCESSIBILITY_KEY_SET=e.SELECT_ACCESSIBILITY_KEY_SET=e.TABS_ACCESSIBILITY_KEY_SET=e.OVERLAY_ACCESSIBILITY_KEY_SET=e.DROPDOWN_ACCESSIBILITY_KEY_SET=e.POSITIONS=void 0,e.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},e.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","Home","End","Enter"],e.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],e.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],e.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Tab"],e.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],e.BREAKPOINTS={sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},961:(t,e)=>{
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(self,(()=>(()=>{"use strict";var t={223:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BREAKPOINTS=e.COMBO_BOX_ACCESSIBILITY_KEY_SET=e.SELECT_ACCESSIBILITY_KEY_SET=e.TABS_ACCESSIBILITY_KEY_SET=e.OVERLAY_ACCESSIBILITY_KEY_SET=e.DROPDOWN_ACCESSIBILITY_KEY_SET=e.POSITIONS=void 0,e.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},e.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","Home","End","Enter"],e.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],e.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],e.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Tab"],e.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],e.BREAKPOINTS={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},961:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e,i){this.el=t,this.options=e,this.events=i,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var i;t.push({id:(null===(i=null==e?void 0:e.el)||void 0===i?void 0:i.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=i},442:function(t,e,i){
/*
* HSBasePlugin
* @version: 2.4.1
* HSSelect
* @version: 2.5.0
* @author: Preline Labs Ltd.

@@ -9,6 +9,5 @@ * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)

*/
Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e,i){this.el=t,this.options=e,this.events=i,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var i;t.push({id:(null===(i=null==e?void 0:e.el)||void 0===i?void 0:i.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=i},442:function(t,e,i){
var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),s=this&&this.__assign||function(){return s=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)},r=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,s){function r(t){try{a(n.next(t))}catch(t){s(t)}}function l(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,l)}a((n=n.apply(t,e||[])).next())}))},l=this&&this.__generator||function(t,e){var i,n,o,s,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(l){return function(a){return function(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(r=0)),r;)try{if(i=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){r.label=l[1];break}if(6===l[0]&&r.label<o[1]){r.label=o[1],o=l;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(l);break}o[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(t){l=[6,t],n=0}finally{i=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}},a=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var n,o=0,s=e.length;o<s;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},d=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var c=i(292),u=d(i(961)),p=i(223),h=function(t){function e(e,i){var n,o,r=t.call(this,e,i)||this;r.optionId=0;var l=e.getAttribute("data-hs-select"),a=l?JSON.parse(l):{},d=s(s({},a),i),c={items:", ",betweenItemsAndCounter:"and"};return r.value=(null==d?void 0:d.value)||r.el.value||null,r.placeholder=(null==d?void 0:d.placeholder)||"Select...",r.hasSearch=(null==d?void 0:d.hasSearch)||!1,r.preventSearchFocus=(null==d?void 0:d.preventSearchFocus)||!1,r.mode=(null==d?void 0:d.mode)||"default",r.viewport=void 0!==(null==d?void 0:d.viewport)?document.querySelector(null==d?void 0:d.viewport):null,r.isOpened=Boolean(null==d?void 0:d.isOpened)||!1,r.isMultiple=r.el.hasAttribute("multiple")||!1,r.isDisabled=r.el.hasAttribute("disabled")||!1,r.selectedItems=[],r.apiUrl=(null==d?void 0:d.apiUrl)||null,r.apiQuery=(null==d?void 0:d.apiQuery)||null,r.apiOptions=(null==d?void 0:d.apiOptions)||null,r.apiSearchQueryKey=(null==d?void 0:d.apiSearchQueryKey)||null,r.apiDataPart=(null==d?void 0:d.apiDataPart)||null,r.apiFieldsMap=(null==d?void 0:d.apiFieldsMap)||null,r.apiIconTag=(null==d?void 0:d.apiIconTag)||null,r.wrapperClasses=(null==d?void 0:d.wrapperClasses)||null,r.toggleTag=(null==d?void 0:d.toggleTag)||null,r.toggleClasses=(null==d?void 0:d.toggleClasses)||null,r.toggleSeparators=null!==(n=s(s({},c),null==d?void 0:d.toggleSeparators))&&void 0!==n?n:c,r.toggleCountText=(null==d?void 0:d.toggleCountText)||null,r.toggleCountTextMinItems=(null==d?void 0:d.toggleCountTextMinItems)||1,r.toggleCountTextMode=(null==d?void 0:d.toggleCountTextMode)||"countAfterLimit",r.tagsItemTemplate=(null==d?void 0:d.tagsItemTemplate)||null,r.tagsItemClasses=(null==d?void 0:d.tagsItemClasses)||null,r.tagsInputId=(null==d?void 0:d.tagsInputId)||null,r.tagsInputClasses=(null==d?void 0:d.tagsInputClasses)||null,r.dropdownTag=(null==d?void 0:d.dropdownTag)||null,r.dropdownClasses=(null==d?void 0:d.dropdownClasses)||null,r.dropdownDirectionClasses=(null==d?void 0:d.dropdownDirectionClasses)||null,r.dropdownSpace=(null==d?void 0:d.dropdownSpace)||10,r.dropdownPlacement=(null==d?void 0:d.dropdownPlacement)||null,r.dropdownScope=(null==d?void 0:d.dropdownScope)||"parent",r.searchTemplate=(null==d?void 0:d.searchTemplate)||null,r.searchWrapperTemplate=(null==d?void 0:d.searchWrapperTemplate)||null,r.searchWrapperClasses=(null==d?void 0:d.searchWrapperClasses)||"bg-white p-2 sticky top-0",r.searchId=(null==d?void 0:d.searchId)||null,r.searchLimit=(null==d?void 0:d.searchLimit)||1/0,r.isSearchDirectMatch=void 0===(null==d?void 0:d.isSearchDirectMatch)||(null==d?void 0:d.isSearchDirectMatch),r.searchClasses=(null==d?void 0:d.searchClasses)||"block w-[calc(100%-2rem)] text-sm border-gray-200 rounded-md focus:border-blue-500 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 py-2 px-3 my-2 mx-4",r.searchPlaceholder=(null==d?void 0:d.searchPlaceholder)||"Search...",r.searchNoResultTemplate=(null==d?void 0:d.searchNoResultTemplate)||"<span></span>",r.searchNoResultText=(null==d?void 0:d.searchNoResultText)||"No results found",r.searchNoResultClasses=(null==d?void 0:d.searchNoResultClasses)||"px-4 text-sm text-gray-800 dark:text-neutral-200",r.optionTemplate=(null==d?void 0:d.optionTemplate)||null,r.optionTag=(null==d?void 0:d.optionTag)||null,r.optionClasses=(null==d?void 0:d.optionClasses)||null,r.extraMarkup=(null==d?void 0:d.extraMarkup)||null,r.descriptionClasses=(null==d?void 0:d.descriptionClasses)||null,r.iconClasses=(null==d?void 0:d.iconClasses)||null,r.isAddTagOnEnter=null===(o=null==d?void 0:d.isAddTagOnEnter)||void 0===o||o,r.animationInProcess=!1,r.selectOptions=[],r.remoteOptions=[],r.tagsInputHelper=null,r.init(),r}return o(e,t),e.prototype.setValue=function(t){this.value=t,this.clearSelections(),Array.isArray(t)?(this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder,this.unselectMultipleItems(),this.selectMultipleItems()):(this.setToggleTitle(),this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.selectSingleItem())},e.prototype.init=function(){this.createCollection(window.$hsSelectCollection,this),this.build()},e.prototype.build=function(){var t=this;if(this.el.style.display="none",this.el.children&&Array.from(this.el.children).filter((function(t){return t.value&&""!==t.value})).forEach((function(e){var i=e.getAttribute("data-hs-select-option");t.selectOptions=a(a([],t.selectOptions,!0),[{title:e.textContent,val:e.value,disabled:e.disabled,options:"undefined"!==i?JSON.parse(i):null}],!1)})),this.isMultiple){var e=Array.from(this.el.children).filter((function(t){return t.selected}));if(e){var i=[];e.forEach((function(t){i.push(t.value)})),this.value=i}}this.buildWrapper(),"tags"===this.mode?this.buildTags():this.buildToggle(),this.buildDropdown(),this.extraMarkup&&this.buildExtraMarkup()},e.prototype.buildWrapper=function(){var t=this;this.wrapper=document.createElement("div"),this.wrapper.classList.add("hs-select","relative"),"tags"===this.mode&&this.wrapper.addEventListener("click",(function(e){e.target.closest("[data-hs-select-dropdown]")||e.target.closest("[data-tag-value]")||t.tagsInput.focus()})),this.wrapperClasses&&(0,c.classToClassList)(this.wrapperClasses,this.wrapper),this.el.before(this.wrapper),this.wrapper.append(this.el)},e.prototype.buildExtraMarkup=function(){var t=this,e=function(e){var i=(0,c.htmlToElement)(e);return t.wrapper.append(i),i},i=function(e){e.classList.contains("--prevent-click")||e.addEventListener("click",(function(e){e.stopPropagation(),t.toggleFn()}))};if(Array.isArray(this.extraMarkup))this.extraMarkup.forEach((function(t){var n=e(t);i(n)}));else{var n=e(this.extraMarkup);i(n)}},e.prototype.buildToggle=function(){var t,e,i,n,o=this;this.toggleTextWrapper=document.createElement("span"),this.toggleTextWrapper.classList.add("truncate"),this.toggle=(0,c.htmlToElement)(this.toggleTag||"<div></div>"),i=this.toggle.querySelector("[data-icon]"),n=this.toggle.querySelector("[data-title]"),!this.isMultiple&&i&&this.setToggleIcon(),!this.isMultiple&&n&&this.setToggleTitle(),this.isMultiple?this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder:this.toggleTextWrapper.innerHTML=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder,n||this.toggle.append(this.toggleTextWrapper),this.toggleClasses&&(0,c.classToClassList)(this.toggleClasses,this.toggle),this.isDisabled&&this.toggle.classList.add("disabled"),this.wrapper&&this.wrapper.append(this.toggle),(null===(e=this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.isOpened?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),this.toggle.addEventListener("click",(function(){if(o.isDisabled)return!1;o.toggleFn()}))},e.prototype.setToggleIcon=function(){var t,e=this.getItemByValue(this.value),i=this.toggle.querySelector("[data-icon]");if(i.innerHTML="",i){var n=(0,c.htmlToElement)(this.apiUrl&&this.apiIconTag?this.apiIconTag||"":(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.icon)||"");this.value&&this.apiUrl&&this.apiIconTag&&e[this.apiFieldsMap.icon]&&(n.src=e[this.apiFieldsMap.icon]||""),i.append(n),n&&(null==n?void 0:n.src)?i.classList.remove("hidden"):i.classList.add("hidden")}},e.prototype.setToggleTitle=function(){var t,e=this.toggle.querySelector("[data-title]");if(e.classList.add("truncate"),e.innerHTML="",e){var i=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder;e.innerHTML=i,this.toggle.append(e)}},e.prototype.buildTags=function(){this.isDisabled&&this.wrapper.classList.add("disabled"),this.buildTagsInput(),this.setTagsItems()},e.prototype.reassignTagsInputPlaceholder=function(t){this.tagsInput.placeholder=t,this.tagsInputHelper.innerHTML=t,this.calculateInputWidth()},e.prototype.buildTagsItem=function(t){var e,i,n,o,s,r,l,a,d=this,u=this.getItemByValue(t),p=document.createElement("div");if(p.setAttribute("data-tag-value",t),this.tagsItemClasses&&(0,c.classToClassList)(this.tagsItemClasses,p),this.tagsItemTemplate&&(s=(0,c.htmlToElement)(this.tagsItemTemplate),p.append(s)),(null===(e=null==u?void 0:u.options)||void 0===e?void 0:e.icon)||this.apiIconTag){var h=(0,c.htmlToElement)(this.apiUrl&&this.apiIconTag?this.apiIconTag:null===(i=null==u?void 0:u.options)||void 0===i?void 0:i.icon);this.apiUrl&&this.apiIconTag&&u[this.apiFieldsMap.icon]&&(h.src=u[this.apiFieldsMap.icon]||""),(a=s?s.querySelector("[data-icon]"):document.createElement("span")).append(h),s||p.append(a)}!s||!s.querySelector("[data-icon]")||(null===(n=null==u?void 0:u.options)||void 0===n?void 0:n.icon)||this.apiUrl||this.apiIconTag||u[null===(o=this.apiFieldsMap)||void 0===o?void 0:o.icon]||s.querySelector("[data-icon]").classList.add("hidden"),(r=s?s.querySelector("[data-title]"):document.createElement("span")).textContent=u.title||"",s||p.append(r),s?l=s.querySelector("[data-remove]"):((l=document.createElement("span")).textContent="X",p.append(l)),l.addEventListener("click",(function(){d.value=d.value.filter((function(e){return e!==t})),d.selectedItems=d.selectedItems.filter((function(e){return e!==t})),d.value.length||d.reassignTagsInputPlaceholder(d.placeholder),d.unselectMultipleItems(),d.selectMultipleItems(),p.remove()})),this.wrapper.append(p)},e.prototype.getItemByValue=function(t){var e=this;return this.apiUrl?this.remoteOptions.find((function(i){return i[e.apiFieldsMap.title]===t})):this.selectOptions.find((function(e){return e.val===t}))},e.prototype.setTagsItems=function(){var t=this;this.value&&this.value.forEach((function(e){t.selectedItems.includes(e)||t.buildTagsItem(e),t.selectedItems=t.selectedItems.includes(e)?t.selectedItems:a(a([],t.selectedItems,!0),[e],!1)}))},e.prototype.buildTagsInput=function(){var t=this;this.tagsInput=document.createElement("input"),this.tagsInputId&&(this.tagsInput.id=this.tagsInputId),this.tagsInputClasses&&(0,c.classToClassList)(this.tagsInputClasses,this.tagsInput),this.tagsInput.addEventListener("focus",(function(){t.isOpened||t.open()})),this.tagsInput.addEventListener("input",(function(){return t.calculateInputWidth()})),this.tagsInput.addEventListener("input",(0,c.debounce)((function(e){return t.searchOptions(e.target.value)}))),this.tagsInput.addEventListener("keydown",(function(e){if("Enter"===e.key&&t.isAddTagOnEnter){var i=e.target.value;if(t.selectOptions.find((function(t){return t.val===i})))return!1;t.addSelectOption(i,i),t.buildOption(i,i),t.dropdown.querySelector('[data-value="'.concat(i,'"]')).click(),t.resetTagsInputField()}})),this.wrapper.append(this.tagsInput),setTimeout((function(){t.adjustInputWidth(),t.reassignTagsInputPlaceholder(t.value.length?"":t.placeholder)}))},e.prototype.buildDropdown=function(){var t=this;this.dropdown=(0,c.htmlToElement)(this.dropdownTag||"<div></div>"),this.dropdown.setAttribute("data-hs-select-dropdown",""),"parent"===this.dropdownScope&&this.dropdown.classList.add("absolute","top-full"),this.dropdown.role="listbox",this.dropdown.tabIndex=-1,this.dropdown.ariaOrientation="vertical",this.isOpened||this.dropdown.classList.add("hidden"),this.dropdownClasses&&(0,c.classToClassList)(this.dropdownClasses,this.dropdown),this.wrapper&&this.wrapper.append(this.dropdown),this.dropdown&&this.hasSearch&&this.buildSearch(),this.selectOptions&&this.selectOptions.forEach((function(e,i){return t.buildOption(e.title,e.val,e.disabled,e.selected,e.options,"".concat(i))})),this.apiUrl&&this.optionsFromRemoteData(),"window"===this.dropdownScope&&this.buildPopper()},e.prototype.buildPopper=function(){"undefined"!=typeof Popper&&Popper.createPopper&&(document.body.appendChild(this.dropdown),this.popperInstance=Popper.createPopper("tags"===this.mode?this.wrapper:this.toggle,this.dropdown,{placement:p.POSITIONS[this.dropdownPlacement]||"bottom",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,5]}}]}))},e.prototype.updateDropdownWidth=function(){var t="tags"===this.mode?this.wrapper:this.toggle;this.dropdown.style.width="".concat(t.clientWidth,"px")},e.prototype.buildSearch=function(){var t,e=this;this.searchWrapper=(0,c.htmlToElement)(this.searchWrapperTemplate||"<div></div>"),this.searchWrapperClasses&&(0,c.classToClassList)(this.searchWrapperClasses,this.searchWrapper),t=this.searchWrapper.querySelector("[data-input]");var i=(0,c.htmlToElement)(this.searchTemplate||'<input type="text" />');this.search="INPUT"===i.tagName?i:i.querySelector(":scope input"),this.search.placeholder=this.searchPlaceholder,this.searchClasses&&(0,c.classToClassList)(this.searchClasses,this.search),this.searchId&&(this.search.id=this.searchId),this.search.addEventListener("input",(0,c.debounce)((function(t){e.apiUrl?e.remoteSearch(t.target.value):e.searchOptions(t.target.value)}))),t?t.append(i):this.searchWrapper.append(i),this.dropdown.append(this.searchWrapper)},e.prototype.buildOption=function(t,e,i,n,o,s,r){var l,d=this;void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===s&&(s="1");var u=null,p=null,h=(0,c.htmlToElement)(this.optionTag||"<div></div>");if(h.setAttribute("data-value",e),h.setAttribute("data-title-value",t),h.setAttribute("tabIndex",s),h.classList.add("cursor-pointer"),h.setAttribute("data-id",r||"".concat(this.optionId)),r||this.optionId++,i&&h.classList.add("disabled"),n&&(this.isMultiple?this.value=a(a([],this.value,!0),[e],!1):this.value=e),this.optionTemplate&&(u=(0,c.htmlToElement)(this.optionTemplate),h.append(u)),u?u.querySelector("[data-title]").textContent=t||"":h.textContent=t||"",o){if(o.icon){var g=(0,c.htmlToElement)(null!==(l=this.apiIconTag)&&void 0!==l?l:o.icon);if(g.classList.add("max-w-full"),this.apiUrl&&(g.setAttribute("alt",t),g.setAttribute("src",o.icon)),u)u.querySelector("[data-icon]").append(g);else{var v=(0,c.htmlToElement)("<div></div>");this.iconClasses&&(0,c.classToClassList)(this.iconClasses,v),v.append(g),h.append(v)}}if(o.description)if(u)(p=u.querySelector("[data-description]"))&&p.append(o.description);else{var f=(0,c.htmlToElement)("<div></div>");f.textContent=o.description,this.descriptionClasses&&(0,c.classToClassList)(this.descriptionClasses,f),h.append(f)}}u&&u.querySelector("[data-icon]")&&!o&&!(null==o?void 0:o.icon)&&u.querySelector("[data-icon]").classList.add("hidden"),this.value&&(this.isMultiple?this.value.includes(e):this.value===e)&&h.classList.add("selected"),i||h.addEventListener("click",(function(){return d.onSelectOption(e)})),this.optionClasses&&(0,c.classToClassList)(this.optionClasses,h),this.dropdown&&this.dropdown.append(h),n&&this.setNewValue()},e.prototype.buildOptionFromRemoteData=function(t,e,i,n,o,s,r){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===o&&(o="1"),o?this.buildOption(t,e,i,n,r,o,s):alert("ID parameter is required for generating remote options! Please check your API endpoint have it.")},e.prototype.buildOptionsFromRemoteData=function(t){var e=this;t.forEach((function(t,i){var n=null,o="",s={id:"",title:"",icon:null,description:null,rest:{}};Object.keys(t).forEach((function(i){var r;t[e.apiFieldsMap.id]&&(n=t[e.apiFieldsMap.id]),t[e.apiFieldsMap.title]&&(o=t[e.apiFieldsMap.title]),t[e.apiFieldsMap.icon]&&(s.icon=t[e.apiFieldsMap.icon]),t[null===(r=e.apiFieldsMap)||void 0===r?void 0:r.description]&&(s.description=t[e.apiFieldsMap.description]),s.rest[i]=t[i]})),e.buildOriginalOption(o,o,n,!1,!1,s),e.buildOptionFromRemoteData(o,o,!1,!1,"".concat(i),n,s)})),this.sortElements(this.el,"option"),this.sortElements(this.dropdown,"[data-value]")},e.prototype.optionsFromRemoteData=function(){return r(this,arguments,void 0,(function(t){var e;return void 0===t&&(t=""),l(this,(function(i){switch(i.label){case 0:return[4,this.apiRequest(t)];case 1:return e=i.sent(),this.remoteOptions=e,e.length?this.buildOptionsFromRemoteData(this.remoteOptions):console.log("There is no data were responded!"),[2]}}))}))},e.prototype.apiRequest=function(){return r(this,arguments,void 0,(function(t){var e,i,n,o,s,r;return void 0===t&&(t=""),l(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),e=this.apiUrl,i=this.apiSearchQueryKey?"".concat(this.apiSearchQueryKey,"=").concat(t.toLowerCase()):null,n="".concat(this.apiQuery),o=this.apiOptions||{},i&&(e+="?".concat(i)),this.apiQuery&&(e+="".concat(i?"&":"?").concat(n)),[4,fetch(e,o)];case 1:return[4,l.sent().json()];case 2:return s=l.sent(),[2,this.apiDataPart?s[this.apiDataPart]:s];case 3:return r=l.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},e.prototype.sortElements=function(t,e){var i=Array.from(t.querySelectorAll(e));i.sort((function(t,e){var i=t.classList.contains("selected")||t.hasAttribute("selected"),n=e.classList.contains("selected")||e.hasAttribute("selected");return i&&!n?-1:!i&&n?1:0})),i.forEach((function(e){return t.appendChild(e)}))},e.prototype.remoteSearch=function(t){return r(this,void 0,void 0,(function(){var e,i,n,o,s=this;return l(this,(function(r){switch(r.label){case 0:return[4,this.apiRequest(t)];case 1:return e=r.sent(),this.remoteOptions=e,i=e.map((function(t){return"".concat(t.id)})),null,o=this.dropdown.querySelectorAll("[data-value]"),this.el.querySelectorAll("[data-hs-select-option]").forEach((function(t){var e,n=t.getAttribute("data-id");i.includes(n)||(null===(e=s.value)||void 0===e?void 0:e.includes(t.value))||s.destroyOriginalOption(t.value)})),o.forEach((function(t){var e,n=t.getAttribute("data-id");i.includes(n)||(null===(e=s.value)||void 0===e?void 0:e.includes(t.getAttribute("data-value")))?i=i.filter((function(t){return t!==n})):s.destroyOption(t.getAttribute("data-value"))})),(n=e.filter((function(t){return i.includes("".concat(t.id))}))).length?this.buildOptionsFromRemoteData(n):console.log("There is no data were responded!"),[2]}}))}))},e.prototype.destroyOption=function(t){var e=this.dropdown.querySelector('[data-value="'.concat(t,'"]'));if(!e)return!1;e.remove()},e.prototype.buildOriginalOption=function(t,e,i,n,o,s){var r=(0,c.htmlToElement)("<option></option>");r.setAttribute("value",e),n&&r.setAttribute("disabled","disabled"),o&&r.setAttribute("selected","selected"),i&&r.setAttribute("data-id",i),r.setAttribute("data-hs-select-option",JSON.stringify(s)),r.innerText=t,this.el.append(r)},e.prototype.destroyOriginalOption=function(t){var e=this.el.querySelector('[value="'.concat(t,'"]'));if(!e)return!1;e.remove()},e.prototype.buildTagsInputHelper=function(){this.tagsInputHelper=document.createElement("span"),this.tagsInputHelper.style.fontSize=window.getComputedStyle(this.tagsInput).fontSize,this.tagsInputHelper.style.fontFamily=window.getComputedStyle(this.tagsInput).fontFamily,this.tagsInputHelper.style.fontWeight=window.getComputedStyle(this.tagsInput).fontWeight,this.tagsInputHelper.style.letterSpacing=window.getComputedStyle(this.tagsInput).letterSpacing,this.tagsInputHelper.style.visibility="hidden",this.tagsInputHelper.style.whiteSpace="pre",this.tagsInputHelper.style.position="absolute",this.wrapper.appendChild(this.tagsInputHelper)},e.prototype.calculateInputWidth=function(){this.tagsInputHelper.textContent=this.tagsInput.value||this.tagsInput.placeholder;var t=parseInt(window.getComputedStyle(this.tagsInput).paddingLeft)+parseInt(window.getComputedStyle(this.tagsInput).paddingRight),e=parseInt(window.getComputedStyle(this.tagsInput).borderLeftWidth)+parseInt(window.getComputedStyle(this.tagsInput).borderRightWidth),i=this.tagsInputHelper.offsetWidth+t+e,n=this.wrapper.offsetWidth-(parseInt(window.getComputedStyle(this.wrapper).paddingLeft)+parseInt(window.getComputedStyle(this.wrapper).paddingRight));this.tagsInput.style.width="".concat(Math.min(i,n)+2,"px")},e.prototype.adjustInputWidth=function(){this.buildTagsInputHelper(),this.calculateInputWidth()},e.prototype.onSelectOption=function(t){var e=this;if(this.clearSelections(),this.isMultiple?(this.value=this.value.includes(t)?Array.from(this.value).filter((function(e){return e!==t})):a(a([],Array.from(this.value),!0),[t],!1),this.selectMultipleItems(),this.setNewValue()):(this.value=t,this.selectSingleItem(),this.setNewValue()),this.fireEvent("change",this.value),(0,c.dispatch)("change.hs.select",this.el,this.value),"tags"===this.mode){var i=this.selectedItems.filter((function(t){return!e.value.includes(t)}));i.length&&i.forEach((function(t){e.selectedItems=e.selectedItems.filter((function(e){return e!==t})),e.wrapper.querySelector('[data-tag-value="'.concat(t,'"]')).remove()})),this.resetTagsInputField()}this.isMultiple||(this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.close()),this.value.length||"tags"!==this.mode||this.reassignTagsInputPlaceholder(this.placeholder),this.isOpened&&"tags"===this.mode&&this.tagsInput&&this.tagsInput.focus(),this.triggerChangeEventForNativeSelect()},e.prototype.triggerChangeEventForNativeSelect=function(){var t=new Event("change",{bubbles:!0});this.el.dispatchEvent(t)},e.prototype.addSelectOption=function(t,e,i,n,o){this.selectOptions=a(a([],this.selectOptions,!0),[{title:t,val:e,disabled:i,selected:n,options:o}],!1)},e.prototype.removeSelectOption=function(t,e){if(void 0===e&&(e=!1),!!!this.selectOptions.some((function(e){return e.val===t})))return!1;this.selectOptions=this.selectOptions.filter((function(e){return e.val!==t})),this.value=e?this.value.filter((function(e){return e!==t})):t},e.prototype.resetTagsInputField=function(){this.tagsInput.value="",this.reassignTagsInputPlaceholder(""),this.searchOptions("")},e.prototype.clearSelections=function(){Array.from(this.dropdown.children).forEach((function(t){t.classList.contains("selected")&&t.classList.remove("selected")})),Array.from(this.el.children).forEach((function(t){t.selected&&(t.selected=!1)}))},e.prototype.setNewValue=function(){var t;"tags"===this.mode?this.setTagsItems():(null===(t=this.value)||void 0===t?void 0:t.length)?this.toggleTextWrapper.innerHTML=this.stringFromValue():this.toggleTextWrapper.innerHTML=this.placeholder},e.prototype.stringFromValueBasic=function(t){var e=this,i=[],n="";if(t.forEach((function(t){e.isMultiple?e.value.includes(t.val)&&i.push(t.title):e.value===t.val&&i.push(t.title)})),this.toggleCountText&&""!==this.toggleCountText&&i.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){var o=i.slice(0,this.toggleCountTextMinItems-1);n="".concat(o.join(this.toggleSeparators.items)," ").concat(this.toggleSeparators.betweenItemsAndCounter," ").concat(i.length-o.length," ").concat(this.toggleCountText)}else n="".concat(i.length," ").concat(this.toggleCountText);else n=i.join(this.toggleSeparators.items);return n},e.prototype.stringFromValueRemoteData=function(){var t=this,e=this.dropdown.querySelectorAll("[data-title-value]"),i=[],n="";if(e.forEach((function(e){var n=e.getAttribute("data-value");t.isMultiple?t.value.includes(n)&&i.push(n):t.value===n&&i.push(n)})),this.toggleCountText&&""!==this.toggleCountText&&i.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){var o=i.slice(0,this.toggleCountTextMinItems-1);n="".concat(o.join(this.toggleSeparators.items)," ").concat(this.toggleSeparators.betweenItemsAndCounter," ").concat(i.length-o.length," ").concat(this.toggleCountText)}else n="".concat(i.length," ").concat(this.toggleCountText);else n=i.join(this.toggleSeparators.items);return n},e.prototype.stringFromValue=function(){return this.apiUrl?this.stringFromValueRemoteData():this.stringFromValueBasic(this.selectOptions)},e.prototype.selectSingleItem=function(){var t=this;Array.from(this.el.children).find((function(e){return t.value===e.value})).selected=!0;var e=Array.from(this.dropdown.children).find((function(e){return t.value===e.getAttribute("data-value")}));e&&e.classList.add("selected")},e.prototype.selectMultipleItems=function(){var t=this;Array.from(this.dropdown.children).filter((function(e){return t.value.includes(e.getAttribute("data-value"))})).forEach((function(t){return t.classList.add("selected")})),Array.from(this.el.children).filter((function(e){return t.value.includes(e.value)})).forEach((function(t){return t.selected=!0}))},e.prototype.unselectMultipleItems=function(){Array.from(this.dropdown.children).forEach((function(t){return t.classList.remove("selected")})),Array.from(this.el.children).forEach((function(t){return t.selected=!1}))},e.prototype.searchOptions=function(t){var e=this;this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null),this.searchNoResult=(0,c.htmlToElement)(this.searchNoResultTemplate),this.searchNoResult.innerText=this.searchNoResultText,(0,c.classToClassList)(this.searchNoResultClasses,this.searchNoResult);var i,n=this.dropdown.querySelectorAll("[data-value]"),o=!1;this.searchLimit&&(i=0),n.forEach((function(n){var s=n.getAttribute("data-title-value").toLocaleLowerCase(),r=t?t.split("").map((function(t){return t.match(/\w/)?"".concat(t,"[\\W_]*"):"\\W*"})).join(""):"",l=new RegExp(r,"i"),a=e.isSearchDirectMatch,d=s.trim();(t?a?!d.toLowerCase().includes(t.toLowerCase())||i>=e.searchLimit:!l.test(d)||i>=e.searchLimit:!l.test(d))?n.classList.add("hidden"):(n.classList.remove("hidden"),o=!0,e.searchLimit&&i++)})),o||this.dropdown.append(this.searchNoResult)},e.prototype.eraseToggleIcon=function(){var t=this.toggle.querySelector("[data-icon]");t&&(t.innerHTML=null,t.classList.add("hidden"))},e.prototype.eraseToggleTitle=function(){var t=this.toggle.querySelector("[data-title]");t?t.innerHTML=this.placeholder:this.toggleTextWrapper.innerHTML=this.placeholder},e.prototype.toggleFn=function(){this.isOpened?this.close():this.open()},e.prototype.destroy=function(){var t=this.el.parentElement.parentElement;this.el.classList.remove("hidden"),this.el.style.display="",t.prepend(this.el),t.querySelector(".hs-select").remove(),this.wrapper=null},e.prototype.open=function(){var t,e=this,i=(null===(t=null===window||void 0===window?void 0:window.$hsSelectCollection)||void 0===t?void 0:t.find((function(t){return t.element.isOpened})))||null;if(i&&i.element.close(),this.animationInProcess)return!1;this.animationInProcess=!0,"window"===this.dropdownScope&&this.dropdown.classList.add("invisible"),this.dropdown.classList.remove("hidden"),this.recalculateDirection(),setTimeout((function(){var t;(null===(t=null==e?void 0:e.toggle)||void 0===t?void 0:t.ariaExpanded)&&(e.toggle.ariaExpanded="true"),e.wrapper.classList.add("active"),e.dropdown.classList.add("opened"),e.dropdown.classList.contains("w-full")&&"window"===e.dropdownScope&&e.updateDropdownWidth(),e.popperInstance&&"window"===e.dropdownScope&&(e.popperInstance.update(),e.dropdown.classList.remove("invisible")),e.hasSearch&&!e.preventSearchFocus&&e.search.focus(),e.animationInProcess=!1})),this.isOpened=!0},e.prototype.close=function(){var t,e,i,n,o=this;if(this.animationInProcess)return!1;this.animationInProcess=!0,(null===(t=null==this?void 0:this.toggle)||void 0===t?void 0:t.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.wrapper.classList.remove("active"),this.dropdown.classList.remove("opened","bottom-full","top-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.style.marginBottom="",(0,c.afterTransition)(this.dropdown,(function(){o.dropdown.classList.add("hidden"),o.hasSearch&&(o.search.value="",o.search.dispatchEvent(new Event("input",{bubbles:!0})),o.search.blur()),o.animationInProcess=!1})),null===(n=this.dropdown.querySelector(".hs-select-option-highlighted"))||void 0===n||n.classList.remove("hs-select-option-highlighted"),this.isOpened=!1},e.prototype.addOption=function(t){var e=this,i="".concat(this.selectOptions.length),n=function(t){var n=t.title,o=t.val,s=t.disabled,r=t.selected,l=t.options;!!e.selectOptions.some((function(t){return t.val===o}))||(e.addSelectOption(n,o,s,r,l),e.buildOption(n,o,s,r,l,i),e.buildOriginalOption(n,o,null,s,r,l),r&&!e.isMultiple&&e.onSelectOption(o))};Array.isArray(t)?t.forEach((function(t){n(t)})):n(t)},e.prototype.removeOption=function(t){var e=this,i=function(t,i){void 0===i&&(i=!1),!!e.selectOptions.some((function(e){return e.val===t}))&&(e.removeSelectOption(t,i),e.destroyOption(t),e.destroyOriginalOption(t),e.value===t&&(e.value=null,e.eraseToggleTitle(),e.eraseToggleIcon()))};Array.isArray(t)?t.forEach((function(t){i(t,e.isMultiple)})):i(t,this.isMultiple),this.setNewValue()},e.prototype.recalculateDirection=function(){var t,e,i,n;(0,c.isEnoughSpace)(this.dropdown,this.toggle||this.tagsInput,"bottom",this.dropdownSpace,this.viewport)?(this.dropdown.classList.remove("bottom-full"),(null===(t=this.dropdownDirectionClasses)||void 0===t?void 0:t.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="",this.dropdown.classList.add("top-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.top)&&this.dropdown.classList.add(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="".concat(this.dropdownSpace,"px")):(this.dropdown.classList.remove("top-full"),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.classList.add("bottom-full"),(null===(n=this.dropdownDirectionClasses)||void 0===n?void 0:n.bottom)&&this.dropdown.classList.add(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="".concat(this.dropdownSpace,"px"))},e.getInstance=function(t,e){var i=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return i?e?i:i.element:null},e.autoInit=function(){window.$hsSelectCollection||(window.$hsSelectCollection=[]),document.querySelectorAll("[data-hs-select]:not(.--prevent-on-load-init)").forEach((function(t){if(!window.$hsSelectCollection.find((function(e){var i;return(null===(i=null==e?void 0:e.element)||void 0===i?void 0:i.el)===t}))){var i=t.getAttribute("data-hs-select"),n=i?JSON.parse(i):{};new e(t,n)}})),window.$hsSelectCollection&&(window.addEventListener("click",(function(t){var i=t.target;e.closeCurrentlyOpened(i)})),document.addEventListener("keydown",(function(t){return e.accessibility(t)})))},e.open=function(t){var e=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&!e.element.isOpened&&e.element.open()},e.close=function(t){var e=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&e.element.isOpened&&e.element.close()},e.closeCurrentlyOpened=function(t){if(void 0===t&&(t=null),!t.closest(".hs-select.active")&&!t.closest("[data-hs-select-dropdown].opened")){var e=window.$hsSelectCollection.filter((function(t){return t.element.isOpened}))||null;e&&e.forEach((function(t){t.element.close()}))}},e.accessibility=function(t){if(window.$hsSelectCollection.find((function(t){return t.element.isOpened}))&&p.SELECT_ACCESSIBILITY_KEY_SET.includes(t.code)&&!t.metaKey)switch(t.code){case"Escape":t.preventDefault(),this.onEscape();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow(!1);break;case"Tab":t.preventDefault(),t.stopImmediatePropagation(),this.onTab(t.shiftKey);break;case"Home":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd();break;case"End":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd(!1);break;case"Enter":t.preventDefault(),this.onEnter(t)}},e.onEscape=function(){var t=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));t&&t.element.close()},e.onArrow=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((function(t){return!t.classList.contains("disabled")})),o=i.querySelector(".hs-select-option-highlighted")||i.querySelector(".selected");o||n[0].classList.add("hs-select-option-highlighted");var s=n.findIndex((function(t){return t===o}));s+1<n.length&&s++,n[s].focus(),o&&o.classList.remove("hs-select-option-highlighted"),n[s].classList.add("hs-select-option-highlighted")}},e.onTab=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((function(t){return!t.classList.contains("disabled")})),o=i.querySelector(".hs-select-option-highlighted")||i.querySelector(".selected");o||n[0].classList.add("hs-select-option-highlighted");var s=n.findIndex((function(t){return t===o}));if(!(s+1<n.length))return o&&o.classList.remove("hs-select-option-highlighted"),e.element.close(),e.element.toggle.focus(),!1;n[++s].focus(),o&&o.classList.remove("hs-select-option-highlighted"),n[s].classList.add("hs-select-option-highlighted")}},e.onStartEnd=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")):Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse()).filter((function(t){return!t.classList.contains("disabled")})),o=i.querySelector(".hs-select-option-highlighted");n.length&&(n[0].focus(),o&&o.classList.remove("hs-select-option-highlighted"),n[0].classList.add("hs-select-option-highlighted"))}},e.onEnter=function(t){var e=t.target.previousSibling;if(window.$hsSelectCollection.find((function(t){return t.element.el===e}))){var i=window.$hsSelectCollection.find((function(t){return t.element.isOpened})),n=window.$hsSelectCollection.find((function(t){return t.element.el===e}));i.element.close(),n.element.open()}else{(n=window.$hsSelectCollection.find((function(t){return t.element.isOpened})))&&n.element.onSelectOption(t.target.dataset.value||"")}},e}(u.default);window.addEventListener("load",(function(){h.autoInit()})),document.addEventListener("scroll",(function(){if(!window.$hsSelectCollection)return!1;var t=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));t&&t.element.recalculateDirection()})),"undefined"!=typeof window&&(window.HSSelect=h),e.default=h},292:function(t,e){
/*
* HSSelect
* @version: 2.4.1
* @version: 2.5.0
* @author: Preline Labs Ltd.

@@ -18,2 +17,2 @@ * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)

*/
var n,s=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},o.apply(this,arguments)},l=this&&this.__spreadArray||function(t,e,i){if(i||2===arguments.length)for(var n,s=0,o=e.length;s<o;s++)!n&&s in e||(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=i(292),d=r(i(961)),c=i(223),u=function(t){function e(e,i){var n,s,l=t.call(this,e,i)||this,r=e.getAttribute("data-hs-select"),a=r?JSON.parse(r):{},d=o(o({},a),i),c={items:", ",betweenItemsAndCounter:"and"};return l.value=(null==d?void 0:d.value)||l.el.value||null,l.placeholder=(null==d?void 0:d.placeholder)||"Select...",l.hasSearch=(null==d?void 0:d.hasSearch)||!1,l.preventSearchFocus=(null==d?void 0:d.preventSearchFocus)||!1,l.mode=(null==d?void 0:d.mode)||"default",l.viewport=void 0!==(null==d?void 0:d.viewport)?document.querySelector(null==d?void 0:d.viewport):null,l.isOpened=Boolean(null==d?void 0:d.isOpened)||!1,l.isMultiple=l.el.hasAttribute("multiple")||!1,l.isDisabled=l.el.hasAttribute("disabled")||!1,l.selectedItems=[],l.wrapperClasses=(null==d?void 0:d.wrapperClasses)||null,l.toggleTag=(null==d?void 0:d.toggleTag)||null,l.toggleClasses=(null==d?void 0:d.toggleClasses)||null,l.toggleSeparators=null!==(n=o(o({},c),null==d?void 0:d.toggleSeparators))&&void 0!==n?n:c,l.toggleCountText=(null==d?void 0:d.toggleCountText)||null,l.toggleCountTextMinItems=(null==d?void 0:d.toggleCountTextMinItems)||1,l.toggleCountTextMode=(null==d?void 0:d.toggleCountTextMode)||"countAfterLimit",l.tagsItemTemplate=(null==d?void 0:d.tagsItemTemplate)||null,l.tagsItemClasses=(null==d?void 0:d.tagsItemClasses)||null,l.tagsInputClasses=(null==d?void 0:d.tagsInputClasses)||null,l.dropdownTag=(null==d?void 0:d.dropdownTag)||null,l.dropdownClasses=(null==d?void 0:d.dropdownClasses)||null,l.dropdownDirectionClasses=(null==d?void 0:d.dropdownDirectionClasses)||null,l.dropdownSpace=(null==d?void 0:d.dropdownSpace)||10,l.searchWrapperTemplate=(null==d?void 0:d.searchWrapperTemplate)||null,l.searchWrapperClasses=(null==d?void 0:d.searchWrapperClasses)||"bg-white p-2 sticky top-0",l.searchClasses=(null==d?void 0:d.searchClasses)||"block w-[calc(100%-2rem)] text-sm border-gray-200 rounded-md focus:border-blue-500 focus:ring-blue-500 dark:bg-neutral-900 dark:border-neutral-700 dark:text-neutral-400 py-2 px-3 my-2 mx-4",l.searchPlaceholder=(null==d?void 0:d.searchPlaceholder)||"Search...",l.searchNoResultText=(null==d?void 0:d.searchNoResultText)||"No results found",l.searchNoResultClasses=(null==d?void 0:d.searchNoResultClasses)||"px-4 text-sm text-gray-800 dark:text-neutral-200",l.optionTemplate=(null==d?void 0:d.optionTemplate)||null,l.optionTag=(null==d?void 0:d.optionTag)||null,l.optionClasses=(null==d?void 0:d.optionClasses)||null,l.extraMarkup=(null==d?void 0:d.extraMarkup)||null,l.descriptionClasses=(null==d?void 0:d.descriptionClasses)||null,l.iconClasses=(null==d?void 0:d.iconClasses)||null,l.isAddTagOnEnter=null===(s=null==d?void 0:d.isAddTagOnEnter)||void 0===s||s,l.animationInProcess=!1,l.selectOptions=[],l.tagsInputHelper=null,l.init(),l}return s(e,t),e.prototype.setValue=function(t){this.value=t,this.clearSelections(),Array.isArray(t)?(this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder,this.unselectMultipleItems(),this.selectMultipleItems()):(this.setToggleTitle(),this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.selectSingleItem())},e.prototype.init=function(){this.createCollection(window.$hsSelectCollection,this),this.build()},e.prototype.build=function(){var t=this;if(this.el.style.display="none",this.el.children&&Array.from(this.el.children).filter((function(t){return t.value&&""!==t.value})).forEach((function(e){var i=e.getAttribute("data-hs-select-option");t.selectOptions=l(l([],t.selectOptions,!0),[{title:e.textContent,val:e.value,disabled:e.disabled,options:"undefined"!==i?JSON.parse(i):null}],!1)})),this.isMultiple){var e=Array.from(this.el.children).filter((function(t){return t.selected}));if(e){var i=[];e.forEach((function(t){i.push(t.value)})),this.value=i}}this.buildWrapper(),"tags"===this.mode?this.buildTags():this.buildToggle(),this.buildDropdown(),this.extraMarkup&&this.buildExtraMarkup()},e.prototype.buildWrapper=function(){var t=this;this.wrapper=document.createElement("div"),this.wrapper.classList.add("hs-select","relative"),"tags"===this.mode&&this.wrapper.addEventListener("click",(function(e){e.target.closest("[data-hs-select-dropdown]")||e.target.closest("[data-tag-value]")||t.tagsInput.focus()})),this.wrapperClasses&&(0,a.classToClassList)(this.wrapperClasses,this.wrapper),this.el.before(this.wrapper),this.wrapper.append(this.el)},e.prototype.buildExtraMarkup=function(){var t=this,e=function(e){t.wrapper.append((0,a.htmlToElement)(e))};Array.isArray(this.extraMarkup)?this.extraMarkup.forEach((function(t){return e(t)})):e(this.extraMarkup)},e.prototype.buildToggle=function(){var t,e,i,n,s=this;this.toggleTextWrapper=document.createElement("span"),this.toggleTextWrapper.classList.add("truncate"),this.toggle=(0,a.htmlToElement)(this.toggleTag||"<div></div>"),i=this.toggle.querySelector("[data-icon]"),n=this.toggle.querySelector("[data-title]"),!this.isMultiple&&i&&this.setToggleIcon(),!this.isMultiple&&n&&this.setToggleTitle(),this.isMultiple?this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder:this.toggleTextWrapper.innerHTML=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder,n||this.toggle.append(this.toggleTextWrapper),this.toggleClasses&&(0,a.classToClassList)(this.toggleClasses,this.toggle),this.isDisabled&&this.toggle.classList.add("disabled"),this.wrapper&&this.wrapper.append(this.toggle),(null===(e=this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.isOpened?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),this.toggle.addEventListener("click",(function(){if(s.isDisabled)return!1;s.isOpened?s.close():s.open()}))},e.prototype.setToggleIcon=function(){var t,e,i=this.toggle.querySelector("[data-icon]");if(i.innerHTML="",i){var n=(0,a.htmlToElement)((null===(e=null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.options)||void 0===e?void 0:e.icon)||"");i.append(n),n?i.classList.remove("hidden"):i.classList.add("hidden")}},e.prototype.setToggleTitle=function(){var t,e=this.toggle.querySelector("[data-title]");if(e.classList.add("truncate"),e.innerHTML="",e){var i=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder;e.innerHTML=i,this.toggle.append(e)}},e.prototype.buildTags=function(){this.isDisabled&&this.wrapper.classList.add("disabled"),this.buildTagsInput(),this.setTagsItems()},e.prototype.reassignTagsInputPlaceholder=function(t){this.tagsInput.placeholder=t,this.tagsInputHelper.innerHTML=t,this.calculateInputWidth()},e.prototype.buildTagsItem=function(t){var e,i,n,s,o,l,r,d=this,c=this.getItemByValue(t),u=document.createElement("div");if(u.setAttribute("data-tag-value",t),this.tagsItemClasses&&(0,a.classToClassList)(this.tagsItemClasses,u),this.tagsItemTemplate&&(s=(0,a.htmlToElement)(this.tagsItemTemplate),u.append(s)),null===(e=null==c?void 0:c.options)||void 0===e?void 0:e.icon){var p=(0,a.htmlToElement)(null===(i=null==c?void 0:c.options)||void 0===i?void 0:i.icon);(r=s?s.querySelector("[data-icon]"):document.createElement("span")).append(p),s||u.append(r)}s&&s.querySelector("[data-icon]")&&!(null===(n=null==c?void 0:c.options)||void 0===n?void 0:n.icon)&&s.querySelector("[data-icon]").classList.add("hidden"),(o=s?s.querySelector("[data-title]"):document.createElement("span")).textContent=c.title||"",s||u.append(o),s?l=s.querySelector("[data-remove]"):((l=document.createElement("span")).textContent="X",u.append(l)),l.addEventListener("click",(function(){d.value=d.value.filter((function(e){return e!==t})),d.selectedItems=d.selectedItems.filter((function(e){return e!==t})),d.value.length||d.reassignTagsInputPlaceholder(d.placeholder),d.unselectMultipleItems(),d.selectMultipleItems(),u.remove()})),this.wrapper.append(u)},e.prototype.getItemByValue=function(t){return this.selectOptions.find((function(e){return e.val===t}))},e.prototype.setTagsItems=function(){var t=this;this.value&&this.value.forEach((function(e){t.selectedItems.includes(e)||t.buildTagsItem(e),t.selectedItems=t.selectedItems.includes(e)?t.selectedItems:l(l([],t.selectedItems,!0),[e],!1)}))},e.prototype.buildTagsInput=function(){var t=this;this.tagsInput=document.createElement("input"),this.tagsInputClasses&&(0,a.classToClassList)(this.tagsInputClasses,this.tagsInput),this.tagsInput.addEventListener("focus",(function(){return t.open()})),this.tagsInput.addEventListener("input",(function(){return t.calculateInputWidth()})),this.tagsInput.addEventListener("input",(0,a.debounce)((function(e){return t.searchOptions(e.target.value)}))),this.tagsInput.addEventListener("keydown",(function(e){if("Enter"===e.key&&t.isAddTagOnEnter){var i=e.target.value;if(t.selectOptions.find((function(t){return t.val===i})))return!1;t.addSelectOption(i,i),t.buildOption(i,i),t.dropdown.querySelector('[data-value="'.concat(i,'"]')).click(),t.resetTagsInputField()}})),this.wrapper.append(this.tagsInput),setTimeout((function(){t.adjustInputWidth(),t.reassignTagsInputPlaceholder(t.value.length?"":t.placeholder)}))},e.prototype.buildDropdown=function(){var t=this;this.dropdown=(0,a.htmlToElement)(this.dropdownTag||"<div></div>"),this.dropdown.setAttribute("data-hs-select-dropdown",""),this.dropdown.classList.add("absolute","top-full"),this.dropdown.role="listbox",this.dropdown.tabIndex=-1,this.dropdown.ariaOrientation="vertical",this.isOpened||this.dropdown.classList.add("hidden"),this.dropdownClasses&&(0,a.classToClassList)(this.dropdownClasses,this.dropdown),this.wrapper&&this.wrapper.append(this.dropdown),this.dropdown&&this.hasSearch&&this.buildSearch(),this.selectOptions&&this.selectOptions.forEach((function(e,i){return t.buildOption(e.title,e.val,e.disabled,e.selected,e.options,"".concat(i))}))},e.prototype.buildSearch=function(){var t,e=this;this.searchWrapper=(0,a.htmlToElement)(this.searchWrapperTemplate||"<div></div>"),this.searchWrapperClasses&&(0,a.classToClassList)(this.searchWrapperClasses,this.searchWrapper),t=this.searchWrapper.querySelector("[data-input]"),this.search=(0,a.htmlToElement)('<input type="text" />'),this.search.placeholder=this.searchPlaceholder,this.searchClasses&&(0,a.classToClassList)(this.searchClasses,this.search),this.search.addEventListener("input",(0,a.debounce)((function(t){return e.searchOptions(t.target.value)}))),t?t.append(this.search):this.searchWrapper.append(this.search),this.dropdown.append(this.searchWrapper)},e.prototype.buildOption=function(t,e,i,n,s,o){var r=this;void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===o&&(o="1");var d=null,c=(0,a.htmlToElement)(this.optionTag||"<div></div>");if(c.setAttribute("data-value",e),c.setAttribute("data-title-value",t),c.setAttribute("tabIndex",o),c.classList.add("cursor-pointer"),i&&c.classList.add("disabled"),n&&(this.isMultiple?this.value=l(l([],this.value,!0),[e],!1):this.value=e),this.optionTemplate&&(d=(0,a.htmlToElement)(this.optionTemplate),c.append(d)),d?d.querySelector("[data-title]").textContent=t||"":c.textContent=t||"",s){if(s.icon){var u=(0,a.htmlToElement)(s.icon);if(u.classList.add("max-w-full"),d)d.querySelector("[data-icon]").append(u);else{var p=(0,a.htmlToElement)("<div></div>");this.iconClasses&&(0,a.classToClassList)(this.iconClasses,p),p.append(u),c.append(p)}}if(s.description)if(d)d.querySelector("[data-description]").append(s.description);else{var h=(0,a.htmlToElement)("<div></div>");h.textContent=s.description,this.descriptionClasses&&(0,a.classToClassList)(this.descriptionClasses,h),c.append(h)}}d&&d.querySelector("[data-icon]")&&!s&&!(null==s?void 0:s.icon)&&d.querySelector("[data-icon]").classList.add("hidden"),this.value&&(this.isMultiple?this.value.includes(e):this.value===e)&&c.classList.add("selected"),i||c.addEventListener("click",(function(){return r.onSelectOption(e)})),this.optionClasses&&(0,a.classToClassList)(this.optionClasses,c),this.dropdown&&this.dropdown.append(c),n&&this.setNewValue()},e.prototype.destroyOption=function(t){var e=this.dropdown.querySelector('[data-value="'.concat(t,'"]'));if(!e)return!1;e.remove()},e.prototype.buildOriginalOption=function(t,e,i,n,s){var o=(0,a.htmlToElement)("<option></option>");o.setAttribute("value",e),i&&o.setAttribute("disabled","disabled"),n&&o.setAttribute("selected","selected"),o.setAttribute("data-hs-select-option",JSON.stringify(s)),o.innerText=t,this.el.append(o)},e.prototype.destroyOriginalOption=function(t){var e=this.el.querySelector('[value="'.concat(t,'"]'));if(!e)return!1;e.remove()},e.prototype.buildTagsInputHelper=function(){this.tagsInputHelper=document.createElement("span"),this.tagsInputHelper.style.fontSize=window.getComputedStyle(this.tagsInput).fontSize,this.tagsInputHelper.style.fontFamily=window.getComputedStyle(this.tagsInput).fontFamily,this.tagsInputHelper.style.fontWeight=window.getComputedStyle(this.tagsInput).fontWeight,this.tagsInputHelper.style.letterSpacing=window.getComputedStyle(this.tagsInput).letterSpacing,this.tagsInputHelper.style.visibility="hidden",this.tagsInputHelper.style.whiteSpace="pre",this.tagsInputHelper.style.position="absolute",this.wrapper.appendChild(this.tagsInputHelper)},e.prototype.calculateInputWidth=function(){this.tagsInputHelper.textContent=this.tagsInput.value||this.tagsInput.placeholder;var t=parseInt(window.getComputedStyle(this.tagsInput).paddingLeft)+parseInt(window.getComputedStyle(this.tagsInput).paddingRight),e=parseInt(window.getComputedStyle(this.tagsInput).borderLeftWidth)+parseInt(window.getComputedStyle(this.tagsInput).borderRightWidth),i=this.tagsInputHelper.offsetWidth+t+e,n=this.wrapper.offsetWidth-(parseInt(window.getComputedStyle(this.wrapper).paddingLeft)+parseInt(window.getComputedStyle(this.wrapper).paddingRight));this.tagsInput.style.width="".concat(Math.min(i,n)+2,"px")},e.prototype.adjustInputWidth=function(){this.buildTagsInputHelper(),this.calculateInputWidth()},e.prototype.onSelectOption=function(t){var e=this;if(this.clearSelections(),this.isMultiple?(this.value=this.value.includes(t)?Array.from(this.value).filter((function(e){return e!==t})):l(l([],Array.from(this.value),!0),[t],!1),this.selectMultipleItems(),this.setNewValue()):(this.value=t,this.selectSingleItem(),this.setNewValue()),this.fireEvent("change",this.value),(0,a.dispatch)("change.hs.select",this.el,this.value),"tags"===this.mode){var i=this.selectedItems.filter((function(t){return!e.value.includes(t)}));i.length&&i.forEach((function(t){e.selectedItems=e.selectedItems.filter((function(e){return e!==t})),e.wrapper.querySelector('[data-tag-value="'.concat(t,'"]')).remove()})),this.resetTagsInputField()}this.isMultiple||(this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.close()),this.value.length||"tags"!==this.mode||this.reassignTagsInputPlaceholder(this.placeholder),this.isOpened&&"tags"===this.mode&&this.tagsInput&&this.tagsInput.focus(),this.triggerChangeEventForNativeSelect()},e.prototype.triggerChangeEventForNativeSelect=function(){var t=new Event("change",{bubbles:!0});this.el.dispatchEvent(t)},e.prototype.addSelectOption=function(t,e,i,n,s){this.selectOptions=l(l([],this.selectOptions,!0),[{title:t,val:e,disabled:i,selected:n,options:s}],!1)},e.prototype.removeSelectOption=function(t,e){if(void 0===e&&(e=!1),!!!this.selectOptions.some((function(e){return e.val===t})))return!1;this.selectOptions=this.selectOptions.filter((function(e){return e.val!==t})),console.log(e),this.value=e?this.value.filter((function(e){return e!==t})):t,console.log(this.value)},e.prototype.resetTagsInputField=function(){this.tagsInput.value="",this.reassignTagsInputPlaceholder(""),this.searchOptions("")},e.prototype.clearSelections=function(){Array.from(this.dropdown.children).forEach((function(t){t.classList.contains("selected")&&t.classList.remove("selected")})),Array.from(this.el.children).forEach((function(t){t.selected&&(t.selected=!1)}))},e.prototype.setNewValue=function(){"tags"===this.mode?this.setTagsItems():(console.log(),this.value.length?this.toggleTextWrapper.innerHTML=this.stringFromValue():this.toggleTextWrapper.innerHTML=this.placeholder)},e.prototype.stringFromValue=function(){var t=this,e=[],i="";if(this.selectOptions.forEach((function(i){t.isMultiple?t.value.includes(i.val)&&e.push(i.title):t.value===i.val&&e.push(i.title)})),this.toggleCountText&&""!==this.toggleCountText&&e.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){var n=e.slice(0,this.toggleCountTextMinItems-1);i="".concat(n.join(this.toggleSeparators.items)," ").concat(this.toggleSeparators.betweenItemsAndCounter," ").concat(e.length-n.length," ").concat(this.toggleCountText)}else i="".concat(e.length," ").concat(this.toggleCountText);else i=e.join(this.toggleSeparators.items);return i},e.prototype.selectSingleItem=function(){var t=this;Array.from(this.el.children).find((function(e){return t.value===e.value})).selected=!0;var e=Array.from(this.dropdown.children).find((function(e){return t.value===e.getAttribute("data-value")}));e&&e.classList.add("selected")},e.prototype.selectMultipleItems=function(){var t=this;Array.from(this.dropdown.children).filter((function(e){return t.value.includes(e.getAttribute("data-value"))})).forEach((function(t){return t.classList.add("selected")})),Array.from(this.el.children).filter((function(e){return t.value.includes(e.value)})).forEach((function(t){return t.selected=!0}))},e.prototype.unselectMultipleItems=function(){Array.from(this.dropdown.children).forEach((function(t){return t.classList.remove("selected")})),Array.from(this.el.children).forEach((function(t){return t.selected=!1}))},e.prototype.searchOptions=function(t){this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null),this.searchNoResult=(0,a.htmlToElement)("<span></span>"),this.searchNoResult.innerText=this.searchNoResultText,(0,a.classToClassList)(this.searchNoResultClasses,this.searchNoResult);var e=this.dropdown.querySelectorAll("[data-value]"),i=!1;e.forEach((function(e){e.getAttribute("data-title-value").toLocaleLowerCase().includes(t.toLocaleLowerCase())?(e.classList.remove("hidden"),i=!0):e.classList.add("hidden")})),i||this.dropdown.append(this.searchNoResult)},e.prototype.eraseToggleIcon=function(){var t=this.toggle.querySelector("[data-icon]");t&&(t.innerHTML=null,t.classList.add("hidden"))},e.prototype.eraseToggleTitle=function(){var t=this.toggle.querySelector("[data-title]");t?t.innerHTML=this.placeholder:this.toggleTextWrapper.innerHTML=this.placeholder},e.prototype.destroy=function(){var t=this.el.parentElement.parentElement;this.el.classList.remove("hidden"),this.el.style.display="",t.prepend(this.el),t.querySelector(".hs-select").remove(),this.wrapper=null},e.prototype.open=function(){var t,e=this,i=(null===(t=null===window||void 0===window?void 0:window.$hsSelectCollection)||void 0===t?void 0:t.find((function(t){return t.element.isOpened})))||null;if(i&&i.element.close(),this.animationInProcess)return!1;this.animationInProcess=!0,this.dropdown.classList.remove("hidden"),this.recalculateDirection(),setTimeout((function(){var t;(null===(t=null==e?void 0:e.toggle)||void 0===t?void 0:t.ariaExpanded)&&(e.toggle.ariaExpanded="true"),e.wrapper.classList.add("active"),e.dropdown.classList.add("opened"),e.hasSearch&&!e.preventSearchFocus&&e.search.focus(),e.animationInProcess=!1})),this.isOpened=!0},e.prototype.close=function(){var t,e,i,n,s=this;if(this.animationInProcess)return!1;this.animationInProcess=!0,(null===(t=null==this?void 0:this.toggle)||void 0===t?void 0:t.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.wrapper.classList.remove("active"),this.dropdown.classList.remove("opened","bottom-full","top-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.style.marginBottom="",(0,a.afterTransition)(this.dropdown,(function(){s.dropdown.classList.add("hidden"),s.hasSearch&&(s.search.value="",s.search.dispatchEvent(new Event("input",{bubbles:!0})),s.search.blur()),s.animationInProcess=!1})),null===(n=this.dropdown.querySelector(".hs-select-option-highlighted"))||void 0===n||n.classList.remove("hs-select-option-highlighted"),this.isOpened=!1},e.prototype.addOption=function(t){var e=this,i="".concat(this.selectOptions.length),n=function(t){var n=t.title,s=t.val,o=t.disabled,l=t.selected,r=t.options;!!e.selectOptions.some((function(t){return t.val===s}))||(e.addSelectOption(n,s,o,l,r),e.buildOption(n,s,o,l,r,i),e.buildOriginalOption(n,s,o,l,r),l&&!e.isMultiple&&e.onSelectOption(s))};Array.isArray(t)?t.forEach((function(t){n(t)})):n(t)},e.prototype.removeOption=function(t){var e=this,i=function(t,i){void 0===i&&(i=!1),!!e.selectOptions.some((function(e){return e.val===t}))&&(e.removeSelectOption(t,i),e.destroyOption(t),e.destroyOriginalOption(t),e.value===t&&(e.value=null,e.eraseToggleTitle(),e.eraseToggleIcon()))};Array.isArray(t)?t.forEach((function(t){i(t,e.isMultiple)})):i(t,this.isMultiple),this.setNewValue()},e.prototype.recalculateDirection=function(){var t,e,i,n;(0,a.isEnoughSpace)(this.dropdown,this.toggle||this.tagsInput,"bottom",this.dropdownSpace,this.viewport)?(this.dropdown.classList.remove("bottom-full"),(null===(t=this.dropdownDirectionClasses)||void 0===t?void 0:t.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="",this.dropdown.classList.add("top-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.top)&&this.dropdown.classList.add(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="".concat(this.dropdownSpace,"px")):(this.dropdown.classList.remove("top-full"),(null===(i=this.dropdownDirectionClasses)||void 0===i?void 0:i.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.classList.add("bottom-full"),(null===(n=this.dropdownDirectionClasses)||void 0===n?void 0:n.bottom)&&this.dropdown.classList.add(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="".concat(this.dropdownSpace,"px"))},e.getInstance=function(t,e){var i=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return i?e?i:i.element:null},e.autoInit=function(){window.$hsSelectCollection||(window.$hsSelectCollection=[]),document.querySelectorAll("[data-hs-select]:not(.--prevent-on-load-init)").forEach((function(t){if(!window.$hsSelectCollection.find((function(e){var i;return(null===(i=null==e?void 0:e.element)||void 0===i?void 0:i.el)===t}))){var i=t.getAttribute("data-hs-select"),n=i?JSON.parse(i):{};new e(t,n)}})),window.$hsSelectCollection&&(window.addEventListener("click",(function(t){var i=t.target;e.closeCurrentlyOpened(i)})),document.addEventListener("keydown",(function(t){return e.accessibility(t)})))},e.open=function(t){var e=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&!e.element.isOpened&&e.element.open()},e.close=function(t){var e=window.$hsSelectCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&e.element.isOpened&&e.element.close()},e.closeCurrentlyOpened=function(t){if(void 0===t&&(t=null),!t.closest(".hs-select.active")){var e=window.$hsSelectCollection.filter((function(t){return t.element.isOpened}))||null;e&&e.forEach((function(t){t.element.close()}))}},e.accessibility=function(t){if(window.$hsSelectCollection.find((function(t){return t.element.isOpened}))&&c.SELECT_ACCESSIBILITY_KEY_SET.includes(t.code)&&!t.metaKey)switch(t.code){case"Escape":t.preventDefault(),this.onEscape();break;case"ArrowUp":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow();break;case"ArrowDown":t.preventDefault(),t.stopImmediatePropagation(),this.onArrow(!1);break;case"Tab":t.preventDefault(),t.stopImmediatePropagation(),this.onTab(t.shiftKey);break;case"Home":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd();break;case"End":t.preventDefault(),t.stopImmediatePropagation(),this.onStartEnd(!1);break;case"Enter":t.preventDefault(),this.onEnter(t)}},e.onEscape=function(){var t=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));t&&t.element.close()},e.onArrow=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((function(t){return!t.classList.contains("disabled")})),s=i.querySelector(".hs-select-option-highlighted")||i.querySelector(".selected");s||n[0].classList.add("hs-select-option-highlighted");var o=n.findIndex((function(t){return t===s}));o+1<n.length&&o++,n[o].focus(),s&&s.classList.remove("hs-select-option-highlighted"),n[o].classList.add("hs-select-option-highlighted")}},e.onTab=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(i.querySelectorAll(":scope > *:not(.hidden)"))).filter((function(t){return!t.classList.contains("disabled")})),s=i.querySelector(".hs-select-option-highlighted")||i.querySelector(".selected");s||n[0].classList.add("hs-select-option-highlighted");var o=n.findIndex((function(t){return t===s}));if(!(o+1<n.length))return s&&s.classList.remove("hs-select-option-highlighted"),e.element.close(),e.element.toggle.focus(),!1;n[++o].focus(),s&&s.classList.remove("hs-select-option-highlighted"),n[o].classList.add("hs-select-option-highlighted")}},e.onStartEnd=function(t){void 0===t&&(t=!0);var e=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));if(e){var i=e.element.dropdown;if(!i)return!1;var n=(t?Array.from(i.querySelectorAll(":scope > *:not(.hidden)")):Array.from(i.querySelectorAll(":scope > *:not(.hidden)")).reverse()).filter((function(t){return!t.classList.contains("disabled")})),s=i.querySelector(".hs-select-option-highlighted");n.length&&(n[0].focus(),s&&s.classList.remove("hs-select-option-highlighted"),n[0].classList.add("hs-select-option-highlighted"))}},e.onEnter=function(t){var e=t.target.previousSibling;if(window.$hsSelectCollection.find((function(t){return t.element.el===e}))){var i=window.$hsSelectCollection.find((function(t){return t.element.isOpened})),n=window.$hsSelectCollection.find((function(t){return t.element.el===e}));i.element.close(),n.element.open()}else{(n=window.$hsSelectCollection.find((function(t){return t.element.isOpened})))&&n.element.onSelectOption(t.target.dataset.value||"")}},e}(d.default);window.addEventListener("load",(function(){u.autoInit()})),document.addEventListener("scroll",(function(){if(!window.$hsSelectCollection)return!1;var t=window.$hsSelectCollection.find((function(t){return t.element.isOpened}));t&&t.element.recalculateDirection()})),"undefined"!=typeof window&&(window.HSSelect=u),e.default=u},292:function(t,e){var i=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getZIndex=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0,e.getHighestZIndex=function(t){var e=Number.NEGATIVE_INFINITY;return t.forEach((function(t){var i=n(t);"auto"!==i&&(i=parseInt(i,10))>e&&(e=i)})),e};e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,i){return void 0===i&&(i=""),(window.getComputedStyle(t).getPropertyValue(e)||i).replace(" ","")};e.getClassPropertyAlt=function(t,e,i){void 0===i&&(i="");var n="";return t.classList.forEach((function(t){t.includes(e)&&(n=t)})),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:i};var n=function(t){return window.getComputedStyle(t).getPropertyValue("z-index")};e.getZIndex=n;e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,i,n,s){void 0===i&&(i="auto"),void 0===n&&(n=10),void 0===s&&(s=null);var o=e.getBoundingClientRect(),l=s?s.getBoundingClientRect():null,r=window.innerHeight,a=l?o.top-l.top:o.top,d=(s?l.bottom:r)-o.bottom,c=t.clientHeight+n;return"bottom"===i?d>=c:"top"===i?a>=c:a>=c||d>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var s=function(t){return!!t&&("none"===window.getComputedStyle(t).display||s(t.parentElement))};e.isParentOrElementHidden=s;e.debounce=function(t,e){var n;return void 0===e&&(e=200),function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];clearTimeout(n),n=setTimeout((function(){t.apply(i,s)}),e)}};e.dispatch=function(t,e,i){void 0===i&&(i=null);var n=new CustomEvent(t,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(n)};e.afterTransition=function(t,e){var i=function(){e(),t.removeEventListener("transitionend",i,!0)},n=window.getComputedStyle(t),s=n.getPropertyValue("transition-duration");"none"!==n.getPropertyValue("transition-property")&&parseFloat(s)>0?t.addEventListener("transitionend",i,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,i,n){void 0===i&&(i=" "),void 0===n&&(n="add"),t.split(i).forEach((function(t){return"add"===n?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var i=function i(n){var s=e[n];if(void 0!==s)return s.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,i),o.exports}(442);return i})()));
var i=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isDirectChild=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getZIndex=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0,e.getHighestZIndex=function(t){var e=Number.NEGATIVE_INFINITY;return t.forEach((function(t){var i=n(t);"auto"!==i&&(i=parseInt(i,10))>e&&(e=i)})),e};e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,i){return void 0===i&&(i=""),(window.getComputedStyle(t).getPropertyValue(e)||i).replace(" ","")};e.getClassPropertyAlt=function(t,e,i){void 0===i&&(i="");var n="";return t.classList.forEach((function(t){t.includes(e)&&(n=t)})),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:i};var n=function(t){return window.getComputedStyle(t).getPropertyValue("z-index")};e.getZIndex=n;e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isDirectChild=function(t,e){for(var i=t.children,n=0;n<i.length;n++)if(i[n]===e)return!0;return!1};e.isEnoughSpace=function(t,e,i,n,o){void 0===i&&(i="auto"),void 0===n&&(n=10),void 0===o&&(o=null);var s=e.getBoundingClientRect(),r=o?o.getBoundingClientRect():null,l=window.innerHeight,a=r?s.top-r.top:s.top,d=(o?r.bottom:l)-s.bottom,c=t.clientHeight+n;return"bottom"===i?d>=c:"top"===i?a>=c:a>=c||d>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var o=function(t){return!!t&&("none"===window.getComputedStyle(t).display||o(t.parentElement))};e.isParentOrElementHidden=o;e.debounce=function(t,e){var n;return void 0===e&&(e=200),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];clearTimeout(n),n=setTimeout((function(){t.apply(i,o)}),e)}};e.dispatch=function(t,e,i){void 0===i&&(i=null);var n=new CustomEvent(t,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(n)};e.afterTransition=function(t,e){var i=function(){e(),t.removeEventListener("transitionend",i,!0)},n=window.getComputedStyle(t),o=n.getPropertyValue("transition-duration");"none"!==n.getPropertyValue("transition-property")&&parseFloat(o)>0?t.addEventListener("transitionend",i,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,i,n){void 0===i&&(i=" "),void 0===n&&(n="add"),t.split(i).forEach((function(t){return"add"===n?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var i=function i(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,i),s.exports}(442);return i})()));
{
"name": "@preline/select",
"version": "2.4.1",
"version": "2.5.0",
"description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc