import { ah as p, ai as d, aj as h, ak as y, al as g, am as M, an as A, ao as C, ap as D, aq as E } from "./main-jKCzbrWn.js";
import { useCallback as n, useMemo as _ } from "react";
import { u as j } from "./useKeysData-B1kiZOOw.js";
import "./css-BUXMI9PB.js";
import "./jsx-runtime-C5mzlN2N.js";
import { v as I } from "./eraser-DXDDmPgV.js";
import "react-dom";
const w = ({ retrieve: r, pageSize: t = 10 }) => {
  const o = n(() => {
    r(
      ({ offset: u = -t, searchTerm: a = "", ...m }) => ({
        ...m,
        offset: u + t,
        limit: t,
        searchTerm: a
      }),
      { mode: "append" }
    );
  }, [r, t]), c = n(
    (u) => r((a) => ({ ...a, searchTerm: u, offset: 0, limit: t })),
    [r, t]
  );
  return { fetchMore: o, search: c };
}, x = ({
  first: r,
  second: t
}) => {
  const o = _(
    () => [...r.data, ...t.data],
    [r.data, t.data]
  ), c = n(
    (a) => r.getItem?.(a) ?? t.getItem?.(a),
    [r.getItem, t.getItem]
  ), u = n(
    (a, m) => {
      const i = r.subscribe?.(a, m), b = t.subscribe?.(a, m);
      return () => {
        i?.(), b?.();
      };
    },
    [r.subscribe, t.subscribe]
  );
  return { data: o, getItem: c, subscribe: u };
}, R = ({ initialData: r } = {}) => {
  const t = p(() => {
    const e = /* @__PURE__ */ new Map();
    return r == null || r.forEach((s) => e.set(s.key, s)), e;
  }), o = p(() => /* @__PURE__ */ new Map()), c = n((e) => {
    const s = new Set(e);
    o.current.forEach((f, l) => {
      s.has(f) && l();
    });
  }, []), u = n((e) => {
    const s = I.toArray(e), f = s.map((l) => l.key);
    s.forEach((l) => t.current.set(l.key, l)), c(f);
  }, []), a = n((e) => {
    const s = I.toArray(e);
    s.forEach((f) => t.current.delete(f)), c(s);
  }, []), m = n(
    (e, s) => s == null ? () => {
    } : (o.current.set(e, s), () => {
      o.current.delete(e);
    }),
    [o]
  ), i = n(
    (e) => {
      if (e != null)
        return Array.isArray(e) ? e.map((s) => t.current.get(s)).filter((s) => s != null) : t.current.get(e);
    },
    []
  ), b = n((e) => t.current.has(e), []);
  return { setItem: u, deleteItem: a, subscribe: m, getItem: i, hasItem: b };
}, S = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  CoreFrame: d,
  Frame: h,
  Item: y,
  Items: g,
  useCombinedData: x,
  useData: M,
  useItem: A,
  useKeysData: j,
  useMapData: R,
  usePager: w,
  useScroller: C,
  useStaticData: D,
  useUtilContext: E
}, Symbol.toStringTag, { value: "Module" }));
export {
  S as e,
  w as u
};
