{% macro warningItem(item) -%}
  <div style="{{ styles.borderedGroup }}">

    {% if item.kind == "MismatchedPackageWarning" %}
      <div style="{{ styles.base }}">
        You chose <span style="{{ styles.code }}">{{ item.desiredPackage }}</span> for your production environment,
        but you have <span style="{{ styles.code }}">{{ item.similarPackage }}</span> locally.
      </div>

      <div style="{{ styles.base }}">To match your environment to production, run:</div>
      <div style="{{ styles.base }} padding-left: 15px;">
        <span style="{{ styles.code }}">!pip install {{ item.desiredPackage }}</span>
      </div>


      <div style="{{ styles.base }}">To match production to your local environment, include this line in your deployment:</div>
      <div style="{{ styles.base }} padding-left: 15px;">
        <span style="{{ styles.code }}">mb.deploy(my_deploy_function, <b>python_packages=["{{ item.similarPackage }}"]</b>)</span>
      </div>
    {% endif %}

    {% if item.kind == "MissingPackageFromImportWarning" %}
      <div style="{{ styles.base }}">
        Your deployment imports <span style="{{ styles.code }}">{{ item.importedModule }}</span> but you did not
        specify <span style="{{ styles.code }}">{{ item.localPackage }}</span> in your production environment.
      </div>

      <div style="{{ styles.base }}">To add the missing package to your production environment, run:</div>
      <div style="{{ styles.base }} padding-left: 15px;">
        <span style="{{ styles.code }}">mb.deploy(my_deploy_function, <b>python_packages=["{{ item.localPackage }}"]</b>)</span>
      </div>
    {% endif %}

    {% if item.kind == "DifferentPythonVerWarning" %}
      <div style="{{ styles.base }}">
        You chose <span style="{{ styles.code }}">Python {{ item.desiredVersion }}</span> for your production environment,
        but you have <span style="{{ styles.code }}">Python {{ item.localVersion }}</span> locally.
      </div>

      <div style="{{ styles.base }}">To match production to your local environment, include this line in your deployment:</div>
      <div style="{{ styles.base }} padding-left: 15px;">
        <span style="{{ styles.code }}">mb.deploy(my_deploy_function, <b>python_version="{{ item.localVersion }}"</b>)</span>
      </div>

      <div style="{{ styles.base }}">To match your local environment to production, consider installing
      <span style="{{ styles.code }}">Python {{ item.desiredVersion }}</span> locally.</div>
    {% endif %}

  </div>
{%- endmacro %}

{% if warningsList | length > 0 %}
  <div style="{{ styles.base }} margin-top: 10px;">
    <div style="{{ styles.header }}">Heads up!</div>
    <div style="{{ styles.base }}" id="fst-{{ renderId }}">
      {{ warningItem(warningsList[0]) }}
    </div>
    {% if warningsList | length > 1 %}
      {% if warningsList | length == 2 %}
        <div style="{{ styles.base }}" id="btn-{{ renderId }}">
          There is one more inconsistency.
          <span style="{{ styles.link }}" onClick="document.getElementById('lst-{{ renderId }}').style.display='block'; document.getElementById('btn-{{ renderId }}').style.display='none'; document.getElementById('fst-{{ renderId }}').style.display='none';">
            View it.
          </span>
        </div>
      {% else %}
        <div style="{{ styles.base }}" id="btn-{{ renderId }}">
          There are {{ (warningsList | length) - 1 }} more inconsistencies.
          <span style="{{ styles.link }}" onClick="document.getElementById('lst-{{ renderId }}').style.display='block'; document.getElementById('btn-{{ renderId }}').style.display='none'; document.getElementById('fst-{{ renderId }}').style.display='none';">
            View all.
          </span>
        </div>
      {% endif %}
      <div style="{{ styles.base }} display: none;" id="lst-{{ renderId }}">
        {% for warning in warningsList %}  
          {{ warningItem(warning) }}
        {% endfor %}
      </div>
    {% endif %}
  </div>
{% endif %}
