const require_fetcher = require('../fetcher.cjs');
const require_built = require('../config/dist/esm/built.cjs');

//#region ../@intlayer/cli/dist/esm/api/dist/esm/getIntlayerAPI/audit.mjs
const getAuditAPI = (authAPIOptions = {}, intlayerConfig) => {
	const backendURL = intlayerConfig?.editor?.backendURL ?? require_built.built_default?.editor?.backendURL;
	if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
	const AUDIT_API_ROUTE = `${backendURL}/api/audit`;
	/**
	* Creates a new audit in the database.
	* @param audit - Audit data.
	*/
	const createAudit = async (audit, otherOptions = {}) => await require_fetcher.fetcher(`${AUDIT_API_ROUTE}`, authAPIOptions, otherOptions, {
		method: "POST",
		body: audit
	});
	/**
	* Retrieves audits for the current user or project.
	* @param params - Query parameters (page, pageSize).
	*/
	const getAudits = async (params, otherOptions = {}) => await require_fetcher.fetcher(AUDIT_API_ROUTE, authAPIOptions, otherOptions, {
		cache: "no-store",
		params
	});
	/**
	* Retrieves an audit by its ID.
	* @param auditId - Audit ID.
	*/
	const getAuditById = async (auditId, otherOptions = {}) => await require_fetcher.fetcher(`${AUDIT_API_ROUTE}/${String(auditId)}`, authAPIOptions, otherOptions, { cache: "no-store" });
	return {
		createAudit,
		getAudits,
		getAuditById
	};
};

//#endregion
exports.getAuditAPI = getAuditAPI;
//# sourceMappingURL=audit.cjs.map