preline
Version:
Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
24 lines • 30.9 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(self,()=>(()=>{"use strict";var e={8223(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BREAKPOINTS=t.COMBO_BOX_ACCESSIBILITY_KEY_SET=t.SELECT_ACCESSIBILITY_KEY_SET=t.TABS_ACCESSIBILITY_KEY_SET=t.OVERLAY_ACCESSIBILITY_KEY_SET=t.DROPDOWN_ACCESSIBILITY_KEY_SET=t.POSITIONS=void 0,t.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"},t.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Home","End","Enter"],t.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],t.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],t.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"],t.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],t.BREAKPOINTS={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},248(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});const n=i(292);t.default=class{constructor(){this.components=[],this.currentlyOpenedComponents=[],this.activeComponent=null,this.allowedKeybindings=new Set(["Escape","Enter"," ","Space","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Tab","Home","End"]),this.initGlobalListeners()}initGlobalListeners(){document.addEventListener("keydown",e=>this.handleGlobalKeydown(e)),document.addEventListener("focusin",e=>this.handleGlobalFocusin(e))}isAllowedKeybinding(e){return!!this.allowedKeybindings.has(e.key)||!(1!==e.key.length||!/^[a-zA-Z]$/.test(e.key)||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)}getActiveComponent(e){if(!e)return null;const t=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));if(0===t.length)return null;if(1===t.length)return t[0];let i=null,n=Number.MAX_SAFE_INTEGER;for(const o of t){let t=0,s=e;for(;s&&s!==o.wrapper&&s!==o.context;)t++,s=s.parentElement;t<n&&(n=t,i=o)}return i}getActiveComponentForKey(e,t){if(!e)return null;const i=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));if(0===i.length)return null;const n=i.filter(e=>{const i=e.handlers;switch(t){case"Escape":return!!i.onEsc;case"Enter":return!!i.onEnter;case" ":case"Space":return!!i.onSpace;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":return!!i.onArrow;case"Tab":return!!i.onTab||!!i.onShiftTab;case"Home":return!!i.onHome;case"End":return!!i.onEnd;default:return!!i.onFirstLetter}});if(0===n.length)return this.getActiveComponent(e);if(1===n.length)return n[0];let o=null,s=Number.MAX_SAFE_INTEGER;for(const t of n){let i=0,n=e;for(;n&&n!==t.wrapper&&n!==t.context;)i++,n=n.parentElement;i<s&&(s=i,o=t)}return o}getDistanceToComponent(e,t){let i=0,n=e;for(;n&&n!==t.wrapper&&n!==t.context;)i++,n=n.parentElement;return i}getComponentsByNesting(e){if(!e)return[];const t=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));return t.length<=1?t:[...t].sort((t,i)=>this.getDistanceToComponent(e,i)-this.getDistanceToComponent(e,t))}getSequentialHandlersForKey(e,t){const i=this.getComponentsByNesting(e);return 0===i.length?[]:i.map(e=>"Enter"===t?e.handlers.onEnter:e.handlers.onSpace).filter(e=>"function"==typeof e)}executeSequentialHandlers(e,t){let i=!1,n=!1;for(const o of e){i=!0;if(!1===o(t)){n=!0;break}}return{called:i,stopped:n}}handleGlobalFocusin(e){const t=e.target;this.activeComponent=this.getActiveComponent(t)}handleGlobalKeydown(e){var t;const i=e.target;this.activeComponent=this.getActiveComponentForKey(i,e.key);const o=this.activeComponent,s="Enter"===e.key||" "===e.key||"Space"===e.key;if((o||s)&&this.isAllowedKeybinding(e))switch(e.key){case"Escape":if(!o)break;if(o.isOpened){if(o.handlers.onEsc){const t=o.handlers.onEsc();if(e.preventDefault(),e.stopPropagation(),!1===t){const e=this.findClosestOpenParent(i);(null==e?void 0:e.handlers.onEsc)&&e.handlers.onEsc()}}}else{const t=this.findClosestOpenParent(i);(null==t?void 0:t.handlers.onEsc)&&(t.handlers.onEsc(),e.preventDefault(),e.stopPropagation())}break;case"Enter":{const t=this.getSequentialHandlersForKey(i,"Enter");if(0===t.length)break;const{called:o,stopped:s}=this.executeSequentialHandlers(t,e);if(o&&!(0,n.isFormElement)(i)&&(e.stopPropagation(),e.preventDefault()),s)break;break}case" ":case"Space":{if("INPUT"===i.tagName||"TEXTAREA"===i.tagName)return;const t=this.getActiveComponent(i),n=this.getSequentialHandlersForKey(i,"Space");if(0===n.length)break;const{stopped:o}=this.executeSequentialHandlers(n);(o||(null==t?void 0:t.handlers.onSpace))&&(e.preventDefault(),e.stopPropagation());break}case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(!o)break;if(o.handlers.onArrow){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;o.handlers.onArrow(e),e.preventDefault(),e.stopPropagation()}break;case"Tab":if(!o)break;if(!o.handlers.onTab)break;const s=e.shiftKey?o.handlers.onShiftTab:o.handlers.onTab;s&&s(e);break;case"Home":if(!o)break;o.handlers.onHome&&(o.handlers.onHome(),e.preventDefault(),e.stopPropagation());break;case"End":if(!o)break;o.handlers.onEnd&&(o.handlers.onEnd(),e.preventDefault(),e.stopPropagation());break;default:if(!o)break;if(o.handlers.onFirstLetter&&1===e.key.length&&/^[a-zA-Z]$/.test(e.key)){if(o.handlers.onFirstLetter(e.key),!(null===(t=o.stopPropagation)||void 0===t?void 0:t.onFirstLetter))return;e.preventDefault(),e.stopPropagation()}}}findClosestOpenParent(e){let t=e.parentElement;for(;t;){const e=this.currentlyOpenedComponents.find(e=>e.wrapper===t&&e!==this.activeComponent);if(e)return e;t=t.parentElement}return null}registerComponent(e,t,i=!0,n="",o="",s,l){const r={wrapper:e,handlers:t,isOpened:i,name:n,selector:o,context:s,isRegistered:!0,stopPropagation:l};return this.components.push(r),r}updateComponentState(e,t){e.isOpened=t,t?this.currentlyOpenedComponents.includes(e)||this.currentlyOpenedComponents.push(e):this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter(t=>t!==e)}unregisterComponent(e){this.components=this.components.filter(t=>t!==e),this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter(t=>t!==e)}addAllowedKeybinding(e){this.allowedKeybindings.add(e)}removeAllowedKeybinding(e){this.allowedKeybindings.delete(e)}getAllowedKeybindings(){return Array.from(this.allowedKeybindings)}}},2961(e,t){
/*
* HSBasePlugin
* @version: 4.2.0
* @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.
*/
Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,i){this.el=e,this.options=t,this.events=i,this.el=e,this.options=t,this.events={}}createCollection(e,t){var i,n;let o=e;if(!Array.isArray(o)&&"undefined"!=typeof window){const e=null===(i=this.constructor)||void 0===i?void 0:i.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),o=window[t])}Array.isArray(o)&&o.push({id:(null===(n=null==t?void 0:t.el)||void 0===n?void 0:n.id)||o.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}}},2447(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=n(i(4343)),s=i(292);let l=null;const r=(e=!1)=>{var t,i;if(!(null===(t=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===t?void 0:t.length)||!(null===(i=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===i?void 0:i.find(e=>e.element.autoClose)))return!1;window.$hsOverlayCollection.filter(t=>t.element.autoClose&&(!e||t.element.isToggleClassesImmediately)).forEach(e=>{const{autoCloseEqualityType:t,autoClose:i}=e.element;("less-than"===t?document.body.clientWidth<=i:document.body.clientWidth>=i)&&e.element.el.classList.contains("opened")?(e.element.el.classList.contains("minified")&&e.element.minify(!1),e.element.close(!0)):e.element.isLayoutAffect&&e.element.el.classList.contains("opened")&&document.body.classList.add("hs-overlay-body-open")})},a=()=>{var e,t;if(!(null===(e=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===e?void 0:e.length)||!(null===(t=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===t?void 0:t.find(e=>e.element.moveOverlayToBody)))return!1;window.$hsOverlayCollection.filter(e=>e.element.moveOverlayToBody).forEach(e=>{const t=e.element.moveOverlayToBody,i=e.element.initContainer,n=document.querySelector("body"),o=e.element.el;if(!i&&o)return!1;document.body.clientWidth<=t&&!(0,s.isDirectChild)(n,o)?n.appendChild(o):document.body.clientWidth>t&&!i.contains(o)&&i.appendChild(o)})},d=(e=!1)=>{var t,i;if(!(null===(t=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===t?void 0:t.length)||!(null===(i=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===i?void 0:i.find(e=>e.element.openedBreakpoint)))return!1;window.$hsOverlayCollection.filter(t=>t.element.openedBreakpoint&&(!e||t.element.isToggleClassesImmediately)).forEach(e=>{const{openedBreakpoint:t}=e.element;document.body.clientWidth>=t?e.element.el.classList.contains("opened")||o.default.setOpened(t,e):e.element.el.classList.contains("opened")&&(e.element.el.classList.contains("minified")&&e.element.minify(!1),e.element.close(!0))})},c=()=>{var e;(null===(e=window.$hsOverlayCollection)||void 0===e?void 0:e.length)&&window.$hsOverlayCollection.forEach(e=>{var t;const i=e.element;(null===(t=i.toggleMinifierButtons)||void 0===t?void 0:t.length)>0&&i.openedBreakpoint&&(document.body.clientWidth>=i.openedBreakpoint?document.body.classList.add("hs-overlay-body-open"):document.body.classList.remove("hs-overlay-body-open"))})};window.addEventListener("load",()=>{o.default.autoInit(),a(),c()}),window.addEventListener("resize",()=>{r(!0),d(!0),((e,t=150)=>{l&&clearTimeout(l),l=setTimeout(e,t)})(()=>{r(),d()}),a(),(()=>{var e,t;if(!(null===(e=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===e?void 0:e.length)||!(null===(t=null===window||void 0===window?void 0:window.$hsOverlayCollection)||void 0===t?void 0:t.find(e=>e.element.el.classList.contains("opened"))))return!1;window.$hsOverlayCollection.filter(e=>e.element.el.classList.contains("opened")).forEach(e=>{const t=parseInt(window.getComputedStyle(e.element.el).getPropertyValue("z-index")),i=document.querySelector(`#${e.element.el.id}-backdrop`);return!!i&&(t!==parseInt(window.getComputedStyle(i).getPropertyValue("z-index"))+1&&("style"in i&&(i.style.zIndex=""+(t-1)),void document.body.classList.add("hs-overlay-body-open")))})})(),c()}),"undefined"!=typeof window&&(window.HSOverlay=o.default)},4343(e,t,i){
/*
* HSOverlay
* @version: 4.2.0
* @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.
*/
var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(292),s=i(8223),l=n(i(2961)),r=n(i(248));class a extends l.default{constructor(e,t,i){var n,l,r,a,d,c,h;super(e,t,i),this.lastFocusedToggle=null,this.initialZIndex=0,window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),this.toggleButtons=Array.from(document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`));const u=this.collectToggleParameters(this.toggleButtons);this.toggleMinifierButtons=Array.from(document.querySelectorAll(`[data-hs-overlay-minifier="#${this.el.id}"]`));const p=e.getAttribute("data-hs-overlay-options"),y=p?JSON.parse(p):{},m=Object.assign(Object.assign(Object.assign({},y),u),t);this.hiddenClass=(null==m?void 0:m.hiddenClass)||"hidden",this.emulateScrollbarSpace=(null==m?void 0:m.emulateScrollbarSpace)||!1,this.isClosePrev=null===(n=null==m?void 0:m.isClosePrev)||void 0===n||n,this.backdropClasses=null!==(l=null==m?void 0:m.backdropClasses)&&void 0!==l?l:"hs-overlay-backdrop transition duration fixed inset-0 bg-gray-900/50 dark:bg-neutral-900/80",this.backdropParent="string"==typeof m.backdropParent?document.querySelector(m.backdropParent):document.body,this.backdropExtraClasses=null!==(r=null==m?void 0:m.backdropExtraClasses)&&void 0!==r?r:"",this.moveOverlayToBody=(null==m?void 0:m.moveOverlayToBody)||null,this.isToggleClassesImmediately=null!==(a=null==m?void 0:m.isToggleClassesImmediately)&&void 0!==a?a:(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--toggle-classes-immediately","false")||"false"),this.openNextOverlay=!1,this.autoHide=null,this.initContainer=(null===(d=this.el)||void 0===d?void 0:d.parentElement)||null,this.isCloseWhenClickInside=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--close-when-click-inside","false")||"false"),this.isTabAccessibilityLimited=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--tab-accessibility-limited","true")||"true"),this.isLayoutAffect=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--is-layout-affect","false")||"false"),this.hasAutofocus=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--has-autofocus","true")||"true"),this.hasDynamicZIndex=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--has-dynamic-z-index","false")||"false"),this.hasAbilityToCloseOnBackdropClick=(0,o.stringToBoolean)(this.el.getAttribute("data-hs-overlay-keyboard")||"true"),this.isScrollInsideViewport="inside-viewport"===(0,o.getClassProperty)(this.el,"--overlay-scroll-behavior"),this.onScrollInsideViewportClickListener=null;const f=(0,o.getClassProperty)(this.el,"--auto-close"),v=(0,o.getClassProperty)(this.el,"--auto-close-equality-type"),g=(0,o.getClassProperty)(this.el,"--opened");this.autoClose=!isNaN(+f)&&isFinite(+f)?+f:s.BREAKPOINTS[f]||null,this.autoCloseEqualityType=null!==(c=v)&&void 0!==c?c:null,this.openedBreakpoint=(!isNaN(+g)&&isFinite(+g)?+g:s.BREAKPOINTS[g])||null,this.animationTarget=(null===(h=null==this?void 0:this.el)||void 0===h?void 0:h.querySelector(".hs-overlay-animation-target"))||this.el,this.initialZIndex=parseInt(getComputedStyle(this.el).zIndex,10),this.onElementClickListener=[],this.onElementMinifierClickListener=[],this.initiallyOpened=this.isOpened(),this.init()}elementClick(){const e=()=>{const e={el:this.el,isOpened:!!this.el.classList.contains("open")};this.fireEvent("toggleClicked",e),(0,o.dispatch)("toggleClicked.hs.overlay",this.el,e)};this.el.classList.contains("opened")?this.close(!1,e):this.open(e)}elementMinifierClick(){const e=()=>{const e={el:this.el,isMinified:!!this.el.classList.contains("minified")};this.fireEvent("toggleMinifierClicked",e),(0,o.dispatch)("toggleMinifierClicked.hs.overlay",this.el,e)};this.el.classList.contains("minified")?this.minify(!1,e):this.minify(!0,e)}minify(e,t=null){e?(this.el.classList.add("minified"),document.body.classList.add("hs-overlay-minified"),t&&t()):(this.el.classList.remove("minified"),document.body.classList.remove("hs-overlay-minified"),t&&t())}overlayClick(e){e.target.id&&e.target.id===this.el.id&&this.isCloseWhenClickInside&&this.hasAbilityToCloseOnBackdropClick&&this.close()}backdropClick(){this.close()}init(){if(this.createCollection(window.$hsOverlayCollection,this),this.isLayoutAffect&&this.openedBreakpoint){const e=a.getInstance(this.el,!0);a.setOpened(this.openedBreakpoint,e)}this.onOverlayClickListener=e=>this.overlayClick(e),this.el.addEventListener("click",this.onOverlayClickListener),this.toggleButtons.length&&this.buildToggleButtons(this.toggleButtons),this.toggleMinifierButtons.length&&this.buildToggleMinifierButtons(),"undefined"!=typeof window&&(window.HSAccessibilityObserver||(window.HSAccessibilityObserver=new r.default),this.setupAccessibility())}buildToggleButtons(e){e.forEach(e=>{this.el.classList.contains("opened")?e.ariaExpanded="true":e.ariaExpanded="false",this.onElementClickListener.push({el:e,fn:()=>this.elementClick()}),e.addEventListener("click",this.onElementClickListener.find(t=>t.el===e).fn)})}buildToggleMinifierButtons(){this.toggleMinifierButtons.forEach(e=>{this.el.classList.contains("minified")?e.ariaExpanded="true":e.ariaExpanded="false",this.onElementMinifierClickListener.push({el:e,fn:()=>this.elementMinifierClick()}),e.addEventListener("click",this.onElementMinifierClickListener.find(t=>t.el===e).fn)})}hideAuto(){const e=parseInt((0,o.getClassProperty)(this.el,"--auto-hide","0"));e&&(this.autoHide=setTimeout(()=>{this.close()},e))}checkTimer(){this.autoHide&&(clearTimeout(this.autoHide),this.autoHide=null)}buildBackdrop(){const e=this.el.classList.value.split(" "),t=parseInt(window.getComputedStyle(this.el).getPropertyValue("z-index")),i=this.el.getAttribute("data-hs-overlay-backdrop-container")||!1;this.backdrop=document.createElement("div");let n=`${this.backdropClasses} ${this.backdropExtraClasses}`;const s="static"!==(0,o.getClassProperty)(this.el,"--overlay-backdrop","true"),l="false"===(0,o.getClassProperty)(this.el,"--overlay-backdrop","true");this.backdrop.id=`${this.el.id}-backdrop`,"style"in this.backdrop&&(this.backdrop.style.zIndex=""+(t-1));for(const t of e)(t.startsWith("hs-overlay-backdrop-open:")||t.includes(":hs-overlay-backdrop-open:"))&&(n+=` ${t}`);l||(i&&(this.backdrop=document.querySelector(i).cloneNode(!0),this.backdrop.classList.remove("hidden"),n=`${this.backdrop.classList.toString()}`,this.backdrop.classList.value=""),s&&(this.onBackdropClickListener=()=>this.backdropClick(),this.backdrop.addEventListener("click",this.onBackdropClickListener,!0)),this.backdrop.setAttribute("data-hs-overlay-backdrop-template",""),this.backdropParent.appendChild(this.backdrop),setTimeout(()=>{this.backdrop.classList.value=n}))}destroyBackdrop(){const e=document.querySelector(`#${this.el.id}-backdrop`);e&&(this.openNextOverlay&&(e.style.transitionDuration=1.8*parseFloat(window.getComputedStyle(e).transitionDuration.replace(/[^\d.-]/g,""))+"s"),e.classList.add("opacity-0"),(0,o.afterTransition)(e,()=>{e.remove()}))}focusElement(){const e=this.el.querySelector("[autofocus]");if(!e)return!1;e.focus()}getBodyCurrentScrollbarSize(){return Math.max(window.innerWidth-document.documentElement.clientWidth,0)}collectToggleParameters(e){let t={};return e.forEach(e=>{const i=e.getAttribute("data-hs-overlay-options"),n=i?JSON.parse(i):{};t=Object.assign(Object.assign({},t),n)}),t}isElementVisible(){const e=window.getComputedStyle(this.el);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity)return!1;const t=this.el.getBoundingClientRect();if(0===t.width||0===t.height)return!1;let i=this.el.parentElement;for(;i;){const e=window.getComputedStyle(i);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity)return!1;i=i.parentElement}return!0}isOpened(){return this.el.classList.contains("open")&&!this.el.classList.contains(this.hiddenClass)}open(e=null){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),this.el.classList.contains("minified")&&this.minify(!1),this.hasDynamicZIndex&&(a.currentZIndex<this.initialZIndex&&(a.currentZIndex=this.initialZIndex),a.currentZIndex++,this.el.style.zIndex=`${a.currentZIndex}`);const t=document.querySelectorAll(".hs-overlay.open"),i=window.$hsOverlayCollection.find(e=>Array.from(t).includes(e.element.el)&&!e.element.isLayoutAffect),n=document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`),s="true"!==(0,o.getClassProperty)(this.el,"--body-scroll","false");if(this.lastFocusedToggle=document.activeElement,this.isClosePrev&&i)return this.openNextOverlay=!0,i.element.close().then(()=>{this.open(),this.openNextOverlay=!1});s&&(this.emulateScrollbarSpace&&(document.body.style.paddingRight=`${this.getBodyCurrentScrollbarSize()}px`),document.body.style.overflow="hidden"),this.buildBackdrop(),this.checkTimer(),this.hideAuto(),n.forEach(e=>{e.ariaExpanded&&(e.ariaExpanded="true")}),this.el.classList.remove(this.hiddenClass),this.el.setAttribute("aria-overlay","true"),this.el.setAttribute("tabindex","-1");const l=()=>{if(this.el.classList.contains("opened"))return!1;this.el.classList.add("open","opened"),this.isLayoutAffect&&document.body.classList.add("hs-overlay-body-open"),!this.initiallyOpened&&this.hasAutofocus&&(this.el.focus({preventScroll:!0}),this.el.style.outline="none"),this.initiallyOpened=!1,this.fireEvent("open",this.el),(0,o.dispatch)("open.hs.overlay",this.el,this.el),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!0),this.hasAutofocus&&this.focusElement(),"function"==typeof e&&e(),this.isScrollInsideViewport&&(this.el.style.pointerEvents="auto",this.onScrollInsideViewportClickListener=e=>{e.target===this.el&&this.hasAbilityToCloseOnBackdropClick&&this.close()},this.el.addEventListener("click",this.onScrollInsideViewportClickListener)),this.isElementVisible()&&a.openedItemsQty++};this.isToggleClassesImmediately?l():setTimeout(l,50)}close(e=!1,t=null){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),this.isElementVisible()&&(a.openedItemsQty=a.openedItemsQty<=0?0:a.openedItemsQty-1),0===a.openedItemsQty&&this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open");const i=e=>{if(this.el.classList.contains("open"))return!1;document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`).forEach(e=>{e.ariaExpanded&&(e.ariaExpanded="false")}),this.el.classList.add(this.hiddenClass),this.hasDynamicZIndex&&(this.el.style.zIndex=""),this.destroyBackdrop(),this.fireEvent("close",this.el),(0,o.dispatch)("close.hs.overlay",this.el,this.el),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!1);if(window.$hsOverlayCollection.some(e=>e.element.el.classList.contains("opened")&&!e.element.isLayoutAffect)||(document.body.style.overflow="",this.emulateScrollbarSpace&&(document.body.style.paddingRight="")),this.lastFocusedToggle&&(this.lastFocusedToggle.focus(),this.lastFocusedToggle=null),e(this.el),"function"==typeof t&&t(),0===a.openedItemsQty){if(!this.isLayoutAffect){window.$hsOverlayCollection.some(e=>e.element.isLayoutAffect&&e.element.el.classList.contains("opened"))||document.body.classList.remove("hs-overlay-body-open")}this.hasDynamicZIndex&&(a.currentZIndex=0)}};return new Promise(t=>{this.el.classList.remove("open","opened"),this.el.removeAttribute("aria-overlay"),this.el.removeAttribute("tabindex"),this.el.style.outline="",this.isScrollInsideViewport&&(this.el.style.pointerEvents="",this.onScrollInsideViewportClickListener&&(this.el.removeEventListener("click",this.onScrollInsideViewportClickListener),this.onScrollInsideViewportClickListener=null)),e||this.isToggleClassesImmediately?i(t):(0,o.afterTransition)(this.animationTarget,()=>i(t))})}updateToggles(){const e=Array.from(document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`)).filter(e=>!this.toggleButtons.includes(e));e.length&&(this.toggleButtons.push(...e),this.buildToggleButtons(e)),this.toggleButtons=this.toggleButtons.filter(e=>{var t;if(document.contains(e))return!0;const i=null===(t=this.onElementClickListener)||void 0===t?void 0:t.find(t=>t.el===e);return i&&e.removeEventListener("click",i.fn),!1})}destroy(){window.$hsOverlayCollection&&(this.el.classList.remove("open","opened",this.hiddenClass),this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open"),this.el.removeEventListener("click",this.onOverlayClickListener),this.onElementClickListener.length&&(this.onElementClickListener.forEach(({el:e,fn:t})=>{e.removeEventListener("click",t)}),this.onElementClickListener=null),this.backdrop&&this.backdrop.removeEventListener("click",this.onBackdropClickListener),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),this.onScrollInsideViewportClickListener&&(this.el.removeEventListener("click",this.onScrollInsideViewportClickListener),this.onScrollInsideViewportClickListener=null),window.$hsOverlayCollection=window.$hsOverlayCollection.filter(({element:e})=>e.el!==this.el))}static findInCollection(e){return window.$hsOverlayCollection&&window.$hsOverlayCollection.find(t=>e instanceof a?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e)||null}static getInstance(e,t){const i="string"==typeof e?document.querySelector(e):e,n=(null==i?void 0:i.getAttribute("data-hs-overlay"))?i.getAttribute("data-hs-overlay"):e,o=window.$hsOverlayCollection.find(e=>e.element.el===("string"==typeof n?document.querySelector(n):n)||e.element.el===("string"==typeof n?document.querySelector(n):n));return o?t?o:o.element.el:null}static autoInit(){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),window.$hsOverlayCollection&&(window.$hsOverlayCollection=window.$hsOverlayCollection.filter(({element:e})=>document.contains(e.el))),a.openedItemsQty=window.$hsOverlayCollection.filter(({element:e})=>e.el.classList.contains("opened")).length,document.querySelectorAll(".hs-overlay:not(.--prevent-on-load-init)").forEach(e=>{window.$hsOverlayCollection.find(t=>{var i;return(null===(i=null==t?void 0:t.element)||void 0===i?void 0:i.el)===e})||new a(e)}),window.$hsOverlayCollection.forEach(({element:e})=>{e.updateToggles()})}static open(e){const t=a.findInCollection(e);t&&t.element.el.classList.contains(t.element.hiddenClass)&&t.element.open()}static close(e){const t=a.findInCollection(e);t&&!t.element.el.classList.contains(t.element.hiddenClass)&&t.element.close()}static minify(e,t){const i=a.findInCollection(e);i&&i.element.minify(t)}static setOpened(e,t){document.body.clientWidth>=e?(t.element.el.classList.contains("minified")&&t.element.minify(!1),document.body.classList.add("hs-overlay-body-open"),t.element.open()):t.element.close(!0)}setupAccessibility(){this.accessibilityComponent=window.HSAccessibilityObserver.registerComponent(this.el,{onEnter:()=>{this.isOpened()||this.open()},onEsc:()=>{this.isOpened()&&this.hasAbilityToCloseOnBackdropClick&&this.close()},onTab:()=>{var e;if(!this.isOpened()||!this.isTabAccessibilityLimited)return;const t=Array.from(this.el.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.hidden&&"none"!==window.getComputedStyle(e).display);if(0===t.length)return;const i=this.el.querySelector(":focus"),n=i?t.indexOf(i):-1;window.event instanceof KeyboardEvent&&window.event.shiftKey?n<=0?t[t.length-1].focus():t[n-1].focus():n===t.length-1?t[0].focus():t[n+1].focus(),null===(e=window.event)||void 0===e||e.preventDefault()}},this.isOpened(),"Overlay",".hs-overlay"),this.toggleButtons.forEach(e=>{window.HSAccessibilityObserver.registerComponent(e,{onEnter:()=>{this.isOpened()?this.close():this.open()},onEsc:()=>{this.isOpened()&&this.hasAbilityToCloseOnBackdropClick&&this.close()}},this.isOpened(),"Overlay Toggle",`[data-hs-overlay="#${this.el.id}"]`)})}static on(e,t,i){const n=a.findInCollection(t);n&&(n.element.events[e]=i)}}a.openedItemsQty=0,a.currentZIndex=0,t.default=a},292(e,t){
/*
* @version: 4.2.0
* @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.
*/
Object.defineProperty(t,"__esModule",{value:!0}),t.stringToBoolean=t.menuSearchHistory=t.isScrollable=t.isParentOrElementHidden=t.isJson=t.isIpadOS=t.isIOS=t.isFormElement=t.isFocused=t.isEnoughSpace=t.isDirectChild=t.htmlToElement=t.getZIndex=t.getHighestZIndex=t.getClassPropertyAlt=t.getClassProperty=t.dispatch=t.debounce=t.classToClassList=t.afterTransition=void 0;t.stringToBoolean=e=>"true"===e;t.getClassProperty=(e,t,i="")=>(window.getComputedStyle(e).getPropertyValue(t)||i).replace(" ","");t.getClassPropertyAlt=(e,t,i="")=>{let n="";return e.classList.forEach(e=>{e.includes(t)&&(n=e)}),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:i};const i=e=>window.getComputedStyle(e).getPropertyValue("z-index");t.getZIndex=i;t.getHighestZIndex=e=>{let t=Number.NEGATIVE_INFINITY;return e.forEach(e=>{let n=i(e);"auto"!==n&&(n=parseInt(n,10),n>t&&(t=n))}),t};t.isDirectChild=(e,t)=>{const i=e.children;for(let e=0;e<i.length;e++)if(i[e]===t)return!0;return!1};t.isEnoughSpace=(e,t,i="auto",n=10,o=null)=>{const s=t.getBoundingClientRect(),l=o?o.getBoundingClientRect():null,r=window.innerHeight,a=l?s.top-l.top:s.top,d=(o?l.bottom:r)-s.bottom,c=e.clientHeight+n;return"bottom"===i?d>=c:"top"===i?a>=c:a>=c||d>=c};t.isFocused=e=>document.activeElement===e;t.isFormElement=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement;t.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isJson=e=>{if("string"!=typeof e)return!1;const t=e.trim()[0],i=e.trim().slice(-1);if("{"===t&&"}"===i||"["===t&&"]"===i)try{return JSON.parse(e),!0}catch(e){return!1}return!1};const n=e=>{if(!e)return!1;return"none"===window.getComputedStyle(e).display||n(e.parentElement)};t.isParentOrElementHidden=n;t.isScrollable=e=>{const t=window.getComputedStyle(e),i=t.overflowY,n=t.overflowX,o=("scroll"===i||"auto"===i)&&e.scrollHeight>e.clientHeight,s=("scroll"===n||"auto"===n)&&e.scrollWidth>e.clientWidth;return o||s};t.debounce=(e,t=200)=>{let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>{e.apply(this,n)},t)}};t.dispatch=(e,t,i=null)=>{const n=new CustomEvent(e,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(n)};t.afterTransition=(e,t)=>{const i=()=>{t(),e.removeEventListener("transitionend",i,!0)},n=window.getComputedStyle(e),o=n.getPropertyValue("transition-duration");"none"!==n.getPropertyValue("transition-property")&&parseFloat(o)>0?e.addEventListener("transitionend",i,!0):t()};t.htmlToElement=e=>{const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=(e,t,i=" ",n="add")=>{e.split(i).forEach(e=>{e.trim()&&("add"===n?t.classList.add(e):t.classList.remove(e))})};const o={historyIndex:-1,addHistory(e){this.historyIndex=e},existsInHistory(e){return e>this.historyIndex},clearHistory(){this.historyIndex=-1}};t.menuSearchHistory=o}},t={};var i=function i(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}(2447);return i})());