import{r as h,d as Ae,R as Y}from"./react-vendor-jWT2yUdV.js";import{ao as oe,aO as Me,aN as Ce,a3 as ce,br as Re,ba as Be,ap as Se,bs as ue,a8 as X,bt as xe,a6 as Pe,bu as Le,a5 as Oe,ai as we,ab as ae,b1 as he,aa as Ue,a9 as ze,bv as We,ah as He}from"./index-DiaaLdUu.js";import{$ as Fe}from"./usePress-BrNwsdVw.js";function pe(i,e){const t=h.useRef(!0),l=h.useRef(null);oe(()=>(t.current=!0,()=>{t.current=!1}),[]),oe(()=>{t.current?t.current=!1:(!l.current||e.some((n,c)=>!Object.is(n,l[c])))&&i(),l.current=e},e)}function je(i,e){const t=[];for(;i&&i!==document.documentElement;)Me(i,e)&&t.push(i),i=i.parentElement;return t}function V(i){return Ce()?i.metaKey:i.ctrlKey}let Ge=0;const ie=new Map;function qe(i){let[e,t]=h.useState();return oe(()=>{if(!i)return;let l=ie.get(i);if(l)t(l.element.id);else{let n=`react-aria-description-${Ge++}`;t(n);let c=document.createElement("div");c.id=n,c.style.display="none",c.textContent=i,document.body.appendChild(c),l={refCount:0,element:c},ie.set(i,l)}return l.refCount++,()=>{l&&--l.refCount===0&&(l.element.remove(),ie.delete(i))}},[i]),{"aria-describedby":i?e:void 0}}function Z(i,e,t,l){let n=ce(t),c=t==null;h.useEffect(()=>{if(c||!i.current)return;let r=i.current;return r.addEventListener(e,n,l),()=>{r.removeEventListener(e,n,l)}},[i,e,l,c,n])}function Te(i,e){let t=ye(i,e,"left"),l=ye(i,e,"top"),n=e.offsetWidth,c=e.offsetHeight,r=i.scrollLeft,f=i.scrollTop,{borderTopWidth:a,borderLeftWidth:b,scrollPaddingTop:k,scrollPaddingRight:g,scrollPaddingBottom:p,scrollPaddingLeft:S}=getComputedStyle(i),{scrollMarginTop:$,scrollMarginRight:A,scrollMarginBottom:y,scrollMarginLeft:w}=getComputedStyle(e),v=r+parseInt(b,10),m=f+parseInt(a,10),x=v+i.clientWidth,M=m+i.clientHeight,D=parseInt(k,10)||0,I=parseInt(p,10)||0,F=parseInt(g,10)||0,L=parseInt(S,10)||0,U=parseInt($,10)||0,R=parseInt(y,10)||0,C=parseInt(A,10)||0,T=parseInt(w,10)||0,H=t-T,z=t+n+C,j=l-U,o=l+c+R,d=r+parseInt(b,10)+L,K=x-F,s=f+parseInt(a,10)+D,P=M-I;(H>d||zx-F&&(r+=z-x+F)),(j>s||oM-I&&(f+=o-M+I)),i.scrollTo({left:r,top:f})}function ye(i,e,t){const l=t==="left"?"offsetLeft":"offsetTop";let n=0;for(;e.offsetParent&&(n+=e[l],e.offsetParent!==i);){if(e.offsetParent.contains(i)){n-=i[l];break}e=e.offsetParent}return n}function ve(i,e){if(i&&document.contains(i)){let r=document.scrollingElement||document.documentElement;if(!(window.getComputedStyle(r).overflow==="hidden")&&!Re()){var t;let{left:a,top:b}=i.getBoundingClientRect();i==null||(t=i.scrollIntoView)===null||t===void 0||t.call(i,{block:"nearest"});let{left:k,top:g}=i.getBoundingClientRect();if(Math.abs(a-k)>1||Math.abs(b-g)>1){var l,n,c;e==null||(n=e.containingElement)===null||n===void 0||(l=n.scrollIntoView)===null||l===void 0||l.call(n,{block:"center",inline:"center"}),(c=i.scrollIntoView)===null||c===void 0||c.call(i,{block:"nearest"})}}else{let a=je(i);for(let b of a)Te(b,i)}}}const Ye="react-aria-clear-focus",Ve="react-aria-focus",Xe=500;function Ze(i){let{isDisabled:e,onLongPressStart:t,onLongPressEnd:l,onLongPress:n,threshold:c=Xe,accessibilityDescription:r}=i;const f=h.useRef(void 0);let{addGlobalListener:a,removeGlobalListener:b}=Be(),{pressProps:k}=Fe({isDisabled:e,onPressStart(p){if(p.continuePropagation(),(p.pointerType==="mouse"||p.pointerType==="touch")&&(t&&t({...p,type:"longpressstart"}),f.current=setTimeout(()=>{p.target.dispatchEvent(new PointerEvent("pointercancel",{bubbles:!0})),Se(p.target).activeElement!==p.target&&ue(p.target),n&&n({...p,type:"longpress"}),f.current=void 0},c),p.pointerType==="touch")){let S=$=>{$.preventDefault()};a(p.target,"contextmenu",S,{once:!0}),a(window,"pointerup",()=>{setTimeout(()=>{b(p.target,"contextmenu",S)},30)},{once:!0})}},onPressEnd(p){f.current&&clearTimeout(f.current),l&&(p.pointerType==="mouse"||p.pointerType==="touch")&&l({...p,type:"longpressend"})}}),g=qe(n&&!e?r:void 0);return{longPressProps:X(k,g)}}function De(i){let e=Qe(Se(i));e!==i&&(e&&Je(e,i),i&&ke(i,e))}function Je(i,e){i.dispatchEvent(new FocusEvent("blur",{relatedTarget:e})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:e}))}function ke(i,e){i.dispatchEvent(new FocusEvent("focus",{relatedTarget:e})),i.dispatchEvent(new FocusEvent("focusin",{bubbles:!0,relatedTarget:e}))}function Qe(i){let e=xe(i),t=e==null?void 0:e.getAttribute("aria-activedescendant");return t&&i.getElementById(t)||e}function fe(i){return Le()?i.altKey:i.ctrlKey}function ne(i,e){var t,l;let n=`[data-key="${CSS.escape(String(e))}"]`,c=(t=i.current)===null||t===void 0?void 0:t.dataset.collection;return c&&(n=`[data-collection="${CSS.escape(c)}"]${n}`),(l=i.current)===null||l===void 0?void 0:l.querySelector(n)}const Ie=new WeakMap;function Ne(i){let e=Pe();return Ie.set(i,e),e}function _e(i){return Ie.get(i)}const et=1e3;function tt(i){let{keyboardDelegate:e,selectionManager:t,onTypeSelect:l}=i,n=h.useRef({search:"",timeout:void 0}).current,c=r=>{let f=lt(r.key);if(!(!f||r.ctrlKey||r.metaKey||!r.currentTarget.contains(r.target)||n.search.length===0&&f===" ")){if(f===" "&&n.search.trim().length>0&&(r.preventDefault(),"continuePropagation"in r||r.stopPropagation()),n.search+=f,e.getKeyForSearch!=null){let a=e.getKeyForSearch(n.search,t.focusedKey);a==null&&(a=e.getKeyForSearch(n.search)),a!=null&&(t.setFocusedKey(a),l&&l(a))}clearTimeout(n.timeout),n.timeout=setTimeout(()=>{n.search=""},et)}};return{typeSelectProps:{onKeyDownCapture:e.getKeyForSearch?c:void 0}}}function lt(i){return i.length===1||!/^[A-Z]/i.test(i)?i:""}function dt(i){let{selectionManager:e,keyboardDelegate:t,ref:l,autoFocus:n=!1,shouldFocusWrap:c=!1,disallowEmptySelection:r=!1,disallowSelectAll:f=!1,escapeKeyBehavior:a="clearSelection",selectOnFocus:b=e.selectionBehavior==="replace",disallowTypeAhead:k=!1,shouldUseVirtualFocus:g,allowsTabNavigation:p=!1,isVirtualized:S,scrollRef:$=l,linkBehavior:A="action"}=i,{direction:y}=Oe(),w=we(),v=o=>{var d;if(o.altKey&&o.key==="Tab"&&o.preventDefault(),!(!((d=l.current)===null||d===void 0)&&d.contains(o.target)))return;const K=(u,G)=>{if(u!=null){if(e.isLink(u)&&A==="selection"&&b&&!fe(o)){Ae.flushSync(()=>{e.setFocusedKey(u,G)});let q=ne(l,u),de=e.getItemProps(u);q&&w.open(q,o,de.href,de.routerOptions);return}if(e.setFocusedKey(u,G),e.isLink(u)&&A==="override")return;o.shiftKey&&e.selectionMode==="multiple"?e.extendSelection(u):b&&!fe(o)&&e.replaceSelection(u)}};switch(o.key){case"ArrowDown":if(t.getKeyBelow){var s,P,E;let u=e.focusedKey!=null?(s=t.getKeyBelow)===null||s===void 0?void 0:s.call(t,e.focusedKey):(P=t.getFirstKey)===null||P===void 0?void 0:P.call(t);u==null&&c&&(u=(E=t.getFirstKey)===null||E===void 0?void 0:E.call(t,e.focusedKey)),u!=null&&(o.preventDefault(),K(u))}break;case"ArrowUp":if(t.getKeyAbove){var O,W,J;let u=e.focusedKey!=null?(O=t.getKeyAbove)===null||O===void 0?void 0:O.call(t,e.focusedKey):(W=t.getLastKey)===null||W===void 0?void 0:W.call(t);u==null&&c&&(u=(J=t.getLastKey)===null||J===void 0?void 0:J.call(t,e.focusedKey)),u!=null&&(o.preventDefault(),K(u))}break;case"ArrowLeft":if(t.getKeyLeftOf){var Q,N,_;let u=e.focusedKey!=null?(Q=t.getKeyLeftOf)===null||Q===void 0?void 0:Q.call(t,e.focusedKey):null;u==null&&c&&(u=y==="rtl"?(N=t.getFirstKey)===null||N===void 0?void 0:N.call(t,e.focusedKey):(_=t.getLastKey)===null||_===void 0?void 0:_.call(t,e.focusedKey)),u!=null&&(o.preventDefault(),K(u,y==="rtl"?"first":"last"))}break;case"ArrowRight":if(t.getKeyRightOf){var ee,te,le;let u=e.focusedKey!=null?(ee=t.getKeyRightOf)===null||ee===void 0?void 0:ee.call(t,e.focusedKey):null;u==null&&c&&(u=y==="rtl"?(te=t.getLastKey)===null||te===void 0?void 0:te.call(t,e.focusedKey):(le=t.getFirstKey)===null||le===void 0?void 0:le.call(t,e.focusedKey)),u!=null&&(o.preventDefault(),K(u,y==="rtl"?"last":"first"))}break;case"Home":if(t.getFirstKey){if(e.focusedKey===null&&o.shiftKey)return;o.preventDefault();let u=t.getFirstKey(e.focusedKey,V(o));e.setFocusedKey(u),u!=null&&(V(o)&&o.shiftKey&&e.selectionMode==="multiple"?e.extendSelection(u):b&&e.replaceSelection(u))}break;case"End":if(t.getLastKey){if(e.focusedKey===null&&o.shiftKey)return;o.preventDefault();let u=t.getLastKey(e.focusedKey,V(o));e.setFocusedKey(u),u!=null&&(V(o)&&o.shiftKey&&e.selectionMode==="multiple"?e.extendSelection(u):b&&e.replaceSelection(u))}break;case"PageDown":if(t.getKeyPageBelow&&e.focusedKey!=null){let u=t.getKeyPageBelow(e.focusedKey);u!=null&&(o.preventDefault(),K(u))}break;case"PageUp":if(t.getKeyPageAbove&&e.focusedKey!=null){let u=t.getKeyPageAbove(e.focusedKey);u!=null&&(o.preventDefault(),K(u))}break;case"a":V(o)&&e.selectionMode==="multiple"&&f!==!0&&(o.preventDefault(),e.selectAll());break;case"Escape":a==="clearSelection"&&!r&&e.selectedKeys.size!==0&&(o.stopPropagation(),o.preventDefault(),e.clearSelection());break;case"Tab":if(!p){if(o.shiftKey)l.current.focus();else{let u=Ue(l.current,{tabbable:!0}),G,q;do q=u.lastChild(),q&&(G=q);while(q);G&&!G.contains(document.activeElement)&&ue(G)}break}}},m=h.useRef({top:0,left:0});Z($,"scroll",S?void 0:()=>{var o,d,K,s;m.current={top:(K=(o=$.current)===null||o===void 0?void 0:o.scrollTop)!==null&&K!==void 0?K:0,left:(s=(d=$.current)===null||d===void 0?void 0:d.scrollLeft)!==null&&s!==void 0?s:0}});let x=o=>{if(e.isFocused){o.currentTarget.contains(o.target)||e.setFocused(!1);return}if(o.currentTarget.contains(o.target)){if(e.setFocused(!0),e.focusedKey==null){var d,K;let E=W=>{W!=null&&(e.setFocusedKey(W),b&&!e.isSelected(W)&&e.replaceSelection(W))},O=o.relatedTarget;var s,P;O&&o.currentTarget.compareDocumentPosition(O)&Node.DOCUMENT_POSITION_FOLLOWING?E((s=e.lastSelectedKey)!==null&&s!==void 0?s:(d=t.getLastKey)===null||d===void 0?void 0:d.call(t)):E((P=e.firstSelectedKey)!==null&&P!==void 0?P:(K=t.getFirstKey)===null||K===void 0?void 0:K.call(t))}else!S&&$.current&&($.current.scrollTop=m.current.top,$.current.scrollLeft=m.current.left);if(e.focusedKey!=null&&$.current){let E=ne(l,e.focusedKey);E instanceof HTMLElement&&(!E.contains(document.activeElement)&&!g&&ue(E),he()==="keyboard"&&ve(E,{containingElement:l.current}))}}},M=o=>{o.currentTarget.contains(o.relatedTarget)||e.setFocused(!1)},D=h.useRef(!1);Z(l,Ve,g?o=>{let{detail:d}=o;o.stopPropagation(),e.setFocused(!0),(d==null?void 0:d.focusStrategy)==="first"&&(D.current=!0)}:void 0);let I=ce(()=>{var o,d;let K=(d=(o=t.getFirstKey)===null||o===void 0?void 0:o.call(t))!==null&&d!==void 0?d:null;if(K==null){let s=xe();De(l.current),ke(s,null),e.collection.size>0&&(D.current=!1)}else e.setFocusedKey(K),D.current=!1});pe(()=>{D.current&&I()},[e.collection,I]);let F=ce(()=>{e.collection.size>0&&(D.current=!1)});pe(()=>{F()},[e.focusedKey,F]),Z(l,Ye,g?o=>{var d;o.stopPropagation(),e.setFocused(!1),!((d=o.detail)===null||d===void 0)&&d.clearFocusKey&&e.setFocusedKey(null)}:void 0);const L=h.useRef(n),U=h.useRef(!1);h.useEffect(()=>{if(L.current){var o,d;let P=null;var K;n==="first"&&(P=(K=(o=t.getFirstKey)===null||o===void 0?void 0:o.call(t))!==null&&K!==void 0?K:null);var s;n==="last"&&(P=(s=(d=t.getLastKey)===null||d===void 0?void 0:d.call(t))!==null&&s!==void 0?s:null);let E=e.selectedKeys;if(E.size){for(let O of E)if(e.canSelectItem(O)){P=O;break}}e.setFocused(!0),e.setFocusedKey(P),P==null&&!g&&l.current&&ae(l.current),e.collection.size>0&&(L.current=!1,U.current=!0)}});let R=h.useRef(e.focusedKey),C=h.useRef(null);h.useEffect(()=>{if(e.isFocused&&e.focusedKey!=null&&(e.focusedKey!==R.current||U.current)&&$.current&&l.current){let o=he(),d=ne(l,e.focusedKey);if(!(d instanceof HTMLElement))return;(o==="keyboard"||U.current)&&(C.current&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{$.current&&(Te($.current,d),o!=="virtual"&&ve(d,{containingElement:l.current}))}))}!g&&e.isFocused&&e.focusedKey==null&&R.current!=null&&l.current&&ae(l.current),R.current=e.focusedKey,U.current=!1}),h.useEffect(()=>()=>{C.current&&cancelAnimationFrame(C.current)},[]),Z(l,"react-aria-focus-scope-restore",o=>{o.preventDefault(),e.setFocused(!0)});let T={onKeyDown:v,onFocus:x,onBlur:M,onMouseDown(o){$.current===o.target&&o.preventDefault()}},{typeSelectProps:H}=tt({keyboardDelegate:t,selectionManager:e});k||(T=X(H,T));let z;g||(z=e.focusedKey==null?0:-1);let j=Ne(e.collection);return{collectionProps:X(T,{tabIndex:z,"data-collection":j})}}function ht(i){let{id:e,selectionManager:t,key:l,ref:n,shouldSelectOnPressUp:c,shouldUseVirtualFocus:r,focus:f,isDisabled:a,onAction:b,allowsDifferentPressOrigin:k,linkBehavior:g="action"}=i,p=we();e=Pe(e);let S=s=>{if(s.pointerType==="keyboard"&&fe(s))t.toggleSelection(l);else{if(t.selectionMode==="none")return;if(t.isLink(l)){if(g==="selection"&&n.current){let P=t.getItemProps(l);p.open(n.current,s,P.href,P.routerOptions),t.setSelectedKeys(t.selectedKeys);return}else if(g==="override"||g==="none")return}t.selectionMode==="single"?t.isSelected(l)&&!t.disallowEmptySelection?t.toggleSelection(l):t.replaceSelection(l):s&&s.shiftKey?t.extendSelection(l):t.selectionBehavior==="toggle"||s&&(V(s)||s.pointerType==="touch"||s.pointerType==="virtual")?t.toggleSelection(l):t.replaceSelection(l)}};h.useEffect(()=>{l===t.focusedKey&&t.isFocused&&(r?De(n.current):f?f():document.activeElement!==n.current&&n.current&&ae(n.current))},[n,l,t.focusedKey,t.childFocusStrategy,t.isFocused,r]),a=a||t.isDisabled(l);let $={};!r&&!a?$={tabIndex:l===t.focusedKey?0:-1,onFocus(s){s.target===n.current&&t.setFocusedKey(l)}}:a&&($.onMouseDown=s=>{s.preventDefault()});let A=t.isLink(l)&&g==="override",y=b&&i.UNSTABLE_itemBehavior==="action",w=t.isLink(l)&&g!=="selection"&&g!=="none",v=!a&&t.canSelectItem(l)&&!A&&!y,m=(b||w)&&!a,x=m&&(t.selectionBehavior==="replace"?!v:!v||t.isEmpty),M=m&&v&&t.selectionBehavior==="replace",D=x||M,I=h.useRef(null),F=D&&v,L=h.useRef(!1),U=h.useRef(!1),R=t.getItemProps(l),C=s=>{if(b){var P;b(),(P=n.current)===null||P===void 0||P.dispatchEvent(new CustomEvent("react-aria-item-action",{bubbles:!0}))}w&&n.current&&p.open(n.current,s,R.href,R.routerOptions)},T={ref:n};if(c?(T.onPressStart=s=>{I.current=s.pointerType,L.current=F,s.pointerType==="keyboard"&&(!D||$e())&&S(s)},k?(T.onPressUp=x?void 0:s=>{s.pointerType==="mouse"&&v&&S(s)},T.onPress=x?C:s=>{s.pointerType!=="keyboard"&&s.pointerType!=="mouse"&&v&&S(s)}):T.onPress=s=>{if(x||M&&s.pointerType!=="mouse"){if(s.pointerType==="keyboard"&&!be())return;C(s)}else s.pointerType!=="keyboard"&&v&&S(s)}):(T.onPressStart=s=>{I.current=s.pointerType,L.current=F,U.current=x,v&&(s.pointerType==="mouse"&&!x||s.pointerType==="keyboard"&&(!m||$e()))&&S(s)},T.onPress=s=>{(s.pointerType==="touch"||s.pointerType==="pen"||s.pointerType==="virtual"||s.pointerType==="keyboard"&&D&&be()||s.pointerType==="mouse"&&U.current)&&(D?C(s):v&&S(s))}),$["data-collection"]=_e(t.collection),$["data-key"]=l,T.preventFocusOnPress=r,r&&(T=X(T,{onPressStart(s){s.pointerType!=="touch"&&(t.setFocused(!0),t.setFocusedKey(l))},onPress(s){s.pointerType==="touch"&&(t.setFocused(!0),t.setFocusedKey(l))}})),R)for(let s of["onPressStart","onPressEnd","onPressChange","onPress","onPressUp","onClick"])R[s]&&(T[s]=ze(T[s],R[s]));let{pressProps:H,isPressed:z}=Fe(T),j=M?s=>{I.current==="mouse"&&(s.stopPropagation(),s.preventDefault(),C(s))}:void 0,{longPressProps:o}=Ze({isDisabled:!F,onLongPress(s){s.pointerType==="touch"&&(S(s),t.setSelectionBehavior("toggle"))}}),d=s=>{I.current==="touch"&&L.current&&s.preventDefault()},K=g!=="none"&&t.isLink(l)?s=>{We.isOpening||s.preventDefault()}:void 0;return{itemProps:X($,v||x||r&&!a?H:{},F?o:{},{onDoubleClick:j,onDragStartCapture:d,onClick:K,id:e},r?{onMouseDown:s=>s.preventDefault()}:void 0),isPressed:z,isSelected:t.isSelected(l),isFocused:t.isFocused&&t.focusedKey===l,isDisabled:a,allowsSelection:v,hasAction:D}}function be(){let i=window.event;return(i==null?void 0:i.key)==="Enter"}function $e(){let i=window.event;return(i==null?void 0:i.key)===" "||(i==null?void 0:i.code)==="Space"}class B extends Set{constructor(e,t,l){super(e),e instanceof B?(this.anchorKey=t??e.anchorKey,this.currentKey=l??e.currentKey):(this.anchorKey=t??null,this.currentKey=l??null)}}function it(i,e){if(i.size!==e.size)return!1;for(let t of i)if(!e.has(t))return!1;return!0}function pt(i){let{selectionMode:e="none",disallowEmptySelection:t=!1,allowDuplicateSelectionEvents:l,selectionBehavior:n="toggle",disabledBehavior:c="all"}=i,r=h.useRef(!1),[,f]=h.useState(!1),a=h.useRef(null),b=h.useRef(null),[,k]=h.useState(null),g=h.useMemo(()=>ge(i.selectedKeys),[i.selectedKeys]),p=h.useMemo(()=>ge(i.defaultSelectedKeys,new B),[i.defaultSelectedKeys]),[S,$]=He(g,p,i.onSelectionChange),A=h.useMemo(()=>i.disabledKeys?new Set(i.disabledKeys):new Set,[i.disabledKeys]),[y,w]=h.useState(n);n==="replace"&&y==="toggle"&&typeof S=="object"&&S.size===0&&w("replace");let v=h.useRef(n);return h.useEffect(()=>{n!==v.current&&(w(n),v.current=n)},[n]),{selectionMode:e,disallowEmptySelection:t,selectionBehavior:y,setSelectionBehavior:w,get isFocused(){return r.current},setFocused(m){r.current=m,f(m)},get focusedKey(){return a.current},get childFocusStrategy(){return b.current},setFocusedKey(m,x="first"){a.current=m,b.current=x,k(m)},selectedKeys:S,setSelectedKeys(m){(l||!it(m,S))&&$(m)},disabledKeys:A,disabledBehavior:c}}function ge(i,e){return i?i==="all"?"all":new B(i):e}class nt{build(e,t){return this.context=t,me(()=>this.iterateCollection(e))}*iterateCollection(e){let{children:t,items:l}=e;if(Y.isValidElement(t)&&t.type===Y.Fragment)yield*this.iterateCollection({children:t.props.children,items:l});else if(typeof t=="function"){if(!l)throw new Error("props.children was a function but props.items is missing");let n=0;for(let c of l)yield*this.getFullNode({value:c,index:n},{renderer:t}),n++}else{let n=[];Y.Children.forEach(t,r=>{r&&n.push(r)});let c=0;for(let r of n){let f=this.getFullNode({element:r,index:c},{});for(let a of f)c++,yield a}}}getKey(e,t,l,n){if(e.key!=null)return e.key;if(t.type==="cell"&&t.key!=null)return`${n}${t.key}`;let c=t.value;if(c!=null){var r;let f=(r=c.key)!==null&&r!==void 0?r:c.id;if(f==null)throw new Error("No key found for item");return f}return n?`${n}.${t.index}`:`$.${t.index}`}getChildState(e,t){return{renderer:t.renderer||e.renderer}}*getFullNode(e,t,l,n){if(Y.isValidElement(e.element)&&e.element.type===Y.Fragment){let y=[];Y.Children.forEach(e.element.props.children,v=>{y.push(v)});var c;let w=(c=e.index)!==null&&c!==void 0?c:0;for(const v of y)yield*this.getFullNode({element:v,index:w++},t,l,n);return}let r=e.element;if(!r&&e.value&&t&&t.renderer){let y=this.cache.get(e.value);if(y&&(!y.shouldInvalidate||!y.shouldInvalidate(this.context))){y.index=e.index,y.parentKey=n?n.key:null,yield y;return}r=t.renderer(e.value)}if(Y.isValidElement(r)){let y=r.type;if(typeof y!="function"&&typeof y.getCollectionNode!="function"){let x=r.type;throw new Error(`Unknown element <${x}> in collection.`)}let w=y.getCollectionNode(r.props,this.context);var f;let v=(f=e.index)!==null&&f!==void 0?f:0,m=w.next();for(;!m.done&&m.value;){let x=m.value;e.index=v;var a;let M=(a=x.key)!==null&&a!==void 0?a:null;M==null&&(M=x.element?null:this.getKey(r,e,t,l));let I=[...this.getFullNode({...x,key:M,index:v,wrapper:st(e.wrapper,x.wrapper)},this.getChildState(t,x),l?`${l}${r.key}`:r.key,n)];for(let F of I){var b,k;F.value=(k=(b=x.value)!==null&&b!==void 0?b:e.value)!==null&&k!==void 0?k:null,F.value&&this.cache.set(F.value,F);var g;if(e.type&&F.type!==e.type)throw new Error(`Unsupported type <${se(F.type)}> in <${se((g=n==null?void 0:n.type)!==null&&g!==void 0?g:"unknown parent type")}>. Only <${se(e.type)}> is supported.`);v++,yield F}m=w.next(I)}return}if(e.key==null||e.type==null)return;let p=this;var S,$;let A={type:e.type,props:e.props,key:e.key,parentKey:n?n.key:null,value:(S=e.value)!==null&&S!==void 0?S:null,level:n?n.level+1:0,index:e.index,rendered:e.rendered,textValue:($=e.textValue)!==null&&$!==void 0?$:"","aria-label":e["aria-label"],wrapper:e.wrapper,shouldInvalidate:e.shouldInvalidate,hasChildNodes:e.hasChildNodes||!1,childNodes:me(function*(){if(!e.hasChildNodes||!e.childNodes)return;let y=0;for(let w of e.childNodes()){w.key!=null&&(w.key=`${A.key}${w.key}`);let v=p.getFullNode({...w,index:y},p.getChildState(t,w),A.key,A);for(let m of v)y++,yield m}})};yield A}constructor(){this.cache=new WeakMap}}function me(i){let e=[],t=null;return{*[Symbol.iterator](){for(let l of e)yield l;t||(t=i());for(let l of t)e.push(l),yield l}}}function st(i,e){if(i&&e)return t=>i(e(t));if(i)return i;if(e)return e}function se(i){return i[0].toUpperCase()+i.slice(1)}function yt(i,e,t){let l=h.useMemo(()=>new nt,[]),{children:n,items:c,collection:r}=i;return h.useMemo(()=>{if(r)return r;let a=l.build({children:n,items:c},t);return e(a)},[l,n,c,r,t,e])}function rt(i,e){return typeof e.getChildren=="function"?e.getChildren(i.key):i.childNodes}function ot(i){return ct(i,0)}function ct(i,e){if(e<0)return;let t=0;for(let l of i){if(t===e)return l;t++}}function vt(i){let e;for(let t of i)e=t;return e}function re(i,e,t){if(e.parentKey===t.parentKey)return e.index-t.index;let l=[...Ke(i,e),e],n=[...Ke(i,t),t],c=l.slice(0,n.length).findIndex((r,f)=>r!==n[f]);return c!==-1?(e=l[c],t=n[c],e.index-t.index):l.findIndex(r=>r===t)>=0?1:(n.findIndex(r=>r===e)>=0,-1)}function Ke(i,e){let t=[],l=e;for(;(l==null?void 0:l.parentKey)!=null;)l=i.getItem(l.parentKey),l&&t.unshift(l);return t}class Ee{get selectionMode(){return this.state.selectionMode}get disallowEmptySelection(){return this.state.disallowEmptySelection}get selectionBehavior(){return this.state.selectionBehavior}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}get isFocused(){return this.state.isFocused}setFocused(e){this.state.setFocused(e)}get focusedKey(){return this.state.focusedKey}get childFocusStrategy(){return this.state.childFocusStrategy}setFocusedKey(e,t){(e==null||this.collection.getItem(e))&&this.state.setFocusedKey(e,t)}get selectedKeys(){return this.state.selectedKeys==="all"?new Set(this.getSelectAllKeys()):this.state.selectedKeys}get rawSelection(){return this.state.selectedKeys}isSelected(e){if(this.state.selectionMode==="none")return!1;let t=this.getKey(e);return t==null?!1:this.state.selectedKeys==="all"?this.canSelectItem(t):this.state.selectedKeys.has(t)}get isEmpty(){return this.state.selectedKeys!=="all"&&this.state.selectedKeys.size===0}get isSelectAll(){if(this.isEmpty)return!1;if(this.state.selectedKeys==="all")return!0;if(this._isSelectAll!=null)return this._isSelectAll;let e=this.getSelectAllKeys(),t=this.state.selectedKeys;return this._isSelectAll=e.every(l=>t.has(l)),this._isSelectAll}get firstSelectedKey(){let e=null;for(let l of this.state.selectedKeys){let n=this.collection.getItem(l);(!e||n&&re(this.collection,n,e)<0)&&(e=n)}var t;return(t=e==null?void 0:e.key)!==null&&t!==void 0?t:null}get lastSelectedKey(){let e=null;for(let l of this.state.selectedKeys){let n=this.collection.getItem(l);(!e||n&&re(this.collection,n,e)>0)&&(e=n)}var t;return(t=e==null?void 0:e.key)!==null&&t!==void 0?t:null}get disabledKeys(){return this.state.disabledKeys}get disabledBehavior(){return this.state.disabledBehavior}extendSelection(e){if(this.selectionMode==="none")return;if(this.selectionMode==="single"){this.replaceSelection(e);return}let t=this.getKey(e);if(t==null)return;let l;if(this.state.selectedKeys==="all")l=new B([t],t,t);else{let r=this.state.selectedKeys;var n;let f=(n=r.anchorKey)!==null&&n!==void 0?n:t;l=new B(r,f,t);var c;for(let a of this.getKeyRange(f,(c=r.currentKey)!==null&&c!==void 0?c:t))l.delete(a);for(let a of this.getKeyRange(t,f))this.canSelectItem(a)&&l.add(a)}this.state.setSelectedKeys(l)}getKeyRange(e,t){let l=this.collection.getItem(e),n=this.collection.getItem(t);return l&&n?re(this.collection,l,n)<=0?this.getKeyRangeInternal(e,t):this.getKeyRangeInternal(t,e):[]}getKeyRangeInternal(e,t){var l;if(!((l=this.layoutDelegate)===null||l===void 0)&&l.getKeyRange)return this.layoutDelegate.getKeyRange(e,t);let n=[],c=e;for(;c!=null;){let r=this.collection.getItem(c);if(r&&(r.type==="item"||r.type==="cell"&&this.allowsCellSelection)&&n.push(c),c===t)return n;c=this.collection.getKeyAfter(c)}return[]}getKey(e){let t=this.collection.getItem(e);if(!t||t.type==="cell"&&this.allowsCellSelection)return e;for(;t&&t.type!=="item"&&t.parentKey!=null;)t=this.collection.getItem(t.parentKey);return!t||t.type!=="item"?null:t.key}toggleSelection(e){if(this.selectionMode==="none")return;if(this.selectionMode==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}let t=this.getKey(e);if(t==null)return;let l=new B(this.state.selectedKeys==="all"?this.getSelectAllKeys():this.state.selectedKeys);l.has(t)?l.delete(t):this.canSelectItem(t)&&(l.add(t),l.anchorKey=t,l.currentKey=t),!(this.disallowEmptySelection&&l.size===0)&&this.state.setSelectedKeys(l)}replaceSelection(e){if(this.selectionMode==="none")return;let t=this.getKey(e);if(t==null)return;let l=this.canSelectItem(t)?new B([t],t,t):new B;this.state.setSelectedKeys(l)}setSelectedKeys(e){if(this.selectionMode==="none")return;let t=new B;for(let l of e){let n=this.getKey(l);if(n!=null&&(t.add(n),this.selectionMode==="single"))break}this.state.setSelectedKeys(t)}getSelectAllKeys(){let e=[],t=l=>{for(;l!=null;){if(this.canSelectItem(l)){var n;let r=this.collection.getItem(l);(r==null?void 0:r.type)==="item"&&e.push(l);var c;r!=null&&r.hasChildNodes&&(this.allowsCellSelection||r.type!=="item")&&t((c=(n=ot(rt(r,this.collection)))===null||n===void 0?void 0:n.key)!==null&&c!==void 0?c:null)}l=this.collection.getKeyAfter(l)}};return t(this.collection.getFirstKey()),e}selectAll(){!this.isSelectAll&&this.selectionMode==="multiple"&&this.state.setSelectedKeys("all")}clearSelection(){!this.disallowEmptySelection&&(this.state.selectedKeys==="all"||this.state.selectedKeys.size>0)&&this.state.setSelectedKeys(new B)}toggleSelectAll(){this.isSelectAll?this.clearSelection():this.selectAll()}select(e,t){this.selectionMode!=="none"&&(this.selectionMode==="single"?this.isSelected(e)&&!this.disallowEmptySelection?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior==="toggle"||t&&(t.pointerType==="touch"||t.pointerType==="virtual")?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys)return!0;let t=this.selectedKeys;if(e.size!==t.size)return!1;for(let l of e)if(!t.has(l))return!1;for(let l of t)if(!e.has(l))return!1;return!0}canSelectItem(e){var t;if(this.state.selectionMode==="none"||this.state.disabledKeys.has(e))return!1;let l=this.collection.getItem(e);return!(!l||!(l==null||(t=l.props)===null||t===void 0)&&t.isDisabled||l.type==="cell"&&!this.allowsCellSelection)}isDisabled(e){var t,l;return this.state.disabledBehavior==="all"&&(this.state.disabledKeys.has(e)||!!(!((l=this.collection.getItem(e))===null||l===void 0||(t=l.props)===null||t===void 0)&&t.isDisabled))}isLink(e){var t,l;return!!(!((l=this.collection.getItem(e))===null||l===void 0||(t=l.props)===null||t===void 0)&&t.href)}getItemProps(e){var t;return(t=this.collection.getItem(e))===null||t===void 0?void 0:t.props}withCollection(e){return new Ee(e,this.state,{allowsCellSelection:this.allowsCellSelection,layoutDelegate:this.layoutDelegate||void 0})}constructor(e,t,l){this.collection=e,this.state=t;var n;this.allowsCellSelection=(n=l==null?void 0:l.allowsCellSelection)!==null&&n!==void 0?n:!1,this._isSelectAll=null,this.layoutDelegate=(l==null?void 0:l.layoutDelegate)||null}}export{rt as $,vt as a,ot as b,ct as c,qe as d,dt as e,ht as f,ve as g,pt as h,Ee as i,yt as j,Ze as k,ne as l};