require("../../../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_utils = require("../../../table/utils.js");
let ahooks = require("ahooks");
//#region src/components/dataSourceComponents/fields/Input.Subdomain/serve.ts
/**
* 获取nocobase数据列表 获取域名后缀
*/
const getTenantData = function() {
	var _ref = require_asyncToGenerator._asyncToGenerator(function* (id) {
		try {
			const { data } = yield require_utils.request.getRequest().get(`/tenant/core/meta/tenant/${id}/saas`, {}, {
				isNocobase: false,
				fullResult: true,
				headers: { "x-data-source": "pisell2" }
			});
			return data;
		} catch (error) {
			console.error("Failed to fetch tenant data:", error);
			throw error;
		}
	});
	return function getTenantData(_x) {
		return _ref.apply(this, arguments);
	};
}();
/**
* 自定义 Hook，用于获取租户数据
*/
const useTenantData = (rootDomain, tenantId) => {
	const { data } = (0, ahooks.useRequest)(() => {
		if (rootDomain === "saas" && tenantId) return getTenantData(tenantId);
		return Promise.resolve(void 0);
	}, {
		cacheKey: `tenant-data-${tenantId}`,
		staleTime: 1e3 * 60 * 5,
		cacheTime: 1e3 * 60 * 60
	});
	return data;
};
//#endregion
exports.useTenantData = useTenantData;
