import u,{createContext as m,useContext as D,useMemo as l,useState as T}from"react";import{useId as P}from'../../hooks/use-id.js';import{forwardRefWithAs as g,render as E}from'../../utils/render.js';import{useIsoMorphicEffect as x}from'../../hooks/use-iso-morphic-effect.js';import{useSyncRefs as R}from'../../hooks/use-sync-refs.js';import{useEvent as I}from'../../hooks/use-event.js';let d=m(null);function f(){let r=D(d);if(r===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,f),t}return r}function M(){let[r,t]=T([]);return[r.length>0?r.join(" "):void 0,l(()=>function(e){let i=I(s=>(t(o=>[...o,s]),()=>t(o=>{let p=o.slice(),c=p.indexOf(s);return c!==-1&&p.splice(c,1),p}))),n=l(()=>({register:i,slot:e.slot,name:e.name,props:e.props}),[i,e.slot,e.name,e.props]);return u.createElement(d.Provider,{value:n},e.children)},[t])]}let S="p";function h(r,t){let a=P(),{id:e=`headlessui-description-${a}`,...i}=r,n=f(),s=R(t);x(()=>n.register(e),[e,n.register]);let o={ref:s,...n.props,id:e};return E({ourProps:o,theirProps:i,slot:n.slot||{},defaultTag:S,name:n.name||"Description"})}let y=g(h),b=Object.assign(y,{});export{b as Description,M as useDescriptions};
