UNPKG

preline

Version:

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

24 lines 40.5 kB
var e={189(e,t,n){n.d(t,{lP:()=>o});const o={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"}},8862(e,t,n){n.d(t,{A:()=>i});var o=n(1926);const i=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 n=null,o=Number.MAX_SAFE_INTEGER;for(const i of t){let t=0,s=e;for(;s&&s!==i.wrapper&&s!==i.context;)t++,s=s.parentElement;t<o&&(o=t,n=i)}return n}getActiveComponentForKey(e,t){if(!e)return null;const n=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));if(0===n.length)return null;const o=n.filter(e=>{const n=e.handlers;switch(t){case"Escape":return!!n.onEsc;case"Enter":return!!n.onEnter;case" ":case"Space":return!!n.onSpace;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":return!!n.onArrow;case"Tab":return!!n.onTab||!!n.onShiftTab;case"Home":return!!n.onHome;case"End":return!!n.onEnd;default:return!!n.onFirstLetter}});if(0===o.length)return this.getActiveComponent(e);if(1===o.length)return o[0];let i=null,s=Number.MAX_SAFE_INTEGER;for(const t of o){let n=0,o=e;for(;o&&o!==t.wrapper&&o!==t.context;)n++,o=o.parentElement;n<s&&(s=n,i=t)}return i}getDistanceToComponent(e,t){let n=0,o=e;for(;o&&o!==t.wrapper&&o!==t.context;)n++,o=o.parentElement;return n}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,n)=>this.getDistanceToComponent(e,n)-this.getDistanceToComponent(e,t))}getSequentialHandlersForKey(e,t){const n=this.getComponentsByNesting(e);return 0===n.length?[]:n.map(e=>"Enter"===t?e.handlers.onEnter:e.handlers.onSpace).filter(e=>"function"==typeof e)}executeSequentialHandlers(e,t){let n=!1,o=!1;for(const i of e){n=!0;if(!1===i(t)){o=!0;break}}return{called:n,stopped:o}}handleGlobalFocusin(e){const t=e.target;this.activeComponent=this.getActiveComponent(t)}handleGlobalKeydown(e){var t;const n=e.target;this.activeComponent=this.getActiveComponentForKey(n,e.key);const i=this.activeComponent,s="Enter"===e.key||" "===e.key||"Space"===e.key;if((i||s)&&this.isAllowedKeybinding(e))switch(e.key){case"Escape":if(!i)break;if(i.isOpened){if(i.handlers.onEsc){const t=i.handlers.onEsc();if(e.preventDefault(),e.stopPropagation(),!1===t){const e=this.findClosestOpenParent(n);(null==e?void 0:e.handlers.onEsc)&&e.handlers.onEsc()}}}else{const t=this.findClosestOpenParent(n);(null==t?void 0:t.handlers.onEsc)&&(t.handlers.onEsc(),e.preventDefault(),e.stopPropagation())}break;case"Enter":{const t=this.getSequentialHandlersForKey(n,"Enter");if(0===t.length)break;const{called:i,stopped:s}=this.executeSequentialHandlers(t,e);if(i&&!(0,o.V6)(n)&&(e.stopPropagation(),e.preventDefault()),s)break;break}case" ":case"Space":{if("INPUT"===n.tagName||"TEXTAREA"===n.tagName)return;const t=this.getActiveComponent(n),o=this.getSequentialHandlersForKey(n,"Space");if(0===o.length)break;const{stopped:i}=this.executeSequentialHandlers(o);(i||(null==t?void 0:t.handlers.onSpace))&&(e.preventDefault(),e.stopPropagation());break}case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(!i)break;if(i.handlers.onArrow){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;i.handlers.onArrow(e),e.preventDefault(),e.stopPropagation()}break;case"Tab":if(!i)break;if(!i.handlers.onTab)break;const s=e.shiftKey?i.handlers.onShiftTab:i.handlers.onTab;s&&s(e);break;case"Home":if(!i)break;i.handlers.onHome&&(i.handlers.onHome(),e.preventDefault(),e.stopPropagation());break;case"End":if(!i)break;i.handlers.onEnd&&(i.handlers.onEnd(),e.preventDefault(),e.stopPropagation());break;default:if(!i)break;if(i.handlers.onFirstLetter&&1===e.key.length&&/^[a-zA-Z]$/.test(e.key)){if(i.handlers.onFirstLetter(e.key),!(null===(t=i.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,n=!0,o="",i="",s,r){const l={wrapper:e,handlers:t,isOpened:n,name:o,selector:i,context:s,isRegistered:!0,stopPropagation:r};return this.components.push(l),l}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)}}},7615(e,t,n){n.d(t,{A:()=>o}); /* * 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. */ class o{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,o;let i=e;if(!Array.isArray(i)&&"undefined"!=typeof window){const e=null===(n=this.constructor)||void 0===n?void 0:n.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),i=window[t])}Array.isArray(i)&&i.push({id:(null===(o=null==t?void 0:t.el)||void 0===o?void 0:o.id)||i.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}}},1926(e,t,n){n.d(t,{BF:()=>s,JD:()=>c,PK:()=>o,V6:()=>r,gj:()=>i,un:()=>l,yd:()=>d,zG:()=>a}); /* * @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. */ const o=e=>"true"===e,i=(e,t,n="")=>(window.getComputedStyle(e).getPropertyValue(t)||n).replace(" ",""),s=(e,t,n="")=>{let o="";return e.classList.forEach(e=>{e.includes(t)&&(o=e)}),o.match(/:(.*)]/)?o.match(/:(.*)]/)[1]:n},r=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,l=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),a=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),c=(e,t,n=null)=>{const o=new CustomEvent(e,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(o)},d=(e,t)=>{const n=()=>{t(),e.removeEventListener("transitionend",n,!0)},o=window.getComputedStyle(e),i=o.getPropertyValue("transition-duration");"none"!==o.getPropertyValue("transition-property")&&parseFloat(i)>0?e.addEventListener("transitionend",n,!0):t()}},7663(e,t,n){n.d(t,{ll:()=>he,rD:()=>me,UU:()=>pe,cY:()=>fe});const o=Math.min,i=Math.max,s=Math.round,r=Math.floor,l=e=>({x:e,y:e}),a={left:"right",right:"left",bottom:"top",top:"bottom"};function c(e,t){return"function"==typeof e?e(t):e}function d(e){return e.split("-")[0]}function u(e){return e.split("-")[1]}function h(e){return"y"===e?"height":"width"}function f(e){const t=e[0];return"t"===t||"b"===t?"y":"x"}function p(e){return"x"===f(e)?"y":"x"}function m(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const g=["left","right"],w=["right","left"],y=["top","bottom"],v=["bottom","top"];function b(e,t,n,o){const i=u(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?w:g:t?g:w;case"left":case"right":return t?y:v;default:return[]}}(d(e),"start"===n,o);return i&&(s=s.map(e=>e+"-"+i),t&&(s=s.concat(s.map(m)))),s}function x(e){const t=d(e);return a[t]+e.slice(t.length)}function E(e){const{x:t,y:n,width:o,height:i}=e;return{width:o,height:i,top:n,left:t,right:t+o,bottom:n+i,x:t,y:n}}function L(e,t,n){let{reference:o,floating:i}=e;const s=f(t),r=p(t),l=h(r),a=d(t),c="y"===s,m=o.x+o.width/2-i.width/2,g=o.y+o.height/2-i.height/2,w=o[l]/2-i[l]/2;let y;switch(a){case"top":y={x:m,y:o.y-i.height};break;case"bottom":y={x:m,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:g};break;case"left":y={x:o.x-i.width,y:g};break;default:y={x:o.x,y:o.y}}switch(u(t)){case"start":y[r]-=w*(n&&c?-1:1);break;case"end":y[r]+=w*(n&&c?-1:1)}return y}async function C(e,t){var n;void 0===t&&(t={});const{x:o,y:i,platform:s,rects:r,elements:l,strategy:a}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=c(t,e),m=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(p),g=l[f?"floating"===h?"reference":"floating":h],w=E(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(g)))||n?g:g.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:a})),y="floating"===h?{x:o,y:i,width:r.floating.width,height:r.floating.height}:r.reference,v=await(null==s.getOffsetParent?void 0:s.getOffsetParent(l.floating)),b=await(null==s.isElement?void 0:s.isElement(v))&&await(null==s.getScale?void 0:s.getScale(v))||{x:1,y:1},x=E(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:v,strategy:a}):y);return{top:(w.top-x.top+m.top)/b.y,bottom:(x.bottom-w.bottom+m.bottom)/b.y,left:(w.left-x.left+m.left)/b.x,right:(x.right-w.right+m.right)/b.x}}const A=new Set(["left","top"]);function T(){return"undefined"!=typeof window}function S(e){return P(e)?(e.nodeName||"").toLowerCase():"#document"}function k(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function O(e){var t;return null==(t=(P(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function P(e){return!!T()&&(e instanceof Node||e instanceof k(e).Node)}function M(e){return!!T()&&(e instanceof Element||e instanceof k(e).Element)}function D(e){return!!T()&&(e instanceof HTMLElement||e instanceof k(e).HTMLElement)}function R(e){return!(!T()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof k(e).ShadowRoot)}function F(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=B(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&"inline"!==i&&"contents"!==i}function I(e){return/^(table|td|th)$/.test(S(e))}function H(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}const K=/transform|translate|scale|rotate|perspective|filter/,V=/paint|layout|strict|content/,$=e=>!!e&&"none"!==e;let q;function U(e){const t=M(e)?B(e):e;return $(t.transform)||$(t.translate)||$(t.scale)||$(t.rotate)||$(t.perspective)||!N()&&($(t.backdropFilter)||$(t.filter))||K.test(t.willChange||"")||V.test(t.contain||"")}function N(){return null==q&&(q="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),q}function W(e){return/^(html|body|#document)$/.test(S(e))}function B(e){return k(e).getComputedStyle(e)}function j(e){return M(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function z(e){if("html"===S(e))return e;const t=e.assignedSlot||e.parentNode||R(e)&&e.host||O(e);return R(t)?t.host:t}function G(e){const t=z(e);return W(t)?e.ownerDocument?e.ownerDocument.body:e.body:D(t)&&F(t)?t:G(t)}function X(e,t,n){var o;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=G(e),s=i===(null==(o=e.ownerDocument)?void 0:o.body),r=k(i);if(s){const e=_(r);return t.concat(r,r.visualViewport||[],F(i)?i:[],e&&n?X(e):[])}return t.concat(i,X(i,[],n))}function _(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Y(e){const t=B(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=D(e),r=i?e.offsetWidth:n,l=i?e.offsetHeight:o,a=s(n)!==r||s(o)!==l;return a&&(n=r,o=l),{width:n,height:o,$:a}}function J(e){return M(e)?e:e.contextElement}function Z(e){const t=J(e);if(!D(t))return l(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:r}=Y(t);let a=(r?s(n.width):n.width)/o,c=(r?s(n.height):n.height)/i;return a&&Number.isFinite(a)||(a=1),c&&Number.isFinite(c)||(c=1),{x:a,y:c}}const Q=l(0);function ee(e){const t=k(e);return N()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Q}function te(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),s=J(e);let r=l(1);t&&(o?M(o)&&(r=Z(o)):r=Z(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==k(e))&&t}(s,n,o)?ee(s):l(0);let c=(i.left+a.x)/r.x,d=(i.top+a.y)/r.y,u=i.width/r.x,h=i.height/r.y;if(s){const e=k(s),t=o&&M(o)?k(o):o;let n=e,i=_(n);for(;i&&o&&t!==n;){const e=Z(i),t=i.getBoundingClientRect(),o=B(i),s=t.left+(i.clientLeft+parseFloat(o.paddingLeft))*e.x,r=t.top+(i.clientTop+parseFloat(o.paddingTop))*e.y;c*=e.x,d*=e.y,u*=e.x,h*=e.y,c+=s,d+=r,n=k(i),i=_(n)}}return E({width:u,height:h,x:c,y:d})}function ne(e,t){const n=j(e).scrollLeft;return t?t.left+n:te(O(e)).left+n}function oe(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ne(e,n),y:n.top+t.scrollTop}}function ie(e,t,n){let o;if("viewport"===t)o=function(e,t){const n=k(e),o=O(e),i=n.visualViewport;let s=o.clientWidth,r=o.clientHeight,l=0,a=0;if(i){s=i.width,r=i.height;const e=N();(!e||e&&"fixed"===t)&&(l=i.offsetLeft,a=i.offsetTop)}const c=ne(o);if(c<=0){const e=o.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,r=Math.abs(o.clientWidth-t.clientWidth-i);r<=25&&(s-=r)}else c<=25&&(s+=c);return{width:s,height:r,x:l,y:a}}(e,n);else if("document"===t)o=function(e){const t=O(e),n=j(e),o=e.ownerDocument.body,s=i(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=i(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let l=-n.scrollLeft+ne(e);const a=-n.scrollTop;return"rtl"===B(o).direction&&(l+=i(t.clientWidth,o.clientWidth)-s),{width:s,height:r,x:l,y:a}}(O(e));else if(M(t))o=function(e,t){const n=te(e,!0,"fixed"===t),o=n.top+e.clientTop,i=n.left+e.clientLeft,s=D(e)?Z(e):l(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:i*s.x,y:o*s.y}}(t,n);else{const n=ee(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return E(o)}function se(e,t){const n=z(e);return!(n===t||!M(n)||W(n))&&("fixed"===B(n).position||se(n,t))}function re(e,t,n){const o=D(t),i=O(t),s="fixed"===n,r=te(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=l(0);function d(){c.x=ne(i)}if(o||!o&&!s)if(("body"!==S(t)||F(i))&&(a=j(t)),o){const e=te(t,!0,s,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&d();s&&!o&&i&&d();const u=!i||o||s?l(0):oe(i,a);return{x:r.left+a.scrollLeft-c.x-u.x,y:r.top+a.scrollTop-c.y-u.y,width:r.width,height:r.height}}function le(e){return"static"===B(e).position}function ae(e,t){if(!D(e)||"fixed"===B(e).position)return null;if(t)return t(e);let n=e.offsetParent;return O(e)===n&&(n=n.ownerDocument.body),n}function ce(e,t){const n=k(e);if(H(e))return n;if(!D(e)){let t=z(e);for(;t&&!W(t);){if(M(t)&&!le(t))return t;t=z(t)}return n}let o=ae(e,t);for(;o&&I(o)&&le(o);)o=ae(o,t);return o&&W(o)&&le(o)&&!U(o)?n:o||function(e){let t=z(e);for(;D(t)&&!W(t);){if(U(t))return t;if(H(t))return null;t=z(t)}return null}(e)||n}const de={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const s="fixed"===i,r=O(o),a=!!t&&H(t.floating);if(o===r||a&&s)return n;let c={scrollLeft:0,scrollTop:0},d=l(1);const u=l(0),h=D(o);if((h||!h&&!s)&&(("body"!==S(o)||F(r))&&(c=j(o)),h)){const e=te(o);d=Z(o),u.x=e.x+o.clientLeft,u.y=e.y+o.clientTop}const f=!r||h||s?l(0):oe(r,c);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:n.y*d.y-c.scrollTop*d.y+u.y+f.y}},getDocumentElement:O,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const l=[..."clippingAncestors"===n?H(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let o=X(e,[],!1).filter(e=>M(e)&&"body"!==S(e)),i=null;const s="fixed"===B(e).position;let r=s?z(e):e;for(;M(r)&&!W(r);){const t=B(r),n=U(r);n||"fixed"!==t.position||(i=null),(s?!n&&!i:!n&&"static"===t.position&&i&&("absolute"===i.position||"fixed"===i.position)||F(r)&&!n&&se(e,r))?o=o.filter(e=>e!==r):i=t,r=z(r)}return t.set(e,o),o}(t,this._c):[].concat(n),s],a=ie(t,l[0],r);let c=a.top,d=a.right,u=a.bottom,h=a.left;for(let e=1;e<l.length;e++){const n=ie(t,l[e],r);c=i(n.top,c),d=o(n.right,d),u=o(n.bottom,u),h=i(n.left,h)}return{width:d-h,height:u-c,x:h,y:c}},getOffsetParent:ce,getElementRects:async function(e){const t=this.getOffsetParent||ce,n=this.getDimensions,o=await n(e.floating);return{reference:re(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Y(e);return{width:t,height:n}},getScale:Z,isElement:M,isRTL:function(e){return"rtl"===B(e).direction}};function ue(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function he(e,t,n,s){void 0===s&&(s={});const{ancestorScroll:l=!0,ancestorResize:a=!0,elementResize:c="function"==typeof ResizeObserver,layoutShift:d="function"==typeof IntersectionObserver,animationFrame:u=!1}=s,h=J(e),f=l||a?[...h?X(h):[],...t?X(t):[]]:[];f.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),a&&e.addEventListener("resize",n)});const p=h&&d?function(e,t){let n,s=null;const l=O(e);function a(){var e;clearTimeout(n),null==(e=s)||e.disconnect(),s=null}return function c(d,u){void 0===d&&(d=!1),void 0===u&&(u=1),a();const h=e.getBoundingClientRect(),{left:f,top:p,width:m,height:g}=h;if(d||t(),!m||!g)return;const w={rootMargin:-r(p)+"px "+-r(l.clientWidth-(f+m))+"px "+-r(l.clientHeight-(p+g))+"px "+-r(f)+"px",threshold:i(0,o(1,u))||1};let y=!0;function v(t){const o=t[0].intersectionRatio;if(o!==u){if(!y)return c();o?c(!1,o):n=setTimeout(()=>{c(!1,1e-7)},1e3)}1!==o||ue(h,e.getBoundingClientRect())||c(),y=!1}try{s=new IntersectionObserver(v,{...w,root:l.ownerDocument})}catch(e){s=new IntersectionObserver(v,w)}s.observe(e)}(!0),a}(h,n):null;let m,g=-1,w=null;c&&(w=new ResizeObserver(e=>{let[o]=e;o&&o.target===h&&w&&t&&(w.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var e;null==(e=w)||e.observe(t)})),n()}),h&&!u&&w.observe(h),t&&w.observe(t));let y=u?te(e):null;return u&&function t(){const o=te(e);y&&!ue(y,o)&&n();y=o,m=requestAnimationFrame(t)}(),n(),()=>{var e;f.forEach(e=>{l&&e.removeEventListener("scroll",n),a&&e.removeEventListener("resize",n)}),null==p||p(),null==(e=w)||e.disconnect(),w=null,u&&cancelAnimationFrame(m)}}const fe=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:i,y:s,placement:r,middlewareData:l}=t,a=await async function(e,t){const{placement:n,platform:o,elements:i}=e,s=await(null==o.isRTL?void 0:o.isRTL(i.floating)),r=d(n),l=u(n),a="y"===f(n),h=A.has(r)?-1:1,p=s&&a?-1:1,m=c(t,e);let{mainAxis:g,crossAxis:w,alignmentAxis:y}="number"==typeof m?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&"number"==typeof y&&(w="end"===l?-1*y:y),a?{x:w*p,y:g*h}:{x:g*h,y:w*p}}(t,e);return r===(null==(n=l.offset)?void 0:n.placement)&&null!=(o=l.arrow)&&o.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:r}}}}},pe=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:i,middlewareData:s,rects:r,initialPlacement:l,platform:a,elements:g}=t,{mainAxis:w=!0,crossAxis:y=!0,fallbackPlacements:v,fallbackStrategy:E="bestFit",fallbackAxisSideDirection:L="none",flipAlignment:C=!0,...A}=c(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const T=d(i),S=f(l),k=d(l)===l,O=await(null==a.isRTL?void 0:a.isRTL(g.floating)),P=v||(k||!C?[x(l)]:function(e){const t=x(e);return[m(e),t,m(t)]}(l)),M="none"!==L;!v&&M&&P.push(...b(l,C,L,O));const D=[l,...P],R=await a.detectOverflow(t,A),F=[];let I=(null==(o=s.flip)?void 0:o.overflows)||[];if(w&&F.push(R[T]),y){const e=function(e,t,n){void 0===n&&(n=!1);const o=u(e),i=p(e),s=h(i);let r="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=x(r)),[r,x(r)]}(i,r,O);F.push(R[e[0]],R[e[1]])}if(I=[...I,{placement:i,overflows:F}],!F.every(e=>e<=0)){var H,K;const e=((null==(H=s.flip)?void 0:H.index)||0)+1,t=D[e];if(t){if(!("alignment"===y&&S!==f(t))||I.every(e=>f(e.placement)!==S||e.overflows[0]>0))return{data:{index:e,overflows:I},reset:{placement:t}}}let n=null==(K=I.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:K.placement;if(!n)switch(E){case"bestFit":{var V;const e=null==(V=I.filter(e=>{if(M){const t=f(e.placement);return t===S||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:V[0];e&&(n=e);break}case"initialPlacement":n=l}if(i!==n)return{reset:{placement:n}}}return{}}}},me=(e,t,n)=>{const o=new Map,i={platform:de,...n},s={...i.platform,_c:o};return(async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:r}=n,l=r.detectOverflow?r:{...r,detectOverflow:C},a=await(null==r.isRTL?void 0:r.isRTL(t));let c=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:u}=L(c,o,a),h=o,f=0;const p={};for(let n=0;n<s.length;n++){const m=s[n];if(!m)continue;const{name:g,fn:w}=m,{x:y,y:v,data:b,reset:x}=await w({x:d,y:u,initialPlacement:o,placement:h,strategy:i,middlewareData:p,rects:c,platform:l,elements:{reference:e,floating:t}});d=null!=y?y:d,u=null!=v?v:u,p[g]={...p[g],...b},x&&f<50&&(f++,"object"==typeof x&&(x.placement&&(h=x.placement),x.rects&&(c=!0===x.rects?await r.getElementRects({reference:e,floating:t,strategy:i}):x.rects),({x:d,y:u}=L(c,h,a))),n=-1)}return{x:d,y:u,placement:h,strategy:i,middlewareData:p}})(e,t,{...i,platform:s})}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};n.d(o,{A:()=>d});var i=n(1926),s=n(7663),r=n(7615),l=n(8862),a=n(189); /* * HSDropdown * @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. */ class c extends r.A{constructor(e,t,n){super(e,t,n),this.longPressTimer=null,this.openedViaKeyboard=!1,this.onTouchStartListener=null,this.onTouchEndListener=null,this.toggle=this.el.querySelector(":scope > .hs-dropdown-toggle")||this.el.querySelector(":scope > .hs-dropdown-toggle-wrapper > .hs-dropdown-toggle")||this.el.children[0],this.closers=Array.from(this.el.querySelectorAll(":scope .hs-dropdown-close"))||null,this.menu=this.el.querySelector(":scope > .hs-dropdown-menu"),this.eventMode=(0,i.gj)(this.el,"--trigger","click"),this.closeMode=(0,i.gj)(this.el,"--auto-close","true"),this.hasAutofocus=(0,i.PK)((0,i.gj)(this.el,"--has-autofocus","true")||"true"),this.autofocusOnKeyboardOnly=(0,i.PK)((0,i.gj)(this.el,"--autofocus-on-keyboard-only","true")||"true"),this.animationInProcess=!1,this.onCloserClickListener=[],this.toggle&&this.menu&&this.init()}elementMouseEnter(){this.onMouseEnterHandler()}elementMouseLeave(){this.onMouseLeaveHandler()}toggleClick(e){this.onClickHandler(e)}toggleContextMenu(e){e.preventDefault(),this.onContextMenuHandler(e)}handleTouchStart(e){this.longPressTimer=window.setTimeout(()=>{e.preventDefault();const t=e.touches[0],n=new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,view:window,clientX:t.clientX,clientY:t.clientY});this.toggle&&this.toggle.dispatchEvent(n)},400)}handleTouchEnd(e){this.longPressTimer&&(clearTimeout(this.longPressTimer),this.longPressTimer=null)}closerClick(){this.close()}init(){if(c.ensureGlobalHandlers(),this.createCollection(window.$hsDropdownCollection,this),this.toggle.disabled)return!1;this.toggle&&this.buildToggle(),this.menu&&this.buildMenu(),this.closers&&this.buildClosers(),(0,i.un)()||(0,i.zG)()||(this.onElementMouseEnterListener=()=>this.elementMouseEnter(),this.onElementMouseLeaveListener=()=>this.elementMouseLeave(),this.el.addEventListener("mouseenter",this.onElementMouseEnterListener),this.el.addEventListener("mouseleave",this.onElementMouseLeaveListener)),"undefined"!=typeof window&&(window.HSAccessibilityObserver||(window.HSAccessibilityObserver=new l.A),this.setupAccessibility())}resizeHandler(){this.eventMode=(0,i.gj)(this.el,"--trigger","click"),this.closeMode=(0,i.gj)(this.el,"--auto-close","true"),this.hasAutofocus=(0,i.PK)((0,i.gj)(this.el,"--has-autofocus","true")||"true"),this.autofocusOnKeyboardOnly=(0,i.PK)((0,i.gj)(this.el,"--autofocus-on-keyboard-only","true")||"true")}isOpen(){return this.el.classList.contains("open")&&!this.menu.classList.contains("hidden")}buildToggle(){var e;(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.el.classList.contains("open")?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),"contextmenu"===this.eventMode?(this.onToggleContextMenuListener=e=>this.toggleContextMenu(e),this.onTouchStartListener=this.handleTouchStart.bind(this),this.onTouchEndListener=this.handleTouchEnd.bind(this),this.toggle.addEventListener("contextmenu",this.onToggleContextMenuListener),this.toggle.addEventListener("touchstart",this.onTouchStartListener,{passive:!1}),this.toggle.addEventListener("touchend",this.onTouchEndListener),this.toggle.addEventListener("touchmove",this.onTouchEndListener)):(this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener))}buildMenu(){this.menu.role=this.menu.getAttribute("role")||"menu",this.menu.tabIndex=-1;const e=this.menu.querySelectorAll('[role="menuitemcheckbox"]'),t=this.menu.querySelectorAll('[role="menuitemradio"]');e.forEach(e=>e.addEventListener("click",()=>this.selectCheckbox(e))),t.forEach(e=>e.addEventListener("click",()=>this.selectRadio(e))),this.menu.addEventListener("click",e=>{const t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||"BUTTON"===t.tagName||"A"===t.tagName||t.closest("button")||t.closest("a")||t.closest("input")||t.closest("textarea")||t.closest("select")||this.menu.focus()})}buildClosers(){this.closers.forEach(e=>{this.onCloserClickListener.push({el:e,fn:()=>this.closerClick()}),e.addEventListener("click",this.onCloserClickListener.find(t=>t.el===e).fn)})}getScrollbarSize(){let e=document.createElement("div");e.style.overflow="scroll",e.style.width="100px",e.style.height="100px",document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t}onContextMenuHandler(e){const t={getBoundingClientRect:(()=>new DOMRect,()=>new DOMRect(e.clientX,e.clientY,0,0))};c.closeCurrentlyOpened(),this.el.classList.contains("open")&&!this.menu.classList.contains("hidden")?(this.close(),document.body.style.overflow="",document.body.style.paddingRight=""):(document.body.style.overflow="hidden",document.body.style.paddingRight=`${this.getScrollbarSize()}px`,this.open(t))}onClickHandler(e){var t;if("hover"===this.eventMode&&window.matchMedia("(hover: hover)").matches&&"mouse"===e.pointerType){const n=e.currentTarget;return"A"===n.tagName&&n.hasAttribute("href")&&"#"!==n.getAttribute("href")||(e.preventDefault(),e.stopPropagation(),null===(t=e.stopImmediatePropagation)||void 0===t||t.call(e)),!1}this.el.classList.contains("open")&&!this.menu.classList.contains("hidden")?this.close():this.open()}onMouseEnterHandler(){if("hover"!==this.eventMode)return!1;(!this.el._floatingUI||this.el._floatingUI&&!this.el.classList.contains("open"))&&this.forceClearState(),!this.el.classList.contains("open")&&this.menu.classList.contains("hidden")&&this.open()}onMouseLeaveHandler(){if("hover"!==this.eventMode)return!1;this.el.classList.contains("open")&&!this.menu.classList.contains("hidden")&&this.close()}destroyFloatingUI(){const e=(window.getComputedStyle(this.el).getPropertyValue("--scope")||"").trim();this.menu.classList.remove("block"),this.menu.classList.add("hidden"),this.menu.style.inset=null,this.menu.style.position=null,this.el&&this.el._floatingUI&&(this.el._floatingUI.destroy(),this.el._floatingUI=null),"window"===e&&this.el.appendChild(this.menu),this.animationInProcess=!1}focusElement(){const e=this.menu.querySelector("[autofocus]");if(e)return e.focus(),!0;const t=this.menu.querySelectorAll('a:not([hidden]), button:not([hidden]), [role="menuitem"]:not([hidden])');if(t.length>0){return t[0].focus(),!0}return!1}setupFloatingUI(e){const t=e||this.el,n=window.getComputedStyle(this.el),o=(n.getPropertyValue("--placement")||"").trim(),i=(n.getPropertyValue("--flip")||"true").trim(),r=(n.getPropertyValue("--strategy")||"fixed").trim(),l=(n.getPropertyValue("--offset")||"10").trim(),c=(n.getPropertyValue("--gpu-acceleration")||"true").trim(),d=(window.getComputedStyle(this.el).getPropertyValue("--adaptive")||"adaptive").replace(" ",""),u=r,h=parseInt(l,10),f=a.lP[o]||"bottom-start",p=[..."true"===i?[(0,s.UU)()]:[],(0,s.cY)(h)],m={placement:f,strategy:u,middleware:p};"fixed"===u&&Object.assign(this.menu.style,{position:u});const g=e=>{const t=this.menu.getBoundingClientRect(),n=window.innerWidth-(window.innerWidth-document.documentElement.clientWidth);return e+t.width>n&&(e=n-t.width),e<0&&(e=0),e},w=()=>{(0,s.rD)(t,this.menu,m).then(({x:e,y:t,placement:n})=>{const o=g(e);"absolute"===u&&"none"===d?Object.assign(this.menu.style,{position:u,margin:"0"}):"absolute"===u?Object.assign(this.menu.style,{position:u,transform:`translate3d(${e}px, ${t}px, 0px)`,margin:"0"}):"true"===c?Object.assign(this.menu.style,{position:u,left:"",top:"",inset:"0px auto auto 0px",margin:"0",transform:`translate3d(${"adaptive"===d?o:0}px, ${t}px, 0)`}):Object.assign(this.menu.style,{position:u,left:`${e}px`,top:`${t}px`,transform:""}),this.menu.setAttribute("data-placement",n)})};w();return{update:w,destroy:(0,s.ll)(t,this.menu,w)}}selectCheckbox(e){e.ariaChecked="true"===e.ariaChecked?"false":"true"}selectRadio(e){if("true"===e.ariaChecked)return!1;const t=e.closest(".group").querySelectorAll('[role="menuitemradio"]');Array.from(t).filter(t=>t!==e).forEach(e=>{e.ariaChecked="false"}),e.ariaChecked="true"}calculatePopperPosition(e){const t=this.setupFloatingUI(e),n=this.menu.getAttribute("data-placement");return t.update(),t.destroy(),n}open(e,t=!1){if(this.el.classList.contains("open")||this.animationInProcess)return!1;this.openedViaKeyboard=t,this.animationInProcess=!0,this.menu.style.cssText="";const n=e||this.el,o=window.getComputedStyle(this.el),s=(o.getPropertyValue("--scope")||"").trim(),r=(o.getPropertyValue("--strategy")||"fixed").trim();"window"===s&&document.body.appendChild(this.menu),"static"!==r&&(this.el._floatingUI=this.setupFloatingUI(n)),this.menu.style.margin=null,this.menu.classList.remove("hidden"),this.menu.classList.add("block"),setTimeout(()=>{var e;(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.el.classList.add("open"),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!0),"window"===s&&this.menu.classList.add("open"),this.animationInProcess=!1,!this.hasAutofocus||this.autofocusOnKeyboardOnly&&!this.openedViaKeyboard||this.focusElement(),this.fireEvent("open",this.el),(0,i.JD)("open.hs.dropdown",this.el,this.el)})}close(e=!0){if(this.animationInProcess||!this.el.classList.contains("open"))return!1;const t=(window.getComputedStyle(this.el).getPropertyValue("--scope")||"").trim();if(this.animationInProcess=!0,"window"===t&&this.menu.classList.remove("open"),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!1),e){const e=this.el.querySelector("[data-hs-dropdown-transition]")||this.menu;let t=!1;const n=()=>{t||(t=!0,this.destroyFloatingUI())};(0,i.yd)(e,n);const o=window.getComputedStyle(e).getPropertyValue("transition-duration"),s=1e3*parseFloat(o)||150;setTimeout(n,s+50)}else this.destroyFloatingUI();(()=>{var e;this.menu.style.margin=null,(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.el.classList.remove("open"),this.openedViaKeyboard=!1,this.fireEvent("close",this.el),(0,i.JD)("close.hs.dropdown",this.el,this.el)})()}forceClearState(){this.destroyFloatingUI(),this.menu.style.margin=null,this.el.classList.remove("open"),this.menu.classList.add("hidden"),this.openedViaKeyboard=!1}destroy(){(0,i.un)()||(0,i.zG)()||(this.el.removeEventListener("mouseenter",this.onElementMouseEnterListener),this.el.removeEventListener("mouseleave",()=>this.onElementMouseLeaveListener),this.onElementMouseEnterListener=null,this.onElementMouseLeaveListener=null),"contextmenu"===this.eventMode?(this.toggle&&(this.toggle.removeEventListener("contextmenu",this.onToggleContextMenuListener),this.toggle.removeEventListener("touchstart",this.onTouchStartListener),this.toggle.removeEventListener("touchend",this.onTouchEndListener),this.toggle.removeEventListener("touchmove",this.onTouchEndListener)),this.onToggleContextMenuListener=null,this.onTouchStartListener=null,this.onTouchEndListener=null):(this.toggle&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.onToggleClickListener=null),this.closers.length&&(this.closers.forEach(e=>{e.removeEventListener("click",this.onCloserClickListener.find(t=>t.el===e).fn)}),this.onCloserClickListener=null),this.el.classList.remove("open"),this.destroyFloatingUI(),window.$hsDropdownCollection=window.$hsDropdownCollection.filter(({element:e})=>e.el!==this.el)}static findInCollection(e){return window.$hsDropdownCollection.find(t=>e instanceof c?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.$hsDropdownCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return n?t?n:n.element:null}static autoInit(){c.ensureGlobalHandlers(),window.$hsDropdownCollection&&(window.$hsDropdownCollection=window.$hsDropdownCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".hs-dropdown:not(.--prevent-on-load-init)").forEach(e=>{window.$hsDropdownCollection.find(t=>{var n;return(null===(n=null==t?void 0:t.element)||void 0===n?void 0:n.el)===e})||new c(e)})}static ensureGlobalHandlers(){if("undefined"==typeof window)return;if(window.$hsDropdownCollection||(window.$hsDropdownCollection=[]),c.globalListenersInitialized)return;c.globalListenersInitialized=!0,window.addEventListener("click",e=>{const t=e.target;c.closeCurrentlyOpened(t)});let e=window.innerWidth;window.addEventListener("resize",()=>{window.innerWidth!==e&&(e=innerWidth,c.closeCurrentlyOpened(null,!1))})}static open(e,t=!1){const n=c.findInCollection(e);n&&n.element.menu.classList.contains("hidden")&&n.element.open(void 0,t)}static close(e){const t=c.findInCollection(e);t&&!t.element.menu.classList.contains("hidden")&&t.element.close()}static closeCurrentlyOpened(e=null,t=!0){const n=e&&e.closest(".hs-dropdown")&&e.closest(".hs-dropdown").parentElement.closest(".hs-dropdown")?e.closest(".hs-dropdown").parentElement.closest(".hs-dropdown"):null;let o=n?window.$hsDropdownCollection.filter(e=>e.element.el.classList.contains("open")&&e.element.menu.closest(".hs-dropdown").parentElement.closest(".hs-dropdown")===n):window.$hsDropdownCollection.filter(e=>e.element.el.classList.contains("open"));if(e){const t=e.closest(".hs-dropdown");if(t)"inside"===(0,i.BF)(t,"--auto-close")&&(o=o.filter(e=>e.element.el!==t));else{const t=e.closest(".hs-dropdown-menu");if(t){const e=window.$hsDropdownCollection.find(e=>e.element.menu===t);e&&"inside"===(0,i.BF)(e.element.el,"--auto-close")&&(o=o.filter(t=>t.element.el!==e.element.el))}}}o&&o.forEach(e=>{if("false"===e.element.closeMode||"outside"===e.element.closeMode)return!1;e.element.close(t)}),o&&o.forEach(e=>{if("contextmenu"!==(0,i.BF)(e.element.el,"--trigger"))return!1;document.body.style.overflow="",document.body.style.paddingRight=""})}setupAccessibility(){this.accessibilityComponent=window.HSAccessibilityObserver.registerComponent(this.el,{onEnter:()=>{var e;const t=document.activeElement;if(!t)return;if(t.closest(".hs-dropdown-menu")){const n=t.closest(".hs-dropdown-toggle, [data-hs-dropdown-toggle]");if(n)return void n.click();const o=t.closest('[role="menuitem"], a, button, [data-hs-dropdown-item]');if((null===(e=null==o?void 0:o.children)||void 0===e?void 0:e.length)>0)return Array.from(o.children).forEach(e=>{e.matches("input[type='checkbox']:not([hidden]), input[type='radio']:not([hidden])")&&e.click()}),void o.focus();if(o){if(t.matches("input, textarea, select"))return;o.click()}return}this.isOpened()?this.close():this.open(void 0,!0)},onSpace:()=>{this.isOpened()||this.open(void 0,!0)},onEsc:()=>{this.isOpened()&&(this.close(),this.toggle&&this.toggle.focus())},onArrow:e=>{if(!e.metaKey)switch(e.key){case"ArrowDown":this.isOpened()?this.focusMenuItem("next"):this.open(void 0,!0);break;case"ArrowUp":this.isOpened()&&this.focusMenuItem("prev");break;case"ArrowRight":this.onArrowX(e,"right");break;case"ArrowLeft":this.onArrowX(e,"left")}},onHome:()=>{this.isOpened()&&this.onStartEnd(!0)},onEnd:()=>{this.isOpened()&&this.onStartEnd(!1)},onTab:()=>{setTimeout(()=>{const e=document.activeElement,t=e.closest(".hs-dropdown-menu");if(e&&t){const t=e.closest(".hs-dropdown-toggle, [data-hs-dropdown-toggle]");return t?void t.click():void e.focus()}this.isOpened()&&this.close()},100)},onFirstLetter:e=>{const t=document.activeElement;!(null==t?void 0:t.matches("input, textarea"))&&this.isOpened()&&this.onFirstLetter(e)}},this.isOpened(),"Dropdown",".hs-dropdown",this.menu,{onFirstLetter:!1})}onFirstLetter(e){var t;if(!this.isOpened()||!this.menu)return;const n=this.menu.querySelectorAll('a:not([hidden]), button:not([hidden]), [role="menuitem"]:not([hidden])');if(0===n.length)return;const o=Array.from(n).indexOf(document.activeElement);for(let i=1;i<=n.length;i++){const s=(o+i)%n.length;if(((null===(t=n[s].textContent)||void 0===t?void 0:t.trim().toLowerCase())||"").startsWith(e.toLowerCase()))return void n[s].focus()}n[0].focus()}onArrowX(e,t){if(!this.isOpened())return;e.preventDefault(),e.stopImmediatePropagation();const n=this.menu.querySelectorAll('a:not([hidden]), button:not([hidden]), [role="menuitem"]:not([hidden])');if(!n.length)return;const o=Array.from(n).indexOf(document.activeElement);let i=-1;i="right"===t?(o+1)%n.length:o>0?o-1:n.length-1,n[i].focus()}onStartEnd(e=!0){if(!this.isOpened())return;const t=this.menu.querySelectorAll('a:not([hidden]), button:not([hidden]), [role="menuitem"]:not([hidden])');if(!t.length)return;t[e?0:t.length-1].focus()}focusMenuItem(e){const t=this.menu.querySelectorAll('a:not([hidden]), button:not([hidden]), [role="menuitem"]:not([hidden])');if(!t.length)return;const n=Array.from(t).indexOf(document.activeElement);t["next"===e?(n+1)%t.length:(n-1+t.length)%t.length].focus()}static on(e,t,n){const o=c.findInCollection(t);o&&(o.element.events[e]=n)}isOpened(){return this.isOpen()}containsElement(e){return this.el.contains(e)}}c.globalListenersInitialized=!1;const d=c,u=o.A;export{u as default};