// src/reconstruct.ts
function findUnresolvedEntityRefs(recalledSnippets, recalledEntityRefs, knownEntities) {
  const refSet = new Set(recalledEntityRefs.map((r) => r.toLowerCase()));
  const combinedText = recalledSnippets.join(" ").toLowerCase();
  const sorted = [...knownEntities].sort((a, b) => b.length - a.length);
  const matched = /* @__PURE__ */ new Set();
  const unresolved = [];
  for (const entity of sorted) {
    const lower = entity.toLowerCase();
    if (refSet.has(lower)) continue;
    const escaped = lower.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
    const pattern = new RegExp(`(?:^|[\\s,;:'"(\\[])${escaped}(?:$|[\\s,;:'".)\\]])`, "i");
    if (pattern.test(combinedText) && !matched.has(lower)) {
      unresolved.push(entity);
      matched.add(lower);
    }
  }
  return unresolved;
}

export {
  findUnresolvedEntityRefs
};
//# sourceMappingURL=chunk-X7XN6YU4.js.map