<form class="{{cssClass}}" autocomplete="off">

  {{!-- Sheet Header --}}
  <header class="sheet-header">
    <div class="header-fields">
      <h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
      <div class="flexrow">
        <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
        <div class="flexcol">

          <div class="flexrow">
            {{#each system.attributes as |attr attrKey|}}
              <div class="flexcol">
                <div class="flerow">
                  <span>{{attr.label}}</span>
                  <input type="text" class="item-field-label-short" name="system.attributes.{{attrKey}}.value" value="{{attr.value}}" data-dtype="Number"/>
                </div>
                  {{#each attr.skills as |skill skillKey|}}
                  <div class="flexrow">
                      <span class="item-field-skill skill-label"><a class="roll-skill" data-attr-key="{{attrKey}}" data-skill-key="{{skillKey}}"><i class="fa-solid fa-dice-d12"></i> {{upperFirst skillKey}} {{skill.finalvalue}}</a></span>
                      <input type="checkbox" class="skill-good-checkbox" name="system.attributes.{{attrKey}}.skills.{{skillKey}}.good" {{checked skill.good}} />
                  </div>
                  {{/each}}
              </div>
            {{/each}}
          </div>

            <div class="ability-item">
            </div>

            <div class="ability-item status-block">
            </div>

          </div>
        </div>
      </div>
    </div>
  </header>

  {{!-- Sheet Tab Navigation --}}
  <nav class="sheet-tabs tabs" data-group="primary">
    <a class="item" data-tab="main">Main</a>
    <a class="item" data-tab="modules">Modules</a>
    <a class="item" data-tab="spells">Spells</a>
    <a class="item" data-tab="moves">Moves</a>
    <a class="item" data-tab="traits">Traits</a>
    <a class="item" data-tab="equipment">Equipment</a>
    <a class="item" data-tab="crafting">Crafting</a>
    <a class="item" data-tab="biodata">Biography</a>
  </nav>

  {{!-- Sheet Body --}}
  <section class="sheet-body">

    {{!-- Skills Tab --}}
    <div class="tab main" data-group="primary" data-tab="main">

      <ul class="stat-list alternate-list item-list">
        <li class="item flexrow list-item">
          <span class="item-name-label-header-short">Level</span>
          <input type="text" class="item-field-label-short" name="system.level.value" value="{{system.level.value}}" data-dtype="Number"/>
          
          <span class="item-name-label-header-short">&nbsp;</span>

          <span class="item-name-label-header-short">Health</span>
          <input type="text" class="item-field-label-short" name="system.health.value" value="{{system.health.value}}" data-dtype="Number"/> / 
          <input type="text" class="item-field-label-short" name="system.health.max" value="{{system.health.max}}" data-dtype="Number" disabled/>

          <span class="item-name-label-header-medium">&nbsp;</span>

        </li>
      </ul>

      <div class="grid-2col">
        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header-long">
              <h3><label class="items-title-text">Mitigations</label></h3>
            </span>
          </li>
          {{#each system.mitigation as |mitigation key|}}
          <li class="item flexrow list-item list-item-shadow" data-mitigation-id="{{key}}">
            <span class="item-name-label-medium">{{mitigation.label}}</span>
            <span class="item-name-label-short">{{mitigation.value}}</span>
          </li>
          {{/each}}
        </ul>

        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header-long">
              <h3><label class="items-title-text">Bonuses</label></h3>
            </span>
          </li>
          {{#each system.bonus as |bonus key|}}
          <li class="item flexrow list-item list-item-shadow" data-bonus-id="{{key}}">
            <span class="item-name-label-medium">{{upperFirst key}}</span>
            <ul class="ul-level1">
              {{#each bonus as |value key2|}}
              <li class="item flexrow list-item list-item-shadow" data-bonus-id="{{key}}">
                <span class="item-name-label-short">{{upperFirst key2}}</span>
                <span class="item-name-label-short">{{value}}</span>
              </li>
            {{/each}}
            </ul>
          </li>
          {{/each}}
        </ul>
      </div>
    </div>

    {{!-- Modules Tab --}}
    <div class="tab modules" data-group="primary" data-tab="modules">

      <div class="flexcol">
          <ul class="stat-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header-long">
                <h3><label class="items-title-text">Modules</label></h3>
              </span>
            </li>
            {{#each modules as |module key|}}
            <li class="item flexrow list-item list-item-shadow" data-item-id="{{module._id}}">
              <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
                  src="{{module.img}}" /></a>
              <span class="item-name-label-long"><a class ="item-edit">{{module.name}}</a></span>

              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>

    </div>


    {{!-- Spells Tab --}}
    <div class="tab spells" data-group="primary" data-tab="spells">

      <div class="flexcol">

        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item">
            <span class="item-name-label-header-short">Focus Regen</span>
            <input type="text" class="item-field-label-short" value="{{system.focus.focusregen}}" data-dtype="Number" disabled/>

            
            <span class="item-name-label-header-short">&nbsp;</span>

            <span class="item-name-label-header-short">Focus Points</span>
            <input type="text" class="item-field-label-short"  name="system.focus.currentfocuspoints" value="{{system.focus.currentfocuspoints}}" data-dtype="Number"/> / 
            <input type="text" class="item-field-label-short" value="{{system.focus.focuspoints}}" data-dtype="Number" disabled/>

            <span class="item-name-label-header-medium">&nbsp;</span>
          </li>
        </ul>
        
        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header">
              <h3><label class="items-title-text">Name</label></h3>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Type</label>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Level</label>
            </span>
          </li>

          {{#each spells as |spell key|}}
          <li class="item stat flexrow list-item list-item-shadow" data-item-id="{{spell._id}}">
            <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
                src="{{spell.img}}" /></a>
            <span class="item-name-label">
              <a class="roll-spell"><i class="fa-solid fa-dice-d12"> </i>{{spell.name}}</a>
            </span>
            <span class="item-field-label-medium">{{upperFirst spell.system.spelltype}}</span>
            <span class="item-field-label-medium">{{upperFirst spell.system.level}}</span>
            <div class="item-filler">&nbsp;</div>
            <div class="item-controls item-controls-fixed">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>  
          </li>
          {{/each}}

        </ul>

      </div>
    </div>

    {{!-- moves Tab --}}
    <div class="tab moves" data-group="primary" data-tab="moves">

      <div class="flexcol">

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header item-name-label-header-long2">
            <h3><label class="item-name-label-header-long2">Equipped Weapons</label></h3>
          </span>
          <span class="item-field-label-long">
            <label class="short-label">Damage</label>
          </span>
          <span class="item-field-label-long">
            <label class="short-label">Critical</label>
          </span>
          <span class="item-field-label-long">
            <label class="short-label">Brutal</label>
          </span>
        </li>
        {{#each weapons as |weapon key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{weapon.img}}" /></a>
          <span class="item-name-label-long2"><a class="roll-weapon"><i class="fa-solid fa-dice-d12"></i>{{weapon.name}}</a></span>
          <span class="item-field-label-long"><label><a class="roll-weapon-damage" data-damage="normal"><i class="fa-solid fa-dice-d12"></i>{{weapon.system.damages.primary.normal}}</label></a></span>
          <span class="item-field-label-long"><label><a class="roll-weapon-damage" data-damage="critical"><i class="fa-solid fa-dice-d12"></i>{{weapon.system.damages.primary.critical}}</label></a></span>
          <span class="item-field-label-long"><label><a class="roll-weapon-damage" data-damage="brutal"><i class="fa-solid fa-dice-d12"></i>{{weapon.system.damages.primary.brutal}}</label></a></span>
          <div class="item-filler">&nbsp;</div>
        </li>
        {{/each}}
      </ul>

        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header">
              <h3><label class="items-title-text">Name</label></h3>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Type</label>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Level</label>
            </span>
          </li>

          {{#each spells as |spell key|}}
          <li class="item stat flexrow list-item list-item-shadow" data-item-id="{{spell._id}}">
            <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
                src="{{spell.img}}" /></a>
            <span class="item-name-label">
              <a class="spell-roll">{{spell.name}}</a>
            </span>
            <span class="item-field-label-medium">{{upperFirst spell.system.spelltype}}</span>
            <span class="item-field-label-medium">{{upperFirst spell.system.level}}</span>
            <div class="item-filler">&nbsp;</div>
            <div class="item-controls item-controls-fixed">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>  
          </li>
          {{/each}}
        </ul>

      </div>
    </div>

    {{!-- traits Tab --}}
    <div class="tab traits" data-group="primary" data-tab="traits">

      <div class="flexcol">

        <ul class="stat-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header">
              <h3><label class="items-title-text">Name</label></h3>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Type</label>
            </span>
            <span class="item-field-label-medium">
              <label class="short-label">Level</label>
            </span>
          </li>

          {{#each traits as |trait key|}}
          <li class="item stat flexrow list-item list-item-shadow" data-item-id="{{trait._id}}">
            <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
                src="{{trait.img}}" /></a>
            <span class="item-name-label">
              <a class="spell-roll">{{trait.name}}</a>
            </span>
            <span class="item-field-label-medium">{{upperFirst trait.system.spelltype}}</span>
            <span class="item-field-label-medium">{{upperFirst trait.system.level}}</span>
            <div class="item-filler">&nbsp;</div>
            <div class="item-controls item-controls-fixed">
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>  
          </li>
          {{/each}}

        </ul>

      </div>
    </div>

    {{!-- Equipement Tab --}}
    <div class="tab equipment" data-group="primary" data-tab="equipment">

      <div class="flexrow">
        <h3>Encumbrance</h3>
        <span class="small-label">Current : {{encCurrent}}</span>
        <span class="small-label">Capacity : {{encCapacity}}</span>
      </div>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">Money</label></h3>
          </span>
          <span class="item-field-label-long">
            <label class="short-label">Qty</label>
          </span>
          <span class="item-field-label-medium">
            <label class="short-label">Weight</label>
          </span>
          <span class="item-field-label-medium">
            <label class="short-label">IDR</label>
          </span>
          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="money" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>
        </li>
        {{#each moneys as |money key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{money._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{money.img}}" /></a>
          <span class="item-name-label">{{money.name}}</span>

          <span class="item-field-label-long"><label>
              {{money.system.quantity}}
              (<a class="quantity-minus plus-minus-button"> -</a>/<a class="quantity-plus plus-minus-button">+</a>)
            </label>
          </span>
          <span class="item-field-label-medium">
            <label>{{money.system.weight}}</label>
          </span>
          <span class="item-field-label-medium">
            {{#if money.system.idrDice}}
            <a class="roll-idr" data-dice-value="{{money.data.idrDice}}">{{money.system.idrDice}}</a>
            {{else}}
            &nbsp;-&nbsp;
            {{/if}}
          </span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">Weapons</label></h3>
          </span>
          <span class="item-field-label-short">
            <label class="short-label">Attack</label>
          </span>
          <span class="item-field-label-short">
            <label class="short-label">Damage</label>
          </span>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="weapon" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>
        </li>
        {{#each weapons as |weapon key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{weapon.img}}" /></a>
          <span class="item-name-label">{{weapon.name}}</span>
          <span class="item-field-label-short"><label>{{upperFirst weapon.system.ability}}</label></span>
          <span class="item-field-label-short"><label>{{upperFirst weapon.system.damage}}</label></span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-equip" title="Worn">{{#if weapon.system.equipped}}<i
                class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">Armors</label></h3>
          </span>
          <span class="item-field-label-short">
            <label class="short-label">Type</label>
          </span>
          <span class="item-field-label-short">
            <label class="short-label">Absorption</label>
          </span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="armor" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>
        </li>
        {{#each armors as |armor key|}}
        <li class="item list-item flexrow list-item-shadow" data-item-id="{{armor._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{armor.img}}" /></a>
          <span class="item-name-label">{{armor.name}}</span>
          <span class="item-field-label-short">{{upperFirst armor.system.armortype}}</span>
          <span class="item-field-label-short">{{armor.system.absorprionroll}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-equip" title="Worn">{{#if armor.system.equipped}}<i
                class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">Shields</label></h3>
          </span>
          <span class="item-field-label-short">
            <label class="short-label">Dice</label>
          </span>
          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="shield" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>
        </li>
        {{#each shields as |shield key|}}
        <li class="item flexrow list-item list-item-shadow" data-item-id="{{shield._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{shield.img}}" /></a>
          <span class="item-name-label">{{shield.name}}</span>
          <span class="item-field-label-short">{{shield.system.levelDice}}</span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-equip" title="Worn">{{#if shield.system.equipped}}<i
                class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <ul class="item-list alternate-list">
        <li class="item flexrow list-item items-title-bg">
          <span class="item-name-label-header">
            <h3><label class="items-title-text">Equipment</label></h3>
          </span>
          <span class="item-field-label-long">
            <label class="short-label">Qty</label>
          </span>
          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-add" data-type="equipment" title="Create Item"><i class="fas fa-plus"></i></a>
          </div>

        </li>
        {{#each equipments as |equip key|}}
        <li class="item list-item flexrow list-item-shadow" data-item-id="{{equip._id}}">
          <a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
              src="{{equip.img}}" /></a>
          <span class="item-name-label">{{equip.name}}</span>

          <span class="item-field-label-long"><label>
              {{equip.system.quantity}}
              (<a class="quantity-minus plus-minus-button"> -</a>/<a class="quantity-plus plus-minus-button">+</a>)
            </label>
          </span>

          <div class="item-filler">&nbsp;</div>
          <div class="item-controls item-controls-fixed">
            <a class="item-control item-equip" title="Worn">{{#if equip.system.equipped}}<i
                class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
            <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
          </div>
        </li>
        {{/each}}
      </ul>

      <hr>

    </div>

    {{!-- Biography Tab --}}
    <div class="tab biodata" data-group="primary" data-tab="biodata">
      <div class="grid grid-2col">
        <div>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="generic-label">Origin</label>
              <input type="text" class="" name="system.biodata.origin" value="{{data.biodata.origin}}"
                data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="generic-label">Age</label>
              <input type="text" class="" name="system.biodata.age" value="{{data.biodata.age}}" data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="generic-label">Height</label>
              <input type="text" class="" name="system.biodata.height" value="{{data.biodata.height}}" data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="generic-label">Eyes</label>
              <input type="text" class="" name="system.biodata.eyes" value="{{data.biodata.eyes}}" data-dtype="String" />
            </li>
            <li class="item flexrow">
              <label class="generic-label">Hair</label>
              <input type="text" class="" name="system.biodata.hair" value="{{data.biodata.hair}}" data-dtype="String" />
            </li>
          </ul>
        </div>
       <div>
          <ul>
            <li class="flexrow item">
              <label class="generic-label">Size</label>
              <select class="competence-base flexrow" type="text" name="system.biodata.size" value="{{data.biodata.size}}" data-dtype="Number">
                {{#select data.biodata.size}}
                <option value="1">Tiny</option>
                <option value="2">Small</option>
                <option value="3">Medium</option>
                <option value="4">Large</option>
                <option value="5">Huge</option>
                <option value="6">Gargantuan</option>
                {{/select}}
              </select> 
            </li>
            <li class="flexrow item">
              <label class="generic-label">Sex</label>
              <input type="text" class="" name="system.biodata.sex" value="{{data.biodata.sex}}" data-dtype="String" />
            </li>
            <li class="flexrow item">
              <label class="generic-label">Preferred Hand</label>
              <input type="text" class="" name="system.biodata.preferredhand" value="{{data.biodata.preferredhand}}"
                data-dtype="String" />
            </li>
            <li class="flexrow item" data-item-id="{{race._id}}">
              <label class="generic-label">Race</label>
              <a class="item-edit"><img class="stat-icon" src="{{race.img}}"></a>
              <input type="text" class="" name="system.biodata.racename" value="{{data.biodata.racename}}" data-dtype="String" />
            </li>
          </ul>
        </div>
      </div>


      <hr>
      <h3>Background : </h3>
      <div class="form-group editor">
        {{editor data.biodata.description target="system.biodata.description" button=true owner=owner
        editable=editable}}
      </div>
      <hr>
      <h3>Notes : </h3>
      <div class="form-group editor">
        {{editor data.biodata.notes target="system.biodata.notes" button=true owner=owner editable=editable}}
      </div>
      <hr>
      </article>
    </div>

  </section>
</form>