import useDataSource from "../../dataSourceComponents/hooks/useDataSource.js";
import { useMemo, useRef } from "react";
import { isString } from "@pisell/utils";
//#region src/components/pisellDataSourceContainer/hooks/useDataSourceKey.ts
const useDataSourceKey = () => {
	const { dataSource } = useDataSource();
	const dataSourceKey = useMemo(() => {
		return isString(dataSource) ? dataSource : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.key) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.tableName);
	}, [dataSource]);
	const dataSourceKeyRef = useRef(dataSourceKey);
	dataSourceKeyRef.current = dataSourceKey;
	return {
		dataSourceKey,
		dataSourceKeyRef
	};
};
//#endregion
export { useDataSourceKey as default };
