import { html, svg } from "../../property-information/index.js";
import { htmlVoidElements } from "../../html-void-elements/index.js";
import { handle } from "./handle/index.js";
var emptyOptions = {}, emptyCharacterReferences = {}, emptyChildren = [];
function toHtml(s, c) {
	let l = c || emptyOptions, u = l.quote || "\"", d = u === "\"" ? "'" : "\"";
	if (u !== "\"" && u !== "'") throw Error("Invalid quote `" + u + "`, expected `'` or `\"`");
	return {
		one,
		all,
		settings: {
			omitOptionalTags: l.omitOptionalTags || !1,
			allowParseErrors: l.allowParseErrors || !1,
			allowDangerousCharacters: l.allowDangerousCharacters || !1,
			quoteSmart: l.quoteSmart || !1,
			preferUnquoted: l.preferUnquoted || !1,
			tightAttributes: l.tightAttributes || !1,
			upperDoctype: l.upperDoctype || !1,
			tightDoctype: l.tightDoctype || !1,
			bogusComments: l.bogusComments || !1,
			tightCommaSeparatedLists: l.tightCommaSeparatedLists || !1,
			tightSelfClosing: l.tightSelfClosing || !1,
			collapseEmptyAttributes: l.collapseEmptyAttributes || !1,
			allowDangerousHtml: l.allowDangerousHtml || !1,
			voids: l.voids || htmlVoidElements,
			characterReferences: l.characterReferences || emptyCharacterReferences,
			closeSelfClosing: l.closeSelfClosing || !1,
			closeEmptyElements: l.closeEmptyElements || !1
		},
		schema: l.space === "svg" ? svg : html,
		quote: u,
		alternative: d
	}.one(Array.isArray(s) ? {
		type: "root",
		children: s
	} : s, void 0, void 0);
}
function one(e, a, o) {
	return handle(e, a, o, this);
}
function all(e) {
	let a = [], o = e && e.children || emptyChildren, s = -1;
	for (; ++s < o.length;) a[s] = this.one(o[s], s, e);
	return a.join("");
}
export { toHtml };
