{%- macro title() -%}
<div class="title">{{ caller() }}</div>
{%- endmacro -%}

{%- macro chart_title() -%}
<div class="title chart">{{ caller() }}</div>
{%- endmacro -%}

{%- macro small_title() -%}
<div class="title small">{{ caller() }}</div>
{%- endmacro -%}

{%- macro segmentation() -%}
<div class="segmentation"></div>
{%- endmacro -%}

{%- macro content() -%}
<div class="content">{{ caller() }}</div>
{%- endmacro -%}

{%- macro split_line() -%}
<div class="split-line">
  <div class="text">{{ caller() }}</div>
</div>
{%- endmacro -%}

{%- macro footer() -%}
<div class="footer">{{ caller() }}</div>
{%- endmacro -%}

{%- macro grade_line_top(summaries) -%}
{#-
Args:
- summaries: List[RankSummary]
-#}
<div class="content grade-line">
  {%- for i in range(3) -%}
  <div class="grade">
    {%- if i == 0 -%}
    <img src="/shittim/assets/diamond.webp" />
    {%- elif i == 1 -%}
    <img src="/shittim/assets/gold.webp" />
    {%- else -%}
    <img src="/shittim/assets/silver.webp" />
    {%- endif -%}
    {%- set rank = summaries[i] -%}
    {%- if rank -%}
    <div class="score">{{ "{:,}".format(rank.best_ranking_point) }}</div>
    <div class="time">{{ rank.hard }} {{ rank.battle_time }}</div>
    {%- else -%}
    <div class="score">暂无数据</div>
    <div class="time">-- --:--.---</div>
    {%- endif -%}
  </div>
  {%- endfor -%}
</div>
{%- endmacro -%}

{%- macro grade_line_by_last_rank(summaries) -%}
{#-
Args:
- summaries: List[RankSummary]
-#}
<div class="content grade-line">
  {%- for rank in summaries -%}
  <div class="grade">
    <div class="grade-title {{ rank.hard_fullname | lower }}">{{ rank.hard_fullname }}</div>
    <div class="number">{{ rank.rank }}</div>
  </div>
  {%- endfor -%}
</div>
{%- endmacro -%}

{%- macro rank_table(rank_list) -%}
{#-
Args:
- rank_list: List[RankRecord]
-#}
<table>
  <colgroup>
    <col width="74" />
    <col width="300" />
    <col width="65" />
    <col width="290" />
    <col width="59" />
  </colgroup>

  <thead>
    <tr>
      <th>排名</th>
      <th>分数</th>
      <th>难度</th>
      <th>用时</th>
      <th>刀数</th>
    </tr>
  </thead>

  <tbody>
    {%- for rank in rank_list -%}
    <tr>
      <td>{{ rank.rank }}</td>
      <td>{{ "{:,}".format(rank.best_ranking_point) }}</td>
      <td>
        <div class="grade-title {{ rank.hard_fullname | lower }}">{{ rank.hard }}</div>
      </td>
      <td>{{ rank.battle_time }}</td>
      <td>{%- if rank.try_number_infos -%}{{ rank.try_number_infos | length }}{%- else -%}未知{%- endif -%}</td>
    </tr>
    {%- endfor -%}
  </tbody>
</table>
{%- endmacro -%}

{%- macro char_head(char) -%}
<div class="character-head">
  <img class="head" src="/shittim/assets/Card_Bg.png" />
  <img class="head" src="/shittim_student_icon/{{ char.unique_id }}" />
  <img class="frame" src="/shittim/assets/frame/{{ char.bullet_type }}.png" />
  {%- if char.is_assist -%}<img class="asist" src="/shittim/assets/Common_Icon_Asist.png" />{%- endif -%}
  <img class="role-types" src="/shittim/assets/role/{{ char.tactic_role }}.png" />
  <img class="star" src="/shittim/assets/star/{{ char.star_grade }}.png" />
</div>
{%- endmacro -%}

{%- macro rank_record(record) -%}
{#-
Args:
- record: RankRecord
-#}
<div class="content">
  <div class="team-div">
    <div class="cust-info">
      <div class="info-left">
        <div class="cust-head">
          <img class="head" src="/shittim/assets/Card_Bg.png" />
          <img class="head" src="/shittim_student_icon/{{ record.represent_character_unique_id }}" />
          <img class="rank" src="/shittim/assets/{% if record.rank < 20000 %}diamond{% else %}gold{% endif %}.webp" />
        </div>
        <div class="infos">
          <div class="info-line">
            <div class="left">ID</div>
            <div class="right">{{ record.nickname }}</div>
          </div>
          <div class="info-line">
            <div class="left">Lv</div>
            <div class="right">Lv.{{ record.level }}</div>
          </div>
        </div>
      </div>

      <div class="info-right">
        <div class="rank">第 {{ record.rank }} 名</div>
        <div class="score">{{ record.hard }} {{ "{:,}".format(record.best_ranking_point) }}</div>
      </div>
    </div>
    {%- if record.try_number_infos -%}
    {%- for info in record.try_number_infos -%}
    <div class="cust-character">
      <p>第 {{ info.try_number }} 刀</p>
      <div class="character-line">
        {%- for char in info.main_characters -%}{{ char_head(char) }}{%- endfor -%}
        <div style="width: 16px;"></div>
        {%- for char in info.support_characters -%}{{ char_head(char) }}{%- endfor -%}
      </div>
    </div>
    {%- endfor -%}
    {%- endif -%}
  </div>
</div>
{%- endmacro -%}
