import{b as r,j as d,r as E}from"./app-C7YxHmQz.js";import{c as D}from"./index-CCZex4bU.js";import{u as S,a as M}from"./index-Cp62Blk_.js";function b(l){const i=l+"CollectionProvider",[A,N]=D(i),[v,u]=A(i,{collectionRef:{current:null},itemMap:new Map}),p=c=>{const{scope:e,children:s}=c,t=r.useRef(null),o=r.useRef(new Map).current;return d.jsx(v,{scope:e,itemMap:o,collectionRef:t,children:s})};p.displayName=i;const f=l+"CollectionSlot",T=M(f),C=r.forwardRef((c,e)=>{const{scope:s,children:t}=c,o=u(f,s),n=S(e,o.collectionRef);return d.jsx(T,{ref:n,children:t})});C.displayName=f;const m=l+"CollectionItemSlot",x="data-radix-collection-item",O=M(m),R=r.forwardRef((c,e)=>{const{scope:s,children:t,...o}=c,n=r.useRef(null),I=S(e,n),a=u(m,s);return r.useEffect(()=>(a.itemMap.set(n,{ref:n,...o}),()=>void a.itemMap.delete(n))),d.jsx(O,{[x]:"",ref:I,children:t})});R.displayName=m;function _(c){const e=u(l+"CollectionConsumer",c);return r.useCallback(()=>{const t=e.collectionRef.current;if(!t)return[];const o=Array.from(t.querySelectorAll(`[${x}]`));return Array.from(e.itemMap.values()).sort((a,y)=>o.indexOf(a.ref.current)-o.indexOf(y.ref.current))},[e.collectionRef,e.itemMap])}return[{Provider:p,Slot:C,ItemSlot:R},_,N]}var j=E.createContext(void 0);function g(l){const i=E.useContext(j);return l||i||"ltr"}export{b as c,g as u};
