// page-changelog.jsx — /changelog

const RELEASES = [
  {
    v: '1.0.3', date: { en: 'Sep 8, 2026', vi: '08/09/2026' },
    highlights: { en: [], vi: [] },
    items: {
      en: [
        { title: 'Arrange closes small gaps', body: 'A window sitting slightly off its column counted as already in place, so the shortcut did nothing about exactly the kind of offset you press it to fix.' },
        { title: 'Undo always reverses the last action', body: 'Control-Option-Command-Z now undoes whatever you did most recently \u2014 a run, Clear Desk, an arrange or a shuffle. The separate "Undo Clear Desk" item is gone, since the general one covers it.' },
        { title: 'Clear Desk keeps a stubborn app hidden', body: 'An app whose window came back on screen after Hide all stayed up. It is hidden again now.' },
      ],
      vi: [
        { title: 'Sắp xếp khép được những khoảng lệch nhỏ', body: 'Cửa sổ hơi lệch khỏi cột vẫn bị coi là đã đúng chỗ, nên phím tắt không xử lý đúng cái độ lệch mà bạn bấm nó để sửa.' },
        { title: 'Hoàn tác luôn quay lại hành động gần nhất', body: 'Control-Option-Command-Z giờ hoàn tác đúng việc bạn vừa làm \u2014 chạy preset, Dọn bàn, sắp xếp hay xáo cửa sổ. Mục "Hoàn tác Dọn bàn" riêng đã bỏ vì mục chung đã bao trùm.' },
        { title: 'Dọn bàn giữ được app cứng đầu ở trạng thái ẩn', body: 'App có cửa sổ bật lại sau khi Ẩn tất cả thì vẫn nằm trên màn hình. Giờ nó được ẩn lại.' },
      ],
    },
    fixes: { en: [], vi: [] },
    known: { en: [], vi: [] },
  },
  {
    v: '1.0.2', date: { en: 'Sep 2, 2026', vi: '02/09/2026' },
    highlights: { en: [], vi: [] },
    items: {
      en: [
        { title: 'Fixes', body: 'A number of small bugs fixed across the app.' },
      ],
      vi: [
        { title: 'Sửa lỗi', body: 'Sửa một số lỗi cơ bản trong ứng dụng.' },
      ],
    },
    fixes: { en: [], vi: [] },
    known: { en: [], vi: [] },
  },
  {
    v: '1.0.1', date: { en: 'Sep 1, 2026', vi: '01/09/2026' },
    highlights: { en: [], vi: [] },
    items: {
      en: [
        { title: 'Capture takes what is on screen', body: 'Saving a workspace no longer picks up windows you had minimized to the Dock. A preset records the desk as it looks, and a window you put away is not on the desk. Presets you saved before this keep everything they already hold, and still bring those windows back minimized.' },
        { title: 'Renaming a preset works when you clear the field', body: 'Selecting the whole name and deleting it used to snap the old name straight back, so there was no way to type a fresh one over it. The field now stays empty for as long as you need. Clearing it and clicking away still returns the preset to its automatic name, as before.' },
      ],
      vi: [
        { title: 'Chụp đúng những gì đang hiện trên màn hình', body: 'Lưu một không gian làm việc không còn lấy theo những cửa sổ bạn đã thu nhỏ xuống Dock. Preset ghi lại bàn làm việc như nó đang hiện ra, mà cửa sổ bạn đã cất đi thì không nằm trên bàn. Các preset lưu từ trước vẫn giữ nguyên mọi thứ chúng đang có, và vẫn mở lại những cửa sổ đó ở trạng thái thu nhỏ.' },
        { title: 'Đổi tên preset hoạt động đúng khi bạn xoá hết ô tên', body: 'Trước đây chọn hết tên rồi xoá thì tên cũ lập tức nhảy lại, nên không cách nào gõ tên mới đè lên. Giờ ô tên để trống bao lâu tuỳ bạn. Xoá hết rồi bấm ra ngoài thì preset vẫn quay về tên tự động như trước.' },
      ],
    },
    fixes: { en: [], vi: [] },
    known: { en: [], vi: [] },
  },
  {
    v: '1.0.0', date: { en: 'Aug 31, 2026', vi: '31/08/2026' },
    highlights: {
      en: [
        'Snapovo 1.0 — the first public release. A macOS workspace manager that lives in your menu bar.',
        'Capture open apps, window positions (multi-display aware), browser tabs (Safari, Chrome, Edge, Brave, Vivaldi), Finder paths and Terminal windows as a preset.',
        'Restore in one click, a hotkey, Spotlight, Apple Shortcuts, Raycast / Alfred / LaunchBar, a snapovo:// URL, or an automatic trigger — display connect or disconnect, wake, a schedule, or a Focus mode change.',
        'Arrange open windows with tiling templates: recipes for 1 to 7 windows, plus scalable column layouts for 8 or more.',
        'Clear Desk closes or hides everything outside your keep-list, then puts it all back. Runs and Clear Desk sessions are undoable while Snapovo is running; after a relaunch, Clear Desk restores from its saved session.',
        'Chains and timed Pomodoro sessions — 20-20-20 eye breaks, 25/5 focus, 50/10 deep work — plus break reminders, Insights, proactive suggestions, themes including seasonal ones, and launcher integration.',
      ],
      vi: [
        'Snapovo 1.0 — bản phát hành công khai đầu tiên. Trình quản lý không gian làm việc cho macOS, nằm ngay trên thanh menu.',
        'Lưu các app đang mở, vị trí cửa sổ (nhận biết đa màn hình), tab trình duyệt (Safari, Chrome, Edge, Brave, Vivaldi), đường dẫn Finder và cửa sổ Terminal thành một preset.',
        'Khôi phục bằng một cú click, phím tắt, Spotlight, Apple Shortcuts, Raycast / Alfred / LaunchBar, link snapovo://, hoặc trigger tự động — cắm hay rút màn hình, máy thức, theo giờ, hoặc khi đổi chế độ Focus.',
        'Sắp xếp cửa sổ đang mở theo mẫu lưới: công thức riêng cho 1 đến 7 cửa sổ, và bố cục cột mở rộng cho 8 cửa sổ trở lên.',
        'Clear Desk đóng hoặc ẩn mọi thứ ngoài danh sách giữ lại, rồi đưa tất cả trở về. Các lần chạy và phiên Clear Desk đều hoàn tác được khi Snapovo đang chạy; sau khi khởi động lại, Clear Desk phục hồi từ phiên đã lưu.',
        'Chains và phiên Pomodoro hẹn giờ — nghỉ mắt 20-20-20, tập trung 25/5, deep work 50/10 — cùng nhắc nghỉ, Insights, gợi ý chủ động, themes (gồm theo mùa) và tích hợp launcher.',
      ],
    },
    pricing: {
      en: [
        'One-time purchase via Lemon Squeezy. No subscription.',
        '7-day free trial — full Pro, up to 3 presets.',
        'After the trial Snapovo stays usable for free in run-only mode: your existing presets and chains keep running. Creating or editing workspaces, chains, automations, and themes need Pro.',
        'One license covers 1 Mac or 2 Macs, depending on the tier — movable between your own Macs.',
      ],
      vi: [
        'Mua một lần qua Lemon Squeezy. Không thuê bao.',
        'Dùng thử miễn phí 7 ngày — đầy đủ Pro, tối đa 3 preset.',
        'Hết hạn dùng thử, Snapovo vẫn dùng được miễn phí ở chế độ chỉ chạy: các preset và chain có sẵn vẫn hoạt động. Tạo hoặc sửa workspace, chain, tự động hoá và theme cần Pro.',
        'Một giấy phép dùng cho 1 Mac hoặc 2 Mac tuỳ gói — chuyển được giữa các máy của bạn.',
      ],
    },
    fixes: { en: [], vi: [] },
    known: { en: [], vi: [] },
  },
];

const Changelog = ({ lang }) => {
  const vi = lang === 'vi';
  const L = (en, v) => (vi ? v : en);
  const pick = (o) => (vi ? o.vi : o.en);
  return (
  <main>
    <section className="ph">
      <div className="container">
        <div className="ph-inner">
          <Eyebrow>{L('Changelog', 'Nhật ký cập nhật')}</Eyebrow>
          <h1 style={{ marginTop: 14 }}>{L('What changed, when.', 'Thay đổi gì, khi nào.')}</h1>
          <p>{L('Every release, newest first.', 'Mọi bản phát hành, mới nhất trước.')}</p>
        </div>
      </div>
    </section>

    <section>
      <div className="container">
        {RELEASES.map((r) => (
          <div key={r.v} className="changelog-entry">
            <div className="changelog-meta">
              <div className="changelog-version">v{r.v}</div>
              <div className="changelog-date">{pick(r.date)}</div>
              {window.SN_DMG_URL && r.v === window.SN_VERSION ? (
                <a style={{ marginTop: 6, fontSize: 12, color: 'var(--text-dim)' }} href={window.SN_DMG_URL} download>
                  <Icon.Download size={11} /> &nbsp;{(window.SN_DMG_URL || '').split('/').pop() || `Snapovo-${r.v}.dmg`} · {pick(r.date)}
                </a>
              ) : (
                <span style={{ marginTop: 6, fontSize: 12, color: 'var(--text-dim)', display: 'inline-flex', alignItems: 'center', opacity: 0.55 }}>
                  <Icon.Download size={11} /> &nbsp;Snapovo-{r.v}.dmg · {pick(r.date)}
                </span>
              )}
            </div>
            <div className="changelog-body">
              {pick(r.highlights).length > 0 && <>
                <h4>{L('Highlights', 'Nổi bật')}</h4>
                <ul>{pick(r.highlights).map((h, i) => <li key={i}>{h}</li>)}</ul>
              </>}
              {r.items && pick(r.items).length > 0 && <>
                <h4>{L('Fixed', 'Đã sửa')}</h4>
                {pick(r.items).map((it, i) => (
                  <div key={i} className="changelog-item">
                    <h5>{it.title}</h5>
                    <p>{it.body}</p>
                  </div>
                ))}
              </>}
              {r.pricing && pick(r.pricing).length > 0 && <>
                <h4>{L('Pricing & licensing', 'Giá & giấy phép')}</h4>
                <ul>{pick(r.pricing).map((p, i) => <li key={i}>{p}</li>)}</ul>
              </>}
              {pick(r.fixes).length > 0 && <>
                <h4>{L('Build & pipeline', 'Bản dựng & quy trình')}</h4>
                <ul>{pick(r.fixes).map((f, i) => <li key={i}>{f}</li>)}</ul>
              </>}
              {pick(r.known).length > 0 && <>
                <h4>{L('Known issues', 'Vấn đề đã biết')}</h4>
                <ul>{pick(r.known).map((k, i) => <li key={i}>{k}</li>)}</ul>
              </>}
            </div>
          </div>
        ))}

        <div style={{ padding: '64px 0 32px', textAlign: 'center', color: 'var(--text-dim)', fontSize: 13, fontFamily: 'var(--font-mono)' }}>
          ⌁ &nbsp; {L('Snapovo 1.0 is the first public release. Future updates will appear above, newest first.', 'Snapovo 1.0 là bản phát hành công khai đầu tiên. Các cập nhật sau sẽ hiện phía trên, mới nhất trước.')} &nbsp; ⌁
        </div>
      </div>
    </section>
  </main>
  );
};

window.Changelog = Changelog;
