let counter = 0;

// helper function that activates the PatchSignals
// watcher plugin to simulate a completed fetch request
const patchSignals = (count) => {
  // a simulated `datastar-patch-signals` event
  const detail = {
    type: "datastar-patch-signals",
    argsRaw: {
      signals: JSON.stringify({ count })
    }
  };

  // trigger the SSEEventWatcher by simulating a `datastar-fetch` event
  document.dispatchEvent(new CustomEvent("datastar-fetch", { detail }));
};

setInterval(() => {
  patchSignals(counter);
  counter++;
}, 250);
