import { L as e, Y as t, h as n, r, t as i } from "./parser-9pXf3QZR.js";
//#region src/components-core/parts.ts
var a = "label", o = "labeledItem", s = "input", c = "startAdornment", l = "endAdornment", u = "icon", d = "conciseValidationFeedback", f = "clearButton", p = "month", m = "year", h = "avatar", g = "title", _ = "subtitle", v = "header", y = "content", b = "hamburger", x = "listWrapper", S = "footer", C = "spinnerUp", w = "spinnerDown", T = "pagination-controls", E = "page-info", D = "page-size-selector-container", O = "overflow", k = "ring", A = "primaryPanel", j = "secondaryPanel", M = "hsl(356, 100%, 91%)", N = "hsl(356, 100%, 70%)", P = "hsl(204, 30.3%, 13%)", F = "#555b5e", I = "0.5rem";
function L(t, a = 0, o) {
	let { parse: s, getText: c } = i(t), { node: l, errors: u } = s(), d = new r(t);
	if (u.length > 0) return {
		component: null,
		errors: u.map((e) => q(e, d, t)),
		erroneousCompoundComponentName: K(l, c),
		warnings: []
	};
	try {
		let e = [];
		return {
			component: n(l, c, a, o, e, d),
			errors: [],
			warnings: e
		};
	} catch (n) {
		let r = K(l, c);
		if (n instanceof e) {
			let e;
			if (n.pos && n.end) {
				let { contextPos: r, contextEnd: i } = d.getSurroundingContext(n.pos, n.end, 1);
				e = q({
					message: n.message,
					code: n.code,
					pos: n.pos,
					end: n.end,
					contextPos: r,
					contextEnd: i
				}, d, t);
			} else e = {
				message: n.message,
				code: n.code,
				pos: 0,
				end: 0,
				contextPos: 0,
				contextEnd: 0,
				contextSource: "",
				contextStartLine: 0,
				errPosCol: 0,
				errPosLine: 0
			};
			return {
				component: null,
				erroneousCompoundComponentName: r,
				errors: [e],
				warnings: []
			};
		} else throw n;
	}
}
function R(e) {
	return {
		type: "VStack",
		props: {
			padding: "$padding-normal",
			gap: 0
		},
		children: [{
			type: "H1",
			props: {
				value: e,
				padding: "$padding-normal",
				backgroundColor: "$color-error",
				color: "white"
			}
		}]
	};
}
function z(e) {
	let t = R(e);
	return t.component = R(e), t;
}
function B(e, t) {
	let n = e.sort((e, t) => e.pos === void 0 && t.pos === void 0 ? 0 : e.pos === void 0 ? 1 : t.pos === void 0 ? -1 : e.pos - t.pos).map((e, n) => {
		let r = e.pos - e.contextPos, i = e.end - e.contextPos, a = e.contextSource.split("\n"), o = 0, s = (e.contextStartLine + a.length - 1).toString().length, c = [];
		for (let t = 0; t < a.length; t++) {
			let n = a[t], l = `${(e.contextStartLine + t).toString().padStart(s, "0")} | `, u = o, d = o + n.length, f = [{
				type: "Theme",
				props: {},
				children: [{
					type: "Text",
					props: {
						value: l,
						fontFamily: "monospace",
						color: F
					}
				}]
			}];
			if (r >= u && r < d) {
				let e = n.substring(0, r - u), t = n.substring(r - u, Math.min(i - u, n.length)), a = n.substring(Math.min(i - u, n.length));
				e && f.push({
					type: "Text",
					props: {
						value: e,
						fontFamily: "monospace"
					}
				}), t && f.push({
					type: "Text",
					props: {
						value: t,
						fontFamily: "monospace",
						textDecorationLine: "underline",
						textDecorationColor: "$color-error",
						backgroundColor: M
					}
				}), a && f.push({
					type: "Text",
					props: {
						value: a,
						fontFamily: "monospace"
					}
				});
			} else if (r < u && i > d) f.push({
				type: "Text",
				props: {
					value: n,
					fontFamily: "monospace",
					textDecorationLine: "underline",
					textDecorationColor: "$color-error",
					backgroundColor: M
				}
			});
			else if (r < u && i >= u && i < d) {
				let e = n.substring(0, i - u), t = n.substring(i - u);
				e && f.push({
					type: "Text",
					props: {
						value: e,
						fontFamily: "monospace",
						textDecorationLine: "underline",
						textDecorationColor: "$color-error",
						backgroundColor: M
					}
				}), t && f.push({
					type: "Text",
					props: {
						value: t,
						fontFamily: "monospace"
					}
				});
			} else d === r && r === i ? (f.push({
				type: "Text",
				props: {
					value: n,
					fontFamily: "monospace"
				}
			}), f.push({
				type: "Text",
				props: {
					value: " ",
					preserveLinebreaks: !0,
					textDecorationLine: "underline",
					fontFamily: "monospace",
					fontWeight: "bold",
					backgroundColor: M,
					color: "$color-error"
				}
			})) : f.push({
				type: "Text",
				props: {
					value: n,
					fontFamily: "monospace"
				}
			});
			c.push({
				type: "HStack",
				props: { gap: "0" },
				children: f
			}), o = d + 1;
		}
		let l = {
			type: "Text",
			children: [{
				type: "Text",
				props: { value: `#${n + 1}: ${t} (${e.errPosLine}:${e.errPosCol}):` }
			}, {
				type: "Text",
				props: {
					value: ` ${e.message}`,
					fontWeight: "bold"
				}
			}]
		}, u = {
			type: "HStack",
			props: { width: "100%" },
			children: [{
				type: "VStack",
				props: {
					gap: "0",
					padding: "$padding-normal",
					backgroundColor: "$color-surface-variant"
				},
				children: c
			}]
		}, d = {
			type: "VStack",
			props: {
				gap: "$gap-none",
				padding: "16px",
				backgroundColor: "white",
				borderRadius: I
			},
			children: [l]
		};
		return e.contextSource === "" && e.pos === 0 && e.end === 0 || d.children.push(u), d;
	});
	return {
		type: "Theme",
		props: { "textColor-primary": P },
		children: [{
			type: "VStack",
			props: {
				padding: "16px 32px 16px 38px",
				gap: 0,
				backgroundColor: M,
				margin: "10px",
				border: "2px solid " + N,
				borderRadius: I
			},
			children: [{
				type: "HStack",
				props: {
					verticalAlignment: "center",
					marginLeft: "-34px",
					padding: "0px 0px 15px 0px",
					gap: "4px"
				},
				children: [{
					type: "Icon",
					props: {
						name: "error",
						size: "30px",
						color: "$color-error"
					}
				}, {
					type: "H2",
					props: {
						value: `${n.length} ${n.length > 1 ? "errors" : "error"} while processing XMLUI markup`,
						fontWeight: "bold",
						showAnchor: !1
					}
				}]
			}, {
				type: "VStack",
				props: {
					padding: "$padding-none",
					gap: "16px"
				},
				children: n
			}]
		}]
	};
}
function V(e, t, n) {
	let r = B(e, t);
	return r.name = n, r.component = B(e, t), r;
}
function H(e, t) {
	return {
		type: "VStack",
		props: {
			padding: "$padding-normal",
			gap: 0
		},
		children: [{
			type: "H1",
			props: {
				value: "An error found while processing XMLUI code-behind script",
				padding: "$padding-normal",
				backgroundColor: "$color-error",
				color: "white"
			}
		}, {
			type: "VStack",
			props: {
				gap: "$gap-tight",
				padding: "$padding-normal"
			},
			children: [{
				type: "HStack",
				props: { gap: "0" },
				children: [{
					type: "Text",
					props: {
						value: `${t} (${e.line}:${e.column}):\xa0`,
						color: "$color-info"
					}
				}, {
					type: "Text",
					props: {
						value: ` ${e.text}`,
						fontWeight: "bold"
					}
				}]
			}]
		}]
	};
}
function U(e, t) {
	let n = H(e, t);
	return n.component = H(e, t), n;
}
function W(e, t) {
	let n = [], r = 1;
	return Object.keys(e).map((i) => {
		let a = e[i];
		for (let e of a) n.push({
			type: "VStack",
			props: { gap: "0px" },
			children: [{
				type: "HStack",
				props: { gap: "0" },
				children: [{
					type: "Text",
					props: {
						value: `#${r++}: ${t} (${e.line}:${e.column}):\xa0`,
						color: "$color-info"
					}
				}, {
					type: "Text",
					props: {
						value: ` ${e.text}`,
						fontWeight: "bold"
					}
				}]
			}]
		});
	}), {
		type: "VStack",
		props: {
			padding: "$padding-normal",
			gap: 0
		},
		children: [{
			type: "H1",
			props: {
				value: `${n.length} ${n.length > 1 ? "Errors" : "Error"} found while processing XMLUI code-behind script`,
				padding: "$padding-normal",
				backgroundColor: "$color-error",
				color: "white"
			}
		}, {
			type: "VStack",
			props: {
				gap: "$gap-tight",
				padding: "$padding-normal"
			},
			children: n
		}]
	};
}
function G(e, t) {
	let n = W(e, t);
	return n.component = W(e, t), n;
}
function K(e, n) {
	let r = e?.children?.[0], i = r?.children?.find((e) => e.kind === t.TagNameNode)?.children, a = i?.[i.length - 1];
	if (a === void 0 || n(a) !== "Component") return;
	let o = (r.children?.find((e) => e.kind === t.AttributeListNode)?.children)?.find((e) => e.kind === t.AttributeNode && n(e?.children[0]) === "name")?.children, s = o?.[o.length - 1];
	if (s !== void 0 && s.kind === t.StringLiteral) {
		let e = n(s);
		return e.substring(1, e.length - 1);
	}
}
function q(e, t, n) {
	let { line: r, character: i } = t.offsetToDisplayPos(e.pos), { line: a } = t.offsetToDisplayPos(e.contextPos);
	return {
		...e,
		errPosLine: r,
		errPosCol: i,
		contextStartLine: a,
		contextSource: n.substring(e.contextPos, e.contextEnd)
	};
}
//#endregion
export { _ as A, T as C, w as D, j as E, m as M, C as O, D as S, k as T, x as _, L as a, O as b, d as c, b as d, v as f, o as g, a as h, U as i, g as j, c as k, y as l, s as m, z as n, h as o, u as p, G as r, f as s, V as t, l as u, p as v, A as w, E as x, S as y };

//# sourceMappingURL=xmlui-parser-feKTBlgv.js.map