<section>
  {{> "systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"}}
  <div class="sheet-body">
  <fieldset>
    <legend>But</legend>
    {{formField systemFields.but value=system.but}}
  </fieldset>
  <fieldset>
    <legend>Manipulation</legend>
    {{formInput systemFields.manipulation enriched=enriched.manipulation value=system.manipulation name="system.manipulation" toggled=true}}
  </fieldset>
  <fieldset>
    <legend>Utilisation</legend>
    {{formInput systemFields.utilisation enriched=enriched.utilisation value=system.utilisation name="system.utilisation" toggled=true}}
  </fieldset>
  <fieldset>
    <legend>Enchantement</legend>
    {{formInput systemFields.enchantement enriched=enriched.enchantement value=system.enchantement name="system.enchantement" toggled=true}}
  </fieldset>
  <fieldset>
    <legend>Sur-effet</legend>
    {{formInput systemFields.sureffet enriched=enriched.sureffet value=system.sureffet name="system.sureffet" toggled=true}}
  </fieldset>
  <fieldset class="ingredients-section">
    <legend>
      Ingrédients
      <button type="button" data-action="addIngredient" data-tooltip="Ajouter un ingrédient"><i class="fas fa-plus"></i></button>
      <button type="button" data-action="extractIngredients" data-tooltip="Extraire depuis la manipulation"><i class="fas fa-magic"></i></button>
    </legend>
    {{#if parsedIngredients.length}}
    <ul class="ingredients-list alterne-list">
      {{#each parsedIngredients as |ingredient i|}}
      <li class="ingredient-row flexrow" data-index="{{i}}">
        <input type="text" name="ingredient-nom-{{i}}" value="{{ingredient.nom}}" placeholder="Nom">
        <select name="ingredient-type-{{i}}" data-dtype="String">
          {{#select ingredient.type}}
          {{#each ../INGREDIENT_TYPES as |label key|}}
          <option value="{{key}}">{{label}}</option>
          {{/each}}
          {{/select}}
        </select>
        <input type="number" name="ingredient-quantite-{{i}}" value="{{ingredient.quantite}}" min="0" step="1">
        <select name="ingredient-unite-{{i}}" data-dtype="String">
          {{#select ingredient.unite}}
          {{#each ../INGREDIENT_UNITS as |label key|}}
          <option value="{{key}}">{{label}}</option>
          {{/each}}
          {{/select}}
        </select>
        <label class="checkbox-label">
          <input type="checkbox" name="ingredient-consommable-{{i}}" {{checked ingredient.consommable}}> Cons.
        </label>
        <button type="button" data-action="deleteIngredient" data-index="{{i}}" data-tooltip="Supprimer"><i class="fas fa-trash"></i></button>
      </li>
      {{/each}}
    </ul>
    {{else}}
    <p class="ingredients-empty">Aucun ingrédient défini.</p>
    {{/if}}
  </fieldset>
  <fieldset>
    <legend>Résultat</legend>
    <div class="resultat-fields flexrow">
      <select name="system.resultat-type" data-dtype="String">
        {{#select parsedResultat.type}}
        {{#each resultatTypes as |label key|}}
        <option value="{{key}}">{{label}}</option>
        {{/each}}
        {{/select}}
      </select>
      <input type="text" name="system.resultat-name" value="{{parsedResultat.name}}" placeholder="Nom de l'item">
      <input type="number" name="system.resultat-quantite" value="{{parsedResultat.quantite}}" min="1">
    </div>
  </fieldset>
  {{>"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-description.hbs"}}
  </div>
</section>
