function isAstNode(e) {
	return typeof e == "object" && !!e && typeof e.$type == "string";
}
function isReference(e) {
	return typeof e == "object" && !!e && typeof e.$refText == "string" && "ref" in e;
}
function isMultiReference(e) {
	return typeof e == "object" && !!e && typeof e.$refText == "string" && "items" in e;
}
function isAstNodeDescription(e) {
	return typeof e == "object" && !!e && typeof e.name == "string" && typeof e.type == "string" && typeof e.path == "string";
}
function isLinkingError(e) {
	return typeof e == "object" && !!e && typeof e.info == "object" && typeof e.message == "string";
}
var AbstractAstReflection = class {
	constructor() {
		this.subtypes = {}, this.allSubtypes = {};
	}
	getAllTypes() {
		return Object.keys(this.types);
	}
	getReferenceType(e) {
		let a = this.types[e.container.$type];
		if (!a) throw Error(`Type ${e.container.$type || "undefined"} not found.`);
		let o = a.properties[e.property]?.referenceType;
		if (!o) throw Error(`Property ${e.property || "undefined"} of type ${e.container.$type} is not a reference.`);
		return o;
	}
	getTypeMetaData(e) {
		return this.types[e] || {
			name: e,
			properties: {},
			superTypes: []
		};
	}
	isInstance(a, o) {
		return isAstNode(a) && this.isSubtype(a.$type, o);
	}
	isSubtype(e, a) {
		if (e === a) return !0;
		let o = this.subtypes[e];
		o ||= this.subtypes[e] = {};
		let s = o[a];
		if (s !== void 0) return s;
		{
			let s = this.types[e], c = s ? s.superTypes.some((e) => this.isSubtype(e, a)) : !1;
			return o[a] = c, c;
		}
	}
	getAllSubTypes(e) {
		let a = this.allSubtypes[e];
		if (a) return a;
		{
			let a = this.getAllTypes(), o = [];
			for (let s of a) this.isSubtype(s, e) && o.push(s);
			return this.allSubtypes[e] = o, o;
		}
	}
};
function isCompositeCstNode(e) {
	return typeof e == "object" && !!e && Array.isArray(e.content);
}
function isLeafCstNode(e) {
	return typeof e == "object" && !!e && typeof e.tokenType == "object";
}
function isRootCstNode(e) {
	return isCompositeCstNode(e) && typeof e.fullText == "string";
}
export { AbstractAstReflection, isAstNode, isAstNodeDescription, isCompositeCstNode, isLeafCstNode, isLinkingError, isMultiReference, isReference, isRootCstNode };
