import { pointEnd, pointStart } from "../../../unist-util-position/lib/index.js";
function table(n, r) {
	let i = n.all(r), a = i.shift(), o = [];
	if (a) {
		let e = {
			type: "element",
			tagName: "thead",
			properties: {},
			children: n.wrap([a], !0)
		};
		n.patch(r.children[0], e), o.push(e);
	}
	if (i.length > 0) {
		let a = {
			type: "element",
			tagName: "tbody",
			properties: {},
			children: n.wrap(i, !0)
		}, s = pointStart(r.children[1]), c = pointEnd(r.children[r.children.length - 1]);
		s && c && (a.position = {
			start: s,
			end: c
		}), o.push(a);
	}
	let s = {
		type: "element",
		tagName: "table",
		properties: {},
		children: n.wrap(o, !0)
	};
	return n.patch(r, s), n.applyData(r, s);
}
export { table };
