import { useQuery as L } from "../../../../node_modules/.pnpm/@tanstack_react-query@5.80.6_react@19.0.0/node_modules/@tanstack/react-query/build/modern/useQuery.js";
import { useInfiniteQuery as P } from "../../../../node_modules/.pnpm/@tanstack_react-query@5.80.6_react@19.0.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js";
import "../../../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/index.js";
import g from "../../../../node_modules/.pnpm/axios@1.9.0/node_modules/axios/lib/axios.js";
function C({ collection: t, pageSize: o = 50, searchText: a = "" }) {
  const {
    data: i,
    isLoading: d,
    isError: c
  } = L({
    queryKey: ["icon-collection", t],
    queryFn: () => g.get(`https://api.iconify.design/collection?prefix=${t}`).then((n) => n.data),
    enabled: !!t,
    staleTime: 1 / 0,
    // Icons don't change often, so we can cache them indefinitely
    gcTime: 36e5
    // Keep unused data in cache for 1 hour
  }), e = a && (i != null && i.uncategorized) ? i.uncategorized.filter(
    (n) => n.toLowerCase().includes(a.toLowerCase())
  ) : i == null ? void 0 : i.uncategorized, {
    data: u,
    isLoading: m,
    isError: f,
    fetchNextPage: y,
    hasNextPage: h,
    isFetchingNextPage: p
  } = P({
    queryKey: ["collection-icon-data", { collection: t, icons: e, searchText: a }],
    queryFn: ({ pageParam: n = 0 }) => {
      const r = (n ?? 0) * o, s = r + o;
      return g.get(`https://api.iconify.design/${t}.json`, {
        params: {
          icons: e == null ? void 0 : e.slice(r, s).join(",")
        }
      }).then((l) => l.data);
    },
    initialPageParam: 0,
    getNextPageParam: (n, r) => {
      const s = r.length * o;
      if (e && s < e.length)
        return r.length;
    },
    enabled: !!e && e.length > 0,
    staleTime: 1 / 0,
    // Icons don't change often, so we can cache them indefinitely
    gcTime: 1e3 * 60 * 60
    // Keep unused data in cache for 1 hour
  });
  return {
    data: u,
    isLoading: d || m,
    isError: c || f,
    fetchNextPage: y,
    hasNextPage: h,
    isFetchingNextPage: p
  };
}
export {
  C as useIcons
};
//# sourceMappingURL=use-icons.js.map
