/* Chatterkick icons — Tabler Icons webfont (v3.31.0), rendered as <i class="ti ti-NAME">.
   Pages that use these components must load the Tabler stylesheet:
   https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.31.0/dist/tabler-icons.min.css
   Same convention as Button.jsx: no imports or exports, React from the UMD global,
   components published on `window`. Pick names from preview/icons.html. */

const TONES = {
  up:     { background: "#E4F7E1", color: "#067D0E" },
  warn:   { background: "#F6F7CE", color: "#6A6C00" },
  danger: { background: "#F7E3E3", color: "#A32D2D" },
  neutral:{ background: "#F3F3F3", color: "#111" },
};

/** A bare Tabler icon. Inherits text color; size is font-size in px. */
function Icon({ name, size = 16, color, style }) {
  return React.createElement("i", {
    className: "ti ti-" + name,
    style: { fontSize: size, color, lineHeight: 1, ...style },
    "aria-hidden": "true",
  });
}

/** Icon inside the tinted callout tile. Tile and icon colors are paired by tone. */
function IconTile({ name, tone = "up", size = 38 }) {
  const t = TONES[tone] || TONES.up;
  return React.createElement(
    "span",
    {
      style: {
        width: size, height: size, borderRadius: 10, background: t.background, color: t.color,
        display: "inline-flex", alignItems: "center", justifyContent: "center", flex: "none",
      },
    },
    React.createElement(Icon, { name, size: Math.round(size / 2) })
  );
}

Object.assign(window, { Icon, IconTile });
