import{r as l,j as E,k as R}from"./index-C-9v46qO.js";import{c as v}from"./index-WGdLp8p1.js";import{c as T,u as M}from"./button-B-2orO_-.js";function N(e){const t=j(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 j(e){const t=l.forwardRef((n,r)=>{const{children:o,...c}=n;if(l.isValidElement(o)){const a=w(o),s=b(c,o.props);return o.type!==l.Fragment&&(s.ref=r?T(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 P=Symbol("radix.slottable");function D(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===P}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 w(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 k(e){const t=e+"CollectionProvider",[n,r]=v(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 V=l.createContext(void 0);function B(e){const t=l.useContext(V);return e||t||"ltr"}export{k as c,B as u};
