import { h as e, s as t } from "../../hastscript/lib/index.js";
import { webNamespaces as n } from "../../web-namespaces/index.js";
//#region ../../node_modules/hast-util-from-dom/lib/index.js
function r(e, t) {
	return i(e, t || {}) || {
		type: "root",
		children: []
	};
}
function i(e, t) {
	let n = a(e, t);
	return n && t.afterTransform && t.afterTransform(e, n), n;
}
function a(e, t) {
	switch (e.nodeType) {
		case 1: return u(e, t);
		case 3: return c(e);
		case 8: return l(e);
		case 9: return o(e, t);
		case 10: return s();
		case 11: return o(e, t);
		default: return;
	}
}
function o(e, t) {
	return {
		type: "root",
		children: d(e, t)
	};
}
function s() {
	return { type: "doctype" };
}
function c(e) {
	return {
		type: "text",
		value: e.nodeValue || ""
	};
}
function l(e) {
	return {
		type: "comment",
		value: e.nodeValue || ""
	};
}
function u(r, i) {
	let a = r.namespaceURI, o = a === n.svg ? t : e, s = a === n.html ? r.tagName.toLowerCase() : r.tagName, c = a === n.html && s === "template" ? r.content : r, l = r.getAttributeNames(), u = {}, f = -1;
	for (; ++f < l.length;) u[l[f]] = r.getAttribute(l[f]) || "";
	return o(s, u, d(c, i));
}
function d(e, t) {
	let n = e.childNodes, r = [], a = -1;
	for (; ++a < n.length;) {
		let e = i(n[a], t);
		e !== void 0 && r.push(e);
	}
	return r;
}
//#endregion
export { r as fromDom };
