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

//#region ../chokidar/dist/esm/api/dist/esm/getIntlayerAPI/newsletter.mjs
const getNewsletterAPI = (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 NEWSLETTER_API_ROUTE = `${backendURL}/api/newsletter`;
	/**
	* Subscribe a user to newsletter(s)
	* @param body - Newsletter subscription parameters.
	* @returns Newsletter subscription result.
	*/
	const subscribeToNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/subscribe`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	/**
	* Unsubscribe a user from newsletter(s)
	* @param body - Newsletter unsubscription parameters.
	* @returns Newsletter unsubscription result.
	*/
	const unsubscribeFromNewsletter = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/unsubscribe`, authAPIOptions, otherOptions, {
		method: "POST",
		body
	});
	/**
	* Get newsletter subscription status for the authenticated user
	* @returns Newsletter subscription status.
	*/
	const getNewsletterStatus = async (otherOptions = {}) => await require_fetcher.fetcher(`${NEWSLETTER_API_ROUTE}/status`, authAPIOptions, otherOptions, { method: "GET" });
	return {
		subscribeToNewsletter,
		unsubscribeFromNewsletter,
		getNewsletterStatus
	};
};

//#endregion
exports.getNewsletterAPI = getNewsletterAPI;
//# sourceMappingURL=newsletter.cjs.map