UNPKG

flyonui

Version:

The easiest, free and open-source Tailwind CSS component library with semantic classes.

16 lines 36.9 kB
var e={68:(e,t,n)=>{n.d(t,{A:()=>o});const o=class{constructor(){this.components=[],this.currentlyOpenedComponents=[],this.activeComponent=null,this.initGlobalListeners()}initGlobalListeners(){document.addEventListener("keydown",e=>this.handleGlobalKeydown(e)),document.addEventListener("focusin",e=>this.handleGlobalFocusin(e))}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}handleGlobalFocusin(e){const t=e.target;this.activeComponent=this.getActiveComponent(t)}handleGlobalKeydown(e){const t=e.target;if(this.activeComponent=this.getActiveComponent(t),this.activeComponent)switch(e.key){case"Escape":if(this.activeComponent.isOpened)this.activeComponent.handlers.onEsc&&(this.activeComponent.handlers.onEsc(),e.preventDefault(),e.stopPropagation());else{const n=this.findClosestOpenParent(t);(null==n?void 0:n.handlers.onEsc)&&(n.handlers.onEsc(),e.preventDefault(),e.stopPropagation())}break;case"Enter":this.activeComponent.handlers.onEnter&&(this.activeComponent.handlers.onEnter(),e.preventDefault(),e.stopPropagation());break;case" ":case"Space":if("INPUT"===t.tagName||"TEXTAREA"===t.tagName)return;this.activeComponent.handlers.onSpace&&(this.activeComponent.handlers.onSpace(),e.preventDefault(),e.stopPropagation());break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(this.activeComponent.handlers.onArrow){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;this.activeComponent.handlers.onArrow(e),e.preventDefault(),e.stopPropagation()}break;case"Tab":if(!this.activeComponent.handlers.onTab)break;const n=e.shiftKey?this.activeComponent.handlers.onShiftTab:this.activeComponent.handlers.onTab;n&&n();break;case"Home":this.activeComponent.handlers.onHome&&(this.activeComponent.handlers.onHome(),e.preventDefault(),e.stopPropagation());break;case"End":this.activeComponent.handlers.onEnd&&(this.activeComponent.handlers.onEnd(),e.preventDefault(),e.stopPropagation());break;default:this.activeComponent.handlers.onFirstLetter&&1===e.key.length&&/^[a-zA-Z]$/.test(e.key)&&(this.activeComponent.handlers.onFirstLetter(e.key),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){const r={wrapper:e,handlers:t,isOpened:n,name:o,selector:i,context:s,isRegistered:!0};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)}}},179:(e,t,n)=>{n.d(t,{lP:()=>o});const o={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-start":"top-start","top-end":"top-end",bottom:"bottom","bottom-start":"bottom-start","bottom-end":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"}},392:(e,t,n)=>{n.d(t,{BF:()=>s,JD:()=>a,PK:()=>o,gj:()=>i,un:()=>r,yd:()=>c,zG:()=>l}); /* * @version: 3.2.2 * @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=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),l=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),a=(e,t,n=null)=>{const o=new CustomEvent(e,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(o)},c=(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()}},663:(e,t,n)=>{n.d(t,{ll:()=>ye,rD:()=>xe,UU:()=>be,cY:()=>ve});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"},c={start:"end",end:"start"};function d(e,t){return"function"==typeof e?e(t):e}function u(e){return e.split("-")[0]}function h(e){return e.split("-")[1]}function p(e){return"y"===e?"height":"width"}const f=new Set(["top","bottom"]);function m(e){return f.has(u(e))?"y":"x"}function g(e){return"x"===m(e)?"y":"x"}function w(e){return e.replace(/start|end/g,e=>c[e])}const y=["left","right"],v=["right","left"],b=["top","bottom"],x=["bottom","top"];function C(e,t,n,o){const i=h(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?v:y:t?y:v;case"left":case"right":return t?b:x;default:return[]}}(u(e),"start"===n,o);return i&&(s=s.map(e=>e+"-"+i),t&&(s=s.concat(s.map(w)))),s}function L(e){return e.replace(/left|right|bottom|top/g,e=>a[e])}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 A(e,t,n){let{reference:o,floating:i}=e;const s=m(t),r=g(t),l=p(r),a=u(t),c="y"===s,d=o.x+o.width/2-i.width/2,f=o.y+o.height/2-i.height/2,w=o[l]/2-i[l]/2;let y;switch(a){case"top":y={x:d,y:o.y-i.height};break;case"bottom":y={x:d,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:f};break;case"left":y={x:o.x-i.width,y:f};break;default:y={x:o.x,y:o.y}}switch(h(t)){case"start":y[r]-=w*(n&&c?-1:1);break;case"end":y[r]+=w*(n&&c?-1:1)}return y}async function T(e,t){var n;void 0===t&&(t={});const{x:o,y:i,platform:s,rects:r,elements:l,strategy:a}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=d(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}}(f),g=l[p?"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:c,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 S=new Set(["left","top"]);function O(){return"undefined"!=typeof window}function P(e){return R(e)?(e.nodeName||"").toLowerCase():"#document"}function k(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function D(e){var t;return null==(t=(R(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function R(e){return!!O()&&(e instanceof Node||e instanceof k(e).Node)}function M(e){return!!O()&&(e instanceof Element||e instanceof k(e).Element)}function I(e){return!!O()&&(e instanceof HTMLElement||e instanceof k(e).HTMLElement)}function F(e){return!(!O()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof k(e).ShadowRoot)}const H=new Set(["inline","contents"]);function V(e){const{overflow:t,overflowX:n,overflowY:o,display:i}=_(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!H.has(i)}const $=new Set(["table","td","th"]);function U(e){return $.has(P(e))}const K=[":popover-open",":modal"];function j(e){return K.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const q=["transform","translate","scale","rotate","perspective"],W=["transform","translate","scale","rotate","perspective","filter"],B=["paint","layout","strict","content"];function z(e){const t=N(),n=M(e)?_(e):e;return q.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||W.some(e=>(n.willChange||"").includes(e))||B.some(e=>(n.contain||"").includes(e))}function N(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const G=new Set(["html","body","#document"]);function X(e){return G.has(P(e))}function _(e){return k(e).getComputedStyle(e)}function Y(e){return M(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function J(e){if("html"===P(e))return e;const t=e.assignedSlot||e.parentNode||F(e)&&e.host||D(e);return F(t)?t.host:t}function Z(e){const t=J(e);return X(t)?e.ownerDocument?e.ownerDocument.body:e.body:I(t)&&V(t)?t:Z(t)}function Q(e,t,n){var o;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=Z(e),s=i===(null==(o=e.ownerDocument)?void 0:o.body),r=k(i);if(s){const e=ee(r);return t.concat(r,r.visualViewport||[],V(i)?i:[],e&&n?Q(e):[])}return t.concat(i,Q(i,[],n))}function ee(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function te(e){const t=_(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const i=I(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 ne(e){return M(e)?e:e.contextElement}function oe(e){const t=ne(e);if(!I(t))return l(1);const n=t.getBoundingClientRect(),{width:o,height:i,$:r}=te(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 ie=l(0);function se(e){const t=k(e);return N()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:ie}function re(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),s=ne(e);let r=l(1);t&&(o?M(o)&&(r=oe(o)):r=oe(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==k(e))&&t}(s,n,o)?se(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=ee(n);for(;i&&o&&t!==n;){const e=oe(i),t=i.getBoundingClientRect(),o=_(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=ee(n)}}return E({width:u,height:h,x:c,y:d})}function le(e,t){const n=Y(e).scrollLeft;return t?t.left+n:re(D(e)).left+n}function ae(e,t,n){void 0===n&&(n=!1);const o=e.getBoundingClientRect();return{x:o.left+t.scrollLeft-(n?0:le(e,o)),y:o.top+t.scrollTop}}const ce=new Set(["absolute","fixed"]);function de(e,t,n){let o;if("viewport"===t)o=function(e,t){const n=k(e),o=D(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)}return{width:s,height:r,x:l,y:a}}(e,n);else if("document"===t)o=function(e){const t=D(e),n=Y(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+le(e);const a=-n.scrollTop;return"rtl"===_(o).direction&&(l+=i(t.clientWidth,o.clientWidth)-s),{width:s,height:r,x:l,y:a}}(D(e));else if(M(t))o=function(e,t){const n=re(e,!0,"fixed"===t),o=n.top+e.clientTop,i=n.left+e.clientLeft,s=I(e)?oe(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=se(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return E(o)}function ue(e,t){const n=J(e);return!(n===t||!M(n)||X(n))&&("fixed"===_(n).position||ue(n,t))}function he(e,t,n){const o=I(t),i=D(t),s="fixed"===n,r=re(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=l(0);function d(){c.x=le(i)}if(o||!o&&!s)if(("body"!==P(t)||V(i))&&(a=Y(t)),o){const e=re(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):ae(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 pe(e){return"static"===_(e).position}function fe(e,t){if(!I(e)||"fixed"===_(e).position)return null;if(t)return t(e);let n=e.offsetParent;return D(e)===n&&(n=n.ownerDocument.body),n}function me(e,t){const n=k(e);if(j(e))return n;if(!I(e)){let t=J(e);for(;t&&!X(t);){if(M(t)&&!pe(t))return t;t=J(t)}return n}let o=fe(e,t);for(;o&&U(o)&&pe(o);)o=fe(o,t);return o&&X(o)&&pe(o)&&!z(o)?n:o||function(e){let t=J(e);for(;I(t)&&!X(t);){if(z(t))return t;if(j(t))return null;t=J(t)}return null}(e)||n}const ge={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:o,strategy:i}=e;const s="fixed"===i,r=D(o),a=!!t&&j(t.floating);if(o===r||a&&s)return n;let c={scrollLeft:0,scrollTop:0},d=l(1);const u=l(0),h=I(o);if((h||!h&&!s)&&(("body"!==P(o)||V(r))&&(c=Y(o)),I(o))){const e=re(o);d=oe(o),u.x=e.x+o.clientLeft,u.y=e.y+o.clientTop}const p=!r||h||s?l(0):ae(r,c,!0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+p.x,y:n.y*d.y-c.scrollTop*d.y+u.y+p.y}},getDocumentElement:D,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const l=[..."clippingAncestors"===n?j(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let o=Q(e,[],!1).filter(e=>M(e)&&"body"!==P(e)),i=null;const s="fixed"===_(e).position;let r=s?J(e):e;for(;M(r)&&!X(r);){const t=_(r),n=z(r);n||"fixed"!==t.position||(i=null),(s?!n&&!i:!n&&"static"===t.position&&i&&ce.has(i.position)||V(r)&&!n&&ue(e,r))?o=o.filter(e=>e!==r):i=t,r=J(r)}return t.set(e,o),o}(t,this._c):[].concat(n),s],a=l[0],c=l.reduce((e,n)=>{const s=de(t,n,r);return e.top=i(s.top,e.top),e.right=o(s.right,e.right),e.bottom=o(s.bottom,e.bottom),e.left=i(s.left,e.left),e},de(t,a,r));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},getOffsetParent:me,getElementRects:async function(e){const t=this.getOffsetParent||me,n=this.getDimensions,o=await n(e.floating);return{reference:he(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}=te(e);return{width:t,height:n}},getScale:oe,isElement:M,isRTL:function(e){return"rtl"===_(e).direction}};function we(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ye(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=ne(e),p=l||a?[...h?Q(h):[],...Q(t)]:[];p.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),a&&e.addEventListener("resize",n)});const f=h&&d?function(e,t){let n,s=null;const l=D(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:p,top:f,width:m,height:g}=h;if(d||t(),!m||!g)return;const w={rootMargin:-r(f)+"px "+-r(l.clientWidth-(p+m))+"px "+-r(l.clientHeight-(f+g))+"px "+-r(p)+"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||we(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&&(w.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var e;null==(e=w)||e.observe(t)})),n()}),h&&!u&&w.observe(h),w.observe(t));let y=u?re(e):null;return u&&function t(){const o=re(e);y&&!we(y,o)&&n();y=o,m=requestAnimationFrame(t)}(),n(),()=>{var e;p.forEach(e=>{l&&e.removeEventListener("scroll",n),a&&e.removeEventListener("resize",n)}),null==f||f(),null==(e=w)||e.disconnect(),w=null,u&&cancelAnimationFrame(m)}}const ve=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=u(n),l=h(n),a="y"===m(n),c=S.has(r)?-1:1,p=s&&a?-1:1,f=d(t,e);let{mainAxis:g,crossAxis:w,alignmentAxis:y}="number"==typeof f?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&"number"==typeof y&&(w="end"===l?-1*y:y),a?{x:w*p,y:g*c}:{x:g*c,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}}}}},be=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:c}=t,{mainAxis:f=!0,crossAxis:y=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:E=!0,...A}=d(e,t);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const S=u(i),O=m(l),P=u(l)===l,k=await(null==a.isRTL?void 0:a.isRTL(c.floating)),D=v||(P||!E?[L(l)]:function(e){const t=L(e);return[w(e),t,w(t)]}(l)),R="none"!==x;!v&&R&&D.push(...C(l,E,x,k));const M=[l,...D],I=await T(t,A),F=[];let H=(null==(o=s.flip)?void 0:o.overflows)||[];if(f&&F.push(I[S]),y){const e=function(e,t,n){void 0===n&&(n=!1);const o=h(e),i=g(e),s=p(i);let r="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=L(r)),[r,L(r)]}(i,r,k);F.push(I[e[0]],I[e[1]])}if(H=[...H,{placement:i,overflows:F}],!F.every(e=>e<=0)){var V,$;const e=((null==(V=s.flip)?void 0:V.index)||0)+1,t=M[e];if(t){if(!("alignment"===y&&O!==m(t))||H.every(e=>m(e.placement)!==O||e.overflows[0]>0))return{data:{index:e,overflows:H},reset:{placement:t}}}let n=null==($=H.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:$.placement;if(!n)switch(b){case"bestFit":{var U;const e=null==(U=H.filter(e=>{if(R){const t=m(e.placement);return t===O||"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:U[0];e&&(n=e);break}case"initialPlacement":n=l}if(i!==n)return{reset:{placement:n}}}return{}}}},xe=(e,t,n)=>{const o=new Map,i={platform:ge,...n},s={...i.platform,_c:o};return(async(e,t,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:r}=n,l=s.filter(Boolean),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}=A(c,o,a),h=o,p={},f=0;for(let n=0;n<l.length;n++){const{name:s,fn:m}=l[n],{x:g,y:w,data:y,reset:v}=await m({x:d,y:u,initialPlacement:o,placement:h,strategy:i,middlewareData:p,rects:c,platform:r,elements:{reference:e,floating:t}});d=null!=g?g:d,u=null!=w?w:u,p={...p,[s]:{...p[s],...y}},v&&f<=50&&(f++,"object"==typeof v&&(v.placement&&(h=v.placement),v.rects&&(c=!0===v.rects?await r.getElementRects({reference:e,floating:t,strategy:i}):v.rects),({x:d,y:u}=A(c,h,a))),n=-1)}return{x:d,y:u,placement:h,strategy:i,middlewareData:p}})(e,t,{...i,platform:s})}},709:(e,t,n)=>{n.d(t,{A:()=>o});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;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}}}},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(392),s=n(663),r=n(709),l=n(68),a=n(179); /* * HSDropdown * @version: 3.2.2 * @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 > .dropdown-toggle")||this.el.querySelector(":scope > .dropdown-toggle-wrapper > .dropdown-toggle")||this.el.children[0],this.closers=Array.from(this.el.querySelectorAll(":scope .dropdown-close"))||null,this.menu=this.el.querySelector(":scope > .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(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",()=>{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"===(0,i.gj)(this.el,"--trigger","click")&&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"!==(0,i.gj)(this.el,"--trigger","click"))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"!==(0,i.gj)(this.el,"--trigger","click"))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]), .dropdown-item');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")||"6").trim(),c=(n.getPropertyValue("--gpu-acceleration")||"true").trim(),d=(window.getComputedStyle(this.el).getPropertyValue("--adaptive")||"adaptive").replace(" ",""),u=r,h=parseInt(l,10),p=a.lP[o]||"bottom-start",f=[..."true"===i?[(0,s.UU)()]:[],(0,s.cY)(h)],m={placement:p,strategy:u,middleware:f},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"}calculateFloatingUIPosition(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.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-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.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(){if(!window.$hsDropdownCollection){window.$hsDropdownCollection=[],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))})}window.$hsDropdownCollection&&(window.$hsDropdownCollection=window.$hsDropdownCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".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 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(".dropdown")&&e.closest(".dropdown").parentElement.closest(".dropdown")?e.closest(".dropdown").parentElement.closest(".dropdown"):null;let o=n?window.$hsDropdownCollection.filter(e=>e.element.el.classList.contains("open")&&e.element.menu.closest(".dropdown").parentElement.closest(".dropdown")===n):window.$hsDropdownCollection.filter(e=>e.element.el.classList.contains("open"));if(e){const t=e.closest(".dropdown");if(t)"inside"===(0,i.BF)(t,"--auto-close")&&(o=o.filter(e=>e.element.el!==t));else{const t=e.closest(".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))}}}e&&e.closest(".dropdown")&&"outside"===(0,i.BF)(e.closest(".dropdown"),"--auto-close")&&(o=o.filter(t=>t.element.el==e.closest(".dropdown")),o.forEach(e=>e.element.close(t))),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:()=>{this.isOpened()||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:()=>{this.isOpened()&&this.close()},onFirstLetter:e=>{this.isOpened()&&this.onFirstLetter(e)}},this.isOpened(),"Dropdown",".dropdown",this.menu)}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]), .dropdown-item');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]), .dropdown-item');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]), .dropdown-item');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]), .dropdown-item');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)}}window.addEventListener("load",()=>{c.autoInit()}),window.addEventListener("resize",()=>{window.$hsDropdownCollection||(window.$hsDropdownCollection=[]),window.$hsDropdownCollection.forEach(e=>e.element.resizeHandler())}),"undefined"!=typeof window&&(window.HSDropdown=c);const d=c,u=o.A;export{u as default};