1import{ay as v,r as s,dZ as L,gC as B}from"./index-CpeGhXo5.js";const E={limit:50,sortBy:"name",sortOrder:"asc"};function O(p=[]){const d=v(),[l,f]=s.useState(""),[h,y]=s.useState(""),[i,w]=s.useState([]);s.useEffect(()=>{const e=window.setTimeout(()=>y(l.trim()),300);return()=>window.clearTimeout(e)},[l]);const{data:S,isFetching:g}=L({...E,q:h||void 0}),r=S?.items??[],m=s.useMemo(()=>{const e=new Set([...r,...i].map(t=>t.id));return[...new Set(p.filter(t=>t&&!e.has(t)))]},[r,i,p]),C=m.join(",");s.useEffect(()=>{if(!m.length)return;let e=!1;return(async()=>{const t=[];for(const a of m.slice(0,15))try{const o=await d(B.endpoints.getCompanyById.initiate(a,{subscribe:!1})).unwrap();o&&t.push(o)}catch{}!e&&t.length&&w(a=>{const o=new Map(a.map(c=>[c.id,c]));for(const c of t)o.set(c.id,c);return[...o.values()]})})(),()=>{e=!0}},[C,d,m]);const n=s.useMemo(()=>{const e=new Map;for(const t of[...r,...i])e.set(t.id,t);return[...e.values()].sort((t,a)=>t.name.localeCompare(a.name))},[r,i]),b=s.useMemo(()=>n.map(e=>({value:e.id,label:e.name})),[n]),u=s.useMemo(()=>new Map(n.map(e=>[e.id,e.name])),[n]),M=s.useCallback(e=>u.get(e),[u]);return{companiesList:n,companyOptions:b,companyNameById:u,resolveCompanyLabel:M,isLoading:g,onCompanySearchChange:f}}export{O 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.