import{Z as l,V as E,E as v,G as T,R,a4 as M}from"./index-DxAX-4zq.js";function N(e){const t=P(e),n=l.forwardRef((r,o)=>{const{children:c,...a}=r,s=l.Children.toArray(c),d=s.find(D);if(d){const f=d.props.children,S=s.map(y=>y===d?l.Children.count(f)>1?l.Children.only(null):l.isValidElement(f)?f.props.children:null:y);return E.jsx(t,{...a,ref:o,children:l.isValidElement(f)?l.cloneElement(f,void 0,S):null})}return E.jsx(t,{...a,ref:o,children:c})});return n.displayName=`${e}.Slot`,n}function P(e){const t=l.forwardRef((n,r)=>{const{children:o,...c}=n;if(l.isValidElement(o)){const a=V(o),s=b(c,o.props);return o.type!==l.Fragment&&(s.ref=r?v(r,a):a),l.cloneElement(o,s)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var j=Symbol("radix.slottable");function D(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===j}function b(e,t){const n={...t};for(const r in t){const o=e[r],c=t[r];/^on[A-Z]/.test(r)?o&&c?n[r]=(...s)=>{const d=c(...s);return o(...s),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...c}:r==="className"&&(n[r]=[o,c].filter(Boolean).join(" "))}return{...e,...n}}function V(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function W(e){const t=e+"CollectionProvider",[n,r]=T(t),[o,c]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:i,children:x}=m,u=R.useRef(null),p=R.useRef(new Map).current;return E.jsx(o,{scope:i,itemMap:p,collectionRef:u,children:x})};a.displayName=t;const s=e+"CollectionSlot",d=N(s),f=R.forwardRef((m,i)=>{const{scope:x,children:u}=m,p=c(s,x),C=M(i,p.collectionRef);return E.jsx(d,{ref:C,children:u})});f.displayName=s;const S=e+"CollectionItemSlot",y="data-radix-collection-item",O=N(S),g=R.forwardRef((m,i)=>{const{scope:x,children:u,...p}=m,C=R.useRef(null),A=M(i,C),I=c(S,x);return R.useEffect(()=>(I.itemMap.set(C,{ref:C,...p}),()=>{I.itemMap.delete(C)})),E.jsx(O,{[y]:"",ref:A,children:u})});g.displayName=S;function _(m){const i=c(e+"CollectionConsumer",m);return R.useCallback(()=>{const u=i.collectionRef.current;if(!u)return[];const p=Array.from(u.querySelectorAll(`[${y}]`));return Array.from(i.itemMap.values()).sort((I,h)=>p.indexOf(I.ref.current)-p.indexOf(h.ref.current))},[i.collectionRef,i.itemMap])}return[{Provider:a,Slot:f,ItemSlot:g},_,r]}var w=l.createContext(void 0);function $(e){const t=l.useContext(w);return e||t||"ltr"}export{W as c,$ as u};
