// Partitura — distinct icons for each event kind.

function EventIcon({ kind, sev, size = 14, color }) {
  const s = size;
  const c = color || EVENT_COLORS[kind] || "#a1a1aa";
  switch (kind) {
    case "new_task":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <circle cx="12" cy="12" r="10" fill={c} />
          <path d="M12 7v10M7 12h10" stroke="var(--ev-inner)" strokeWidth="2.5" strokeLinecap="round" />
        </svg>
      );
    case "state_change":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <rect x="2" y="6" width="20" height="12" rx="3" fill={c} />
          <path d="M8 12h7M13 9l3 3-3 3" stroke="var(--ev-inner)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      );
    case "assigned":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <circle cx="12" cy="12" r="10" fill={c} />
          <circle cx="12" cy="10" r="3" fill="var(--ev-inner)" />
          <path d="M6 20c1.5-3.5 5-5 6-5s4.5 1.5 6 5" stroke="var(--ev-inner)" strokeWidth="2" strokeLinecap="round" fill="none" />
        </svg>
      );
    case "label":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <path d="M3 3h10l8 8-10 10L3 13V3z" fill={c} />
          <circle cx="8" cy="8" r="1.6" fill="var(--ev-inner)" />
        </svg>
      );
    case "comment":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <path d="M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4V5z" fill={c} />
          <circle cx="9" cy="10"  r="1.2" fill="var(--ev-inner)" />
          <circle cx="12" cy="10" r="1.2" fill="var(--ev-inner)" />
          <circle cx="15" cy="10" r="1.2" fill="var(--ev-inner)" />
        </svg>
      );
    case "commit":
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <circle cx="12" cy="12" r="4.5" fill="none" stroke={c} strokeWidth="2.5" />
          <path d="M2 12h5.5M16.5 12H22" stroke={c} strokeWidth="2.5" strokeLinecap="round" />
        </svg>
      );
    case "alert": {
      const ac = sev === "critical" ? "var(--crit)" : sev === "warning" ? "var(--warn)" : "var(--info)";
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <path d="M12 2L22 21H2L12 2z" fill={ac} />
          <path d="M12 9v6" stroke="var(--ev-inner)" strokeWidth="2.2" strokeLinecap="round" />
          <circle cx="12" cy="18" r="1.2" fill="var(--ev-inner)" />
        </svg>
      );
    }
    default:
      return (
        <svg width={s} height={s} viewBox="0 0 24 24" fill="none">
          <circle cx="12" cy="12" r="6" fill={c} />
        </svg>
      );
  }
}

const EVENT_COLORS = {
  new_task:     "#22c55e",
  state_change: "#3b82f6",
  assigned:     "#a78bfa",
  label:        "#f59e0b",
  comment:      "#9ca3af",
  commit:       "#22d3ee",
  alert:        "#ef4444",
};

const EVENT_LABELS = {
  new_task:     "Новая задача",
  state_change: "Смена статуса",
  assigned:     "Назначение",
  label:        "Лейбл",
  comment:      "Комментарий",
  commit:       "Коммит",
  alert:        "Алерт",
};

const EVENT_KINDS_ORDER = ["new_task", "state_change", "assigned", "label", "comment", "commit", "alert"];

window.EventIcon = EventIcon;
window.EVENT_COLORS = EVENT_COLORS;
window.EVENT_LABELS = EVENT_LABELS;
window.EVENT_KINDS_ORDER = EVENT_KINDS_ORDER;
