//#region ../../node_modules/mdast-util-to-hast/lib/handlers/list-item.js
function e(e, r, i) {
	let a = e.all(r), o = i ? t(i) : n(r), s = {}, c = [];
	if (typeof r.checked == "boolean") {
		let e = a[0], t;
		e && e.type === "element" && e.tagName === "p" ? t = e : (t = {
			type: "element",
			tagName: "p",
			properties: {},
			children: []
		}, a.unshift(t)), t.children.length > 0 && t.children.unshift({
			type: "text",
			value: " "
		}), t.children.unshift({
			type: "element",
			tagName: "input",
			properties: {
				type: "checkbox",
				checked: r.checked,
				disabled: !0
			},
			children: []
		}), s.className = ["task-list-item"];
	}
	let l = -1;
	for (; ++l < a.length;) {
		let e = a[l];
		(o || l !== 0 || e.type !== "element" || e.tagName !== "p") && c.push({
			type: "text",
			value: "\n"
		}), e.type === "element" && e.tagName === "p" && !o ? c.push(...e.children) : c.push(e);
	}
	let u = a[a.length - 1];
	u && (o || u.type !== "element" || u.tagName !== "p") && c.push({
		type: "text",
		value: "\n"
	});
	let d = {
		type: "element",
		tagName: "li",
		properties: s,
		children: c
	};
	return e.patch(r, d), e.applyData(r, d);
}
function t(e) {
	let t = !1;
	if (e.type === "list") {
		t = e.spread || !1;
		let r = e.children, i = -1;
		for (; !t && ++i < r.length;) t = n(r[i]);
	}
	return t;
}
function n(e) {
	return e.spread ?? e.children.length > 1;
}
//#endregion
export { e as listItem };
