//#region src/v2/helpers/download-document.ts
/**
* Triggers a file download in the browser for the given content.
* Creates a blob, programmatically clicks a temporary link, then revokes the object URL.
*
* @param content - The string content to download (e.g. JSON or YAML).
* @param filename - The name of the file to save (e.g. "my-api.json").
* @param mimeType - Optional MIME type for the blob. Defaults to "application/json".
*/
function createClickEvent() {
	try {
		return new MouseEvent("click", {
			bubbles: true,
			cancelable: true,
			view: window
		});
	} catch {
		return new MouseEvent("click", {
			bubbles: true,
			cancelable: true
		});
	}
}
function downloadAsFile(content, filename, mimeType = "application/json") {
	const blob = new Blob([content], { type: mimeType });
	const url = URL.createObjectURL(blob);
	const link = document.createElement("a");
	link.href = url;
	link.download = filename;
	link.style.display = "none";
	link.setAttribute("aria-hidden", "true");
	document.body.appendChild(link);
	link.dispatchEvent(createClickEvent());
	setTimeout(() => {
		URL.revokeObjectURL(url);
		document.body.removeChild(link);
	}, 100);
}
//#endregion
export { downloadAsFile };

//# sourceMappingURL=download-document.js.map