/* Polls server build id; full reload when watchfiles restarts Python (new process = new id). */
(function () {
  var prev = null;
  function tick() {
    fetch('/__dev/build-id', { cache: 'no-store', credentials: 'same-origin' })
      .then(function (r) {
        return r.ok ? r.text() : '';
      })
      .then(function (id) {
        id = (id || '').trim();
        if (!id) return;
        if (prev === null) {
          prev = id;
          return;
        }
        if (id !== prev) {
          prev = id;
          window.location.reload();
        }
      })
      .catch(function () {});
  }
  setInterval(tick, 750);
  tick();
})();
