"use strict";const l=require("./Items-CXBBG9Ip.cjs"),n=require("react"),h=require("@synnaxlabs/x"),y=require("./Editable-HUPqTaui.cjs");require("./Text-XHBXXDRS.cjs");require("./jsx-runtime-nZSsnGb7.cjs");require("./types-DI2vtOGs.cjs");require("./css-CloSmhZB.cjs");require("./Box-CNUz5BsV.cjs");require("./Provider-cSwm-2e_.cjs");const M=require("./useStaticData-BTwIe0Il.cjs"),C=10,d=({offset:e,searchTerm:t="",...s},c=C)=>({...s,offset:(e??-c)+c,limit:c,searchTerm:t}),g=(e,t,s=C)=>({...e,searchTerm:t,offset:0,limit:s}),q=({retrieve:e,pageSize:t=C})=>{const s=n.useCallback(()=>{e(o=>d(o,t),{mode:"append"})},[e,t]),c=n.useCallback(o=>e(a=>g(a,o,t)),[e,t]);return n.useMemo(()=>({fetchMore:s,search:c}),[s,c])},D=({first:e,second:t})=>{const s=n.useMemo(()=>[...e.data,...t.data],[e.data,t.data]),c=n.useCallback(a=>{if(Array.isArray(a)){const m=e.getItem?.(a)??[],i=t.getItem?.(a)??[];return[...m,...i]}return e.getItem?.(a)??t.getItem?.(a)},[e.getItem,t.getItem]),o=n.useCallback((a,m)=>{const i=e.subscribe?.(a,m),f=t.subscribe?.(a,m);return()=>{i?.(),f?.()}},[e.subscribe,t.subscribe]);return n.useMemo(()=>({data:s,getItem:c,subscribe:o}),[s,c,o])},A=e=>{const t=n.useCallback((s=>{if(Array.isArray(s)){const o=new Set(s);return e.filter(a=>o.has(a)).map(a=>({key:a}))}const c=e.find(o=>o===s);return c?{key:c}:void 0}),[e]);return n.useMemo(()=>({data:e,getItem:t}),[e,t])},E=({initialData:e}={})=>{const t=y.useInitializerRef(()=>{const r=new Map;return e==null||e.forEach(u=>r.set(u.key,u)),r}),s=y.useInitializerRef(()=>new Map),c=n.useCallback(r=>{const u=new Set(r);s.current.forEach((I,b)=>{u.has(I)&&b()})},[]),o=n.useCallback(r=>{const u=h.array.toArray(r),I=u.map(b=>b.key);u.forEach(b=>t.current.set(b.key,b)),c(I)},[]),a=n.useCallback(r=>{const u=h.array.toArray(r);u.forEach(I=>t.current.delete(I)),c(u)},[]),m=n.useCallback((r,u)=>u==null?()=>{}:(s.current.set(r,u),()=>{s.current.delete(r)}),[s]),i=n.useCallback((r=>{if(r!=null)return Array.isArray(r)?r.map(u=>t.current.get(u)).filter(u=>u!=null):t.current.get(r)}),[]),f=n.useCallback(r=>t.current.has(r),[]);return n.useMemo(()=>({setItem:o,deleteItem:a,subscribe:m,getItem:i,hasItem:f}),[o,a,m,i,f])},k=Object.freeze(Object.defineProperty({__proto__:null,BaseFrame:l.BaseFrame,Frame:l.Frame,Item:l.Item,Items:l.Items,createGetItem:l.createGetItem,page:d,search:g,useCombinedData:D,useData:l.useData,useItem:l.useItem,useKeysData:A,useMapData:E,usePager:q,useScroller:l.useScroller,useStaticData:M.useStaticData,useUtilContext:l.useUtilContext},Symbol.toStringTag,{value:"Module"}));exports.external=k;exports.useKeysData=A;exports.usePager=q;
