import { asciiAlpha as e, asciiAlphanumeric as t, asciiControl as n, markdownLineEndingOrSpace as r, unicodePunctuation as i, unicodeWhitespace as a } from "../../micromark-util-character/index.js";
//#region ../../node_modules/micromark-extension-gfm-autolink-literal/lib/syntax.js
var o = {
	tokenize: b,
	partial: !0
}, s = {
	tokenize: x,
	partial: !0
}, c = {
	tokenize: S,
	partial: !0
}, l = {
	tokenize: C,
	partial: !0
}, u = {
	tokenize: w,
	partial: !0
}, d = {
	name: "wwwAutolink",
	tokenize: v,
	previous: T
}, f = {
	name: "protocolAutolink",
	tokenize: y,
	previous: E
}, p = {
	name: "emailAutolink",
	tokenize: _,
	previous: D
}, m = {};
function h() {
	return { text: m };
}
for (var g = 48; g < 123;) m[g] = p, g++, g === 58 ? g = 65 : g === 91 && (g = 97);
m[43] = p, m[45] = p, m[46] = p, m[95] = p, m[72] = [p, f], m[104] = [p, f], m[87] = [p, d], m[119] = [p, d];
function _(n, r, i) {
	let a = this, o, s;
	return c;
	function c(e) {
		return !O(e) || !D.call(a, a.previous) || k(a.events) ? i(e) : (n.enter("literalAutolink"), n.enter("literalAutolinkEmail"), l(e));
	}
	function l(e) {
		return O(e) ? (n.consume(e), l) : e === 64 ? (n.consume(e), d) : i(e);
	}
	function d(e) {
		return e === 46 ? n.check(u, p, f)(e) : e === 45 || e === 95 || t(e) ? (s = !0, n.consume(e), d) : p(e);
	}
	function f(e) {
		return n.consume(e), o = !0, d;
	}
	function p(t) {
		return s && o && e(a.previous) ? (n.exit("literalAutolinkEmail"), n.exit("literalAutolink"), r(t)) : i(t);
	}
}
function v(e, t, n) {
	let r = this;
	return i;
	function i(t) {
		return t !== 87 && t !== 119 || !T.call(r, r.previous) || k(r.events) ? n(t) : (e.enter("literalAutolink"), e.enter("literalAutolinkWww"), e.check(o, e.attempt(s, e.attempt(c, a), n), n)(t));
	}
	function a(n) {
		return e.exit("literalAutolinkWww"), e.exit("literalAutolink"), t(n);
	}
}
function y(t, o, l) {
	let u = this, d = "", f = !1;
	return p;
	function p(e) {
		return (e === 72 || e === 104) && E.call(u, u.previous) && !k(u.events) ? (t.enter("literalAutolink"), t.enter("literalAutolinkHttp"), d += String.fromCodePoint(e), t.consume(e), m) : l(e);
	}
	function m(n) {
		if (e(n) && d.length < 5) return d += String.fromCodePoint(n), t.consume(n), m;
		if (n === 58) {
			let e = d.toLowerCase();
			if (e === "http" || e === "https") return t.consume(n), h;
		}
		return l(n);
	}
	function h(e) {
		return e === 47 ? (t.consume(e), f ? g : (f = !0, h)) : l(e);
	}
	function g(e) {
		return e === null || n(e) || r(e) || a(e) || i(e) ? l(e) : t.attempt(s, t.attempt(c, _), l)(e);
	}
	function _(e) {
		return t.exit("literalAutolinkHttp"), t.exit("literalAutolink"), o(e);
	}
}
function b(e, t, n) {
	let r = 0;
	return i;
	function i(t) {
		return (t === 87 || t === 119) && r < 3 ? (r++, e.consume(t), i) : t === 46 && r === 3 ? (e.consume(t), a) : n(t);
	}
	function a(e) {
		return e === null ? n(e) : t(e);
	}
}
function x(e, t, n) {
	let o, s, c;
	return u;
	function u(t) {
		return t === 46 || t === 95 ? e.check(l, f, d)(t) : t === null || r(t) || a(t) || t !== 45 && i(t) ? f(t) : (c = !0, e.consume(t), u);
	}
	function d(t) {
		return t === 95 ? o = !0 : (s = o, o = void 0), e.consume(t), u;
	}
	function f(e) {
		return s || o || !c ? n(e) : t(e);
	}
}
function S(e, t) {
	let n = 0, i = 0;
	return o;
	function o(c) {
		return c === 40 ? (n++, e.consume(c), o) : c === 41 && i < n ? s(c) : c === 33 || c === 34 || c === 38 || c === 39 || c === 41 || c === 42 || c === 44 || c === 46 || c === 58 || c === 59 || c === 60 || c === 63 || c === 93 || c === 95 || c === 126 ? e.check(l, t, s)(c) : c === null || r(c) || a(c) ? t(c) : (e.consume(c), o);
	}
	function s(t) {
		return t === 41 && i++, e.consume(t), o;
	}
}
function C(t, n, i) {
	return o;
	function o(e) {
		return e === 33 || e === 34 || e === 39 || e === 41 || e === 42 || e === 44 || e === 46 || e === 58 || e === 59 || e === 63 || e === 95 || e === 126 ? (t.consume(e), o) : e === 38 ? (t.consume(e), c) : e === 93 ? (t.consume(e), s) : e === 60 || e === null || r(e) || a(e) ? n(e) : i(e);
	}
	function s(e) {
		return e === null || e === 40 || e === 91 || r(e) || a(e) ? n(e) : o(e);
	}
	function c(t) {
		return e(t) ? l(t) : i(t);
	}
	function l(n) {
		return n === 59 ? (t.consume(n), o) : e(n) ? (t.consume(n), l) : i(n);
	}
}
function w(e, n, r) {
	return i;
	function i(t) {
		return e.consume(t), a;
	}
	function a(e) {
		return t(e) ? r(e) : n(e);
	}
}
function T(e) {
	return e === null || e === 40 || e === 42 || e === 95 || e === 91 || e === 93 || e === 126 || r(e);
}
function E(t) {
	return !e(t);
}
function D(e) {
	return !(e === 47 || O(e));
}
function O(e) {
	return e === 43 || e === 45 || e === 46 || e === 95 || t(e);
}
function k(e) {
	let t = e.length, n = !1;
	for (; t--;) {
		let r = e[t][1];
		if ((r.type === "labelLink" || r.type === "labelImage") && !r._balanced) {
			n = !0;
			break;
		}
		if (r._gfmAutolinkLiteralWalkedInto) {
			n = !1;
			break;
		}
	}
	return e.length > 0 && !n && (e[e.length - 1][1]._gfmAutolinkLiteralWalkedInto = !0), n;
}
//#endregion
export { h as gfmAutolinkLiteral };
