function buildPaletteIndex({ catalog, actionLabels }) {
  const entries = [];
  for (const cat of catalog) {
    entries.push({
      id: cat.id,
      label: cat.label,
      kind: "category",
      keywords: [cat.label, cat.description, cat.id]
    });
    for (const field of cat.fields) {
      entries.push({
        id: field.key,
        label: `${cat.label} \u203A ${field.label}`,
        path: cat.id,
        kind: "field",
        keywords: [field.label, cat.label, field.key, field.help ?? ""]
      });
    }
  }
  for (const label of actionLabels) {
    const id = label.toLowerCase();
    entries.push({
      id,
      label,
      kind: "action",
      keywords: [label, id]
    });
  }
  return entries;
}
function fuzzyScore(query, candidate) {
  if (!query) return 1;
  const q = query.toLowerCase().replace(/\s+/g, "");
  const c = candidate.toLowerCase().replace(/\s+/g, "");
  let i = 0;
  for (const ch of c) {
    if (ch === q[i]) i++;
    if (i === q.length) break;
  }
  if (i < q.length) return 0;
  let score = 1;
  if (c.includes(q)) score += 10;
  const tokens = candidate.split(/[\s›\W_]+/);
  for (const t of tokens) {
    if (t.toLowerCase().startsWith(q[0] ?? "")) score += 2;
  }
  return score;
}
export {
  buildPaletteIndex,
  fuzzyScore
};
//# sourceMappingURL=palette-index.js.map