import { checkBullet } from "../util/check-bullet.js";
import { checkBulletOther } from "../util/check-bullet-other.js";
import { checkBulletOrdered } from "../util/check-bullet-ordered.js";
import { checkRule } from "../util/check-rule.js";
function list(i, a, o, s) {
	let c = o.enter("list"), l = o.bulletCurrent, u = i.ordered ? checkBulletOrdered(o) : checkBullet(o), d = i.ordered ? u === "." ? ")" : "." : checkBulletOther(o), f = a && o.bulletLastUsed ? u === o.bulletLastUsed : !1;
	if (!i.ordered) {
		let e = i.children ? i.children[0] : void 0;
		if ((u === "*" || u === "-") && e && (!e.children || !e.children[0]) && o.stack[o.stack.length - 1] === "list" && o.stack[o.stack.length - 2] === "listItem" && o.stack[o.stack.length - 3] === "list" && o.stack[o.stack.length - 4] === "listItem" && o.indexStack[o.indexStack.length - 1] === 0 && o.indexStack[o.indexStack.length - 2] === 0 && o.indexStack[o.indexStack.length - 3] === 0 && (f = !0), checkRule(o) === u && e) {
			let e = -1;
			for (; ++e < i.children.length;) {
				let r = i.children[e];
				if (r && r.type === "listItem" && r.children && r.children[0] && r.children[0].type === "thematicBreak") {
					f = !0;
					break;
				}
			}
		}
	}
	f && (u = d), o.bulletCurrent = u;
	let p = o.containerFlow(i, s);
	return o.bulletLastUsed = u, o.bulletCurrent = l, c(), p;
}
export { list };
