import { markdownLineEnding as e, markdownLineEndingOrSpace as t, markdownSpace as n } from "../../micromark-util-character/index.js";
import { normalizeIdentifier as r } from "../../micromark-util-normalize-identifier/index.js";
import { factorySpace as i } from "../../micromark-factory-space/index.js";
import { factoryDestination as a } from "../../micromark-factory-destination/index.js";
import { factoryLabel as o } from "../../micromark-factory-label/index.js";
import { factoryTitle as s } from "../../micromark-factory-title/index.js";
import { factoryWhitespace as c } from "../../micromark-factory-whitespace/index.js";
//#region ../../node_modules/micromark-core-commonmark/lib/definition.js
var l = {
	name: "definition",
	tokenize: d
}, u = {
	partial: !0,
	tokenize: f
};
function d(s, l, d) {
	let f = this, p;
	return m;
	function m(e) {
		return s.enter("definition"), h(e);
	}
	function h(e) {
		return o.call(f, s, g, d, "definitionLabel", "definitionLabelMarker", "definitionLabelString")(e);
	}
	function g(e) {
		return p = r(f.sliceSerialize(f.events[f.events.length - 1][1]).slice(1, -1)), e === 58 ? (s.enter("definitionMarker"), s.consume(e), s.exit("definitionMarker"), _) : d(e);
	}
	function _(e) {
		return t(e) ? c(s, v)(e) : v(e);
	}
	function v(e) {
		return a(s, y, d, "definitionDestination", "definitionDestinationLiteral", "definitionDestinationLiteralMarker", "definitionDestinationRaw", "definitionDestinationString")(e);
	}
	function y(e) {
		return s.attempt(u, b, b)(e);
	}
	function b(e) {
		return n(e) ? i(s, x, "whitespace")(e) : x(e);
	}
	function x(t) {
		return t === null || e(t) ? (s.exit("definition"), f.parser.defined.push(p), l(t)) : d(t);
	}
}
function f(r, a, o) {
	return l;
	function l(e) {
		return t(e) ? c(r, u)(e) : o(e);
	}
	function u(e) {
		return s(r, d, o, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(e);
	}
	function d(e) {
		return n(e) ? i(r, f, "whitespace")(e) : f(e);
	}
	function f(t) {
		return t === null || e(t) ? a(t) : o(t);
	}
}
//#endregion
export { l as definition };
