import { fetcher } from "../fetcher.mjs";
import { built_default } from "../config/dist/esm/built.mjs";

//#region ../@intlayer/chokidar/dist/esm/api/dist/esm/getIntlayerAPI/tag.mjs
const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
	const backendURL = intlayerConfig?.editor?.backendURL ?? built_default?.editor?.backendURL;
	if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
	const PROJECT_API_ROUTE = `${backendURL}/api/tag`;
	/**
	* Retrieves a list of tags based on filters and pagination.
	* @param filters - Filters and pagination options.
	*/
	const getTags = async (filters, otherOptions = {}) => await fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
		cache: "no-store",
		params: filters
	});
	/**
	* Adds a new tag to the database.
	* @param tag - Tag data.
	*/
	const addTag = async (tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
		method: "POST",
		body: tag
	});
	/**
	* Updates an existing tag in the database.
	* @param tag - Updated tag data.
	*/
	const updateTag = async (tagId, tag, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, {
		method: "PUT",
		body: tag
	});
	/**
	* Deletes a tag from the database by its ID.
	* @param tagId - Tag ID.
	*/
	const deleteTag = async (tagId, otherOptions = {}) => await fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, { method: "DELETE" });
	return {
		getTags,
		addTag,
		updateTag,
		deleteTag
	};
};

//#endregion
export { getTagAPI };
//# sourceMappingURL=tag.mjs.map