<!DOCTYPE html>
<!--
Copyright (c) Jupyter Development Team.
Distributed under the terms of the Modified BSD License.
-->
<html>

<head>
  <meta charset="utf-8">

  <title>{% block title %}{{page_title}}{% endblock %}</title>

  {% block stylesheet %}
    {% for css_file in jupyterlab_css %}
      <link href="{{ css_file }}" rel="stylesheet">
    {% endfor %}
  {% endblock %}

  <script id='jupyter-config-data' type="application/json">{
    {% for key, value in jupyterlab_config.items() -%}
    "{{ key }}": "{{ value }}",
    {% endfor -%}
    "baseUrl": "{{base_url | urlencode}}",
    "wsUrl": "{{ws_url | urlencode}}"
  }</script>

  {% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="/static/base/images/favicon.ico">{% endblock %}

  {% for bundle_file in jupyterlab_bundles %}
  <script src="{{ bundle_file }}" type="text/javascript" charset="utf-8"></script>
  {% endfor %}

  {% if mathjax_url %}
  <script type="text/javascript" src="{{mathjax_url}}?config={{mathjax_config}}&amp;delayStartupUntil=configured" charset="utf-8"></script>
  {% endif %}

  {% block meta %}
  {% endblock %}

</head>

<body>

{% block script %}
<script>
  var loader = jupyter.loader;
  delete jupyter.loader;

  var createLab = loader.require("{{ jupyterlab_main }}").createLab;
  var lab = jupyter.lab = createLab(loader);
  var plugins = [];

  /**
   * Get the plugins for an entry point.
   */
  var getEntryPoint = function (entryPoint) {
    var plugins = loader.require(entryPoint);
    try {
      plugins = loader.extractPlugins(plugins);
    } catch (err) {
      console.error(err);
      plugins = [];
    }
    return plugins;
  }

  {% for plugin_entry in plugin_entries %}
  plugins = plugins.concat(getEntryPoint("{{ plugin_entry }}"));
  {% endfor %}

  lab.registerPlugins(plugins);
  lab.start();
</script>
{% endblock %}

</body>

</html>
