UNPKG

preline

Version:

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.

8 lines 119 kB
var e={189:(e,t,n)=>{n.d(t,{fp:()=>o,lP:()=>s});const s={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"},o=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"]},236:(e,t,n)=>{n.d(t,{A:()=>r});var s=n(926),o=n(615),a=n(189),i=function(e,t,n,s){return new(n||(n=Promise))((function(o,a){function i(e){try{r(s.next(e))}catch(e){a(e)}}function l(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}r((s=s.apply(e,t||[])).next())}))};class l extends o.A{constructor(e,t){var n,s,o,a;super(e,t),this.optionId=0;const i=e.getAttribute("data-hs-select"),l=i?JSON.parse(i):{},r=Object.assign(Object.assign({},l),t);this.value=(null==r?void 0:r.value)||this.el.value||null,this.placeholder=(null==r?void 0:r.placeholder)||"Select...",this.hasSearch=(null==r?void 0:r.hasSearch)||!1,this.minSearchLength=null!==(n=null==r?void 0:r.minSearchLength)&&void 0!==n?n:0,this.preventSearchFocus=(null==r?void 0:r.preventSearchFocus)||!1,this.mode=(null==r?void 0:r.mode)||"default",this.viewport=void 0!==(null==r?void 0:r.viewport)?document.querySelector(null==r?void 0:r.viewport):null,this.isOpened=Boolean(null==r?void 0:r.isOpened)||!1,this.isMultiple=this.el.hasAttribute("multiple")||!1,this.isDisabled=this.el.hasAttribute("disabled")||!1,this.selectedItems=[],this.apiUrl=(null==r?void 0:r.apiUrl)||null,this.apiQuery=(null==r?void 0:r.apiQuery)||null,this.apiOptions=(null==r?void 0:r.apiOptions)||null,this.apiSearchQueryKey=(null==r?void 0:r.apiSearchQueryKey)||null,this.apiDataPart=(null==r?void 0:r.apiDataPart)||null,this.apiFieldsMap=(null==r?void 0:r.apiFieldsMap)||null,this.apiIconTag=(null==r?void 0:r.apiIconTag)||null,this.wrapperClasses=(null==r?void 0:r.wrapperClasses)||null,this.toggleTag=(null==r?void 0:r.toggleTag)||null,this.toggleClasses=(null==r?void 0:r.toggleClasses)||null,this.toggleCountText=void 0===typeof(null==r?void 0:r.toggleCountText)?null:r.toggleCountText,this.toggleCountTextPlacement=(null==r?void 0:r.toggleCountTextPlacement)||"postfix",this.toggleCountTextMinItems=(null==r?void 0:r.toggleCountTextMinItems)||1,this.toggleCountTextMode=(null==r?void 0:r.toggleCountTextMode)||"countAfterLimit",this.toggleSeparators={items:(null===(s=null==r?void 0:r.toggleSeparators)||void 0===s?void 0:s.items)||", ",betweenItemsAndCounter:(null===(o=null==r?void 0:r.toggleSeparators)||void 0===o?void 0:o.betweenItemsAndCounter)||"and"},this.tagsItemTemplate=(null==r?void 0:r.tagsItemTemplate)||null,this.tagsItemClasses=(null==r?void 0:r.tagsItemClasses)||null,this.tagsInputId=(null==r?void 0:r.tagsInputId)||null,this.tagsInputClasses=(null==r?void 0:r.tagsInputClasses)||null,this.dropdownTag=(null==r?void 0:r.dropdownTag)||null,this.dropdownClasses=(null==r?void 0:r.dropdownClasses)||null,this.dropdownDirectionClasses=(null==r?void 0:r.dropdownDirectionClasses)||null,this.dropdownSpace=(null==r?void 0:r.dropdownSpace)||10,this.dropdownPlacement=(null==r?void 0:r.dropdownPlacement)||null,this.dropdownVerticalFixedPlacement=(null==r?void 0:r.dropdownVerticalFixedPlacement)||null,this.dropdownScope=(null==r?void 0:r.dropdownScope)||"parent",this.searchTemplate=(null==r?void 0:r.searchTemplate)||null,this.searchWrapperTemplate=(null==r?void 0:r.searchWrapperTemplate)||null,this.searchWrapperClasses=(null==r?void 0:r.searchWrapperClasses)||"bg-white p-2 sticky top-0",this.searchId=(null==r?void 0:r.searchId)||null,this.searchLimit=(null==r?void 0:r.searchLimit)||1/0,this.isSearchDirectMatch=void 0===(null==r?void 0:r.isSearchDirectMatch)||(null==r?void 0:r.isSearchDirectMatch),this.searchClasses=(null==r?void 0:r.searchClasses)||"block w-[calc(100%-32px)] 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",this.searchPlaceholder=(null==r?void 0:r.searchPlaceholder)||"Search...",this.searchNoResultTemplate=(null==r?void 0:r.searchNoResultTemplate)||"<span></span>",this.searchNoResultText=(null==r?void 0:r.searchNoResultText)||"No results found",this.searchNoResultClasses=(null==r?void 0:r.searchNoResultClasses)||"px-4 text-sm text-gray-800 dark:text-neutral-200",this.optionAllowEmptyOption=void 0!==(null==r?void 0:r.optionAllowEmptyOption)&&(null==r?void 0:r.optionAllowEmptyOption),this.optionTemplate=(null==r?void 0:r.optionTemplate)||null,this.optionTag=(null==r?void 0:r.optionTag)||null,this.optionClasses=(null==r?void 0:r.optionClasses)||null,this.extraMarkup=(null==r?void 0:r.extraMarkup)||null,this.descriptionClasses=(null==r?void 0:r.descriptionClasses)||null,this.iconClasses=(null==r?void 0:r.iconClasses)||null,this.isAddTagOnEnter=null===(a=null==r?void 0:r.isAddTagOnEnter)||void 0===a||a,this.animationInProcess=!1,this.selectOptions=[],this.remoteOptions=[],this.tagsInputHelper=null,this.init()}wrapperClick(e){e.target.closest("[data-hs-select-dropdown]")||e.target.closest("[data-tag-value]")||this.tagsInput.focus()}toggleClick(){if(this.isDisabled)return!1;this.toggleFn()}tagsInputFocus(){this.isOpened||this.open()}tagsInputInput(){this.calculateInputWidth()}tagsInputInputSecond(e){this.searchOptions(e.target.value)}tagsInputKeydown(e){if("Enter"===e.key&&this.isAddTagOnEnter){const t=e.target.value;if(this.selectOptions.find((e=>e.val===t)))return!1;this.addSelectOption(t,t),this.buildOption(t,t),this.dropdown.querySelector(`[data-value="${t}"]`).click(),this.resetTagsInputField()}}searchInput(e){const t=e.target.value;this.apiUrl?this.remoteSearch(t):this.searchOptions(t)}setValue(e){if(this.value=e,this.clearSelections(),Array.isArray(e))if("tags"===this.mode){this.unselectMultipleItems(),this.selectMultipleItems(),this.selectedItems=[];this.wrapper.querySelectorAll("[data-tag-value]").forEach((e=>e.remove())),this.setTagsItems(),this.reassignTagsInputPlaceholder(this.value.length?"":this.placeholder)}else this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder,this.unselectMultipleItems(),this.selectMultipleItems();else this.setToggleTitle(),this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.selectSingleItem()}init(){this.createCollection(window.$hsSelectCollection,this),this.build()}build(){if(this.el.style.display="none",this.el.children&&Array.from(this.el.children).filter((e=>this.optionAllowEmptyOption||!this.optionAllowEmptyOption&&e.value&&""!==e.value)).forEach((e=>{const t=e.getAttribute("data-hs-select-option");this.selectOptions=[...this.selectOptions,{title:e.textContent,val:e.value,disabled:e.disabled,options:"undefined"!==t?JSON.parse(t):null}]})),this.isMultiple){const e=Array.from(this.el.children).filter((e=>e.selected));if(e){const t=[];e.forEach((e=>{t.push(e.value)})),this.value=t}}this.buildWrapper(),"tags"===this.mode?this.buildTags():this.buildToggle(),this.buildDropdown(),this.extraMarkup&&this.buildExtraMarkup()}buildWrapper(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("hs-select","relative"),"tags"===this.mode&&(this.onWrapperClickListener=e=>this.wrapperClick(e),this.wrapper.addEventListener("click",this.onWrapperClickListener)),this.wrapperClasses&&(0,s.en)(this.wrapperClasses,this.wrapper),this.el.before(this.wrapper),this.wrapper.append(this.el)}buildExtraMarkup(){const e=e=>{const t=(0,s.fc)(e);return this.wrapper.append(t),t},t=e=>{e.classList.contains("--prevent-click")||e.addEventListener("click",(e=>{e.stopPropagation(),this.toggleFn()}))};if(Array.isArray(this.extraMarkup))this.extraMarkup.forEach((n=>{const s=e(n);t(s)}));else{const n=e(this.extraMarkup);t(n)}}buildToggle(){var e,t;let n,o;this.toggleTextWrapper=document.createElement("span"),this.toggleTextWrapper.classList.add("truncate"),this.toggle=(0,s.fc)(this.toggleTag||"<div></div>"),n=this.toggle.querySelector("[data-icon]"),o=this.toggle.querySelector("[data-title]"),!this.isMultiple&&n&&this.setToggleIcon(),!this.isMultiple&&o&&this.setToggleTitle(),this.isMultiple?this.toggleTextWrapper.innerHTML=this.value.length?this.stringFromValue():this.placeholder:this.toggleTextWrapper.innerHTML=(null===(e=this.getItemByValue(this.value))||void 0===e?void 0:e.title)||this.placeholder,o||this.toggle.append(this.toggleTextWrapper),this.toggleClasses&&(0,s.en)(this.toggleClasses,this.toggle),this.isDisabled&&this.toggle.classList.add("disabled"),this.wrapper&&this.wrapper.append(this.toggle),(null===(t=this.toggle)||void 0===t?void 0:t.ariaExpanded)&&(this.isOpened?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)}setToggleIcon(){var e;const t=this.getItemByValue(this.value),n=this.toggle.querySelector("[data-icon]");if(n){n.innerHTML="";const o=(0,s.fc)(this.apiUrl&&this.apiIconTag?this.apiIconTag||"":(null===(e=null==t?void 0:t.options)||void 0===e?void 0:e.icon)||"");this.value&&this.apiUrl&&this.apiIconTag&&t[this.apiFieldsMap.icon]&&(o.src=t[this.apiFieldsMap.icon]||""),n.append(o),o?n.classList.remove("hidden"):n.classList.add("hidden")}}setToggleTitle(){var e,t;const n=this.toggle.querySelector("[data-title]");n?(n.innerHTML=(null===(e=this.getItemByValue(this.value))||void 0===e?void 0:e.title)||this.placeholder,n.classList.add("truncate"),this.toggle.append(n)):this.toggle.innerText=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder}buildTags(){this.isDisabled&&this.wrapper.classList.add("disabled"),this.buildTagsInput(),this.setTagsItems()}reassignTagsInputPlaceholder(e){this.tagsInput.placeholder=e,this.tagsInputHelper.innerHTML=e,this.calculateInputWidth()}buildTagsItem(e){var t,n,o,a;const i=this.getItemByValue(e);let l,r,d,c;const u=document.createElement("div");if(u.setAttribute("data-tag-value",e),this.tagsItemClasses&&(0,s.en)(this.tagsItemClasses,u),this.tagsItemTemplate&&(l=(0,s.fc)(this.tagsItemTemplate),u.append(l)),(null===(t=null==i?void 0:i.options)||void 0===t?void 0:t.icon)||this.apiIconTag){const e=(0,s.fc)(this.apiUrl&&this.apiIconTag?this.apiIconTag:null===(n=null==i?void 0:i.options)||void 0===n?void 0:n.icon);this.apiUrl&&this.apiIconTag&&i[this.apiFieldsMap.icon]&&(e.src=i[this.apiFieldsMap.icon]||""),c=l?l.querySelector("[data-icon]"):document.createElement("span"),c.append(e),l||u.append(c)}!l||!l.querySelector("[data-icon]")||(null===(o=null==i?void 0:i.options)||void 0===o?void 0:o.icon)||this.apiUrl||this.apiIconTag||i[null===(a=this.apiFieldsMap)||void 0===a?void 0:a.icon]||l.querySelector("[data-icon]").classList.add("hidden"),r=l?l.querySelector("[data-title]"):document.createElement("span"),r.textContent=i.title||"",l||u.append(r),l?d=l.querySelector("[data-remove]"):(d=document.createElement("span"),d.textContent="X",u.append(d)),d.addEventListener("click",(()=>{this.value=this.value.filter((t=>t!==e)),this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.value.length||this.reassignTagsInputPlaceholder(this.placeholder),this.unselectMultipleItems(),this.selectMultipleItems(),u.remove(),this.triggerChangeEventForNativeSelect()})),this.wrapper.append(u)}getItemByValue(e){return this.apiUrl?this.remoteOptions.find((t=>`${t[this.apiFieldsMap.val]}`===e||t[this.apiFieldsMap.title]===e)):this.selectOptions.find((t=>t.val===e))}setTagsItems(){this.value&&this.value.forEach((e=>{this.selectedItems.includes(e)||this.buildTagsItem(e),this.selectedItems=this.selectedItems.includes(e)?this.selectedItems:[...this.selectedItems,e]})),this.isOpened&&this.floatingUIInstance&&this.floatingUIInstance.update()}buildTagsInput(){this.tagsInput=document.createElement("input"),this.tagsInputId&&(this.tagsInput.id=this.tagsInputId),this.tagsInputClasses&&(0,s.en)(this.tagsInputClasses,this.tagsInput),this.onTagsInputFocusListener=()=>this.tagsInputFocus(),this.onTagsInputInputListener=()=>this.tagsInputInput(),this.onTagsInputInputSecondListener=(0,s.sg)((e=>this.tagsInputInputSecond(e))),this.onTagsInputKeydownListener=e=>this.tagsInputKeydown(e),this.tagsInput.addEventListener("focus",this.onTagsInputFocusListener),this.tagsInput.addEventListener("input",this.onTagsInputInputListener),this.tagsInput.addEventListener("input",this.onTagsInputInputSecondListener),this.tagsInput.addEventListener("keydown",this.onTagsInputKeydownListener),this.wrapper.append(this.tagsInput),setTimeout((()=>{this.adjustInputWidth(),this.reassignTagsInputPlaceholder(this.value.length?"":this.placeholder)}))}buildDropdown(){this.dropdown=(0,s.fc)(this.dropdownTag||"<div></div>"),this.dropdown.setAttribute("data-hs-select-dropdown",""),"parent"===this.dropdownScope&&(this.dropdown.classList.add("absolute"),this.dropdownVerticalFixedPlacement||this.dropdown.classList.add("top-full")),this.dropdown.role="listbox",this.dropdown.tabIndex=-1,this.dropdown.ariaOrientation="vertical",this.isOpened||this.dropdown.classList.add("hidden"),this.dropdownClasses&&(0,s.en)(this.dropdownClasses,this.dropdown),this.wrapper&&this.wrapper.append(this.dropdown),this.dropdown&&this.hasSearch&&this.buildSearch(),this.selectOptions&&this.selectOptions.forEach(((e,t)=>this.buildOption(e.title,e.val,e.disabled,e.selected,e.options,`${t}`))),this.apiUrl&&this.optionsFromRemoteData(),"window"===this.dropdownScope&&this.buildFloatingUI()}buildFloatingUI(){if("undefined"!=typeof FloatingUIDOM&&FloatingUIDOM.computePosition){document.body.appendChild(this.dropdown);const e="tags"===this.mode?this.wrapper:this.toggle,t={placement:a.lP[this.dropdownPlacement]||"bottom",strategy:"fixed",middleware:[FloatingUIDOM.offset([0,5])]},n=()=>{FloatingUIDOM.computePosition(e,this.dropdown,t).then((({x:e,y:t,placement:n})=>{Object.assign(this.dropdown.style,{position:"fixed",left:`${e}px`,top:`${t}px`}),this.dropdown.setAttribute("data-placement",n)}))};n();const s=FloatingUIDOM.autoUpdate(e,this.dropdown,n);this.floatingUIInstance={update:n,destroy:s}}else console.error("FloatingUIDOM not found! Please enable it on the page.")}updateDropdownWidth(){const e="tags"===this.mode?this.wrapper:this.toggle;this.dropdown.style.width=`${e.clientWidth}px`}buildSearch(){let e;this.searchWrapper=(0,s.fc)(this.searchWrapperTemplate||"<div></div>"),this.searchWrapperClasses&&(0,s.en)(this.searchWrapperClasses,this.searchWrapper),e=this.searchWrapper.querySelector("[data-input]");const t=(0,s.fc)(this.searchTemplate||'<input type="text">');this.search="INPUT"===t.tagName?t:t.querySelector(":scope input"),this.search.placeholder=this.searchPlaceholder,this.searchClasses&&(0,s.en)(this.searchClasses,this.search),this.searchId&&(this.search.id=this.searchId),this.onSearchInputListener=(0,s.sg)((e=>this.searchInput(e))),this.search.addEventListener("input",this.onSearchInputListener),e?e.append(t):this.searchWrapper.append(t),this.dropdown.append(this.searchWrapper)}buildOption(e,t,n=!1,o=!1,a,i="1",l){var r;let d=null,c=null,u=null,h=null;const p=(0,s.fc)(this.optionTag||"<div></div>");if(p.setAttribute("data-value",t),p.setAttribute("data-title-value",e),p.setAttribute("tabIndex",i),p.classList.add("cursor-pointer"),p.setAttribute("data-id",l||`${this.optionId}`),l||this.optionId++,n&&p.classList.add("disabled"),o&&(this.isMultiple?this.value=[...this.value,t]:this.value=t),this.optionTemplate&&(d=(0,s.fc)(this.optionTemplate),p.append(d)),d?(c=d.querySelector("[data-title]"),c.textContent=e||""):p.textContent=e||"",a){if(a.icon){const t=(0,s.fc)(null!==(r=this.apiIconTag)&&void 0!==r?r:a.icon);if(t.classList.add("max-w-full"),this.apiUrl&&(t.setAttribute("alt",e),t.setAttribute("src",a.icon)),d)u=d.querySelector("[data-icon]"),u.append(t);else{const e=(0,s.fc)("<div></div>");this.iconClasses&&(0,s.en)(this.iconClasses,e),e.append(t),p.append(e)}}if(a.description)if(d)h=d.querySelector("[data-description]"),h&&h.append(a.description);else{const e=(0,s.fc)("<div></div>");e.textContent=a.description,this.descriptionClasses&&(0,s.en)(this.descriptionClasses,e),p.append(e)}}d&&d.querySelector("[data-icon]")&&!a&&!(null==a?void 0:a.icon)&&d.querySelector("[data-icon]").classList.add("hidden"),this.value&&(this.isMultiple?this.value.includes(t):this.value===t)&&p.classList.add("selected"),n||p.addEventListener("click",(()=>this.onSelectOption(t))),this.optionClasses&&(0,s.en)(this.optionClasses,p),this.dropdown&&this.dropdown.append(p),o&&this.setNewValue()}buildOptionFromRemoteData(e,t,n=!1,s=!1,o="1",a,i){o?this.buildOption(e,t,n,s,i,o,a):alert("ID parameter is required for generating remote options! Please check your API endpoint have it.")}buildOptionsFromRemoteData(e){e.forEach(((e,t)=>{let n=null,s="",o="";const a={id:"",val:"",title:"",icon:null,description:null,rest:{}};Object.keys(e).forEach((t=>{var i;e[this.apiFieldsMap.id]&&(n=e[this.apiFieldsMap.id]),(e[this.apiFieldsMap.val]||e[this.apiFieldsMap.title])&&(o=e[this.apiFieldsMap.val]||e[this.apiFieldsMap.title]),e[this.apiFieldsMap.title]&&(s=e[this.apiFieldsMap.title]),e[this.apiFieldsMap.icon]&&(a.icon=e[this.apiFieldsMap.icon]),e[null===(i=this.apiFieldsMap)||void 0===i?void 0:i.description]&&(a.description=e[this.apiFieldsMap.description]),a.rest[t]=e[t]})),this.buildOriginalOption(s,`${o}`,n,!1,!1,a),this.buildOptionFromRemoteData(s,`${o}`,!1,!1,`${t}`,n,a)})),this.sortElements(this.el,"option"),this.sortElements(this.dropdown,"[data-value]")}optionsFromRemoteData(){return i(this,arguments,void 0,(function*(e=""){const t=yield this.apiRequest(e);this.remoteOptions=t,t.length?this.buildOptionsFromRemoteData(this.remoteOptions):console.log("There is no data were responded!")}))}apiRequest(){return i(this,arguments,void 0,(function*(e=""){try{let t=this.apiUrl;const n=this.apiSearchQueryKey?`${this.apiSearchQueryKey}=${e.toLowerCase()}`:null,s=`${this.apiQuery}`,o=this.apiOptions||{};n&&(t+=`?${n}`),this.apiQuery&&(t+=`${n?"&":"?"}${s}`);const a=yield fetch(t,o),i=yield a.json();return this.apiDataPart?i[this.apiDataPart]:i}catch(e){console.error(e)}}))}sortElements(e,t){const n=Array.from(e.querySelectorAll(t));n.sort(((e,t)=>{const n=e.classList.contains("selected")||e.hasAttribute("selected"),s=t.classList.contains("selected")||t.hasAttribute("selected");return n&&!s?-1:!n&&s?1:0})),n.forEach((t=>e.appendChild(t)))}remoteSearch(e){return i(this,void 0,void 0,(function*(){if(e.length<=this.minSearchLength){const e=yield this.apiRequest("");return this.remoteOptions=e,Array.from(this.dropdown.querySelectorAll("[data-value]")).forEach((e=>e.remove())),Array.from(this.el.querySelectorAll("option[value]")).forEach((e=>{e.remove()})),e.length?this.buildOptionsFromRemoteData(e):console.log("No data responded!"),!1}const t=yield this.apiRequest(e);this.remoteOptions=t;let n=t.map((e=>`${e.id}`)),s=null;const o=this.dropdown.querySelectorAll("[data-value]");this.el.querySelectorAll("[data-hs-select-option]").forEach((e=>{var t;const s=e.getAttribute("data-id");n.includes(s)||(null===(t=this.value)||void 0===t?void 0:t.includes(e.value))||this.destroyOriginalOption(e.value)})),o.forEach((e=>{var t;const s=e.getAttribute("data-id");n.includes(s)||(null===(t=this.value)||void 0===t?void 0:t.includes(e.getAttribute("data-value")))?n=n.filter((e=>e!==s)):this.destroyOption(e.getAttribute("data-value"))})),s=t.filter((e=>n.includes(`${e.id}`))),s.length?this.buildOptionsFromRemoteData(s):console.log("No data responded!")}))}destroyOption(e){const t=this.dropdown.querySelector(`[data-value="${e}"]`);if(!t)return!1;t.remove()}buildOriginalOption(e,t,n,o,a,i){const l=(0,s.fc)("<option></option>");l.setAttribute("value",t),o&&l.setAttribute("disabled","disabled"),a&&l.setAttribute("selected","selected"),n&&l.setAttribute("data-id",n),l.setAttribute("data-hs-select-option",JSON.stringify(i)),l.innerText=e,this.el.append(l)}destroyOriginalOption(e){const t=this.el.querySelector(`[value="${e}"]`);if(!t)return!1;t.remove()}buildTagsInputHelper(){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)}calculateInputWidth(){this.tagsInputHelper.textContent=this.tagsInput.value||this.tagsInput.placeholder;const e=parseInt(window.getComputedStyle(this.tagsInput).paddingLeft)+parseInt(window.getComputedStyle(this.tagsInput).paddingRight),t=parseInt(window.getComputedStyle(this.tagsInput).borderLeftWidth)+parseInt(window.getComputedStyle(this.tagsInput).borderRightWidth),n=this.tagsInputHelper.offsetWidth+e+t,s=this.wrapper.offsetWidth-(parseInt(window.getComputedStyle(this.wrapper).paddingLeft)+parseInt(window.getComputedStyle(this.wrapper).paddingRight));this.tagsInput.style.width=`${Math.min(n,s)+2}px`}adjustInputWidth(){this.buildTagsInputHelper(),this.calculateInputWidth()}onSelectOption(e){if(this.clearSelections(),this.isMultiple?(this.value=this.value.includes(e)?Array.from(this.value).filter((t=>t!==e)):[...Array.from(this.value),e],this.selectMultipleItems(),this.setNewValue()):(this.value=e,this.selectSingleItem(),this.setNewValue()),this.fireEvent("change",this.value),"tags"===this.mode){const e=this.selectedItems.filter((e=>!this.value.includes(e)));e.length&&e.forEach((e=>{this.selectedItems=this.selectedItems.filter((t=>t!==e)),this.wrapper.querySelector(`[data-tag-value="${e}"]`).remove()})),this.resetTagsInputField()}this.isMultiple||(this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.close(!0)),this.value.length||"tags"!==this.mode||this.reassignTagsInputPlaceholder(this.placeholder),this.isOpened&&"tags"===this.mode&&this.tagsInput&&this.tagsInput.focus(),this.triggerChangeEventForNativeSelect()}triggerChangeEventForNativeSelect(){const e=new Event("change",{bubbles:!0});this.el.dispatchEvent(e),(0,s.JD)("change.hs.select",this.el,this.value)}addSelectOption(e,t,n,s,o){this.selectOptions=[...this.selectOptions,{title:e,val:t,disabled:n,selected:s,options:o}]}removeSelectOption(e,t=!1){if(!!!this.selectOptions.some((t=>t.val===e)))return!1;this.selectOptions=this.selectOptions.filter((t=>t.val!==e)),this.value=t?this.value.filter((t=>t!==e)):e}resetTagsInputField(){this.tagsInput.value="",this.reassignTagsInputPlaceholder(""),this.searchOptions("")}clearSelections(){Array.from(this.dropdown.children).forEach((e=>{e.classList.contains("selected")&&e.classList.remove("selected")})),Array.from(this.el.children).forEach((e=>{e.selected&&(e.selected=!1)}))}setNewValue(){var e;"tags"===this.mode?this.setTagsItems():(null===(e=this.value)||void 0===e?void 0:e.length)?this.toggleTextWrapper.innerHTML=this.stringFromValue():this.toggleTextWrapper.innerHTML=this.placeholder}stringFromValueBasic(e){var t;const n=[];let s="";if(e.forEach((e=>{this.isMultiple?this.value.includes(e.val)&&n.push(e.title):this.value===e.val&&n.push(e.title)})),void 0!==this.toggleCountText&&null!==this.toggleCountText&&n.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){const e=n.slice(0,this.toggleCountTextMinItems-1),o=[e.join(this.toggleSeparators.items)],a=""+(n.length-e.length);if((null===(t=null==this?void 0:this.toggleSeparators)||void 0===t?void 0:t.betweenItemsAndCounter)&&o.push(this.toggleSeparators.betweenItemsAndCounter),this.toggleCountText)switch(this.toggleCountTextPlacement){case"postfix-no-space":o.push(`${a}${this.toggleCountText}`);break;case"prefix-no-space":o.push(`${this.toggleCountText}${a}`);break;case"prefix":o.push(`${this.toggleCountText} ${a}`);break;default:o.push(`${a} ${this.toggleCountText}`)}s=o.join(" ")}else s=`${n.length} ${this.toggleCountText}`;else s=n.join(this.toggleSeparators.items);return s}stringFromValueRemoteData(){const e=this.dropdown.querySelectorAll("[data-title-value]"),t=[];let n="";if(e.forEach((e=>{const n=e.getAttribute("data-value"),s=e.getAttribute("data-title-value");this.isMultiple?this.value.includes(n)&&t.push(s):this.value===n&&t.push(s)})),this.toggleCountText&&""!==this.toggleCountText&&t.length>=this.toggleCountTextMinItems)if("nItemsAndCount"===this.toggleCountTextMode){const e=t.slice(0,this.toggleCountTextMinItems-1);n=`${e.join(this.toggleSeparators.items)} ${this.toggleSeparators.betweenItemsAndCounter} ${t.length-e.length} ${this.toggleCountText}`}else n=`${t.length} ${this.toggleCountText}`;else n=t.join(this.toggleSeparators.items);return n}stringFromValue(){return this.apiUrl?this.stringFromValueRemoteData():this.stringFromValueBasic(this.selectOptions)}selectSingleItem(){Array.from(this.el.children).find((e=>this.value===e.value)).selected=!0;const e=Array.from(this.dropdown.children).find((e=>this.value===e.getAttribute("data-value")));e&&e.classList.add("selected")}selectMultipleItems(){Array.from(this.dropdown.children).filter((e=>this.value.includes(e.getAttribute("data-value")))).forEach((e=>e.classList.add("selected"))),Array.from(this.el.children).filter((e=>this.value.includes(e.value))).forEach((e=>e.selected=!0))}unselectMultipleItems(){Array.from(this.dropdown.children).forEach((e=>e.classList.remove("selected"))),Array.from(this.el.children).forEach((e=>e.selected=!1))}searchOptions(e){if(e.length<=this.minSearchLength){this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null);return this.dropdown.querySelectorAll("[data-value]").forEach((e=>{e.classList.remove("hidden")})),!1}this.searchNoResult&&(this.searchNoResult.remove(),this.searchNoResult=null),this.searchNoResult=(0,s.fc)(this.searchNoResultTemplate),this.searchNoResult.innerText=this.searchNoResultText,(0,s.en)(this.searchNoResultClasses,this.searchNoResult);const t=this.dropdown.querySelectorAll("[data-value]");let n,o=!1;this.searchLimit&&(n=0),t.forEach((t=>{const s=t.getAttribute("data-title-value").toLocaleLowerCase();let a;if(this.isSearchDirectMatch)a=!s.includes(e.toLowerCase())||this.searchLimit&&n>=this.searchLimit;else{const t=e?e.split("").map((e=>/\w/.test(e)?`${e}[\\W_]*`:"\\W*")).join(""):"";a=!new RegExp(t,"i").test(s.trim())||this.searchLimit&&n>=this.searchLimit}a?t.classList.add("hidden"):(t.classList.remove("hidden"),o=!0,this.searchLimit&&n++)})),o||this.dropdown.append(this.searchNoResult)}eraseToggleIcon(){const e=this.toggle.querySelector("[data-icon]");e&&(e.innerHTML=null,e.classList.add("hidden"))}eraseToggleTitle(){const e=this.toggle.querySelector("[data-title]");e?e.innerHTML=this.placeholder:this.toggleTextWrapper.innerHTML=this.placeholder}toggleFn(){this.isOpened?this.close():this.open()}destroy(){this.wrapper&&this.wrapper.removeEventListener("click",this.onWrapperClickListener),this.toggle&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.tagsInput&&(this.tagsInput.removeEventListener("focus",this.onTagsInputFocusListener),this.tagsInput.removeEventListener("input",this.onTagsInputInputListener),this.tagsInput.removeEventListener("input",this.onTagsInputInputSecondListener),this.tagsInput.removeEventListener("keydown",this.onTagsInputKeydownListener)),this.search&&this.search.removeEventListener("input",this.onSearchInputListener);const e=this.el.parentElement.parentElement;this.el.classList.add("hidden"),this.el.style.display="",e.prepend(this.el),e.querySelector(".hs-select").remove(),this.wrapper=null,window.$hsSelectCollection=window.$hsSelectCollection.filter((({element:e})=>e.el!==this.el))}open(){var e;const t=(null===(e=null===window||void 0===window?void 0:window.$hsSelectCollection)||void 0===e?void 0:e.find((e=>e.element.isOpened)))||null;if(t&&t.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((()=>{var e;(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.wrapper.classList.add("active"),this.dropdown.classList.add("opened"),this.dropdown.classList.contains("w-full")&&"window"===this.dropdownScope&&this.updateDropdownWidth(),this.floatingUIInstance&&"window"===this.dropdownScope&&(this.floatingUIInstance.update(),this.dropdown.classList.remove("invisible")),this.hasSearch&&!this.preventSearchFocus&&this.search.focus(),this.animationInProcess=!1})),this.isOpened=!0}close(e=!1){var t,n,o,a;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===(n=this.dropdownDirectionClasses)||void 0===n?void 0:n.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),(null===(o=this.dropdownDirectionClasses)||void 0===o?void 0:o.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.style.marginBottom="",(0,s.yd)(this.dropdown,(()=>{this.dropdown.classList.add("hidden"),this.hasSearch&&(this.search.value="",this.search.dispatchEvent(new Event("input",{bubbles:!0})),this.search.blur()),e&&this.toggle.focus(),this.animationInProcess=!1})),null===(a=this.dropdown.querySelector(".hs-select-option-highlighted"))||void 0===a||a.classList.remove("hs-select-option-highlighted"),this.isOpened=!1}addOption(e){let t=`${this.selectOptions.length}`;const n=e=>{const{title:n,val:s,disabled:o,selected:a,options:i}=e;!!this.selectOptions.some((e=>e.val===s))||(this.addSelectOption(n,s,o,a,i),this.buildOption(n,s,o,a,i,t),this.buildOriginalOption(n,s,null,o,a,i),a&&!this.isMultiple&&this.onSelectOption(s))};Array.isArray(e)?e.forEach((e=>{n(e)})):n(e)}removeOption(e){const t=(e,t=!1)=>{!!this.selectOptions.some((t=>t.val===e))&&(this.removeSelectOption(e,t),this.destroyOption(e),this.destroyOriginalOption(e),this.value===e&&(this.value=null,this.eraseToggleTitle(),this.eraseToggleIcon()))};Array.isArray(e)?e.forEach((e=>{t(e,this.isMultiple)})):t(e,this.isMultiple),this.setNewValue()}recalculateDirection(){var e,t,n,o;if((null==this?void 0:this.dropdownVerticalFixedPlacement)&&(this.dropdown.classList.contains("bottom-full")||this.dropdown.classList.contains("top-full")))return!1;"top"===(null==this?void 0:this.dropdownVerticalFixedPlacement)?(this.dropdown.classList.add("bottom-full"),this.dropdown.style.marginBottom=`${this.dropdownSpace}px`):"bottom"===(null==this?void 0:this.dropdownVerticalFixedPlacement)?(this.dropdown.classList.add("top-full"),this.dropdown.style.marginTop=`${this.dropdownSpace}px`):(0,s.PR)(this.dropdown,this.toggle||this.tagsInput,"bottom",this.dropdownSpace,this.viewport)?(this.dropdown.classList.remove("bottom-full"),(null===(e=this.dropdownDirectionClasses)||void 0===e?void 0:e.bottom)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom="",this.dropdown.classList.add("top-full"),(null===(t=this.dropdownDirectionClasses)||void 0===t?void 0:t.top)&&this.dropdown.classList.add(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop=`${this.dropdownSpace}px`):(this.dropdown.classList.remove("top-full"),(null===(n=this.dropdownDirectionClasses)||void 0===n?void 0:n.top)&&this.dropdown.classList.remove(this.dropdownDirectionClasses.top),this.dropdown.style.marginTop="",this.dropdown.classList.add("bottom-full"),(null===(o=this.dropdownDirectionClasses)||void 0===o?void 0:o.bottom)&&this.dropdown.classList.add(this.dropdownDirectionClasses.bottom),this.dropdown.style.marginBottom=`${this.dropdownSpace}px`)}static findInCollection(e){return window.$hsSelectCollection.find((t=>e instanceof l?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e))||null}static getInstance(e,t){const n=window.$hsSelectCollection.find((t=>t.element.el===("string"==typeof e?document.querySelector(e):e)));return n?t?n:n.element:null}static autoInit(){window.$hsSelectCollection||(window.$hsSelectCollection=[],window.addEventListener("click",(e=>{const t=e.target;l.closeCurrentlyOpened(t)})),document.addEventListener("keydown",(e=>l.accessibility(e)))),window.$hsSelectCollection&&(window.$hsSelectCollection=window.$hsSelectCollection.filter((({element:e})=>document.contains(e.el)))),document.querySelectorAll("[data-hs-select]:not(.--prevent-on-load-init)").forEach((e=>{if(!window.$hsSelectCollection.find((t=>{var n;return(null===(n=null==t?void 0:t.element)||void 0===n?void 0:n.el)===e}))){const t=e.getAttribute("data-hs-select"),n=t?JSON.parse(t):{};new l(e,n)}}))}static open(e){const t=l.findInCollection(e);t&&!t.element.isOpened&&t.element.open()}static close(e){const t=l.findInCollection(e);t&&t.element.isOpened&&t.element.close()}static closeCurrentlyOpened(e=null){if(!e.closest(".hs-select.active")&&!e.closest("[data-hs-select-dropdown].opened")){const e=window.$hsSelectCollection.filter((e=>e.element.isOpened))||null;e&&e.forEach((e=>{e.element.close()}))}}static accessibility(e){const t=window.$hsSelectCollection.find((e=>e.element.isOpened));if(t&&a.fp.includes(e.code)&&!e.metaKey)switch(e.code){case"Escape":e.preventDefault(),this.onEscape();break;case"ArrowUp":e.preventDefault(),e.stopImmediatePropagation(),this.onArrow();break;case"ArrowDown":e.preventDefault(),e.stopImmediatePropagation(),this.onArrow(!1);break;case"Tab":e.preventDefault(),e.stopImmediatePropagation(),this.onTab(e.shiftKey);break;case"Home":e.preventDefault(),e.stopImmediatePropagation(),this.onStartEnd();break;case"End":e.preventDefault(),e.stopImmediatePropagation(),this.onStartEnd(!1);break;case"Enter":e.preventDefault(),this.onEnter(e);break;case"Space":if((0,s.ar)(t.element.search))break;e.preventDefault(),this.onEnter(e)}}static onEscape(){const e=window.$hsSelectCollection.find((e=>e.element.isOpened));e&&e.element.close()}static onArrow(e=!0){const t=window.$hsSelectCollection.find((e=>e.element.isOpened));if(t){const n=t.element.dropdown;if(!n)return!1;const s=(e?Array.from(n.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(n.querySelectorAll(":scope > *:not(.hidden)"))).filter((e=>!e.classList.contains("disabled"))),o=n.querySelector(".hs-select-option-highlighted")||n.querySelector(".selected");o||s[0].classList.add("hs-select-option-highlighted");let a=s.findIndex((e=>e===o));a+1<s.length&&a++,s[a].focus(),o&&o.classList.remove("hs-select-option-highlighted"),s[a].classList.add("hs-select-option-highlighted")}}static onTab(e=!0){const t=window.$hsSelectCollection.find((e=>e.element.isOpened));if(t){const n=t.element.dropdown;if(!n)return!1;const s=(e?Array.from(n.querySelectorAll(":scope > *:not(.hidden)")).reverse():Array.from(n.querySelectorAll(":scope > *:not(.hidden)"))).filter((e=>!e.classList.contains("disabled"))),o=n.querySelector(".hs-select-option-highlighted")||n.querySelector(".selected");o||s[0].classList.add("hs-select-option-highlighted");let a=s.findIndex((e=>e===o));if(!(a+1<s.length))return o&&o.classList.remove("hs-select-option-highlighted"),t.element.close(),t.element.toggle.focus(),!1;a++,s[a].focus(),o&&o.classList.remove("hs-select-option-highlighted"),s[a].classList.add("hs-select-option-highlighted")}}static onStartEnd(e=!0){const t=window.$hsSelectCollection.find((e=>e.element.isOpened));if(t){const n=t.element.dropdown;if(!n)return!1;const s=(e?Array.from(n.querySelectorAll(":scope > *:not(.hidden)")):Array.from(n.querySelectorAll(":scope > *:not(.hidden)")).reverse()).filter((e=>!e.classList.contains("disabled"))),o=n.querySelector(".hs-select-option-highlighted");s.length&&(s[0].focus(),o&&o.classList.remove("hs-select-option-highlighted"),s[0].classList.add("hs-select-option-highlighted"))}}static onEnter(e){const t=e.target.previousSibling;if(window.$hsSelectCollection.find((e=>e.element.el===t))){const e=window.$hsSelectCollection.find((e=>e.element.isOpened)),n=window.$hsSelectCollection.find((e=>e.element.el===t));e.element.close(),e!==n&&n.element.open()}else{const t=window.$hsSelectCollection.find((e=>e.element.isOpened));t&&t.element.onSelectOption(e.target.dataset.value||"")}}}window.addEventListener("load",(()=>{l.autoInit()})),document.addEventListener("scroll",(()=>{if(!window.$hsSelectCollection)return!1;const e=window.$hsSelectCollection.find((e=>e.element.isOpened));e&&e.element.recalculateDirection()})),"undefined"!=typeof window&&(window.HSSelect=l);const r=l},615:(e,t,n)=>{n.d(t,{A:()=>s});class s{constructor(e,t,n){this.el=e,this.options=t,this.events=n,this.el=e,this.options=t,this.events={}}createCollection(e,t){var n;e.push({id:(null===(n=null==t?void 0:t.el)||void 0===n?void 0:n.id)||e.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}},926:(e,t,n)=>{n.d(t,{JD:()=>i,PR:()=>s,ar:()=>o,en:()=>d,fc:()=>r,sg:()=>a,yd:()=>l}); /* * @version: 3.0.1 * @author: Preline Labs Ltd. * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) * Copyright 2024 Preline Labs Ltd. */ const s=(e,t,n="auto",s=10,o=null)=>{const a=t.getBoundingClientRect(),i=o?o.getBoundingClientRect():null,l=window.innerHeight,r=i?a.top-i.top:a.top,d=(o?i.bottom:l)-a.bottom,c=e.clientHeight+s;return"bottom"===n?d>=c:"top"===n?r>=c:r>=c||d>=c},o=e=>document.activeElement===e,a=(e,t=200)=>{let n;return(...s)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(void 0,s)}),t)}},i=(e,t,n=null)=>{const s=new CustomEvent(e,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(s)},l=(e,t)=>{const n=()=>{t(),e.removeEventListener("transitionend",n,!0)},s=window.getComputedStyle(e),o=s.getPropertyValue("transition-duration");"none"!==s.getPropertyValue("transition-property")&&parseFloat(o)>0?e.addEventListener("transitionend",n,!0):t()},r=e=>{const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild},d=(e,t,n=" ",s="add")=>{e.split(n).forEach((e=>"add"===s?t.classList.add(e):t.classList.remove(e)))}}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};n.d(s,{A:()=>Xe});var o=n(926),a=Object.defineProperty,i=Object.defineProperties,l=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,u=(e,t,n)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&u(e,n,t[n]);if(r)for(var n of r(t))c.call(t,n)&&u(e,n,t[n]);return e},p=(e,t,n)=>(u(e,"symbol"!=typeof t?t+"":t,n),n);const m=e=>`${e} is not found, check the first argument passed to new Calendar.`,v='The calendar has not been initialized, please initialize it using the "init()" method first.',g="You specified an incorrect language label or did not specify the required number of values ​​for «locale.weekdays» or «locale.months».",y="The value of the time property can be: false, 12 or 24.",b="For the «multiple» calendar type, the «displayMonthsCount» parameter can have a value from 2 to 12, and for all others it cannot be greater than 1.",w=(e,t,n)=>{e.context[t]=n};function f(e){if(!e||!e.getBoundingClientRect)return{top:0,bottom:0,left:0,right:0};const t=e.getBoundingClientRect(),n=document.documentElement;return{bottom:t.bottom,right:t.right,top:t.top+window.scrollY-n.clientTop,left:t.left+window.scrollX-n.clientLeft}}function x(){return{vw:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),vh:Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)}}function M(e){const{top:t,left:n}={left:window.scrollX||document.documentElement.scrollLeft||0,top:window.scrollY||document.documentElement.scrollTop||0},{top:s,left:o}=f(e),{vh:a,vw:i}=x(),l=s-t,r=o-n;return{top:l,bottom:a-(l+e.clientHeight),left:r,right:i-(r+e.clientWidth)}}function D(e,t,n=5){const s={top:!0,bottom:!0,left:!0,right:!0},o=[];if(!t||!e)return{canShow:s,parentPositions:o};const{bottom:a,top:i}=M(e),{top:l,left:r}=f(e),{height:d,width:c}=t.getBoundingClientRect(),{vh:u,vw:h}=x(),p=h/2,m=u/2;return[{condition:l<m,position:"top"},{condition:l>m,position:"bottom"},{condition:r<p,position:"left"},{condition:r>p,position:"right"}].forEach((({condition:e,position:t})=>{e&&o.push(t)})),Object.assign(s,{top:d<=i-n,bottom:d<=a-n,left:c<=r,right:c<=h-r}),{canShow:s,parentPositions:o}}const C=(e,t)=>{var n;e.popups&&(null==(n=Object.entries(e.popups))||n.forEach((([n,s])=>((e,t,n,s)=>{var o;const a=s.querySelector(`[data-vc-date="${t}"]`),i=null==a?void 0:a.querySelector("[data-vc-date-btn]");if(!a||!i)return;if((null==n?void 0:n.modifier)&&i.classList.add(...n.modifier.trim().split(" ")),!(null==n?void 0:n.html))return;const l=document.createElement("div");l.className=e.styles.datePopup,l.dataset.vcDatePopup="",l.innerHTML=e.sanitizerHTML(n.html),i.ariaExpanded="true",i.ariaLabel=`${i.ariaLabel}, ${null==(o=null==l?void 0:l.textContent)?void 0:o.replace(/^\s+|\s+(?=\s)|\s+$/g,"").replace(/&nbsp;/g," ")}`,a.appendChild(l),requestAnimationFrame((()=>{if(!l)return;const{canShow:e}=D(a,l),t=e.bottom?a.offsetHeight:-l.offsetHeight,n=e.left&&!e.right?a.offsetWidth-l.offsetWidth/2:!e.left&&e.right?l.offsetWidth/2:0;Object.assign(l.style,{left:`${n}px`,top:`${t}px`})}))})(e,n,s,t))))},k=e=>new Date(`${e}T00:00:00`),T=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,E=e=>e.reduce(((e,t)=>{if(t instanceof Date||"number"==typeof t){const n=t instanceof Date?t:new Date(t);e.push(n.toISOString().substring(0,10))}else t.match(/^(\d{4}-\d{2}-\d{2})$/g)?e.push(t):t.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g,((t,n,s)=>{const o=k(n),a=k(s),i=new Date(o.getTime());for(;i<=a;i.setDate(i.getDate()+1))e.push(T(i));return t}));return e}),[]),S=(e,t,n,s="")=>{t?e.setAttribute(n,s):e.getAttribute(n)===s&&e.removeAttribute(n)},I=(e,t,n,s,o,a,i)=>{var l,r,d,c;const u=k(e.context.displayDateMin)>k(a)||k(e.context.displayDateMax)<k(a)||(null==(l=e.context.disableDates)?void 0:l.includes(a))||!e.selectionMonthsMode&&"current"!==i||!e.selectionYearsMode&&k(a).getFullYear()!==t;S(n,u,"data-vc-date-disabled"),s&&S(s,u,"aria-disabled","true"),s&&S(s,u,"tabindex","-1"),S(n,!e.disableToday&&e.context.dateToday===a,"data-vc-date-today"),S(n,!e.disableToday&&e.context.dateToday===a,"aria-current","date"),S(n,null==(r=e.selectedWeekends)?void 0:r.includes(o),"data-vc-date-weekend");const h=(null==(d=e.selectedHolidays)?void 0:d[0])?E(e.selectedHolidays):[];if(S(n,h.includes(a),"data-vc-date-holiday"),(null==(c=e.context.selectedDates)?void 0:c.includes(a))?(n.setAttribute("data-vc-date-selected",""),s&&s.setAttribute("aria-selected","true"),e.context.selectedDates.length>1&&"multiple-ranged"===e.selectionDatesMode&&(e.context.selectedDates[0]===a&&e.context.selectedDates[e.context.selectedDates.length-1]===a?n.setAttribute("data-vc-date-selected","first-and-last"):e.context.selectedDates[0]===a?n.setAttribute("data-vc-date-selected","first"):e.context.selectedDates[e.context.selectedDates.length-1]===a&&n.setAttribute("data-vc-date-selected","last"),e.context.selectedDates[0]!==a&&e.context.selectedDates[e.context.selectedDates.length-1]!==a&&n.setAttribute("data-vc-date-selected","middle"))):n.hasAttribute("data-vc-date-selected")&&(n.removeAttribute("data-vc-date-selected"),s&&s.removeAttribute("aria-selected")),!e.context.disableDates.includes(a)&&e.enableEdgeDatesOnly&&e.context.selectedDates.length>1&&"multiple-ranged"===e.selectionDatesMode){const t=k(e.context.selectedDates[0]),s=k(e.context.selectedDates[e.context.selectedDates.length-1]),o=k(a);S(n,o>t&&o<s,"data-vc-date-selected","middle")}},A=(e,t)=>{const n=k(e),s=(n.getDay()-t+7)%7;n.setDate(n.getDate()+4-s);const o=new Date(n.getFullYear(),0,1),a=Math.ceil(((+n-+o)/864e5+1)/7);return{year:n.getFullYear(),week:a}},L=(e,t,n,s,o,a)=>{const i=k(o).getDay(),l="string"==typeof e.locale&&e.locale.length?e.locale:"en",r=document.createElement("div");let d;r.className=e.styles.date,r.dataset.vcDate=o,r.dataset.vcDateMonth=a,r.dataset.vcDateWeekDay=String(i),("current"===a||e.displayDatesOutside)&&(d=document.createElement("button"),d.className=e.styles.dateBtn,d.type="button",d.role="gridcell",d.ariaLabel=((e,t,n)=>new Date(`${e}T00:00:00.000Z`).toLocaleString(t,n))(o,l,{dateStyle:"long",timeZone:"UTC"}),d.dataset.vcDateBtn="",d.innerText=String(s),r.appendChild(d)),e.enableWeekNumbers&&((e,t,n)=>{const s=A(n,e.firstWeekday);s&&(t.dataset.vcDateWeekNumber=String(s.week))})(e,r,o),((e,t,n)=>{var s,o,a,i,l;const r=null==(s=e.disableWeekdays)?void 0:s.includes(n),d=e.disableAllDates&&!!(null==(o=e.context.enableDates)?void 0:o[0]);!r&&!d||(null==(a=e.context.enableDates)?void 0:a.includes(t))||(null==(i=e.context.disableDates)?void 0:i.includes(t))||(e.context.disableDates.push(t),null==(l=e.context.disableDates)||l.sort(((e,t)=>+new Date(e)-+new Date(t))))})(e,o,i),I(e,t,r,d,i,o,a),n.appendChild(r),e.onCreateDateEls&&e.onCreateDateEls(e,r)},$=e=>{const t=new Date(e.context.selectedYear,e.context.selectedMonth,1),n=e.context.mainElement.querySelectorAll('[data-vc="dates"]'),s=e.context.mainElement.querySelectorAll('[data-vc-week="numbers"]');n.forEach(((n,o)=>{e.selectionDatesMode||(n.dataset.vcDatesDisabled=""),n.textContent="";const a=new Date(t);a.setMonth(a.getMonth()+o);const i=a.getMonth(),l=a.getFullYear(),r=(new Date(l,i,1).getDay()-e.firstWeekday+7)%7,d=new Date(l,i+1,0).getDate();((e,t,n,s,o)=>{let a=new Date(n,s,0).getDate()-(o-1);const i=0===s?n-1:n,l=0===s?12:s<10?`0${s}`:s;for(let s=o;s>0;s--,a++)L(e,n,t,a,`${i}-${l}-${a}`,"prev")})(e,n,l,i,r),((e,t,n,s,o)=>{for(let a=1;a<=n;a++){const n=new Date(s,o,a);L(e,s,t,a,T(n),"current")}})(e,n,d,l,i),((e,t,n,s,o,a)=>{const i=a+n,l=7*Math.ceil(i/7)-i,r=o+1===12?s+1:s,d=o+1===12?"01":o+2<10?`0${o+2}`:o+2;for(let n=1;n<=l;n++){const o=n<10?`0${n}`:String(n);L(e,s,t,n,`${r}-${d}-${o}`,"next")}})(e,n,d,l,i,r),C(e,n),((e,t,n,s,o)=>{if(!e.enableWeekNumbers)return;s.textContent="";const a=document.createElement("b");a.className=e.styles.weekNumbersTitle,a.innerText="#",a.dataset.vcWeekNumbers="title",s.appendChild(a);const i=document.createElement("div");i.className=e.styles.weekNumbersContent,i.dataset.vcWeekNumbers="content",s.appendChild(i);const l=document.createElement("button");l.type="button",l.className=e.styles.weekNumber;const r=o.querySelectorAll("[data-vc-date]"),d=Math.ceil((t+n)/7);for(let t=0;t<d;t++){const n=r[0===t?6:7*t].dataset.vcDate,s=A(n,e.firstWeekday);if(!s)return;const o=l.cloneNode(!0);o.innerText=String(s.week),o.dataset.vcWeekNumber=String(s.week),o.dataset.vcWeekYear=String(s.year),o.role="rowheader",o.ariaLabel=`${s.week}`,i.appendChild(o)}})(e,r,d,s[o],n)}))},O=e=>`\n <div class="${e.styles.header}" data-vc="header" role="toolbar" aria-label="${e.labels.navigation}">\n <#ArrowPrev [month] />\n <div class="${e.styles.headerContent}" data-vc-header="content">\n <#Month />\n <#Year />\n </div>\n <#ArrowNext [month] />\n </div>\n <div class="${e.styles.wrapper}" data-vc="wrapper">\n <#WeekNumbers />\n <div class="${e.styles.content}" data-vc="content">\n <#Week />\n <#Dates />\n <#DateRangeTooltip />\n </div>\n </div>\n <#ControlTime />\n`,N=e=>`\n <div class="${e.styles.header}" data-vc="header" role="toolbar" aria-label="${e.labels.navigation}">\n <div class="${e.styles.headerContent}" data-vc-header="content">\n <#Month />\n <#Year />\n </div>\n </div>\n <div class="${e.styles.wrapper}" data-vc="wrapper">\n <div class="${e.styles.content}" data-vc="content">\n <#Months />\n </div>\n </div>\n`,Y=e=>`\n <div class="${e.styles.controls}" data-vc="controls" role="toolbar" aria-label="${e.labels.navigation}">\n <#ArrowPrev [month] />\n <#ArrowNext [month] />\n </div>\n <div class="${e.styles.grid}" data-vc="grid">\n <#Multiple>\n <div class="${e.styles.column}" data-vc="column" role="region">\n <div class="${e.styles.header}" data-vc="header">\n <div class="${e.styles.headerContent}" data-vc-header="content">\n <#Month />\n <#Year />\n </div>\n </div>\n <div class="${e.styles.wrapper}" data-vc="wrapper">\n <#WeekNumbers />\n <div class="${e.styles.content}" data-vc="content">\n <#Week />\n <#Dates />\n </div>\n </div>\n </div>\n <#/Multiple>\n <#DateRangeTooltip />\n </div>\n <#ControlTime />\n`,q=e=>`\n <div class="${e.styles.header}" data-vc="header" role="toolbar" aria-label="${e.labels.navigation}">\n <#ArrowPrev [year] />\n <div class="${e.styles.headerContent}" data-vc-header="content">\n <#Month />\n <#Year />\n </div>\n <#ArrowNext [year] />\n </div>\n <div class="${e.styles.wrapper}" data-vc="wrapper">\n <div class="${e.styles.content}" data-vc="content">\n <#Years />\n </div>\n </div>\n`,F={ArrowNext:(e,t)=>`<button type="button" class="${e.styles.arrowNext}" data-vc-arrow="next" aria-label="${e.labels.arrowNext[t]}"></button>`,ArrowPrev:(e,t)=>`<button type="butto