UNPKG

flyonui

Version:

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

16 lines 72.6 kB
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(self,()=>(()=>{"use strict";var t={287:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t,e,i){this.el=t,this.options=e,this.events=i,this.el=t,this.options=e,this.events={}}createCollection(t,e){var i;t.push({id:(null===(i=null==e?void 0:e.el)||void 0===i?void 0:i.id)||t.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},294:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.components=[],this.currentlyOpenedComponents=[],this.activeComponent=null,this.initGlobalListeners()}initGlobalListeners(){document.addEventListener("keydown",t=>this.handleGlobalKeydown(t)),document.addEventListener("focusin",t=>this.handleGlobalFocusin(t))}getActiveComponent(t){if(!t)return null;const e=this.components.filter(e=>e.wrapper.contains(t)||e.context&&e.context.contains(t));if(0===e.length)return null;if(1===e.length)return e[0];let i=null,s=Number.MAX_SAFE_INTEGER;for(const n of e){let e=0,o=t;for(;o&&o!==n.wrapper&&o!==n.context;)e++,o=o.parentElement;e<s&&(s=e,i=n)}return i}handleGlobalFocusin(t){const e=t.target;this.activeComponent=this.getActiveComponent(e)}handleGlobalKeydown(t){const e=t.target;if(this.activeComponent=this.getActiveComponent(e),this.activeComponent)switch(t.key){case"Escape":if(this.activeComponent.isOpened)this.activeComponent.handlers.onEsc&&(this.activeComponent.handlers.onEsc(),t.preventDefault(),t.stopPropagation());else{const i=this.findClosestOpenParent(e);(null==i?void 0:i.handlers.onEsc)&&(i.handlers.onEsc(),t.preventDefault(),t.stopPropagation())}break;case"Enter":this.activeComponent.handlers.onEnter&&(this.activeComponent.handlers.onEnter(),t.preventDefault(),t.stopPropagation());break;case" ":case"Space":if("INPUT"===e.tagName||"TEXTAREA"===e.tagName)return;this.activeComponent.handlers.onSpace&&(this.activeComponent.handlers.onSpace(),t.preventDefault(),t.stopPropagation());break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(this.activeComponent.handlers.onArrow){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;this.activeComponent.handlers.onArrow(t),t.preventDefault(),t.stopPropagation()}break;case"Tab":if(!this.activeComponent.handlers.onTab)break;const i=t.shiftKey?this.activeComponent.handlers.onShiftTab:this.activeComponent.handlers.onTab;i&&i();break;case"Home":this.activeComponent.handlers.onHome&&(this.activeComponent.handlers.onHome(),t.preventDefault(),t.stopPropagation());break;case"End":this.activeComponent.handlers.onEnd&&(this.activeComponent.handlers.onEnd(),t.preventDefault(),t.stopPropagation());break;default:this.activeComponent.handlers.onFirstLetter&&1===t.key.length&&/^[a-zA-Z]$/.test(t.key)&&(this.activeComponent.handlers.onFirstLetter(t.key),t.preventDefault(),t.stopPropagation())}}findClosestOpenParent(t){let e=t.parentElement;for(;e;){const t=this.currentlyOpenedComponents.find(t=>t.wrapper===e&&t!==this.activeComponent);if(t)return t;e=e.parentElement}return null}registerComponent(t,e,i=!0,s="",n="",o){const l={wrapper:t,handlers:e,isOpened:i,name:s,selector:n,context:o,isRegistered:!0};return this.components.push(l),l}updateComponentState(t,e){t.isOpened=e,e?this.currentlyOpenedComponents.includes(t)||this.currentlyOpenedComponents.push(t):this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter(e=>e!==t)}unregisterComponent(t){this.components=this.components.filter(e=>e!==t),this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter(e=>e!==t)}}},806:function(t,e){ /* * @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. */ Object.defineProperty(e,"__esModule",{value:!0}),e.stringToBoolean=e.menuSearchHistory=e.isScrollable=e.isParentOrElementHidden=e.isJson=e.isIpadOS=e.isIOS=e.isFormElement=e.isFocused=e.isEnoughSpace=e.isDirectChild=e.htmlToElement=e.getZIndex=e.getHighestZIndex=e.getClassPropertyAlt=e.getClassProperty=e.dispatch=e.debounce=e.classToClassList=e.afterTransition=void 0;e.stringToBoolean=t=>"true"===t;e.getClassProperty=(t,e,i="")=>(window.getComputedStyle(t).getPropertyValue(e)||i).replace(" ","");e.getClassPropertyAlt=(t,e,i="")=>{let s="";return t.classList.forEach(t=>{t.includes(e)&&(s=t)}),s.match(/:(.*)]/)?s.match(/:(.*)]/)[1]:i};const i=t=>window.getComputedStyle(t).getPropertyValue("z-index");e.getZIndex=i;e.getHighestZIndex=t=>{let e=Number.NEGATIVE_INFINITY;return t.forEach(t=>{let s=i(t);"auto"!==s&&(s=parseInt(s,10),s>e&&(e=s))}),e};e.isDirectChild=(t,e)=>{const i=t.children;for(let t=0;t<i.length;t++)if(i[t]===e)return!0;return!1};e.isEnoughSpace=(t,e,i="auto",s=10,n=null)=>{const o=e.getBoundingClientRect(),l=n?n.getBoundingClientRect():null,r=window.innerHeight,a=l?o.top-l.top:o.top,d=(n?l.bottom:r)-o.bottom,h=t.clientHeight+s;return"bottom"===i?d>=h:"top"===i?a>=h:a>=h||d>=h};e.isFocused=t=>document.activeElement===t;e.isFormElement=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement;e.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);e.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);e.isJson=t=>{if("string"!=typeof t)return!1;const e=t.trim()[0],i=t.trim().slice(-1);if("{"===e&&"}"===i||"["===e&&"]"===i)try{return JSON.parse(t),!0}catch(t){return!1}return!1};const s=t=>{if(!t)return!1;return"none"===window.getComputedStyle(t).display||s(t.parentElement)};e.isParentOrElementHidden=s;e.isScrollable=t=>{const e=window.getComputedStyle(t),i=e.overflowY,s=e.overflowX,n=("scroll"===i||"auto"===i)&&t.scrollHeight>t.clientHeight,o=("scroll"===s||"auto"===s)&&t.scrollWidth>t.clientWidth;return n||o};e.debounce=(t,e=200)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>{t.apply(this,s)},e)}};e.dispatch=(t,e,i=null)=>{const s=new CustomEvent(t,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(s)};e.afterTransition=(t,e)=>{const i=()=>{e(),t.removeEventListener("transitionend",i,!0)},s=window.getComputedStyle(t),n=s.getPropertyValue("transition-duration");"none"!==s.getPropertyValue("transition-property")&&parseFloat(n)>0?t.addEventListener("transitionend",i,!0):e()};e.htmlToElement=t=>{const e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=(t,e,i=" ",s="add")=>{t.split(i).forEach(t=>{t.trim()&&("add"===s?e.classList.add(t):e.classList.remove(t))})};const n={historyIndex:-1,addHistory(t){this.historyIndex=t},existsInHistory(t){return t>this.historyIndex},clearHistory(){this.historyIndex=-1}};e.menuSearchHistory=n},917:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BREAKPOINTS=e.COMBO_BOX_ACCESSIBILITY_KEY_SET=e.SELECT_ACCESSIBILITY_KEY_SET=e.TABS_ACCESSIBILITY_KEY_SET=e.OVERLAY_ACCESSIBILITY_KEY_SET=e.DROPDOWN_ACCESSIBILITY_KEY_SET=e.POSITIONS=void 0,e.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-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"},e.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Home","End","Enter"],e.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],e.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],e.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"],e.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],e.BREAKPOINTS={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},949:(t,e,i)=>{i.r(e),i.d(e,{arrow:()=>_t,autoPlacement:()=>Pt,autoUpdate:()=>Ot,computePosition:()=>$t,detectOverflow:()=>At,flip:()=>Rt,getOverflowAncestors:()=>dt,hide:()=>Ht,inline:()=>kt,limitShift:()=>Wt,offset:()=>Mt,platform:()=>Et,shift:()=>Ft,size:()=>Dt});const s=["top","right","bottom","left"],n=["start","end"],o=s.reduce((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1]),[]),l=Math.min,r=Math.max,a=Math.round,d=Math.floor,h=t=>({x:t,y:t}),c={left:"right",right:"left",bottom:"top",top:"bottom"},p={start:"end",end:"start"};function u(t,e,i){return r(t,l(e,i))}function g(t,e){return"function"==typeof t?t(e):t}function f(t){return t.split("-")[0]}function m(t){return t.split("-")[1]}function v(t){return"x"===t?"y":"x"}function w(t){return"y"===t?"height":"width"}const y=new Set(["top","bottom"]);function b(t){return y.has(f(t))?"y":"x"}function T(t){return v(b(t))}function S(t,e,i){void 0===i&&(i=!1);const s=m(t),n=T(t),o=w(n);let l="x"===n?s===(i?"end":"start")?"right":"left":"start"===s?"bottom":"top";return e.reference[o]>e.floating[o]&&(l=A(l)),[l,A(l)]}function I(t){return t.replace(/start|end/g,t=>p[t])}const x=["left","right"],C=["right","left"],E=["top","bottom"],L=["bottom","top"];function O(t,e,i,s){const n=m(t);let o=function(t,e,i){switch(t){case"top":case"bottom":return i?e?C:x:e?x:C;case"left":case"right":return e?E:L;default:return[]}}(f(t),"start"===i,s);return n&&(o=o.map(t=>t+"-"+n),e&&(o=o.concat(o.map(I)))),o}function A(t){return t.replace(/left|right|bottom|top/g,t=>c[t])}function M(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function P(t){const{x:e,y:i,width:s,height:n}=t;return{width:s,height:n,top:i,left:e,right:e+s,bottom:i+n,x:e,y:i}}function F(t,e,i){let{reference:s,floating:n}=t;const o=b(e),l=T(e),r=w(l),a=f(e),d="y"===o,h=s.x+s.width/2-n.width/2,c=s.y+s.height/2-n.height/2,p=s[r]/2-n[r]/2;let u;switch(a){case"top":u={x:h,y:s.y-n.height};break;case"bottom":u={x:h,y:s.y+s.height};break;case"right":u={x:s.x+s.width,y:c};break;case"left":u={x:s.x-n.width,y:c};break;default:u={x:s.x,y:s.y}}switch(m(e)){case"start":u[l]-=p*(i&&d?-1:1);break;case"end":u[l]+=p*(i&&d?-1:1)}return u}async function R(t,e){var i;void 0===e&&(e={});const{x:s,y:n,platform:o,rects:l,elements:r,strategy:a}=t,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:c="floating",altBoundary:p=!1,padding:u=0}=g(e,t),f=M(u),m=r[p?"floating"===c?"reference":"floating":c],v=P(await o.getClippingRect({element:null==(i=await(null==o.isElement?void 0:o.isElement(m)))||i?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(r.floating)),boundary:d,rootBoundary:h,strategy:a})),w="floating"===c?{x:s,y:n,width:l.floating.width,height:l.floating.height}:l.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(r.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},T=P(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:w,offsetParent:y,strategy:a}):w);return{top:(v.top-T.top+f.top)/b.y,bottom:(T.bottom-v.bottom+f.bottom)/b.y,left:(v.left-T.left+f.left)/b.x,right:(T.right-v.right+f.right)/b.x}}function D(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function H(t){return s.some(e=>t[e]>=0)}function _(t){const e=l(...t.map(t=>t.left)),i=l(...t.map(t=>t.top));return{x:e,y:i,width:r(...t.map(t=>t.right))-e,height:r(...t.map(t=>t.bottom))-i}}const k=new Set(["left","top"]);function W(){return"undefined"!=typeof window}function $(t){return V(t)?(t.nodeName||"").toLowerCase():"#document"}function N(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function q(t){var e;return null==(e=(V(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function V(t){return!!W()&&(t instanceof Node||t instanceof N(t).Node)}function B(t){return!!W()&&(t instanceof Element||t instanceof N(t).Element)}function U(t){return!!W()&&(t instanceof HTMLElement||t instanceof N(t).HTMLElement)}function j(t){return!(!W()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof N(t).ShadowRoot)}const K=new Set(["inline","contents"]);function Y(t){const{overflow:e,overflowX:i,overflowY:s,display:n}=ot(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+i)&&!K.has(n)}const z=new Set(["table","td","th"]);function G(t){return z.has($(t))}const X=[":popover-open",":modal"];function J(t){return X.some(e=>{try{return t.matches(e)}catch(t){return!1}})}const Q=["transform","translate","scale","rotate","perspective"],Z=["transform","translate","scale","rotate","perspective","filter"],tt=["paint","layout","strict","content"];function et(t){const e=it(),i=B(t)?ot(t):t;return Q.some(t=>!!i[t]&&"none"!==i[t])||!!i.containerType&&"normal"!==i.containerType||!e&&!!i.backdropFilter&&"none"!==i.backdropFilter||!e&&!!i.filter&&"none"!==i.filter||Z.some(t=>(i.willChange||"").includes(t))||tt.some(t=>(i.contain||"").includes(t))}function it(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const st=new Set(["html","body","#document"]);function nt(t){return st.has($(t))}function ot(t){return N(t).getComputedStyle(t)}function lt(t){return B(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function rt(t){if("html"===$(t))return t;const e=t.assignedSlot||t.parentNode||j(t)&&t.host||q(t);return j(e)?e.host:e}function at(t){const e=rt(t);return nt(e)?t.ownerDocument?t.ownerDocument.body:t.body:U(e)&&Y(e)?e:at(e)}function dt(t,e,i){var s;void 0===e&&(e=[]),void 0===i&&(i=!0);const n=at(t),o=n===(null==(s=t.ownerDocument)?void 0:s.body),l=N(n);if(o){const t=ht(l);return e.concat(l,l.visualViewport||[],Y(n)?n:[],t&&i?dt(t):[])}return e.concat(n,dt(n,[],i))}function ht(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ct(t){const e=ot(t);let i=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const n=U(t),o=n?t.offsetWidth:i,l=n?t.offsetHeight:s,r=a(i)!==o||a(s)!==l;return r&&(i=o,s=l),{width:i,height:s,$:r}}function pt(t){return B(t)?t:t.contextElement}function ut(t){const e=pt(t);if(!U(e))return h(1);const i=e.getBoundingClientRect(),{width:s,height:n,$:o}=ct(e);let l=(o?a(i.width):i.width)/s,r=(o?a(i.height):i.height)/n;return l&&Number.isFinite(l)||(l=1),r&&Number.isFinite(r)||(r=1),{x:l,y:r}}const gt=h(0);function ft(t){const e=N(t);return it()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:gt}function mt(t,e,i,s){void 0===e&&(e=!1),void 0===i&&(i=!1);const n=t.getBoundingClientRect(),o=pt(t);let l=h(1);e&&(s?B(s)&&(l=ut(s)):l=ut(t));const r=function(t,e,i){return void 0===e&&(e=!1),!(!i||e&&i!==N(t))&&e}(o,i,s)?ft(o):h(0);let a=(n.left+r.x)/l.x,d=(n.top+r.y)/l.y,c=n.width/l.x,p=n.height/l.y;if(o){const t=N(o),e=s&&B(s)?N(s):s;let i=t,n=ht(i);for(;n&&s&&e!==i;){const t=ut(n),e=n.getBoundingClientRect(),s=ot(n),o=e.left+(n.clientLeft+parseFloat(s.paddingLeft))*t.x,l=e.top+(n.clientTop+parseFloat(s.paddingTop))*t.y;a*=t.x,d*=t.y,c*=t.x,p*=t.y,a+=o,d+=l,i=N(n),n=ht(i)}}return P({width:c,height:p,x:a,y:d})}function vt(t,e){const i=lt(t).scrollLeft;return e?e.left+i:mt(q(t)).left+i}function wt(t,e,i){void 0===i&&(i=!1);const s=t.getBoundingClientRect();return{x:s.left+e.scrollLeft-(i?0:vt(t,s)),y:s.top+e.scrollTop}}const yt=new Set(["absolute","fixed"]);function bt(t,e,i){let s;if("viewport"===e)s=function(t,e){const i=N(t),s=q(t),n=i.visualViewport;let o=s.clientWidth,l=s.clientHeight,r=0,a=0;if(n){o=n.width,l=n.height;const t=it();(!t||t&&"fixed"===e)&&(r=n.offsetLeft,a=n.offsetTop)}return{width:o,height:l,x:r,y:a}}(t,i);else if("document"===e)s=function(t){const e=q(t),i=lt(t),s=t.ownerDocument.body,n=r(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=r(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let l=-i.scrollLeft+vt(t);const a=-i.scrollTop;return"rtl"===ot(s).direction&&(l+=r(e.clientWidth,s.clientWidth)-n),{width:n,height:o,x:l,y:a}}(q(t));else if(B(e))s=function(t,e){const i=mt(t,!0,"fixed"===e),s=i.top+t.clientTop,n=i.left+t.clientLeft,o=U(t)?ut(t):h(1);return{width:t.clientWidth*o.x,height:t.clientHeight*o.y,x:n*o.x,y:s*o.y}}(e,i);else{const i=ft(t);s={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return P(s)}function Tt(t,e){const i=rt(t);return!(i===e||!B(i)||nt(i))&&("fixed"===ot(i).position||Tt(i,e))}function St(t,e,i){const s=U(e),n=q(e),o="fixed"===i,l=mt(t,!0,o,e);let r={scrollLeft:0,scrollTop:0};const a=h(0);function d(){a.x=vt(n)}if(s||!s&&!o)if(("body"!==$(e)||Y(n))&&(r=lt(e)),s){const t=mt(e,!0,o,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else n&&d();o&&!s&&n&&d();const c=!n||s||o?h(0):wt(n,r);return{x:l.left+r.scrollLeft-a.x-c.x,y:l.top+r.scrollTop-a.y-c.y,width:l.width,height:l.height}}function It(t){return"static"===ot(t).position}function xt(t,e){if(!U(t)||"fixed"===ot(t).position)return null;if(e)return e(t);let i=t.offsetParent;return q(t)===i&&(i=i.ownerDocument.body),i}function Ct(t,e){const i=N(t);if(J(t))return i;if(!U(t)){let e=rt(t);for(;e&&!nt(e);){if(B(e)&&!It(e))return e;e=rt(e)}return i}let s=xt(t,e);for(;s&&G(s)&&It(s);)s=xt(s,e);return s&&nt(s)&&It(s)&&!et(s)?i:s||function(t){let e=rt(t);for(;U(e)&&!nt(e);){if(et(e))return e;if(J(e))return null;e=rt(e)}return null}(t)||i}const Et={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:s,strategy:n}=t;const o="fixed"===n,l=q(s),r=!!e&&J(e.floating);if(s===l||r&&o)return i;let a={scrollLeft:0,scrollTop:0},d=h(1);const c=h(0),p=U(s);if((p||!p&&!o)&&(("body"!==$(s)||Y(l))&&(a=lt(s)),U(s))){const t=mt(s);d=ut(s),c.x=t.x+s.clientLeft,c.y=t.y+s.clientTop}const u=!l||p||o?h(0):wt(l,a,!0);return{width:i.width*d.x,height:i.height*d.y,x:i.x*d.x-a.scrollLeft*d.x+c.x+u.x,y:i.y*d.y-a.scrollTop*d.y+c.y+u.y}},getDocumentElement:q,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:s,strategy:n}=t;const o=[..."clippingAncestors"===i?J(e)?[]:function(t,e){const i=e.get(t);if(i)return i;let s=dt(t,[],!1).filter(t=>B(t)&&"body"!==$(t)),n=null;const o="fixed"===ot(t).position;let l=o?rt(t):t;for(;B(l)&&!nt(l);){const e=ot(l),i=et(l);i||"fixed"!==e.position||(n=null),(o?!i&&!n:!i&&"static"===e.position&&n&&yt.has(n.position)||Y(l)&&!i&&Tt(t,l))?s=s.filter(t=>t!==l):n=e,l=rt(l)}return e.set(t,s),s}(e,this._c):[].concat(i),s],a=o[0],d=o.reduce((t,i)=>{const s=bt(e,i,n);return t.top=r(s.top,t.top),t.right=l(s.right,t.right),t.bottom=l(s.bottom,t.bottom),t.left=r(s.left,t.left),t},bt(e,a,n));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}},getOffsetParent:Ct,getElementRects:async function(t){const e=this.getOffsetParent||Ct,i=this.getDimensions,s=await i(t.floating);return{reference:St(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:i}=ct(t);return{width:e,height:i}},getScale:ut,isElement:B,isRTL:function(t){return"rtl"===ot(t).direction}};function Lt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ot(t,e,i,s){void 0===s&&(s={});const{ancestorScroll:n=!0,ancestorResize:o=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:h="function"==typeof IntersectionObserver,animationFrame:c=!1}=s,p=pt(t),u=n||o?[...p?dt(p):[],...dt(e)]:[];u.forEach(t=>{n&&t.addEventListener("scroll",i,{passive:!0}),o&&t.addEventListener("resize",i)});const g=p&&h?function(t,e){let i,s=null;const n=q(t);function o(){var t;clearTimeout(i),null==(t=s)||t.disconnect(),s=null}return function a(h,c){void 0===h&&(h=!1),void 0===c&&(c=1),o();const p=t.getBoundingClientRect(),{left:u,top:g,width:f,height:m}=p;if(h||e(),!f||!m)return;const v={rootMargin:-d(g)+"px "+-d(n.clientWidth-(u+f))+"px "+-d(n.clientHeight-(g+m))+"px "+-d(u)+"px",threshold:r(0,l(1,c))||1};let w=!0;function y(e){const s=e[0].intersectionRatio;if(s!==c){if(!w)return a();s?a(!1,s):i=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==s||Lt(p,t.getBoundingClientRect())||a(),w=!1}try{s=new IntersectionObserver(y,{...v,root:n.ownerDocument})}catch(t){s=new IntersectionObserver(y,v)}s.observe(t)}(!0),o}(p,i):null;let f,m=-1,v=null;a&&(v=new ResizeObserver(t=>{let[s]=t;s&&s.target===p&&v&&(v.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var t;null==(t=v)||t.observe(e)})),i()}),p&&!c&&v.observe(p),v.observe(e));let w=c?mt(t):null;return c&&function e(){const s=mt(t);w&&!Lt(w,s)&&i();w=s,f=requestAnimationFrame(e)}(),i(),()=>{var t;u.forEach(t=>{n&&t.removeEventListener("scroll",i),o&&t.removeEventListener("resize",i)}),null==g||g(),null==(t=v)||t.disconnect(),v=null,c&&cancelAnimationFrame(f)}}const At=R,Mt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var i,s;const{x:n,y:o,placement:l,middlewareData:r}=e,a=await async function(t,e){const{placement:i,platform:s,elements:n}=t,o=await(null==s.isRTL?void 0:s.isRTL(n.floating)),l=f(i),r=m(i),a="y"===b(i),d=k.has(l)?-1:1,h=o&&a?-1:1,c=g(e,t);let{mainAxis:p,crossAxis:u,alignmentAxis:v}="number"==typeof c?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return r&&"number"==typeof v&&(u="end"===r?-1*v:v),a?{x:u*h,y:p*d}:{x:p*d,y:u*h}}(e,t);return l===(null==(i=r.offset)?void 0:i.placement)&&null!=(s=r.arrow)&&s.alignmentOffset?{}:{x:n+a.x,y:o+a.y,data:{...a,placement:l}}}}},Pt=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var i,s,n;const{rects:l,middlewareData:r,placement:a,platform:d,elements:h}=e,{crossAxis:c=!1,alignment:p,allowedPlacements:u=o,autoAlignment:v=!0,...w}=g(t,e),y=void 0!==p||u===o?function(t,e,i){return(t?[...i.filter(e=>m(e)===t),...i.filter(e=>m(e)!==t)]:i.filter(t=>f(t)===t)).filter(i=>!t||m(i)===t||!!e&&I(i)!==i)}(p||null,v,u):u,b=await R(e,w),T=(null==(i=r.autoPlacement)?void 0:i.index)||0,x=y[T];if(null==x)return{};const C=S(x,l,await(null==d.isRTL?void 0:d.isRTL(h.floating)));if(a!==x)return{reset:{placement:y[0]}};const E=[b[f(x)],b[C[0]],b[C[1]]],L=[...(null==(s=r.autoPlacement)?void 0:s.overflows)||[],{placement:x,overflows:E}],O=y[T+1];if(O)return{data:{index:T+1,overflows:L},reset:{placement:O}};const A=L.map(t=>{const e=m(t.placement);return[t.placement,e&&c?t.overflows.slice(0,2).reduce((t,e)=>t+e,0):t.overflows[0],t.overflows]}).sort((t,e)=>t[1]-e[1]),M=(null==(n=A.filter(t=>t[2].slice(0,m(t[0])?2:3).every(t=>t<=0))[0])?void 0:n[0])||A[0][0];return M!==a?{data:{index:T+1,overflows:L},reset:{placement:M}}:{}}}},Ft=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:s,placement:n}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:r={fn:t=>{let{x:e,y:i}=t;return{x:e,y:i}}},...a}=g(t,e),d={x:i,y:s},h=await R(e,a),c=b(f(n)),p=v(c);let m=d[p],w=d[c];if(o){const t="y"===p?"bottom":"right";m=u(m+h["y"===p?"top":"left"],m,m-h[t])}if(l){const t="y"===c?"bottom":"right";w=u(w+h["y"===c?"top":"left"],w,w-h[t])}const y=r.fn({...e,[p]:m,[c]:w});return{...y,data:{x:y.x-i,y:y.y-s,enabled:{[p]:o,[c]:l}}}}}},Rt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var i,s;const{placement:n,middlewareData:o,rects:l,initialPlacement:r,platform:a,elements:d}=e,{mainAxis:h=!0,crossAxis:c=!0,fallbackPlacements:p,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...w}=g(t,e);if(null!=(i=o.arrow)&&i.alignmentOffset)return{};const y=f(n),T=b(r),x=f(r)===r,C=await(null==a.isRTL?void 0:a.isRTL(d.floating)),E=p||(x||!v?[A(r)]:function(t){const e=A(t);return[I(t),e,I(e)]}(r)),L="none"!==m;!p&&L&&E.push(...O(r,v,m,C));const M=[r,...E],P=await R(e,w),F=[];let D=(null==(s=o.flip)?void 0:s.overflows)||[];if(h&&F.push(P[y]),c){const t=S(n,l,C);F.push(P[t[0]],P[t[1]])}if(D=[...D,{placement:n,overflows:F}],!F.every(t=>t<=0)){var H,_;const t=((null==(H=o.flip)?void 0:H.index)||0)+1,e=M[t];if(e){if(!("alignment"===c&&T!==b(e))||D.every(t=>b(t.placement)!==T||t.overflows[0]>0))return{data:{index:t,overflows:D},reset:{placement:e}}}let i=null==(_=D.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:_.placement;if(!i)switch(u){case"bestFit":{var k;const t=null==(k=D.filter(t=>{if(L){const e=b(t.placement);return e===T||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:k[0];t&&(i=t);break}case"initialPlacement":i=r}if(n!==i)return{reset:{placement:i}}}return{}}}},Dt=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var i,s;const{placement:n,rects:o,platform:a,elements:d}=e,{apply:h=()=>{},...c}=g(t,e),p=await R(e,c),u=f(n),v=m(n),w="y"===b(n),{width:y,height:T}=o.floating;let S,I;"top"===u||"bottom"===u?(S=u,I=v===(await(null==a.isRTL?void 0:a.isRTL(d.floating))?"start":"end")?"left":"right"):(I=u,S="end"===v?"top":"bottom");const x=T-p.top-p.bottom,C=y-p.left-p.right,E=l(T-p[S],x),L=l(y-p[I],C),O=!e.middlewareData.shift;let A=E,M=L;if(null!=(i=e.middlewareData.shift)&&i.enabled.x&&(M=C),null!=(s=e.middlewareData.shift)&&s.enabled.y&&(A=x),O&&!v){const t=r(p.left,0),e=r(p.right,0),i=r(p.top,0),s=r(p.bottom,0);w?M=y-2*(0!==t||0!==e?t+e:r(p.left,p.right)):A=T-2*(0!==i||0!==s?i+s:r(p.top,p.bottom))}await h({...e,availableWidth:M,availableHeight:A});const P=await a.getDimensions(d.floating);return y!==P.width||T!==P.height?{reset:{rects:!0}}:{}}}},Ht=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:i}=e,{strategy:s="referenceHidden",...n}=g(t,e);switch(s){case"referenceHidden":{const t=D(await R(e,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:H(t)}}}case"escaped":{const t=D(await R(e,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:t,escaped:H(t)}}}default:return{}}}}},_t=t=>({name:"arrow",options:t,async fn(e){const{x:i,y:s,placement:n,rects:o,platform:r,elements:a,middlewareData:d}=e,{element:h,padding:c=0}=g(t,e)||{};if(null==h)return{};const p=M(c),f={x:i,y:s},v=T(n),y=w(v),b=await r.getDimensions(h),S="y"===v,I=S?"top":"left",x=S?"bottom":"right",C=S?"clientHeight":"clientWidth",E=o.reference[y]+o.reference[v]-f[v]-o.floating[y],L=f[v]-o.reference[v],O=await(null==r.getOffsetParent?void 0:r.getOffsetParent(h));let A=O?O[C]:0;A&&await(null==r.isElement?void 0:r.isElement(O))||(A=a.floating[C]||o.floating[y]);const P=E/2-L/2,F=A/2-b[y]/2-1,R=l(p[I],F),D=l(p[x],F),H=R,_=A-b[y]-D,k=A/2-b[y]/2+P,W=u(H,k,_),$=!d.arrow&&null!=m(n)&&k!==W&&o.reference[y]/2-(k<H?R:D)-b[y]/2<0,N=$?k<H?k-H:k-_:0;return{[v]:f[v]+N,data:{[v]:W,centerOffset:k-W-N,...$&&{alignmentOffset:N}},reset:$}}}),kt=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:i,elements:s,rects:n,platform:o,strategy:a}=e,{padding:d=2,x:h,y:c}=g(t,e),p=Array.from(await(null==o.getClientRects?void 0:o.getClientRects(s.reference))||[]),u=function(t){const e=t.slice().sort((t,e)=>t.y-e.y),i=[];let s=null;for(let t=0;t<e.length;t++){const n=e[t];!s||n.y-s.y>s.height/2?i.push([n]):i[i.length-1].push(n),s=n}return i.map(t=>P(_(t)))}(p),m=P(_(p)),v=M(d);const w=await o.getElementRects({reference:{getBoundingClientRect:function(){if(2===u.length&&u[0].left>u[1].right&&null!=h&&null!=c)return u.find(t=>h>t.left-v.left&&h<t.right+v.right&&c>t.top-v.top&&c<t.bottom+v.bottom)||m;if(u.length>=2){if("y"===b(i)){const t=u[0],e=u[u.length-1],s="top"===f(i),n=t.top,o=e.bottom,l=s?t.left:e.left,r=s?t.right:e.right;return{top:n,bottom:o,left:l,right:r,width:r-l,height:o-n,x:l,y:n}}const t="left"===f(i),e=r(...u.map(t=>t.right)),s=l(...u.map(t=>t.left)),n=u.filter(i=>t?i.left===s:i.right===e),o=n[0].top,a=n[n.length-1].bottom;return{top:o,bottom:a,left:s,right:e,width:e-s,height:a-o,x:s,y:o}}return m}},floating:s.floating,strategy:a});return n.reference.x!==w.reference.x||n.reference.y!==w.reference.y||n.reference.width!==w.reference.width||n.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},Wt=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:i,y:s,placement:n,rects:o,middlewareData:l}=e,{offset:r=0,mainAxis:a=!0,crossAxis:d=!0}=g(t,e),h={x:i,y:s},c=b(n),p=v(c);let u=h[p],m=h[c];const w=g(r,e),y="number"==typeof w?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(a){const t="y"===p?"height":"width",e=o.reference[p]-o.floating[t]+y.mainAxis,i=o.reference[p]+o.reference[t]-y.mainAxis;u<e?u=e:u>i&&(u=i)}if(d){var T,S;const t="y"===p?"width":"height",e=k.has(f(n)),i=o.reference[c]-o.floating[t]+(e&&(null==(T=l.offset)?void 0:T[c])||0)+(e?0:y.crossAxis),s=o.reference[c]+o.reference[t]+(e?0:(null==(S=l.offset)?void 0:S[c])||0)-(e?y.crossAxis:0);m<i?m=i:m>s&&(m=s)}return{[p]:u,[c]:m}}}},$t=(t,e,i)=>{const s=new Map,n={platform:Et,...i},o={...n.platform,_c:s};return(async(t,e,i)=>{const{placement:s="bottom",strategy:n="absolute",middleware:o=[],platform:l}=i,r=o.filter(Boolean),a=await(null==l.isRTL?void 0:l.isRTL(e));let d=await l.getElementRects({reference:t,floating:e,strategy:n}),{x:h,y:c}=F(d,s,a),p=s,u={},g=0;for(let i=0;i<r.length;i++){const{name:o,fn:f}=r[i],{x:m,y:v,data:w,reset:y}=await f({x:h,y:c,initialPlacement:s,placement:p,strategy:n,middlewareData:u,rects:d,platform:l,elements:{reference:t,floating:e}});h=null!=m?m:h,c=null!=v?v:c,u={...u,[o]:{...u[o],...w}},y&&g<=50&&(g++,"object"==typeof y&&(y.placement&&(p=y.placement),y.rects&&(d=!0===y.rects?await l.getElementRects({reference:t,floating:e,strategy:n}):y.rects),({x:h,y:c}=F(d,p,a))),i=-1)}return{x:h,y:c,placement:p,strategy:n,middlewareData:u}})(t,e,{...n,platform:o})}},956:function(t,e,i){ /* * HSSelect * @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. */ var s=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(n,o){function l(t){try{a(s.next(t))}catch(t){o(t)}}function r(t){try{a(s.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(l,r)}a((s=s.apply(t,e||[])).next())})},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=i(806),l=i(949),r=n(i(287)),a=n(i(294)),d=i(917);class h extends r.default{constructor(t,e){var i,s,n,o,l;super(t,e),this.disabledObserver=null,this.optionId=0;const r=t.getAttribute("data-select"),a=r?JSON.parse(r):{},d=Object.assign(Object.assign({},a),e);this.value=(null==d?void 0:d.value)||this.el.value||null,this.placeholder=(null==d?void 0:d.placeholder)||"Select...",this.hasSearch=(null==d?void 0:d.hasSearch)||!1,this.minSearchLength=null!==(i=null==d?void 0:d.minSearchLength)&&void 0!==i?i:0,this.preventSearchFocus=(null==d?void 0:d.preventSearchFocus)||!1,this.mode=(null==d?void 0:d.mode)||"default",this.viewport=void 0!==(null==d?void 0:d.viewport)?document.querySelector(null==d?void 0:d.viewport):null,this._isOpened=Boolean(null==d?void 0:d.isOpened)||!1,this.isMultiple=this.el.hasAttribute("multiple")||!1,this.isDisabled=this.el.hasAttribute("disabled")||!1,this.selectedItems=[],this.apiUrl=(null==d?void 0:d.apiUrl)||null,this.apiQuery=(null==d?void 0:d.apiQuery)||null,this.apiOptions=(null==d?void 0:d.apiOptions)||null,this.apiSearchQueryKey=(null==d?void 0:d.apiSearchQueryKey)||null,this.apiDataPart=(null==d?void 0:d.apiDataPart)||null,this.apiLoadMore=!0===(null==d?void 0:d.apiLoadMore)?{perPage:10,scrollThreshold:100}:"object"==typeof(null==d?void 0:d.apiLoadMore)&&null!==(null==d?void 0:d.apiLoadMore)&&{perPage:d.apiLoadMore.perPage||10,scrollThreshold:d.apiLoadMore.scrollThreshold||100},this.apiFieldsMap=(null==d?void 0:d.apiFieldsMap)||null,this.apiIconTag=(null==d?void 0:d.apiIconTag)||null,this.apiSelectedValues=(null==d?void 0:d.apiSelectedValues)||null,this.currentPage=0,this.isLoading=!1,this.hasMore=!0,this.wrapperClasses=(null==d?void 0:d.wrapperClasses)||null,this.toggleTag=(null==d?void 0:d.toggleTag)||null,this.toggleClasses=(null==d?void 0:d.toggleClasses)||null,this.toggleCountText=void 0===typeof(null==d?void 0:d.toggleCountText)?null:d.toggleCountText,this.toggleCountTextPlacement=(null==d?void 0:d.toggleCountTextPlacement)||"postfix",this.toggleCountTextMinItems=(null==d?void 0:d.toggleCountTextMinItems)||1,this.toggleCountTextMode=(null==d?void 0:d.toggleCountTextMode)||"countAfterLimit",this.toggleSeparators={items:(null===(s=null==d?void 0:d.toggleSeparators)||void 0===s?void 0:s.items)||", ",betweenItemsAndCounter:(null===(n=null==d?void 0:d.toggleSeparators)||void 0===n?void 0:n.betweenItemsAndCounter)||"and"},this.tagsItemTemplate=(null==d?void 0:d.tagsItemTemplate)||null,this.tagsItemClasses=(null==d?void 0:d.tagsItemClasses)||null,this.tagsInputId=(null==d?void 0:d.tagsInputId)||null,this.tagsInputClasses=(null==d?void 0:d.tagsInputClasses)||null,this.dropdownTag=(null==d?void 0:d.dropdownTag)||null,this.dropdownClasses=(null==d?void 0:d.dropdownClasses)||null,this.dropdownDirectionClasses=(null==d?void 0:d.dropdownDirectionClasses)||null,this.dropdownSpace=(null==d?void 0:d.dropdownSpace)||10,this.dropdownPlacement=(null==d?void 0:d.dropdownPlacement)||null,this.dropdownVerticalFixedPlacement=(null==d?void 0:d.dropdownVerticalFixedPlacement)||null,this.dropdownScope=(null==d?void 0:d.dropdownScope)||"parent",this.dropdownAutoPlacement=(null==d?void 0:d.dropdownAutoPlacement)||!1,this.searchTemplate=(null==d?void 0:d.searchTemplate)||null,this.searchWrapperTemplate=(null==d?void 0:d.searchWrapperTemplate)||null,this.searchWrapperClasses=(null==d?void 0:d.searchWrapperClasses)||"bg-base-100 sticky top-0 mb-2 px-2 pt-3",this.searchId=(null==d?void 0:d.searchId)||null,this.searchLimit=(null==d?void 0:d.searchLimit)||1/0,this.isSearchDirectMatch=void 0===(null==d?void 0:d.isSearchDirectMatch)||(null==d?void 0:d.isSearchDirectMatch),this.searchClasses=(null==d?void 0:d.searchClasses)||"border-base-content/40 focus:border-primary focus:outline-primary bg-base-100 block w-full rounded-field border px-3 py-2 text-base focus:outline-1",this.searchPlaceholder=(null==d?void 0:d.searchPlaceholder)||"Search...",this.searchNoResultTemplate=(null==d?void 0:d.searchNoResultTemplate)||"<span></span>",this.searchNoResultText=(null==d?void 0:d.searchNoResultText)||"No results found",this.searchNoResultClasses=(null==d?void 0:d.searchNoResultClasses)||"block advance-select-option",this.optionAllowEmptyOption=void 0!==(null==d?void 0:d.optionAllowEmptyOption)&&(null==d?void 0:d.optionAllowEmptyOption),this.optionTemplate=(null==d?void 0:d.optionTemplate)||null,this.optionTag=(null==d?void 0:d.optionTag)||null,this.optionClasses=(null==d?void 0:d.optionClasses)||null,this.extraMarkup=(null==d?void 0:d.extraMarkup)||null,this.descriptionClasses=(null==d?void 0:d.descriptionClasses)||null,this.iconClasses=(null==d?void 0:d.iconClasses)||null,this.isAddTagOnEnter=null===(o=null==d?void 0:d.isAddTagOnEnter)||void 0===o||o,this.isSelectedOptionOnTop=null!==(l=null==d?void 0:d.isSelectedOptionOnTop)&&void 0!==l&&l,this.animationInProcess=!1,this.selectOptions=[],this.remoteOptions=[],this.tagsInputHelper=null,this.disabledObserver=new MutationObserver(t=>{t.some(t=>"disabled"===t.attributeName)&&this.setDisabledState(this.el.hasAttribute("disabled"))}),this.disabledObserver.observe(this.el,{attributes:!0,attributeFilter:["disabled"]}),this.init()}wrapperClick(t){t.target.closest("[data-select-dropdown]")||t.target.closest("[data-tag-value]")||this.tagsInput.focus()}toggleClick(){if(this.isDisabled)return!1;this.toggleFn()}tagsInputFocus(){this._isOpened||this.open()}tagsInputInput(){this.calculateInputWidth()}tagsInputInputSecond(t){this.apiUrl||this.searchOptions(t.target.value)}tagsInputKeydown(t){if("Enter"===t.key&&this.isAddTagOnEnter){const e=t.target.value;if(this.selectOptions.find(t=>t.val===e))return!1;this.addSelectOption(e,e),this.buildOption(e,e),this.buildOriginalOption(e,e),this.dropdown.querySelector(`[data-value="${e}"]`).click(),this.resetTagsInputField()}}searchInput(t){const e=t.target.value;this.apiUrl?this.remoteSearch(e):this.searchOptions(e)}setValue(t){if(this.value=t,this.clearSelections(),Array.isArray(t))if("tags"===this.mode){this.unselectMultipleItems(),this.selectMultipleItems(),this.selectedItems=[];this.wrapper.querySelectorAll("[data-tag-value]").forEach(t=>t.remove()),this.setTagsItems(),this.reassignTagsInputPlaceholder(this.hasValue()?"":this.placeholder)}else this.toggleTextWrapper.innerHTML=this.hasValue()?this.stringFromValue():this.placeholder,this.unselectMultipleItems(),this.selectMultipleItems();else this.setToggleTitle(),this.toggle.querySelector("[data-icon]")&&this.setToggleIcon(),this.toggle.querySelector("[data-title]")&&this.setToggleTitle(),this.selectSingleItem()}setDisabledState(t){this.isDisabled=t;const e="tags"===this.mode?this.wrapper:this.toggle;null==e||e.classList.toggle("disabled",t),t&&this.isOpened()&&this.close()}hasValue(){return this.isMultiple?Array.isArray(this.value)&&this.value.length>0&&this.value.some(t=>null!=t&&""!==t):null!==this.value&&void 0!==this.value&&""!==this.value}init(){this.createCollection(window.$hsSelectCollection,this),this.build(),"undefined"!=typeof window&&(window.HSAccessibilityObserver||(window.HSAccessibilityObserver=new a.default),this.setupAccessibility())}build(){if(this.el.style.display="none",this.el.children&&Array.from(this.el.children).filter(t=>this.optionAllowEmptyOption||!this.optionAllowEmptyOption&&t.value&&""!==t.value).forEach(t=>{const e=t.getAttribute("data-select-option");this.selectOptions=[...this.selectOptions,{title:t.textContent,val:t.value,disabled:t.disabled,options:"undefined"!==e?JSON.parse(e):null}]}),this.optionAllowEmptyOption&&!this.value&&(this.value=""),this.isMultiple){const t=Array.from(this.el.children).filter(t=>t.selected),e=[];t.forEach(t=>{e.push(t.value)}),this.value=e}this.buildWrapper(),"tags"===this.mode?this.buildTags():this.buildToggle(),this.buildDropdown(),this.extraMarkup&&this.buildExtraMarkup()}buildWrapper(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("advance-select","relative"),this.setDisabledState(this.isDisabled),"tags"===this.mode&&(this.onWrapperClickListener=t=>this.wrapperClick(t),this.wrapper.addEventListener("click",this.onWrapperClickListener)),this.wrapperClasses&&(0,o.classToClassList)(this.wrapperClasses,this.wrapper),this.el.before(this.wrapper),this.wrapper.append(this.el)}buildExtraMarkup(){const t=t=>{const e=(0,o.htmlToElement)(t);return this.wrapper.append(e),e},e=t=>{t.classList.contains("--prevent-click")||t.addEventListener("click",t=>{t.stopPropagation(),this.isDisabled||this.toggleFn()})};if(Array.isArray(this.extraMarkup))this.extraMarkup.forEach(i=>{const s=t(i);e(s)});else{const i=t(this.extraMarkup);e(i)}}buildToggle(){var t,e;let i,s;this.toggleTextWrapper=document.createElement("span"),this.toggleTextWrapper.classList.add("truncate"),this.toggle=(0,o.htmlToElement)(this.toggleTag||"<div></div>"),i=this.toggle.querySelector("[data-icon]"),s=this.toggle.querySelector("[data-title]"),!this.isMultiple&&i&&this.setToggleIcon(),!this.isMultiple&&s&&this.setToggleTitle(),this.isMultiple?this.toggleTextWrapper.innerHTML=this.hasValue()?this.stringFromValue():this.placeholder:this.toggleTextWrapper.innerHTML=(null===(t=this.getItemByValue(this.value))||void 0===t?void 0:t.title)||this.placeholder,s||this.toggle.append(this.toggleTextWrapper),this.toggleClasses&&(0,o.classToClassList)(this.toggleClasses,this.toggle),this.isDisabled&&this.toggle.classList.add("disabled"),this.wrapper&&this.wrapper.append(this.toggle),(null===(e=this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this._isOpened?this.toggle.ariaExpanded="true":this.toggle.ariaExpanded="false"),this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)}setToggleIcon(){var t;const e=this.getItemByValue(this.value),i=this.toggle.querySelector("[data-icon]");if(i){i.innerHTML="";const s=(0,o.htmlToElement)(this.apiUrl&&this.apiIconTag?this.apiIconTag||"":(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.icon)||"");this.value&&this.apiUrl&&this.apiIconTag&&e[this.apiFieldsMap.icon]&&(s.src=e[this.apiFieldsMap.icon]||""),i.append(s),(null==s?void 0:s.src)?i.classList.remove("hidden"):i.classList.add("hidden")}}setToggleTitle(){const t=this.toggle.querySelector("[data-title]");let e=this.placeholder;if(this.optionAllowEmptyOption&&""===this.value){const t=this.selectOptions.find(t=>""===t.val);e=(null==t?void 0:t.title)||this.placeholder}else if(this.value)if(this.apiUrl){const t=this.remoteOptions.find(t=>`${t[this.apiFieldsMap.val]}`===this.value||`${t[this.apiFieldsMap.title]}`===this.value);t&&(e=t[this.apiFieldsMap.title])}else{const t=this.selectOptions.find(t=>t.val===this.value);t&&(e=t.title)}t?(t.innerHTML=e,t.classList.add("truncate"),this.toggle.append(t)):this.toggleTextWrapper.innerHTML=e}buildTags(){this.isDisabled&&this.wrapper.classList.add("disabled"),this.wrapper.setAttribute("tabindex","0"),this.buildTagsInput(),this.setTagsItems()}reassignTagsInputPlaceholder(t){this.tagsInput.placeholder=t,this.tagsInputHelper.innerHTML=t,this.calculateInputWidth()}buildTagsItem(t){var e,i,s,n,l;const r=this.getItemByValue(t);let a,d,h,c;const p=document.createElement("div");if(p.setAttribute("data-tag-value",t),this.tagsItemClasses&&(0,o.classToClassList)(this.tagsItemClasses,p),this.tagsItemTemplate&&(a=(0,o.htmlToElement)(this.tagsItemTemplate),p.append(a)),(null===(e=null==r?void 0:r.options)||void 0===e?void 0:e.icon)||this.apiIconTag){const t=(0,o.htmlToElement)(this.apiUrl&&this.apiIconTag?this.apiIconTag:null===(i=null==r?void 0:r.options)||void 0===i?void 0:i.icon);this.apiUrl&&this.apiIconTag&&r[this.apiFieldsMap.icon]&&(t.src=r[this.apiFieldsMap.icon]||""),c=a?a.querySelector("[data-icon]"):document.createElement("span"),c.append(t),a||p.append(c)}!a||!a.querySelector("[data-icon]")||(null===(s=null==r?void 0:r.options)||void 0===s?void 0:s.icon)||this.apiUrl||this.apiIconTag||r[null===(n=this.apiFieldsMap)||void 0===n?void 0:n.icon]||a.querySelector("[data-icon]").classList.add("hidden"),d=a?a.querySelector("[data-title]"):document.createElement("span"),this.apiUrl&&(null===(l=this.apiFieldsMap)||void 0===l?void 0:l.title)&&r[this.apiFieldsMap.title]?d.textContent=r[this.apiFieldsMap.title]:d.textContent=r.title||"",a||p.append(d),a?h=a.querySelector("[data-remove]"):(h=document.createElement("span"),h.textContent="X",p.append(h)),h.addEventListener("click",()=>{this.value=this.value.filter(e=>e!==t),this.selectedItems=this.selectedItems.filter(e=>e!==t),this.hasValue()||this.reassignTagsInputPlaceholder(this.placeholder),this.unselectMultipleItems(),this.selectMultipleItems(),p.remove(),this.triggerChangeEventForNativeSelect()}),this.wrapper.append(p)}getItemByValue(t){return this.apiUrl?this.remoteOptions.find(e=>`${e[this.apiFieldsMap.val]}`===t||e[this.apiFieldsMap.title]===t):this.selectOptions.find(e=>e.val===t)}setTagsItems(){if(this.value){(Array.isArray(this.value)?this.value:null!=this.value?[this.value]:[]).forEach(t=>{this.selectedItems.includes(t)||this.buildTagsItem(t),this.selectedItems=this.selectedItems.includes(t)?this.selectedItems:[...this.selectedItems,t]})}this._isOpened&&this.floatingUIInstance&&this.floatingUIInstance.update()}buildTagsInput(){this.tagsInput=document.createElement("input"),this.tagsInputId&&(this.tagsInput.id=this.tagsInputId),this.tagsInputClasses&&(0,o.classToClassList)(this.tagsInputClasses,this.tagsInput),this.tagsInput.setAttribute("tabindex","-1"),this.onTagsInputFocusListener=()=>this.tagsInputFocus(),this.onTagsInputInputListener=()=>this.tagsInputInput(),this.onTagsInputInputSecondListener=(0,o.debounce)(t=>this.tagsInputInputSecond(t)),this.onTagsInputKeydownListener=t=>this.tagsInputKeydown(t),this.tagsInput.addEventListener("focus",this.onTagsInputFocusListener),this.tagsInput.addEventListener("input",this.onTagsInputInputListener),this.tagsInput.addEventListener("input",this.onTagsInputInputSecondListener),this.tagsInput.addEventListener("keydown",this.onTagsInputKeydownListener),this.wrapper.append(this.tagsInput),setTimeout(()=>{this.adjustInputWidth(),this.reassignTagsInputPlaceholder(this.hasValue()?"":this.placeholder)})}buildDropdown(){this.dropdown=(0,o.htmlToElement)(this.dropdownTag||"<div></div>"),this.dropdown.setAttribute("data-select-dropdown",""),"parent"===this.dropdownScope&&(this.dropdown.classList.add("absolute"),this.dropdownVerticalFixedPlacement||this.dropdown.classList.add("top-full")),this.dropdown.role="listbox",this.dropdown.tabIndex=-1,this.dropdown.ariaOrientation="vertical",this._isOpened||this.dropdown.classList.add("hidden"),this.dropdownClasses&&(0,o.classToClassList)(this.dropdownClasses,this.dropdown),this.wrapper&&this.wrapper.append(this.dropdown),this.dropdown&&this.hasSearch&&this.buildSearch(),this.selectOptions&&this.selectOptions.forEach((t,e)=>this.buildOption(t.title,t.val,t.disabled,t.selected,t.options,`${e}`)),this.apiUrl&&this.optionsFromRemoteData(),this.apiUrl||(this.sortElements(this.el,"option"),this.sortElements(this.dropdown,"[data-value]")),"window"===this.dropdownScope&&this.buildFloatingUI(),this.dropdown&&this.apiLoadMore&&this.setupInfiniteScroll()}setupInfiniteScroll(){this.dropdown.addEventListener("scroll",this.handleScroll.bind(this))}handleScroll(){return s(this,void 0,void 0,function*(){if(!this.dropdown||this.isLoading||!this.hasMore||!this.apiLoadMore)return;const{scrollTop:t,scrollHeight:e,clientHeight:i}=this.dropdown;e-t-i<("object"==typeof this.apiLoadMore?this.apiLoadMore.scrollThreshold:100)&&(yield this.loadMore())})}loadMore(){return s(this,void 0,void 0,function*(){var t,e,i,s;if(this.apiUrl&&!this.isLoading&&this.hasMore&&this.apiLoadMore){this.isLoading=!0;try{const n=new URL(this.apiUrl),o=(null===(t=this.apiFieldsMap)||void 0===t?void 0:t.page)||(null===(e=this.apiFieldsMap)||void 0===e?void 0:e.offset)||"page",l=!!(null===(i=this.apiFieldsMap)||void 0===i?void 0:i.offset),r="object"==typeof this.apiLoadMore?this.apiLoadMore.perPage:10;if(l){const t=this.currentPage*r;n.searchParams.set(o,t.toString()),this.currentPage++}else this.currentPage++,n.searchParams.set(o,this.currentPage.toString());n.searchParams.set((null===(s=this.apiFieldsMap)||void 0===s?void 0:s.limit)||"limit",r.toString());const a=yield fetch(n.toString(),this.apiOptions||{}),d=yield a.json(),h=this.apiDataPart?d[this.apiDataPart]:d.results,c=d.count||0,p=this.currentPage*r;h&&h.length>0?(this.remoteOptions=[...this.remoteOptions||[],...h],this.buildOptionsFromRemoteData(h),this.hasMore=p<c):this.hasMore=!1}catch(t){this.hasMore=!1,console.error("Error loading more options:",t)}finally{this.isLoading=!1}}})}buildFloatingUI(){document.body.appendChild(this.dropdown);const t="tags"===this.mode?this.wrapper:this.toggle,e=[(0,l.offset)(0)];this.dropdownAutoPlacement&&e.push((0,l.flip)({fallbackPlacements:["bottom-start","bottom-end","top-start","top-end"]}));const i={placement:d.POSITIONS[this.dropdownPlacement]||"bottom",strategy:"fixed",middleware:e},s=()=>{(0,l.computePosition)(t,this.dropdown,i).then(({x:t,y:e,placement:i})=>{Object.assign(this.dropdown.style,{position:"fixed",left:`${t}px`,top:`${e}px`,["margin"+("bottom"===i?"Top":"top"===i?"Bottom":"right"===i?"Left":"Right")]:`${this.dropdownSpace}px`}),this.dropdown.setAttribute("data-placement",i)})};s();const n=(0,l.autoUpdate)(t,this.dropdown,s);this.floatingUIInstance={update:s,destroy:n}}updateDropdownWidth(){const t="tags"===this.mode?this.wrapper:this.toggle;this.dropdown.style.width=`${t.clientWidth}px`}buildSearch(){let t;this.searchWrapper=(0,o.htmlToElement)(this.searchWrapperTemplate||"<div></div>"),this.searchWrapperClasses&&(0,o.classToClassList)(this.searchWrapperClasses,this.searchWrapper),t=this.searchWrapper.querySelector("[data-input]");const e=(0,o.htmlToElement)(this.searchTemplate||'<input type="text">');this.search="INPUT"===e.tagName?e:e.querySelector(":scope input"),this.search.placeholder=this.searchPlaceholder,this.searchClasses&&(0,o.classToClassList)(this.searchClasses,this.search),this.searchId&&(this.search.id=this.searchId),this.onSearchInputListener=(0,o.debounce)(t=>this.searchInput(t)),this.search.addEventListener("input",this.onSearchInputListener),t?t.append(e):this.searchWrapper.append(e),this.dropdown.append(this.searchWrapper)}buildOption(t,e,i=!1,s=!1,n,l="1",r){var a;let d=null,h=null,c=null,p=null;const u=(0,o.htmlToElement)(this.optionTag||"<div></div>");if(u.setAttribute("data-value",e),u.setAttribute("data-title-value",t),u.setAttribute("tabIndex",l),u.classList.add("cursor-pointer"),u.setAttribute("data-id",r||`${this.optionId}`),r||this.optionId++,i&&u.classList.add("disabled"),s&&(this.isMultiple?this.value=[...this.value,e]:this.value=e),this.optionTemplate&&(d=(0,o.htmlToElement)(this.optionTemplate),u.append(d)),d?(h=d.querySelector("[data-title]"),h.textContent=t||""):u.textContent=t||"",n){if(n.icon){const e=(0,o.htmlToElement)(null!==(a=this.apiIconTag)&&void 0!==a?a:n.icon);if(e.classList.add("max-w-full"),this.apiUrl&&(e.setAttribute("alt",t),e.setAttribute("src",n.icon)),d)c=d.querySelector("[data-icon]"),c.append(e);else{const t=(0,o.htmlToElement)("<div></div>");this.iconClasses&&(0,o.classToClassList)(this.iconClasses,t),t.append(e),u.append(t)}}if(n.description)if(d)p=d.querySelector("[data-description]"),p&&p.append(n.description);else{const t=(0,o.htmlToElement)("<div></div>");t.textContent=n.description,this.descr