@keenmate/web-multiselect 1.0.0-rc05 → 1.0.0-rc08

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,26 @@
1
- (function(P,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(P=typeof globalThis<"u"?globalThis:P||self,C(P.MultiSelect={}))})(this,function(P){"use strict";var Nt=Object.defineProperty;var Ft=(P,C,S)=>C in P?Nt(P,C,{enumerable:!0,configurable:!0,writable:!0,value:S}):P[C]=S;var h=(P,C,S)=>Ft(P,typeof C!="symbol"?C+"":C,S);const C=Math.min,S=Math.max,q=Math.round,Z=Math.floor,I=i=>({x:i,y:i}),Ye={left:"right",right:"left",bottom:"top",top:"bottom"},Xe={start:"end",end:"start"};function Ce(i,e,t){return S(i,C(e,t))}function Q(i,e){return typeof i=="function"?i(e):i}function R(i){return i.split("-")[0]}function ee(i){return i.split("-")[1]}function ke(i){return i==="x"?"y":"x"}function Pe(i){return i==="y"?"height":"width"}const Je=new Set(["top","bottom"]);function D(i){return Je.has(R(i))?"y":"x"}function Ae(i){return ke(D(i))}function qe(i,e,t){t===void 0&&(t=!1);const l=ee(i),o=Ae(i),s=Pe(o);let n=o==="x"?l===(t?"end":"start")?"right":"left":l==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(n=te(n)),[n,te(n)]}function Ze(i){const e=te(i);return[he(i),e,he(e)]}function he(i){return i.replace(/start|end/g,e=>Xe[e])}const Se=["left","right"],Oe=["right","left"],Qe=["top","bottom"],et=["bottom","top"];function tt(i,e,t){switch(i){case"top":case"bottom":return t?e?Oe:Se:e?Se:Oe;case"left":case"right":return e?Qe:et;default:return[]}}function it(i,e,t,l){const o=ee(i);let s=tt(R(i),t==="start",l);return o&&(s=s.map(n=>n+"-"+o),e&&(s=s.concat(s.map(he)))),s}function te(i){return i.replace(/left|right|bottom|top/g,e=>Ye[e])}function lt(i){return{top:0,right:0,bottom:0,left:0,...i}}function ot(i){return typeof i!="number"?lt(i):{top:i,right:i,bottom:i,left:i}}function ie(i){const{x:e,y:t,width:l,height:o}=i;return{width:l,height:o,top:t,left:e,right:e+l,bottom:t+o,x:e,y:t}}function Te(i,e,t){let{reference:l,floating:o}=i;const s=D(e),n=Ae(e),r=Pe(n),a=R(e),c=s==="y",p=l.x+l.width/2-o.width/2,d=l.y+l.height/2-o.height/2,m=l[r]/2-o[r]/2;let u;switch(a){case"top":u={x:p,y:l.y-o.height};break;case"bottom":u={x:p,y:l.y+l.height};break;case"right":u={x:l.x+l.width,y:d};break;case"left":u={x:l.x-o.width,y:d};break;default:u={x:l.x,y:l.y}}switch(ee(e)){case"start":u[n]-=m*(t&&c?-1:1);break;case"end":u[n]+=m*(t&&c?-1:1);break}return u}const st=async(i,e,t)=>{const{placement:l="bottom",strategy:o="absolute",middleware:s=[],platform:n}=t,r=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(e));let c=await n.getElementRects({reference:i,floating:e,strategy:o}),{x:p,y:d}=Te(c,l,a),m=l,u={},g=0;for(let v=0;v<r.length;v++){const{name:w,fn:b}=r[v],{x:_,y,data:k,reset:x}=await b({x:p,y:d,initialPlacement:l,placement:m,strategy:o,middlewareData:u,rects:c,platform:n,elements:{reference:i,floating:e}});p=_??p,d=y??d,u={...u,[w]:{...u[w],...k}},x&&g<=50&&(g++,typeof x=="object"&&(x.placement&&(m=x.placement),x.rects&&(c=x.rects===!0?await n.getElementRects({reference:i,floating:e,strategy:o}):x.rects),{x:p,y:d}=Te(c,m,a)),v=-1)}return{x:p,y:d,placement:m,strategy:o,middlewareData:u}};async function Me(i,e){var t;e===void 0&&(e={});const{x:l,y:o,platform:s,rects:n,elements:r,strategy:a}=i,{boundary:c="clippingAncestors",rootBoundary:p="viewport",elementContext:d="floating",altBoundary:m=!1,padding:u=0}=Q(e,i),g=ot(u),w=r[m?d==="floating"?"reference":"floating":d],b=ie(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(w)))==null||t?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(r.floating)),boundary:c,rootBoundary:p,strategy:a})),_=d==="floating"?{x:l,y:o,width:n.floating.width,height:n.floating.height}:n.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(r.floating)),k=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},x=ie(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:_,offsetParent:y,strategy:a}):_);return{top:(b.top-x.top+g.top)/k.y,bottom:(x.bottom-b.bottom+g.bottom)/k.y,left:(b.left-x.left+g.left)/k.x,right:(x.right-b.right+g.right)/k.x}}const nt=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(e){var t,l;const{placement:o,middlewareData:s,rects:n,initialPlacement:r,platform:a,elements:c}=e,{mainAxis:p=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...w}=Q(i,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const b=R(o),_=D(r),y=R(r)===r,k=await(a.isRTL==null?void 0:a.isRTL(c.floating)),x=m||(y||!v?[te(r)]:Ze(r)),X=g!=="none";!m&&X&&x.push(...it(r,v,g,k));const G=[r,...x],ye=await Me(e,w),pe=[];let K=((l=s.flip)==null?void 0:l.overflows)||[];if(p&&pe.push(ye[b]),d){const F=qe(o,n,k);pe.push(ye[F[0]],ye[F[1]])}if(K=[...K,{placement:o,overflows:pe}],!pe.every(F=>F<=0)){var Ge,Ke;const F=(((Ge=s.flip)==null?void 0:Ge.index)||0)+1,xe=G[F];if(xe&&(!(d==="alignment"?_!==D(xe):!1)||K.every(M=>D(M.placement)===_?M.overflows[0]>0:!0)))return{data:{index:F,overflows:K},reset:{placement:xe}};let J=(Ke=K.filter(B=>B.overflows[0]<=0).sort((B,M)=>B.overflows[1]-M.overflows[1])[0])==null?void 0:Ke.placement;if(!J)switch(u){case"bestFit":{var Ue;const B=(Ue=K.filter(M=>{if(X){const z=D(M.placement);return z===_||z==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(z=>z>0).reduce((z,Rt)=>z+Rt,0)]).sort((M,z)=>M[1]-z[1])[0])==null?void 0:Ue[0];B&&(J=B);break}case"initialPlacement":J=r;break}if(o!==J)return{reset:{placement:J}}}return{}}}},rt=new Set(["left","top"]);async function at(i,e){const{placement:t,platform:l,elements:o}=i,s=await(l.isRTL==null?void 0:l.isRTL(o.floating)),n=R(t),r=ee(t),a=D(t)==="y",c=rt.has(n)?-1:1,p=s&&a?-1:1,d=Q(e,i);let{mainAxis:m,crossAxis:u,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return r&&typeof g=="number"&&(u=r==="end"?g*-1:g),a?{x:u*p,y:m*c}:{x:m*c,y:u*p}}const ct=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(e){var t,l;const{x:o,y:s,placement:n,middlewareData:r}=e,a=await at(e,i);return n===((t=r.offset)==null?void 0:t.placement)&&(l=r.arrow)!=null&&l.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:n}}}}},dt=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(e){const{x:t,y:l,placement:o}=e,{mainAxis:s=!0,crossAxis:n=!1,limiter:r={fn:w=>{let{x:b,y:_}=w;return{x:b,y:_}}},...a}=Q(i,e),c={x:t,y:l},p=await Me(e,a),d=D(R(o)),m=ke(d);let u=c[m],g=c[d];if(s){const w=m==="y"?"top":"left",b=m==="y"?"bottom":"right",_=u+p[w],y=u-p[b];u=Ce(_,u,y)}if(n){const w=d==="y"?"top":"left",b=d==="y"?"bottom":"right",_=g+p[w],y=g-p[b];g=Ce(_,g,y)}const v=r.fn({...e,[m]:u,[d]:g});return{...v,data:{x:v.x-t,y:v.y-l,enabled:{[m]:s,[d]:n}}}}}};function le(){return typeof window<"u"}function H(i){return Ie(i)?(i.nodeName||"").toLowerCase():"#document"}function A(i){var e;return(i==null||(e=i.ownerDocument)==null?void 0:e.defaultView)||window}function E(i){var e;return(e=(Ie(i)?i.ownerDocument:i.document)||window.document)==null?void 0:e.documentElement}function Ie(i){return le()?i instanceof Node||i instanceof A(i).Node:!1}function O(i){return le()?i instanceof Element||i instanceof A(i).Element:!1}function V(i){return le()?i instanceof HTMLElement||i instanceof A(i).HTMLElement:!1}function Ee(i){return!le()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof A(i).ShadowRoot}const pt=new Set(["inline","contents"]);function U(i){const{overflow:e,overflowX:t,overflowY:l,display:o}=T(i);return/auto|scroll|overlay|hidden|clip/.test(e+l+t)&&!pt.has(o)}const ht=new Set(["table","td","th"]);function ut(i){return ht.has(H(i))}const mt=[":popover-open",":modal"];function oe(i){return mt.some(e=>{try{return i.matches(e)}catch{return!1}})}const ft=["transform","translate","scale","rotate","perspective"],gt=["transform","translate","scale","rotate","perspective","filter"],bt=["paint","layout","strict","content"];function ue(i){const e=me(),t=O(i)?T(i):i;return ft.some(l=>t[l]?t[l]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||gt.some(l=>(t.willChange||"").includes(l))||bt.some(l=>(t.contain||"").includes(l))}function vt(i){let e=$(i);for(;V(e)&&!j(e);){if(ue(e))return e;if(oe(e))return null;e=$(e)}return null}function me(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const wt=new Set(["html","body","#document"]);function j(i){return wt.has(H(i))}function T(i){return A(i).getComputedStyle(i)}function se(i){return O(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function $(i){if(H(i)==="html")return i;const e=i.assignedSlot||i.parentNode||Ee(i)&&i.host||E(i);return Ee(e)?e.host:e}function Ve(i){const e=$(i);return j(e)?i.ownerDocument?i.ownerDocument.body:i.body:V(e)&&U(e)?e:Ve(e)}function Y(i,e,t){var l;e===void 0&&(e=[]),t===void 0&&(t=!0);const o=Ve(i),s=o===((l=i.ownerDocument)==null?void 0:l.body),n=A(o);if(s){const r=fe(n);return e.concat(n,n.visualViewport||[],U(o)?o:[],r&&t?Y(r):[])}return e.concat(o,Y(o,[],t))}function fe(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function De(i){const e=T(i);let t=parseFloat(e.width)||0,l=parseFloat(e.height)||0;const o=V(i),s=o?i.offsetWidth:t,n=o?i.offsetHeight:l,r=q(t)!==s||q(l)!==n;return r&&(t=s,l=n),{width:t,height:l,$:r}}function ge(i){return O(i)?i:i.contextElement}function W(i){const e=ge(i);if(!V(e))return I(1);const t=e.getBoundingClientRect(),{width:l,height:o,$:s}=De(e);let n=(s?q(t.width):t.width)/l,r=(s?q(t.height):t.height)/o;return(!n||!Number.isFinite(n))&&(n=1),(!r||!Number.isFinite(r))&&(r=1),{x:n,y:r}}const _t=I(0);function $e(i){const e=A(i);return!me()||!e.visualViewport?_t:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function yt(i,e,t){return e===void 0&&(e=!1),!t||e&&t!==A(i)?!1:e}function N(i,e,t,l){e===void 0&&(e=!1),t===void 0&&(t=!1);const o=i.getBoundingClientRect(),s=ge(i);let n=I(1);e&&(l?O(l)&&(n=W(l)):n=W(i));const r=yt(s,t,l)?$e(s):I(0);let a=(o.left+r.x)/n.x,c=(o.top+r.y)/n.y,p=o.width/n.x,d=o.height/n.y;if(s){const m=A(s),u=l&&O(l)?A(l):l;let g=m,v=fe(g);for(;v&&l&&u!==g;){const w=W(v),b=v.getBoundingClientRect(),_=T(v),y=b.left+(v.clientLeft+parseFloat(_.paddingLeft))*w.x,k=b.top+(v.clientTop+parseFloat(_.paddingTop))*w.y;a*=w.x,c*=w.y,p*=w.x,d*=w.y,a+=y,c+=k,g=A(v),v=fe(g)}}return ie({width:p,height:d,x:a,y:c})}function ne(i,e){const t=se(i).scrollLeft;return e?e.left+t:N(E(i)).left+t}function Le(i,e){const t=i.getBoundingClientRect(),l=t.left+e.scrollLeft-ne(i,t),o=t.top+e.scrollTop;return{x:l,y:o}}function xt(i){let{elements:e,rect:t,offsetParent:l,strategy:o}=i;const s=o==="fixed",n=E(l),r=e?oe(e.floating):!1;if(l===n||r&&s)return t;let a={scrollLeft:0,scrollTop:0},c=I(1);const p=I(0),d=V(l);if((d||!d&&!s)&&((H(l)!=="body"||U(n))&&(a=se(l)),V(l))){const u=N(l);c=W(l),p.x=u.x+l.clientLeft,p.y=u.y+l.clientTop}const m=n&&!d&&!s?Le(n,a):I(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+p.x+m.x,y:t.y*c.y-a.scrollTop*c.y+p.y+m.y}}function Ct(i){return Array.from(i.getClientRects())}function kt(i){const e=E(i),t=se(i),l=i.ownerDocument.body,o=S(e.scrollWidth,e.clientWidth,l.scrollWidth,l.clientWidth),s=S(e.scrollHeight,e.clientHeight,l.scrollHeight,l.clientHeight);let n=-t.scrollLeft+ne(i);const r=-t.scrollTop;return T(l).direction==="rtl"&&(n+=S(e.clientWidth,l.clientWidth)-o),{width:o,height:s,x:n,y:r}}const ze=25;function Pt(i,e){const t=A(i),l=E(i),o=t.visualViewport;let s=l.clientWidth,n=l.clientHeight,r=0,a=0;if(o){s=o.width,n=o.height;const p=me();(!p||p&&e==="fixed")&&(r=o.offsetLeft,a=o.offsetTop)}const c=ne(l);if(c<=0){const p=l.ownerDocument,d=p.body,m=getComputedStyle(d),u=p.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(l.clientWidth-d.clientWidth-u);g<=ze&&(s-=g)}else c<=ze&&(s+=c);return{width:s,height:n,x:r,y:a}}const At=new Set(["absolute","fixed"]);function St(i,e){const t=N(i,!0,e==="fixed"),l=t.top+i.clientTop,o=t.left+i.clientLeft,s=V(i)?W(i):I(1),n=i.clientWidth*s.x,r=i.clientHeight*s.y,a=o*s.x,c=l*s.y;return{width:n,height:r,x:a,y:c}}function Re(i,e,t){let l;if(e==="viewport")l=Pt(i,t);else if(e==="document")l=kt(E(i));else if(O(e))l=St(e,t);else{const o=$e(i);l={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ie(l)}function Ne(i,e){const t=$(i);return t===e||!O(t)||j(t)?!1:T(t).position==="fixed"||Ne(t,e)}function Ot(i,e){const t=e.get(i);if(t)return t;let l=Y(i,[],!1).filter(r=>O(r)&&H(r)!=="body"),o=null;const s=T(i).position==="fixed";let n=s?$(i):i;for(;O(n)&&!j(n);){const r=T(n),a=ue(n);!a&&r.position==="fixed"&&(o=null),(s?!a&&!o:!a&&r.position==="static"&&!!o&&At.has(o.position)||U(n)&&!a&&Ne(i,n))?l=l.filter(p=>p!==n):o=r,n=$(n)}return e.set(i,l),l}function Tt(i){let{element:e,boundary:t,rootBoundary:l,strategy:o}=i;const n=[...t==="clippingAncestors"?oe(e)?[]:Ot(e,this._c):[].concat(t),l],r=n[0],a=n.reduce((c,p)=>{const d=Re(e,p,o);return c.top=S(d.top,c.top),c.right=C(d.right,c.right),c.bottom=C(d.bottom,c.bottom),c.left=S(d.left,c.left),c},Re(e,r,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Mt(i){const{width:e,height:t}=De(i);return{width:e,height:t}}function It(i,e,t){const l=V(e),o=E(e),s=t==="fixed",n=N(i,!0,s,e);let r={scrollLeft:0,scrollTop:0};const a=I(0);function c(){a.x=ne(o)}if(l||!l&&!s)if((H(e)!=="body"||U(o))&&(r=se(e)),l){const u=N(e,!0,s,e);a.x=u.x+e.clientLeft,a.y=u.y+e.clientTop}else o&&c();s&&!l&&o&&c();const p=o&&!l&&!s?Le(o,r):I(0),d=n.left+r.scrollLeft-a.x-p.x,m=n.top+r.scrollTop-a.y-p.y;return{x:d,y:m,width:n.width,height:n.height}}function be(i){return T(i).position==="static"}function Fe(i,e){if(!V(i)||T(i).position==="fixed")return null;if(e)return e(i);let t=i.offsetParent;return E(i)===t&&(t=t.ownerDocument.body),t}function Be(i,e){const t=A(i);if(oe(i))return t;if(!V(i)){let o=$(i);for(;o&&!j(o);){if(O(o)&&!be(o))return o;o=$(o)}return t}let l=Fe(i,e);for(;l&&ut(l)&&be(l);)l=Fe(l,e);return l&&j(l)&&be(l)&&!ue(l)?t:l||vt(i)||t}const Et=async function(i){const e=this.getOffsetParent||Be,t=this.getDimensions,l=await t(i.floating);return{reference:It(i.reference,await e(i.floating),i.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function Vt(i){return T(i).direction==="rtl"}const Dt={convertOffsetParentRelativeRectToViewportRelativeRect:xt,getDocumentElement:E,getClippingRect:Tt,getOffsetParent:Be,getElementRects:Et,getClientRects:Ct,getDimensions:Mt,getScale:W,isElement:O,isRTL:Vt};function He(i,e){return i.x===e.x&&i.y===e.y&&i.width===e.width&&i.height===e.height}function $t(i,e){let t=null,l;const o=E(i);function s(){var r;clearTimeout(l),(r=t)==null||r.disconnect(),t=null}function n(r,a){r===void 0&&(r=!1),a===void 0&&(a=1),s();const c=i.getBoundingClientRect(),{left:p,top:d,width:m,height:u}=c;if(r||e(),!m||!u)return;const g=Z(d),v=Z(o.clientWidth-(p+m)),w=Z(o.clientHeight-(d+u)),b=Z(p),y={rootMargin:-g+"px "+-v+"px "+-w+"px "+-b+"px",threshold:S(0,C(1,a))||1};let k=!0;function x(X){const G=X[0].intersectionRatio;if(G!==a){if(!k)return n();G?n(!1,G):l=setTimeout(()=>{n(!1,1e-7)},1e3)}G===1&&!He(c,i.getBoundingClientRect())&&n(),k=!1}try{t=new IntersectionObserver(x,{...y,root:o.ownerDocument})}catch{t=new IntersectionObserver(x,y)}t.observe(i)}return n(!0),s}function re(i,e,t,l){l===void 0&&(l={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:a=!1}=l,c=ge(i),p=o||s?[...c?Y(c):[],...Y(e)]:[];p.forEach(b=>{o&&b.addEventListener("scroll",t,{passive:!0}),s&&b.addEventListener("resize",t)});const d=c&&r?$t(c,t):null;let m=-1,u=null;n&&(u=new ResizeObserver(b=>{let[_]=b;_&&_.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=u)==null||y.observe(e)})),t()}),c&&!a&&u.observe(c),u.observe(e));let g,v=a?N(i):null;a&&w();function w(){const b=N(i);v&&!He(v,b)&&t(),v=b,g=requestAnimationFrame(w)}return t(),()=>{var b;p.forEach(_=>{o&&_.removeEventListener("scroll",t),s&&_.removeEventListener("resize",t)}),d==null||d(),(b=u)==null||b.disconnect(),u=null,a&&cancelAnimationFrame(g)}}const ae=ct,ce=dt,ve=nt,de=(i,e,t)=>{const l=new Map,o={platform:Dt,...t},s={...o.platform,_c:l};return st(i,e,{...o,platform:s})};let L=0;const f={debug:(i,...e)=>{L++,console.log(`%c[MultiSelect ${L}]%c ${i}`,"color: #0ea5e9; font-weight: bold;","color: inherit;",...e)},info:(i,...e)=>{L++,console.info(`%c[MultiSelect ${L}]%c ${i}`,"color: #10b981; font-weight: bold;","color: inherit;",...e)},warn:(i,...e)=>{L++,console.warn(`%c[MultiSelect ${L}]%c ${i}`,"color: #f59e0b; font-weight: bold;","color: inherit;",...e)},error:(i,...e)=>{L++,console.error(`%c[MultiSelect ${L}]%c ${i}`,"color: #ef4444; font-weight: bold;","color: inherit;",...e)}};class je{constructor(e,t={}){h(this,"element");h(this,"instanceId");h(this,"options");h(this,"isOpen",!1);h(this,"selectedValues",new Set);h(this,"selectedOptions",new Map);h(this,"allOptions",[]);h(this,"filteredOptions",[]);h(this,"hiddenInputs",[]);h(this,"focusedIndex",-1);h(this,"searchTerm","");h(this,"isLoading",!1);h(this,"showSelectedPopover",!1);h(this,"selectedPopoverPlacement",null);h(this,"dropdownPlacement",null);h(this,"isRTL",!1);h(this,"effectivePillsPosition","bottom");h(this,"justClosedViaClick",!1);h(this,"dropdownCleanup",null);h(this,"hintCleanup",null);h(this,"selectedPopoverCleanup",null);h(this,"pillTooltips",new Map);h(this,"pillTooltipCleanups",new Map);h(this,"input");h(this,"dropdown");h(this,"pillsContainer");h(this,"countBadge");h(this,"hint");h(this,"selectedPopover");this.element=e,this.instanceId=`MS-${Math.random().toString(36).substr(2,9)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",dropdownMinWidth:e.dataset.dropdownMinWidth||void 0,pillsDisplayMode:e.dataset.pillsDisplayMode||"pills",pillsPosition:e.dataset.pillsPosition||"bottom",pillsThresholdMode:e.dataset.pillsThresholdMode||"count",maxHeight:e.dataset.maxHeight||"20rem",emptyMessage:e.dataset.emptyMessage||"No results found",loadingMessage:e.dataset.loadingMessage||"Loading...",searchInputMode:e.dataset.searchInputMode||"normal",pillsThreshold:e.dataset.pillsThreshold?parseInt(e.dataset.pillsThreshold):void 0,minSearchLength:parseInt(e.dataset.minSearchLength||"0")||0,isMultipleEnabled:e.dataset.multiple!=="false",isGroupsAllowed:e.dataset.allowGroups!=="false",isSelectAllAllowed:e.dataset.allowSelectAll!=="false",isClearAllAllowed:e.dataset.allowClearAll!=="false",isCheckboxesShown:e.dataset.showCheckboxes!=="false",isActionsSticky:e.dataset.stickyActions!=="false",isCloseOnSelect:e.dataset.closeOnSelect==="true",isPlacementLocked:e.dataset.lockPlacement!=="false",isSearchEnabled:e.dataset.enableSearch!=="false",isAddNewAllowed:e.dataset.allowAddNew==="true",isCountBadgeShown:e.dataset.showCountBadge==="true",options:[],container:void 0,...t},this.init()}getItemValue(e){return Array.isArray(e)&&e.length===2?e[0]:this.options.valueMember&&e[this.options.valueMember]!==void 0?e[this.options.valueMember]:this.options.getValueCallback?this.options.getValueCallback(e):"[N/A]"}getItemDisplayValue(e){return Array.isArray(e)&&e.length===2?String(e[1]):this.options.displayValueMember&&e[this.options.displayValueMember]!==void 0?String(e[this.options.displayValueMember]):this.options.getDisplayValueCallback?this.options.getDisplayValueCallback(e):"[N/A]"}getItemPillDisplayValue(e){return this.options.getPillDisplayCallback?this.options.getPillDisplayCallback(e):this.getItemDisplayValue(e)}getItemSearchValue(e){return this.options.searchValueMember&&e[this.options.searchValueMember]!==void 0?String(e[this.options.searchValueMember]):this.options.getSearchValueCallback?this.options.getSearchValueCallback(e):this.getItemDisplayValue(e)}getItemIcon(e){if(!Array.isArray(e)){if(this.options.iconMember&&e[this.options.iconMember]!==void 0)return String(e[this.options.iconMember]);if(this.options.getIconCallback)return this.options.getIconCallback(e)}}getItemSubtitle(e){if(!Array.isArray(e)){if(this.options.subtitleMember&&e[this.options.subtitleMember]!==void 0)return String(e[this.options.subtitleMember]);if(this.options.getSubtitleCallback)return this.options.getSubtitleCallback(e)}}getItemGroup(e){if(!Array.isArray(e)){if(this.options.groupMember&&e[this.options.groupMember]!==void 0)return String(e[this.options.groupMember]);if(this.options.getGroupCallback)return this.options.getGroupCallback(e)}}getItemDisabled(e){return Array.isArray(e)?!1:this.options.disabledMember&&e[this.options.disabledMember]!==void 0?!!e[this.options.disabledMember]:this.options.getDisabledCallback?this.options.getDisabledCallback(e):!1}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),f.debug(`Initialized [${this.instanceId}] with options:`,{placeholder:this.options.searchPlaceholder,totalOptions:this.allOptions.length,isCloseOnSelect:this.options.isCloseOnSelect,dataAttribute:this.element.dataset.closeOnSelect,isSelectAllAllowed:this.options.isSelectAllAllowed,isClearAllAllowed:this.options.isClearAllAllowed})}parseOptions(){const e=this.element.dataset.options;if(e)try{this.allOptions=JSON.parse(e)}catch(t){console.error("[MultiSelect] Failed to parse data-options:",t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions]}buildHTML(){const e=this.options.container||document.body,t=this.element.getRootNode(),l=t instanceof ShadowRoot?t.host:this.element,o=l.getAttribute("dir")==="rtl",s=l.closest('[dir="rtl"]')!==null;this.isRTL=o||s,console.log("[MultiSelect RTL Debug]",{isShadowRoot:t instanceof ShadowRoot,hostElement:l,elementDir:l.getAttribute("dir"),hasElementDir:o,hasAncestorDir:s,isRTL:this.isRTL}),this.effectivePillsPosition=this.options.pillsPosition||"bottom",this.isRTL&&(this.effectivePillsPosition==="left"?this.effectivePillsPosition="right":this.effectivePillsPosition==="right"&&(this.effectivePillsPosition="left")),this.element.classList.add("ml"),this.isRTL&&(this.element.classList.add("ml--rtl"),console.log("[MultiSelect RTL] Added ml--rtl class to element")),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ml--no-checkboxes");const n=document.createElement("div");n.className="ml__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ml__input",this.input.placeholder=this.options.searchPlaceholder,this.input.autocomplete="off",this.options.searchInputMode==="readonly"?this.input.readOnly=!0:this.options.searchInputMode==="hidden"&&(this.input.style.display="none");const r=document.createElement("span");r.className="ml__toggle",r.innerHTML="▼",this.countBadge=document.createElement("span"),this.countBadge.className="ml__count-badge",this.countBadge.style.display="none",n.appendChild(this.input),n.appendChild(this.countBadge),n.appendChild(r),this.pillsContainer=document.createElement("div"),this.pillsContainer.className="ml__pills";const a=document.createElement("div");a.className="ml-wrapper",(this.effectivePillsPosition==="left"||this.effectivePillsPosition==="right")&&a.classList.add("ml-wrapper--inline"),a.appendChild(n),a.appendChild(this.pillsContainer),this.element.appendChild(a),this.dropdown=document.createElement("div"),this.dropdown.className="ml__dropdown",e.appendChild(this.dropdown),this.options.searchHint&&(this.hint=document.createElement("div"),this.hint.className="ml__hint",this.hint.textContent=this.options.searchHint,e.appendChild(this.hint)),this.selectedPopover=document.createElement("div"),this.selectedPopover.className="ml__selected-popover",e.appendChild(this.selectedPopover),this.renderDropdown()}renderDropdown(){let e="";if(this.isLoading){e+='<div class="ml__loader">',e+='<div class="pa-loader pa-loader--sm"></div>',e+=`<div class="ml__loading-text">${this.options.loadingMessage}</div>`,e+="</div>",this.dropdown.innerHTML=e;return}if(this.options.isMultipleEnabled&&(this.options.isSelectAllAllowed||this.options.isClearAllAllowed)){const t=this.options.isActionsSticky?" ml__actions--sticky":"";e+=`<div class="ml__actions${t}">`,this.options.isSelectAllAllowed&&(e+='<button type="button" class="ml__action-btn" data-action="select-all">Select All</button>'),this.options.isClearAllAllowed&&(e+='<button type="button" class="ml__action-btn" data-action="clear-all">Clear All</button>'),e+="</div>"}if(e+='<div class="ml__options">',this.filteredOptions.length===0)e+=`<div class="ml__empty">${this.options.emptyMessage}</div>`;else if(this.options.isGroupsAllowed){const t=this.groupOptions(this.filteredOptions);Object.keys(t).forEach(l=>{e+='<div class="ml__group">',l!=="__ungrouped__"&&(e+=`<div class="ml__group-label">${l}</div>`),t[l].forEach((o,s)=>{e+=this.renderOption(o,s)}),e+="</div>"})}else this.filteredOptions.forEach((t,l)=>{e+=this.renderOption(t,l)});e+="</div>",this.dropdown.innerHTML=e}renderOption(e,t){const l=this.getItemValue(e),o=this.getItemDisplayValue(e),s=this.getItemIcon(e),n=this.getItemSubtitle(e),r=this.getItemDisabled(e),a=this.selectedValues.has(String(l)),c=t===this.focusedIndex,p=["ml__option"];a&&p.push("ml__option--selected"),c&&p.push("ml__option--focused"),r&&p.push("ml__option--disabled");let d=`<div class="${p.join(" ")}" data-value="${l}" data-index="${t}">`;return this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(d+=`<input type="checkbox" class="ml__checkbox" ${a?"checked":""} ${r?"disabled":""}>`),d+='<div class="ml__option-content">',s&&(d+=`<span class="ml__option-icon">${s}</span>`),d+='<div class="ml__option-text">',d+=`<div class="ml__option-title">${this.highlightMatch(o,this.searchTerm)}</div>`,n&&(d+=`<div class="ml__option-subtitle">${n}</div>`),d+="</div>",d+="</div>",d+="</div>",d}highlightMatch(e,t){if(!t)return e;const l=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(l,"<mark>$1</mark>")}groupOptions(e){const t={};return e.forEach(l=>{const o=this.getItemGroup(l)||"__ungrouped__";t[o]||(t[o]=[]),t[o].push(l)}),t}renderPills(){this.destroyAllPillTooltips();const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(!this.options.isMultipleEnabled){this.pillsContainer.innerHTML="",this.countBadge.style.display="none";const s=e[0]?this.getItemDisplayValue(e[0]):void 0;f.warn(`[${this.instanceId}] renderPills() single-select mode`,{isOpen:this.isOpen,count:t,selectedOptionsLength:e.length,willSetValue:!this.isOpen&&t>0&&e.length>0,selectedLabel:s}),!this.isOpen&&t>0&&e.length>0?(f.info(`[${this.instanceId}] ✅ SETTING input.value = "${s}"`),this.input.value=s,f.info(`[${this.instanceId}] 🔍 VERIFY input.value = "${this.input.value}"`)):this.isOpen?f.info(`[${this.instanceId}] ⏭️ SKIPPING input update (dropdown is open)`):(f.info(`[${this.instanceId}] ❌ CLEARING input.value (no selection)`),this.input.value="");return}let l=this.options.pillsDisplayMode;if(this.options.pillsThreshold!==null&&t>this.options.pillsThreshold&&(l=this.options.pillsThresholdMode||"count"),!this.isOpen)if(t>0&&l==="count"){const s=this.options.getCountPillCallback?this.options.getCountPillCallback(t):`${t} selected`;this.input.placeholder=s}else this.input.placeholder=this.options.searchPlaceholder;if(this.options.isCountBadgeShown&&t>0?(this.countBadge.textContent=`[${t}]`,this.countBadge.style.display=""):this.countBadge.style.display="none",l==="pills")this.pillsContainer.className=`ml__pills ml__pills--${this.effectivePillsPosition}`,this.pillsContainer.innerHTML=e.map(s=>{const n=this.getItemValue(s),r=this.getItemPillDisplayValue(s);return`
1
+ (function(C,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(C=typeof globalThis<"u"?globalThis:C||self,I(C.MultiSelect={}))})(this,function(C){"use strict";var fi=Object.defineProperty;var gi=(C,I,T)=>I in C?fi(C,I,{enumerable:!0,configurable:!0,writable:!0,value:T}):C[I]=T;var u=(C,I,T)=>gi(C,typeof I!="symbol"?I+"":I,T);const I=Math.min,T=Math.max,oe=Math.round,se=Math.floor,$=i=>({x:i,y:i}),ct={left:"right",right:"left",bottom:"top",top:"bottom"},dt={start:"end",end:"start"};function Ve(i,e,t){return T(i,I(e,t))}function ne(i,e){return typeof i=="function"?i(e):i}function B(i){return i.split("-")[0]}function re(i){return i.split("-")[1]}function $e(i){return i==="x"?"y":"x"}function ze(i){return i==="y"?"height":"width"}const pt=new Set(["top","bottom"]);function R(i){return pt.has(B(i))?"y":"x"}function De(i){return $e(R(i))}function ht(i,e,t){t===void 0&&(t=!1);const l=re(i),o=De(i),s=ze(o);let n=o==="x"?l===(t?"end":"start")?"right":"left":l==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(n=ae(n)),[n,ae(n)]}function mt(i){const e=ae(i);return[ye(i),e,ye(e)]}function ye(i){return i.replace(/start|end/g,e=>dt[e])}const Re=["left","right"],Fe=["right","left"],ut=["top","bottom"],ft=["bottom","top"];function gt(i,e,t){switch(i){case"top":case"bottom":return t?e?Fe:Re:e?Re:Fe;case"left":case"right":return e?ut:ft;default:return[]}}function bt(i,e,t,l){const o=re(i);let s=gt(B(i),t==="start",l);return o&&(s=s.map(n=>n+"-"+o),e&&(s=s.concat(s.map(ye)))),s}function ae(i){return i.replace(/left|right|bottom|top/g,e=>ct[e])}function vt(i){return{top:0,right:0,bottom:0,left:0,...i}}function wt(i){return typeof i!="number"?vt(i):{top:i,right:i,bottom:i,left:i}}function ce(i){const{x:e,y:t,width:l,height:o}=i;return{width:l,height:o,top:t,left:e,right:e+l,bottom:t+o,x:e,y:t}}function Ne(i,e,t){let{reference:l,floating:o}=i;const s=R(e),n=De(e),r=ze(n),a=B(e),d=s==="y",c=l.x+l.width/2-o.width/2,m=l.y+l.height/2-o.height/2,p=l[r]/2-o[r]/2;let h;switch(a){case"top":h={x:c,y:l.y-o.height};break;case"bottom":h={x:c,y:l.y+l.height};break;case"right":h={x:l.x+l.width,y:m};break;case"left":h={x:l.x-o.width,y:m};break;default:h={x:l.x,y:l.y}}switch(re(e)){case"start":h[n]-=p*(t&&d?-1:1);break;case"end":h[n]+=p*(t&&d?-1:1);break}return h}const yt=async(i,e,t)=>{const{placement:l="bottom",strategy:o="absolute",middleware:s=[],platform:n}=t,r=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(e));let d=await n.getElementRects({reference:i,floating:e,strategy:o}),{x:c,y:m}=Ne(d,l,a),p=l,h={},f=0;for(let w=0;w<r.length;w++){const{name:b,fn:v}=r[w],{x:y,y:x,data:O,reset:A}=await v({x:c,y:m,initialPlacement:l,placement:p,strategy:o,middlewareData:h,rects:d,platform:n,elements:{reference:i,floating:e}});c=y??c,m=x??m,h={...h,[b]:{...h[b],...O}},A&&f<=50&&(f++,typeof A=="object"&&(A.placement&&(p=A.placement),A.rects&&(d=A.rects===!0?await n.getElementRects({reference:i,floating:e,strategy:o}):A.rects),{x:c,y:m}=Ne(d,p,a)),w=-1)}return{x:c,y:m,placement:p,strategy:o,middlewareData:h}};async function He(i,e){var t;e===void 0&&(e={});const{x:l,y:o,platform:s,rects:n,elements:r,strategy:a}=i,{boundary:d="clippingAncestors",rootBoundary:c="viewport",elementContext:m="floating",altBoundary:p=!1,padding:h=0}=ne(e,i),f=wt(h),b=r[p?m==="floating"?"reference":"floating":m],v=ce(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(b)))==null||t?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(r.floating)),boundary:d,rootBoundary:c,strategy:a})),y=m==="floating"?{x:l,y:o,width:n.floating.width,height:n.floating.height}:n.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(r.floating)),O=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},A=ce(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:r,rect:y,offsetParent:x,strategy:a}):y);return{top:(v.top-A.top+f.top)/O.y,bottom:(A.bottom-v.bottom+f.bottom)/O.y,left:(v.left-A.left+f.left)/O.x,right:(A.right-v.right+f.right)/O.x}}const _t=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(e){var t,l;const{placement:o,middlewareData:s,rects:n,initialPlacement:r,platform:a,elements:d}=e,{mainAxis:c=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:w=!0,...b}=ne(i,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const v=B(o),y=R(r),x=B(r)===r,O=await(a.isRTL==null?void 0:a.isRTL(d.floating)),A=p||(x||!w?[ae(r)]:mt(r)),ie=f!=="none";!p&&ie&&A.push(...bt(r,w,f,O));const X=[r,...A],Me=await He(e,b),we=[];let q=((l=s.flip)==null?void 0:l.overflows)||[];if(c&&we.push(Me[v]),m){const G=ht(o,n,O);we.push(Me[G[0]],Me[G[1]])}if(q=[...q,{placement:o,overflows:we}],!we.every(G=>G<=0)){var nt,rt;const G=(((nt=s.flip)==null?void 0:nt.index)||0)+1,Ee=X[G];if(Ee&&(!(m==="alignment"?y!==R(Ee):!1)||q.every(V=>R(V.placement)===y?V.overflows[0]>0:!0)))return{data:{index:G,overflows:q},reset:{placement:Ee}};let le=(rt=q.filter(U=>U.overflows[0]<=0).sort((U,V)=>U.overflows[1]-V.overflows[1])[0])==null?void 0:rt.placement;if(!le)switch(h){case"bestFit":{var at;const U=(at=q.filter(V=>{if(ie){const H=R(V.placement);return H===y||H==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(H=>H>0).reduce((H,ui)=>H+ui,0)]).sort((V,H)=>V[1]-H[1])[0])==null?void 0:at[0];U&&(le=U);break}case"initialPlacement":le=r;break}if(o!==le)return{reset:{placement:le}}}return{}}}},xt=new Set(["left","top"]);async function Ct(i,e){const{placement:t,platform:l,elements:o}=i,s=await(l.isRTL==null?void 0:l.isRTL(o.floating)),n=B(t),r=re(t),a=R(t)==="y",d=xt.has(n)?-1:1,c=s&&a?-1:1,m=ne(e,i);let{mainAxis:p,crossAxis:h,alignmentAxis:f}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return r&&typeof f=="number"&&(h=r==="end"?f*-1:f),a?{x:h*c,y:p*d}:{x:p*d,y:h*c}}const kt=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(e){var t,l;const{x:o,y:s,placement:n,middlewareData:r}=e,a=await Ct(e,i);return n===((t=r.offset)==null?void 0:t.placement)&&(l=r.arrow)!=null&&l.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:n}}}}},St=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(e){const{x:t,y:l,placement:o}=e,{mainAxis:s=!0,crossAxis:n=!1,limiter:r={fn:b=>{let{x:v,y}=b;return{x:v,y}}},...a}=ne(i,e),d={x:t,y:l},c=await He(e,a),m=R(B(o)),p=$e(m);let h=d[p],f=d[m];if(s){const b=p==="y"?"top":"left",v=p==="y"?"bottom":"right",y=h+c[b],x=h-c[v];h=Ve(y,h,x)}if(n){const b=m==="y"?"top":"left",v=m==="y"?"bottom":"right",y=f+c[b],x=f-c[v];f=Ve(y,f,x)}const w=r.fn({...e,[p]:h,[m]:f});return{...w,data:{x:w.x-t,y:w.y-l,enabled:{[p]:s,[m]:n}}}}}};function de(){return typeof window<"u"}function K(i){return Be(i)?(i.nodeName||"").toLowerCase():"#document"}function P(i){var e;return(i==null||(e=i.ownerDocument)==null?void 0:e.defaultView)||window}function z(i){var e;return(e=(Be(i)?i.ownerDocument:i.document)||window.document)==null?void 0:e.documentElement}function Be(i){return de()?i instanceof Node||i instanceof P(i).Node:!1}function L(i){return de()?i instanceof Element||i instanceof P(i).Element:!1}function D(i){return de()?i instanceof HTMLElement||i instanceof P(i).HTMLElement:!1}function We(i){return!de()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof P(i).ShadowRoot}const At=new Set(["inline","contents"]);function Z(i){const{overflow:e,overflowX:t,overflowY:l,display:o}=M(i);return/auto|scroll|overlay|hidden|clip/.test(e+l+t)&&!At.has(o)}const Ot=new Set(["table","td","th"]);function It(i){return Ot.has(K(i))}const Pt=[":popover-open",":modal"];function pe(i){return Pt.some(e=>{try{return i.matches(e)}catch{return!1}})}const Tt=["transform","translate","scale","rotate","perspective"],Lt=["transform","translate","scale","rotate","perspective","filter"],Mt=["paint","layout","strict","content"];function _e(i){const e=xe(),t=L(i)?M(i):i;return Tt.some(l=>t[l]?t[l]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||Lt.some(l=>(t.willChange||"").includes(l))||Mt.some(l=>(t.contain||"").includes(l))}function Et(i){let e=F(i);for(;D(e)&&!Y(e);){if(_e(e))return e;if(pe(e))return null;e=F(e)}return null}function xe(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Vt=new Set(["html","body","#document"]);function Y(i){return Vt.has(K(i))}function M(i){return P(i).getComputedStyle(i)}function he(i){return L(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function F(i){if(K(i)==="html")return i;const e=i.assignedSlot||i.parentNode||We(i)&&i.host||z(i);return We(e)?e.host:e}function je(i){const e=F(i);return Y(e)?i.ownerDocument?i.ownerDocument.body:i.body:D(e)&&Z(e)?e:je(e)}function Q(i,e,t){var l;e===void 0&&(e=[]),t===void 0&&(t=!0);const o=je(i),s=o===((l=i.ownerDocument)==null?void 0:l.body),n=P(o);if(s){const r=Ce(n);return e.concat(n,n.visualViewport||[],Z(o)?o:[],r&&t?Q(r):[])}return e.concat(o,Q(o,[],t))}function Ce(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function Ge(i){const e=M(i);let t=parseFloat(e.width)||0,l=parseFloat(e.height)||0;const o=D(i),s=o?i.offsetWidth:t,n=o?i.offsetHeight:l,r=oe(t)!==s||oe(l)!==n;return r&&(t=s,l=n),{width:t,height:l,$:r}}function ke(i){return L(i)?i:i.contextElement}function J(i){const e=ke(i);if(!D(e))return $(1);const t=e.getBoundingClientRect(),{width:l,height:o,$:s}=Ge(e);let n=(s?oe(t.width):t.width)/l,r=(s?oe(t.height):t.height)/o;return(!n||!Number.isFinite(n))&&(n=1),(!r||!Number.isFinite(r))&&(r=1),{x:n,y:r}}const $t=$(0);function Ue(i){const e=P(i);return!xe()||!e.visualViewport?$t:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function zt(i,e,t){return e===void 0&&(e=!1),!t||e&&t!==P(i)?!1:e}function W(i,e,t,l){e===void 0&&(e=!1),t===void 0&&(t=!1);const o=i.getBoundingClientRect(),s=ke(i);let n=$(1);e&&(l?L(l)&&(n=J(l)):n=J(i));const r=zt(s,t,l)?Ue(s):$(0);let a=(o.left+r.x)/n.x,d=(o.top+r.y)/n.y,c=o.width/n.x,m=o.height/n.y;if(s){const p=P(s),h=l&&L(l)?P(l):l;let f=p,w=Ce(f);for(;w&&l&&h!==f;){const b=J(w),v=w.getBoundingClientRect(),y=M(w),x=v.left+(w.clientLeft+parseFloat(y.paddingLeft))*b.x,O=v.top+(w.clientTop+parseFloat(y.paddingTop))*b.y;a*=b.x,d*=b.y,c*=b.x,m*=b.y,a+=x,d+=O,f=P(w),w=Ce(f)}}return ce({width:c,height:m,x:a,y:d})}function me(i,e){const t=he(i).scrollLeft;return e?e.left+t:W(z(i)).left+t}function Ke(i,e){const t=i.getBoundingClientRect(),l=t.left+e.scrollLeft-me(i,t),o=t.top+e.scrollTop;return{x:l,y:o}}function Dt(i){let{elements:e,rect:t,offsetParent:l,strategy:o}=i;const s=o==="fixed",n=z(l),r=e?pe(e.floating):!1;if(l===n||r&&s)return t;let a={scrollLeft:0,scrollTop:0},d=$(1);const c=$(0),m=D(l);if((m||!m&&!s)&&((K(l)!=="body"||Z(n))&&(a=he(l)),D(l))){const h=W(l);d=J(l),c.x=h.x+l.clientLeft,c.y=h.y+l.clientTop}const p=n&&!m&&!s?Ke(n,a):$(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-a.scrollLeft*d.x+c.x+p.x,y:t.y*d.y-a.scrollTop*d.y+c.y+p.y}}function Rt(i){return Array.from(i.getClientRects())}function Ft(i){const e=z(i),t=he(i),l=i.ownerDocument.body,o=T(e.scrollWidth,e.clientWidth,l.scrollWidth,l.clientWidth),s=T(e.scrollHeight,e.clientHeight,l.scrollHeight,l.clientHeight);let n=-t.scrollLeft+me(i);const r=-t.scrollTop;return M(l).direction==="rtl"&&(n+=T(e.clientWidth,l.clientWidth)-o),{width:o,height:s,x:n,y:r}}const Ye=25;function Nt(i,e){const t=P(i),l=z(i),o=t.visualViewport;let s=l.clientWidth,n=l.clientHeight,r=0,a=0;if(o){s=o.width,n=o.height;const c=xe();(!c||c&&e==="fixed")&&(r=o.offsetLeft,a=o.offsetTop)}const d=me(l);if(d<=0){const c=l.ownerDocument,m=c.body,p=getComputedStyle(m),h=c.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,f=Math.abs(l.clientWidth-m.clientWidth-h);f<=Ye&&(s-=f)}else d<=Ye&&(s+=d);return{width:s,height:n,x:r,y:a}}const Ht=new Set(["absolute","fixed"]);function Bt(i,e){const t=W(i,!0,e==="fixed"),l=t.top+i.clientTop,o=t.left+i.clientLeft,s=D(i)?J(i):$(1),n=i.clientWidth*s.x,r=i.clientHeight*s.y,a=o*s.x,d=l*s.y;return{width:n,height:r,x:a,y:d}}function Je(i,e,t){let l;if(e==="viewport")l=Nt(i,t);else if(e==="document")l=Ft(z(i));else if(L(e))l=Bt(e,t);else{const o=Ue(i);l={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ce(l)}function Xe(i,e){const t=F(i);return t===e||!L(t)||Y(t)?!1:M(t).position==="fixed"||Xe(t,e)}function Wt(i,e){const t=e.get(i);if(t)return t;let l=Q(i,[],!1).filter(r=>L(r)&&K(r)!=="body"),o=null;const s=M(i).position==="fixed";let n=s?F(i):i;for(;L(n)&&!Y(n);){const r=M(n),a=_e(n);!a&&r.position==="fixed"&&(o=null),(s?!a&&!o:!a&&r.position==="static"&&!!o&&Ht.has(o.position)||Z(n)&&!a&&Xe(i,n))?l=l.filter(c=>c!==n):o=r,n=F(n)}return e.set(i,l),l}function jt(i){let{element:e,boundary:t,rootBoundary:l,strategy:o}=i;const n=[...t==="clippingAncestors"?pe(e)?[]:Wt(e,this._c):[].concat(t),l],r=n[0],a=n.reduce((d,c)=>{const m=Je(e,c,o);return d.top=T(m.top,d.top),d.right=I(m.right,d.right),d.bottom=I(m.bottom,d.bottom),d.left=T(m.left,d.left),d},Je(e,r,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Gt(i){const{width:e,height:t}=Ge(i);return{width:e,height:t}}function Ut(i,e,t){const l=D(e),o=z(e),s=t==="fixed",n=W(i,!0,s,e);let r={scrollLeft:0,scrollTop:0};const a=$(0);function d(){a.x=me(o)}if(l||!l&&!s)if((K(e)!=="body"||Z(o))&&(r=he(e)),l){const h=W(e,!0,s,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else o&&d();s&&!l&&o&&d();const c=o&&!l&&!s?Ke(o,r):$(0),m=n.left+r.scrollLeft-a.x-c.x,p=n.top+r.scrollTop-a.y-c.y;return{x:m,y:p,width:n.width,height:n.height}}function Se(i){return M(i).position==="static"}function qe(i,e){if(!D(i)||M(i).position==="fixed")return null;if(e)return e(i);let t=i.offsetParent;return z(i)===t&&(t=t.ownerDocument.body),t}function Ze(i,e){const t=P(i);if(pe(i))return t;if(!D(i)){let o=F(i);for(;o&&!Y(o);){if(L(o)&&!Se(o))return o;o=F(o)}return t}let l=qe(i,e);for(;l&&It(l)&&Se(l);)l=qe(l,e);return l&&Y(l)&&Se(l)&&!_e(l)?t:l||Et(i)||t}const Kt=async function(i){const e=this.getOffsetParent||Ze,t=this.getDimensions,l=await t(i.floating);return{reference:Ut(i.reference,await e(i.floating),i.strategy),floating:{x:0,y:0,width:l.width,height:l.height}}};function Yt(i){return M(i).direction==="rtl"}const Jt={convertOffsetParentRelativeRectToViewportRelativeRect:Dt,getDocumentElement:z,getClippingRect:jt,getOffsetParent:Ze,getElementRects:Kt,getClientRects:Rt,getDimensions:Gt,getScale:J,isElement:L,isRTL:Yt};function Qe(i,e){return i.x===e.x&&i.y===e.y&&i.width===e.width&&i.height===e.height}function Xt(i,e){let t=null,l;const o=z(i);function s(){var r;clearTimeout(l),(r=t)==null||r.disconnect(),t=null}function n(r,a){r===void 0&&(r=!1),a===void 0&&(a=1),s();const d=i.getBoundingClientRect(),{left:c,top:m,width:p,height:h}=d;if(r||e(),!p||!h)return;const f=se(m),w=se(o.clientWidth-(c+p)),b=se(o.clientHeight-(m+h)),v=se(c),x={rootMargin:-f+"px "+-w+"px "+-b+"px "+-v+"px",threshold:T(0,I(1,a))||1};let O=!0;function A(ie){const X=ie[0].intersectionRatio;if(X!==a){if(!O)return n();X?n(!1,X):l=setTimeout(()=>{n(!1,1e-7)},1e3)}X===1&&!Qe(d,i.getBoundingClientRect())&&n(),O=!1}try{t=new IntersectionObserver(A,{...x,root:o.ownerDocument})}catch{t=new IntersectionObserver(A,x)}t.observe(i)}return n(!0),s}function ue(i,e,t,l){l===void 0&&(l={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:r=typeof IntersectionObserver=="function",animationFrame:a=!1}=l,d=ke(i),c=o||s?[...d?Q(d):[],...Q(e)]:[];c.forEach(v=>{o&&v.addEventListener("scroll",t,{passive:!0}),s&&v.addEventListener("resize",t)});const m=d&&r?Xt(d,t):null;let p=-1,h=null;n&&(h=new ResizeObserver(v=>{let[y]=v;y&&y.target===d&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),t()}),d&&!a&&h.observe(d),h.observe(e));let f,w=a?W(i):null;a&&b();function b(){const v=W(i);w&&!Qe(w,v)&&t(),w=v,f=requestAnimationFrame(b)}return t(),()=>{var v;c.forEach(y=>{o&&y.removeEventListener("scroll",t),s&&y.removeEventListener("resize",t)}),m==null||m(),(v=h)==null||v.disconnect(),h=null,a&&cancelAnimationFrame(f)}}const fe=kt,ge=St,Ae=_t,be=(i,e,t)=>{const l=new Map,o={platform:Jt,...t},s={...o.platform,_c:l};return yt(i,e,{...o,platform:s})};var et=function(){},E="undefined",qt=typeof window!==E&&typeof window.navigator!==E&&/Trident\/|MSIE /.test(window.navigator.userAgent),Oe=["trace","debug","info","warn","error"],ee={},_=null;function tt(i,e){var t=i[e];if(typeof t.bind=="function")return t.bind(i);try{return Function.prototype.bind.call(t,i)}catch{return function(){return Function.prototype.apply.apply(t,[i,arguments])}}}function Zt(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function Qt(i){return i==="debug"&&(i="log"),typeof console===E?!1:i==="trace"&&qt?Zt:console[i]!==void 0?tt(console,i):console.log!==void 0?tt(console,"log"):et}function te(){for(var i=this.getLevel(),e=0;e<Oe.length;e++){var t=Oe[e];this[t]=e<i?et:this.methodFactory(t,i,this.name)}if(this.log=this.debug,typeof console===E&&i<this.levels.SILENT)return"No console available for logging"}function ei(i){return function(){typeof console!==E&&(te.call(this),this[i].apply(this,arguments))}}function ti(i,e,t){return Qt(i)||ei.apply(this,arguments)}function it(i,e){var t=this,l,o,s,n="loglevel";typeof i=="string"?n+=":"+i:typeof i=="symbol"&&(n=void 0);function r(p){var h=(Oe[p]||"silent").toUpperCase();if(!(typeof window===E||!n)){try{window.localStorage[n]=h;return}catch{}try{window.document.cookie=encodeURIComponent(n)+"="+h+";"}catch{}}}function a(){var p;if(!(typeof window===E||!n)){try{p=window.localStorage[n]}catch{}if(typeof p===E)try{var h=window.document.cookie,f=encodeURIComponent(n),w=h.indexOf(f+"=");w!==-1&&(p=/^([^;]+)/.exec(h.slice(w+f.length+1))[1])}catch{}return t.levels[p]===void 0&&(p=void 0),p}}function d(){if(!(typeof window===E||!n)){try{window.localStorage.removeItem(n)}catch{}try{window.document.cookie=encodeURIComponent(n)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function c(p){var h=p;if(typeof h=="string"&&t.levels[h.toUpperCase()]!==void 0&&(h=t.levels[h.toUpperCase()]),typeof h=="number"&&h>=0&&h<=t.levels.SILENT)return h;throw new TypeError("log.setLevel() called with invalid level: "+p)}t.name=i,t.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},t.methodFactory=e||ti,t.getLevel=function(){return s??o??l},t.setLevel=function(p,h){return s=c(p),h!==!1&&r(s),te.call(t)},t.setDefaultLevel=function(p){o=c(p),a()||t.setLevel(p,!1)},t.resetLevel=function(){s=null,d(),te.call(t)},t.enableAll=function(p){t.setLevel(t.levels.TRACE,p)},t.disableAll=function(p){t.setLevel(t.levels.SILENT,p)},t.rebuild=function(){if(_!==t&&(l=c(_.getLevel())),te.call(t),_===t)for(var p in ee)ee[p].rebuild()},l=c(_?_.getLevel():"WARN");var m=a();m!=null&&(s=c(m)),te.call(t)}_=new it,_.getLogger=function(e){if(typeof e!="symbol"&&typeof e!="string"||e==="")throw new TypeError("You must supply a name when creating a logger.");var t=ee[e];return t||(t=ee[e]=new it(e,_.methodFactory)),t};var ii=typeof window!==E?window.log:void 0;_.noConflict=function(){return typeof window!==E&&window.log===_&&(window.log=ii),_},_.getLoggers=function(){return ee},_.default=_;var li=function(i){for(var e=1,t=arguments.length,l;e<t;e++)for(l in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],l)&&(i[l]=arguments[e][l]);return i},oi={template:"[%t] %l:",levelFormatter:function(i){return i.toUpperCase()},nameFormatter:function(i){return i||"root"},timestampFormatter:function(i){return i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")},format:void 0},lt,j={},si=function(i){if(!i||!i.getLogger)throw new TypeError("Argument is not a root logger");lt=i},ni=function(i,e){if(!i||!i.setLevel)throw new TypeError("Argument is not a logger");var t=i.methodFactory,l=i.name||"",o=j[l]||j[""]||oi;function s(n,r,a){var d=t(n,r,a),c=j[a]||j[""],m=c.template.indexOf("%t")!==-1,p=c.template.indexOf("%l")!==-1,h=c.template.indexOf("%n")!==-1;return function(){for(var f="",w=arguments.length,b=Array(w),v=0;v<w;v++)b[v]=arguments[v];if(l||!j[a]){var y=c.timestampFormatter(new Date),x=c.levelFormatter(n),O=c.nameFormatter(a);c.format?f+=c.format(x,O,y):(f+=c.template,m&&(f=f.replace(/%t/,y)),p&&(f=f.replace(/%l/,x)),h&&(f=f.replace(/%n/,O))),b.length&&typeof b[0]=="string"?b[0]=f+" "+b[0]:b.unshift(f)}d.apply(void 0,b)}}return j[l]||(i.methodFactory=s),e=e||{},e.template&&(e.format=void 0),j[l]=li({},o,e),i.setLevel(i.getLevel()),lt||i.warn("It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"),i},Ie={reg:si,apply:ni};const ve={debug:"#0ea5e9",info:"#10b981",warn:"#f59e0b",error:"#ef4444"};Ie.reg(_),Ie.apply(_,{format(i,e,t){return ve[i.toLowerCase()],`%c[${t}]%c %c[${i}]%c ${e?`%c[${e}]%c `:""}`},timestampFormatter(i){return i.toTimeString().split(" ")[0]+"."+i.getMilliseconds().toString().padStart(3,"0")}});const ri=_.methodFactory;_.methodFactory=function(i,e,t){const l=ri(i,e,t);return function(...o){if(o.length>0&&typeof o[0]=="string"&&o[0].includes("%c")){const s=ve[i]||"#666",n=[o[0],`color: ${s}; font-weight: bold;`,"color: inherit;",`color: ${s}; font-weight: bold;`,"color: inherit;",...t?[`color: ${s}; font-weight: bold;`,"color: inherit;"]:[],...o.slice(1)];l(...n)}else l(...o)}},_.setLevel("silent");const N=_.getLogger("INIT"),k=_.getLogger("DATA"),g=_.getLogger("UI"),S=_.getLogger("INTERACTION");[N,k,g,S].forEach(i=>{Ie.apply(i,{format(t,l,o){return ve[t.toLowerCase()],`%c[${o}]%c %c[${t}]%c %c[${l}]%c `},timestampFormatter(t){return t.toTimeString().split(" ")[0]+"."+t.getMilliseconds().toString().padStart(3,"0")}});const e=i.methodFactory;i.methodFactory=function(t,l,o){const s=e(t,l,o);return function(...n){if(n.length>0&&typeof n[0]=="string"&&n[0].includes("%c")){const r=ve[t]||"#666",a=[n[0],`color: ${r}; font-weight: bold;`,"color: inherit;",`color: ${r}; font-weight: bold;`,"color: inherit;",`color: ${r}; font-weight: bold;`,"color: inherit;",...n.slice(1)];s(...a)}else s(...n)}},i.setLevel("silent")});const Pe=i=>{_.setLevel(i),N.setLevel(i),k.setLevel(i),g.setLevel(i),S.setLevel(i)},ai=()=>{Pe("debug")},ci=()=>{Pe("silent")},di=(i,e="debug")=>{({INIT:N,DATA:k,UI:g,INTERACTION:S})[i].setLevel(e)};class pi{constructor(e){u(this,"container");u(this,"wrapper");u(this,"viewport");u(this,"itemHeight");u(this,"items");u(this,"renderItem");u(this,"bufferSize");u(this,"onVisibleRangeChange");u(this,"onScroll");u(this,"scrollTop",0);u(this,"viewportHeight",0);u(this,"visibleStart",0);u(this,"visibleEnd",0);u(this,"scrollHandler");u(this,"resizeObserver");this.container=e.container,this.itemHeight=e.itemHeight,this.items=e.items,this.renderItem=e.renderItem,this.bufferSize=e.bufferSize??10,this.onVisibleRangeChange=e.onVisibleRangeChange,this.onScroll=e.onScroll,this.scrollHandler=this.handleScroll.bind(this),this.init()}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.style.position="relative",this.wrapper.style.width="100%",this.wrapper.style.height=`${this.items.length*this.itemHeight}px`,this.wrapper.className="ml__virtual-scroll-wrapper",this.viewport=document.createElement("div"),this.viewport.style.position="absolute",this.viewport.style.top="0",this.viewport.style.left="0",this.viewport.style.right="0",this.viewport.style.width="100%",this.viewport.className="ml__virtual-scroll-viewport",this.wrapper.appendChild(this.viewport),this.container.appendChild(this.wrapper),this.container.addEventListener("scroll",this.scrollHandler),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.updateViewportHeight(),this.render()}),this.resizeObserver.observe(this.container)),this.updateViewportHeight(),this.render()}updateViewportHeight(){this.viewportHeight=this.container.clientHeight}handleScroll(){this.scrollTop=this.container.scrollTop,this.onScroll&&this.onScroll(this.scrollTop),this.render()}calculateVisibleRange(){const e=Math.floor(this.scrollTop/this.itemHeight),t=Math.ceil((this.scrollTop+this.viewportHeight)/this.itemHeight),l=Math.max(0,e-this.bufferSize),o=Math.min(this.items.length,t+this.bufferSize);return{start:l,end:o}}render(){const{start:e,end:t}=this.calculateVisibleRange();if(e===this.visibleStart&&t===this.visibleEnd)return;this.visibleStart=e,this.visibleEnd=t,this.onVisibleRangeChange&&this.onVisibleRangeChange(e,t);let l="";for(let o=e;o<t;o++){const s=this.items[o],n=this.renderItem(s,o),r=o*this.itemHeight;l+=`<div class="ml__virtual-item" style="position: absolute; top: ${r}px; left: 0; right: 0; height: ${this.itemHeight}px;" data-index="${o}">`,l+=n,l+="</div>"}this.viewport.innerHTML=l}setItems(e){this.items=e,this.wrapper.style.height=`${e.length*this.itemHeight}px`,this.updateViewportHeight(),this.visibleStart=-1,this.visibleEnd=-1,this.render()}scrollToIndex(e){if(e<0||e>=this.items.length)return;const t=e*this.itemHeight;this.container.scrollTop=t}getVisibleRange(){return{start:this.visibleStart,end:this.visibleEnd}}getItemCount(){return this.items.length}setItemHeight(e){this.itemHeight=e,this.wrapper.style.height=`${this.items.length*e}px`,this.visibleStart=-1,this.visibleEnd=-1,this.render()}setBufferSize(e){this.bufferSize=e,this.visibleStart=-1,this.visibleEnd=-1,this.render()}refresh(){this.visibleStart=-1,this.visibleEnd=-1,this.render()}destroy(){this.container.removeEventListener("scroll",this.scrollHandler),this.resizeObserver&&this.resizeObserver.disconnect(),this.container.innerHTML=""}}class ot{constructor(e,t={}){u(this,"element");u(this,"instanceId");u(this,"options");u(this,"isOpen",!1);u(this,"selectedValues",new Set);u(this,"selectedOptions",new Map);u(this,"allOptions",[]);u(this,"filteredOptions",[]);u(this,"hiddenInputs",[]);u(this,"focusedIndex",-1);u(this,"matchingIndices",new Set);u(this,"searchTerm","");u(this,"isLoading",!1);u(this,"showSelectedPopover",!1);u(this,"selectedPopoverPlacement",null);u(this,"dropdownPlacement",null);u(this,"isRTL",!1);u(this,"effectivePillsPosition","bottom");u(this,"justClosedViaClick",!1);u(this,"dropdownCleanup",null);u(this,"hintCleanup",null);u(this,"selectedPopoverCleanup",null);u(this,"pillTooltips",new Map);u(this,"pillTooltipCleanups",new Map);u(this,"virtualScroll",null);u(this,"optionsContainer",null);u(this,"input");u(this,"dropdown");u(this,"pillsContainer");u(this,"countBadge");u(this,"hint");u(this,"selectedPopover");this.element=e,this.instanceId=`MS-${Math.random().toString(36).substr(2,9)}`,this.options={searchHint:e.dataset.searchHint||"",searchPlaceholder:e.dataset.searchPlaceholder||"Search...",dropdownMinWidth:e.dataset.dropdownMinWidth||void 0,pillsDisplayMode:e.dataset.pillsDisplayMode||"pills",pillsPosition:e.dataset.pillsPosition||"bottom",pillsThresholdMode:e.dataset.pillsThresholdMode||"count",maxHeight:e.dataset.maxHeight||"20rem",emptyMessage:e.dataset.emptyMessage||"No results found",loadingMessage:e.dataset.loadingMessage||"Loading...",searchInputMode:e.dataset.searchInputMode||"normal",searchMode:e.dataset.searchMode||"filter",pillsThreshold:e.dataset.pillsThreshold?parseInt(e.dataset.pillsThreshold):void 0,minSearchLength:parseInt(e.dataset.minSearchLength||"0")||0,isMultipleEnabled:e.dataset.multiple!=="false",isGroupsAllowed:e.dataset.allowGroups!=="false",isSelectAllAllowed:e.dataset.allowSelectAll!=="false",isClearAllAllowed:e.dataset.allowClearAll!=="false",isCheckboxesShown:e.dataset.showCheckboxes!=="false",isActionsSticky:e.dataset.stickyActions!=="false",isCloseOnSelect:e.dataset.closeOnSelect==="true",isPlacementLocked:e.dataset.lockPlacement!=="false",isSearchEnabled:e.dataset.enableSearch!=="false",isAddNewAllowed:e.dataset.allowAddNew==="true",isCountBadgeShown:e.dataset.showCountBadge==="true",isKeepOptionsOnSearch:e.dataset.keepOptionsOnSearch!=="false",options:[],container:void 0,...t},this.init()}getItemValue(e){return Array.isArray(e)&&e.length===2?e[0]:this.options.valueMember&&e[this.options.valueMember]!==void 0?e[this.options.valueMember]:this.options.getValueCallback?this.options.getValueCallback(e):"[N/A]"}getItemDisplayValue(e){return Array.isArray(e)&&e.length===2?String(e[1]):this.options.displayValueMember&&e[this.options.displayValueMember]!==void 0?String(e[this.options.displayValueMember]):this.options.getDisplayValueCallback?this.options.getDisplayValueCallback(e):"[N/A]"}getItemPillDisplayValue(e){return this.options.getPillDisplayCallback?this.options.getPillDisplayCallback(e):this.getItemDisplayValue(e)}getItemSearchValue(e){return this.options.searchValueMember&&e[this.options.searchValueMember]!==void 0?String(e[this.options.searchValueMember]):this.options.getSearchValueCallback?this.options.getSearchValueCallback(e):this.getItemDisplayValue(e)}getItemIcon(e){if(!Array.isArray(e)){if(this.options.iconMember&&e[this.options.iconMember]!==void 0)return String(e[this.options.iconMember]);if(this.options.getIconCallback)return this.options.getIconCallback(e)}}getItemSubtitle(e){if(!Array.isArray(e)){if(this.options.subtitleMember&&e[this.options.subtitleMember]!==void 0)return String(e[this.options.subtitleMember]);if(this.options.getSubtitleCallback)return this.options.getSubtitleCallback(e)}}getItemGroup(e){if(!Array.isArray(e)){if(this.options.groupMember&&e[this.options.groupMember]!==void 0)return String(e[this.options.groupMember]);if(this.options.getGroupCallback)return this.options.getGroupCallback(e)}}getItemDisabled(e){return Array.isArray(e)?!1:this.options.disabledMember&&e[this.options.disabledMember]!==void 0?!!e[this.options.disabledMember]:this.options.getDisabledCallback?this.options.getDisabledCallback(e):!1}init(){this.parseOptions(),this.buildHTML(),this.attachEvents(),this.parseInitialSelection(),N.debug(`Initialized [${this.instanceId}] with options:`,{placeholder:this.options.searchPlaceholder,totalOptions:this.allOptions.length,isCloseOnSelect:this.options.isCloseOnSelect,dataAttribute:this.element.dataset.closeOnSelect,isSelectAllAllowed:this.options.isSelectAllAllowed,isClearAllAllowed:this.options.isClearAllAllowed})}parseOptions(){const e=this.element.dataset.options;if(e)try{this.allOptions=JSON.parse(e)}catch(t){k.error(`[${this.instanceId}] Failed to parse data-options:`,t),this.allOptions=[]}else this.options.options&&(this.allOptions=this.options.options);this.filteredOptions=[...this.allOptions]}buildHTML(){const e=this.options.container||document.body,t=this.element.getRootNode(),l=t instanceof ShadowRoot?t.host:this.element,o=l.getAttribute("dir")==="rtl",s=l.closest('[dir="rtl"]')!==null;this.isRTL=o||s,N.debug(`[${this.instanceId}] RTL Debug:`,{isShadowRoot:t instanceof ShadowRoot,hostElement:l,elementDir:l.getAttribute("dir"),hasElementDir:o,hasAncestorDir:s,isRTL:this.isRTL}),this.effectivePillsPosition=this.options.pillsPosition||"bottom",this.isRTL&&(this.effectivePillsPosition==="left"?this.effectivePillsPosition="right":this.effectivePillsPosition==="right"&&(this.effectivePillsPosition="left")),this.element.classList.add("ml"),this.isRTL&&(this.element.classList.add("ml--rtl"),N.debug(`[${this.instanceId}] Added ml--rtl class to element`)),(!this.options.isCheckboxesShown||!this.options.isMultipleEnabled)&&this.element.classList.add("ml--no-checkboxes");const n=document.createElement("div");n.className="ml__input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="ml__input",this.input.placeholder=this.options.searchPlaceholder,this.input.autocomplete="off",this.options.searchInputMode==="readonly"?this.input.readOnly=!0:this.options.searchInputMode==="hidden"&&(this.input.style.display="none");const r=document.createElement("span");r.className="ml__toggle",r.innerHTML="▼",this.countBadge=document.createElement("span"),this.countBadge.className="ml__count-badge",this.countBadge.style.display="none",n.appendChild(this.input),n.appendChild(this.countBadge),n.appendChild(r),this.pillsContainer=document.createElement("div"),this.pillsContainer.className="ml__pills";const a=document.createElement("div");a.className="ml-wrapper",(this.effectivePillsPosition==="left"||this.effectivePillsPosition==="right")&&a.classList.add("ml-wrapper--inline"),a.appendChild(n),a.appendChild(this.pillsContainer),this.element.appendChild(a),this.dropdown=document.createElement("div"),this.dropdown.className="ml__dropdown",e.appendChild(this.dropdown),this.options.searchHint&&(this.hint=document.createElement("div"),this.hint.className="ml__hint",this.hint.textContent=this.options.searchHint,e.appendChild(this.hint)),this.selectedPopover=document.createElement("div"),this.selectedPopover.className="ml__selected-popover",e.appendChild(this.selectedPopover),this.renderDropdown()}shouldUseVirtualScroll(){if(!this.options.isVirtualScrollEnabled||this.options.isGroupsAllowed&&this.hasGroups())return!1;const e=this.options.virtualScrollThreshold??100;return this.filteredOptions.length>=e}hasGroups(){return this.filteredOptions.some(e=>{const t=this.getItemGroup(e);return t&&t.trim()!==""})}renderDropdown(){if(this.shouldUseVirtualScroll()){this.dropdown.classList.add("ml__dropdown--virtual"),this.renderDropdownVirtual();return}this.dropdown.classList.remove("ml__dropdown--virtual");let e="";if(this.isLoading){e+='<div class="ml__loader">',e+='<div class="pa-loader pa-loader--sm"></div>',e+=`<div class="ml__loading-text">${this.options.loadingMessage}</div>`,e+="</div>",this.dropdown.innerHTML=e;return}if(this.options.isMultipleEnabled&&(this.options.isSelectAllAllowed||this.options.isClearAllAllowed)){const t=this.options.isActionsSticky?" ml__actions--sticky":"";e+=`<div class="ml__actions${t}">`,this.options.isSelectAllAllowed&&(e+='<button type="button" class="ml__action-btn" data-action="select-all">Select All</button>'),this.options.isClearAllAllowed&&(e+='<button type="button" class="ml__action-btn" data-action="clear-all">Clear All</button>'),e+="</div>"}if(e+='<div class="ml__options">',this.filteredOptions.length===0)e+=`<div class="ml__empty">${this.options.emptyMessage}</div>`;else if(this.options.isGroupsAllowed){const t=this.groupOptions(this.filteredOptions);Object.keys(t).forEach(l=>{e+='<div class="ml__group">',l!=="__ungrouped__"&&(e+=`<div class="ml__group-label">${l}</div>`),t[l].forEach((o,s)=>{e+=this.renderOption(o,s)}),e+="</div>"})}else this.filteredOptions.forEach((t,l)=>{e+=this.renderOption(t,l)});e+="</div>",this.dropdown.innerHTML=e}renderDropdownVirtual(){if(!this.virtualScroll){let l="";if(this.options.isMultipleEnabled&&(this.options.isSelectAllAllowed||this.options.isClearAllAllowed)){const s=this.options.isActionsSticky?" ml__actions--sticky":"";l+=`<div class="ml__actions${s}">`,this.options.isSelectAllAllowed&&(l+='<button type="button" class="ml__action-btn" data-action="select-all">Select All</button>'),this.options.isClearAllAllowed&&(l+='<button type="button" class="ml__action-btn" data-action="clear-all">Clear All</button>'),l+="</div>"}const o=this.options.maxHeight||"20rem";l+=`<div class="ml__options ml__options--virtual" style="height: ${o}; max-height: ${o}; overflow-y: auto; position: relative;"></div>`,this.dropdown.innerHTML=l,this.optionsContainer=this.dropdown.querySelector(".ml__options")}if(this.filteredOptions.length===0){this.optionsContainer.innerHTML=`<div class="ml__empty">${this.options.emptyMessage}</div>`;return}const e=this.options.optionHeight??50,t=this.options.virtualScrollBuffer??10;requestAnimationFrame(()=>{this.optionsContainer&&(this.virtualScroll?this.virtualScroll.setItems(this.filteredOptions):this.virtualScroll=new pi({container:this.optionsContainer,itemHeight:e,items:this.filteredOptions,renderItem:(l,o)=>this.renderOption(l,o),bufferSize:t}))})}renderOption(e,t){const l=this.getItemValue(e),o=this.getItemDisplayValue(e),s=this.getItemIcon(e),n=this.getItemSubtitle(e),r=this.getItemDisabled(e),a=this.selectedValues.has(String(l)),d=t===this.focusedIndex,c=this.matchingIndices.has(t),m=["ml__option"];a&&m.push("ml__option--selected"),d&&m.push("ml__option--focused"),c&&m.push("ml__option--matched"),r&&m.push("ml__option--disabled");let p=`<div class="${m.join(" ")}" data-value="${l}" data-index="${t}">`;return this.options.isCheckboxesShown&&this.options.isMultipleEnabled&&(p+=`<input type="checkbox" class="ml__checkbox" ${a?"checked":""} ${r?"disabled":""}>`),p+='<div class="ml__option-content">',s&&(p+=`<span class="ml__option-icon">${s}</span>`),p+='<div class="ml__option-text">',p+=`<div class="ml__option-title">${this.highlightMatch(o,this.searchTerm)}</div>`,n&&(p+=`<div class="ml__option-subtitle">${n}</div>`),p+="</div>",p+="</div>",p+="</div>",p}highlightMatch(e,t){if(!t)return e;const l=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(l,"<mark>$1</mark>")}groupOptions(e){const t={};return e.forEach(l=>{const o=this.getItemGroup(l)||"__ungrouped__";t[o]||(t[o]=[]),t[o].push(l)}),t}renderPills(){this.destroyAllPillTooltips();const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;if(!this.options.isMultipleEnabled){this.pillsContainer.innerHTML="",this.countBadge.style.display="none";const s=e[0]?this.getItemDisplayValue(e[0]):void 0;g.warn(`[${this.instanceId}] renderPills() single-select mode`,{isOpen:this.isOpen,count:t,selectedOptionsLength:e.length,willSetValue:!this.isOpen&&t>0&&e.length>0,selectedLabel:s}),!this.isOpen&&t>0&&e.length>0?(g.info(`[${this.instanceId}] ✅ SETTING input.value = "${s}"`),this.input.value=s,g.info(`[${this.instanceId}] 🔍 VERIFY input.value = "${this.input.value}"`)):this.isOpen?g.info(`[${this.instanceId}] ⏭️ SKIPPING input update (dropdown is open)`):(g.info(`[${this.instanceId}] ❌ CLEARING input.value (no selection)`),this.input.value="");return}let l=this.options.pillsDisplayMode;if(this.options.pillsThreshold!==null&&t>this.options.pillsThreshold&&(l=this.options.pillsThresholdMode||"count"),!this.isOpen)if(t>0&&l==="count"){const s=this.options.getCountPillCallback?this.options.getCountPillCallback(t):`${t} selected`;this.input.placeholder=s}else this.input.placeholder=this.options.searchPlaceholder;if(this.options.isCountBadgeShown&&t>0?(this.countBadge.textContent=`[${t}]`,this.countBadge.style.display=""):this.countBadge.style.display="none",l==="pills")this.pillsContainer.className=`ml__pills ml__pills--${this.effectivePillsPosition}`,this.pillsContainer.innerHTML=e.map(s=>{const n=this.getItemValue(s),r=this.getItemPillDisplayValue(s);return`
2
2
  <div class="ml__pill">
3
3
  <span class="ml__pill-text">${r}</span>
4
4
  <button type="button" class="ml__pill-remove" data-value="${n}" aria-label="Remove ${r}"></button>
5
5
  </div>
6
- `}).join("");else if(l==="partial"){this.pillsContainer.className=`ml__pills ml__pills--${this.effectivePillsPosition}`;const s=this.options.pillsMaxVisible||3,n=e.slice(0,s),r=t-s,a=n.map(p=>{const d=this.getItemValue(p),m=this.getItemPillDisplayValue(p);return`
6
+ `}).join("");else if(l==="partial"){this.pillsContainer.className=`ml__pills ml__pills--${this.effectivePillsPosition}`;const s=this.options.pillsMaxVisible||3,n=e.slice(0,s),r=t-s,a=n.map(c=>{const m=this.getItemValue(c),p=this.getItemPillDisplayValue(c);return`
7
7
  <div class="ml__pill">
8
- <span class="ml__pill-text">${m}</span>
9
- <button type="button" class="ml__pill-remove" data-value="${d}" aria-label="Remove ${m}"></button>
8
+ <span class="ml__pill-text">${p}</span>
9
+ <button type="button" class="ml__pill-remove" data-value="${m}" aria-label="Remove ${p}"></button>
10
10
  </div>
11
- `}).join("");let c="";r>0&&(c=`
11
+ `}).join("");let d="";r>0&&(d=`
12
12
  <div class="ml__pill ml__pill--more" data-action="show-selected">
13
13
  <span class="ml__pill-text">${this.options.getCountPillCallback?this.options.getCountPillCallback(t,r):`+${r} more`}</span>
14
14
  <button type="button" class="ml__pill-remove" data-action="remove-hidden" aria-label="Remove ${r} hidden items"></button>
15
15
  </div>
16
- `),this.pillsContainer.innerHTML=a+c}else if(this.pillsContainer.className=`ml__count-display ml__count-display--${this.effectivePillsPosition}`,t>0){const s=this.options.getCountPillCallback?this.options.getCountPillCallback(t):`${t} selected`;this.pillsContainer.innerHTML=`
16
+ `),this.pillsContainer.innerHTML=a+d}else if(this.pillsContainer.className=`ml__count-display ml__count-display--${this.effectivePillsPosition}`,t>0){const s=this.options.getCountPillCallback?this.options.getCountPillCallback(t):`${t} selected`;this.pillsContainer.innerHTML=`
17
17
  <div class="ml__count-badge-wrapper">
18
18
  <button type="button" class="ml__count-text" data-action="show-selected">
19
19
  ${s}
20
20
  </button>
21
21
  <button type="button" class="ml__count-clear" data-action="clear-count" aria-label="Clear all selections"></button>
22
22
  </div>
23
- `}else this.pillsContainer.innerHTML="";this.attachPillTooltips()}attachEvents(){this.input.addEventListener("mousedown",e=>{e.stopPropagation(),this.isOpen?(this.justClosedViaClick=!0,this.close(),setTimeout(()=>{this.justClosedViaClick=!1},0)):this.open()}),this.input.addEventListener("focus",()=>{!this.isOpen&&!this.justClosedViaClick&&this.open()}),this.input.addEventListener("input",e=>{const t=e.target.value;this.options.isSearchEnabled&&!this.isOpen&&this.open(),this.handleSearch(t)}),this.input.addEventListener("keydown",e=>this.handleKeydown(e)),setTimeout(()=>{document.addEventListener("click",e=>this.handleClickOutside(e))},0),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.pillsContainer.addEventListener("mousedown",e=>{e.target.closest(".ml__count-text")&&!this.showSelectedPopover&&e.stopPropagation()}),this.pillsContainer.addEventListener("click",e=>this.handlePillClick(e)),this.countBadge.addEventListener("mousedown",e=>{this.showSelectedPopover||e.stopPropagation()}),this.countBadge.addEventListener("click",e=>{e.stopPropagation(),this.toggleSelectedPopover()}),this.selectedPopover.addEventListener("click",e=>this.handleSelectedPopoverClick(e))}async handleSearch(e){if(this.searchTerm=e,!!this.options.isSearchEnabled)if(this.options.searchCallback){if(e.length<this.options.minSearchLength){this.filteredOptions=[],this.allOptions=[],this.renderDropdown();return}this.isLoading=!0,this.renderDropdown(),f.debug(`[${this.instanceId}] Loading data for search term:`,e);try{const t=await this.options.searchCallback(e);this.searchTerm===e&&(this.allOptions=t||[],this.filteredOptions=[...this.allOptions],this.isLoading=!1,this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),f.debug(`[${this.instanceId}] Loaded ${this.allOptions.length} results`))}catch(t){f.error(`[${this.instanceId}] Error loading data:`,t),this.isLoading=!1,this.filteredOptions=[],this.allOptions=[],this.renderDropdown()}}else e?this.filteredOptions=this.allOptions.filter(t=>this.getItemSearchValue(t).toLowerCase().includes(e.toLowerCase())):this.filteredOptions=[...this.allOptions],this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown()}handleKeydown(e){if(!this.isOpen){(e.key==="Enter"||e.key==="ArrowDown")&&(e.preventDefault(),this.open());return}if(!this.options.isSearchEnabled){const t=e.key.length===1||e.key==="Backspace"||e.key==="Delete",l=["ArrowUp","ArrowDown","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key);if(t&&!l){e.preventDefault();return}}switch(e.key){case"ArrowDown":e.preventDefault(),this.focusNext();break;case"ArrowUp":e.preventDefault(),this.focusPrevious();break;case"Enter":e.preventDefault(),this.focusedIndex>=0?this.toggleOption(this.filteredOptions[this.focusedIndex]):this.options.isAddNewAllowed&&this.options.addNewCallback&&this.input.value.trim()&&this.handleAddNew(this.input.value.trim());break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.close();break;case"PageUp":e.preventDefault(),this.focusPageUp();break;case"PageDown":e.preventDefault(),this.focusPageDown();break;case"Home":e.preventDefault(),this.focusFirst();break;case"End":e.preventDefault(),this.focusLast();break}}handleDropdownClick(e){f.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const o=t.dataset.action;f.debug(`[${this.instanceId}] Action button clicked:`,o),o==="select-all"?this.selectAll():o==="clear-all"&&this.clearAll();return}const l=e.target.closest(".ml__option");if(l&&!l.classList.contains("ml__option--disabled")){e.preventDefault();const o=l.dataset.value,s=this.filteredOptions.find(n=>String(this.getItemValue(n))===o);f.debug(`[${this.instanceId}] Option clicked:`,{value:o,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),s&&this.toggleOption(s)}}handlePillClick(e){if(e.target.closest(".ml__count-clear")){e.preventDefault(),e.stopPropagation(),f.debug(`[${this.instanceId}] Count clear button clicked`),this.clearAll();return}if(e.target.closest(".ml__count-text")){e.preventDefault(),e.stopPropagation(),this.toggleSelectedPopover();return}const o=e.target.closest(".ml__pill-remove");if(o){if(e.preventDefault(),e.stopPropagation(),o.dataset.action==="remove-hidden"){f.debug(`[${this.instanceId}] Remove hidden items button clicked`);const a=this.options.pillsMaxVisible||3;Array.from(this.selectedOptions.values()).slice(a).forEach(d=>this.deselectOption(d));return}const n=o.dataset.value,r=this.selectedOptions.get(n);r&&this.deselectOption(r);return}if(e.target.closest(".ml__pill--more")&&!e.target.closest(".ml__pill-remove")){e.preventDefault(),e.stopPropagation(),f.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`),this.toggleSelectedPopover();return}}handleClickOutside(e){var o;const t=e.composedPath();if(this.showSelectedPopover&&!t.some(n=>n instanceof Node&&(this.selectedPopover.contains(n)||this.countBadge.contains(n)||n.closest&&n.closest(".ml__count-text")))){f.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const l=t.some(s=>s instanceof Node&&(this.element.contains(s)||this.dropdown.contains(s)||this.hint&&this.hint.contains(s)));f.debug(`[${this.instanceId}] handleClickOutside`,{target:e.target.className,targetTag:e.target.tagName,clickedInside:l,pathLength:t.length,firstInPath:(o=t[0])==null?void 0:o.tagName,elementContains:t.some(s=>s instanceof Node&&this.element.contains(s)),dropdownContains:t.some(s=>s instanceof Node&&this.dropdown.contains(s)),isConnected:this.dropdown.isConnected}),l||(f.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusNext(){this.filteredOptions.length!==0&&(this.focusedIndex=(this.focusedIndex+1)%this.filteredOptions.length,this.renderDropdown(),this.scrollToFocused())}focusPrevious(){this.filteredOptions.length!==0&&(this.focusedIndex=this.focusedIndex<=0?this.filteredOptions.length-1:this.focusedIndex-1,this.renderDropdown(),this.scrollToFocused())}focusFirst(){this.filteredOptions.length!==0&&(this.focusedIndex=0,this.renderDropdown(),this.scrollToFocused())}focusLast(){this.filteredOptions.length!==0&&(this.focusedIndex=this.filteredOptions.length-1,this.renderDropdown(),this.scrollToFocused())}focusPageUp(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.max(0,this.focusedIndex-10),this.renderDropdown(),this.scrollToFocused())}focusPageDown(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+10),this.renderDropdown(),this.scrollToFocused())}scrollToFocused(){const e=this.dropdown.querySelector(".ml__option--focused");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}toggleOption(e){const t=this.getItemValue(e),l=String(t);if(f.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),!this.options.isMultipleEnabled){this.selectedValues.has(l)?(f.debug(`[${this.instanceId}] Deselecting option in single-select mode`,{value:t}),this.deselectOption(e)):(f.debug(`[${this.instanceId}] Clearing previous selections and selecting new option`,{value:t}),this.selectedValues.clear(),this.selectedOptions.clear(),this.selectOption(e)),f.info(`[${this.instanceId}] ❌ Closing dropdown (single-select mode)`),this.close();return}this.selectedValues.has(l)?(f.debug(`[${this.instanceId}] Deselecting option`,{value:t}),this.deselectOption(e)):(f.debug(`[${this.instanceId}] Selecting option`,{value:t}),this.selectOption(e)),f.debug(`[${this.instanceId}] Checking closeOnSelect`,{closeOnSelect:this.options.isCloseOnSelect,willClose:this.options.isCloseOnSelect===!0,placeholder:this.options.searchPlaceholder}),this.options.isCloseOnSelect?(f.info(`[${this.instanceId}] ❌ Closing dropdown (closeOnSelect=true)`),this.close()):f.info(`[${this.instanceId}] ✅ Keeping dropdown open (closeOnSelect=false)`)}async handleAddNew(e){if(this.options.addNewCallback)try{f.debug(`[${this.instanceId}] Adding new option:`,e);const t=await this.options.addNewCallback(e);this.allOptions.push(t),this.filteredOptions.push(t),this.selectOption(t),this.input.value="",this.renderDropdown(),this.renderPills(),this.options.isCloseOnSelect&&this.close()}catch(t){f.error(`[${this.instanceId}] Error adding new option:`,t)}}selectOption(e){const t=this.getItemValue(e),l=String(t);this.selectedValues.add(l),this.selectedOptions.set(l,e),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.selectCallback&&this.options.selectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}deselectOption(e){const t=this.getItemValue(e),l=String(t);this.selectedValues.delete(l),this.selectedOptions.delete(l),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.deselectCallback&&this.options.deselectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}selectAll(){this.filteredOptions.forEach(e=>{if(!this.getItemDisabled(e)){const t=this.getItemValue(e),l=String(t);this.selectedValues.add(l),this.selectedOptions.set(l,e)}}),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}clearAll(){this.selectedValues.clear(),this.selectedOptions.clear(),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}open(){f.debug(`[${this.instanceId}] open() called`,{isOpen:this.isOpen}),!this.isOpen&&(this.isOpen=!0,this.element.classList.add("ml--open"),this.dropdown.classList.add("ml__dropdown--visible"),f.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.options.searchPlaceholder,!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=""),this.renderDropdown(),this.positionDropdown(),this.hint&&(this.hint.classList.add("ml__hint--visible"),this.positionHint()))}close(){if(f.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),!this.isOpen)return;this.isOpen=!1,this.element.classList.remove("ml--open"),this.dropdown.classList.remove("ml__dropdown--visible"),this.hint&&this.hint.classList.remove("ml__hint--visible"),this.searchTerm="";const e=this.options.isMultipleEnabled||this.options.isSearchEnabled;f.warn(`[${this.instanceId}] close() - input clearing decision`,{multiple:this.options.isMultipleEnabled,enableSearch:this.options.isSearchEnabled,willClearInput:e,currentInputValue:this.input.value}),e?(f.info(`[${this.instanceId}] 🧹 close() CLEARING input.value`),this.input.value=""):f.info(`[${this.instanceId}] 🔒 close() KEEPING input.value = "${this.input.value}"`),this.filteredOptions=[...this.allOptions],this.focusedIndex=-1,f.info(`[${this.instanceId}] 📞 close() CALLING renderPills()`),this.renderPills(),f.info(`[${this.instanceId}] ✅ close() AFTER renderPills(), input.value = "${this.input.value}"`),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,f.info(`[${this.instanceId}] Dropdown closed. Stack trace:`),console.trace()}positionDropdown(){this.dropdownCleanup=re(this.input,this.dropdown,()=>{const e=this.options.isPlacementLocked&&this.dropdownPlacement?this.dropdownPlacement:"bottom-start",t=[ae(4),...this.options.isPlacementLocked&&this.dropdownPlacement?[]:[ve()],ce({padding:8})];de(this.input,this.dropdown,{placement:e,middleware:t}).then(({x:l,y:o,placement:s})=>{this.options.isPlacementLocked&&!this.dropdownPlacement&&(this.dropdownPlacement=s,f.debug(`[${this.instanceId}] Locked dropdown placement:`,s));const n={left:`${l}px`,top:`${o}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(n.minWidth=this.options.dropdownMinWidth),Object.assign(this.dropdown.style,n),this.hint&&this.isOpen&&this.positionHint()})})}positionHint(){this.hint&&(this.hintCleanup&&this.hintCleanup(),this.hintCleanup=re(this.input,this.hint,()=>{let e="top-start";this.dropdownPlacement&&(this.dropdownPlacement.startsWith("bottom")?e=this.dropdownPlacement.replace("bottom","top"):this.dropdownPlacement.startsWith("top")&&(e=this.dropdownPlacement.replace("top","bottom"))),de(this.input,this.hint,{placement:e,middleware:[ae(4),ce({padding:8})]}).then(({x:t,y:l})=>{Object.assign(this.hint.style,{left:`${t}px`,top:`${l}px`})})}))}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(l=>{const o=String(l);this.selectedValues.add(o);const s=this.allOptions.find(n=>String(this.getItemValue(n))===o);s&&this.selectedOptions.set(o,s)}),this.renderPills()}catch(t){console.error("[MultiSelect] Failed to parse initial values:",t)}}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){f.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ml__selected-popover--visible"),this.positionSelectedPopover()}hideSelectedPopover(){f.debug(`[${this.instanceId}] hideSelectedPopover() called`),this.showSelectedPopover=!1,this.selectedPopover.classList.remove("ml__selected-popover--visible"),this.selectedPopoverPlacement=null,this.selectedPopoverCleanup&&(this.selectedPopoverCleanup(),this.selectedPopoverCleanup=null)}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;this.selectedPopover.innerHTML=`
23
+ `}else this.pillsContainer.innerHTML="";this.attachPillTooltips()}attachEvents(){this.input.addEventListener("mousedown",e=>{e.stopPropagation(),this.isOpen?(this.justClosedViaClick=!0,this.close(),setTimeout(()=>{this.justClosedViaClick=!1},0)):this.open()}),this.input.addEventListener("focus",()=>{!this.isOpen&&!this.justClosedViaClick&&this.open()}),this.input.addEventListener("input",e=>{const t=e.target.value;this.options.isSearchEnabled&&!this.isOpen&&this.open(),this.handleSearch(t)}),this.input.addEventListener("keydown",e=>this.handleKeydown(e)),setTimeout(()=>{document.addEventListener("click",e=>this.handleClickOutside(e))},0),this.dropdown.addEventListener("click",e=>this.handleDropdownClick(e)),this.dropdown.addEventListener("wheel",e=>{if(this.virtualScroll)return;const t=e.currentTarget,l=t.scrollTop===0,o=t.scrollTop+t.clientHeight>=t.scrollHeight;(e.deltaY<0&&l||e.deltaY>0&&o)&&e.preventDefault(),e.stopPropagation()},{passive:!1}),this.pillsContainer.addEventListener("mousedown",e=>{e.target.closest(".ml__count-text")&&!this.showSelectedPopover&&e.stopPropagation()}),this.pillsContainer.addEventListener("click",e=>this.handlePillClick(e)),this.countBadge.addEventListener("mousedown",e=>{this.showSelectedPopover||e.stopPropagation()}),this.countBadge.addEventListener("click",e=>{e.stopPropagation(),this.toggleSelectedPopover()}),this.selectedPopover.addEventListener("click",e=>this.handleSelectedPopoverClick(e))}async handleSearch(e){if(this.searchTerm=e,!this.options.isSearchEnabled)return;let t=e;if(this.options.beforeSearchCallback){const l=this.options.beforeSearchCallback(e);if(l===null){k.debug(`[${this.instanceId}] beforeSearchCallback blocked search for term:`,e),this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.renderDropdown();return}t=l,t!==e&&k.debug(`[${this.instanceId}] beforeSearchCallback transformed: "${e}" -> "${t}"`)}if(this.options.searchCallback){if(t.length<this.options.minSearchLength){this.isLoading=!1,this.options.isKeepOptionsOnSearch?(this.filteredOptions=[...this.allOptions],k.debug(`[${this.instanceId}] Search term below minimum, showing ${this.allOptions.length} initial options`)):this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown();return}this.isLoading=!0,this.renderDropdown(),k.debug(`[${this.instanceId}] Loading data for search term:`,t);try{const l=await this.options.searchCallback(t);if(this.searchTerm===e){const o=l||[];this.filteredOptions=[...o],this.isLoading=!1,this.matchingIndices.clear(),this.focusedIndex=this.options.isSearchEnabled&&this.filteredOptions.length>0?0:-1,this.renderDropdown(),k.debug(`[${this.instanceId}] Loaded ${o.length} results`)}}catch(l){k.error(`[${this.instanceId}] Error loading data:`,l),this.isLoading=!1,this.options.isKeepOptionsOnSearch?this.filteredOptions=[...this.allOptions]:this.filteredOptions=[],this.matchingIndices.clear(),this.renderDropdown()}}else{if(!t)this.filteredOptions=[...this.allOptions],this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1;else{const l=this.options.searchMode||"filter",o=t.toLowerCase();if(l==="filter")this.filteredOptions=this.allOptions.filter(s=>this.getItemSearchValue(s).toLowerCase().includes(o)),this.matchingIndices.clear(),this.focusedIndex=this.filteredOptions.length>0?0:-1,k.debug(`[${this.instanceId}] Filter mode: ${this.filteredOptions.length} matches for "${t}"`);else{this.filteredOptions=[...this.allOptions],this.matchingIndices.clear();let s=-1;this.allOptions.forEach((n,r)=>{this.getItemSearchValue(n).toLowerCase().includes(o)&&(this.matchingIndices.add(r),s===-1&&(s=r))}),s>=0?(this.focusedIndex=s,k.debug(`[${this.instanceId}] Navigate mode: ${this.matchingIndices.size} matches, jumped to index ${s}`)):k.debug(`[${this.instanceId}] Navigate mode: No matches found, keeping previous focus`)}}this.renderDropdown(),this.options.searchMode==="navigate"&&this.focusedIndex>=0&&this.scrollToFocused()}}handleKeydown(e){if(!this.isOpen){(e.key==="Enter"||e.key==="ArrowDown")&&(e.preventDefault(),this.open());return}if(!this.options.isSearchEnabled){const t=e.key.length===1||e.key==="Backspace"||e.key==="Delete",l=["ArrowUp","ArrowDown","PageUp","PageDown","Home","End","Enter","Escape","Tab"].includes(e.key);if(t&&!l){e.preventDefault();return}}switch(e.key){case"ArrowDown":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusNextMatch():this.focusNext();break;case"ArrowUp":e.preventDefault(),e.ctrlKey||e.metaKey?this.focusPreviousMatch():this.focusPrevious();break;case"Enter":e.preventDefault(),this.focusedIndex>=0?this.toggleOption(this.filteredOptions[this.focusedIndex]):this.options.isAddNewAllowed&&this.options.addNewCallback&&this.input.value.trim()&&this.handleAddNew(this.input.value.trim());break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.close();break;case"PageUp":e.preventDefault(),this.focusPageUp();break;case"PageDown":e.preventDefault(),this.focusPageDown();break;case"Home":e.preventDefault(),this.focusFirst();break;case"End":e.preventDefault(),this.focusLast();break}}handleDropdownClick(e){S.debug(`[${this.instanceId}] Dropdown clicked`,{target:e.target.className}),e.stopPropagation();const t=e.target.closest("[data-action]");if(t){e.preventDefault();const o=t.dataset.action;S.debug(`[${this.instanceId}] Action button clicked:`,o),o==="select-all"?this.selectAll():o==="clear-all"&&this.clearAll();return}const l=e.target.closest(".ml__option");if(l&&!l.classList.contains("ml__option--disabled")){e.preventDefault();const o=l.dataset.value,s=this.filteredOptions.find(n=>String(this.getItemValue(n))===o);S.debug(`[${this.instanceId}] Option clicked:`,{value:o,closeOnSelect:this.options.isCloseOnSelect,placeholder:this.options.searchPlaceholder}),s&&this.toggleOption(s)}}handlePillClick(e){if(e.target.closest(".ml__count-clear")){e.preventDefault(),e.stopPropagation(),S.debug(`[${this.instanceId}] Count clear button clicked`),this.clearAll();return}if(e.target.closest(".ml__count-text")){e.preventDefault(),e.stopPropagation(),this.toggleSelectedPopover();return}const o=e.target.closest(".ml__pill-remove");if(o){if(e.preventDefault(),e.stopPropagation(),o.dataset.action==="remove-hidden"){S.debug(`[${this.instanceId}] Remove hidden items button clicked`);const a=this.options.pillsMaxVisible||3;Array.from(this.selectedOptions.values()).slice(a).forEach(m=>this.deselectOption(m));return}const n=o.dataset.value,r=this.selectedOptions.get(n);r&&this.deselectOption(r);return}if(e.target.closest(".ml__pill--more")&&!e.target.closest(".ml__pill-remove")){e.preventDefault(),e.stopPropagation(),S.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`),this.toggleSelectedPopover();return}}handleClickOutside(e){var o;const t=e.composedPath();if(this.showSelectedPopover&&!t.some(n=>n instanceof Node&&(this.selectedPopover.contains(n)||this.countBadge.contains(n)||n.closest&&n.closest(".ml__count-text")))){g.debug(`[${this.instanceId}] Closing selected popover due to click outside`),this.hideSelectedPopover();return}if(!this.isOpen)return;const l=t.some(s=>s instanceof Node&&(this.element.contains(s)||this.dropdown.contains(s)||this.hint&&this.hint.contains(s)));S.debug(`[${this.instanceId}] handleClickOutside`,{target:e.target.className,targetTag:e.target.tagName,clickedInside:l,pathLength:t.length,firstInPath:(o=t[0])==null?void 0:o.tagName,elementContains:t.some(s=>s instanceof Node&&this.element.contains(s)),dropdownContains:t.some(s=>s instanceof Node&&this.dropdown.contains(s)),isConnected:this.dropdown.isConnected}),l||(S.warn(`[${this.instanceId}] Closing dropdown due to click outside`),this.close())}focusNext(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+1),this.renderDropdown(),this.scrollToFocused())}focusPrevious(){this.filteredOptions.length!==0&&(this.focusedIndex=this.focusedIndex<=0?this.filteredOptions.length-1:this.focusedIndex-1,this.renderDropdown(),this.scrollToFocused())}focusFirst(){this.filteredOptions.length!==0&&(this.focusedIndex=0,this.renderDropdown(),this.scrollToFocused())}focusLast(){this.filteredOptions.length!==0&&(this.focusedIndex=this.filteredOptions.length-1,this.renderDropdown(),this.scrollToFocused())}focusNextMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((o,s)=>o-s),t=e.findIndex(o=>o===this.focusedIndex),l=(t+1)%e.length;this.focusedIndex=e[l],this.renderDropdown(),this.scrollToFocused(),S.debug(`[${this.instanceId}] Jumped to next match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPreviousMatch(){if(this.matchingIndices.size===0)return;const e=Array.from(this.matchingIndices).sort((o,s)=>o-s),t=e.findIndex(o=>o===this.focusedIndex),l=t<=0?e.length-1:t-1;this.focusedIndex=e[l],this.renderDropdown(),this.scrollToFocused(),S.debug(`[${this.instanceId}] Jumped to previous match: index ${this.focusedIndex} (${t+1} of ${e.length})`)}focusPageUp(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.max(0,this.focusedIndex-10),this.renderDropdown(),this.scrollToFocused())}focusPageDown(){this.filteredOptions.length!==0&&(this.focusedIndex=Math.min(this.filteredOptions.length-1,this.focusedIndex+10),this.renderDropdown(),this.scrollToFocused())}scrollToFocused(){if(this.virtualScroll&&this.focusedIndex>=0)this.virtualScroll.scrollToIndex(this.focusedIndex);else{const e=this.dropdown.querySelector(".ml__option--focused");e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}}toggleOption(e){const t=this.getItemValue(e),l=String(t);if(S.debug(`[${this.instanceId}] toggleOption called`,{value:t,multiple:this.options.isMultipleEnabled}),!this.options.isMultipleEnabled){this.selectedValues.has(l)?(S.debug(`[${this.instanceId}] Deselecting option in single-select mode`,{value:t}),this.deselectOption(e)):(S.debug(`[${this.instanceId}] Clearing previous selections and selecting new option`,{value:t}),this.selectedValues.clear(),this.selectedOptions.clear(),this.selectOption(e)),g.info(`[${this.instanceId}] ❌ Closing dropdown (single-select mode)`),this.close();return}this.selectedValues.has(l)?(S.debug(`[${this.instanceId}] Deselecting option`,{value:t}),this.deselectOption(e)):(S.debug(`[${this.instanceId}] Selecting option`,{value:t}),this.selectOption(e)),S.debug(`[${this.instanceId}] Checking closeOnSelect`,{closeOnSelect:this.options.isCloseOnSelect,willClose:this.options.isCloseOnSelect===!0,placeholder:this.options.searchPlaceholder}),this.options.isCloseOnSelect?(g.info(`[${this.instanceId}] ❌ Closing dropdown (closeOnSelect=true)`),this.close()):g.info(`[${this.instanceId}] ✅ Keeping dropdown open (closeOnSelect=false)`)}async handleAddNew(e){if(this.options.addNewCallback)try{k.debug(`[${this.instanceId}] Adding new option:`,e);const t=await this.options.addNewCallback(e);this.allOptions.push(t),this.filteredOptions.push(t),this.selectOption(t),this.input.value="",this.renderDropdown(),this.renderPills(),this.options.isCloseOnSelect&&this.close()}catch(t){k.error(`[${this.instanceId}] Error adding new option:`,t)}}selectOption(e){const t=this.getItemValue(e),l=String(t);this.selectedValues.add(l),this.selectedOptions.set(l,e),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.selectCallback&&this.options.selectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}deselectOption(e){const t=this.getItemValue(e),l=String(t);this.selectedValues.delete(l),this.selectedOptions.delete(l),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.deselectCallback&&this.options.deselectCallback(e),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}selectAll(){this.filteredOptions.forEach(e=>{if(!this.getItemDisabled(e)){const t=this.getItemValue(e),l=String(t);this.selectedValues.add(l),this.selectedOptions.set(l,e)}}),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}clearAll(){this.selectedValues.clear(),this.selectedOptions.clear(),this.renderDropdown(),this.renderPills(),this.updateHiddenInput(),this.options.changeCallback&&this.options.changeCallback(this.getSelected())}open(){g.debug(`[${this.instanceId}] open() called`,{isOpen:this.isOpen}),!this.isOpen&&(this.isOpen=!0,this.element.classList.add("ml--open"),this.dropdown.classList.add("ml__dropdown--visible"),g.info(`[${this.instanceId}] Dropdown opened`),this.input.placeholder=this.options.searchPlaceholder,!this.options.isMultipleEnabled&&this.options.isSearchEnabled&&(this.input.value=""),this.options.searchCallback&&this.options.isKeepOptionsOnSearch&&!this.searchTerm&&(this.filteredOptions=[...this.allOptions],g.debug(`[${this.instanceId}] Showing ${this.allOptions.length} initial options on open`)),this.renderDropdown(),this.positionDropdown(),this.hint&&(this.hint.classList.add("ml__hint--visible"),this.positionHint()))}close(){if(g.debug(`[${this.instanceId}] close() called`,{isOpen:this.isOpen}),!this.isOpen)return;this.isOpen=!1,this.element.classList.remove("ml--open"),this.dropdown.classList.remove("ml__dropdown--visible"),this.hint&&this.hint.classList.remove("ml__hint--visible"),this.searchTerm="";const e=this.options.isMultipleEnabled||this.options.isSearchEnabled;g.warn(`[${this.instanceId}] close() - input clearing decision`,{multiple:this.options.isMultipleEnabled,enableSearch:this.options.isSearchEnabled,willClearInput:e,currentInputValue:this.input.value}),e?(g.info(`[${this.instanceId}] 🧹 close() CLEARING input.value`),this.input.value=""):g.info(`[${this.instanceId}] 🔒 close() KEEPING input.value = "${this.input.value}"`),this.filteredOptions=[...this.allOptions],this.focusedIndex=-1,g.info(`[${this.instanceId}] 📞 close() CALLING renderPills()`),this.renderPills(),g.info(`[${this.instanceId}] ✅ close() AFTER renderPills(), input.value = "${this.input.value}"`),this.dropdownCleanup&&(this.dropdownCleanup(),this.dropdownCleanup=null),this.hintCleanup&&(this.hintCleanup(),this.hintCleanup=null),this.dropdownPlacement=null,g.info(`[${this.instanceId}] Dropdown closed. Stack trace:`),g.trace()}positionDropdown(){this.dropdownCleanup=ue(this.input,this.dropdown,()=>{const e=this.options.isPlacementLocked&&this.dropdownPlacement?this.dropdownPlacement:"bottom-start",t=[fe(4),...this.options.isPlacementLocked&&this.dropdownPlacement?[]:[Ae()],ge({padding:8})];be(this.input,this.dropdown,{placement:e,middleware:t}).then(({x:l,y:o,placement:s})=>{this.options.isPlacementLocked&&!this.dropdownPlacement&&(this.dropdownPlacement=s,g.debug(`[${this.instanceId}] Locked dropdown placement:`,s));const n={left:`${l}px`,top:`${o}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(n.minWidth=this.options.dropdownMinWidth),Object.assign(this.dropdown.style,n),this.hint&&this.isOpen&&this.positionHint()})})}positionHint(){this.hint&&(this.hintCleanup&&this.hintCleanup(),this.hintCleanup=ue(this.input,this.hint,()=>{let e="top-start";this.dropdownPlacement&&(this.dropdownPlacement.startsWith("bottom")?e=this.dropdownPlacement.replace("bottom","top"):this.dropdownPlacement.startsWith("top")&&(e=this.dropdownPlacement.replace("top","bottom"))),be(this.input,this.hint,{placement:e,middleware:[fe(4),ge({padding:8})]}).then(({x:t,y:l})=>{Object.assign(this.hint.style,{left:`${t}px`,top:`${l}px`})})}))}parseInitialSelection(){const e=this.element.dataset.initialValues;if(e)try{JSON.parse(e).forEach(l=>{const o=String(l);this.selectedValues.add(o);const s=this.allOptions.find(n=>String(this.getItemValue(n))===o);s&&this.selectedOptions.set(o,s)}),this.renderPills()}catch(t){k.error(`[${this.instanceId}] Failed to parse initial values:`,t)}}toggleSelectedPopover(){this.showSelectedPopover?this.hideSelectedPopover():this.showPopover()}showPopover(){g.debug(`[${this.instanceId}] showPopover() called`),this.isOpen&&this.close(),this.showSelectedPopover=!0,this.renderSelectedPopover(),this.selectedPopover.classList.add("ml__selected-popover--visible"),this.positionSelectedPopover()}hideSelectedPopover(){g.debug(`[${this.instanceId}] hideSelectedPopover() called`),this.showSelectedPopover=!1,this.selectedPopover.classList.remove("ml__selected-popover--visible"),this.selectedPopoverPlacement=null,this.selectedPopoverCleanup&&(this.selectedPopoverCleanup(),this.selectedPopoverCleanup=null)}renderSelectedPopover(){const e=Array.from(this.selectedOptions.values()),t=this.selectedValues.size;this.selectedPopover.innerHTML=`
24
24
  <div class="ml__selected-popover-header">
25
25
  <span>Selected Items (${t})</span>
26
26
  <button type="button" class="ml__selected-popover-close" aria-label="Close">&times;</button>
@@ -33,14 +33,14 @@
33
33
  </div>
34
34
  `}).join("")}
35
35
  </div>
36
- `}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".ml__selected-popover-close")){e.preventDefault(),this.hideSelectedPopover();return}const l=e.target.closest(".ml__pill-remove");if(l){e.preventDefault();const o=l.dataset.value,s=this.selectedOptions.get(o);s&&(this.deselectOption(s),this.renderSelectedPopover(),this.selectedValues.size===0&&this.hideSelectedPopover())}}positionSelectedPopover(){this.selectedPopoverCleanup=re(this.input,this.selectedPopover,()=>{const e=this.selectedPopoverPlacement||"bottom-start";de(this.input,this.selectedPopover,{placement:e,middleware:[ae(4),...this.selectedPopoverPlacement?[]:[ve()],ce({padding:8})]}).then(({x:t,y:l,placement:o})=>{this.selectedPopoverPlacement||(this.selectedPopoverPlacement=o,f.debug(`[${this.instanceId}] Locked popover placement:`,o));const s={left:`${t}px`,top:`${l}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(s.minWidth=this.options.dropdownMinWidth),Object.assign(this.selectedPopover.style,s)})})}updateHiddenInput(){if(!this.options.formFieldId)return;this.hiddenInputs.forEach(o=>o.remove()),this.hiddenInputs=[];const e=this.options.valueFormat||"json",t=Array.from(this.selectedOptions.values()).map(o=>this.getItemValue(o)),l=this.options.hostElement||this.element;if(e==="array")t.forEach(o=>{const s=document.createElement("input");s.type="hidden",s.name=`${this.options.formFieldId}[]`,s.value=String(o),l.appendChild(s),this.hiddenInputs.push(s)});else{const o=document.createElement("input");o.type="hidden",o.name=this.options.formFieldId,o.id=this.options.formFieldId,o.value=this.getFormValue(),l.appendChild(o),this.hiddenInputs.push(o)}}getFormValue(){const e=Array.from(this.selectedOptions.values()).map(l=>this.getItemValue(l));return this.options.getValueFormatCallback?this.options.getValueFormatCallback(e):(this.options.valueFormat||"json")==="csv"?e.join(","):JSON.stringify(e)}getSelected(){return Array.from(this.selectedOptions.values())}setSelected(e){this.selectedValues=new Set(e.map(t=>String(t))),this.selectedOptions.clear(),e.forEach(t=>{const l=String(t),o=this.allOptions.find(s=>String(this.getItemValue(s))===l);o&&this.selectedOptions.set(l,o)}),this.renderDropdown(),this.renderPills(),this.updateHiddenInput()}get selectedItem(){return this.selectedOptions.size===0?null:Array.from(this.selectedOptions.values())[0]}get selectedValue(){if(!this.options.valueMember&&!this.options.getValueCallback)return null;if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}getValue(){if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}attachPillTooltips(){if(!this.options.isPillTooltipsEnabled){console.log("[Tooltips] Disabled - isPillTooltipsEnabled is false");return}const e=this.pillsContainer.querySelectorAll(".ml__pill:not(.ml__pill--more)");console.log(`[Tooltips] Found ${e.length} pills to attach tooltips to`),e.forEach(l=>{const o=l,s=o.querySelector(".ml__pill-remove");if(!s)return;const n=s.dataset.value,r=this.selectedOptions.get(n);if(!r)return;const a=o.querySelector(".ml__pill-text");a&&this.createTooltipForElement(a,r,n);const c=this.getItemPillDisplayValue(r);this.createRemoveButtonTooltip(s,c,n)});const t=this.pillsContainer.querySelector(".ml__pill--more");if(t){const l=t.querySelector(".ml__pill-remove");if(l&&l.dataset.action==="remove-hidden"){const o=this.options.pillsMaxVisible||3,n=Array.from(this.selectedOptions.values()).length-o;this.createRemoveButtonTooltip(l,`${n} hidden items`,"more-badge-remove")}}}createTooltipForElement(e,t,l){const o=document.createElement("div");o.className="ml__pill-tooltip";let s;if(this.options.getPillTooltipCallback)s=this.options.getPillTooltipCallback(t),console.log("[Tooltips] Using custom callback for tooltip content");else{const d=this.getItemPillDisplayValue(t),m=this.getItemSubtitle(t);s=m?`${d}
37
- ${m}`:d,console.log(`[Tooltips] Using default content: "${s}"`)}typeof s=="string"?o.textContent=s:o.appendChild(s),(this.options.container||document.body).appendChild(o),console.log(`[Tooltips] Tooltip element created and appended for "${l}"`),this.pillTooltips.set(l,o);let r,a;const c=()=>{clearTimeout(a),console.log(`[Tooltips] Mouse entered pill "${l}", will show tooltip in ${this.options.pillTooltipDelay||300}ms`),r=window.setTimeout(()=>{console.log(`[Tooltips] Showing tooltip for "${l}"`),o.classList.add("ml__pill-tooltip--visible"),this.positionPillTooltip(e,o,l)},this.options.pillTooltipDelay||300)},p=()=>{clearTimeout(r),a=window.setTimeout(()=>{o.classList.remove("ml__pill-tooltip--visible"),this.cleanupPillTooltip(l)},100)};e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",p)}createRemoveButtonTooltip(e,t,l){const o=document.createElement("div");o.className="ml__pill-tooltip",o.textContent=`Remove ${t}`,(this.options.container||document.body).appendChild(o);const n=`${l}-remove`;this.pillTooltips.set(n,o);let r,a;const c=()=>{clearTimeout(a);const d=this.pillTooltips.get(l);d&&d.classList.remove("ml__pill-tooltip--visible"),r=window.setTimeout(()=>{o.classList.add("ml__pill-tooltip--visible"),this.positionPillTooltip(e,o,n)},this.options.pillTooltipDelay||300)},p=()=>{clearTimeout(r),a=window.setTimeout(()=>{o.classList.remove("ml__pill-tooltip--visible"),this.cleanupPillTooltip(n)},100)};e.addEventListener("mouseenter",c),e.addEventListener("mouseleave",p)}positionPillTooltip(e,t,l){const o=re(e,t,()=>{de(e,t,{placement:this.options.pillTooltipPlacement||"top",strategy:"fixed",middleware:[ae(this.options.pillTooltipOffset||8),ve(),ce({padding:8})]}).then(({x:s,y:n})=>{Object.assign(t.style,{left:`${s}px`,top:`${n}px`}),console.log(`[Tooltips] Positioned tooltip "${l}" at x:${s}, y:${n}`,{placement:this.options.pillTooltipPlacement||"top",tooltipClasses:t.className,tooltipDisplay:window.getComputedStyle(t).display,tooltipOpacity:window.getComputedStyle(t).opacity,tooltipVisibility:window.getComputedStyle(t).visibility,tooltipZIndex:window.getComputedStyle(t).zIndex,tooltipPosition:window.getComputedStyle(t).position})})});this.pillTooltipCleanups.set(l,o)}cleanupPillTooltip(e){const t=this.pillTooltipCleanups.get(e);t&&(t(),this.pillTooltipCleanups.delete(e))}destroyAllPillTooltips(){this.pillTooltipCleanups.forEach(e=>e()),this.pillTooltipCleanups.clear(),this.pillTooltips.forEach(e=>e.remove()),this.pillTooltips.clear()}destroy(){this.destroyAllPillTooltips(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),this.dropdown&&this.dropdown.remove(),this.hint&&this.hint.remove(),this.selectedPopover&&this.selectedPopover.remove(),this.element.innerHTML="",this.element.classList.remove("ml","ml--open","ml--no-checkboxes"),console.log("[MultiSelect] Destroyed")}}const Lt='@charset "UTF-8";multi-select:not(:defined){display:block;min-height:2.5rem;color:transparent!important;background:transparent}.ml-wrapper{display:flex;flex-direction:column;align-items:stretch}.ml-wrapper--inline{flex-direction:row;align-items:flex-start}.ml{position:relative;width:100%}.ml__input-wrapper{position:relative;display:flex;align-items:center}.ml__input{width:100%;padding:var(--ml-input-padding, .5rem .75rem);padding-right:var(--ml-input-padding-right, 2.5rem);font-size:var(--ml-input-font-size, .875rem);border:var(--ml-input-border-style, 1px solid #d1d5db);border-radius:var(--ml-input-border-radius, .375rem);background:var(--ml-input-bg, #ffffff);color:var(--ml-input-text, #111827);cursor:pointer;transition:border-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__input:focus{outline:none;border-color:var(--ml-input-focus-border-color, #3b82f6)}.ml__input::placeholder{color:var(--ml-input-placeholder-color, #6b7280);opacity:0;transition:opacity var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}:host([data-ready]) .ml__input::placeholder{opacity:var(--ml-placeholder-opacity, .6)}.ml__toggle{position:absolute;right:var(--ml-toggle-right, .75rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));pointer-events:none;color:var(--ml-toggle-color, #6b7280);transition:transform var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml--open .ml__toggle{transform:var(--ml-transform-center-y, translateY(-50%)) rotate(var(--ml-transform-rotate-180, 180deg))}.ml__count-badge{position:absolute;right:var(--ml-count-badge-offset, 2rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));padding:var(--ml-count-badge-padding, .125rem .25rem);background:var(--ml-count-badge-bg, #3b82f6);color:var(--ml-count-badge-color, #ffffff);font-size:var(--ml-count-badge-font-size, .75rem);font-weight:var(--ml-count-badge-font-weight, 600);border-radius:var(--ml-count-badge-border-radius, .25rem);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge:hover{background:var(--ml-count-badge-bg-hover, #2563eb);transform:var(--ml-transform-center-y, translateY(-50%)) scale(var(--ml-transform-scale-hover, 1.1))}.ml__hint{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);padding:var(--ml-hint-padding, .5rem .75rem);background:var(--ml-hint-bg, #ffffff);border:var(--ml-hint-border, 1px solid #e5e7eb);border-radius:var(--ml-hint-border-radius, .375rem);box-shadow:var(--ml-hint-box-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));font-size:var(--ml-hint-font-size, .75rem);color:var(--ml-hint-color, #6b7280);line-height:var(--ml-line-height-relaxed, 1.4);max-width:100%}.ml__hint--visible{display:block}.ml__dropdown{display:none;position:absolute;z-index:var(--ml-z-index-dropdown, 9999);background:var(--ml-dropdown-bg, #ffffff);border:var(--ml-dropdown-border, 1px solid #e5e7eb);border-radius:var(--ml-dropdown-border-radius, .375rem);box-shadow:var(--ml-dropdown-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));max-height:var(--ml-dropdown-max-height, 20rem);overflow-y:auto;color:var(--ml-dropdown-color, #111827)}.ml__dropdown--visible{display:block}.ml__actions{display:flex;gap:var(--ml-actions-gap, .25rem);padding:var(--ml-actions-padding, .5rem);border-bottom:var(--ml-actions-border-bottom, 1px solid #e5e7eb)}.ml__actions--sticky{position:sticky;top:0;z-index:var(--ml-z-index-sticky, 1);background:var(--ml-actions-bg, #ffffff)}.ml__action-btn{flex:1;padding:var(--ml-action-btn-padding, .25rem .5rem);font-size:var(--ml-action-btn-font-size, .75rem);border:var(--ml-action-btn-border, 1px solid #e5e7eb);border-radius:var(--ml-action-btn-border-radius, .25rem);background:var(--ml-action-btn-bg, transparent);color:var(--ml-action-btn-color, inherit);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__action-btn:hover{background:var(--ml-action-btn-bg-hover, #f3f4f6);border-color:var(--ml-action-btn-border-color-hover, #3b82f6)}.ml__action-btn:active{transform:scale(var(--ml-transform-scale-active, .98))}.ml__options{padding:var(--ml-options-padding, .25rem 0)}.ml__group+.ml__group{border-top:var(--ml-group-border-top, 1px solid #e5e7eb);margin-top:var(--ml-group-margin-top, .25rem);padding-top:var(--ml-group-padding-top, .25rem)}.ml__group-label{padding:var(--ml-group-label-padding, .25rem .75rem);font-size:var(--ml-group-label-font-size, .75rem);font-weight:var(--ml-group-label-font-weight, 600);color:var(--ml-group-label-color, #6b7280);text-transform:var(--ml-group-label-transform, uppercase);letter-spacing:var(--ml-group-label-letter-spacing, .05em)}.ml__option{display:flex;align-items:flex-start;gap:var(--ml-option-gap, .5rem);padding:var(--ml-option-padding, .5rem .75rem);cursor:pointer;transition:background-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__option:hover{background:var(--ml-option-bg-hover, #f9fafb)}.ml__option--focused{background:var(--ml-option-bg-focused, #f9fafb);outline:var(--ml-option-outline-focused, 2px solid #3b82f6);outline-offset:var(--ml-option-focus-outline-offset, -2px)}.ml__option--selected{background:var(--ml-option-bg-selected, rgba(59, 130, 246, .1))}.ml__option--disabled{opacity:var(--ml-disabled-opacity, .5);cursor:not-allowed}.ml__option--disabled:hover{background:var(--ml-option-bg, transparent)}.ml__checkbox{flex-shrink:0;margin-top:var(--ml-checkbox-margin-top, .125rem);cursor:pointer}.ml__option--disabled .ml__checkbox{cursor:not-allowed}.ml__option-content{flex:1;display:flex;align-items:flex-start;gap:var(--ml-option-content-gap, .5rem);min-width:0}.ml__option-icon{flex-shrink:0;width:var(--ml-option-icon-size, 1.25rem);height:var(--ml-option-icon-size, 1.25rem);display:flex;align-items:center;justify-content:center;font-size:var(--ml-option-icon-font-size, 1rem)}.ml__option-icon svg{width:100%;height:100%;fill:currentColor}.ml__option-text{flex:1;min-width:0}.ml__option-title{font-size:var(--ml-option-title-font-size, .875rem);color:var(--ml-option-title-color, inherit);line-height:var(--ml-line-height-relaxed, 1.4)}.ml__option-title mark{background:var(--ml-option-mark-bg, rgba(59, 130, 246, .2));color:var(--ml-option-mark-color, inherit);font-weight:var(--ml-option-mark-font-weight, 600)}.ml__option-subtitle{margin-top:var(--ml-option-subtitle-margin-top, .25rem);font-size:var(--ml-option-subtitle-font-size, .75rem);color:var(--ml-option-subtitle-color, #6b7280);line-height:var(--ml-option-subtitle-line-height, 1.3)}.ml__empty{padding:var(--ml-empty-padding, 1rem .75rem);text-align:center;font-size:var(--ml-empty-font-size, .875rem);color:var(--ml-empty-color, #6b7280)}.ml__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ml-loader-padding, 1rem);gap:var(--ml-loader-gap, .5rem)}.ml__loading-text{font-size:var(--ml-loading-text-font-size, .875rem);color:var(--ml-loading-text-color, #6b7280)}.ml__pills{display:flex;flex-wrap:wrap;gap:var(--ml-pills-gap, .5rem);padding:0}.ml__pills:empty{display:none}.ml__pills--bottom{margin-top:var(--ml-pills-margin-bottom, .5rem)}.ml__pills--top{margin-bottom:var(--ml-pills-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__pills--left{order:var(--ml-order-first, -1);margin-right:var(--ml-pills-margin-left, .25rem);justify-content:flex-end}.ml__pills--right{margin-left:var(--ml-pills-margin-right, .25rem);justify-content:flex-start}.ml__count-display{display:flex;align-items:center}.ml__count-display:empty{display:none}.ml__count-display--bottom{margin-top:var(--ml-count-display-margin-bottom, .5rem)}.ml__count-display--top{margin-bottom:var(--ml-count-display-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__count-display--left{order:var(--ml-order-first, -1);margin-right:var(--ml-count-display-margin-left, .5rem);justify-content:flex-start}.ml__count-display--right{margin-left:var(--ml-count-display-margin-right, .5rem);justify-content:flex-end}.ml__count-badge-wrapper{display:inline-flex;align-items:center;gap:var(--ml-count-badge-wrapper-gap, .25rem);background:var(--ml-count-badge-wrapper-bg, transparent);border:var(--ml-count-badge-wrapper-border, 1px solid #e5e7eb);border-radius:var(--ml-count-badge-wrapper-border-radius, .25rem);padding:var(--ml-count-badge-wrapper-padding, .25rem .5rem);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge-wrapper:hover{background:var(--ml-count-badge-wrapper-bg-hover, #f9fafb);border-color:var(--ml-count-badge-wrapper-border-color-hover, #3b82f6)}.ml__count-text{display:inline-flex;align-items:center;background:var(--ml-count-text-bg, transparent);border:var(--ml-count-text-border, none);padding:0;font-size:var(--ml-count-text-font-size, .875rem);color:var(--ml-count-text-color, #111827);cursor:pointer;transition:color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ml-count-clear-size, 1rem);height:var(--ml-count-clear-size, 1rem);padding:0;border:none;background:var(--ml-count-clear-bg, transparent);color:var(--ml-count-clear-color, #6b7280);font-size:var(--ml-count-clear-font-size, 1.125rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-count-clear-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear:hover{background:var(--ml-count-clear-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-count-clear-color-hover, #3b82f6)}.ml__count-clear:before{content:var(--ml-icon-clear, "×")}.ml__pill{display:inline-flex;align-items:center;height:var(--ml-pill-height, 1.5rem);font-size:var(--ml-pill-font-size, .75rem);font-weight:var(--ml-pill-font-weight, 600);line-height:var(--ml-line-height-none, 1);border-radius:var(--ml-pill-border-radius, .375rem);overflow:hidden;max-width:100%}.ml__pill-text{display:flex;align-items:center;height:100%;padding:var(--ml-pill-text-padding, 0 .5rem);background:var(--ml-pill-text-bg, #eff6ff);color:var(--ml-pill-text-color, #3b82f6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ml-transition-normal, .2s) ease}.ml__pill-remove{display:flex;align-items:center;justify-content:center;width:var(--ml-pill-remove-width, 1.5rem);height:100%;flex-shrink:0;background:var(--ml-pill-remove-bg, #3b82f6);color:var(--ml-pill-remove-color, #ffffff);border:var(--ml-pill-remove-border, none);cursor:pointer;transition:background-color var(--ml-transition-normal, .2s) ease;font-size:var(--ml-pill-remove-font-size, .75rem)}.ml__pill-remove:hover{background:var(--ml-pill-remove-bg-hover, #2563eb)}.ml__pill-remove:focus{outline:none;box-shadow:var(--ml-pill-remove-box-shadow-focus, 0 0 0 2px rgba(59, 130, 246, .5))}.ml__pill-remove:before{content:var(--ml-icon-remove, "×");font-size:var(--ml-font-size-base, 1rem);line-height:var(--ml-line-height-none, 1)}.ml__pill--more{cursor:pointer}.ml__pill--more .ml__pill-text{background:var(--ml-more-badge-bg, #eff6ff);font-weight:var(--ml-pill-font-weight, 600)}.ml__pill--more:hover .ml__pill-text{background:var(--ml-more-badge-hover-bg, #ffffff)}.ml__pill--more:active .ml__pill-text{background:var(--ml-more-badge-active-bg, #e0f2fe)}.ml__pill-tooltip{position:fixed;z-index:var(--ml-tooltip-z-index, 10000);opacity:0;visibility:hidden;transition:opacity var(--ml-transition-normal, .2s) ease,visibility var(--ml-transition-normal, .2s) ease;background:var(--ml-tooltip-bg, #333);color:var(--ml-tooltip-color, #fff);padding:var(--ml-tooltip-padding, .5rem .75rem);border-radius:var(--ml-tooltip-border-radius, .375rem);font-size:var(--ml-tooltip-font-size, .875rem);line-height:var(--ml-line-height-relaxed, 1.4);max-width:var(--ml-tooltip-max-width, 20rem);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ml-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, .15));pointer-events:none}.ml__pill-tooltip--visible{opacity:1;visibility:visible}.ml__selected-popover{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);background:var(--ml-selected-popover-bg, #ffffff);border:var(--ml-selected-popover-border, 1px solid #e5e7eb);border-radius:var(--ml-selected-popover-border-radius, .375rem);box-shadow:var(--ml-selected-popover-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));width:var(--ml-selected-popover-width, 20rem);max-height:var(--ml-selected-popover-max-height, 20rem);overflow:hidden}.ml__selected-popover--visible{display:flex;flex-direction:column}.ml__selected-popover-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ml-selected-popover-header-padding, .5rem .75rem);background:var(--ml-selected-popover-header-bg, rgba(59, 130, 246, .1));border-bottom:var(--ml-selected-popover-header-border-bottom, 1px solid #e5e7eb);font-size:var(--ml-selected-popover-header-font-size, .875rem);font-weight:var(--ml-selected-popover-header-font-weight, 600);color:var(--ml-selected-popover-header-color, #111827)}.ml__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ml-popover-close-size, 1.5rem);height:var(--ml-popover-close-size, 1.5rem);padding:0;border:none;background:var(--ml-selected-popover-close-bg, transparent);color:var(--ml-selected-popover-close-color, #6b7280);font-size:var(--ml-selected-popover-close-font-size, 1.25rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-selected-popover-close-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__selected-popover-close:hover{background:var(--ml-selected-popover-close-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-selected-popover-close-color-hover, #3b82f6)}.ml__selected-popover-body{display:flex;flex-direction:column;gap:var(--ml-selected-popover-body-gap, .25rem);padding:var(--ml-selected-popover-body-padding, .5rem);overflow-y:auto;max-height:var(--ml-selected-popover-body-max-height, 18rem)}.ml__selected-popover-body .ml__pill{width:100%}.ml__selected-popover-body .ml__pill-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.ml--rtl .ml__input-wrapper{direction:rtl}.ml--rtl .ml__input{text-align:right;padding-left:var(--ml-input-padding-right, 2.5rem);padding-right:var(--ml-input-padding-h, .75rem)}.ml--rtl .ml__toggle{left:var(--ml-toggle-right, .75rem)!important;right:auto!important}.ml--rtl .ml__count-badge{left:var(--ml-count-badge-offset, 2rem)!important;right:auto!important}.ml--rtl .ml__dropdown{direction:rtl;text-align:right}.ml--rtl .ml__option{flex-direction:row-reverse}.ml--rtl .ml__checkbox{margin-left:var(--ml-spacing-sm, .5rem);margin-right:0}.ml--rtl .ml__option-content{text-align:right}.ml--rtl .ml__option-icon{margin-left:var(--ml-spacing-xs, .25rem);margin-right:0}.ml--rtl .ml__pills{direction:rtl}.ml--rtl .ml__pill{flex-direction:row-reverse}.ml--rtl .ml__pill-remove{border-radius:var(--ml-pill-remove-border-radius-rtl, .375rem) 0 0 var(--ml-pill-remove-border-radius-rtl, .375rem);border-left:var(--ml-pill-remove-border, none);border-right:none}.ml--rtl .ml__pill-text{border-radius:0 var(--ml-pill-text-border-radius-rtl, .375rem) var(--ml-pill-text-border-radius-rtl, .375rem) 0}.ml--rtl .ml__count-display{direction:rtl}.ml--rtl .ml__count-badge-wrapper{flex-direction:row-reverse}.ml--rtl .ml__selected-popover{direction:rtl;text-align:right}.ml--rtl .ml__actions{direction:rtl}.ml--rtl .ml__group-label,.ml--rtl .ml__empty{text-align:right}.ml--rtl .ml__hint{direction:rtl;text-align:right}.ml--xs .ml__input{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__option{padding:var(--ml-spacing-xs, .25rem) var(--ml-spacing-sm, .5rem)}.ml--xs .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__pill{font-size:var(--ml-font-size-2xs, .625rem)}.ml--sm .ml__input,.ml--sm .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--lg .ml__input,.ml--lg .ml__option-title{font-size:var(--ml-font-size-base, 1rem)}.ml--lg .ml__pill{font-size:var(--ml-font-size-sm, .875rem)}.ml--xl .ml__input,.ml--xl .ml__option-title{font-size:var(--ml-font-size-lg, 1.125rem)}.ml--xl .ml__pill{font-size:var(--ml-font-size-base, 1rem)}.ml--disabled .ml__input{opacity:var(--ml-disabled-input-opacity, .6);cursor:not-allowed;background:var(--ml-input-bg-disabled, rgba(107, 114, 128, .05))}.ml--disabled .ml__toggle{opacity:var(--ml-disabled-input-opacity, .6)}.ml--no-checkboxes .ml__option{gap:0;padding-left:var(--ml-option-padding-h, .75rem)}.ml--no-checkboxes .ml__option-content{padding-left:0}.ml-debug-info{margin-top:.25rem;padding:.25rem;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:.375rem;font-size:.75rem;color:#111827}.ml-debug-info details summary{cursor:pointer;font-weight:600;color:#2563eb;-webkit-user-select:none;user-select:none;padding:.25rem;border-radius:.25rem}.ml-debug-info details summary:hover{background-color:#f3f4f6}.ml-debug-info details summary:focus{outline:2px solid #3b82f6;outline-offset:2px}.ml-debug-info .ml-debug-stats{display:flex;flex-direction:column;gap:.25rem;margin-top:.25rem;padding:.25rem;background-color:#fff;border-radius:.25rem}.ml-debug-info .ml-debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:.625rem}.ml-debug-info .ml-debug-stats span:before{content:"•";margin-right:.25rem;color:#3b82f6}',zt=typeof HTMLElement<"u"?HTMLElement:class{},we=new Set;function We(){return Array.from(we)}class _e extends zt{constructor(){super();h(this,"picker");h(this,"containerElement");h(this,"shadow");h(this,"_options");h(this,"_valueMember");h(this,"_getValueCallback");h(this,"_displayValueMember");h(this,"_getDisplayValueCallback");h(this,"_getPillDisplayCallback");h(this,"_searchValueMember");h(this,"_getSearchValueCallback");h(this,"_iconMember");h(this,"_getIconCallback");h(this,"_subtitleMember");h(this,"_getSubtitleCallback");h(this,"_groupMember");h(this,"_getGroupCallback");h(this,"_disabledMember");h(this,"_getDisabledCallback");h(this,"_getValueFormatCallback");h(this,"_getPillTooltipCallback");h(this,"_getCountPillCallback");h(this,"_searchCallback");h(this,"_addNewCallback");h(this,"_selectCallback");h(this,"_deselectCallback");h(this,"_changeCallback");this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=Lt,this.shadow.appendChild(t),requestAnimationFrame(()=>{this.setAttribute("data-ready","")})}static get observedAttributes(){return["search-hint","search-placeholder","multiple","allow-groups","allow-select-all","allow-clear-all","show-checkboxes","sticky-actions","close-on-select","lock-placement","dropdown-min-width","pills-display-mode","pills-threshold","pills-max-visible","pills-threshold-mode","pills-position","show-count-badge","max-height","empty-message","loading-message","min-search-length","enable-search","search-input-mode","allow-add-new","initial-values","value-member","display-value-member","search-value-member","icon-member","subtitle-member","group-member","disabled-member","name","value-format","enable-pill-tooltips","pill-tooltip-placement","show-debug-info"]}connectedCallback(){we.add(this),this.render(),this.initializePicker()}disconnectedCallback(){we.delete(this),this.picker&&this.picker.destroy()}attributeChangedCallback(t,l,o){l!==o&&this.picker&&t!=="initial-values"&&(this.picker.destroy(),this.initializePicker())}render(){this.containerElement=document.createElement("div"),this.containerElement.setAttribute("data-multiselect",""),this.className&&(this.containerElement.className=this.className),this.shadow.appendChild(this.containerElement),this.getAttribute("show-debug-info")==="true"&&this.renderDebugInfo()}renderDebugInfo(){const t=this.shadow.querySelector(".ml-debug-info");t&&t.remove();const l=document.createElement("div");l.className="ml-debug-info";const o=document.createElement("details"),s=document.createElement("summary");s.textContent="Debug Info";const n=document.createElement("div");n.className="ml-debug-stats",o.appendChild(s),o.appendChild(n),l.appendChild(o),this.shadow.appendChild(l),this.updateDebugInfo()}updateDebugInfo(){var u,g;const t=this.shadow.querySelector(".ml-debug-stats");if(!t||!this.picker)return;const l="1.0.0-rc04",o=We().length,n=this.picker.getSelected().length,r=((u=this._options)==null?void 0:u.length)||0,a=this.picker,c=a.isOpen||!1,p=a.searchTerm||"",d=a.isLoading||!1,m=((g=a.filteredOptions)==null?void 0:g.length)||0;t.innerHTML=`
36
+ `}handleSelectedPopoverClick(e){if(e.stopPropagation(),e.target.closest(".ml__selected-popover-close")){e.preventDefault(),this.hideSelectedPopover();return}const l=e.target.closest(".ml__pill-remove");if(l){e.preventDefault();const o=l.dataset.value,s=this.selectedOptions.get(o);s&&(this.deselectOption(s),this.renderSelectedPopover(),this.selectedValues.size===0&&this.hideSelectedPopover())}}positionSelectedPopover(){this.selectedPopoverCleanup=ue(this.input,this.selectedPopover,()=>{const e=this.selectedPopoverPlacement||"bottom-start";be(this.input,this.selectedPopover,{placement:e,middleware:[fe(4),...this.selectedPopoverPlacement?[]:[Ae()],ge({padding:8})]}).then(({x:t,y:l,placement:o})=>{this.selectedPopoverPlacement||(this.selectedPopoverPlacement=o,g.debug(`[${this.instanceId}] Locked popover placement:`,o));const s={left:`${t}px`,top:`${l}px`,width:`${this.input.offsetWidth}px`};this.options.dropdownMinWidth&&(s.minWidth=this.options.dropdownMinWidth),Object.assign(this.selectedPopover.style,s)})})}updateHiddenInput(){if(!this.options.formFieldId)return;this.hiddenInputs.forEach(o=>o.remove()),this.hiddenInputs=[];const e=this.options.valueFormat||"json",t=Array.from(this.selectedOptions.values()).map(o=>this.getItemValue(o)),l=this.options.hostElement||this.element;if(e==="array")t.forEach(o=>{const s=document.createElement("input");s.type="hidden",s.name=`${this.options.formFieldId}[]`,s.value=String(o),l.appendChild(s),this.hiddenInputs.push(s)});else{const o=document.createElement("input");o.type="hidden",o.name=this.options.formFieldId,o.id=this.options.formFieldId,o.value=this.getFormValue(),l.appendChild(o),this.hiddenInputs.push(o)}}getFormValue(){const e=Array.from(this.selectedOptions.values()).map(l=>this.getItemValue(l));return this.options.getValueFormatCallback?this.options.getValueFormatCallback(e):(this.options.valueFormat||"json")==="csv"?e.join(","):JSON.stringify(e)}getSelected(){return Array.from(this.selectedOptions.values())}setSelected(e){this.selectedValues=new Set(e.map(t=>String(t))),this.selectedOptions.clear(),e.forEach(t=>{const l=String(t),o=this.allOptions.find(s=>String(this.getItemValue(s))===l);o&&this.selectedOptions.set(l,o)}),this.renderDropdown(),this.renderPills(),this.updateHiddenInput()}get selectedItem(){return this.selectedOptions.size===0?null:Array.from(this.selectedOptions.values())[0]}get selectedValue(){if(!this.options.valueMember&&!this.options.getValueCallback)return null;if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}getValue(){if(this.selectedOptions.size===0)return this.options.isMultipleEnabled?[]:null;const e=Array.from(this.selectedOptions.values()).map(t=>this.getItemValue(t));return this.options.isMultipleEnabled?e:e[0]??null}attachPillTooltips(){if(!this.options.isPillTooltipsEnabled){g.debug(`[${this.instanceId}] Tooltips disabled - isPillTooltipsEnabled is false`);return}const e=this.pillsContainer.querySelectorAll(".ml__pill:not(.ml__pill--more)");g.debug(`[${this.instanceId}] Found ${e.length} pills to attach tooltips to`),e.forEach(l=>{const o=l,s=o.querySelector(".ml__pill-remove");if(!s)return;const n=s.dataset.value,r=this.selectedOptions.get(n);if(!r)return;const a=o.querySelector(".ml__pill-text");a&&this.createTooltipForElement(a,r,n);const d=this.getItemPillDisplayValue(r);this.createRemoveButtonTooltip(s,d,n)});const t=this.pillsContainer.querySelector(".ml__pill--more");if(t){const l=t.querySelector(".ml__pill-remove");if(l&&l.dataset.action==="remove-hidden"){const o=this.options.pillsMaxVisible||3,n=Array.from(this.selectedOptions.values()).length-o;this.createRemoveButtonTooltip(l,`${n} hidden items`,"more-badge-remove")}}}createTooltipForElement(e,t,l){const o=document.createElement("div");o.className="ml__pill-tooltip";let s;if(this.options.getPillTooltipCallback)s=this.options.getPillTooltipCallback(t),g.debug(`[${this.instanceId}] Using custom callback for tooltip content`);else{const m=this.getItemPillDisplayValue(t),p=this.getItemSubtitle(t);s=p?`${m}
37
+ ${p}`:m,g.debug(`[${this.instanceId}] Using default content: "${s}"`)}typeof s=="string"?o.textContent=s:o.appendChild(s),(this.options.container||document.body).appendChild(o),g.debug(`[${this.instanceId}] Tooltip element created and appended for "${l}"`),this.pillTooltips.set(l,o);let r,a;const d=()=>{clearTimeout(a),g.debug(`[${this.instanceId}] Mouse entered pill "${l}", will show tooltip in ${this.options.pillTooltipDelay||300}ms`),r=window.setTimeout(()=>{g.debug(`[${this.instanceId}] Showing tooltip for "${l}"`),o.classList.add("ml__pill-tooltip--visible"),this.positionPillTooltip(e,o,l)},this.options.pillTooltipDelay||300)},c=()=>{clearTimeout(r),a=window.setTimeout(()=>{o.classList.remove("ml__pill-tooltip--visible"),this.cleanupPillTooltip(l)},100)};e.addEventListener("mouseenter",d),e.addEventListener("mouseleave",c)}createRemoveButtonTooltip(e,t,l){const o=document.createElement("div");o.className="ml__pill-tooltip",o.textContent=`Remove ${t}`,(this.options.container||document.body).appendChild(o);const n=`${l}-remove`;this.pillTooltips.set(n,o);let r,a;const d=()=>{clearTimeout(a);const m=this.pillTooltips.get(l);m&&m.classList.remove("ml__pill-tooltip--visible"),r=window.setTimeout(()=>{o.classList.add("ml__pill-tooltip--visible"),this.positionPillTooltip(e,o,n)},this.options.pillTooltipDelay||300)},c=()=>{clearTimeout(r),a=window.setTimeout(()=>{o.classList.remove("ml__pill-tooltip--visible"),this.cleanupPillTooltip(n)},100)};e.addEventListener("mouseenter",d),e.addEventListener("mouseleave",c)}positionPillTooltip(e,t,l){const o=ue(e,t,()=>{be(e,t,{placement:this.options.pillTooltipPlacement||"top",strategy:"fixed",middleware:[fe(this.options.pillTooltipOffset||8),Ae(),ge({padding:8})]}).then(({x:s,y:n})=>{Object.assign(t.style,{left:`${s}px`,top:`${n}px`}),g.debug(`[${this.instanceId}] Positioned tooltip "${l}" at x:${s}, y:${n}`,{placement:this.options.pillTooltipPlacement||"top",tooltipClasses:t.className,tooltipDisplay:window.getComputedStyle(t).display,tooltipOpacity:window.getComputedStyle(t).opacity,tooltipVisibility:window.getComputedStyle(t).visibility,tooltipZIndex:window.getComputedStyle(t).zIndex,tooltipPosition:window.getComputedStyle(t).position})})});this.pillTooltipCleanups.set(l,o)}cleanupPillTooltip(e){const t=this.pillTooltipCleanups.get(e);t&&(t(),this.pillTooltipCleanups.delete(e))}destroyAllPillTooltips(){this.pillTooltipCleanups.forEach(e=>e()),this.pillTooltipCleanups.clear(),this.pillTooltips.forEach(e=>e.remove()),this.pillTooltips.clear()}destroy(){this.destroyAllPillTooltips(),this.dropdownCleanup&&this.dropdownCleanup(),this.hintCleanup&&this.hintCleanup(),this.selectedPopoverCleanup&&this.selectedPopoverCleanup(),this.virtualScroll&&(this.virtualScroll.destroy(),this.virtualScroll=null),this.dropdown&&this.dropdown.remove(),this.hint&&this.hint.remove(),this.selectedPopover&&this.selectedPopover.remove(),this.element.innerHTML="",this.element.classList.remove("ml","ml--open","ml--no-checkboxes"),N.info(`[${this.instanceId}] Component destroyed`)}}const hi='@charset "UTF-8";:host{--ml-accent-color: #3b82f6;--ml-accent-color-hover: #2563eb;--ml-accent-color-active: #1d4ed8;--ml-text-primary: #111827;--ml-text-secondary: #6b7280;--ml-text-white: #ffffff;--ml-primary-bg: #f3f4f6;--ml-primary-bg-hover: #e5e7eb;--ml-border-color: #e5e7eb;--ml-input-padding: .5rem .75rem;--ml-input-padding-right: 2.5rem;--ml-input-font-size: .875rem;--ml-input-border-style: 1px solid #d1d5db;--ml-input-border-radius: .375rem;--ml-input-bg: #ffffff;--ml-input-text: #111827;--ml-input-focus-border-color: #3b82f6;--ml-input-placeholder-color: #6b7280;--ml-input-bg-disabled: rgba(107, 114, 128, .05);--ml-toggle-right: .75rem;--ml-toggle-color: #6b7280;--ml-transform-center-y: translateY(-50%);--ml-transform-rotate-180: 180deg;--ml-count-badge-offset: 2rem;--ml-count-badge-padding: .125rem .25rem;--ml-count-badge-bg: #3b82f6;--ml-count-badge-color: #ffffff;--ml-count-badge-font-size: .75rem;--ml-count-badge-font-weight: 600;--ml-count-badge-border-radius: .25rem;--ml-count-badge-bg-hover: #2563eb;--ml-transform-scale-hover: 1.1;--ml-hint-padding: .5rem .75rem;--ml-hint-bg: #ffffff;--ml-hint-border: 1px solid #e5e7eb;--ml-hint-border-radius: .375rem;--ml-hint-box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);--ml-hint-font-size: .75rem;--ml-hint-color: #6b7280;--ml-line-height-relaxed: 1.4;--ml-dropdown-bg: #ffffff;--ml-dropdown-border: 1px solid #e5e7eb;--ml-dropdown-border-radius: .375rem;--ml-dropdown-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ml-dropdown-max-height: 20rem;--ml-dropdown-color: #111827;--ml-z-index-dropdown: 9999;--ml-z-index-sticky: 1;--ml-actions-gap: .25rem;--ml-actions-padding: .5rem;--ml-actions-border-bottom: 1px solid #e5e7eb;--ml-actions-bg: #ffffff;--ml-action-btn-padding: .25rem .5rem;--ml-action-btn-font-size: .75rem;--ml-action-btn-border: 1px solid #e5e7eb;--ml-action-btn-border-radius: .25rem;--ml-action-btn-bg: transparent;--ml-action-btn-color: inherit;--ml-action-btn-bg-hover: #f3f4f6;--ml-action-btn-border-color-hover: #3b82f6;--ml-transform-scale-active: .98;--ml-options-padding: .25rem 0;--ml-group-border-top: 1px solid #e5e7eb;--ml-group-margin-top: .25rem;--ml-group-padding-top: .25rem;--ml-group-label-padding: .25rem .75rem;--ml-group-label-font-size: .75rem;--ml-group-label-font-weight: 600;--ml-group-label-color: #6b7280;--ml-group-label-transform: uppercase;--ml-group-label-letter-spacing: .05em;--ml-option-gap: .5rem;--ml-option-padding: .5rem .75rem;--ml-option-padding-h: .75rem;--ml-option-bg: transparent;--ml-option-bg-hover: #f9fafb;--ml-option-bg-focused: #f9fafb;--ml-option-outline-focused: 2px solid #3b82f6;--ml-option-focus-outline-offset: -2px;--ml-option-bg-matched: rgba(59, 130, 246, .08);--ml-option-border-matched: 3px solid rgba(59, 130, 246, .4);--ml-option-bg-selected: rgba(59, 130, 246, .1);--ml-disabled-opacity: .5;--ml-option-content-gap: .5rem;--ml-option-icon-size: 1.25rem;--ml-option-icon-font-size: 1rem;--ml-option-title-font-size: .875rem;--ml-option-title-color: inherit;--ml-option-mark-bg: rgba(59, 130, 246, .2);--ml-option-mark-color: inherit;--ml-option-mark-font-weight: 600;--ml-option-subtitle-margin-top: .25rem;--ml-option-subtitle-font-size: .75rem;--ml-option-subtitle-color: #6b7280;--ml-option-subtitle-line-height: 1.3;--ml-checkbox-margin-top: .125rem;--ml-empty-padding: 1rem .75rem;--ml-empty-font-size: .875rem;--ml-empty-color: #6b7280;--ml-loader-padding: 1rem;--ml-loader-gap: .5rem;--ml-loading-text-font-size: .875rem;--ml-loading-text-color: #6b7280;--ml-pills-gap: .5rem;--ml-pills-margin-bottom: .5rem;--ml-pills-margin-top: .5rem;--ml-pills-margin-left: .25rem;--ml-pills-margin-right: .25rem;--ml-pill-gap: .5rem;--ml-pill-height: 1.5rem;--ml-pill-font-size: .75rem;--ml-pill-font-weight: 600;--ml-pill-border-radius: .375rem;--ml-pill-bg: #eff6ff;--ml-pill-bg-hover: #ffffff;--ml-pill-bg-active: #e0f2fe;--ml-order-first: -1;--ml-pill-text-padding: 0 .5rem;--ml-pill-text-bg: #eff6ff;--ml-pill-text-color: #3b82f6;--ml-pill-remove-width: 1.5rem;--ml-pill-remove-bg: #3b82f6;--ml-pill-remove-color: #ffffff;--ml-pill-remove-border: none;--ml-pill-remove-font-size: .75rem;--ml-pill-remove-bg-hover: #2563eb;--ml-pill-remove-box-shadow-focus: 0 0 0 2px rgba(59, 130, 246, .5);--ml-icon-remove: "×";--ml-more-badge-bg: #eff6ff;--ml-more-badge-hover-bg: #ffffff;--ml-more-badge-active-bg: #e0f2fe;--ml-count-display-margin-bottom: .5rem;--ml-count-display-margin-top: .5rem;--ml-count-display-margin-left: .5rem;--ml-count-display-margin-right: .5rem;--ml-count-badge-wrapper-bg: transparent;--ml-count-badge-wrapper-border: 1px solid #e5e7eb;--ml-count-badge-wrapper-border-radius: .25rem;--ml-count-badge-wrapper-padding: .25rem .5rem;--ml-count-badge-wrapper-gap: .25rem;--ml-count-badge-wrapper-bg-hover: #f9fafb;--ml-count-badge-wrapper-border-color-hover: #3b82f6;--ml-count-text-bg: transparent;--ml-count-text-border: none;--ml-count-text-font-size: .875rem;--ml-count-text-color: #111827;--ml-count-clear-size: 1rem;--ml-count-clear-bg: transparent;--ml-count-clear-color: #6b7280;--ml-count-clear-font-size: 1.125rem;--ml-count-clear-border-radius: 50%;--ml-count-clear-bg-hover: rgba(59, 130, 246, .2);--ml-count-clear-color-hover: #3b82f6;--ml-icon-clear: "×";--ml-tooltip-bg: #333;--ml-tooltip-color: #fff;--ml-tooltip-padding: .5rem .75rem;--ml-tooltip-border-radius: .375rem;--ml-tooltip-font-size: .875rem;--ml-tooltip-max-width: 20rem;--ml-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .15);--ml-tooltip-z-index: 10000;--ml-z-index-popover: 10000;--ml-selected-popover-width: 20rem;--ml-selected-popover-max-height: 20rem;--ml-selected-popover-bg: #ffffff;--ml-selected-popover-border: 1px solid #e5e7eb;--ml-selected-popover-border-radius: .375rem;--ml-selected-popover-box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);--ml-selected-popover-header-padding: .5rem .75rem;--ml-selected-popover-header-bg: rgba(59, 130, 246, .1);--ml-selected-popover-header-border-bottom: 1px solid #e5e7eb;--ml-selected-popover-header-font-size: .875rem;--ml-selected-popover-header-font-weight: 600;--ml-selected-popover-header-color: #111827;--ml-popover-close-size: 1.5rem;--ml-selected-popover-close-bg: transparent;--ml-selected-popover-close-color: #6b7280;--ml-selected-popover-close-font-size: 1.25rem;--ml-selected-popover-close-border-radius: 50%;--ml-selected-popover-close-bg-hover: rgba(59, 130, 246, .2);--ml-selected-popover-close-color-hover: #3b82f6;--ml-selected-popover-body-gap: .25rem;--ml-selected-popover-body-padding: .5rem;--ml-selected-popover-body-max-height: 18rem;--ml-font-size-2xs: .625rem;--ml-font-size-xs: .75rem;--ml-font-size-sm: .875rem;--ml-font-size-base: 1rem;--ml-font-size-lg: 1.125rem;--ml-font-weight-medium: 500;--ml-font-weight-semibold: 600;--ml-line-height-none: 1;--ml-spacing-xs: .25rem;--ml-spacing-sm: .5rem;--ml-spacing-md: .75rem;--ml-spacing-lg: 1rem;--ml-transition-fast: .15s;--ml-transition-normal: .2s;--ml-easing-snappy: cubic-bezier(.4, 0, .2, 1);--ml-placeholder-opacity: .6;--ml-disabled-input-opacity: .6}multi-select:not(:defined){display:block;min-height:2.5rem;color:transparent!important;background:transparent}.ml-wrapper{display:flex;flex-direction:column;align-items:stretch}.ml-wrapper--inline{flex-direction:row;align-items:flex-start}.ml{position:relative;width:100%}.ml__input-wrapper{position:relative;display:flex;align-items:center}.ml__input{width:100%;padding:var(--ml-input-padding, .5rem .75rem);padding-right:var(--ml-input-padding-right, 2.5rem);font-size:var(--ml-input-font-size, .875rem);border:var(--ml-input-border-style, 1px solid #d1d5db);border-radius:var(--ml-input-border-radius, .375rem);background:var(--ml-input-bg, #ffffff);color:var(--ml-input-text, #111827);cursor:pointer;transition:border-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__input:focus{outline:none;border-color:var(--ml-input-focus-border-color, #3b82f6)}.ml__input::placeholder{color:var(--ml-input-placeholder-color, #6b7280);opacity:0;transition:opacity var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}:host([data-ready]) .ml__input::placeholder{opacity:var(--ml-placeholder-opacity, .6)}.ml__toggle{position:absolute;right:var(--ml-toggle-right, .75rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));pointer-events:none;color:var(--ml-toggle-color, #6b7280);transition:transform var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml--open .ml__toggle{transform:var(--ml-transform-center-y, translateY(-50%)) rotate(var(--ml-transform-rotate-180, 180deg))}.ml__count-badge{position:absolute;right:var(--ml-count-badge-offset, 2rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));padding:var(--ml-count-badge-padding, .125rem .25rem);background:var(--ml-count-badge-bg, #3b82f6);color:var(--ml-count-badge-color, #ffffff);font-size:var(--ml-count-badge-font-size, .75rem);font-weight:var(--ml-count-badge-font-weight, 600);border-radius:var(--ml-count-badge-border-radius, .25rem);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge:hover{background:var(--ml-count-badge-bg-hover, #2563eb);transform:var(--ml-transform-center-y, translateY(-50%)) scale(var(--ml-transform-scale-hover, 1.1))}.ml__hint{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);padding:var(--ml-hint-padding, .5rem .75rem);background:var(--ml-hint-bg, #ffffff);border:var(--ml-hint-border, 1px solid #e5e7eb);border-radius:var(--ml-hint-border-radius, .375rem);box-shadow:var(--ml-hint-box-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));font-size:var(--ml-hint-font-size, .75rem);color:var(--ml-hint-color, #6b7280);line-height:var(--ml-line-height-relaxed, 1.4);max-width:100%}.ml__hint--visible{display:block}.ml__dropdown{display:none;position:absolute;z-index:var(--ml-z-index-dropdown, 9999);background:var(--ml-dropdown-bg, #ffffff);border:var(--ml-dropdown-border, 1px solid #e5e7eb);border-radius:var(--ml-dropdown-border-radius, .375rem);box-shadow:var(--ml-dropdown-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));max-height:var(--ml-dropdown-max-height, 20rem);overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;color:var(--ml-dropdown-color, #111827)}.ml__dropdown--visible{display:block}.ml__dropdown--virtual{overflow-y:visible;max-height:none}.ml__actions{display:flex;gap:var(--ml-actions-gap, .25rem);padding:var(--ml-actions-padding, .5rem);border-bottom:var(--ml-actions-border-bottom, 1px solid #e5e7eb)}.ml__actions--sticky{position:sticky;top:0;z-index:var(--ml-z-index-sticky, 1);background:var(--ml-actions-bg, #ffffff)}.ml__action-btn{flex:1;padding:var(--ml-action-btn-padding, .25rem .5rem);font-size:var(--ml-action-btn-font-size, .75rem);border:var(--ml-action-btn-border, 1px solid #e5e7eb);border-radius:var(--ml-action-btn-border-radius, .25rem);background:var(--ml-action-btn-bg, transparent);color:var(--ml-action-btn-color, inherit);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__action-btn:hover{background:var(--ml-action-btn-bg-hover, #f3f4f6);border-color:var(--ml-action-btn-border-color-hover, #3b82f6)}.ml__action-btn:active{transform:scale(var(--ml-transform-scale-active, .98))}.ml__options{padding:var(--ml-options-padding, .25rem 0)}.ml__options--virtual .ml__option{height:var(--ml-option-height, 50px);min-height:var(--ml-option-height, 50px);max-height:var(--ml-option-height, 50px);overflow:hidden;box-sizing:border-box}.ml__group+.ml__group{border-top:var(--ml-group-border-top, 1px solid #e5e7eb);margin-top:var(--ml-group-margin-top, .25rem);padding-top:var(--ml-group-padding-top, .25rem)}.ml__group-label{padding:var(--ml-group-label-padding, .25rem .75rem);font-size:var(--ml-group-label-font-size, .75rem);font-weight:var(--ml-group-label-font-weight, 600);color:var(--ml-group-label-color, #6b7280);text-transform:var(--ml-group-label-transform, uppercase);letter-spacing:var(--ml-group-label-letter-spacing, .05em)}.ml__option{display:flex;align-items:flex-start;gap:var(--ml-option-gap, .5rem);padding:var(--ml-option-padding, .5rem .75rem);cursor:pointer;transition:background-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__option:hover{background:var(--ml-option-bg-hover, #f9fafb)}.ml__option--focused{background:var(--ml-option-bg-focused, #f9fafb);outline:var(--ml-option-outline-focused, 2px solid #3b82f6);outline-offset:var(--ml-option-focus-outline-offset, -2px)}.ml__option--matched{background:var(--ml-option-bg-matched, rgba(59, 130, 246, .08));border-left:var(--ml-option-border-matched, 3px solid rgba(59, 130, 246, .4))}.ml__option--selected{background:var(--ml-option-bg-selected, rgba(59, 130, 246, .1))}.ml__option--disabled{opacity:var(--ml-disabled-opacity, .5);cursor:not-allowed}.ml__option--disabled:hover{background:var(--ml-option-bg, transparent)}.ml__checkbox{flex-shrink:0;margin-top:var(--ml-checkbox-margin-top, .125rem);cursor:pointer}.ml__option--disabled .ml__checkbox{cursor:not-allowed}.ml__option-content{flex:1;display:flex;align-items:flex-start;gap:var(--ml-option-content-gap, .5rem);min-width:0}.ml__option-icon{flex-shrink:0;width:var(--ml-option-icon-size, 1.25rem);height:var(--ml-option-icon-size, 1.25rem);display:flex;align-items:center;justify-content:center;font-size:var(--ml-option-icon-font-size, 1rem)}.ml__option-icon svg{width:100%;height:100%;fill:currentColor}.ml__option-text{flex:1;min-width:0}.ml__option-title{font-size:var(--ml-option-title-font-size, .875rem);color:var(--ml-option-title-color, inherit);line-height:var(--ml-line-height-relaxed, 1.4)}.ml__option-title mark{background:var(--ml-option-mark-bg, rgba(59, 130, 246, .2));color:var(--ml-option-mark-color, inherit);font-weight:var(--ml-option-mark-font-weight, 600)}.ml__option-subtitle{margin-top:var(--ml-option-subtitle-margin-top, .25rem);font-size:var(--ml-option-subtitle-font-size, .75rem);color:var(--ml-option-subtitle-color, #6b7280);line-height:var(--ml-option-subtitle-line-height, 1.3)}.ml__empty{padding:var(--ml-empty-padding, 1rem .75rem);text-align:center;font-size:var(--ml-empty-font-size, .875rem);color:var(--ml-empty-color, #6b7280)}.ml__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ml-loader-padding, 1rem);gap:var(--ml-loader-gap, .5rem)}.ml__loading-text{font-size:var(--ml-loading-text-font-size, .875rem);color:var(--ml-loading-text-color, #6b7280)}.ml__pills{display:flex;flex-wrap:wrap;gap:var(--ml-pills-gap, .5rem);padding:0}.ml__pills:empty{display:none}.ml__pills--bottom{margin-top:var(--ml-pills-margin-bottom, .5rem)}.ml__pills--top{margin-bottom:var(--ml-pills-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__pills--left{order:var(--ml-order-first, -1);margin-right:var(--ml-pills-margin-left, .25rem);justify-content:flex-end}.ml__pills--right{margin-left:var(--ml-pills-margin-right, .25rem);justify-content:flex-start}.ml__count-display{display:flex;align-items:center}.ml__count-display:empty{display:none}.ml__count-display--bottom{margin-top:var(--ml-count-display-margin-bottom, .5rem)}.ml__count-display--top{margin-bottom:var(--ml-count-display-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__count-display--left{order:var(--ml-order-first, -1);margin-right:var(--ml-count-display-margin-left, .5rem);justify-content:flex-start}.ml__count-display--right{margin-left:var(--ml-count-display-margin-right, .5rem);justify-content:flex-end}.ml__count-badge-wrapper{display:inline-flex;align-items:center;gap:var(--ml-count-badge-wrapper-gap, .25rem);background:var(--ml-count-badge-wrapper-bg, transparent);border:var(--ml-count-badge-wrapper-border, 1px solid #e5e7eb);border-radius:var(--ml-count-badge-wrapper-border-radius, .25rem);padding:var(--ml-count-badge-wrapper-padding, .25rem .5rem);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge-wrapper:hover{background:var(--ml-count-badge-wrapper-bg-hover, #f9fafb);border-color:var(--ml-count-badge-wrapper-border-color-hover, #3b82f6)}.ml__count-text{display:inline-flex;align-items:center;background:var(--ml-count-text-bg, transparent);border:var(--ml-count-text-border, none);padding:0;font-size:var(--ml-count-text-font-size, .875rem);color:var(--ml-count-text-color, #111827);cursor:pointer;transition:color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ml-count-clear-size, 1rem);height:var(--ml-count-clear-size, 1rem);padding:0;border:none;background:var(--ml-count-clear-bg, transparent);color:var(--ml-count-clear-color, #6b7280);font-size:var(--ml-count-clear-font-size, 1.125rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-count-clear-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear:hover{background:var(--ml-count-clear-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-count-clear-color-hover, #3b82f6)}.ml__count-clear:before{content:var(--ml-icon-clear, "×")}.ml__pill{display:inline-flex;align-items:center;height:var(--ml-pill-height, 1.5rem);font-size:var(--ml-pill-font-size, .75rem);font-weight:var(--ml-pill-font-weight, 600);line-height:var(--ml-line-height-none, 1);border-radius:var(--ml-pill-border-radius, .375rem);overflow:hidden;max-width:100%}.ml__pill-text{display:flex;align-items:center;height:100%;padding:var(--ml-pill-text-padding, 0 .5rem);background:var(--ml-pill-text-bg, #eff6ff);color:var(--ml-pill-text-color, #3b82f6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ml-transition-normal, .2s) ease}.ml__pill-remove{display:flex;align-items:center;justify-content:center;width:var(--ml-pill-remove-width, 1.5rem);height:100%;flex-shrink:0;background:var(--ml-pill-remove-bg, #3b82f6);color:var(--ml-pill-remove-color, #ffffff);border:var(--ml-pill-remove-border, none);cursor:pointer;transition:background-color var(--ml-transition-normal, .2s) ease;font-size:var(--ml-pill-remove-font-size, .75rem)}.ml__pill-remove:hover{background:var(--ml-pill-remove-bg-hover, #2563eb)}.ml__pill-remove:focus{outline:none;box-shadow:var(--ml-pill-remove-box-shadow-focus, 0 0 0 2px rgba(59, 130, 246, .5))}.ml__pill-remove:before{content:var(--ml-icon-remove, "×");font-size:var(--ml-font-size-base, 1rem);line-height:var(--ml-line-height-none, 1)}.ml__pill--more{cursor:pointer}.ml__pill--more .ml__pill-text{background:var(--ml-more-badge-bg, #eff6ff);font-weight:var(--ml-pill-font-weight, 600)}.ml__pill--more:hover .ml__pill-text{background:var(--ml-more-badge-hover-bg, #ffffff)}.ml__pill--more:active .ml__pill-text{background:var(--ml-more-badge-active-bg, #e0f2fe)}.ml__pill-tooltip{position:fixed;z-index:var(--ml-tooltip-z-index, 10000);opacity:0;visibility:hidden;transition:opacity var(--ml-transition-normal, .2s) ease,visibility var(--ml-transition-normal, .2s) ease;background:var(--ml-tooltip-bg, #333);color:var(--ml-tooltip-color, #fff);padding:var(--ml-tooltip-padding, .5rem .75rem);border-radius:var(--ml-tooltip-border-radius, .375rem);font-size:var(--ml-tooltip-font-size, .875rem);line-height:var(--ml-line-height-relaxed, 1.4);max-width:var(--ml-tooltip-max-width, 20rem);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ml-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, .15));pointer-events:none}.ml__pill-tooltip--visible{opacity:1;visibility:visible}.ml__selected-popover{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);background:var(--ml-selected-popover-bg, #ffffff);border:var(--ml-selected-popover-border, 1px solid #e5e7eb);border-radius:var(--ml-selected-popover-border-radius, .375rem);box-shadow:var(--ml-selected-popover-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));width:var(--ml-selected-popover-width, 20rem);max-height:var(--ml-selected-popover-max-height, 20rem);overflow:hidden}.ml__selected-popover--visible{display:flex;flex-direction:column}.ml__selected-popover-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ml-selected-popover-header-padding, .5rem .75rem);background:var(--ml-selected-popover-header-bg, rgba(59, 130, 246, .1));border-bottom:var(--ml-selected-popover-header-border-bottom, 1px solid #e5e7eb);font-size:var(--ml-selected-popover-header-font-size, .875rem);font-weight:var(--ml-selected-popover-header-font-weight, 600);color:var(--ml-selected-popover-header-color, #111827)}.ml__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ml-popover-close-size, 1.5rem);height:var(--ml-popover-close-size, 1.5rem);padding:0;border:none;background:var(--ml-selected-popover-close-bg, transparent);color:var(--ml-selected-popover-close-color, #6b7280);font-size:var(--ml-selected-popover-close-font-size, 1.25rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-selected-popover-close-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__selected-popover-close:hover{background:var(--ml-selected-popover-close-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-selected-popover-close-color-hover, #3b82f6)}.ml__selected-popover-body{display:flex;flex-direction:column;gap:var(--ml-selected-popover-body-gap, .25rem);padding:var(--ml-selected-popover-body-padding, .5rem);overflow-y:auto;max-height:var(--ml-selected-popover-body-max-height, 18rem)}.ml__selected-popover-body .ml__pill{width:100%}.ml__selected-popover-body .ml__pill-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.ml--rtl .ml__input-wrapper{direction:rtl}.ml--rtl .ml__input{text-align:right;padding-left:var(--ml-input-padding-right, 2.5rem);padding-right:var(--ml-input-padding-h, .75rem)}.ml--rtl .ml__toggle{left:var(--ml-toggle-right, .75rem)!important;right:auto!important}.ml--rtl .ml__count-badge{left:var(--ml-count-badge-offset, 2rem)!important;right:auto!important}.ml--rtl .ml__dropdown{direction:rtl;text-align:right}.ml--rtl .ml__option{flex-direction:row-reverse}.ml--rtl .ml__checkbox{margin-left:var(--ml-spacing-sm, .5rem);margin-right:0}.ml--rtl .ml__option-content{text-align:right}.ml--rtl .ml__option-icon{margin-left:var(--ml-spacing-xs, .25rem);margin-right:0}.ml--rtl .ml__pills{direction:rtl}.ml--rtl .ml__pill{flex-direction:row-reverse}.ml--rtl .ml__pill-remove{border-radius:var(--ml-pill-remove-border-radius-rtl, .375rem) 0 0 var(--ml-pill-remove-border-radius-rtl, .375rem);border-left:var(--ml-pill-remove-border, none);border-right:none}.ml--rtl .ml__pill-text{border-radius:0 var(--ml-pill-text-border-radius-rtl, .375rem) var(--ml-pill-text-border-radius-rtl, .375rem) 0}.ml--rtl .ml__count-display{direction:rtl}.ml--rtl .ml__count-badge-wrapper{flex-direction:row-reverse}.ml--rtl .ml__selected-popover{direction:rtl;text-align:right}.ml--rtl .ml__actions{direction:rtl}.ml--rtl .ml__group-label,.ml--rtl .ml__empty{text-align:right}.ml--rtl .ml__hint{direction:rtl;text-align:right}.ml--xs .ml__input{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__option{padding:var(--ml-spacing-xs, .25rem) var(--ml-spacing-sm, .5rem)}.ml--xs .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__pill{font-size:var(--ml-font-size-2xs, .625rem)}.ml--sm .ml__input,.ml--sm .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--lg .ml__input,.ml--lg .ml__option-title{font-size:var(--ml-font-size-base, 1rem)}.ml--lg .ml__pill{font-size:var(--ml-font-size-sm, .875rem)}.ml--xl .ml__input,.ml--xl .ml__option-title{font-size:var(--ml-font-size-lg, 1.125rem)}.ml--xl .ml__pill{font-size:var(--ml-font-size-base, 1rem)}.ml--disabled .ml__input{opacity:var(--ml-disabled-input-opacity, .6);cursor:not-allowed;background:var(--ml-input-bg-disabled, rgba(107, 114, 128, .05))}.ml--disabled .ml__toggle{opacity:var(--ml-disabled-input-opacity, .6)}.ml--no-checkboxes .ml__option{gap:0;padding-left:var(--ml-option-padding-h, .75rem)}.ml--no-checkboxes .ml__option-content{padding-left:0}.ml-debug-info{margin-top:.25rem;padding:.25rem;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:.375rem;font-size:.75rem;color:#111827}.ml-debug-info details summary{cursor:pointer;font-weight:600;color:#2563eb;-webkit-user-select:none;user-select:none;padding:.25rem;border-radius:.25rem}.ml-debug-info details summary:hover{background-color:#f3f4f6}.ml-debug-info details summary:focus{outline:2px solid #3b82f6;outline-offset:2px}.ml-debug-info .ml-debug-stats{display:flex;flex-direction:column;gap:.25rem;margin-top:.25rem;padding:.25rem;background-color:#fff;border-radius:.25rem}.ml-debug-info .ml-debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:.625rem}.ml-debug-info .ml-debug-stats span:before{content:"•";margin-right:.25rem;color:#3b82f6}',mi=typeof HTMLElement<"u"?HTMLElement:class{},Te=new Set;function st(){return Array.from(Te)}class Le extends mi{constructor(){super();u(this,"picker");u(this,"containerElement");u(this,"shadow");u(this,"_options");u(this,"_valueMember");u(this,"_getValueCallback");u(this,"_displayValueMember");u(this,"_getDisplayValueCallback");u(this,"_getPillDisplayCallback");u(this,"_searchValueMember");u(this,"_getSearchValueCallback");u(this,"_iconMember");u(this,"_getIconCallback");u(this,"_subtitleMember");u(this,"_getSubtitleCallback");u(this,"_groupMember");u(this,"_getGroupCallback");u(this,"_disabledMember");u(this,"_getDisabledCallback");u(this,"_getValueFormatCallback");u(this,"_getPillTooltipCallback");u(this,"_getCountPillCallback");u(this,"_beforeSearchCallback");u(this,"_searchCallback");u(this,"_addNewCallback");u(this,"_selectCallback");u(this,"_deselectCallback");u(this,"_changeCallback");u(this,"_declarativeSelectedValues");this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=hi,this.shadow.appendChild(t),requestAnimationFrame(()=>{this.setAttribute("data-ready","")})}static get observedAttributes(){return["search-hint","search-placeholder","multiple","allow-groups","allow-select-all","allow-clear-all","show-checkboxes","sticky-actions","close-on-select","lock-placement","dropdown-min-width","pills-display-mode","pills-threshold","pills-max-visible","pills-threshold-mode","pills-position","show-count-badge","keep-options-on-search","max-height","empty-message","loading-message","min-search-length","enable-search","search-input-mode","search-mode","allow-add-new","initial-values","enable-virtual-scroll","virtual-scroll-threshold","option-height","virtual-scroll-buffer","value-member","display-value-member","search-value-member","icon-member","subtitle-member","group-member","disabled-member","name","value-format","enable-pill-tooltips","pill-tooltip-placement","show-debug-info"]}connectedCallback(){Te.add(this),this.render();const t=this.parseDeclarativeOptions();t&&(this._options&&this._options.length>0&&k.warn("[MultiSelectElement] Both declarative <option> elements and programmatic .options detected. Using declarative options."),this._options=t),this.initializePicker()}disconnectedCallback(){Te.delete(this),this.picker&&this.picker.destroy()}attributeChangedCallback(t,l,o){l!==o&&this.picker&&t!=="initial-values"&&(this.picker.destroy(),this.initializePicker())}render(){this.containerElement=document.createElement("div"),this.containerElement.setAttribute("data-multiselect",""),this.className&&(this.containerElement.className=this.className),this.shadow.appendChild(this.containerElement),this.getAttribute("show-debug-info")==="true"&&this.renderDebugInfo()}renderDebugInfo(){const t=this.shadow.querySelector(".ml-debug-info");t&&t.remove();const l=document.createElement("div");l.className="ml-debug-info";const o=document.createElement("details"),s=document.createElement("summary");s.textContent="Debug Info";const n=document.createElement("div");n.className="ml-debug-stats",o.appendChild(s),o.appendChild(n),l.appendChild(o),this.shadow.appendChild(l),this.updateDebugInfo()}updateDebugInfo(){var h,f;const t=this.shadow.querySelector(".ml-debug-stats");if(!t||!this.picker)return;const l="1.0.0-rc08",o=st().length,n=this.picker.getSelected().length,r=((h=this._options)==null?void 0:h.length)||0,a=this.picker,d=a.isOpen||!1,c=a.searchTerm||"",m=a.isLoading||!1,p=((f=a.filteredOptions)==null?void 0:f.length)||0;t.innerHTML=`
38
38
  <span>Version: ${l}</span>
39
39
  <span>Total Instances: ${o}</span>
40
40
  <span>Options: ${r}</span>
41
- <span>Filtered: ${m}</span>
41
+ <span>Filtered: ${p}</span>
42
42
  <span>Selected: ${n}</span>
43
- <span>Dropdown: ${c?"Open":"Closed"}</span>
44
- <span>Search: ${p||"none"}</span>
45
- <span>Loading: ${d?"Yes":"No"}</span>
46
- `,setTimeout(()=>{this.getAttribute("show-debug-info")==="true"&&this.updateDebugInfo()},500)}initializePicker(){if(!this.containerElement)return;let t;const l=this.getAttribute("initial-values");if(l)try{t=JSON.parse(l)}catch(s){console.error("[MultiSelectElement] Failed to parse initial-values:",s)}const o={searchHint:this.getAttribute("search-hint")||void 0,searchPlaceholder:this.getAttribute("search-placeholder")||"Search...",dropdownMinWidth:this.getAttribute("dropdown-min-width")||void 0,pillsDisplayMode:this.getAttribute("pills-display-mode")||"pills",pillsPosition:this.getAttribute("pills-position")||"bottom",pillsThresholdMode:this.getAttribute("pills-threshold-mode")||"count",maxHeight:this.getAttribute("max-height")||"20rem",emptyMessage:this.getAttribute("empty-message")||"No results found",loadingMessage:this.getAttribute("loading-message")||"Loading...",searchInputMode:this.getAttribute("search-input-mode")||"normal",pillsThreshold:this.getAttribute("pills-threshold")?parseInt(this.getAttribute("pills-threshold")):void 0,pillsMaxVisible:this.getAttribute("pills-max-visible")?parseInt(this.getAttribute("pills-max-visible")):void 0,minSearchLength:this.getAttribute("min-search-length")?parseInt(this.getAttribute("min-search-length")):0,isMultipleEnabled:this.getAttribute("multiple")!=="false",isGroupsAllowed:this.getAttribute("allow-groups")!=="false",isSelectAllAllowed:this.getAttribute("allow-select-all")!=="false",isClearAllAllowed:this.getAttribute("allow-clear-all")!=="false",isCheckboxesShown:this.getAttribute("show-checkboxes")!=="false",isActionsSticky:this.getAttribute("sticky-actions")!=="false",isCloseOnSelect:this.getAttribute("close-on-select")==="true",isPlacementLocked:this.getAttribute("lock-placement")!=="false",isSearchEnabled:this.getAttribute("enable-search")!=="false",isAddNewAllowed:this.getAttribute("allow-add-new")==="true",isCountBadgeShown:this.getAttribute("show-count-badge")==="true",valueMember:this.getAttribute("value-member")||this._valueMember,displayValueMember:this.getAttribute("display-value-member")||this._displayValueMember,searchValueMember:this.getAttribute("search-value-member")||this._searchValueMember,iconMember:this.getAttribute("icon-member")||this._iconMember,subtitleMember:this.getAttribute("subtitle-member")||this._subtitleMember,groupMember:this.getAttribute("group-member")||this._groupMember,disabledMember:this.getAttribute("disabled-member")||this._disabledMember,getValueCallback:this._getValueCallback,getDisplayValueCallback:this._getDisplayValueCallback,getPillDisplayCallback:this._getPillDisplayCallback,getSearchValueCallback:this._getSearchValueCallback,getIconCallback:this._getIconCallback,getSubtitleCallback:this._getSubtitleCallback,getGroupCallback:this._getGroupCallback,getDisabledCallback:this._getDisabledCallback,formFieldId:this.getAttribute("name")||void 0,valueFormat:this.getAttribute("value-format")||"json",getValueFormatCallback:this._getValueFormatCallback,isPillTooltipsEnabled:this.getAttribute("enable-pill-tooltips")==="true",getPillTooltipCallback:this._getPillTooltipCallback,pillTooltipPlacement:this.getAttribute("pill-tooltip-placement")||"top",pillTooltipDelay:parseInt(this.getAttribute("pill-tooltip-delay")||"300"),pillTooltipOffset:parseInt(this.getAttribute("pill-tooltip-offset")||"8"),getCountPillCallback:this._getCountPillCallback||((s,n)=>n!==void 0?`+${n} more`:`${s} selected`),options:this._options,searchCallback:this._searchCallback,addNewCallback:this._addNewCallback,selectCallback:s=>{var n,r;this._selectCallback&&this._selectCallback(s),this.dispatchEvent(new CustomEvent("select",{detail:{option:s,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:Array.from(((r=this.picker)==null?void 0:r.getValue())||[])}}))},deselectCallback:s=>{var n,r;this._deselectCallback&&this._deselectCallback(s),this.dispatchEvent(new CustomEvent("deselect",{detail:{option:s,selectedOptions:(n=this.picker)==null?void 0:n.getSelected(),selectedValues:Array.from(((r=this.picker)==null?void 0:r.getValue())||[])}}))},changeCallback:s=>{var n;this._changeCallback&&this._changeCallback(s),this.dispatchEvent(new CustomEvent("change",{detail:{selectedOptions:s,selectedValues:Array.from(((n=this.picker)==null?void 0:n.getValue())||[])}}))},container:this.shadow,hostElement:this};t&&(this.containerElement.dataset.initialValues=JSON.stringify(t)),this.picker=new je(this.containerElement,o)}reinitialize(){this.picker&&(this.picker.destroy(),this.initializePicker())}get options(){return this._options}set options(t){this._options=t,this.reinitialize()}set valueMember(t){this._valueMember=t||void 0,t?this.setAttribute("value-member",t):this.removeAttribute("value-member")}get valueMember(){return this.getAttribute("value-member")}set displayValueMember(t){this._displayValueMember=t||void 0,t?this.setAttribute("display-value-member",t):this.removeAttribute("display-value-member")}get displayValueMember(){return this.getAttribute("display-value-member")}set searchValueMember(t){this._searchValueMember=t||void 0,t?this.setAttribute("search-value-member",t):this.removeAttribute("search-value-member")}get searchValueMember(){return this.getAttribute("search-value-member")}set iconMember(t){this._iconMember=t||void 0,t?this.setAttribute("icon-member",t):this.removeAttribute("icon-member")}get iconMember(){return this.getAttribute("icon-member")}set subtitleMember(t){this._subtitleMember=t||void 0,t?this.setAttribute("subtitle-member",t):this.removeAttribute("subtitle-member")}get subtitleMember(){return this.getAttribute("subtitle-member")}set groupMember(t){this._groupMember=t||void 0,t?this.setAttribute("group-member",t):this.removeAttribute("group-member")}get groupMember(){return this.getAttribute("group-member")}set disabledMember(t){this._disabledMember=t||void 0,t?this.setAttribute("disabled-member",t):this.removeAttribute("disabled-member")}get disabledMember(){return this.getAttribute("disabled-member")}set getValueCallback(t){this._getValueCallback=t,this.reinitialize()}get getValueCallback(){return this._getValueCallback}set getDisplayValueCallback(t){this._getDisplayValueCallback=t,this.reinitialize()}get getDisplayValueCallback(){return this._getDisplayValueCallback}set getPillDisplayCallback(t){this._getPillDisplayCallback=t,this.reinitialize()}get getPillDisplayCallback(){return this._getPillDisplayCallback}set getSearchValueCallback(t){this._getSearchValueCallback=t,this.reinitialize()}get getSearchValueCallback(){return this._getSearchValueCallback}set getIconCallback(t){this._getIconCallback=t,this.reinitialize()}get getIconCallback(){return this._getIconCallback}set getSubtitleCallback(t){this._getSubtitleCallback=t,this.reinitialize()}get getSubtitleCallback(){return this._getSubtitleCallback}set getGroupCallback(t){this._getGroupCallback=t,this.reinitialize()}get getGroupCallback(){return this._getGroupCallback}set getDisabledCallback(t){this._getDisabledCallback=t,this.reinitialize()}get getDisabledCallback(){return this._getDisabledCallback}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get name(){return this.getAttribute("name")}set valueFormat(t){t?this.setAttribute("value-format",t):this.removeAttribute("value-format")}get valueFormat(){return this.getAttribute("value-format")}set getValueFormatCallback(t){this._getValueFormatCallback=t,this.reinitialize()}get getValueFormatCallback(){return this._getValueFormatCallback}set thresholdMode(t){t?this.setAttribute("threshold-mode",t):this.removeAttribute("threshold-mode")}get thresholdMode(){return this.getAttribute("threshold-mode")}set pillsMaxVisible(t){t!==null?this.setAttribute("pills-max-visible",String(t)):this.removeAttribute("pills-max-visible")}get pillsMaxVisible(){const t=this.getAttribute("pills-max-visible");return t?parseInt(t):null}set enablePillTooltips(t){t?this.setAttribute("enable-pill-tooltips","true"):this.removeAttribute("enable-pill-tooltips")}get enablePillTooltips(){return this.getAttribute("enable-pill-tooltips")==="true"}set pillTooltipPlacement(t){t?this.setAttribute("pill-tooltip-placement",t):this.removeAttribute("pill-tooltip-placement")}get pillTooltipPlacement(){return this.getAttribute("pill-tooltip-placement")}set getPillTooltipCallback(t){this._getPillTooltipCallback=t,this.reinitialize()}get getPillTooltipCallback(){return this._getPillTooltipCallback}set getCountPillCallback(t){this._getCountPillCallback=t,this.reinitialize()}get getCountPillCallback(){return this._getCountPillCallback}get searchCallback(){return this._searchCallback}set searchCallback(t){this._searchCallback=t,this.reinitialize()}get addNewCallback(){return this._addNewCallback}set addNewCallback(t){this._addNewCallback=t,this.reinitialize()}get selectCallback(){return this._selectCallback}set selectCallback(t){this._selectCallback=t}get deselectCallback(){return this._deselectCallback}set deselectCallback(t){this._deselectCallback=t}get changeCallback(){return this._changeCallback}set changeCallback(t){this._changeCallback=t}get selectedValue(){var t;return((t=this.picker)==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return((t=this.picker)==null?void 0:t.selectedItem)??null}getSelected(){return this.picker?this.picker.getSelected():[]}setSelected(t){this.picker&&this.picker.setSelected(t)}getValue(){return this.picker?this.picker.getValue():null}destroy(){this.picker&&this.picker.destroy()}}typeof window<"u"&&typeof customElements<"u"&&(customElements.get("multi-select")||customElements.define("multi-select",_e)),typeof window<"u"&&(window.keenmate=window.keenmate||{},window.keenmate.multiselect={version:()=>"1.0.0-rc04",config:{name:"@keenmate/web-multiselect",version:"1.0.0-rc04",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://github.com/keenmate/web-multiselect#readme"},register:()=>{typeof customElements<"u"&&!customElements.get("multi-select")&&customElements.define("multi-select",_e)},getInstances:()=>We()}),P.MultiSelectElement=_e,P.PureMultiSelect=je,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
43
+ <span>Dropdown: ${d?"Open":"Closed"}</span>
44
+ <span>Search: ${c||"none"}</span>
45
+ <span>Loading: ${m?"Yes":"No"}</span>
46
+ `,setTimeout(()=>{this.getAttribute("show-debug-info")==="true"&&this.updateDebugInfo()},500)}parseDeclarativeOptions(){var s,n,r,a;const t=[],l=Array.from(this.children);if(l.length===0)return null;let o=!1;for(const d of l)if(d.tagName==="OPTION"){const c=d,m={value:c.value||((s=c.textContent)==null?void 0:s.trim())||"",label:((n=c.textContent)==null?void 0:n.trim())||c.value||""};c.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(m.value)),c.hasAttribute("disabled")&&(m.disabled=!0),c.hasAttribute("data-icon")&&(m.icon=c.getAttribute("data-icon")),c.hasAttribute("data-subtitle")&&(m.subtitle=c.getAttribute("data-subtitle")),t.push(m),o=!0}else if(d.tagName==="OPTGROUP"){const c=d,m=c.label||c.getAttribute("label")||"Group",p=Array.from(c.querySelectorAll("option"));for(const h of p){const f={value:h.value||((r=h.textContent)==null?void 0:r.trim())||"",label:((a=h.textContent)==null?void 0:a.trim())||h.value||"",group:m};h.hasAttribute("selected")&&(this._declarativeSelectedValues||(this._declarativeSelectedValues=[]),this._declarativeSelectedValues.push(f.value)),h.hasAttribute("disabled")&&(f.disabled=!0),h.hasAttribute("data-icon")&&(f.icon=h.getAttribute("data-icon")),h.hasAttribute("data-subtitle")&&(f.subtitle=h.getAttribute("data-subtitle")),t.push(f),o=!0}}return o?(k.debug(`[MultiSelectElement] Parsed ${t.length} declarative options from Light DOM`),l.forEach(d=>{(d.tagName==="OPTION"||d.tagName==="OPTGROUP")&&d.remove()}),t):null}initializePicker(){if(!this.containerElement)return;let t;if(this._declarativeSelectedValues&&this._declarativeSelectedValues.length>0)t=this._declarativeSelectedValues,k.debug(`[MultiSelectElement] Using ${t.length} declaratively selected values`);else{const o=this.getAttribute("initial-values");if(o)try{t=JSON.parse(o)}catch(s){k.error("[MultiSelectElement] Failed to parse initial-values:",s)}}const l={searchHint:this.getAttribute("search-hint")||void 0,searchPlaceholder:this.getAttribute("search-placeholder")||"Search...",dropdownMinWidth:this.getAttribute("dropdown-min-width")||void 0,pillsDisplayMode:this.getAttribute("pills-display-mode")||"pills",pillsPosition:this.getAttribute("pills-position")||"bottom",pillsThresholdMode:this.getAttribute("pills-threshold-mode")||"count",maxHeight:this.getAttribute("max-height")||"20rem",emptyMessage:this.getAttribute("empty-message")||"No results found",loadingMessage:this.getAttribute("loading-message")||"Loading...",searchInputMode:this.getAttribute("search-input-mode")||"normal",searchMode:this.getAttribute("search-mode")||"filter",pillsThreshold:this.getAttribute("pills-threshold")?parseInt(this.getAttribute("pills-threshold")):void 0,pillsMaxVisible:this.getAttribute("pills-max-visible")?parseInt(this.getAttribute("pills-max-visible")):void 0,minSearchLength:this.getAttribute("min-search-length")?parseInt(this.getAttribute("min-search-length")):0,isMultipleEnabled:this.getAttribute("multiple")!=="false",isGroupsAllowed:this.getAttribute("allow-groups")!=="false",isSelectAllAllowed:this.getAttribute("allow-select-all")!=="false",isClearAllAllowed:this.getAttribute("allow-clear-all")!=="false",isCheckboxesShown:this.getAttribute("show-checkboxes")!=="false",isActionsSticky:this.getAttribute("sticky-actions")!=="false",isCloseOnSelect:this.getAttribute("close-on-select")==="true",isPlacementLocked:this.getAttribute("lock-placement")!=="false",isSearchEnabled:this.getAttribute("enable-search")!=="false",isAddNewAllowed:this.getAttribute("allow-add-new")==="true",isCountBadgeShown:this.getAttribute("show-count-badge")==="true",isKeepOptionsOnSearch:this.getAttribute("keep-options-on-search")!=="false",isVirtualScrollEnabled:this.getAttribute("enable-virtual-scroll")==="true",virtualScrollThreshold:this.getAttribute("virtual-scroll-threshold")?parseInt(this.getAttribute("virtual-scroll-threshold")):100,optionHeight:this.getAttribute("option-height")?parseInt(this.getAttribute("option-height")):50,virtualScrollBuffer:this.getAttribute("virtual-scroll-buffer")?parseInt(this.getAttribute("virtual-scroll-buffer")):10,valueMember:this.getAttribute("value-member")||this._valueMember,displayValueMember:this.getAttribute("display-value-member")||this._displayValueMember,searchValueMember:this.getAttribute("search-value-member")||this._searchValueMember,iconMember:this.getAttribute("icon-member")||this._iconMember,subtitleMember:this.getAttribute("subtitle-member")||this._subtitleMember,groupMember:this.getAttribute("group-member")||this._groupMember,disabledMember:this.getAttribute("disabled-member")||this._disabledMember,getValueCallback:this._getValueCallback,getDisplayValueCallback:this._getDisplayValueCallback,getPillDisplayCallback:this._getPillDisplayCallback,getSearchValueCallback:this._getSearchValueCallback,getIconCallback:this._getIconCallback,getSubtitleCallback:this._getSubtitleCallback,getGroupCallback:this._getGroupCallback,getDisabledCallback:this._getDisabledCallback,formFieldId:this.getAttribute("name")||void 0,valueFormat:this.getAttribute("value-format")||"json",getValueFormatCallback:this._getValueFormatCallback,isPillTooltipsEnabled:this.getAttribute("enable-pill-tooltips")==="true",getPillTooltipCallback:this._getPillTooltipCallback,pillTooltipPlacement:this.getAttribute("pill-tooltip-placement")||"top",pillTooltipDelay:parseInt(this.getAttribute("pill-tooltip-delay")||"300"),pillTooltipOffset:parseInt(this.getAttribute("pill-tooltip-offset")||"8"),getCountPillCallback:this._getCountPillCallback||((o,s)=>s!==void 0?`+${s} more`:`${o} selected`),options:this._options,beforeSearchCallback:this._beforeSearchCallback,searchCallback:this._searchCallback,addNewCallback:this._addNewCallback,selectCallback:o=>{var s,n;this._selectCallback&&this._selectCallback(o),this.dispatchEvent(new CustomEvent("select",{detail:{option:o,selectedOptions:(s=this.picker)==null?void 0:s.getSelected(),selectedValues:Array.from(((n=this.picker)==null?void 0:n.getValue())||[])}}))},deselectCallback:o=>{var s,n;this._deselectCallback&&this._deselectCallback(o),this.dispatchEvent(new CustomEvent("deselect",{detail:{option:o,selectedOptions:(s=this.picker)==null?void 0:s.getSelected(),selectedValues:Array.from(((n=this.picker)==null?void 0:n.getValue())||[])}}))},changeCallback:o=>{var s;this._changeCallback&&this._changeCallback(o),this.dispatchEvent(new CustomEvent("change",{detail:{selectedOptions:o,selectedValues:Array.from(((s=this.picker)==null?void 0:s.getValue())||[])}}))},container:this.shadow,hostElement:this};t&&(this.containerElement.dataset.initialValues=JSON.stringify(t)),this.picker=new ot(this.containerElement,l)}reinitialize(){this.picker&&(this.picker.destroy(),this.initializePicker())}get options(){return this._options}set options(t){this._options=t,this.reinitialize()}set valueMember(t){this._valueMember=t||void 0,t?this.setAttribute("value-member",t):this.removeAttribute("value-member")}get valueMember(){return this.getAttribute("value-member")}set displayValueMember(t){this._displayValueMember=t||void 0,t?this.setAttribute("display-value-member",t):this.removeAttribute("display-value-member")}get displayValueMember(){return this.getAttribute("display-value-member")}set searchValueMember(t){this._searchValueMember=t||void 0,t?this.setAttribute("search-value-member",t):this.removeAttribute("search-value-member")}get searchValueMember(){return this.getAttribute("search-value-member")}set iconMember(t){this._iconMember=t||void 0,t?this.setAttribute("icon-member",t):this.removeAttribute("icon-member")}get iconMember(){return this.getAttribute("icon-member")}set subtitleMember(t){this._subtitleMember=t||void 0,t?this.setAttribute("subtitle-member",t):this.removeAttribute("subtitle-member")}get subtitleMember(){return this.getAttribute("subtitle-member")}set groupMember(t){this._groupMember=t||void 0,t?this.setAttribute("group-member",t):this.removeAttribute("group-member")}get groupMember(){return this.getAttribute("group-member")}set disabledMember(t){this._disabledMember=t||void 0,t?this.setAttribute("disabled-member",t):this.removeAttribute("disabled-member")}get disabledMember(){return this.getAttribute("disabled-member")}set getValueCallback(t){this._getValueCallback=t,this.reinitialize()}get getValueCallback(){return this._getValueCallback}set getDisplayValueCallback(t){this._getDisplayValueCallback=t,this.reinitialize()}get getDisplayValueCallback(){return this._getDisplayValueCallback}set getPillDisplayCallback(t){this._getPillDisplayCallback=t,this.reinitialize()}get getPillDisplayCallback(){return this._getPillDisplayCallback}set getSearchValueCallback(t){this._getSearchValueCallback=t,this.reinitialize()}get getSearchValueCallback(){return this._getSearchValueCallback}set getIconCallback(t){this._getIconCallback=t,this.reinitialize()}get getIconCallback(){return this._getIconCallback}set getSubtitleCallback(t){this._getSubtitleCallback=t,this.reinitialize()}get getSubtitleCallback(){return this._getSubtitleCallback}set getGroupCallback(t){this._getGroupCallback=t,this.reinitialize()}get getGroupCallback(){return this._getGroupCallback}set getDisabledCallback(t){this._getDisabledCallback=t,this.reinitialize()}get getDisabledCallback(){return this._getDisabledCallback}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get name(){return this.getAttribute("name")}set valueFormat(t){t?this.setAttribute("value-format",t):this.removeAttribute("value-format")}get valueFormat(){return this.getAttribute("value-format")}set getValueFormatCallback(t){this._getValueFormatCallback=t,this.reinitialize()}get getValueFormatCallback(){return this._getValueFormatCallback}set thresholdMode(t){t?this.setAttribute("threshold-mode",t):this.removeAttribute("threshold-mode")}get thresholdMode(){return this.getAttribute("threshold-mode")}set pillsMaxVisible(t){t!==null?this.setAttribute("pills-max-visible",String(t)):this.removeAttribute("pills-max-visible")}get pillsMaxVisible(){const t=this.getAttribute("pills-max-visible");return t?parseInt(t):null}set enablePillTooltips(t){t?this.setAttribute("enable-pill-tooltips","true"):this.removeAttribute("enable-pill-tooltips")}get enablePillTooltips(){return this.getAttribute("enable-pill-tooltips")==="true"}set pillTooltipPlacement(t){t?this.setAttribute("pill-tooltip-placement",t):this.removeAttribute("pill-tooltip-placement")}get pillTooltipPlacement(){return this.getAttribute("pill-tooltip-placement")}set getPillTooltipCallback(t){this._getPillTooltipCallback=t,this.reinitialize()}get getPillTooltipCallback(){return this._getPillTooltipCallback}set getCountPillCallback(t){this._getCountPillCallback=t,this.reinitialize()}get getCountPillCallback(){return this._getCountPillCallback}get beforeSearchCallback(){return this._beforeSearchCallback}set beforeSearchCallback(t){this._beforeSearchCallback=t,this.reinitialize()}get searchCallback(){return this._searchCallback}set searchCallback(t){this._searchCallback=t,this.reinitialize()}get addNewCallback(){return this._addNewCallback}set addNewCallback(t){this._addNewCallback=t,this.reinitialize()}get selectCallback(){return this._selectCallback}set selectCallback(t){this._selectCallback=t}get deselectCallback(){return this._deselectCallback}set deselectCallback(t){this._deselectCallback=t}get changeCallback(){return this._changeCallback}set changeCallback(t){this._changeCallback=t}get selectedValue(){var t;return((t=this.picker)==null?void 0:t.selectedValue)??null}get selectedItem(){var t;return((t=this.picker)==null?void 0:t.selectedItem)??null}getSelected(){return this.picker?this.picker.getSelected():[]}setSelected(t){this.picker&&this.picker.setSelected(t)}getValue(){return this.picker?this.picker.getValue():null}destroy(){this.picker&&this.picker.destroy()}}typeof window<"u"&&typeof customElements<"u"&&(customElements.get("web-multiselect")||customElements.define("web-multiselect",Le)),typeof window<"u"&&(window.keenmate=window.keenmate||{},window.keenmate.multiselect={version:()=>"1.0.0-rc08",config:{name:"@keenmate/web-multiselect",version:"1.0.0-rc08",author:"Keenmate",license:"MIT",repository:"git+https://github.com/keenmate/web-multiselect.git",homepage:"https://github.com/keenmate/web-multiselect#readme"},register:()=>{typeof customElements<"u"&&!customElements.get("web-multiselect")&&customElements.define("web-multiselect",Le)},getInstances:()=>st()}),C.MultiSelectElement=Le,C.PureMultiSelect=ot,C.dataLogger=k,C.disableLogging=ci,C.enableCategory=di,C.enableLogging=ai,C.initLogger=N,C.interactionLogger=S,C.setLogLevel=Pe,C.uiLogger=g,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});