<section class="tab protagonist-{{tab.id}} {{tab.cssClass}}" data-tab="{{tab.id}}" data-group="{{tab.group}}">
  <div class="main-div">
  <fieldset>
    <legend>{{localize "CTHULHUETERNAL.Label.weapons"}}{{#if isEditMode}}
      <a class="action" data-tooltip="{{localize " CTHULHUETERNAL.Tooltip.addWeapon"}}" data-tooltip-direction="UP"><i
          class="fas fa-plus" data-action="createWeapon"></i></a>{{/if}}
    </legend>
    <div class="weapons">
      {{#each weapons as |item|}}
      {{!log 'weapon' this}}
      <div class="weapon item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-drag="true">
        <!-- content -->
        <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
        <img src="systems/fvtt-cthulhu-eternal/assets/ui/d100.svg" class="d100" />
        <div class="name rollable" data-roll-type="weapon" data-tooltip="{{{item.system.description}}}">
          {{item.name}}
        </div>

        <div class="damage" data-tooltip="{{localize 'CTHULHUETERNAL.Tooltip.rollDamage'}}">
          {{#if (eq system.lethality 0)}}
            <img src="systems/fvtt-cthulhu-eternal/assets/ui/d100.svg" class="d100" />

            {{#if item.system.hasDamageDistance}}
              {{#each item.system.damageDistance as |damageDistance|}}
                {{#if (gt damageDistance.distance 0)}}
                <a class="rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage"
                    data-roll-value="{{damageDistance.damage}}" >
                  <span class="damage-distance">{{damageDistance.distance}}:{{damageDistance.damage}}&nbsp;&nbsp;</span>
                </a>
                {{/if}}
              {{/each}}
            {{else}}
              <a class="rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage"
                    data-roll-value="{{item.system.damage}}" >
              {{item.system.damage}}
              </a>
            {{/if}}
          {{else}}
            N/A
          {{/if}}
        </div>

        {{#if (gt system.baseRange 0)}}
        <span class="range" data-tooltip="CTHULHUETERNAL.Label.baseRange">{{item.system.baseRange}} {{item.system.rangeUnit}}</span>
        {{else}}
        <span class="range">{{localize "CTHULHUETERNAL.Label.melee"}}</span>
        {{/if}}

        {{#if (gt system.lethality 0)}}
         <a class="lethality rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage"
                  data-tooltip="CTHULHUETERNAL.Label.Lethality" >
          <img src="systems/fvtt-cthulhu-eternal/assets/ui/d100.svg" class="d100" />
          {{item.system.lethality}}%
         </a>
        {{else}}
        <span class="lethality" data-tooltip="CTHULHUETERNAL.Label.Lethality">-</span>
        {{/if}}

        {{#if (gt system.killRadius 0)}}
        <span class="lethality" data-tooltip="CTHULHUETERNAL.Label.killRadius" >{{item.system.killRadius}}</span>
        {{else}}
        <span class="lethality" data-tooltip="CTHULHUETERNAL.Label.killRadius">-</span>
        {{/if}}

        {{#if (gt system.armorPiercing 0)}}
        <span class="lethality" data-tooltip="CTHULHUETERNAL.Label.armorPiercing" >{{item.system.armorPiercing}}</span>
        {{else}}
        <span class="lethality" data-tooltip="CTHULHUETERNAL.Label.armorPiercing">-</span>
        {{/if}}

        {{#if (eq system.weaponType "rangedfirearm")}}
        <span class="ammo" data-tooltip="CTHULHUETERNAL.Label.Ammo" >{{item.system.ammo.value}}/{{item.system.ammo.max}}</span>
        {{else}}
        <span class="ammo" data-tooltip="CTHULHUETERNAL.Label.Ammo">N/A</span>
        {{/if}}

        <div class="controls">
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Delete'}}" data-action="delete" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-trash"></i></a>
        </div>
      </div>
      {{else}}
        <div class="empty-state">{{localize "CTHULHUETERNAL.Label.noWeapons"}}</div>
      {{/each}}
    </div>
  </fieldset>

  <fieldset>
    <legend>{{localize "CTHULHUETERNAL.Label.armors"}}{{#if isEditMode}}
      <a class="action" data-tooltip="{{localize " CTHULHUETERNAL.Tooltip.addArmor"}}" data-tooltip-direction="UP"><i
          class="fas fa-plus" data-action="createArmor"></i></a>{{/if}}
    </legend>
    <div class="armors">
      {{#each armors as |item|}}
      {{!log 'armor' this}}
      <div class="armor" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
        <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
        <div class="name" data-tooltip="{{{item.system.description}}}">
          {{item.name}}
        </div>
        <span class="protection">{{localize "CTHULHUETERNAL.Label.armor"}} : {{item.system.protection}}</span>
        <a class="equipped-toggle {{#if item.system.equipped}}active{{/if}}"
           data-action="toggleEquipped"
           data-item-id="{{item.id}}"
           data-item-uuid="{{item.uuid}}"
           data-tooltip="{{#if item.system.equipped}}{{localize 'CTHULHUETERNAL.Label.equipped'}}{{else}}{{localize 'CTHULHUETERNAL.Label.unequipped'}}{{/if}}">
          <i class="fas {{#if item.system.equipped}}fa-shield-halved{{else}}fa-shield{{/if}}"></i>
        </a>
        <div class="controls">
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Delete'}}" data-action="delete" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-trash"></i></a>
        </div>
      </div>
      {{else}}
        <div class="empty-state">{{localize "CTHULHUETERNAL.Label.noArmors"}}</div>
      {{/each}}
    </div>
  </fieldset>

  <fieldset>
    <legend>{{localize "CTHULHUETERNAL.Label.gears"}}{{#if isEditMode}}
      <a class="action" data-tooltip="{{localize " CTHULHUETERNAL.Tooltip.addGear"}}" data-tooltip-direction="UP"><i
          class="fas fa-plus" data-action="createGear"></i></a>{{/if}}
    </legend>
    <div class="gears">
      {{#each gears as |item|}}
      {{!log 'armor' this}}
      <div class="gear" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
        <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
        <div class="name" data-tooltip="{{{item.system.description}}}">
          {{item.name}}
        </div>
        <div class="controls">
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Delete'}}" data-action="delete" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-trash"></i></a>
        </div>
      </div>
      {{else}}
        <div class="empty-state">{{localize "CTHULHUETERNAL.Label.noGears"}}</div>
      {{/each}}
    </div>
  </fieldset>

  {{#if (count tomes)}}
  <fieldset>
    <legend>{{localize "CTHULHUETERNAL.Label.Tomes"}}{{#if isEditMode}}
      <a class="action" data-tooltip="{{localize "CTHULHUETERNAL.Tooltip.addTome"}}" data-tooltip-direction="UP"><i
          class="fas fa-plus" data-action="createTome"></i></a>{{/if}}
    </legend>
    <div class="tomes">
      {{#each tomes as |item|}}
      <div class="tome" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
        <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
        <div class="name" data-tooltip="{{{item.system.description}}}">
          {{item.name}}
        </div>
        <div class="controls">
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Delete'}}" data-action="delete" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-trash"></i></a>
        </div>
      </div>
      {{/each}}
    </div>
  </fieldset>
  {{/if}}

  {{#if (count rituals)}}
  <fieldset>
    <legend>{{localize "CTHULHUETERNAL.Label.Rituals"}}{{#if isEditMode}}
      <a class="action" data-tooltip="{{localize "CTHULHUETERNAL.Tooltip.addRitual"}}" data-tooltip-direction="UP"><i
          class="fas fa-plus" data-action="createRitual"></i></a>{{/if}}
    </legend>
    <div class="rituals">
      {{#each rituals as |item|}}
      <div class="ritual" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}">
        <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
        <div class="name" data-tooltip="{{{item.system.description}}}">
          {{item.name}}
        </div>
        <div class="controls">
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Edit'}}" data-action="edit" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-edit"></i></a>
          <a data-tooltip="{{localize 'CTHULHUETERNAL.Delete'}}" data-action="delete" data-item-id="{{item.id}}"
            data-item-uuid="{{item.uuid}}"><i class="fas fa-trash"></i></a>
        </div>
      </div>
      {{/each}}
    </div>
  </fieldset>
  {{/if}}

  </div>

</section>