import React from "react";
import { RuntimeContext } from "@qorebase/app-runtime/src/RuntimeContext";
import { usePageParam } from "@qorebase/app-runtime/src/hooks/usePageParam";
export const useSourceView = () => {
    const tables = RuntimeContext.useSelectState((state) => state.schema.tables);
    const views = RuntimeContext.useSelectState((state) => state.schema.views);
    const pageParam = usePageParam();
    const page = RuntimeContext.useSelectState((state) => state.maps.page[pageParam]);
    const sourceView = React.useMemo(() => {
        return (tables.find((table) => table.name === (page === null || page === void 0 ? void 0 : page.sourceID)) ||
            views.find((view) => view.name === (page === null || page === void 0 ? void 0 : page.sourceID)));
    }, [tables, views, page]);
    return sourceView;
};
//# sourceMappingURL=useSourceView.js.map