/* eslint-disable */
/* global React, useLang */
/* blog/posts.jsx — the blog's single list of posts, shared by the index (blog.html) and
   every article page, which load it before their own script. A new post is one entry
   here: `published` (ISO date of publication) orders the index newest first and makes
   the newest post the featured one, `topics` drives the index filters and the
   "Keep reading" block at the end of each article. Publication dates are the date
   each post first landed in git. Posts published the same day keep their order in
   this array (later = newer). */

const BLOG_TOPICS = {
  estrategia: { en: 'AI strategy',  es: 'Estrategia de IA' },
  datos:      { en: 'Data for AI',  es: 'Datos para IA' },
  costos:     { en: 'AI costs',     es: 'Costos de IA' },
};

const POSTS = [
  {
    slug: 'trivial',
    published: '2026-06-24',
    topics: ['estrategia'],
    date:   { en: 'June 2026',  es: 'Junio 2026' },
    author: 'Bruno Ruyú',
    /* Único post sin imagen propia — cae al bloque degradado. */
    cover: 'blog/trivial/cover.png',
    title:  {
      en: 'Trivial',
      es: 'Trivial',
    },
    subtitle: {
      en: 'Why Most SaaS Is Replicable in a Week',
      es: 'Por qué la mayoría del SaaS es replicable en una semana',
    },
    description: {
      en: "Foundation models solved unstructured data structurally. The consequence for a large portion of the software market is simple and devastating.",
      es: 'Los modelos de base resolvieron los datos no estructurados de forma estructural. La consecuencia para gran parte del mercado de software es simple y devastadora.',
    },
  },
  {
    slug: 'the-dynamo-and-ai',
    published: '2026-06-23',
    topics: ['estrategia'],
    date:   { en: 'June 2026',  es: 'Junio 2026' },
    author: 'Bruno Ruyú',
    cover: 'blog/the-dynamo-and-ai/factory-belt-drive.jpg',
    title:  {
      en: 'The Dynamo and AI',
      es: 'El Dínamo y la IA',
    },
    subtitle: {
      en: "Why Your Company Still Isn't Seeing the Results It Expected",
      es: 'Por qué tu empresa todavía no ve los resultados que esperaba',
    },
    description: {
      en: "In 1890, electricity already existed. But industrial productivity took 40 more years to take off. Today, the exact same thing is happening with artificial intelligence — and for the exact same reason.",
      es: 'En 1890, la electricidad ya existía. Pero la productividad industrial tardó 40 años más en despegar. Hoy pasa exactamente lo mismo con la inteligencia artificial. Y la razón es la misma.',
    },
  },
  {
    slug: 'data-is-not-software',
    published: '2026-06-23',
    topics: ['datos'],
    date:   { en: 'June 2026',  es: 'Junio 2026' },
    author: 'Bruno Ruyú',
    /* El diagrama y no el screenshot de Anthropic: a tamaño de portada
       el screenshot es una mancha de texto ilegible. */
    cover: 'blog/data-is-not-software/diagram-comparison.svg',
    title:  {
      en: 'Data Is Not Software',
      es: 'Los Datos No Son Software',
    },
    subtitle: {
      en: "What Anthropic's AI Analytics Project Reveals About the Real Challenge",
      es: 'Lo que el proyecto de Analytics de Anthropic revela sobre el verdadero desafío',
    },
    description: {
      en: "Our read on what it takes to get AI working on real business data — and why most companies can't replicate it alone.",
      es: 'Nuestra lectura sobre lo que hace falta para que la IA funcione con datos reales de negocio — y por qué la mayoría de las empresas no puede replicarlo sola.',
    },
  },
  {
    slug: 'the-token-excuse',
    published: '2026-09-22',
    topics: ['costos'],
    date:   { en: 'September 2026',  es: 'Septiembre 2026' },
    author: 'Bruno Ruyú',
    /* Sin imagen de portada propia — cae al bloque degradado. */
    cover: 'blog/the-token-excuse/cover.png',
    title:  {
      en: 'The Token Excuse',
      es: 'La Excusa de los Tokens',
    },
    subtitle: {
      en: "Why “We're Worried About Token Costs” Doesn't Hold Up As A Financial Argument",
      es: 'Por qué "nos preocupan los costos de tokens" no se sostiene como argumento financiero',
    },
    description: {
      en: "A token costs fractions of a cent, the API gives you full control of spend, and a seat license is usually the better deal in pure dollar terms — not just the safer one.",
      es: 'Un token cuesta fracciones de centavo, la API te da control total del gasto, y una licencia por asiento suele ser el mejor negocio en términos de plata pura, no solo el más seguro.',
    },
  },
  {
    slug: 'token-myths-cost',
    published: '2026-09-22',
    topics: ['costos'],
    date:   { en: 'September 2026',  es: 'Septiembre 2026' },
    author: 'Bruno Ruyú',
    /* Sin imagen de portada propia — cae al bloque degradado. */
    cover: 'blog/token-myths-cost/cover.png',
    title:  {
      en: 'Token Myths: How Much Does It Actually Cost?',
      es: 'Mitos de los Tokens: ¿Cuánto Cuesta Realmente?',
    },
    subtitle: {
      en: 'What a Governed Query Actually Costs — With and Without Teramot',
      es: 'Lo Que Realmente Cuesta una Consulta Gobernada — Con y Sin Teramot',
    },
    description: {
      en: "A real trace, measured in tokens: answering a governed data request costs 6.5× more without Teramot — and still produces nothing governed, versioned, or published.",
      es: 'Un trace real, medido en tokens: responder una solicitud de datos gobernada cuesta 6,5× más sin Teramot — y aun así no produce nada gobernado, versionado ni publicado.',
    },
  },
  {
    slug: 'nobody-talks-about-the-cto',
    published: '2026-10-22',
    topics: ['estrategia'],
    date:   { en: 'October 2026',  es: 'Octubre 2026' },
    author: 'Bruno Ruyú',
    cover: 'blog/nobody-talks-about-the-cto/cover.png',
    title:  {
      en: 'Nobody Talks About the CTO',
      es: 'Nadie Habla del CTO',
    },
    subtitle: {
      en: 'Why the Risk of AI Is Not Replacing the CTO, but Leaving Them Out',
      es: 'Por qué el riesgo de la IA no es que lo reemplace, sino que lo deje afuera',
    },
    description: {
      en: "AI is coming into companies through the back door. The risk is not that it replaces the CTO, but that it leaves them out, and the CTO holds what AI needs to work.",
      es: 'La IA está entrando a las empresas por la puerta de atrás. El riesgo no es que reemplace al CTO, sino que lo deje afuera, y el CTO tiene lo que la IA necesita para funcionar.',
    },
  },
  {
    slug: 'la-ia-bajo-tu-control',
    published: '2026-10-26',
    topics: ['estrategia'],
    date:   { en: 'October 2026',  es: 'Octubre 2026' },
    author: 'Bruno Ruyú',
    cover: 'blog/la-ia-bajo-tu-control/cover.png',
    title:  {
      en: 'AI, Under Your Control',
      es: 'La IA, Bajo Tu Control',
    },
    subtitle: {
      en: 'How the CTO Stops Saying No, Without Giving Up Control',
      es: 'Cómo el CTO deja de decir que no, sin dejar de cuidar',
    },
    description: {
      en: "Today business teams upload files to chats and publish dashboards nobody can find. How Teramot puts your company's AI to work on your data, in your infrastructure and under IT's control: faster, better, more secure and cheaper.",
      es: 'Hoy las áreas suben archivos a chats y publican tableros que nadie sabe dónde viven. Cómo Teramot pone la IA de tu empresa a trabajar con tus datos, en tu infraestructura y bajo control de IT: más rápido, mejor, más seguro y más barato.',
    },
  },
  {
    slug: 'la-ia-es-facil-tus-datos-no',
    published: '2026-10-28',
    topics: ['estrategia', 'datos'],
    date:   { en: 'October 2026',  es: 'Octubre 2026' },
    author: 'Bruno Ruyú',
    cover: 'blog/la-ia-es-facil-tus-datos-no/cover.png',
    title:  {
      en: "AI Is Easy. Your Data Isn't.",
      es: 'La IA Es Fácil. Tus Datos, No.',
    },
    subtitle: {
      en: 'Why No AI Can Work With Your Real Data, and What Changes When It Can',
      es: 'Por qué ninguna IA puede trabajar con tus datos reales, y qué cambia cuando puede',
    },
    description: {
      en: "Any AI builds a dashboard in seconds. None can build it from your source data: 74,000 tables in SAP, the CRM and systems that were never migrated. Teramot solves that part.",
      es: 'Cualquier IA arma un tablero en segundos. Ninguna puede hacerlo desde tus datos de origen: 74.000 tablas en SAP, el CRM y sistemas que nunca se migraron. Teramot resuelve esa parte.',
    },
  },
];

/* Newest first; same-day posts keep array order (later in the array = newer). */
const POSTS_BY_DATE = POSTS
  .map((p, i) => ({ p, i }))
  .sort((a, b) => (b.p.published.localeCompare(a.p.published)) || (b.i - a.i))
  .map(({ p }) => p);

/* "Keep reading" at the end of an article: the two newest posts sharing a topic with
   it, topped up with the newest posts overall when the topic has fewer than two. */
const KeepReading = ({ slug }) => {
  const { lang } = useLang();
  const self = POSTS.find((p) => p.slug === slug);
  const others = POSTS_BY_DATE.filter((p) => p.slug !== slug);
  const same = others.filter((p) => p.topics.some((t) => self.topics.includes(t)));
  const picks = [...same, ...others.filter((p) => !same.includes(p))].slice(0, 2);
  return (
    <aside className="tm-article-mas">
      <p className="tm-article-mas-titulo">{lang === 'en' ? 'Keep reading' : 'Seguir leyendo'}</p>
      <div className="tm-article-mas-lista">
        {picks.map((p) => (
          <a className="tm-article-mas-item" href={p.slug} key={p.slug}>
            <strong>{p.title[lang]}</strong>
            <span>{p.subtitle[lang]}</span>
          </a>
        ))}
      </div>
    </aside>
  );
};
