import { asciiAlpha as e, asciiAlphanumeric as t, markdownLineEnding as n, markdownLineEndingOrSpace as r, markdownSpace as i } from "../../micromark-util-character/index.js";
import { blankLine as a } from "./blank-line.js";
import { htmlBlockNames as o, htmlRawNames as s } from "../../micromark-util-html-tag-name/index.js";
//#region ../../node_modules/micromark-core-commonmark/lib/html-flow.js
var c = {
	concrete: !0,
	name: "htmlFlow",
	resolveTo: d,
	tokenize: f
}, l = {
	partial: !0,
	tokenize: m
}, u = {
	partial: !0,
	tokenize: p
};
function d(e) {
	let t = e.length;
	for (; t-- && !(e[t][0] === "enter" && e[t][1].type === "htmlFlow"););
	return t > 1 && e[t - 2][1].type === "linePrefix" && (e[t][1].start = e[t - 2][1].start, e[t + 1][1].start = e[t - 2][1].start, e.splice(t - 2, 2)), e;
}
function f(a, c, d) {
	let f = this, p, m, h, g, _;
	return v;
	function v(e) {
		return y(e);
	}
	function y(e) {
		return a.enter("htmlFlow"), a.enter("htmlFlowData"), a.consume(e), b;
	}
	function b(t) {
		return t === 33 ? (a.consume(t), x) : t === 47 ? (a.consume(t), m = !0, w) : t === 63 ? (a.consume(t), p = 3, f.interrupt ? c : G) : e(t) ? (a.consume(t), h = String.fromCharCode(t), T) : d(t);
	}
	function x(t) {
		return t === 45 ? (a.consume(t), p = 2, S) : t === 91 ? (a.consume(t), p = 5, g = 0, C) : e(t) ? (a.consume(t), p = 4, f.interrupt ? c : G) : d(t);
	}
	function S(e) {
		return e === 45 ? (a.consume(e), f.interrupt ? c : G) : d(e);
	}
	function C(e) {
		return e === "CDATA[".charCodeAt(g++) ? (a.consume(e), g === 6 ? f.interrupt ? c : L : C) : d(e);
	}
	function w(t) {
		return e(t) ? (a.consume(t), h = String.fromCharCode(t), T) : d(t);
	}
	function T(e) {
		if (e === null || e === 47 || e === 62 || r(e)) {
			let t = e === 47, n = h.toLowerCase();
			return !t && !m && s.includes(n) ? (p = 1, f.interrupt ? c(e) : L(e)) : o.includes(h.toLowerCase()) ? (p = 6, t ? (a.consume(e), E) : f.interrupt ? c(e) : L(e)) : (p = 7, f.interrupt && !f.parser.lazy[f.now().line] ? d(e) : m ? D(e) : O(e));
		}
		return e === 45 || t(e) ? (a.consume(e), h += String.fromCharCode(e), T) : d(e);
	}
	function E(e) {
		return e === 62 ? (a.consume(e), f.interrupt ? c : L) : d(e);
	}
	function D(e) {
		return i(e) ? (a.consume(e), D) : F(e);
	}
	function O(t) {
		return t === 47 ? (a.consume(t), F) : t === 58 || t === 95 || e(t) ? (a.consume(t), k) : i(t) ? (a.consume(t), O) : F(t);
	}
	function k(e) {
		return e === 45 || e === 46 || e === 58 || e === 95 || t(e) ? (a.consume(e), k) : A(e);
	}
	function A(e) {
		return e === 61 ? (a.consume(e), j) : i(e) ? (a.consume(e), A) : O(e);
	}
	function j(e) {
		return e === null || e === 60 || e === 61 || e === 62 || e === 96 ? d(e) : e === 34 || e === 39 ? (a.consume(e), _ = e, M) : i(e) ? (a.consume(e), j) : N(e);
	}
	function M(e) {
		return e === _ ? (a.consume(e), _ = null, P) : e === null || n(e) ? d(e) : (a.consume(e), M);
	}
	function N(e) {
		return e === null || e === 34 || e === 39 || e === 47 || e === 60 || e === 61 || e === 62 || e === 96 || r(e) ? A(e) : (a.consume(e), N);
	}
	function P(e) {
		return e === 47 || e === 62 || i(e) ? O(e) : d(e);
	}
	function F(e) {
		return e === 62 ? (a.consume(e), I) : d(e);
	}
	function I(e) {
		return e === null || n(e) ? L(e) : i(e) ? (a.consume(e), I) : d(e);
	}
	function L(e) {
		return e === 45 && p === 2 ? (a.consume(e), V) : e === 60 && p === 1 ? (a.consume(e), H) : e === 62 && p === 4 ? (a.consume(e), K) : e === 63 && p === 3 ? (a.consume(e), G) : e === 93 && p === 5 ? (a.consume(e), W) : n(e) && (p === 6 || p === 7) ? (a.exit("htmlFlowData"), a.check(l, q, R)(e)) : e === null || n(e) ? (a.exit("htmlFlowData"), R(e)) : (a.consume(e), L);
	}
	function R(e) {
		return a.check(u, z, q)(e);
	}
	function z(e) {
		return a.enter("lineEnding"), a.consume(e), a.exit("lineEnding"), B;
	}
	function B(e) {
		return e === null || n(e) ? R(e) : (a.enter("htmlFlowData"), L(e));
	}
	function V(e) {
		return e === 45 ? (a.consume(e), G) : L(e);
	}
	function H(e) {
		return e === 47 ? (a.consume(e), h = "", U) : L(e);
	}
	function U(t) {
		if (t === 62) {
			let e = h.toLowerCase();
			return s.includes(e) ? (a.consume(t), K) : L(t);
		}
		return e(t) && h.length < 8 ? (a.consume(t), h += String.fromCharCode(t), U) : L(t);
	}
	function W(e) {
		return e === 93 ? (a.consume(e), G) : L(e);
	}
	function G(e) {
		return e === 62 ? (a.consume(e), K) : e === 45 && p === 2 ? (a.consume(e), G) : L(e);
	}
	function K(e) {
		return e === null || n(e) ? (a.exit("htmlFlowData"), q(e)) : (a.consume(e), K);
	}
	function q(e) {
		return a.exit("htmlFlow"), c(e);
	}
}
function p(e, t, r) {
	let i = this;
	return a;
	function a(t) {
		return n(t) ? (e.enter("lineEnding"), e.consume(t), e.exit("lineEnding"), o) : r(t);
	}
	function o(e) {
		return i.parser.lazy[i.now().line] ? r(e) : t(e);
	}
}
function m(e, t, n) {
	return r;
	function r(r) {
		return e.enter("lineEnding"), e.consume(r), e.exit("lineEnding"), e.attempt(a, t, n);
	}
}
//#endregion
export { c as htmlFlow };
