/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
const require_StateAxis = require("../types/StateAxis.cjs");
//#region ../automated-config/dist/utils/canonicalizeStateKey.js
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
function canonicalizeStateKey(atoms) {
	if (atoms.length === 0) return "rest";
	const seen = /* @__PURE__ */ new Set();
	const modifiers = [];
	const interactives = [];
	for (const atom of atoms) {
		if (seen.has(atom)) continue;
		seen.add(atom);
		if (require_StateAxis.isModifierAtomic(atom)) modifiers.push(atom);
		else if (require_StateAxis.isInteractiveAtomic(atom)) interactives.push(atom);
		else throw new Error(`canonicalizeStateKey received an unrecognized atom "${atom}". Atoms must be in MODIFIER_ATOMICS or INTERACTIVE_ATOMICS — see StateAxis.`);
	}
	modifiers.sort(require_StateAxis.comparePriority);
	interactives.sort(require_StateAxis.comparePriority);
	const ordered = [...modifiers, ...interactives];
	return ordered.length === 0 ? "rest" : ordered.join("&");
}
/**
* Splits a canonical (or legacy) state key into its atomic parts.
* `'rest'` and `''` produce an empty array.
*/
function splitStateKey(stateKey) {
	if (!stateKey || stateKey === "rest") return [];
	return stateKey.split("&");
}
//#endregion
exports.canonicalizeStateKey = canonicalizeStateKey;
exports.splitStateKey = splitStateKey;
