, listener);
    document.body.addEventListener("click", listener);
  }

  function panelListener() {
    /** @type {HTMLElement} */
    let panel = null;
    return event => {
      const { target, type } = event;

      if (!(target instanceof HTMLElement)) return;

      // For keys, we only care about Enter key to activate the panel
      // otherwise it's activated via a click.
      if (type === "keydown" && event.key !== "Enter") return;

      const action = deriveAction(event);

      switch (actio