import { E as e, J as t, X as n, Z as r, a as i, i as a, r as o, s, t as c } from "./Parser-UQbHWtve.js";
//#region src/components/abstractions.ts
var l = [
	{
		value: "_self",
		description: "The link will open in the same frame as it was clicked."
	},
	{
		value: "_blank",
		description: "The link will open in a new window or tab."
	},
	{
		value: "_parent",
		description: "The link will open in the parent frame. If no parent, behaves as _self."
	},
	{
		value: "_top",
		description: "The topmost browsing context. The link will open in the full body of the window. If no ancestors, behaves as _self."
	},
	{
		value: "_unfencedTop",
		description: "Allows embedded fenced frames to navigate the top-level frame, i.e. traversing beyond the root of the fenced frame."
	}
], u = [
	{
		value: "xs",
		description: "Extra small devices (e.g., a small smartphone with low screen resolution)"
	},
	{
		value: "sm",
		description: "Small devices (e.g., a smartphone in landscape view)"
	},
	{
		value: "md",
		description: "Medium devices (e.g., a tablet)"
	},
	{
		value: "lg",
		description: "Large devices (e.g., a laptop)"
	},
	{
		value: "xl",
		description: "Extra large devices (e.g., a standard 20\" monitor)"
	},
	{
		value: "xxl",
		description: "Extra extra large devices (e.g., a large 29\" monitor)"
	}
], d = [
	"xs",
	"sm",
	"md",
	"lg",
	"xl"
], f = [
	{
		value: "xs",
		description: "Extra small"
	},
	{
		value: "sm",
		description: "Small"
	},
	{
		value: "md",
		description: "Medium"
	},
	{
		value: "lg",
		description: "Large"
	},
	{
		value: "xl",
		description: "Extra large"
	}
];
function p(e) {
	return d.includes(e);
}
var m = [...[
	"attention",
	"primary",
	"secondary"
]], h = [
	{
		value: "attention",
		description: "Attention state theme color"
	},
	{
		value: "primary",
		description: "Primary theme color"
	},
	{
		value: "secondary",
		description: "Secondary theme color"
	}
], g = [
	{
		value: "button",
		description: "Regular behavior that only executes logic if explicitly determined."
	},
	{
		value: "submit",
		description: "The button submits the form data to the server. This is the default for buttons in a Form or NativeForm component."
	},
	{
		value: "reset",
		description: "Resets all the controls to their initial values. Using it is ill advised for UX reasons."
	}
], _ = [
	"solid",
	"outlined",
	"ghost"
], v = [..._], y = [
	{
		value: "solid",
		description: "A button with a border and a filled background."
	},
	{
		value: "outlined",
		description: "The button is displayed with a border and a transparent background."
	},
	{
		value: "ghost",
		description: "A button with no border and fill. Only the label is visible; the background is colored when hovered or clicked."
	}
], b = [
	"start",
	"center",
	"end"
];
[...b];
var x = [
	{
		value: "center",
		description: "Place the content in the middle"
	},
	{
		value: "start",
		description: "Justify the content to the left (to the right if in right-to-left)"
	},
	{
		value: "end",
		description: "Justify the content to the right (to the left if in right-to-left)"
	}
], S = ["horizontal", "vertical"], C = [{
	value: "horizontal",
	description: "The component will fill the available space horizontally"
}, {
	value: "vertical",
	description: "The component will fill the available space vertically"
}], w = [...["start", "end"]], T = [{
	value: "start",
	description: "The icon will appear at the start (left side when the left-to-right direction is set)"
}, {
	value: "end",
	description: "The icon will appear at the end (right side when the left-to-right direction is set)"
}], E = [
	{
		value: "markRequired",
		description: "Show \"*\" for required fields"
	},
	{
		value: "markOptional",
		description: "Show \"(Optional)\" for optional fields"
	},
	{
		value: "markBoth",
		description: "Show \"*\" for required AND \"(Optional)\" for optional fields"
	}
], D = [
	{
		value: "start",
		description: "The left side of the input (left-to-right) or the right side of the input (right-to-left)"
	},
	{
		value: "end",
		description: "The right side of the input (left-to-right) or the left side of the input (right-to-left)"
	},
	{
		value: "top",
		description: "The top of the input"
	},
	{
		value: "bottom",
		description: "The bottom of the input"
	},
	{
		value: "before",
		description: "The label is placed directly before the input with fit-content width. Similar to 'start' but the label does not stretch."
	},
	{
		value: "after",
		description: "The label is placed directly after the input with fit-content width. Similar to 'end' but the label does not stretch."
	}
], O = [...["start", "end"]], k = [
	{
		value: "valid",
		description: "Visual indicator for an input that is accepted"
	},
	{
		value: "warning",
		description: "Visual indicator for an input that produced a warning"
	},
	{
		value: "error",
		description: "Visual indicator for an input that produced an error"
	}
], A = ["top", "bottom"];
[...A];
var j = {
	abbr: "abbr",
	cite: "cite",
	code: "code",
	deleted: "del",
	inherit: "span",
	inserted: "ins",
	keyboard: "kbd",
	marked: "mark",
	sample: "samp",
	sub: "sub",
	sup: "sup",
	var: "var",
	mono: "pre",
	strong: "strong",
	em: "em",
	title: "span",
	subtitle: "span",
	small: "span",
	caption: "span",
	placeholder: "span",
	paragraph: "p",
	subheading: "h6",
	tableheading: "h6",
	secondary: "span"
}, M = [
	{
		value: "abbr",
		description: "Represents an abbreviation or acronym"
	},
	{
		value: "caption",
		description: "Represents the caption (or title) of a table"
	},
	{
		value: "cite",
		description: "Is used to mark up the title of a cited work"
	},
	{
		value: "code",
		description: "Represents a line of code"
	},
	{
		value: "deleted",
		description: "Represents text that has been deleted"
	},
	{
		value: "em",
		description: "Marks text to stress emphasis"
	},
	{
		value: "inherit",
		description: "Represents text that inherits the style from its parent element"
	},
	{
		value: "inserted",
		description: "Represents a range of text that has been added to a document"
	},
	{
		value: "keyboard",
		description: "Represents a span of text denoting textual user input from a keyboard or voice input"
	},
	{
		value: "marked",
		description: "Represents text which is marked or highlighted for reference or notation"
	},
	{
		value: "mono",
		description: "Text using a mono style font family"
	},
	{
		value: "paragraph",
		description: "Represents a paragraph"
	},
	{
		value: "placeholder",
		description: "Text that is mostly used as the placeholder style in input controls"
	},
	{
		value: "sample",
		description: "Represents sample (or quoted) output from a computer program"
	},
	{
		value: "secondary",
		description: "Represents a bit dimmed secondary text"
	},
	{
		value: "small",
		description: "Represents side-comments and small print"
	},
	{
		value: "sub",
		description: "Specifies inline text as subscript"
	},
	{
		value: "strong",
		description: "Contents have strong importance"
	},
	{
		value: "subheading",
		description: "Indicates that the text is the subtitle in a heading"
	},
	{
		value: "subtitle",
		description: "Indicates that the text is the subtitle of some other content"
	},
	{
		value: "sup",
		description: "Specifies inline text as superscript"
	},
	{
		value: "tableheading",
		description: "Indicates that the text is a table heading"
	},
	{
		value: "title",
		description: "Indicates that the text is the title of some other content"
	},
	{
		value: "var",
		description: "Represents the name of a variable in a mathematical expression"
	}
], ee = ["title"], te = ["cite", "dateTime"], ne = [...ee, ...te], re = [
	"get",
	"post",
	"put",
	"delete",
	"patch",
	"head",
	"options",
	"trace",
	"connect"
], ie = /* @__PURE__ */ "horizontalAlignment.verticalAlignment.orientation.width.minWidth.maxWidth.height.minHeight.maxHeight.gap.border.borderTop.borderRight.borderBottom.borderLeft.borderColor.borderStyle.borderWidth.borderHorizontal.borderVertical.borderRadius.radiusTopLeft.radiusTopRight.radiusBottomLeft.radiusBottomRight.padding.paddingHorizontal.paddingVertical.paddingTop.paddingRight.paddingBottom.paddingLeft.backgroundColor.background.boxShadow.direction.overflowX.overflowY.zIndex.scrollSnapType.scrollSnapAlign.scrollSnapStop.scrollPadding.scrollPaddingTop.scrollPaddingRight.scrollPaddingBottom.scrollPaddingLeft.scrollMargin.scrollMarginTop.scrollMarginRight.scrollMarginBottom.scrollMarginLeft.color.fontFamily.fontSize.fontWeight.fontStyle.textDecoration.wrapContent.canShrink.margin.marginHorizontal.marginVertical.marginTop.marginRight.marginBottom.marginLeft.userSelect.letterSpacing.textTransform.lineHeight.opacity.cursor.textWrap.textAlign.textAlignLast.top.right.bottom.left.zoom.whiteSpace.textDecoration.textDecorationLine.textDecorationColor.textDecorationStyle.textDecorationThickness.textUnderlineOffset.outline.outlineWidth.outlineColor.outlineStyle.outlineOffset.fontVariant.lineBreak.textIndent.textShadow.wordBreak.wordSpacing.wordWrap.writingMode.transition.transform".split("."), N = [
	"xs",
	"sm",
	"md",
	"lg",
	"xl",
	"xxl"
], P = /* @__PURE__ */ function(e) {
	return e[e.Unknown = 0] = "Unknown", e[e.EndOfFileToken = 1] = "EndOfFileToken", e[e.CommentTrivia = 2] = "CommentTrivia", e[e.NewLineTrivia = 3] = "NewLineTrivia", e[e.WhitespaceTrivia = 4] = "WhitespaceTrivia", e[e.Identifier = 5] = "Identifier", e[e.OpenNodeStart = 6] = "OpenNodeStart", e[e.CloseNodeStart = 7] = "CloseNodeStart", e[e.NodeEnd = 8] = "NodeEnd", e[e.NodeClose = 9] = "NodeClose", e[e.Colon = 10] = "Colon", e[e.Equal = 11] = "Equal", e[e.StringLiteral = 12] = "StringLiteral", e[e.CData = 13] = "CData", e[e.Script = 14] = "Script", e[e.TextNode = 15] = "TextNode", e[e.AmpersandEntity = 16] = "AmpersandEntity", e[e.LessThanEntity = 17] = "LessThanEntity", e[e.GreaterThanEntity = 18] = "GreaterThanEntity", e[e.SingleQuoteEntity = 19] = "SingleQuoteEntity", e[e.DoubleQuoteEntity = 20] = "DoubleQuoteEntity", e[e.ElementNode = 21] = "ElementNode", e[e.AttributeNode = 22] = "AttributeNode", e[e.AttributeKeyNode = 23] = "AttributeKeyNode", e[e.ContentListNode = 24] = "ContentListNode", e[e.AttributeListNode = 25] = "AttributeListNode", e[e.TagNameNode = 26] = "TagNameNode", e[e.ErrorNode = 27] = "ErrorNode", e;
}({});
function ae(e) {
	return e >= P.CommentTrivia && e <= P.WhitespaceTrivia;
}
function oe(e) {
	switch (e) {
		case P.Unknown: return "Unknown";
		case P.EndOfFileToken: return "EndOfFileToken";
		case P.CommentTrivia: return "CommentTrivia";
		case P.NewLineTrivia: return "NewLineTrivia";
		case P.WhitespaceTrivia: return "WhitespaceTrivia";
		case P.Identifier: return "Identifier";
		case P.OpenNodeStart: return "OpenNodeStart";
		case P.CloseNodeStart: return "CloseNodeStart";
		case P.NodeEnd: return "NodeEnd";
		case P.NodeClose: return "NodeClose";
		case P.Colon: return "Colon";
		case P.Equal: return "Equal";
		case P.StringLiteral: return "StringLiteral";
		case P.CData: return "CData";
		case P.Script: return "Script";
		case P.AmpersandEntity: return "AmpersandEntity";
		case P.LessThanEntity: return "LessThanEntity";
		case P.GreaterThanEntity: return "GreaterThanEntity";
		case P.SingleQuoteEntity: return "SingleQuoteEntity";
		case P.DoubleQuoteEntity: return "DoubleQuoteEntity";
		case P.ElementNode: return "ElementNode";
		case P.AttributeNode: return "AttributeNode";
		case P.TextNode: return "TextNode";
		case P.ContentListNode: return "ContentListNode";
		case P.AttributeListNode: return "AttributeListNode";
		case P.TagNameNode: return "TagNameNode";
		case P.ErrorNode: return "ErrorNode";
		case P.AttributeKeyNode: return "AttributeKeyNode";
	}
	return se(e);
}
function se(e) {
	throw Error("Didn't expect to get here");
}
//#endregion
//#region src/parsers/xmlui-parser/utils.ts
function ce(e, t, n) {
	let r = e.children?.filter((e) => e.kind !== P.ErrorNode) ?? [], i = t.children?.filter((e) => e.kind !== P.ErrorNode) ?? [];
	if (r.length !== i.length) return !1;
	for (let e = 0; e < r.length; ++e) if (n(r[e]) !== n(i[e])) return !1;
	return !0;
}
function le(e, t) {
	let n = [e], r;
	if (e.start > t || t > e.end) return;
	let i = {
		chainAtPos: n,
		chainBeforePos: void 0,
		sharedParents: void 0
	};
	for (; e.children !== void 0 && e.children.length > 0;) {
		let a = e.children.findIndex((e) => e.start <= t && (t < e.end || e.kind === P.EndOfFileToken && e.start <= e.end)), o = e.children[a], s = e.children[a - 1];
		if (s !== void 0 && t <= o.pos) return r = n.length, {
			chainBeforePos: n.concat(de(s)),
			sharedParents: r,
			chainAtPos: n.concat(ue(o))
		};
		e = o, i.chainAtPos.push(e);
	}
	return i;
}
function ue(e) {
	let t = [e];
	for (; e.children !== void 0 && e.children.length > 0;) e = e.children[0], t.push(e);
	return t;
}
function de(e) {
	let t = [e];
	for (; e.children !== void 0 && e.children.length > 0;) e = e.children[e.children.length - 1], t.push(e);
	return t;
}
//#endregion
//#region src/parsers/xmlui-parser/syntax-node.ts
var F = class {
	constructor(e, t, n, r, i) {
		this.kind = e, this.pos = t, this.end = n, this.triviaBefore = r, this.children = i, r ? this.start = r[0]?.start ?? t : i ? this.start = i[0]?.start ?? t : this.start = t;
	}
	isElementNode() {
		return this.kind === P.ElementNode;
	}
	isAttributeNode() {
		return this.kind === P.AttributeNode;
	}
	isTagLike() {
		return this.kind === P.ElementNode || this.kind === P.CData || this.kind == P.Script;
	}
	isAttributeKeyNode() {
		return this.kind === P.AttributeKeyNode;
	}
	isContentListNode() {
		return this.kind === P.ContentListNode;
	}
	isAttributeListNode() {
		return this.kind === P.AttributeListNode;
	}
	isTagNameNode() {
		return this.kind === P.TagNameNode;
	}
	findTokenAtOffset(e) {
		return le(this, e);
	}
	getTriviaNodes() {
		return this.pos === this.start ? null : this.triviaBefore ? this.triviaBefore : this.children[0].getTriviaNodes();
	}
}, I = /* @__PURE__ */ function(e) {
	return e[e.EOF = -1] = "EOF", e[e.nullCharacter = 0] = "nullCharacter", e[e.maxAsciiCharacter = 127] = "maxAsciiCharacter", e[e.lineFeed = 10] = "lineFeed", e[e.carriageReturn = 13] = "carriageReturn", e[e.lineSeparator = 8232] = "lineSeparator", e[e.paragraphSeparator = 8233] = "paragraphSeparator", e[e.nextLine = 133] = "nextLine", e[e.space = 32] = "space", e[e.nonBreakingSpace = 160] = "nonBreakingSpace", e[e.enQuad = 8192] = "enQuad", e[e.emQuad = 8193] = "emQuad", e[e.enSpace = 8194] = "enSpace", e[e.emSpace = 8195] = "emSpace", e[e.threePerEmSpace = 8196] = "threePerEmSpace", e[e.fourPerEmSpace = 8197] = "fourPerEmSpace", e[e.sixPerEmSpace = 8198] = "sixPerEmSpace", e[e.figureSpace = 8199] = "figureSpace", e[e.punctuationSpace = 8200] = "punctuationSpace", e[e.thinSpace = 8201] = "thinSpace", e[e.hairSpace = 8202] = "hairSpace", e[e.zeroWidthSpace = 8203] = "zeroWidthSpace", e[e.narrowNoBreakSpace = 8239] = "narrowNoBreakSpace", e[e.ideographicSpace = 12288] = "ideographicSpace", e[e.mathematicalSpace = 8287] = "mathematicalSpace", e[e.ogham = 5760] = "ogham", e[e.replacementCharacter = 65533] = "replacementCharacter", e[e._ = 95] = "_", e[e.$ = 36] = "$", e[e._0 = 48] = "_0", e[e._1 = 49] = "_1", e[e._2 = 50] = "_2", e[e._3 = 51] = "_3", e[e._4 = 52] = "_4", e[e._5 = 53] = "_5", e[e._6 = 54] = "_6", e[e._7 = 55] = "_7", e[e._8 = 56] = "_8", e[e._9 = 57] = "_9", e[e.a = 97] = "a", e[e.b = 98] = "b", e[e.c = 99] = "c", e[e.d = 100] = "d", e[e.e = 101] = "e", e[e.f = 102] = "f", e[e.g = 103] = "g", e[e.h = 104] = "h", e[e.i = 105] = "i", e[e.j = 106] = "j", e[e.k = 107] = "k", e[e.l = 108] = "l", e[e.m = 109] = "m", e[e.n = 110] = "n", e[e.o = 111] = "o", e[e.p = 112] = "p", e[e.q = 113] = "q", e[e.r = 114] = "r", e[e.s = 115] = "s", e[e.t = 116] = "t", e[e.u = 117] = "u", e[e.v = 118] = "v", e[e.w = 119] = "w", e[e.x = 120] = "x", e[e.y = 121] = "y", e[e.z = 122] = "z", e[e.A = 65] = "A", e[e.B = 66] = "B", e[e.C = 67] = "C", e[e.D = 68] = "D", e[e.E = 69] = "E", e[e.F = 70] = "F", e[e.G = 71] = "G", e[e.H = 72] = "H", e[e.I = 73] = "I", e[e.J = 74] = "J", e[e.K = 75] = "K", e[e.L = 76] = "L", e[e.M = 77] = "M", e[e.N = 78] = "N", e[e.O = 79] = "O", e[e.P = 80] = "P", e[e.Q = 81] = "Q", e[e.R = 82] = "R", e[e.S = 83] = "S", e[e.T = 84] = "T", e[e.U = 85] = "U", e[e.V = 86] = "V", e[e.W = 87] = "W", e[e.X = 88] = "X", e[e.Y = 89] = "Y", e[e.Z = 90] = "Z", e[e.ampersand = 38] = "ampersand", e[e.asterisk = 42] = "asterisk", e[e.at = 64] = "at", e[e.backslash = 92] = "backslash", e[e.backtick = 96] = "backtick", e[e.bar = 124] = "bar", e[e.caret = 94] = "caret", e[e.closeBrace = 125] = "closeBrace", e[e.closeBracket = 93] = "closeBracket", e[e.closeParen = 41] = "closeParen", e[e.colon = 58] = "colon", e[e.comma = 44] = "comma", e[e.dot = 46] = "dot", e[e.doubleQuote = 34] = "doubleQuote", e[e.equals = 61] = "equals", e[e.exclamation = 33] = "exclamation", e[e.greaterThan = 62] = "greaterThan", e[e.hash = 35] = "hash", e[e.lessThan = 60] = "lessThan", e[e.minus = 45] = "minus", e[e.openBrace = 123] = "openBrace", e[e.openBracket = 91] = "openBracket", e[e.openParen = 40] = "openParen", e[e.percent = 37] = "percent", e[e.plus = 43] = "plus", e[e.question = 63] = "question", e[e.semicolon = 59] = "semicolon", e[e.singleQuote = 39] = "singleQuote", e[e.slash = 47] = "slash", e[e.tilde = 126] = "tilde", e[e.backspace = 8] = "backspace", e[e.formFeed = 12] = "formFeed", e[e.byteOrderMark = 65279] = "byteOrderMark", e[e.tab = 9] = "tab", e[e.verticalTab = 11] = "verticalTab", e;
}({}), L = class extends Error {
	constructor(e, t, n, r, i) {
		super(e.message), this.code = e.code, this.message = e.message, this.pos = t, this.end = n, this.contextPos = r, this.contextEnd = i;
	}
	toString() {
		return `${this.code}: ${this.message}`;
	}
}, R = /* @__PURE__ */ function(e) {
	return e.onlyOneElem = "U002", e.expTagOpen = "U003", e.expTagName = "U004", e.expCloseStart = "U005", e.expEndOrClose = "U006", e.tagNameMismatch = "U007", e.expEnd = "U008", e.expAttrName = "U009", e.expEq = "U010", e.expAttrValue = "U011", e.duplAttr = "U012", e.uppercaseAttr = "U013", e.expTagNameAfterNamespace = "U014", e.expCloseStartWithName = "U015", e.expAttrNameAfterNamespace = "U016", e.unexpectedCloseTag = "U017", e.expTagNameAfterCloseStart = "U019", e.expAttrNameBeforeEq = "U020", e.nestedCompDefs = "U021", e.invalidNodeName = "U022", e.multipleScriptTags = "U023", e.compDefNameExp = "U024", e.compDefNameUppercase = "U025", e.globalNotAllowedInComponent = "U026", e.invalidReusableCompAttr = "U027", e.eventNoOnPrefix = "U028", e.onlyNameValueAttrs = "U029", e.nameAttrRequired = "U030", e.usesValueOnly = "U031", e.cantHaveNameAttr = "U032", e.onlyFieldOrItemChild = "U033", e.cannotMixFieldItem = "U034", e.singleRootElem = "U035", e.compDefNesedElem = "U036", e.duplXmlns = "U037", e.rootCompNoNamespace = "U038", e.nsNotFound = "U039", e.nsValueIncorrect = "U040", e.nsSchemeIncorrect = "U041", e.invalidChar = "W001", e.untermStr = "W002", e.untermComment = "W007", e.untermCData = "W008", e.untermScript = "W009", e;
}({}), fe = {
	unexpectedCloseTag: {
		code: R.unexpectedCloseTag,
		message: "Read '</', but there's no opening tag to close."
	},
	expCloseStartWithName: function(e) {
		return {
			code: R.expCloseStartWithName,
			message: `Opened tag has no closing pair. Expected to see '</${e}>'.`
		};
	},
	expCloseStart: {
		code: R.expCloseStart,
		message: "A '</' token expected."
	},
	uppercaseAttr: function(e) {
		return {
			code: R.uppercaseAttr,
			message: `Attribute name '${e}' cannot start with an uppercase letter.`
		};
	},
	duplAttr: function(e) {
		return {
			code: R.duplAttr,
			message: `Duplicated attribute: '${e}'.`
		};
	},
	tagNameMismatch: function(e, t) {
		return {
			code: R.tagNameMismatch,
			message: `Opening and closing tag names should match. Opening tag has a name '${e}', but the closing tag name is '${t}'.`
		};
	},
	invalidChar: function(e) {
		return {
			code: R.invalidChar,
			message: `Invalid character '${e}'.`
		};
	},
	expEnd: {
		code: R.expEnd,
		message: "A '>' token expected."
	},
	expTagName: {
		code: R.expTagName,
		message: "A tag name expected."
	},
	expAttrStr: {
		code: R.expAttrValue,
		message: "A string expected as an attribute value after '='."
	},
	expEq: {
		code: R.expEq,
		message: "An '=' token expected."
	},
	expTagOpen: {
		code: R.expTagOpen,
		message: "A '<' token expected."
	},
	expEndOrClose: {
		code: R.expEndOrClose,
		message: "A '>' or '/>' token expected."
	},
	expAttrName: {
		code: R.expAttrName,
		message: "An attribute name expected."
	},
	expAttrNameAfterNamespace: function(e) {
		return {
			code: R.expAttrNameAfterNamespace,
			message: `An attribute name expected after namespace '${e}'.`
		};
	},
	expTagNameAfterNamespace: function(e) {
		return {
			code: R.expTagNameAfterNamespace,
			message: `A tag name expected after namespace '${e}'.`
		};
	},
	expTagNameAfterCloseStart: {
		code: R.expTagNameAfterCloseStart,
		message: "Expected tag name after '</'."
	},
	expAttrNameBeforeEq: {
		code: R.expAttrNameBeforeEq,
		message: "Expected attribute name before '='."
	},
	nestedCompDefs: {
		code: R.nestedCompDefs,
		message: "A reusable component definition cannot nest another one."
	},
	invalidNodeName: function(e) {
		return {
			code: R.invalidNodeName,
			message: `Invalid node name '${e}' in a component definition.`
		};
	},
	multipleScriptTags: {
		code: R.multipleScriptTags,
		message: "Cannot have multiple <script> tags in the same tag."
	},
	compDefNameExp: {
		code: R.compDefNameExp,
		message: "A reusable component must have a non-empty name."
	},
	compDefNameUppercase: {
		code: R.compDefNameUppercase,
		message: "A component definition's name must start with an uppercase letter."
	},
	globalNotAllowedInComponent: {
		code: R.globalNotAllowedInComponent,
		message: "Global variables cannot be declared in component definitions. Use Globals.xs or declare them in Main.xmlui instead."
	},
	invalidReusableCompAttr: function(e) {
		return {
			code: R.invalidReusableCompAttr,
			message: `Invalid reusable component attribute '${e}'.`
		};
	},
	eventNoOnPrefix: function(e) {
		return {
			code: R.eventNoOnPrefix,
			message: `Event attribute names should not start with 'on' prefix: '${e}'.`
		};
	},
	onlyNameValueAttrs: function(e) {
		return {
			code: R.onlyNameValueAttrs,
			message: `Only 'name', 'value', and type hint attributes are accepted in '${e}'.`
		};
	},
	nameAttrRequired: function(e) {
		return {
			code: R.nameAttrRequired,
			message: `The 'name' attribute in '${e}' is required.`
		};
	},
	usesValueOnly: {
		code: R.usesValueOnly,
		message: "The uses element must define only a non-empty 'value' attribute."
	},
	cantHaveNameAttr: function(e) {
		return {
			code: R.cantHaveNameAttr,
			message: `The '${e}' node cannot have a 'name' attribute.`
		};
	},
	onlyFieldOrItemChild: {
		code: R.onlyFieldOrItemChild,
		message: "Only 'field' or 'item' are accepted as a child element."
	},
	cannotMixFieldItem: {
		code: R.cannotMixFieldItem,
		message: "Cannot mix 'field' and 'item' nodes within an element."
	},
	singleRootElem: {
		code: R.singleRootElem,
		message: "A component definition must have exactly one XMLUI element."
	},
	compDefNesedElem: {
		code: R.compDefNesedElem,
		message: "A reusable component must have at least one nested component definition."
	},
	duplXmlns: function(e) {
		return {
			code: R.duplXmlns,
			message: `Duplicate xmlns found: '${e}'.`
		};
	},
	rootCompNoNamespace: {
		code: R.rootCompNoNamespace,
		message: "The top level component's name cannot have a namespace."
	},
	nsNotFound: function(e) {
		return {
			code: R.nsNotFound,
			message: `Cannot resolve namespace '${e}'. It was not defined in any of the ancestor components.`
		};
	},
	nsValueIncorrect: function(e, t) {
		return {
			code: R.nsValueIncorrect,
			message: `Incorrect namespace value '${e}'. ${t}`
		};
	},
	nsSchemeIncorrect: function(e, t) {
		return {
			code: R.nsSchemeIncorrect,
			message: `Incorrect scheme specified before ':' (colon) in namespace ${e}. Delete it to get the default '${t}'.`
		};
	}
}, z = {
	invalidAttrName: "T007",
	noTextChild: "T010",
	loaderIdRequired: "T013",
	loaderCantHave: "T014",
	valueAttrRequired: "T019",
	cannotMixCompNonComp: "T020",
	scriptNoAttrs: "T022",
	cantPutReusableDefInSlot: "T024",
	scriptParse: "T030",
	globalNotAllowedInNested: "T031",
	varNameStartsWithDollar: "T032",
	...o
}, B = {
	invalidAttrName: function(e) {
		return {
			code: z.invalidAttrName,
			message: `Invalid attribute name: '${e}'.`
		};
	},
	noTextChild: function(e) {
		return {
			code: z.noTextChild,
			message: `The '${e}' element does not accept a text child.`
		};
	},
	loaderIdRequired: {
		code: z.loaderIdRequired,
		message: "A loader element must have an id."
	},
	loaderCantHave: function(e) {
		return {
			code: z.loaderCantHave,
			message: `A loader element must not have '${e}'.`
		};
	},
	valueAttrRequired: function(e) {
		return {
			code: z.valueAttrRequired,
			message: `The 'value' attribute in '${e}' is required.`
		};
	},
	cannotMixCompNonComp: {
		code: z.cannotMixCompNonComp,
		message: "Cannot mix nested components and non-component children."
	},
	scriptNoAttrs: {
		code: z.scriptNoAttrs,
		message: "The 'script' tag must not have any attribute."
	},
	cantPutReusableDefInSlot: {
		code: z.cantPutReusableDefInSlot,
		message: "Cannot put a reusable component definitions into a slot."
	},
	globalNotAllowedInNested: {
		code: z.globalNotAllowedInNested,
		message: "Global variables can only be declared in the root element of Main.xmlui, not in nested components."
	},
	varNameStartsWithDollar: function(e) {
		return {
			code: z.varNameStartsWithDollar,
			message: `Reactive variable names cannot start with '$': '${e}'.`
		};
	}
}, pe = {
	code: R.invalidChar,
	message: "Invalid character."
}, me = {
	code: R.untermStr,
	message: "Unterminated string literal."
}, he = {
	code: R.untermComment,
	message: "Unterminated comment"
}, ge = {
	code: R.untermCData,
	message: "Unterminated CDATA section"
}, _e = {
	code: R.untermScript,
	message: "Unterminated script section"
};
//#endregion
//#region src/parsers/scripting/modules.ts
function ve(e) {
	return e.type !== "ScriptModule";
}
function ye(t, n) {
	let r = /* @__PURE__ */ new Map(), s = {}, l = u(t, n);
	return !l || Object.keys(s).length > 0 ? s : l;
	function u(t, n) {
		if (r.has(t)) return r.get(t);
		let l = new c(n), u = [];
		try {
			u = l.parseStatements();
		} catch {
			return s[t] = l.errors, null;
		}
		let d = l.current;
		if (d.type !== i.Eof) return s[t] ??= [], s[t].push({
			code: o.unexpectedToken,
			text: a[o.unexpectedToken].replace(/\{(\d+)}/g, () => d.text),
			position: d.startPosition,
			end: d.endPosition,
			line: d.startLine,
			column: d.startColumn
		}), null;
		let f = [], p = {};
		u.filter((t) => t.type === e).forEach((e) => {
			let t = e;
			if (p[t.id.name]) {
				h(o.funcAlreadyDefined, e, t.id.name);
				return;
			}
			p[t.id.name] = t;
		});
		let m = {
			type: "ScriptModule",
			name: t,
			functions: p,
			statements: u,
			sources: /* @__PURE__ */ new Map()
		};
		if (r.set(t, m), f.length > 0) return s[t] = f, null;
		return m;
		function h(e, t, ...n) {
			let r = a[e];
			n && n.forEach((e, t) => r = r.replaceAll(`{${t}}`, n[t].toString())), f.push({
				code: e,
				text: a[e].replace(/\{(\d+)}/g, (e, t) => n[t]),
				position: t.startToken?.startPosition ?? 0,
				end: t.startToken?.endPosition ?? 0,
				line: t.startToken?.startLine ?? 1,
				column: t.startToken?.startColumn ?? 1
			});
		}
	}
}
//#endregion
//#region src/parsers/scripting/code-behind-collect.ts
function be(e, t) {
	let n = {
		vars: {},
		moduleErrors: {},
		functions: {},
		hasInvalidStatements: !1
	}, r = {}, i = ye(e, t);
	return ve(i) ? {
		...n,
		moduleErrors: i
	} : (i.statements.forEach((e) => {
		xe(e, n, r);
	}), n);
}
function xe(n, i, a) {
	switch (n.type) {
		case t:
			n.decls.forEach((e) => {
				if (e.id.name in i.vars) throw Error(`Duplicated var declaration: '${e.id.name}'`);
				i.vars[e.id.name] = {
					[r]: !0,
					tree: e.expr
				};
			});
			break;
		case e:
			Se(n, i, a);
			break;
		default: i.hasInvalidStatements = !0;
	}
}
function Se(e, t, r) {
	if (r?.[e.id.name] !== void 0) return;
	if (e.id.name in t.functions) throw Error(`Duplicated function declaration: '${e.id.name}'`);
	let i = {
		type: s,
		args: e.args.slice(),
		statement: e.stmt,
		[n]: !0,
		closureContext: []
	};
	r[e.id.name] = i, t.functions[e.id.name] = i;
}
var V = /^[A-Z]/, H = /^on[A-Z]/, U = ["name", "value"], W = 9, Ce = 3, G = "component-ns", we = "app-ns", Te = "#app-ns", Ee = "core-ns", De = "#xmlui-core-ns", K = {
	property: "property",
	template: "template",
	event: "event",
	variable: "variable",
	global: "global",
	loaders: "loaders",
	uses: "uses",
	method: "method",
	item: "item",
	field: "field"
}, Oe = 0;
function ke(e, t, n, r, i, a) {
	let o = (e) => e.text ?? t(e), s = e.children[0], l = T(s), u = [], d = [], f = /* @__PURE__ */ new Set();
	return p(u, l);
	function p(e, t) {
		let r = Le(t, o, d);
		if (r === "Component") return h(t);
		let i = {
			type: r,
			debug: { source: {
				start: t.start,
				end: t.end,
				fileId: n
			} }
		};
		return g(e, i, t, !0), Ne(i), i;
	}
	function m(e, t, r = !1) {
		let i = {
			type: Le(t, o, d),
			debug: { source: {
				start: t.start,
				end: t.end,
				fileId: n
			} }
		};
		return g(e, i, t, r), Ne(i), i;
	}
	function h(e) {
		let t = X(e), r = t.map(C), i = r.find((e) => e.name === "name"), a = r.find((e) => e.name === "codeBehind"), s, c = t.map((e) => ({
			attrNode: e,
			segmented: C(e)
		})).filter(({ segmented: e }) => e.startSegment === "method");
		c.length > 0 && (s = {}, c.forEach(({ attrNode: e, segmented: t }) => {
			s[t.name] = j(t.value, e.children?.[2]);
		}));
		let l, f = r.filter((e) => e.startSegment === "var");
		f.length > 0 && (l = {}, f.forEach((e) => {
			l[e.name] = e.value;
		})), r.filter((e) => e.startSegment === "global").length;
		let p = Z(e), h = p.filter((e) => e.kind === P.ElementNode && !(Q(e, o) in K)), _ = [], v = [];
		for (let e of p) if (e.kind === P.ElementNode) {
			let t = Q(e, o);
			t === K.variable ? v.push(e) : t === K.global || t in K && _.push(e);
		}
		let y;
		y = h.length > 1 || v.length > 0 ? Me([...v, ...h]) : h[0], d.push(/* @__PURE__ */ new Map()), r.filter((e) => e.namespace === "xmlns").forEach((e) => {
			Ie(d, y, e.unsegmentedName, e.value);
		});
		let b = m(u, y, !1);
		d.pop();
		let x = {
			name: i.value,
			component: b,
			debug: { source: {
				start: e.start,
				end: e.end,
				fileId: n
			} }
		};
		return s && (x.api = s), l && (b.vars = {
			...b.vars,
			...l
		}), a && (x.codeBehind = a.value), b.debug = { source: {
			start: y.start,
			end: y.end,
			fileId: n
		} }, g(u, x, Pe(e, _), !1), x;
	}
	function g(e, t, n, r = !1) {
		let i = !J(t), a = X(n);
		d.push(/* @__PURE__ */ new Map()), a.forEach((e) => {
			_(t, e, r);
		}), Z(n).forEach((n) => {
			if (n.kind === P.Script) {
				M(t, n, o);
				return;
			}
			if (n.kind === P.TextNode && !i) {
				t.children = Y(t.children, o(n));
				return;
			}
			let a = Q(n, o);
			if (!(i && n.kind === P.ElementNode && !(a in K))) {
				if (!(a in K) && !i) {
					let r = m(e, n);
					r && (t.children ? typeof t.children == "string" ? t.children = [t.children, r] : Array.isArray(t.children) && t.children.push(r) : t.children = [r]);
					return;
				}
				switch (a) {
					case "property":
					case "template":
						x(e, t, n, (e) => J(t) ? t.props?.[e] : void 0, (e, n) => {
							J(t) && (t.props ??= {}, t.props[e] = n);
						});
						return;
					case "event":
						x(e, t, n, (e) => J(t) ? t.events?.[e] : void 0, (e, n, r) => {
							J(t) && (t.events ??= {}, t.events[e] = j(n, r));
						});
						return;
					case K.variable:
						x(e, t, n, (e) => J(t) ? t.vars?.[e] : void 0, (e, n) => {
							J(t) && (t.vars ??= {}, t.vars[e] = n);
						}, (e) => {
							e.startsWith("$") && q(B.varNameStartsWithDollar(e));
						});
						return;
					case K.global:
						if (!r) {
							q(B.globalNotAllowedInNested);
							return;
						}
						x(e, t, n, (e) => J(t) ? t.globalVars?.[e] : void 0, (e, n) => {
							J(t) && (t.globalVars ??= {}, t.globalVars[e] = n);
						}, (e) => {
							e.startsWith("$") && q(B.varNameStartsWithDollar(e));
						});
						return;
					case "loaders":
						b(e, t, n);
						return;
					case "uses":
						S(t, n);
						return;
					case "method":
						x(e, t, n, (e) => J(t) ? t.api?.[e] : void 0, (e, n, r) => {
							let i = Array.isArray(n) ? n.map((e) => j(e, r)) : j(n, r);
							t.api ??= {}, t.api[e] = i;
						});
						return;
					default: return;
				}
			}
		}), d.pop();
	}
	function _(e, t, n = !1) {
		let { namespace: r, startSegment: o, name: s, value: c, unsegmentedName: l } = C(t), u = t.children[2];
		if (r === "xmlns") return Ie(d, e, l, c);
		if (J(e)) switch (s) {
			case "id":
				if (f.has(c)) {
					let e;
					if (a) {
						let { line: n, character: r } = a.positionAt(t.pos);
						e = `line ${n + 1}, column ${r + 1}`;
					} else e = `position ${t.pos}`;
					let n = `Duplicate component id "${c}" detected at ${e}. Component ids must be unique within the same markup.`;
					i ? i.push(n) : console.warn(`[xmlui] ${n}`);
				} else f.add(c);
				e.uid = c;
				return;
			case "testId":
				e.testId = c;
				return;
			case "when":
				e.when = c;
				return;
			case "uses":
				e.uses = $(c);
				return;
			default:
				if (s.startsWith("when-")) {
					let t = s.slice(5);
					if (N.includes(t)) {
						e.responsiveWhen ??= {}, e.responsiveWhen[t] = c;
						return;
					}
				}
				if (o === "var") {
					if (s.startsWith("$")) {
						q(B.varNameStartsWithDollar(s));
						return;
					}
					e.vars ??= {}, e.vars[s] = c;
				} else if (o === "global") {
					if (!n) {
						q(B.globalNotAllowedInNested);
						return;
					}
					if (s.startsWith("$")) {
						q(B.varNameStartsWithDollar(s));
						return;
					}
					e.globalVars ??= {}, e.globalVars[s] = c;
				} else if (o === "method") e.api ??= {}, e.api[s] = j(c, u);
				else if (o === "event") e.events ??= {}, e.events[s] = j(c, u);
				else if (H.test(s)) {
					e.events ??= {};
					let t = s[2].toLowerCase() + s.substring(3);
					e.events[t] = j(c, u);
				} else e.props ??= {}, e.props[s] = c;
				return;
		}
	}
	function v(e, t) {
		let n = null;
		if (!t) return n;
		let r = null;
		return t.forEach((t) => {
			if (t.kind === P.TextNode) {
				n = Y(n, o(t));
				return;
			}
			if (t.kind !== P.ElementNode) return;
			let i = Q(t, o);
			if (i !== "field" && i !== "item") return;
			i === "field" ? r || (r = i, n = {}) : i === "item" && (r || (r = i, n = []));
			let a = y(e, t, i === "field");
			if (!a) return null;
			r === "field" ? n[a.name] = a.value : n.push(a.value);
		}), n;
	}
	function y(e, t, n = !0, r = []) {
		let i = Q(t, o), a = Z(t), s = a.filter((e) => e.kind === P.ElementNode && V.test(Q(e, o))), c = a.filter((e) => e.kind === P.ElementNode && !V.test(Q(e, o))), l = X(t), u = l.map(C), d = r.length > 0 ? [...U, ...r] : U, f = u.filter((e) => d.indexOf(e.name) >= 0);
		if (u.length > f.length) return null;
		let p = f.find((e) => e.name === "name");
		if (n) {
			if (!p?.value) return null;
		} else if (p) return null;
		let h = p?.value, g = f.find((e) => e.name === "value");
		if (g && g.value === void 0) return q(B.valueAttrRequired(i)), null;
		if (h && s.length >= 1) {
			if (c.length > 0) return q(B.cannotMixCompNonComp), null;
			let t = s.map((t) => m(e, t));
			return {
				name: h,
				value: t.length === 1 ? t[0] : t
			};
		}
		let _ = g?.value;
		if (_ === null) return null;
		if (typeof _ == "string") return {
			name: h,
			value: _,
			valueContentNode: l[f.findIndex((e) => e.name === "value")]
		};
		let y;
		return a?.[0]?.kind === P.TextNode && (y = a[0]), {
			name: h,
			value: v(e, a),
			valueContentNode: y
		};
	}
	function b(e, t, n) {
		if (!J(t)) return;
		let r = Z(n);
		if (r.length === 0 && (t.loaders ??= []), n.children?.some((e) => e.kind === P.AttributeListNode)) {
			q(B.loaderCantHave("attributes"));
			return;
		}
		r.forEach((n) => {
			if (n.kind === P.TextNode) {
				q(B.noTextChild("loader"));
				return;
			}
			let r = m(e, n);
			if (!r.uid) {
				q(B.loaderIdRequired);
				return;
			}
			if (r.vars) {
				q(B.loaderCantHave("vars"));
				return;
			}
			if (r.loaders) {
				q(B.loaderCantHave("loaders"));
				return;
			}
			if (r.uses) {
				q(B.loaderCantHave("uses"));
				return;
			}
			t.loaders ??= [], t.loaders.push(r);
		});
	}
	function x(e, t, n, r, i, a, o = []) {
		let s = y(e, n, !0, o);
		if (!s) return;
		a?.(s?.name ?? "");
		let c = s.name, l = s.value;
		if (s?.value !== void 0) i(c, Y(r(c), l), s.valueContentNode);
		else {
			let t = v(e, Z(n)), a = r(c);
			a = Y(a, t), i(c, a);
		}
	}
	function S(e, t) {
		if (!J(e)) return;
		let n = X(t).map(C), r = n.find((e) => e.name === "value");
		if (!r?.value || n.length !== 1) return;
		let i = $(r.value);
		e.uses ? e.uses.push(...i) : e.uses = i;
	}
	function C(e) {
		let t = e.children[0], n = t.children.length === 3, r;
		n && (r = o(t.children[0]));
		let i = o(t.children[t.children.length - 1]), a = i.split(".");
		a.length > 2 && q(B.invalidAttrName(i));
		let s, c;
		a.length === 2 ? (c = a[0], s = a[1], s.trim() === "" && q(B.invalidAttrName(s))) : s = i;
		let l = o(e.children[2]), u = l.substring(1, l.length - 1);
		return {
			namespace: r,
			startSegment: c,
			name: s,
			value: u,
			unsegmentedName: i
		};
	}
	function w(e) {
		for (let t of e) {
			let e = t.children[t.children.length - 1], n = k(o(e));
			n !== null && (e.text = n);
		}
	}
	function T(e) {
		let t = Z(e), n = Q(e, o), r = !(n in K) || n === "property" || n === "template", i = n !== "event" && n !== "method", a = X(e);
		Fe(a), w(a), O(t), A(t, i);
		let s = !1, c = !1;
		for (let e = 0; e < t.length; ++e) {
			let n = t[e], i;
			if (n.kind == P.Script) {
				c = !0;
				continue;
			}
			if (n.kind === P.ElementNode) {
				i = T(n), t[e] = i;
				continue;
			}
			let a = o(n);
			n.kind === P.CData && (s = !0), i = r ? s ? Ae(a, n.kind) : je(a, n.kind) : {
				kind: P.TextNode,
				text: a,
				pos: n.pos,
				end: n.end,
				originalKind: n.kind
			}, t[e] = i;
		}
		let l = [], u = [], d = !1;
		for (let e of t) {
			if (e.kind === P.ElementNode) {
				if ((Q(e, o) ?? void 0) in K) {
					l.push(e);
					continue;
				}
				d = !0;
			}
			u.push(e);
		}
		if (c && d) {
			let t = Me(u);
			return l.push(t), Pe(e, l);
		}
		return e;
	}
	function E(e) {
		for (let t = 0; t < e.length; ++t) if (e[t].kind === P.TextNode) {
			let n = /[\f\n\r\t\v\u0020\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/g;
			e[t].text = o(e[t]).replace(n, " ");
		}
	}
	function D(e) {
		for (let t = 0; t < e.length; ++t) e[t].kind === P.CData && (e[t].text = o(e[t]).slice(W, -Ce));
	}
	function O(e) {
		for (let t of e) if (t.kind === P.TextNode) {
			let e = k(o(t));
			e !== null && (t.text = e);
		}
	}
	function k(e) {
		let t = "", n = 0;
		for (let r = 0; r < e.length; ++r) if (e.charCodeAt(r) === I.ampersand) switch (e.charCodeAt(r + 1)) {
			case I.a:
				switch (e.charCodeAt(r + 2)) {
					case I.m:
						e.charCodeAt(r + 3) === I.p && e.charCodeAt(r + 4) === I.semicolon && (t = t + e.substring(n, r) + "&", r += 4, n = r + 1);
						break;
					case I.p:
						e.charCodeAt(r + 3) === I.o && e.charCodeAt(r + 4) === I.s && e.charCodeAt(r + 5) === I.semicolon && (t = t + e.substring(n, r) + "'", r += 5, n = r + 1);
						break;
				}
				break;
			case I.g:
				e.charCodeAt(r + 2) === I.t && e.charCodeAt(r + 3) === I.semicolon && (t = t + e.substring(n, r) + ">", r += 3, n = r + 1);
				break;
			case I.l:
				e.charCodeAt(r + 2) === I.t && e.charCodeAt(r + 3) === I.semicolon && (t = t + e.substring(n, r) + "<", r += 3, n = r + 1);
				break;
			case I.q:
				e.charCodeAt(r + 2) === I.u && e.charCodeAt(r + 3) === I.o && e.charCodeAt(r + 4) === I.t && e.charCodeAt(r + 5) === I.semicolon && (t = t + e.substring(n, r) + "\"", r += 5, n = r + 1);
				break;
			case I.n:
				e.charCodeAt(r + 2) === I.b && e.charCodeAt(r + 3) === I.s && e.charCodeAt(r + 4) === I.p && e.charCodeAt(r + 5) === I.semicolon && (t = t + e.substring(n, r) + "\xA0", r += 5, n = r + 1);
				break;
		}
		return n === 0 ? null : (t += e.substring(n), t);
	}
	function A(e, t) {
		t && E(e), D(e);
		for (let t = e.length - 1; t > 0; --t) {
			let n = e[t - 1], r = e[t];
			n.kind === P.CData && r.kind === P.TextNode || n.kind === P.CData && r.kind === P.CData ? (e[t - 1] = {
				pos: n.pos,
				end: r.end,
				kind: P.CData,
				text: o(n) + o(r)
			}, e.pop()) : n.kind === P.TextNode && r.kind === P.TextNode ? (o(n).endsWith(" ") && o(r).startsWith(" ") && (n.text = o(n).trimEnd()), e[t - 1] = {
				pos: n.pos,
				end: r.end,
				kind: P.TextNode,
				text: o(n) + o(r)
			}, e.pop()) : n.kind === P.TextNode && r.kind === P.CData && (e[t - 1] = {
				pos: n.pos,
				end: r.end,
				kind: P.CData,
				text: o(n) + o(r)
			}, e.pop());
		}
	}
	function j(e, t) {
		if (typeof e != "string") return e;
		let n = new c(e);
		try {
			return {
				__PARSED: !0,
				statements: n.parseStatements(),
				parseId: ++Oe,
				source: e
			};
		} catch {
			if (n.errors.length > 0) {
				let e = n.errors[0], r = {
					code: e.code,
					message: e.text
				};
				if (t) {
					let n, i, a = t;
					if (a.originalKind !== void 0) if (a.originalKind === P.CData) {
						let t = a.pos + W;
						n = t + e.position, i = t + e.end;
					} else {
						let t = a.pos;
						n = t + e.position, i = t + e.end;
					}
					else if (t.kind === P.StringLiteral) {
						let r = t.pos + 1;
						n = r + e.position, i = r + e.end;
					} else if (t.kind === P.TextNode) {
						let r = t.pos;
						n = r + e.position, i = r + e.end;
					}
					q(r, n, i);
				} else q(r);
			}
		}
	}
	function M(e, t, n) {
		X(t).length > 0 && q(B.scriptNoAttrs);
		let i = n(t), a = i.indexOf(">") + 1, o = i.slice(a, i.lastIndexOf("</"));
		if (o.trim().length === 0) return;
		e.script = o;
		let s = new c(o);
		try {
			s.parseStatements(), e.scriptCollected = be("Main", o), r && (e.scriptCollected.functions = {
				...r.functions,
				...e.scriptCollected.functions
			}, e.scriptCollected.vars = {
				...r.vars,
				...e.scriptCollected.vars
			}), e.scriptCollected.hasInvalidStatements && (e.scriptError = /* @__PURE__ */ Error("Only reactive variable and function definitions are allowed in a code-behind module."));
		} catch (n) {
			if (s.errors && s.errors.length > 0) {
				let e = s.errors[0];
				q({
					code: e.code,
					message: e.text
				}, t.pos + a + e.position, t.pos + a + e.end);
			} else e.scriptError = n;
		}
		let l = e.scriptCollected?.moduleErrors ?? {};
		Object.keys(l).length > 0 && (e.scriptError = l);
	}
}
function Ae(e, t) {
	return {
		kind: P.ElementNode,
		originalKind: t,
		children: [
			{ kind: P.OpenNodeStart },
			{
				kind: P.TagNameNode,
				children: [{
					kind: P.Identifier,
					text: "TextNodeCData"
				}]
			},
			{
				kind: P.AttributeListNode,
				children: [{
					kind: P.AttributeNode,
					children: [
						{
							kind: P.AttributeKeyNode,
							children: [{
								kind: P.Identifier,
								text: "value"
							}]
						},
						{ kind: P.Equal },
						{
							kind: P.Identifier,
							text: `"${e}"`
						}
					]
				}]
			},
			{ kind: P.NodeClose }
		]
	};
}
function je(e, t) {
	return {
		kind: P.ElementNode,
		originalKind: t,
		children: [
			{ kind: P.OpenNodeStart },
			{
				kind: P.TagNameNode,
				children: [{
					kind: P.Identifier,
					text: "TextNode"
				}]
			},
			{
				kind: P.AttributeListNode,
				children: [{
					kind: P.AttributeNode,
					children: [
						{
							kind: P.AttributeKeyNode,
							children: [{
								kind: P.Identifier,
								text: "value"
							}]
						},
						{ kind: P.Equal },
						{
							kind: P.Identifier,
							text: `"${e}"`
						}
					]
				}]
			},
			{ kind: P.NodeClose }
		]
	};
}
function q(e, t, n, r, i) {
	throw new L(e, t, n, r, i);
}
function J(e) {
	return e.type;
}
function Y(e, t) {
	return e ? Array.isArray(e) ? typeof e == "string" ? [e, t] : (e.push(t), e) : [e, t] : t;
}
function Me(e) {
	let t = {
		kind: P.TagNameNode,
		children: [{
			kind: P.Identifier,
			text: "Fragment"
		}]
	};
	return {
		kind: P.ElementNode,
		start: e[0].start,
		pos: e[0].pos,
		end: e[e.length - 1].end,
		children: [
			{ kind: P.OpenNodeStart },
			t,
			{ kind: P.NodeEnd },
			{
				kind: P.ContentListNode,
				children: e
			},
			{ kind: P.CloseNodeStart },
			t,
			{ kind: P.NodeEnd }
		]
	};
}
function Ne(e) {
	if (!(!e.children || !Array.isArray(e.children))) for (let t of e.children) t.type === "Fragment" && t.scriptCollected && (t.script != null && /\$[a-zA-Z_]/.test(t.script) || (e.scriptCollected ? (e.scriptCollected.vars = {
		...e.scriptCollected.vars,
		...t.scriptCollected.vars
	}, e.scriptCollected.functions = {
		...e.scriptCollected.functions,
		...t.scriptCollected.functions
	}) : e.scriptCollected = t.scriptCollected, delete t.scriptCollected));
}
function X(e) {
	return e.children?.find((e) => e.kind === P.AttributeListNode)?.children ?? [];
}
function Z(e) {
	return e.children?.find((e) => e.kind === P.ContentListNode)?.children ?? [];
}
function Pe(e, t) {
	let n = e.children?.findIndex((e) => e.kind === P.ContentListNode);
	if (n === void 0 || n === -1) return e;
	let r = e.children[n];
	return new F(e.kind, e.pos ?? 0, e.end ?? 0, e.triviaBefore, [
		...e.children.slice(0, n),
		new F(r.kind, r.pos ?? 0, r.end ?? 0, void 0, t),
		...e.children.slice(n)
	]);
}
function Fe(e) {
	for (let t of e) if (t.children?.length === 1) {
		let e = { kind: P.Equal }, n = {
			kind: P.StringLiteral,
			text: "\"true\""
		};
		t.children.push(e, n);
	}
}
function Ie(e, t, n, r) {
	let i = r.split(":");
	if (i.length > 2) return;
	let a = r;
	if (i.length === 2) {
		if (i[0] != G) return;
		a = i[1];
	}
	if (a.includes("#")) return;
	switch (a) {
		case G:
			a = n;
			break;
		case we:
			a = Te;
			break;
		case Ee:
			a = De;
			break;
	}
	let o = e[e.length - 1];
	o.has(n) || o.set(n, a);
}
function Q(e, t) {
	let n = e.children.find((e) => e.kind === P.TagNameNode).children;
	return t(n.at(-1));
}
function Le(e, t, n) {
	let r = e.children.find((e) => e.kind === P.TagNameNode).children, i = t(r.at(-1));
	if (r.length === 1) return i;
	let a = t(r[0]);
	if (n.length === 0) return a + "." + i;
	let o;
	for (let e = n.length - 1; e >= 0 && (o = n[e].get(a), o === void 0); --e);
	return o === void 0 ? a + "." + i : o + "." + i;
}
function Re(e) {
	return e[2].toLowerCase() + e.substring(3);
}
function $(e) {
	return e.split(",").map((e) => e.trim());
}
//#endregion
export { _ as A, f as B, x as C, g as D, m as E, D as F, k as H, C as I, S as L, T as M, w as N, y as O, p as P, E as R, ne as S, h as T, M as U, O as V, u as W, ae as _, pe as a, l as b, _e as c, L as d, I as f, oe as g, P as h, fe as i, re as j, v as k, me as l, ce as m, H as n, ge as o, F as p, Re as r, he as s, ke as t, R as u, N as v, b as w, j as x, ie as y, A as z };

//# sourceMappingURL=transform-oFwtbFM_.js.map