import { Kt as e, R as t, Sn as n, Wt as r, Y as i, b as a, c as o, nt as s, q as c, xn as l } from "./dist-DWhP3Dp2.js";
//#region ../../node_modules/.pnpm/linkifyjs@4.3.3/node_modules/linkifyjs/dist/linkify.mjs
var u = " ögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2", d = "ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2", f = "numeric", p = "ascii", m = "alpha", h = "asciinumeric", g = "alphanumeric", _ = "domain", ee = "emoji", te = "scheme", v = "slashscheme", y = "whitespace";
function b(e, t) {
	return e in t || (t[e] = []), t[e];
}
function x(e, t, n) {
	t[f] && (t[h] = !0, t[g] = !0), t[p] && (t[h] = !0, t[m] = !0), t[h] && (t[g] = !0), t[m] && (t[g] = !0), t[g] && (t[_] = !0), t[ee] && (t[_] = !0);
	for (let r in t) {
		let t = b(r, n);
		t.indexOf(e) < 0 && t.push(e);
	}
}
function S(e, t) {
	let n = {};
	for (let r in t) t[r].indexOf(e) >= 0 && (n[r] = !0);
	return n;
}
function C(e = null) {
	this.j = {}, this.jr = [], this.jd = null, this.t = e;
}
C.groups = {}, C.prototype = {
	accepts() {
		return !!this.t;
	},
	go(e) {
		let t = this, n = t.j[e];
		if (n) return n;
		for (let n = 0; n < t.jr.length; n++) {
			let r = t.jr[n][0], i = t.jr[n][1];
			if (i && r.test(e)) return i;
		}
		return t.jd;
	},
	has(e, t = !1) {
		return t ? e in this.j : !!this.go(e);
	},
	ta(e, t, n, r) {
		for (let i = 0; i < e.length; i++) this.tt(e[i], t, n, r);
	},
	tr(e, t, n, r) {
		r ||= C.groups;
		let i;
		return t && t.j ? i = t : (i = new C(t), n && r && x(t, n, r)), this.jr.push([e, i]), i;
	},
	ts(e, t, n, r) {
		let i = this, a = e.length;
		if (!a) return i;
		for (let t = 0; t < a - 1; t++) i = i.tt(e[t]);
		return i.tt(e[a - 1], t, n, r);
	},
	tt(e, t, n, r) {
		r ||= C.groups;
		let i = this;
		if (t && t.j) return i.j[e] = t, t;
		let a = t, o, s = i.go(e);
		return s ? (o = new C(), Object.assign(o.j, s.j), o.jr.push.apply(o.jr, s.jr), o.jd = s.jd, o.t = s.t) : o = new C(), a && (r && (o.t && typeof o.t == "string" ? x(a, Object.assign(S(o.t, r), n), r) : n && x(a, n, r)), o.t = a), i.j[e] = o, o;
	}
};
var w = (e, t, n, r, i) => e.ta(t, n, r, i), T = (e, t, n, r, i) => e.tr(t, n, r, i), ne = (e, t, n, r, i) => e.ts(t, n, r, i), E = (e, t, n, r, i) => e.tt(t, n, r, i), D = "WORD", re = "UWORD", ie = "ASCIINUMERICAL", ae = "ALPHANUMERICAL", O = "LOCALHOST", oe = "TLD", se = "UTLD", ce = "SCHEME", k = "SLASH_SCHEME", le = "NUM", ue = "WS", de = "NL", A = "OPENBRACE", j = "CLOSEBRACE", M = "OPENBRACKET", fe = "CLOSEBRACKET", pe = "OPENPAREN", me = "CLOSEPAREN", he = "OPENANGLEBRACKET", ge = "CLOSEANGLEBRACKET", _e = "FULLWIDTHLEFTPAREN", N = "FULLWIDTHRIGHTPAREN", P = "LEFTCORNERBRACKET", F = "RIGHTCORNERBRACKET", I = "LEFTWHITECORNERBRACKET", ve = "RIGHTWHITECORNERBRACKET", ye = "FULLWIDTHLESSTHAN", be = "FULLWIDTHGREATERTHAN", xe = "AMPERSAND", Se = "APOSTROPHE", Ce = "ASTERISK", L = "AT", we = "BACKSLASH", Te = "BACKTICK", Ee = "CARET", R = "COLON", De = "COMMA", Oe = "DOLLAR", z = "DOT", ke = "EQUALS", Ae = "EXCLAMATION", B = "HYPHEN", V = "PERCENT", je = "PIPE", Me = "PLUS", Ne = "POUND", H = "QUERY", Pe = "QUOTE", Fe = "FULLWIDTHMIDDLEDOT", Ie = "SEMI", U = "SLASH", W = "TILDE", Le = "UNDERSCORE", Re = "EMOJI", ze = "SYM", Be = /* @__PURE__ */ Object.freeze({
	__proto__: null,
	ALPHANUMERICAL: ae,
	AMPERSAND: xe,
	APOSTROPHE: Se,
	ASCIINUMERICAL: ie,
	ASTERISK: Ce,
	AT: L,
	BACKSLASH: we,
	BACKTICK: Te,
	CARET: Ee,
	CLOSEANGLEBRACKET: ge,
	CLOSEBRACE: j,
	CLOSEBRACKET: fe,
	CLOSEPAREN: me,
	COLON: R,
	COMMA: De,
	DOLLAR: Oe,
	DOT: z,
	EMOJI: Re,
	EQUALS: ke,
	EXCLAMATION: Ae,
	FULLWIDTHGREATERTHAN: be,
	FULLWIDTHLEFTPAREN: _e,
	FULLWIDTHLESSTHAN: ye,
	FULLWIDTHMIDDLEDOT: Fe,
	FULLWIDTHRIGHTPAREN: N,
	HYPHEN: B,
	LEFTCORNERBRACKET: P,
	LEFTWHITECORNERBRACKET: I,
	LOCALHOST: O,
	NL: de,
	NUM: le,
	OPENANGLEBRACKET: he,
	OPENBRACE: A,
	OPENBRACKET: M,
	OPENPAREN: pe,
	PERCENT: V,
	PIPE: je,
	PLUS: Me,
	POUND: Ne,
	QUERY: H,
	QUOTE: Pe,
	RIGHTCORNERBRACKET: F,
	RIGHTWHITECORNERBRACKET: ve,
	SCHEME: ce,
	SEMI: Ie,
	SLASH: U,
	SLASH_SCHEME: k,
	SYM: ze,
	TILDE: W,
	TLD: oe,
	UNDERSCORE: Le,
	UTLD: se,
	UWORD: re,
	WORD: D,
	WS: ue
}), G = /[a-z]/, K = /\p{L}/u, Ve = /\p{Emoji}/u, q = /\d/, He = /\s/, Ue = "\r", We = "\n", Ge = "️", Ke = "‍", qe = "￼", Je = null, Ye = null;
function J(e = []) {
	let t = {};
	C.groups = t;
	let n = new C();
	Je ??= Qe(u), Ye ??= Qe(d), E(n, "'", Se), E(n, "{", A), E(n, "}", j), E(n, "[", M), E(n, "]", fe), E(n, "(", pe), E(n, ")", me), E(n, "<", he), E(n, ">", ge), E(n, "（", _e), E(n, "）", N), E(n, "「", P), E(n, "」", F), E(n, "『", I), E(n, "』", ve), E(n, "＜", ye), E(n, "＞", be), E(n, "&", xe), E(n, "*", Ce), E(n, "@", L), E(n, "`", Te), E(n, "^", Ee), E(n, ":", R), E(n, ",", De), E(n, "$", Oe), E(n, ".", z), E(n, "=", ke), E(n, "!", Ae), E(n, "-", B), E(n, "%", V), E(n, "|", je), E(n, "+", Me), E(n, "#", Ne), E(n, "?", H), E(n, "\"", Pe), E(n, "/", U), E(n, ";", Ie), E(n, "~", W), E(n, "_", Le), E(n, "\\", we), E(n, "・", Fe);
	let r = T(n, q, le, { [f]: !0 });
	T(r, q, r);
	let i = T(r, G, ie, { [h]: !0 }), a = T(r, K, ae, { [g]: !0 }), o = T(n, G, D, { [p]: !0 });
	T(o, q, i), T(o, G, o), T(i, q, i), T(i, G, i);
	let s = T(n, K, re, { [m]: !0 });
	T(s, G), T(s, q, a), T(s, K, s), T(a, q, a), T(a, G), T(a, K, a);
	let c = E(n, We, de, { [y]: !0 }), l = E(n, Ue, ue, { [y]: !0 }), b = T(n, He, ue, { [y]: !0 });
	E(n, qe, b), E(l, We, c), E(l, qe, b), T(l, He, b), E(b, Ue), E(b, We), T(b, He, b), E(b, qe, b);
	let S = T(n, Ve, Re, { [ee]: !0 });
	E(S, "#"), T(S, Ve, S), E(S, Ge, S);
	let w = E(S, Ke);
	E(w, "#"), T(w, Ve, S);
	let J = [[G, o], [q, i]], Xe = [
		[G, null],
		[K, s],
		[q, a]
	];
	for (let e = 0; e < Je.length; e++) Y(n, Je[e], oe, D, J);
	for (let e = 0; e < Ye.length; e++) Y(n, Ye[e], se, re, Xe);
	x(oe, {
		tld: !0,
		ascii: !0
	}, t), x(se, {
		utld: !0,
		alpha: !0
	}, t), Y(n, "file", ce, D, J), Y(n, "mailto", ce, D, J), Y(n, "http", k, D, J), Y(n, "https", k, D, J), Y(n, "ftp", k, D, J), Y(n, "ftps", k, D, J), x(ce, {
		scheme: !0,
		ascii: !0
	}, t), x(k, {
		slashscheme: !0,
		ascii: !0
	}, t), e = e.sort((e, t) => e[0] > t[0] ? 1 : -1);
	for (let t = 0; t < e.length; t++) {
		let r = e[t][0], i = e[t][1] ? { [te]: !0 } : { [v]: !0 };
		r.indexOf("-") >= 0 ? i[_] = !0 : G.test(r) ? q.test(r) ? i[h] = !0 : i[p] = !0 : i[f] = !0, ne(n, r, r, i);
	}
	return ne(n, "localhost", O, { ascii: !0 }), n.jd = new C(ze), {
		start: n,
		tokens: Object.assign({ groups: t }, Be)
	};
}
function Xe(e, t) {
	let n = Ze(t.replace(/[A-Z]/g, (e) => e.toLowerCase())), r = n.length, i = [], a = 0, o = 0;
	for (; o < r;) {
		let s = e, c = null, l = 0, u = null, d = -1, f = -1;
		for (; o < r && (c = s.go(n[o]));) s = c, s.accepts() ? (d = 0, f = 0, u = s) : d >= 0 && (d += n[o].length, f++), l += n[o].length, a += n[o].length, o++;
		a -= d, o -= f, l -= d, i.push({
			t: u.t,
			v: t.slice(a - l, a),
			s: a - l,
			e: a
		});
	}
	return i;
}
function Ze(e) {
	let t = [], n = e.length, r = 0;
	for (; r < n;) {
		let i = e.charCodeAt(r), a, o = i < 55296 || i > 56319 || r + 1 === n || (a = e.charCodeAt(r + 1)) < 56320 || a > 57343 ? e[r] : e.slice(r, r + 2);
		t.push(o), r += o.length;
	}
	return t;
}
function Y(e, t, n, r, i) {
	let a, o = t.length;
	for (let n = 0; n < o - 1; n++) {
		let o = t[n];
		e.j[o] ? a = e.j[o] : (a = new C(r), a.jr = i.slice(), e.j[o] = a), e = a;
	}
	return a = new C(n), a.jr = i.slice(), e.j[t[o - 1]] = a, a;
}
function Qe(e) {
	let t = [], n = [], r = 0;
	for (; r < e.length;) {
		let i = 0;
		for (; "0123456789".indexOf(e[r + i]) >= 0;) i++;
		if (i > 0) {
			t.push(n.join(""));
			for (let t = parseInt(e.substring(r, r + i), 10); t > 0; t--) n.pop();
			r += i;
		} else n.push(e[r]), r++;
	}
	return t;
}
var X = {
	defaultProtocol: "http",
	events: null,
	format: et,
	formatHref: et,
	nl2br: !1,
	tagName: "a",
	target: null,
	rel: null,
	validate: !0,
	truncate: Infinity,
	className: null,
	attributes: null,
	ignoreTags: [],
	render: null
};
function $e(e, t = null) {
	let n = Object.assign({}, X);
	e && (n = Object.assign(n, e instanceof $e ? e.o : e));
	let r = n.ignoreTags, i = [];
	for (let e = 0; e < r.length; e++) i.push(r[e].toUpperCase());
	this.o = n, t && (this.defaultRender = t), this.ignoreTags = i;
}
$e.prototype = {
	o: X,
	ignoreTags: [],
	defaultRender(e) {
		return e;
	},
	check(e) {
		return this.get("validate", e.toString(), e);
	},
	get(e, t, n) {
		let r = t != null, i = this.o[e];
		return i && (typeof i == "object" ? (i = n.t in i ? i[n.t] : X[e], typeof i == "function" && r && (i = i(t, n))) : typeof i == "function" && r && (i = i(t, n.t, n)), i);
	},
	getObj(e, t, n) {
		let r = this.o[e];
		return typeof r == "function" && t != null && (r = r(t, n.t, n)), r;
	},
	render(e) {
		let t = e.render(this);
		return (this.get("render", null, e) || this.defaultRender)(t, e.t, e);
	}
};
function et(e) {
	return e;
}
function tt(e, t) {
	this.t = "token", this.v = e, this.tk = t;
}
tt.prototype = {
	isLink: !1,
	toString() {
		return this.v;
	},
	toHref(e) {
		return this.toString();
	},
	toFormattedString(e) {
		let t = this.toString(), n = e.get("truncate", t, this), r = e.get("format", t, this);
		return n && r.length > n ? r.substring(0, n) + "…" : r;
	},
	toFormattedHref(e) {
		return e.get("formatHref", this.toHref(e.get("defaultProtocol")), this);
	},
	startIndex() {
		return this.tk[0].s;
	},
	endIndex() {
		return this.tk[this.tk.length - 1].e;
	},
	toObject(e = X.defaultProtocol) {
		return {
			type: this.t,
			value: this.toString(),
			isLink: this.isLink,
			href: this.toHref(e),
			start: this.startIndex(),
			end: this.endIndex()
		};
	},
	toFormattedObject(e) {
		return {
			type: this.t,
			value: this.toFormattedString(e),
			isLink: this.isLink,
			href: this.toFormattedHref(e),
			start: this.startIndex(),
			end: this.endIndex()
		};
	},
	validate(e) {
		return e.get("validate", this.toString(), this);
	},
	render(e) {
		let t = this, n = this.toHref(e.get("defaultProtocol")), r = e.get("formatHref", n, this), i = e.get("tagName", n, t), a = this.toFormattedString(e), o = {}, s = e.get("className", n, t), c = e.get("target", n, t), l = e.get("rel", n, t), u = e.getObj("attributes", n, t), d = e.getObj("events", n, t);
		return o.href = r, s && (o.class = s), c && (o.target = c), l && (o.rel = l), u && Object.assign(o, u), {
			tagName: i,
			attributes: o,
			content: a,
			eventListeners: d
		};
	}
};
function nt(e, t) {
	class n extends tt {
		constructor(t, n) {
			super(t, n), this.t = e;
		}
	}
	for (let e in t) n.prototype[e] = t[e];
	return n.t = e, n;
}
var rt = nt("email", {
	isLink: !0,
	toHref() {
		return "mailto:" + this.toString();
	}
}), it = nt("text"), at = nt("nl"), ot = nt("url", {
	isLink: !0,
	toHref(e = X.defaultProtocol) {
		return this.hasProtocol() ? this.v : `${e}://${this.v}`;
	},
	hasProtocol() {
		let e = this.tk;
		return e.length >= 2 && e[0].t !== O && e[1].t === R;
	}
}), Z = (e) => new C(e);
function st({ groups: e }) {
	let t = e.domain.concat([
		xe,
		Ce,
		L,
		we,
		Te,
		Ee,
		Oe,
		ke,
		B,
		le,
		V,
		je,
		Me,
		Ne,
		U,
		ze,
		W,
		Le
	]), n = [
		Se,
		R,
		De,
		z,
		Ae,
		V,
		H,
		Pe,
		Ie,
		he,
		ge,
		A,
		j,
		fe,
		M,
		pe,
		me,
		_e,
		N,
		P,
		F,
		I,
		ve,
		ye,
		be
	], r = [
		xe,
		Se,
		Ce,
		we,
		Te,
		Ee,
		Oe,
		ke,
		B,
		A,
		j,
		V,
		je,
		Me,
		Ne,
		H,
		U,
		ze,
		W,
		Le
	], i = Z(), a = E(i, W);
	w(a, r, a), w(a, e.domain, a);
	let o = Z(), s = Z(), c = Z();
	w(i, e.domain, o), w(i, e.scheme, s), w(i, e.slashscheme, c), w(o, r, a), w(o, e.domain, o);
	let l = E(o, L);
	E(a, L, l), E(s, L, l), E(c, L, l);
	let u = E(a, z);
	w(u, r, a), w(u, e.domain, a);
	let d = Z();
	w(l, e.domain, d), w(d, e.domain, d);
	let f = E(d, z);
	w(f, e.domain, d);
	let p = Z(rt);
	w(f, e.tld, p), w(f, e.utld, p), E(l, O, p);
	let m = E(d, B);
	E(m, B, m), w(m, e.domain, d), w(p, e.domain, d), E(p, z, f), E(p, B, m);
	let h = E(o, B), g = E(o, z);
	E(h, B, h), w(h, e.domain, o), w(g, r, a), w(g, e.domain, o);
	let _ = Z(ot);
	w(g, e.tld, _), w(g, e.utld, _), w(_, e.domain, o), w(_, r, a), E(_, z, g), E(_, B, h), E(_, L, l);
	let ee = E(_, R), te = Z(ot);
	w(ee, e.numeric, te);
	let v = Z(ot), y = Z();
	w(v, t, v), w(v, n, y), w(y, t, v), w(y, n, y), E(_, U, v), E(te, U, v);
	let b = E(s, R), x = E(E(E(c, R), U), U);
	w(s, e.domain, o), E(s, z, g), E(s, B, h), w(c, e.domain, o), E(c, z, g), E(c, B, h), w(b, e.domain, v), E(b, U, v), E(b, H, v), w(x, e.domain, v), w(x, t, v), E(x, U, v);
	let S = [
		[A, j],
		[M, fe],
		[pe, me],
		[he, ge],
		[_e, N],
		[P, F],
		[I, ve],
		[ye, be]
	];
	for (let e = 0; e < S.length; e++) {
		let [r, i] = S[e], a = E(v, r);
		E(y, r, a);
		let o = Z(ot);
		w(a, t, o);
		let s = Z();
		w(a, n, s), E(a, i, v), w(o, t, o), w(o, n, s), w(s, t, o), w(s, n, s), E(o, i, v), E(s, i, v);
	}
	return E(i, O, _), E(i, de, at), {
		start: i,
		tokens: Be
	};
}
function ct(e, t, n) {
	let r = n.length, i = 0, a = [], o = [];
	for (; i < r;) {
		let s = e, c = null, l = null, u = 0, d = null, f = -1;
		for (; i < r && !(c = s.go(n[i].t));) o.push(n[i++]);
		for (; i < r && (l = c || s.go(n[i].t));) c = null, s = l, s.accepts() ? (f = 0, d = s) : f >= 0 && f++, i++, u++;
		if (f < 0) i -= u, i < r && (o.push(n[i]), i++);
		else {
			o.length > 0 && (a.push(lt(it, t, o)), o = []), i -= f, u -= f;
			let e = d.t, r = n.slice(i - u, i);
			a.push(lt(e, t, r));
		}
	}
	return o.length > 0 && a.push(lt(it, t, o)), a;
}
function lt(e, t, n) {
	let r = n[0].s, i = n[n.length - 1].e;
	return new e(t.slice(r, i), n);
}
var ut = typeof console < "u" && console && console.warn || (() => {}), dt = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.", Q = {
	scanner: null,
	parser: null,
	tokenQueue: [],
	pluginQueue: [],
	customSchemes: [],
	initialized: !1
};
function ft() {
	return C.groups = {}, Q.scanner = null, Q.parser = null, Q.tokenQueue = [], Q.pluginQueue = [], Q.customSchemes = [], Q.initialized = !1, Q;
}
function pt(e, t = !1) {
	if (Q.initialized && ut(`linkifyjs: already initialized - will not register custom scheme "${e}" ${dt}`), !/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e)) throw Error("linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or \"-\"\n2. Cannot start or end with \"-\"\n3. \"-\" cannot repeat");
	Q.customSchemes.push([e, t]);
}
function mt() {
	Q.scanner = J(Q.customSchemes);
	for (let e = 0; e < Q.tokenQueue.length; e++) Q.tokenQueue[e][1]({ scanner: Q.scanner });
	Q.parser = st(Q.scanner.tokens);
	for (let e = 0; e < Q.pluginQueue.length; e++) Q.pluginQueue[e][1]({
		scanner: Q.scanner,
		parser: Q.parser
	});
	return Q.initialized = !0, Q;
}
function ht(e) {
	return Q.initialized || mt(), ct(Q.parser.start, e, Xe(Q.scanner.start, e));
}
ht.scan = Xe;
function gt(e, t = null, n = null) {
	if (t && typeof t == "object") {
		if (n) throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);
		n = t, t = null;
	}
	let r = new $e(n), i = ht(e), a = [];
	for (let e = 0; e < i.length; e++) {
		let n = i[e];
		n.isLink && (!t || n.t === t) && r.check(n) && a.push(n.toFormattedObject(r));
	}
	return a;
}
//#endregion
//#region ../../node_modules/.pnpm/@tiptap+extension-link@3.23.4_@tiptap+core@3.23.4_@tiptap+pm@3.23.4__@tiptap+pm@3.23.4/node_modules/@tiptap/extension-link/dist/index.js
var _t = "[\0- \xA0 ᠎ -\u2029 　]", vt = new RegExp(_t), yt = RegExp(`${_t}$`), bt = new RegExp(_t, "g");
function xt(e) {
	return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
}
function St(e) {
	return new l({
		key: new n("autolink"),
		appendTransaction: (n, r, o) => {
			let c = n.some((e) => e.docChanged) && !r.doc.eq(o.doc), l = n.some((e) => e.getMeta("preventAutolink"));
			if (!c || l) return;
			let { tr: u } = o;
			if (i(a(r.doc, [...n])).forEach(({ newRange: n }) => {
				let r = t(o.doc, n, (e) => e.isTextblock), i, a;
				if (r.length > 1) i = r[0], a = o.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
				else if (r.length) {
					let e = o.doc.textBetween(n.from, n.to, " ", " ");
					if (!yt.test(e)) return;
					i = r[0], a = o.doc.textBetween(i.pos, n.to, void 0, " ");
				}
				if (i && a) {
					let t = a.split(vt).filter(Boolean);
					if (t.length <= 0) return !1;
					let n = t[t.length - 1], r = i.pos + a.lastIndexOf(n);
					if (!n) return !1;
					let c = ht(n).map((t) => t.toObject(e.defaultProtocol));
					if (!xt(c)) return !1;
					c.filter((e) => e.isLink).map((e) => ({
						...e,
						from: r + e.start + 1,
						to: r + e.end + 1
					})).filter((e) => o.schema.marks.code ? !o.doc.rangeHasMark(e.from, e.to, o.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
						s(t.from, t.to, o.doc).some((t) => t.mark.type === e.type) || u.addMark(t.from, t.to, e.type.create({ href: t.href }));
					});
				}
			}), u.steps.length) return u;
		}
	});
}
function Ct(e) {
	return new l({
		key: new n("handleClickLink"),
		props: { handleClick: (t, n, r) => {
			if (r.button !== 0 || !t.editable) return !1;
			let i = null;
			if (r.target instanceof HTMLAnchorElement) i = r.target;
			else {
				let t = r.target;
				if (!t) return !1;
				let n = e.editor.view.dom;
				i = t.closest("a"), i && !n.contains(i) && (i = null);
			}
			if (!i) return !1;
			let a = !1;
			if (e.enableClickSelection && (a = e.editor.commands.extendMarkRange(e.type.name)), e.openOnClick) {
				let n = c(t.state, e.type.name), r = i.href ?? n.href, o = i.target ?? n.target;
				r && (window.open(r, o), a = !0);
			}
			return a;
		} }
	});
}
function wt(e) {
	return new l({
		key: new n("handlePasteLink"),
		props: { handlePaste: (t, n, r) => {
			let { shouldAutoLink: i } = e, { state: a } = t, { selection: o } = a, { empty: s } = o;
			if (s) return !1;
			let c = "";
			r.content.forEach((e) => {
				c += e.textContent;
			});
			let l = gt(c, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === c);
			return !c || !l || i !== void 0 && !i(l.value) ? !1 : e.editor.commands.setMark(e.type, { href: l.href });
		} }
	});
}
var Tt = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi;
function $(e, t) {
	let n = [
		"http",
		"https",
		"ftp",
		"ftps",
		"mailto",
		"tel",
		"callto",
		"sms",
		"cid",
		"xmpp"
	];
	return t && t.forEach((e) => {
		let t = typeof e == "string" ? e : e.scheme;
		t && n.push(t);
	}), !e || e.replace(bt, "").match(RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`, "i"));
}
var Et = o.create({
	name: "link",
	priority: 1e3,
	keepOnSplit: !1,
	exitable: !0,
	onCreate() {
		this.options.validate && !this.options.shouldAutoLink && (this.options.shouldAutoLink = this.options.validate, console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")), this.options.protocols.forEach((e) => {
			if (typeof e == "string") {
				pt(e);
				return;
			}
			pt(e.scheme, e.optionalSlashes);
		});
	},
	onDestroy() {
		ft();
	},
	inclusive() {
		return this.options.autolink;
	},
	addOptions() {
		return {
			openOnClick: !0,
			enableClickSelection: !1,
			linkOnPaste: !0,
			autolink: !0,
			protocols: [],
			defaultProtocol: "http",
			HTMLAttributes: {
				target: "_blank",
				rel: "noopener noreferrer nofollow",
				class: null
			},
			isAllowedUri: (e, t) => !!$(e, t.protocols),
			validate: (e) => !!e,
			shouldAutoLink: (e) => {
				let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
				if (t || n && !e.includes("@")) return !0;
				let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
				return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
			}
		};
	},
	addAttributes() {
		return {
			href: {
				default: null,
				parseHTML(e) {
					return e.getAttribute("href");
				}
			},
			target: { default: this.options.HTMLAttributes.target },
			rel: { default: this.options.HTMLAttributes.rel },
			class: { default: this.options.HTMLAttributes.class },
			title: { default: null }
		};
	},
	parseHTML() {
		return [{
			tag: "a[href]",
			getAttrs: (e) => {
				let t = e.getAttribute("href");
				return !t || !this.options.isAllowedUri(t, {
					defaultValidate: (e) => !!$(e, this.options.protocols),
					protocols: this.options.protocols,
					defaultProtocol: this.options.defaultProtocol
				}) ? !1 : null;
			}
		}];
	},
	renderHTML({ HTMLAttributes: t }) {
		return this.options.isAllowedUri(t.href, {
			defaultValidate: (e) => !!$(e, this.options.protocols),
			protocols: this.options.protocols,
			defaultProtocol: this.options.defaultProtocol
		}) ? [
			"a",
			e(this.options.HTMLAttributes, t),
			0
		] : [
			"a",
			e(this.options.HTMLAttributes, {
				...t,
				href: ""
			}),
			0
		];
	},
	markdownTokenName: "link",
	parseMarkdown: (e, t) => t.applyMark("link", t.parseInline(e.tokens || []), {
		href: e.href,
		title: e.title || null
	}),
	renderMarkdown: (e, t) => {
		let n = e.attrs?.href ?? "", r = e.attrs?.title ?? "", i = t.renderChildren(e);
		return r ? `[${i}](${n} "${r}")` : `[${i}](${n})`;
	},
	addCommands() {
		return {
			setLink: (e) => ({ chain: t }) => {
				let { href: n } = e;
				return this.options.isAllowedUri(n, {
					defaultValidate: (e) => !!$(e, this.options.protocols),
					protocols: this.options.protocols,
					defaultProtocol: this.options.defaultProtocol
				}) ? t().setMark(this.name, e).setMeta("preventAutolink", !0).run() : !1;
			},
			toggleLink: (e) => ({ chain: t }) => {
				let { href: n } = e || {};
				return n && !this.options.isAllowedUri(n, {
					defaultValidate: (e) => !!$(e, this.options.protocols),
					protocols: this.options.protocols,
					defaultProtocol: this.options.defaultProtocol
				}) ? !1 : t().toggleMark(this.name, e, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run();
			},
			unsetLink: () => ({ chain: e }) => e().unsetMark(this.name, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run()
		};
	},
	addPasteRules() {
		return [r({
			find: (e) => {
				let t = [];
				if (e) {
					let { protocols: n, defaultProtocol: r } = this.options, i = gt(e).filter((e) => e.isLink && this.options.isAllowedUri(e.value, {
						defaultValidate: (e) => !!$(e, n),
						protocols: n,
						defaultProtocol: r
					}));
					i.length && i.forEach((e) => {
						this.options.shouldAutoLink(e.value) && t.push({
							text: e.value,
							data: { href: e.href },
							index: e.start
						});
					});
				}
				return t;
			},
			type: this.type,
			getAttributes: (e) => ({ href: e.data?.href })
		})];
	},
	addProseMirrorPlugins() {
		let e = [], { protocols: t, defaultProtocol: n } = this.options;
		return this.options.autolink && e.push(St({
			type: this.type,
			defaultProtocol: this.options.defaultProtocol,
			validate: (e) => this.options.isAllowedUri(e, {
				defaultValidate: (e) => !!$(e, t),
				protocols: t,
				defaultProtocol: n
			}),
			shouldAutoLink: this.options.shouldAutoLink
		})), e.push(Ct({
			type: this.type,
			editor: this.editor,
			openOnClick: this.options.openOnClick === "whenNotEditable" ? !0 : this.options.openOnClick,
			enableClickSelection: this.options.enableClickSelection
		})), this.options.linkOnPaste && e.push(wt({
			editor: this.editor,
			defaultProtocol: this.options.defaultProtocol,
			type: this.type,
			shouldAutoLink: this.options.shouldAutoLink
		})), e;
	}
}), Dt = Et;
//#endregion
export { Et as Link, Dt as default, $ as isAllowedUri, Tt as pasteRegex };
