import { EMPTY_STREAM as e, Reduction as t, stream as n } from "./stream.js";
//#region ../../node_modules/langium/lib/utils/collections.js
var r = class {
	constructor(e) {
		if (this.map = /* @__PURE__ */ new Map(), e) for (let [t, n] of e) this.add(t, n);
	}
	get size() {
		return t.sum(n(this.map.values()).map((e) => e.length));
	}
	clear() {
		this.map.clear();
	}
	delete(e, t) {
		if (t === void 0) return this.map.delete(e);
		{
			let n = this.map.get(e);
			if (n) {
				let r = n.indexOf(t);
				if (r >= 0) return n.length === 1 ? this.map.delete(e) : n.splice(r, 1), !0;
			}
			return !1;
		}
	}
	get(e) {
		return this.map.get(e) ?? [];
	}
	getStream(t) {
		let r = this.map.get(t);
		return r ? n(r) : e;
	}
	has(e, t) {
		if (t === void 0) return this.map.has(e);
		{
			let n = this.map.get(e);
			return n ? n.indexOf(t) >= 0 : !1;
		}
	}
	add(e, t) {
		return this.map.has(e) ? this.map.get(e).push(t) : this.map.set(e, [t]), this;
	}
	addAll(e, t) {
		return this.map.has(e) ? this.map.get(e).push(...t) : this.map.set(e, Array.from(t)), this;
	}
	forEach(e) {
		this.map.forEach((t, n) => t.forEach((t) => e(t, n, this)));
	}
	[Symbol.iterator]() {
		return this.entries().iterator();
	}
	entries() {
		return n(this.map.entries()).flatMap(([e, t]) => t.map((t) => [e, t]));
	}
	keys() {
		return n(this.map.keys());
	}
	values() {
		return n(this.map.values()).flat();
	}
	entriesGroupedByKey() {
		return n(this.map.entries());
	}
}, i = class {
	get size() {
		return this.map.size;
	}
	constructor(e) {
		if (this.map = /* @__PURE__ */ new Map(), this.inverse = /* @__PURE__ */ new Map(), e) for (let [t, n] of e) this.set(t, n);
	}
	clear() {
		this.map.clear(), this.inverse.clear();
	}
	set(e, t) {
		return this.map.set(e, t), this.inverse.set(t, e), this;
	}
	get(e) {
		return this.map.get(e);
	}
	getKey(e) {
		return this.inverse.get(e);
	}
	delete(e) {
		let t = this.map.get(e);
		return t === void 0 ? !1 : (this.map.delete(e), this.inverse.delete(t), !0);
	}
};
//#endregion
export { i as BiMap, r as MultiMap };
