{% load difftags djblets_utils reviewtags %}

{% definevar "difflinecss" %}font-size: 8pt; line-height: 140%; margin: 0; {{precss}}{% enddefinevar %}
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="{{domain_method}}://{{domain}}{{comment.get_absolute_url}}" style="color: black; font-weight: bold; text-decoration: underline;">{{comment.filediff.dest_file_display}}</a>
    <span style="font-weight: normal;">
{% if comment.interfilediff %}
     (Diff revisions {{comment.filediff.diffset.revision}} - {{comment.interfilediff.diffset.revision}})
{% else %}
     (Diff revision {{comment.filediff.diffset.revision}})
{% endif %}
    </span>
   </th>
  </tr>
 </thead>
{% if chunks.0.meta.headers and chunks.0.meta.headers.0 %}
 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>
{%  if chunks.0.meta.headers.0.text == chunks.0.meta.headers.1.text %}
   <td colspan="4"><pre style="{{difflinecss}}">{{chunks.0.meta.headers.0.text}}</pre></td>
{%  else %}
   <td colspan="2"><pre style="{{difflinecss}}">{{chunks.0.meta.headers.0.text}}</pre></td>
   <td colspan="2"><pre style="{{difflinecss}}">{{chunks.0.meta.headers.1.text}}</pre></td>
{%  endif %}
  </tr>
 </tbody>
{% endif %}
{% for chunk in chunks %}
{% if chunk.change == "replace" %}
 {% definevar "thcolor" %}#e9eaa8{% enddefinevar %}
 {% definevar "bgcolor" %}#fdfebc{% enddefinevar %}
{% elif chunk.change == "insert" %}
 {% definevar "thcolor" %}#b1ebb0{% enddefinevar %}
 {% definevar "bgcolor" %}#c5ffc4{% enddefinevar %}
{% elif chunk.change == "delete" %}
 {% definevar "thcolor" %}#ebb1ba{% enddefinevar %}
 {% definevar "bgcolor" %}#ffc5ce{% enddefinevar %}
{% elif chunk.change == "equal" %}
 {% definevar "thcolor" %}#f0f0f0{% enddefinevar %}
 {% definevar "bgcolor" %}#ffffff{% enddefinevar %}
{% endif %}
 <tbody>
{% for line in chunk.lines %}
  <tr>
    <th bgcolor="{{thcolor}}" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">{{line.1}}</font></th>
    <td bgcolor="{{bgcolor}}" width="50%"><pre style="{{difflinecss}}">{{line.2|highlightregion:line.3|showextrawhitespace}}</pre></td>
    <th bgcolor="{{thcolor}}" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">{{line.4}}</font></th>
    <td bgcolor="{{bgcolor}}" width="50%"><pre style="{{difflinecss}}">{{line.5|highlightregion:line.6|showextrawhitespace}}</pre></td>
  </tr>
{% endfor %}
 </tbody>
{% endfor %}{# chunks #}
</table>
