import { markdownLineEnding, markdownLineEndingOrSpace, markdownSpace } from "../../micromark-util-character/index.js";
import { factorySpace } from "../../micromark-factory-space/index.js";
var tasklistCheck = {
	name: "tasklistCheck",
	tokenize: tokenizeTasklistCheck
};
function gfmTaskListItem() {
	return { text: { 91: tasklistCheck } };
}
function tokenizeTasklistCheck(i, a, o) {
	let s = this;
	return c;
	function c(e) {
		return s.previous !== null || !s._gfmTasklistFirstContentOfListItem ? o(e) : (i.enter("taskListCheck"), i.enter("taskListCheckMarker"), i.consume(e), i.exit("taskListCheckMarker"), l);
	}
	function l(e) {
		return markdownLineEndingOrSpace(e) ? (i.enter("taskListCheckValueUnchecked"), i.consume(e), i.exit("taskListCheckValueUnchecked"), u) : e === 88 || e === 120 ? (i.enter("taskListCheckValueChecked"), i.consume(e), i.exit("taskListCheckValueChecked"), u) : o(e);
	}
	function u(e) {
		return e === 93 ? (i.enter("taskListCheckMarker"), i.consume(e), i.exit("taskListCheckMarker"), i.exit("taskListCheck"), d) : o(e);
	}
	function d(n) {
		return markdownLineEnding(n) ? a(n) : markdownSpace(n) ? i.check({ tokenize: spaceThenNonSpace }, a, o)(n) : o(n);
	}
}
function spaceThenNonSpace(e, n, r) {
	return factorySpace(e, a, "whitespace");
	function a(e) {
		return e === null ? r(e) : n(e);
	}
}
export { gfmTaskListItem };
