{% load static %}

{% load django_glue %}

{% csrf_token %}

<script type="application/javascript" src="{% static 'django_glue/js/session/keep_live.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

<script type="application/javascript">
    const DJANGO_DEBUG = {% if debug %}true{% else %}false{% endif %}
    const DJANGO_GLUE_AJAX_URL = '{% url 'django_glue:django_glue_data_handler' %}'
    const DJANGO_GLUE_KEEP_LIVE_URL = '{% url 'django_glue:django_glue_keep_live_handler' %}'
    const DJANGO_GLUE_KEEP_LIVE_INTERVAL_TIME_MILLISECONDS = parseInt({{ DJANGO_GLUE_KEEP_LIVE_INTERVAL_TIME_MILLISECONDS }})

    window.glue_keep_live = new GlueKeepLive()
    window.glue_session_data = {{ GLUE_SESSION_DATA|safe }}

    setInterval(() => {
        window.glue_keep_live.update(DJANGO_GLUE_KEEP_LIVE_URL)
    }, DJANGO_GLUE_KEEP_LIVE_INTERVAL_TIME_MILLISECONDS)
</script>

{# Core Scripts #}
<script type="application/javascript" src="{% static 'django_glue/js/session/csrf.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/core/ajax.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/core/utils.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/shortcuts/shortcuts.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

{# Responses #}
<script type="application/javascript" src="{% static 'django_glue/js/response/event.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/response/response.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

{# Forms #}
<script type="application/javascript" src="{% static 'django_glue/js/form/field/attr/entities.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/form/field/attr/factories.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/form/field/entities.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/form/field/factories.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

{# Glue Model Objects #}
<script type="application/javascript" src="{% static 'django_glue/js/entities/model_object/field/entities.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/model_object/field/factories.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/model_object/entities.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/model_object/factories.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>

{# Entities #}
<script type="application/javascript" src="{% static 'django_glue/js/entities/query_set.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/function.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/template.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
<script type="application/javascript" src="{% static 'django_glue/js/entities/view.js' %}?v={{ DJANGO_GLUE_VERSION }}"></script>
