var regex = /\sid="(\S+)"/g, counters = /* @__PURE__ */ new Map();
function nextID(e) {
	e = e.replace(/[0-9]+$/, "") || "a";
	let n = counters.get(e) || 0;
	return counters.set(e, n + 1), n ? `${e}${n}` : e;
}
function replaceIDs(t) {
	let r = [], i;
	for (; i = regex.exec(t);) r.push(i[1]);
	if (!r.length) return t;
	let a = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
	return r.forEach((e) => {
		let r = nextID(e), i = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
		t = t.replace(RegExp("([#;\"])(" + i + ")([\")]|\\.[a-z])", "g"), "$1" + r + a + "$3");
	}), t = t.replace(new RegExp(a, "g"), ""), t;
}
export { replaceIDs };
