import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{t}from"./react-Augu_vA3.js";import{C as n,D as r,E as i,M as a,O as o,S as s,T as c,Wt as l,Y as u,_ as d,_t as f,a as p,b as m,c as h,ct as g,d as _,dt as v,f as y,i as b,l as x,m as S,mt as C,o as w,q as T,qi as E,qr as D,s as O,v as k,y as A,zt as j}from"./forms-CL2ODv4X.js";import{t as M}from"./useTranslation-B_YCgyrR.js";import{t as N}from"./jsx-runtime-CTknu7_t.js";import{a as P}from"./cards-CR_9H_Xm.js";import{a as F,d as I,i as L,l as R,n as z,o as B,r as ee,s as te,t as ne,y as re}from"./active-element-history-VhWq-uws.js";import{t as ie}from"./Plus-sxGnuR_5.js";import{t as V}from"./useDebounce-n27W-x2R.js";var H=e(t(),1),ae=e(E(),1);function U(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length{r=e},o}function W(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var G=(e,t)=>Math.abs(e-t)<1.01,oe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},K=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},se=e=>e,q=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},ce=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(K(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(K(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},le={passive:!0},ue=typeof window>`u`||`onscrollend`in window,de=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&ue?()=>void 0:oe(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,le);let l=e.options.useScrollendEvent&&ue;return l&&n.addEventListener(`scrollend`,c,le),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},fe=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},pe=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},me=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:se,rangeExtractor:q,onChange:()=>{},measureElement:fe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=U(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.ende.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=U(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=U(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=U(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?ge({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=U(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{let n=this.indexFromElement(e),r=this.measurementsCache[n];if(!r)return;let i=r.key,a=this.elementsCache.get(i);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(i,e)),e.isConnected&&this.resizeItem(n,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}this._measureElement(e,void 0)},this.getVirtualItems=U(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;rthis.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return W(t[he(0,t.length-1,e=>W(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.measurementsCache[e];if(!n)return;let r=this.getSize(),i=this.getScrollOffset();if(t===`auto`)if(n.end>=i+r-this.options.scrollPaddingEnd)t=`end`;else if(n.start<=i+this.options.scrollPaddingStart)t=`start`;else return[i,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,n.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:t=`start`,behavior:n}={})=>{n===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:n})},this.scrollToIndex=(e,{align:t=`auto`,behavior:n}={})=>{n===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1)),this.currentScrollToIndex=e;let r=0,i=t=>{if(!this.targetWindow)return;let r=this.getOffsetForIndex(e,t);if(!r){console.warn(`Failed to get offset for index:`,e);return}let[i,o]=r;this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{let t=()=>{if(this.currentScrollToIndex!==e)return;let t=this.getScrollOffset(),n=this.getOffsetForIndex(e,o);if(!n){console.warn(`Failed to get offset for index:`,e);return}G(n[0],t)||a(o)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(t):t()})},a=t=>{this.targetWindow&&this.currentScrollToIndex===e&&(r++,r<10?this.targetWindow.requestAnimationFrame(()=>i(t)):console.warn(`Failed to scroll to index ${e} after 10 attempts.`))};i(t)},this.scrollBy=(e,{behavior:t}={})=>{t===`smooth`&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:t})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}},he=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(ar)t=i-1;else return i}return e>0?e-1:0};function ge({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=he(0,i,a,n),s=o;if(r===1)for(;s1){let a=Array(r).fill(0);for(;se=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var _e=typeof document<`u`?H.useLayoutEffect:H.useEffect;function ve({useFlushSync:e=!0,...t}){let n=H.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,ae.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=H.useState(()=>new me(r));return i.setOptions(r),_e(()=>i._didMount(),[]),_e(()=>i._willUpdate()),i}function ye(e){return ve({observeElementRect:ce,observeElementOffset:de,scrollToFn:pe,...e})}function be(e,t){let[n,i]=(0,H.useState)(e),a=r(e);return o(()=>i(a.current),[a,i,...t]),n}function xe(e){return[e.screenX,e.screenY]}function Se(){let e=(0,H.useRef)([-1,-1]);return{wasMoved(t){let n=xe(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=xe(t)}}}function Ce({container:e,accept:t,walk:n,enabled:r=!0}){let i=(0,H.useRef)(t),a=(0,H.useRef)(n);(0,H.useEffect)(()=>{i.current=t,a.current=n},[t,n]),o(()=>{if(!e||!r)return;let t=re(e);if(!t)return;let n=i.current,o=a.current,s=Object.assign(e=>n(e),{acceptNode:n}),c=t.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,s,!1);for(;c.nextNode();)o(c.currentNode)},[e,r,i,a])}function we(e){throw Error(`Unexpected object: `+e)}var J=(e=>(e[e.First=0]=`First`,e[e.Previous=1]=`Previous`,e[e.Next=2]=`Next`,e[e.Last=3]=`Last`,e[e.Specific=4]=`Specific`,e[e.Nothing=5]=`Nothing`,e))(J||{});function Te(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),i=r??-1;switch(e.focus){case 0:for(let e=0;e=0;--e)if(!t.resolveDisabled(n[e],e,n))return e;return r;case 2:for(let e=i+1;e=0;--e)if(!t.resolveDisabled(n[e],e,n))return e;return r;case 4:for(let r=0;r(e[e.Open=0]=`Open`,e[e.Closed=1]=`Closed`,e))(Ee||{}),De=(e=>(e[e.Single=0]=`Single`,e[e.Multi=1]=`Multi`,e))(De||{}),Oe=(e=>(e[e.Pointer=0]=`Pointer`,e[e.Focus=1]=`Focus`,e[e.Other=2]=`Other`,e))(Oe||{}),ke=(e=>(e[e.OpenCombobox=0]=`OpenCombobox`,e[e.CloseCombobox=1]=`CloseCombobox`,e[e.GoToOption=2]=`GoToOption`,e[e.RegisterOption=3]=`RegisterOption`,e[e.UnregisterOption=4]=`UnregisterOption`,e[e.RegisterLabel=5]=`RegisterLabel`,e[e.SetActivationTrigger=6]=`SetActivationTrigger`,e[e.UpdateVirtualOptions=7]=`UpdateVirtualOptions`,e))(ke||{});function Ae(e,t=e=>e){let n=e.activeOptionIndex===null?null:e.options[e.activeOptionIndex],r=t(e.options.slice()),i=r.length>0&&r[0].dataRef.current.order!==null?r.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):I(r,e=>e.dataRef.current.domRef.current),a=n?i.indexOf(n):null;return a===-1&&(a=null),{options:i,activeOptionIndex:a}}var je={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(t!==-1)return{...e,activeOptionIndex:t,comboboxState:0}}return{...e,comboboxState:0}},2(e,t){var n,r,i;if((n=e.dataRef.current)!=null&&n.disabled||(r=e.dataRef.current)!=null&&r.optionsRef.current&&!((i=e.dataRef.current)!=null&&i.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let n=t.focus===J.Specific?t.idx:Te(t,{resolveItems:()=>e.virtual.options,resolveActiveIndex:()=>e.activeOptionIndex??e.virtual.options.findIndex(t=>!e.virtual.disabled(t))??null,resolveDisabled:e.virtual.disabled,resolveId(){throw Error(`Function not implemented.`)}}),r=t.trigger??2;return e.activeOptionIndex===n&&e.activationTrigger===r?e:{...e,activeOptionIndex:n,activationTrigger:r}}let a=Ae(e);if(a.activeOptionIndex===null){let e=a.options.findIndex(e=>!e.dataRef.current.disabled);e!==-1&&(a.activeOptionIndex=e)}let o=t.focus===J.Specific?t.idx:Te(t,{resolveItems:()=>a.options,resolveActiveIndex:()=>a.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),s=t.trigger??2;return e.activeOptionIndex===o&&e.activationTrigger===s?e:{...e,...a,activeOptionIndex:o,activationTrigger:s}},3:(e,t)=>{var n,r,i;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let a=t.payload,o=Ae(e,e=>(e.push(a),e));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(o.activeOptionIndex=o.options.indexOf(a));let s={...e,...o,activationTrigger:2};return(i=e.dataRef.current)!=null&&i.__demoMode&&e.dataRef.current.value===void 0&&(s.activeOptionIndex=0),s},4:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let r=Ae(e,e=>{let n=e.findIndex(e=>e.id===t.id);return n!==-1&&e.splice(n,1),e});return{...e,...r,activationTrigger:2}},5:(e,t)=>e.labelId===t.id?e:{...e,labelId:t.id},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{if(e.virtual?.options===t.options)return e;let n=e.activeOptionIndex;if(e.activeOptionIndex!==null){let r=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=r===-1?null:r}return{...e,activeOptionIndex:n,virtual:Object.assign({},e.virtual,{options:t.options})}}},Me=(0,H.createContext)(null);Me.displayName=`ComboboxActionsContext`;function Y(e){let t=(0,H.useContext)(Me);if(t===null){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Y),t}return t}var Ne=(0,H.createContext)(null);function Pe(e){let t=X(`VirtualProvider`),[n,r]=(0,H.useMemo)(()=>{let e=t.optionsRef.current;if(!e)return[0,0];let n=window.getComputedStyle(e);return[parseFloat(n.paddingBlockStart||n.paddingTop),parseFloat(n.paddingBlockEnd||n.paddingBottom)]},[t.optionsRef.current]),i=ye({scrollPaddingStart:n,scrollPaddingEnd:r,count:t.virtual.options.length,estimateSize(){return 40},getScrollElement(){return t.optionsRef.current??null},overscan:12}),[a,s]=(0,H.useState)(0);return o(()=>{s(e=>e+1)},[t.virtual?.options]),H.createElement(Ne.Provider,{value:i},H.createElement(`div`,{style:{position:`relative`,width:`100%`,height:`${i.getTotalSize()}px`},ref:e=>{if(e){if(typeof process<`u`&&{}.JEST_WORKER_ID!==void 0||t.activationTrigger===0)return;t.activeOptionIndex!==null&&t.virtual.options.length>t.activeOptionIndex&&i.scrollToIndex(t.activeOptionIndex)}}},i.getVirtualItems().map(n=>H.createElement(H.Fragment,{key:n.key},H.cloneElement(e.children?.call(e,{option:t.virtual.options[n.index],open:t.comboboxState===0}),{key:`${a}-${n.key}`,"data-index":n.index,"aria-setsize":t.virtual.options.length,"aria-posinset":n.index+1,style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,overflowAnchor:`none`}})))))}var Fe=(0,H.createContext)(null);Fe.displayName=`ComboboxDataContext`;function X(e){let t=(0,H.useContext)(Fe);if(t===null){let t=Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,X),t}return t}function Ie(e,t){return A(t.type,je,e,t)}var Le=H.Fragment;function Re(e,t){let{value:n,defaultValue:r,onChange:a,form:l,name:u,by:d=null,disabled:f=!1,__demoMode:m=!1,nullable:g=!1,multiple:_=!1,immediate:v=!1,virtual:y=null,...b}=e,[C=_?[]:void 0,w]=c(n,a,r),[T,E]=(0,H.useReducer)(Ie,{dataRef:(0,H.createRef)(),comboboxState:+!m,options:[],virtual:null,activeOptionIndex:null,activationTrigger:2,labelId:null}),D=(0,H.useRef)(!1),k=(0,H.useRef)({static:!1,hold:!1}),j=(0,H.useRef)(null),M=(0,H.useRef)(null),N=(0,H.useRef)(null),P=(0,H.useRef)(null),F=i(typeof d==`string`?(e,t)=>{let n=d;return e?.[n]===t?.[n]}:d??((e,t)=>e===t)),I=i(e=>T.options.findIndex(t=>F(t.dataRef.current.value,e))),L=(0,H.useCallback)(e=>A(B.mode,{1:()=>C.some(t=>F(t,e)),0:()=>F(C,e)}),[C]),R=i(e=>T.activeOptionIndex===I(e)),B=(0,H.useMemo)(()=>({...T,immediate:!1,optionsPropsRef:k,labelRef:j,inputRef:M,buttonRef:N,optionsRef:P,value:C,defaultValue:r,disabled:f,mode:+!!_,virtual:T.virtual,get activeOptionIndex(){if(D.current&&T.activeOptionIndex===null&&T.options.length>0){let e=T.options.findIndex(e=>!e.dataRef.current.disabled);if(e!==-1)return e}return T.activeOptionIndex},calculateIndex:I,compare:F,isSelected:L,isActive:R,nullable:g,__demoMode:m}),[C,r,f,_,g,m,T,null]);o(()=>{},[null,void 0]),o(()=>{T.dataRef.current=B},[B]),te([B.buttonRef,B.inputRef,B.optionsRef],()=>K.closeCombobox(),B.comboboxState===0);let ne=(0,H.useMemo)(()=>({open:B.comboboxState===0,disabled:f,activeIndex:B.activeOptionIndex,activeOption:B.activeOptionIndex===null?null:B.virtual?B.virtual.options[B.activeOptionIndex??0]:B.options[B.activeOptionIndex]?.dataRef.current.value??null,value:C}),[B,f,C]),re=i(()=>{if(B.activeOptionIndex!==null){if(B.virtual)G(B.virtual.options[B.activeOptionIndex]);else{let{dataRef:e}=B.options[B.activeOptionIndex];G(e.current.value)}K.goToOption(J.Specific,B.activeOptionIndex)}}),ie=i(()=>{E({type:0}),D.current=!0}),V=i(()=>{E({type:1}),D.current=!1}),ae=i((e,t,n)=>(D.current=!1,e===J.Specific?E({type:2,focus:J.Specific,idx:t,trigger:n}):E({type:2,focus:e,trigger:n}))),U=i((e,t)=>(E({type:3,payload:{id:e,dataRef:t}}),()=>{B.isActive(t.current.value)&&(D.current=!0),E({type:4,id:e})})),W=i(e=>(E({type:5,id:e}),()=>E({type:5,id:null}))),G=i(e=>A(B.mode,{0(){return w?.(e)},1(){let t=B.value.slice(),n=t.findIndex(t=>F(t,e));return n===-1?t.push(e):t.splice(n,1),w?.(t)}})),oe=i(e=>{E({type:6,trigger:e})}),K=(0,H.useMemo)(()=>({onChange:G,registerOption:U,registerLabel:W,goToOption:ae,closeCombobox:V,openCombobox:ie,setActivationTrigger:oe,selectActiveOption:re}),[]),se=t===null?{}:{ref:t},q=(0,H.useRef)(null),ce=s();return(0,H.useEffect)(()=>{q.current&&r!==void 0&&ce.addEventListener(q.current,`reset`,()=>{w?.(r)})},[q,w]),H.createElement(Me.Provider,{value:K},H.createElement(Fe.Provider,{value:B},H.createElement(ee,{value:A(B.comboboxState,{0:z.Open,1:z.Closed})},u!=null&&C!=null&&p({[u]:C}).map(([e,t],n)=>H.createElement(h,{features:O.Hidden,ref:n===0?e=>{q.current=e?.closest(`form`)??null}:void 0,...S({key:e,as:`input`,type:`hidden`,hidden:!0,readOnly:!0,form:l,disabled:f,name:e,value:t})})),x({ourProps:se,theirProps:b,slot:ne,defaultTag:Le,name:`Combobox`}))))}var ze=`input`;function Be(e,t){let n=m(),{id:r=`headlessui-combobox-input-${n}`,onChange:a,displayValue:o,type:c=`text`,...l}=e,u=X(`Combobox.Input`),f=Y(`Combobox.Input`),p=d(u.inputRef,t),h=B(u.inputRef),g=(0,H.useRef)(!1),_=s(),v=i(()=>{f.onChange(null),u.optionsRef.current&&(u.optionsRef.current.scrollTop=0),f.goToOption(J.Nothing)});F(([e,t],[n,r])=>{if(g.current)return;let i=u.inputRef.current;i&&((r===0&&t===1||e!==n)&&(i.value=e),requestAnimationFrame(()=>{if(g.current||!i||h?.activeElement!==i)return;let{selectionStart:e,selectionEnd:t}=i;Math.abs((t??0)-(e??0))===0&&e===0&&i.setSelectionRange(i.value.length,i.value.length)}))},[function(){return typeof o==`function`&&u.value!==void 0?o(u.value)??``:typeof u.value==`string`?u.value:``}(),u.comboboxState,h]),F(([e],[t])=>{if(e===0&&t===1){if(g.current)return;let e=u.inputRef.current;if(!e)return;let t=e.value,{selectionStart:n,selectionEnd:r,selectionDirection:i}=e;e.value=``,e.value=t,i===null?e.setSelectionRange(n,r):e.setSelectionRange(n,r,i)}},[u.comboboxState]);let y=(0,H.useRef)(!1),S=i(()=>{y.current=!0}),C=i(()=>{_.nextFrame(()=>{y.current=!1})}),w=i(e=>{switch(g.current=!0,e.key){case b.Enter:if(g.current=!1,u.comboboxState!==0||y.current)return;if(e.preventDefault(),e.stopPropagation(),u.activeOptionIndex===null){f.closeCombobox();return}f.selectActiveOption(),u.mode===0&&f.closeCombobox();break;case b.ArrowDown:return g.current=!1,e.preventDefault(),e.stopPropagation(),A(u.comboboxState,{0:()=>f.goToOption(J.Next),1:()=>f.openCombobox()});case b.ArrowUp:return g.current=!1,e.preventDefault(),e.stopPropagation(),A(u.comboboxState,{0:()=>f.goToOption(J.Previous),1:()=>{f.openCombobox(),_.nextFrame(()=>{u.value||f.goToOption(J.Last)})}});case b.Home:if(e.shiftKey)break;return g.current=!1,e.preventDefault(),e.stopPropagation(),f.goToOption(J.First);case b.PageUp:return g.current=!1,e.preventDefault(),e.stopPropagation(),f.goToOption(J.First);case b.End:if(e.shiftKey)break;return g.current=!1,e.preventDefault(),e.stopPropagation(),f.goToOption(J.Last);case b.PageDown:return g.current=!1,e.preventDefault(),e.stopPropagation(),f.goToOption(J.Last);case b.Escape:return g.current=!1,u.comboboxState===0?(e.preventDefault(),u.optionsRef.current&&!u.optionsPropsRef.current.static&&e.stopPropagation(),u.nullable&&u.mode===0&&u.value===null&&v(),f.closeCombobox()):void 0;case b.Tab:if(g.current=!1,u.comboboxState!==0)return;u.mode===0&&u.activationTrigger!==1&&f.selectActiveOption(),f.closeCombobox();break}}),T=i(e=>{a?.(e),u.nullable&&u.mode===0&&e.target.value===``&&v(),f.openCombobox()}),E=i(e=>{var t,n;let r=e.relatedTarget??ne.find(t=>t!==e.currentTarget);if(g.current=!1,!((t=u.optionsRef.current)!=null&&t.contains(r))&&!((n=u.buttonRef.current)!=null&&n.contains(r))&&u.comboboxState===0)return e.preventDefault(),u.mode===0&&(u.nullable&&u.value===null?v():u.activationTrigger!==1&&f.selectActiveOption()),f.closeCombobox()}),D=i(e=>{var t,n;let r=e.relatedTarget??ne.find(t=>t!==e.currentTarget);(t=u.buttonRef.current)!=null&&t.contains(r)||(n=u.optionsRef.current)!=null&&n.contains(r)||u.disabled||u.immediate&&u.comboboxState!==0&&(f.openCombobox(),_.nextFrame(()=>{f.setActivationTrigger(1)}))}),O=be(()=>{if(u.labelId)return[u.labelId].join(` `)},[u.labelId]),k=(0,H.useMemo)(()=>({open:u.comboboxState===0,disabled:u.disabled}),[u]);return x({ourProps:{ref:p,id:r,role:`combobox`,type:c,"aria-controls":u.optionsRef.current?.id,"aria-expanded":u.comboboxState===0,"aria-activedescendant":u.activeOptionIndex===null?void 0:u.virtual?u.options.find(e=>{var t;return!((t=u.virtual)!=null&&t.disabled(e.dataRef.current.value))&&u.compare(e.dataRef.current.value,u.virtual.options[u.activeOptionIndex])})?.id:u.options[u.activeOptionIndex]?.id,"aria-labelledby":O,"aria-autocomplete":`list`,defaultValue:e.defaultValue??(u.defaultValue===void 0?null:o?.(u.defaultValue))??u.defaultValue,disabled:u.disabled,onCompositionStart:S,onCompositionEnd:C,onKeyDown:w,onChange:T,onFocus:D,onBlur:E},theirProps:l,slot:k,defaultTag:ze,name:`Combobox.Input`})}var Ve=`button`;function He(e,t){let n=X(`Combobox.Button`),r=Y(`Combobox.Button`),a=d(n.buttonRef,t),o=m(),{id:c=`headlessui-combobox-button-${o}`,...l}=e,u=s(),f=i(e=>{switch(e.key){case b.ArrowDown:return e.preventDefault(),e.stopPropagation(),n.comboboxState===1&&r.openCombobox(),u.nextFrame(()=>n.inputRef.current?.focus({preventScroll:!0}));case b.ArrowUp:return e.preventDefault(),e.stopPropagation(),n.comboboxState===1&&(r.openCombobox(),u.nextFrame(()=>{n.value||r.goToOption(J.Last)})),u.nextFrame(()=>n.inputRef.current?.focus({preventScroll:!0}));case b.Escape:return n.comboboxState===0?(e.preventDefault(),n.optionsRef.current&&!n.optionsPropsRef.current.static&&e.stopPropagation(),r.closeCombobox(),u.nextFrame(()=>n.inputRef.current?.focus({preventScroll:!0}))):void 0;default:return}}),p=i(e=>{if(w(e.currentTarget))return e.preventDefault();n.comboboxState===0?r.closeCombobox():(e.preventDefault(),r.openCombobox()),u.nextFrame(()=>n.inputRef.current?.focus({preventScroll:!0}))}),h=be(()=>{if(n.labelId)return[n.labelId,c].join(` `)},[n.labelId,c]),g=(0,H.useMemo)(()=>({open:n.comboboxState===0,disabled:n.disabled,value:n.value}),[n]);return x({ourProps:{ref:a,id:c,type:k(e,n.buttonRef),tabIndex:-1,"aria-haspopup":`listbox`,"aria-controls":n.optionsRef.current?.id,"aria-expanded":n.comboboxState===0,"aria-labelledby":h,disabled:n.disabled,onClick:p,onKeyDown:f},theirProps:l,slot:g,defaultTag:Ve,name:`Combobox.Button`})}var Ue=`label`;function We(e,t){let n=m(),{id:r=`headlessui-combobox-label-${n}`,...a}=e,s=X(`Combobox.Label`),c=Y(`Combobox.Label`),l=d(s.labelRef,t);o(()=>c.registerLabel(r),[r]);let u=i(()=>s.inputRef.current?.focus({preventScroll:!0})),f=(0,H.useMemo)(()=>({open:s.comboboxState===0,disabled:s.disabled}),[s]);return x({ourProps:{ref:l,id:r,onClick:u},theirProps:a,slot:f,defaultTag:Ue,name:`Combobox.Label`})}var Ge=`ul`,Ke=_.RenderStrategy|_.Static;function qe(e,t){let n=m(),{id:r=`headlessui-combobox-options-${n}`,hold:i=!1,...a}=e,s=X(`Combobox.Options`),c=d(s.optionsRef,t),l=L(),u=l===null?s.comboboxState===0:(l&z.Open)===z.Open;o(()=>{s.optionsPropsRef.current.static=e.static??!1},[s.optionsPropsRef,e.static]),o(()=>{s.optionsPropsRef.current.hold=i},[s.optionsPropsRef,i]),Ce({container:s.optionsRef.current,enabled:s.comboboxState===0,accept(e){return e.getAttribute(`role`)===`option`?NodeFilter.FILTER_REJECT:e.hasAttribute(`role`)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute(`role`,`none`)}});let f=be(()=>s.labelId??s.buttonRef.current?.id,[s.labelId,s.buttonRef.current]),p=(0,H.useMemo)(()=>({open:s.comboboxState===0,option:void 0}),[s]),h={"aria-labelledby":f,role:`listbox`,"aria-multiselectable":s.mode===1||void 0,id:r,ref:c};return s.virtual&&s.comboboxState===0&&Object.assign(a,{children:H.createElement(Pe,null,a.children)}),x({ourProps:h,theirProps:a,slot:p,defaultTag:Ge,features:Ke,visible:u,name:`Combobox.Options`})}var Je=`li`;function Ye(e,t){let a=m(),{id:s=`headlessui-combobox-option-${a}`,disabled:c=!1,value:l,order:u=null,...f}=e,p=X(`Combobox.Option`),h=Y(`Combobox.Option`),g=p.virtual?p.activeOptionIndex===p.calculateIndex(l):p.activeOptionIndex!==null&&p.options[p.activeOptionIndex]?.id===s,_=p.isSelected(l),v=(0,H.useRef)(null),y=r({disabled:c,value:l,domRef:v,order:u}),b=(0,H.useContext)(Ne),S=d(t,v,b?b.measureElement:null),C=i(()=>h.onChange(l));o(()=>h.registerOption(s,y),[y,s]);let w=(0,H.useRef)(!(p.virtual||p.__demoMode));o(()=>{if(!p.virtual||!p.__demoMode)return;let e=n();return e.requestAnimationFrame(()=>{w.current=!0}),e.dispose},[p.virtual,p.__demoMode]),o(()=>{if(!w.current||p.comboboxState!==0||!g||p.activationTrigger===0)return;let e=n();return e.requestAnimationFrame(()=>{var e,t;(t=(e=v.current)?.scrollIntoView)==null||t.call(e,{block:`nearest`})}),e.dispose},[v,g,p.comboboxState,p.activationTrigger,p.activeOptionIndex]);let T=i(e=>{var t;if(c||(t=p.virtual)!=null&&t.disabled(l))return e.preventDefault();C(),R()||requestAnimationFrame(()=>p.inputRef.current?.focus({preventScroll:!0})),p.mode===0&&requestAnimationFrame(()=>h.closeCombobox())}),E=i(()=>{var e;if(c||(e=p.virtual)!=null&&e.disabled(l))return h.goToOption(J.Nothing);let t=p.calculateIndex(l);h.goToOption(J.Specific,t)}),D=Se(),O=i(e=>D.update(e)),k=i(e=>{var t;if(!D.wasMoved(e)||c||(t=p.virtual)!=null&&t.disabled(l)||g)return;let n=p.calculateIndex(l);h.goToOption(J.Specific,n,0)}),A=i(e=>{var t;D.wasMoved(e)&&(c||(t=p.virtual)!=null&&t.disabled(l)||g&&(p.optionsPropsRef.current.hold||h.goToOption(J.Nothing)))}),j=(0,H.useMemo)(()=>({active:g,selected:_,disabled:c}),[g,_,c]);return x({ourProps:{id:s,ref:S,role:`option`,tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0||void 0,"aria-selected":_,disabled:void 0,onClick:T,onFocus:E,onPointerEnter:O,onMouseEnter:O,onPointerMove:k,onMouseMove:k,onPointerLeave:A,onMouseLeave:A},theirProps:f,slot:j,defaultTag:Je,name:`Combobox.Option`})}var Xe=y(Re),Ze=y(He),Qe=y(Be),$e=y(We),et=y(qe),tt=y(Ye),Z=Object.assign(Xe,{Input:Qe,Button:Ze,Label:$e,Options:et,Option:tt}),Q=e(v(),1),$=e(N(),1);function nt({color:e=`#000`,size:t=`1.1rem`}){return(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,x:`0px`,y:`0px`,style:{width:t,height:t},viewBox:`0 0 12 12`,children:(0,$.jsx)(`path`,{d:`m1.75,6c1.047,1.048,1.803,2.153,2.461,3.579,1.524-3.076,3.659-5.397,6.039-7.158`,fill:`none`,stroke:e,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`})})}var rt=g(Z.Option)` &:hover { background-color: ${e=>e.theme.hoverColor}; } `,it=g.button` &:hover { background-color: ${e=>e.theme.hoverColor}; } `,at=g.li` background-color: ${e=>e.theme.backgroundColor}; &:hover { background-color: ${e=>e.theme.hoverColor}; } `;function ot({inputOptions:e,entries:t,readonly:n,nullable:r,initiallyVisible:i=!1,exclude:o=[],includeOnly:s=[],includeByLabel:c,action:l,onChange:d,onDismiss:p,entryOptions:m,errorMessage:h,clearInputAfterSelection:g,onEmptyValues:_,onFocus:v,onInputValueChange:y,withShadow:b}){let x=f(),S=D(),[C,w]=(0,H.useState)(String(e.value??``)),[E,O]=(0,H.useState)(i),[k,A]=(0,H.useState)(null),[j,M]=(0,H.useState)(-1),N=(0,H.useRef)(null),F=(0,H.useRef)(null),I=C===``?t:t.filter(e=>e.label?.toLowerCase()?.includes(C?.toLowerCase())||e.value?.toString()?.toLowerCase()?.includes(C?.toLowerCase())||e.searchable.toLowerCase().includes(C?.toLowerCase()));I=I.filter(e=>o.length>0?!o.includes(e.value):!0),I=I.filter(e=>s.length>0?s.includes(e[c?`label`:`value`]):!0),(0,H.useEffect)(()=>{let n=t.findIndex(t=>t.value===e.value||t.label===e.value);if(n>=0){A(t[n]),M(n);return}if(r){A({id:-1,label:e.value?e.value.toString():``,value:e.value?e.value.toString():``,resource:null,eventType:`internal`,searchable:m.searchable||m.value});return}},[t]);let L=e=>{w(e),A(null),O(!0),M(-1)},R=e=>{k&&k.value===e.value||(A(e),w(e.label),d(e),g&&(w(``),A(null)),setTimeout(()=>O(!1),100))};return P(N,()=>{if(O(!1),y?.(C),k&&k.value&&C===k.value||C===``)return;let e={id:Date.now(),label:C,value:C,resource:null,eventType:`internal`,searchable:C.toLowerCase()};R(e),d(e)}),V(()=>{if(_&&(C===``&&I.length>0||I.length<=3))return _(C)},600,[C,I]),(0,H.useEffect)(()=>{let e=document.querySelector(`[data-combobox-element-id="${j+1}"]`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`start`})},[j]),(0,$.jsxs)(`div`,{ref:N,className:`w-full`,tabIndex:-1,children:[e.label?(0,$.jsx)(`p`,{className:(0,Q.default)(`text-sm font-medium block`,e.className),style:{color:x.$16},children:e.label}):null,(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`div`,{className:(0,Q.default)(`relative w-full cursor-default overflow-hidden rounded-md border text-left sm:text-sm`,{"shadow-sm":b,"border-[#09090B26]":!S.dark_mode&&!E,"border-black":!S.dark_mode&&E,"border-[#1f2e41]":S.dark_mode&&!E,"border-white":S.dark_mode&&E}),children:[(0,$.jsx)(`input`,{type:`text`,onChange:e=>L(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`&&j0){e.preventDefault(),M(j-1);return}if(e.key===`Enter`){if(O(!1),j>=0){R(I[j]);return}j===-1&&r&&R({id:Date.now(),label:C,value:C,resource:null,eventType:`internal`,searchable:C.toLowerCase()});return}if(e.key===`Escape`){O(!1);return}if(e.key===`Tab`&&r){O(!1),R({id:Date.now(),label:C,value:C,resource:null,eventType:`internal`,searchable:C.toLowerCase()});return}},onFocus:()=>{O(!0),v&&v()},placeholder:e.placeholder,disabled:n,defaultValue:k?k.label:C?.toString(),className:`w-full rounded-md py-1.5 pl-3 pr-10 shadow-sm sm:text-sm sm:leading-6 focus:outline-none focus:ring-0`,ref:F,style:{backgroundColor:x.$1,color:x.$3,border:`none`},"data-cy":`comboboxInput`,tabIndex:-1}),!n&&(0,$.jsx)(`button`,{tabIndex:-1,type:`button`,onClick:e=>{if(p)return e.preventDefault(),O(!1),w(``),F&&F.current&&(F.current.value=``),p()},className:`absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none`,children:p&&k?(0,$.jsx)(a,{size:`0.9rem`,color:x.$3,"data-testid":`combobox-clear-icon`}):(0,$.jsx)(u,{color:x.$3,size:`0.9rem`,"data-testid":`combobox-chevrondown-icon`})})]})}),E&&(0,$.jsxs)(`ul`,{className:`border absolute z-10 mt-1 rounded-md text-base shadow-2xl focus:outline-none sm:text-sm`,style:{backgroundColor:x.$1,borderColor:x.$24},tabIndex:-1,children:[(0,$.jsx)(`div`,{className:`flex flex-col overflow-y-auto overflow-x-hidden max-h-60 p-1`,children:I.map((e,t)=>(0,$.jsxs)(at,{theme:{backgroundColor:x.$1,hoverColor:x.$20},className:`flex items-center space-x-2 min-w-[14rem] relative cursor-pointer select-none py-2 px-3 rounded-[0.1875rem]`,onClick:()=>R(e),"data-combobox-element-id":t,tabIndex:-1,children:[j===t&&(0,$.jsx)(`div`,{className:`self-start mt-1`,children:(0,$.jsx)(nt,{size:`0.9rem`,color:x.$3})}),(0,$.jsx)(`div`,{className:(0,Q.default)({"pl-6":j!==t&&k?.value}),children:e.resource&&m.dropdownLabelFn!==void 0?m.dropdownLabelFn(e.resource):e.label})]},e.id))}),l&&l.visible&&(0,$.jsx)(`div`,{className:`border-t w-full p-1`,style:{borderColor:x.$21},children:(0,$.jsxs)(it,{theme:{hoverColor:x.$20},"data-testid":`combobox-action-button`,type:`button`,onClick:l.onClick,className:`flex items-center space-x-2 justify-start w-full relative cursor-pointer select-none py-2 px-3 rounded-[0.1875rem]`,tabIndex:-1,style:{color:x.$3},children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(ie,{size:`1rem`,color:x.$16})}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:l.label})]})})]}),(0,$.jsx)(T,{className:`mt-2`,children:h})]})}function st({inputOptions:e,entries:t,readonly:n,nullable:r,initiallyVisible:i=!1,exclude:o=[],includeOnly:s=[],includeByLabel:c,action:l,onEmptyValues:d,onChange:p,onDismiss:m,entryOptions:h,errorMessage:g,clearInputAfterSelection:_,isDataLoading:v,compareOnlyByValue:y,withShadow:b}){let[x]=M(),S=f(),w=D(),[E,O]=(0,H.useState)(``),[k,A]=(0,H.useState)(i),[j,N]=(0,H.useState)(null),F=E===``?t:t.filter(e=>e.label?.toLowerCase()?.includes(E?.toLowerCase())||e.value?.toString()?.toLowerCase()?.includes(E?.toLowerCase())||e.searchable.toLowerCase().includes(E?.toLowerCase()));F=F.filter(e=>o.length>0?!o.includes(e.value):!0),F=F.filter(e=>s.length>0?s.includes(e[c?`label`:`value`]):!0);let I=(0,H.useRef)(null),L=(0,H.useRef)(null);P(I,()=>{A(!1)}),V(()=>{if(d&&(E===``&&F.length>0||F.length<=3))return d(E)},600,[F]);let R=e=>{e&&(j&&e.value===j.value?m&&m():N(()=>({...e,eventType:`internal`})))};return(0,H.useEffect)(()=>{j&&j.eventType===`internal`&&p(j),_&&(N(null),O(``)),A(!1),L?.current&&L.current.blur()},[j]),(0,H.useEffect)(()=>{let n=t.find(t=>y?t.value===e.value:t.value===e.value||t.label===e.value);N(n||(r?{id:-1,label:e.value?e.value.toString():``,value:e.value?e.value.toString():``,resource:null,eventType:`external`,searchable:h.searchable||h.value}:null))},[t,e.value]),(0,H.useEffect)(()=>(i&&A(!0),()=>{A(!1)}),[i]),(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsxs)(Z,{as:`div`,value:j,onChange:e=>R(e),disabled:n,ref:I,children:[e.label&&(0,$.jsx)(Z.Label,{className:(0,Q.default)(`text-sm font-medium block`,e.className),style:{color:S.$16},children:e.label}),(0,$.jsx)(`div`,{className:`relative mt-1`,children:(0,$.jsxs)(`div`,{className:(0,Q.default)(`relative w-full cursor-default overflow-hidden rounded-md border text-left sm:text-sm`,{"shadow-sm":b,"border-[#09090B26]":!w.dark_mode&&!k,"border-black":!w.dark_mode&&k,"border-[#1f2e41]":w.dark_mode&&!k,"border-white":w.dark_mode&&k}),children:[(0,$.jsx)(Z.Input,{"data-testid":`combobox-input-field`,ref:L,className:`w-full rounded-md py-1.5 pl-3 pr-10 sm:text-sm sm:leading-6 focus:outline-none focus:ring-0`,onChange:e=>O(e.target.value),displayValue:e=>h.inputLabelFn?.(e?.resource)??(e?.label||E),onClick:()=>A(!0),placeholder:e.placeholder,style:{backgroundColor:S.$1,color:S.$3,border:`none`}}),!n&&(0,$.jsx)(Z.Button,{onClick:e=>{if(m)return e.preventDefault(),O(``),j&&A(!1),!j&&A(e=>!e),m();A(e=>!e)},className:`absolute inset-y-0 right-0 flex items-center rounded-r-md pl-2 pr-3 focus:outline-none`,children:m&&j?(0,$.jsx)(a,{size:`0.9rem`,color:S.$3,"data-testid":`combobox-clear-icon`}):(0,$.jsx)(u,{color:S.$3,size:`1rem`,"data-testid":`combobox-chevrondown-icon`})})]})}),k&&(0,$.jsxs)(Z.Options,{static:!0,className:`border absolute z-10 mt-1 rounded-md shadow-2xl focus:outline-none sm:text-sm`,style:{backgroundColor:S.$1,borderColor:S.$24},children:[(0,$.jsxs)(`div`,{className:`flex flex-col overflow-y-auto overflow-x-hidden max-h-60 p-1`,children:[!!v&&(0,$.jsx)(`div`,{className:`min-w-[14rem] relative cursor-default select-none py-2 pl-3 pr-9`,children:(0,$.jsx)(C,{})}),!v&&!F.length&&(0,$.jsxs)(`div`,{className:`min-w-[14rem] relative cursor-default select-none py-2 px-3 text-sm font-medium`,children:[x(`no_records_found`),`.`]}),r&&E.length>0&&!v&&(0,$.jsx)(rt,{theme:{hoverColor:S.$20},className:`min-w-[14rem] relative cursor-pointer select-none py-2 px-3 rounded-[0.1875rem]`,value:{id:-1,label:r?E:null,value:r?E:null,resource:null},children:()=>(0,$.jsxs)(`div`,{className:`block space-x-1`,children:[(0,$.jsx)(`span`,{children:x(`Select`)}),(0,$.jsx)(`q`,{className:`font-semibold`,children:E})]})},`combobox-not-found`),F.length>0&&!v&&F.map(e=>(0,$.jsx)(rt,{theme:{hoverColor:S.$20},value:e,className:`min-w-[14rem] relative cursor-pointer select-none py-2 px-3 rounded-[0.1875rem]`,style:{color:S.$3},children:({selected:t})=>(0,$.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[t&&(0,$.jsx)(`div`,{className:`self-start mt-1`,style:{color:S.$3},children:(0,$.jsx)(nt,{size:`0.9rem`,color:S.$3})}),(0,$.jsx)(`div`,{className:(0,Q.default)(`block`,{"pl-6":!t&&j?.value}),children:e.resource&&h.dropdownLabelFn!==void 0?h.dropdownLabelFn(e.resource):e.label})]})},e.id))]}),l&&l.visible&&(0,$.jsx)(`div`,{className:`border-t w-full p-1`,style:{borderColor:S.$21},children:(0,$.jsxs)(it,{theme:{hoverColor:S.$20},"data-testid":`combobox-action-button`,type:`button`,onClick:l.onClick,className:`flex items-center space-x-2 justify-start w-full relative cursor-pointer select-none py-2 px-3 rounded-[0.1875rem]`,tabIndex:-1,style:{color:S.$3},children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(ie,{size:`1rem`,color:S.$16})}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:l.label})]})})]})]}),(0,$.jsx)(T,{className:`mt-2`,children:g})]})}function ct({endpoint:e,inputOptions:t,entryOptions:n,readonly:r,staleTime:i,initiallyVisible:a,sortBy:o=`created_at|desc`,exclude:s=[],includeOnly:c,includeByLabel:u,action:d,nullable:f,onChange:p,onDismiss:m,disableWithQueryParameter:h,errorMessage:g,clearInputAfterSelection:_,onInputValueChange:v,compareOnlyByValue:y,withShadow:b,headers:x}){let[S,C]=(0,H.useState)([]),[w,T]=(0,H.useState)(e),[E,D]=(0,H.useState)(!1);(0,H.useEffect)(()=>{a&&D(!0)},[a]),(0,H.useEffect)(()=>{T(e)},[e]);let O=(0,H.useRef)(void 0),k=()=>!S.length||!!S.find(e=>e.value===t.value||e.label===t.value),{data:A,isLoading:M}=l([new URL(w).pathname,new URL(w).pathname+new URL(w).search],()=>j(`GET`,new URL(w).href,{},{headers:x||{}}).then(e=>{let t=[];return(e.data.data||[]).map(e=>t.push({id:e[n.id],label:e[n.label],value:n.customValue?n.customValue(e):e[n.value],resource:e,eventType:`external`,searchable:[n.customSearchableValue?.(e),e[n.searchable||n.id]].filter(Boolean).join(`,`)})),t}),{staleTime:i??1/0,enabled:E});(0,H.useEffect)(()=>{if(!w.includes(`/api/v1/products`)&&!E){clearTimeout(O.current);let e=setTimeout(()=>D(!0),100);O.current=e}},[t.value]),(0,H.useEffect)(()=>{E&&t.value&&!h&&!k()&&T(e=>{let n=new URL(e);return t.value&&t.value.toString().length>0&&(n.searchParams.set(`with`,t.value.toString()),n.searchParams.get(`sort`)&&n.searchParams.delete(`sort`)),n.href}),E&&!t.value&&T(e=>{let t=new URL(e);return t.searchParams.get(`with`)&&t.searchParams.delete(`with`),o&&t.searchParams.set(`sort`,o),t.href})},[S,E,t.value]),(0,H.useEffect)(()=>{A&&C([...A])},[A]),(0,H.useEffect)(()=>(T(e=>{let t=new URL(e);return o&&t.searchParams.set(`sort`,o),t.searchParams.set(`status`,`active`),t.searchParams.set(`filter`,``),t.href}),()=>{C([]),D(!1),O.current=void 0}),[]);let N=e=>{T(t=>{let n=new URL(t);return n.searchParams.set(`filter`,e),n.href})};return w.includes(`/api/v1/products`)?(0,$.jsx)(ot,{entries:S,inputOptions:t,readonly:r,onChange:p,onDismiss:m,initiallyVisible:a,exclude:s,includeOnly:c,includeByLabel:u,action:d,nullable:f,entryOptions:n,errorMessage:g,clearInputAfterSelection:_,isDataLoading:M,onFocus:()=>D(!0),onInputValueChange:v,onEmptyValues:N,compareOnlyByValue:y,withShadow:b}):(0,$.jsx)(st,{entries:S,inputOptions:t,readonly:r,onChange:p,onEmptyValues:N,onDismiss:m,initiallyVisible:a,exclude:s,includeOnly:c,includeByLabel:u,action:d,nullable:f,entryOptions:n,errorMessage:g,clearInputAfterSelection:_,isDataLoading:M,onInputValueChange:v,compareOnlyByValue:y,withShadow:b})}export{nt as i,ct as n,st as r,ot as t};