<form class="{{cssClass}} flexrow" autocomplete="off">
{{!log "character-sheet" this}}
  {{> "systems/cthack/templates/sheets/parts/character-sidebar.hbs"}}
  <div class="main flexcol">
    <header class="character-sheet-header">
      <div class="name" data-name="{{actor.name}}">
        {{#if editable}}
          <input name="name" type="text" value="{{actor.name}}" />
        {{else}}
          <div class="search-name" data-name="{{actor.name}}" data-tooltip="{{localize 'TOOLTIPS.SearchName'}}">{{actor.name}}</div>
        {{/if}}
      </div>

      <div class="header-occupation"> 
        <div class="occupation-archetype" data-tooltip="{{#if system.hasArchetype}} Archetype {{system.archetype}}{{/if}}">
          {{#if system.hasOccupation}}{{system.occupation}} {{#if system.hasSkills}}({{system.skills}}){{/if}}{{/if}}
        </div>
        <div class="sheet-lock">
          {{#if editable}}
            <i class="fas fa-lock-open" data-tooltip="{{localize 'TOOLTIPS.LockSheet'}}"></i>
          {{else}}
            <i class="fas fa-lock" data-tooltip="{{localize 'TOOLTIPS.UnlockSheet'}}"></i>
          {{/if}}
        </div>
      </div>
      
      {{#unless editable}}
          {{#if system.hasShortDescription}}
            <div class="short-description">
              {{system.shortDescription}}
            </div>
          {{/if}}
      {{/unless}}

      {{#if editable}}
        <div class="occupation">
          <label>{{localize "CTHACK.Occupation"}}</label>
          <input class="occupation-name" name="system.occupation" type="text" value="{{system.occupation}}" class="occupation-input"/>
          <label>{{localize "CTHACK.Skills"}}</label>
          <input class="occupation-skills" name="system.skills" type="text" value="{{system.skills}}" class="occupation-input"/>
        </div>
        <div class="archetype">
          <label>{{localize "CTHACK.Archetype"}}</label>
          <input name="system.archetype" type="text" value="{{system.archetype}}" class="occupation-input"/>               
        </div>
        <input class="short-description-editable" name="system.shortDescription" type="text" value="{{system.shortDescription}}" data-tooltip="{{localize 'CTHACK.ShortDescription'}}"/>
      {{/if}}
      <div class="resources {{getNbRessources}}">
        <div class="resource" data-drag="true" data-drag-type="resource" data-drag-target="flashlights">
            <label class="resource-label resource-name {{#if (isDiceRollable system.attributes.flashlights.value)}}rollable{{/if}}" data-resource="flashlights" data-tooltip="{{localize 'CTHACK.FlashLightsDesc'}}" data-tooltip-direction="UP">{{localize "CTHACK.FlashLights"}}</label>
            <div class="resource-content">
                {{#if editable}}
                  <select class="resource-value {{#if hasLostFlashlights}}resource-value-lost{{/if}}" name="system.attributes.flashlights.value">
                    {{selectOptions diceValues selected=system.attributes.flashlights.value}}                  
                  </select>
                  (
                  <select name="system.attributes.flashlights.max">
                    {{selectOptions diceMaxValues selected=system.attributes.flashlights.max}}
                  </select>
                  )
                {{else}}
                  <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.flashlights.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.flashlights.max}}"/>
                {{/if}}
            </div>
        </div>                  
        <div class="resource" data-drag="true" data-drag-type="resource" data-drag-target="smokes">
            <label class="resource-label resource-name {{#if (isDiceRollable system.attributes.smokes.value)}}rollable{{/if}}" data-resource="smokes" data-tooltip="{{localize 'CTHACK.SmokesDesc'}}" data-tooltip-direction="UP">{{localize "CTHACK.Smokes"}}</label>
            <div class="resource-content">
                {{#if editable}}
                  <select class="resource-value {{#if hasLostSmokes}}resource-value-lost{{/if}}" name="system.attributes.smokes.value">
                    {{selectOptions diceValues selected=system.attributes.smokes.value}}
                  </select>                
                  (
                  <select name="system.attributes.smokes.max">
                    {{selectOptions diceMaxValues selected=system.attributes.smokes.max}}
                  </select>
                  )
                  {{else}}
                  <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.smokes.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.smokes.max}}"/>
                {{/if}}
            </div>
        </div>
        <div class="resource" data-drag="true" data-drag-type="resource" data-drag-target="sanity">
            <label class="resource-label resource-name {{#if (isDiceRollable system.attributes.sanity.value)}}rollable{{/if}}" data-resource="sanity" data-tooltip="{{localize 'CTHACK.SanityDesc'}}" data-tooltip-direction="UP">{{localize "CTHACK.Sanity"}}</label>
            <div class="resource-content">
                {{#if editable}}
                  <select class="resource-value {{#if hasLostSanity}}resource-value-lost{{/if}}" name="system.attributes.sanity.value">
                    {{selectOptions diceValues selected=system.attributes.sanity.value}}
                  </select>                
                  (
                  <select name="system.attributes.sanity.max">
                    {{selectOptions diceMaxValues selected=system.attributes.sanity.max}}
                  </select>
                  )
                {{else}}
                  <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.sanity.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.sanity.max}}"/>
                {{/if}}
            </div>
        </div>
        
        {{#if (isEnabled "Wealth")}}  
          <div class="resource" data-drag="true" data-drag-type="resource" data-drag-target="wealthDice">
              <label for="wealthDice.value" class="resource-label wealth-name {{#if isWealthAsResource}}rollable{{/if}}" data-resource="wealthDice">{{localize "CTHACK.Wealth"}}</label>
              <div class="resource-content">
                  {{#if editable}}
                    {{#if isWealthAsResource}}
                      <select class="resource-value {{#if hasLostWealthDice}}resource-value-lost{{/if}}" name="system.attributes.wealthDice.value">
                          {{selectOptions diceValues selected=system.attributes.wealthDice.value}}
                      </select>                  
                        (
                        <select name="system.attributes.wealthDice.max">
                        {{selectOptions diceMaxValues selected=system.attributes.wealthDice.max}}
                        </select>
                        )
                    {{else}}
                      <select class="resource-value {{#if hasLostWealthDice}}resource-value-lost{{/if}}" name="system.attributes.wealthDice.value">
                          {{selectOptions diceValues selected=system.attributes.wealthDice.value}}
                      </select>
                    {{/if}}
                  {{else}}
                    <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.wealthDice.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.wealthDice.max}}"/>
                  {{/if}}
              </div>
          </div>
        {{/if}}

        {{#if (isEnabled "MiscellaneousResource")}}    
            <div class="resource" data-drag="true" data-drag-type="resource" data-drag-target="miscellaneous">
                <label for="miscellaneous.value" class="resource-label miscellaneous-name {{#if (isDiceRollable system.attributes.miscellaneous.value)}}rollable{{/if}} {{#if hasLostMiscellaneous}}resource-value-lost{{/if}}"  data-resource="miscellaneous">{{getMiscellaneousValue}}</label>
                <div class="resource-content">
                    {{#if editable}}
                      <select class="resource-value" name="system.attributes.miscellaneous.value"
                          {{selectOptions diceValues selected=system.attributes.miscellaneous.value}}
                      </select>                    
                      (
                      <select name="system.attributes.miscellaneous.max">
                          {{selectOptions diceMaxValues selected=system.attributes.miscellaneous.max}}
                      </select>
                      )
                    {{else}}
                      <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.miscellaneous.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.miscellaneous.max}}"/>
                    {{/if}}
                </div>
            </div>
        {{/if}}

      </div>
      <div class="fight {{getNbFightColumns}}">
        {{#if displayHP}}
          <div class="resource hitpoints">
                <label class="resource-label">{{localize "CTHACK.HitPoints"}}</label>
                <div class="hitpoints-content">
                    <input class="hitpoints-value" type="text" class="value" name="system.hp.value" value="{{system.hp.value}}"/>
                    /
                    <input class="hitpoints-max" type="text" class="max" name="system.hp.max" value="{{system.hp.max}}"{{disabled uneditable}}/>
                </div>
          </div>
        {{/if}}

        {{#if displayHD}}
          <div class="resource">
                <label class="resource-label resource-name {{#if (isDiceRollable system.attributes.hitDice.value)}}rollable{{/if}}" data-resource="hitDice">{{localize "CTHACK.HitDice"}}</label>
                <div class="resource-content">
                    {{#if editable}}
                      <select class="resource-value {{#if hasLostHitDice}}resource-value-lost{{/if}}" name="system.attributes.hitDice.value">
                          {{selectOptions diceValues selected=system.attributes.hitDice.value}}
                      </select>                    
                      (
                      <select name="system.attributes.hitDice.max">
                          {{selectOptions diceMaxValues selected=system.attributes.hitDice.max}}
                      </select>
                      )
                    {{else}}
                      <img src="{{ concat 'systems/cthack/ui/dice/' system.attributes.hitDice.value '.webp'}}" data-tooltip="{{localize "TOOLTIPS.Max"}} {{system.attributes.hitDice.max}}"/>
                    {{/if}}
                </div>
          </div>
        {{/if}}

        <div class="resource" data-drag="true" data-drag-type="damage" data-drag-target="armedDamage">
            <label for="armedDamage.value" class="resource-label damage {{#if (isDiceRollable system.attributes.armedDamage.value)}}rollable{{/if}}" data-resource="armedDamage">{{localize "CTHACK.ArmedDamage"}}</label>
            <div class="resource-content">
              {{#if editable}}
                <select class="resource-value" name="system.attributes.armedDamage.value">
                  {{selectOptions diceDamageValues selected=system.attributes.armedDamage.value}}
                </select>
              {{else}}
                <img class="img-damage-armed" src="{{ concat 'systems/cthack/ui/dice/' system.attributes.armedDamage.value '.webp'}}"/>
              {{/if}}
            </div>
        </div>

        <div class="resource" data-drag="true" data-drag-type="damage" data-drag-target="unarmedDamage">
            <label for="unarmedDamage.value" class="resource-label damage {{#if (isDiceRollable system.attributes.unarmedDamage.value)}}rollable{{/if}}" data-resource="unarmedDamage">{{localize "CTHACK.UnarmedDamage"}}</label>
            <div class="resource-content">
              {{#if editable}}
                <select class="resource-value" name="system.attributes.unarmedDamage.value">
                  {{selectOptions diceDamageValues selected=system.attributes.unarmedDamage.value}}
                </select>
              {{else}}
                <img class="img-damage-unarmed" src="{{ concat 'systems/cthack/ui/dice/' system.attributes.unarmedDamage.value '.webp'}}"/>
              {{/if}}
            </div>
        </div>

      </div>
    </header>
      
    {{!-- Sheet Tab Navigation --}}
    <nav class="sheet-tabs tabs" data-group="primary">
        <a class="choice" data-tab="description">{{localize "CTHACK.Description"}}</a>        
        <a class="choice" data-tab="equipment">{{localize "CTHACK.Items"}}</a>
        <a class="choice" data-tab="abilities">{{localize "CTHACK.AbilitiesAndMagic"}}</a>
        <a class="choice" data-tab="notes">{{localize "CTHACK.Notes"}}</a>
    </nav>
   
    <section class="sheet-body">
            {{!-- Biography Tab --}}
            <div class="tab biography" data-group="primary" data-tab="description">
                {{editor enrichedBiography target="system.biography" engine="prosemirror" button=true owner=owner}}
            </div>
            
            {{!-- Equipment and Owned Items Tab --}}
            <div class="tab items" data-group="primary" data-tab="equipment">
              {{> "systems/cthack/templates/sheets/parts/character-equipment.hbs"}}
            </div>

            {{!-- Abilities and Magics Tab --}}
            <div class="tab" data-group="primary" data-tab="abilities">
              {{> "systems/cthack/templates/sheets/parts/character-abilities.hbs"}}
            </div>  

            {{!-- Notes Tab --}}
            <div class="tab character-notes" data-group="primary" data-tab="notes">
                {{editor enrichedNotes target="system.notes" engine="prosemirror" button=true owner=owner}}
            </div>  
    </section>
  </div>
</form>

