1import{r as o}from"./index-BDiHYtDp.js";import{d as R,c as E,b as h}from"./useRenderElement-COqWOz6u.js";import{j as L}from"./jsx-runtime-D_zvdyIk.js";const T=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function D(){return o.useContext(T)}function v(u){const{children:m,elementsRef:t,labelsRef:r,onMapChange:b}=u,f=R(b),O=o.useRef(0),p=E(_).current,d=E(S).current,[C,x]=o.useState(0),c=o.useRef(C),M=R((e,i)=>{d.set(e,i??null),c.current+=1,x(c.current)}),a=R(e=>{d.delete(e),c.current+=1,x(c.current)}),n=o.useMemo(()=>{const e=new Map;return Array.from(d.keys()).filter(s=>s.isConnected).sort(P).forEach((s,I)=>{const l=d.get(s)??{};e.set(s,{...l,index:I})}),e},[d,C]);h(()=>{if(typeof MutationObserver!="function"||n.size===0)return;const e=new MutationObserver(i=>{const s=new Set,I=l=>s.has(l)?s.delete(l):s.add(l);i.forEach(l=>{l.removedNodes.forEach(I),l.addedNodes.forEach(I)}),s.size===0&&(c.current+=1,x(c.current))});return n.forEach((i,s)=>{s.parentElement&&e.observe(s.parentElement,{childList:!0})}),()=>{e.disconnect()}},[n]),h(()=>{c.current===C&&(t.current.length!==n.size&&(t.current.length=n.size),r&&r.current.length!==n.size&&(r.current.length=n.size),O.current=n.size),f(n)},[f,n,t,r,C]),h(()=>()=>{t.current=[]},[t]),h(()=>()=>{r&&(r.current=[])},[r]);const N=R(e=>(p.add(e),()=>{p.delete(e)}));h(()=>{p.forEach(e=>e(n))},[p,n]);const g=o.useMemo(()=>({register:M,unregister:a,subscribeMapChange:N,elementsRef:t,labelsRef:r,nextIndexRef:O}),[M,a,N,t,r,O]);return L.jsx(T.Provider,{value:g,children:m})}function S(){return new Map}function _(){return new Set}function P(u,m){const t=u.compareDocumentPosition(m);return t&Node.DOCUMENT_POSITION_FOLLOWING||t&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:t&Node.DOCUMENT_POSITION_PRECEDING||t&Node.DOCUMENT_POSITION_CONTAINS?1:0}let w=function(u){return u[u.None=0]="None",u[u.GuessFromOrder=1]="GuessFromOrder",u}({});function y(u={}){const{label:m,metadata:t,textRef:r,indexGuessBehavior:b,index:f}=u,{register:O,unregister:p,subscribeMapChange:d,elementsRef:C,labelsRef:x,nextIndexRef:c}=D(),M=o.useRef(-1),[a,n]=o.useState(f??(b===w.GuessFromOrder?()=>{if(M.current===-1){const e=c.current;c.current+=1,M.current=e}return M.current}:-1)),N=o.useRef(null),g=o.useCallback(e=>{if(N.current=e,a!==-1&&e!==null&&(C.current[a]=e,x)){const i=m!==void 0;x.current[a]=i?m:r?.current?.textContent??e.textContent}},[a,C,x,m,r]);return h(()=>{if(f!=null)return;const e=N.current;if(e)return O(e,t),()=>{p(e)}},[f,O,p,t]),h(()=>
1{if(f==null)return d(e=>{const i=N.current?e.get(N.current)?.index:null;i!=null&&n(i)})},[f,d,n]),o.useMemo(()=>({ref:g,index:a}),[a,g])}export{v as C,w as I,y as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.