/**
 * Pure milestone ID sort helpers — no external SF dependencies.
 *
 * Extracted from milestone-ids.js to break the circular dependency between
 * milestone-ids.js and queue-order.js. Both files import from here.
 *
 * Purpose: provide extractMilestoneSeq and milestoneIdSort without importing
 * from either queue-order.js or milestone-ids.js.
 *
 * Consumer: milestone-ids.js, queue-order.js.
 */

/** Extract the trailing sequential number from a milestone ID. Returns 0 for non-matches. */
export function extractMilestoneSeq(id) {
	const m = id.match(/^M(\d{3})(?:-[a-z0-9]{6})?$/);
	return m ? parseInt(m[1], 10) : 0;
}

/** Comparator for sorting milestone IDs by sequential number. */
export function milestoneIdSort(a, b) {
	return extractMilestoneSeq(a) - extractMilestoneSeq(b);
}
