{% load static %}

<script src="{% static 'rechat/index.js' %}"></script>
<script>
  var $rechat;
  var $chatroom;
  document.addEventListener('alpine:init', () => {
    console.log("Alpine init");
    $rechat = $alpine.initRechatStore("{{ request.user.get_username }}");
    $chatroom = $alpine.initChatroomStore();
    $alpine.initWs($chatroom);
  });
  //htmx.logAll();
  // add CSRFToken to HTMX headers
  document.body.addEventListener('htmx:configRequest', (event) => {
    event.detail.headers['X-CSRFToken'] = '{{ csrf_token|safe }}';
  });
</script>
