<div class="roll-dialog-content">
  <!-- HIDDEN DATA -->
  <input type="hidden" name="ability" id="ability" value="{{ abilityValue }}" />
  <input type="hidden" name="speakerId" value="{{ actor.id }}" />

  {{#if weapon}}
  <div class="weapon-block combat-dialog-weapon">
    <div class="weapon-block-header flexrow">
      <span class="weapon-icon"><i class="fas fa-crosshairs"></i></span>
      <span class="weapon-name">{{ weapon.name }}</span>
    </div>
    <div class="flexrow flex-wrap weapon-details">
      <span class="weapon-detail">
        <strong>{{localize "VERMINE.damages"}}:</strong>
        {{#if weapon.system.damage.addVigor}}{{localize "ADVERSITY.vigor"}}+ {{/if}}
        {{ weapon.system.damage.value }} ({{ weapon.system.damage.type }})
      </span>
      <span class="weapon-detail">
        <strong>{{localize "VERMINE.ranges"}}:</strong>
        {{ weapon.system.min_range }} / {{ weapon.system.max_range }}
      </span>
      {{#if effectiveRange}}
      <span class="weapon-detail">
        <strong>{{localize "VERMINE.effective_range"}}:</strong>
        {{ effectiveRange }} m
      </span>
      {{/if}}
      <span class="weapon-detail">
        <strong>{{localize "VERMINE.ammo"}}:</strong>
        {{ weapon.system.ammo }}
      </span>
    </div>
  </div>
  {{/if}}

  <h4 class="combat-mode-label">{{#ife mode "ranged"}}{{localize 'VERMINE.attack_ranged'}}{{else}}{{localize 'VERMINE.attack_contact'}}{{/ife}}</h4>

  {{#if lourdMalus}}
  <p class="traits-reminder"><i class="fas fa-weight-hanging"></i> {{ localize 'VERMINE.lourd_malus_note' malus=lourdMalus }}</p>
  {{/if}}
  {{#if mobilityNote}}
  <p class="traits-reminder"><i class="fas fa-shoe-prints"></i> {{ mobilityNote }}</p>
  {{/if}}

  <div class="dice-pool">

    <!-- ATTACKER POOL -->
    <div class="flexrow main-roll-section">
      <div class="flexcol characteristic-section">
        <label class="label">{{localize 'VERMINE.ability'}}</label>
        {{#if isCharacter}}
        <div class="locked-value">{{ smarttlk 'ABILITIES' abilityKey 'name' }} / {{ abilityValue }}</div>
        {{else if isNpc}}
        <div class="locked-value">{{localize 'ADVERSITY.threat'}} / {{ npcThreatPool }}</div>
        {{else}}
        <div class="locked-value">{{localize 'ADVERSITY.attack'}} / {{ basePool }}</div>
        {{/if}}
      </div>
      <div class="flexcol skill-section">
        <label class="label">{{localize 'VERMINE.skill_title'}}</label>
        {{#if isCharacter}}
        <div class="locked-value">{{#if skillKey}}{{ smarttlk 'SKILLS' skillKey 'name' }}{{else}}{{ localize 'VERMINE.none' }}{{/if}} / {{ skillValue }}</div>
        {{else}}
        <div class="locked-value">{{localize 'VERMINE.pool_total'}}</div>
        {{/if}}
      </div>
    </div>

    <!-- SPECIALTIES (limited to the attack skill) -->
    {{#if availableSpecialties.length}}
    <details class="specialties-section">
      <summary class="flexrow">
        <span class="label">{{localize 'VERMINE.specialty'}} (+1D)</span>
        <span class="current-specialty">{{localize 'VERMINE.none'}}</span>
      </summary>
      <div class="flexrow specialty-options">
        <label class="flexrow">
          <input
            type="radio"
            data-roll="true"
            name="usingSpecialization"
            id="usingSpecialization"
            value="aucune"
            checked
          />
          <span>{{localize 'VERMINE.none'}}</span>
        </label>
        {{#each availableSpecialties as |spec ind|}}
          <label class="flexrow">
            <input
              type="radio"
              data-roll="true"
              name="usingSpecialization"
              id="usingSpecialization"
              value="{{spec.name}}"
              data-spec-skill="{{spec.system.skill}}"
            />
            <span>{{spec.name}}</span>
          </label>
        {{/each}}
      </div>
    </details>
    {{/if}}

    <!-- DIFFICULTY -->
    <details class="difficulty-section" open>
      <summary class="flexrow">
        <span class="label">{{localize 'VERMINE.difficulty'}}</span>
        <span class="current-values"><span id="final-difficulty">{{ defaultDifficulty }}</span></span>
      </summary>
      <div class="flexcol difficulty-controls">
        <div class="flexrow combat-difficulty-options">
          {{#each difficultyOptions}}
          <label class="flexrow difficulty-option {{#if this.locked}}locked{{/if}}">
            <input
              type="radio"
              data-roll="true"
              name="combat-difficulty"
              value="{{ this.difficulty }}"
              {{#if this.rangeKey}}data-range-key="{{ this.rangeKey }}"{{/if}}
              {{#ife @root.defaultDifficulty this.difficulty}}checked{{/ife}}
              {{#if this.locked}}disabled{{/if}}
            />
            <span>{{#if this.label}}{{ this.label }}{{else}}{{ this.difficulty }}{{/if}} ({{ this.difficulty }})</span>
          </label>
          {{/each}}
        </div>
        {{#unless isCreature}}
        {{#unless creatureLocked}}
        <label class="flexrow bonus-item">
          <input type="checkbox" data-roll="true" name="second-action" id="second-action" value="1" />
          <span class="label">{{localize 'VERMINE.second_action'}}</span>
        </label>
        {{/unless}}
        {{/unless}}
        {{#if hasAmmo}}
        <label class="flexrow bonus-item">
          <input type="checkbox" data-roll="true" name="use-ammo" id="use-ammo" value="1" checked />
          <span class="label">{{localize 'VERMINE.consume_ammo'}}</span>
        </label>
        {{/if}}
        {{#if hasRafale}}
        <label class="flexrow bonus-item">
          <input type="checkbox" data-roll="true" name="rafale" id="rafale" value="1" />
          <span class="label">{{ localize 'VERMINE.rafale_check' rafaleValue=rafaleValue }}</span>
        </label>
        {{/if}}
        <div class="flexcol handicap-section">
          <label class="label" for="handicap">{{localize 'VERMINE.handicap'}}</label>
          <select class="info-value" data-roll="true" data-dtype="String" type="number"
            name="handicap" id="handicap" min="0" max="3">
            <option value="1" selected>{{localize 'VERMINE.none'}}</option>
            <option value="2">(I)</option>
            <option value="3">(II)</option>
            <option value="4">(III)</option>
          </select>
        </div>
      </div>
    </details>

    <!-- NPC POOLS -->
    {{#if isNpc}}
    <div class="flexrow bonus-item full-width">
      <label class="label" for="pools-spent">{{localize 'VERMINE.npc_pool'}}</label>
      <input
        type="number"
        data-roll="true"
        class="numeric-entry"
        style="text-align: center;"
        name="pools-spent"
        id="pools-spent"
        min="0"
        max="{{ npcPoolMax }}"
        value="0"
      />
      <span>/ {{ npcPoolMax }}</span>
    </div>
    {{/if}}

    <!-- TARGETS -->
    {{#if targets.length}}
    <div class="combat-targets">
      <span class="label">{{localize 'ITEMS.targets'}}:</span>
      {{#each targets}}
      <span class="combat-target-tag">{{ this.name }}</span>
      {{/each}}
    </div>
    {{/if}}

    <!-- BONUSES -->
    <details class="bonuses-section">
      <summary class="flexrow">
        <span class="label">{{localize 'VERMINE.bonuses'}}</span>
        <span class="bonus-count">+<span id="total-bonus">0</span>D</span>
      </summary>
      <div class="grid grid-2col bonus-grid">

        <div class="flexrow bonus-item">
          <input type="checkbox" data-roll="true" name="helped" id="helped" value="1" />
          <label class="label" for="helped">{{localize 'VERMINE.help'}} (+1D)</label>
        </div>

        <div class="flexrow bonus-item">
          <label class="label" for="group">{{localize 'VERMINE.bonus_supplementary'}}</label>
          <input type="number" data-roll="true" class="numeric-entry" style="text-align: center;"
            name="group" id="group" min="0" max="5" value="0" />
          <span>D</span>
        </div>

        <div class="flexrow bonus-item full-width">
          <label class="label" for="temporary-malus">{{localize 'VERMINE.temporary_malus'}}</label>
          <input type="number" data-roll="true" class="numeric-entry" style="text-align: center;"
            name="temporary-malus" id="temporary-malus" min="0" max="5" value="0" />
          <span>D</span>
        </div>

        {{#if isCharacter}}
        <div class="flexrow bonus-item full-width">
          <label class="label" for="self_control">
            {{localize 'VERMINE.self_control'}} <span>(+<span id="self_control_value">0</span>D)</span>
          </label>
          <input type="range" id="self_control" data-roll="true" name="self_control" min="0" max="0" value="0" />
        </div>
        {{/if}}

        {{#if availableItems.length}}
        <div class="flexrow bonus-item full-width">
          <label class="label">{{localize 'VERMINE.tooling'}} (+1D)</label>
          <div class="item-list grid grid-4col">
            <label>
              <input type="radio" data-roll="true" name="usingTools" id="usingTools" value="0" checked />
              <i>{{localize 'VERMINE.none'}}</i>
            </label>
            {{#each availableItems as |item ind|}}
            <label>
              <input type="radio" data-roll="true" name="usingTools" id="usingTools" value="{{ item.name }}" />
              <i>{{ item.name }}</i>
            </label>
            {{/each}}
          </div>
        </div>
        {{/if}}

        {{#ifgt @root.system.adaptation.totems.human.value 0}}
        <div class="flexrow bonus-item full-width totems-section">
          <label class="label">{{localize 'VERMINE.totem_dice'}}</label>
          <div class="flexrow totem-options">
            <label class="totem-option">
              <input type="checkbox" data-roll="true" name="human-totem" id="human-totem" value="1" class="totem-checkbox" />
              <span class="totem-label">{{localize 'TOTEMS.human.name'}}</span>
              <small>({{@root.system.adaptation.totems.human.value}}D)</small>
            </label>
            {{#ifgt @root.system.adaptation.totems.adapted.value 0}}
            <label class="totem-option">
              <input type="checkbox" data-roll="true" name="adapted-totem" id="adapted-totem" value="1" class="totem-checkbox" />
              <span class="totem-label">{{localize 'TOTEMS.adapted.name'}}</span>
              <small>({{@root.system.adaptation.totems.adapted.value}}D)</small>
            </label>
            {{/ifgt}}
          </div>
        </div>
        {{/ifgt}}

      </div>
    </details>

    <!-- TOTAL -->
    <div class="flexrow total-section">
      <label class="label">{{localize 'VERMINE.total'}}:</label>
      <span id="dice-pool-total" class="total-value">0D</span>
      {{#ifgt @root.system.adaptation.totems.human.value 0}}
        {{#ifgt @root.system.adaptation.totems.adapted.value 0}}
          <span class="totem-selector">
            ({{localize 'VERMINE.keep_totem'}}
            <select id="keep-totem-select" name="keep_totem">
              <option value="human">{{localize 'TOTEMS.human.name'}}</option>
              <option value="adapted">{{localize 'TOTEMS.adapted.name'}}</option>
            </select>)
          </span>
        {{/ifgt}}
      {{/ifgt}}
      <span class="totem-selector">
        ({{localize 'VERMINE.difficulty'}}: <strong id="final-difficulty">{{ defaultDifficulty }}</strong>)
      </span>
    </div>

  </div>

  <footer class="sheet-footer flexrow">
    <button type="button" data-action="cancel">
      <i class="fas fa-times"></i> {{localize "VERMINE.cancel"}}
    </button>
    <button type="button" data-action="roll">
      <i class="fas fa-crosshairs"></i> {{localize "VERMINE.attack"}}
    </button>
  </footer>
</div>
