import { STEPS_VAR } from "../../../utils/cel-context.js";
const STEP_REF_RE = new RegExp(
  `(?<![\\w$.])${STEPS_VAR}\\[("(?:[^"\\\\]|\\\\.)*")\\]`,
  "g"
);
export function scanStepRefs(text) {
  const out = [];
  STEP_REF_RE.lastIndex = 0;
  let match;
  while ((match = STEP_REF_RE.exec(text)) !== null) {
    let id;
    try {
      id = JSON.parse(match[1]);
    } catch {
      continue;
    }
    out.push({
      from: match.index,
      to: match.index + match[0].length,
      id
    });
  }
  return out;
}
export function buildStepLookup(roster) {
  const lookup = /* @__PURE__ */ new Map();
  for (const step of roster) lookup.set(step.id, { label: step.label, valid: step.valid });
  return lookup;
}
