import{useState as e,useRef as r}from"react";import{DescendantsManager as t}from"./descendant.js";import{cast as n,useSafeLayoutEffect as s}from"./utils.js";import{mergeRefs as i}from"../../../react-utils/dist/esm/refs.js";import{createContext as u}from"../../../react-utils/dist/esm/context.js";var[a,d]=u({name:"DescendantsProvider",errorMessage:"useDescendantsContext must be used within DescendantsProvider"});function o(){return[n(a),()=>n(d()),()=>function(){var[r]=e((()=>new t));return s((()=>()=>r.destroy())),r}(),t=>function(t){var u=d(),[a,o]=e(-1),c=r(null);s((()=>()=>{c.current&&u.unregister(c.current)}),[]),s((()=>{if(c.current){var e=Number(c.current.dataset.index);a==e||Number.isNaN(e)||o(e)}}));var m=n(t?u.register(t):u.register);return{descendants:u,index:a,enabledIndex:u.enabledIndexOf(c.current),register:i(m,c)}}(t)]}export{o as createDescendantContext};
//# sourceMappingURL=use-descendant.js.map
