<form class="{{cssClass}}" autocomplete="off">
  {{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}

  <section class="sheet-body">
    <div class="flexcol form-group small-editor">
        {{editor description target="system.description" button=true owner=owner editable=(or isGM isOwner) engine="prosemirror"}}
    </div>
    <div class="form-group">
      <input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.illimite" {{#if system.illimite}}checked{{/if}}/>
      <span for="system.illimite">Quantité en vente illimitée</span>
    </div>
    <div class="flexcol">
      <ul class="item-list alterne-list">
        <li class="item flexrow list-item">
          <label class="flex-grow">A vendre</label>
          {{#unless system.illimite}}
          <label>Quantite</label>
          {{/unless}}
          <label>Prix (sols)</label>
          <div class="item-controls">
            {{#unless disabled}}
            <a class="sub-item-info-add" title="Utiliser le drag&amp;drop pour ajouter un objet dans la liste">
              <i class="fa-solid fa-circle-info"></i>
            </a>
            {{/unless}}
          </div>
        </li>
        {{#each system.items as |item key|}}
        <li class="item flexrow list-item service-item" data-item-id="{{item.id}}" data-pack="{{item.pack}}" data-key="{{key}}">
          <label class="flex-grow">
            {{#if item.img}}<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>{{/if}}
            {{> 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs'
            pack=item.pack id=item.id name=item.name}}
          </label>
          {{#unless @root.system.illimite}}
          <span class="flexrow">
            {{#unless @root.disabled}}
            <a class="sub-item-quantite-moins"><i class="fas fa-minus-square"></i></a>
            {{/unless}}
            <input {{@root.disabled}} type="number" class="sub-item-quantite" name="items[{{key}}].system.quantite" value="{{item.system.quantite}}" data-dtype="Number" />
            {{#unless @root.disabled}}
            <a class="sub-item-quantite-plus"><i class="fas fa-plus-square"></i></a>
            {{/unless}}
          </span>
          {{/unless}}
          <span class="flexrow">
            <input {{@root.disabled}} type="number" class="input-prix number-x3 sub-item-cout" name="items[{{key}}].system.cout" value="{{numberFormat item.system.cout decimals=2 sign=false}}" data-dtype="Number" />
          </span>
          <div class="item-controls">
            <a class="sub-item-acheter" title="Acheter"><i class="fa-regular fa-coins"></i></a>
            {{#unless @root.disabled}}
            <a class="sub-item-vendre" title="Vendre"><i class="fas fa-comments-dollar"></i></a>
            <a class="sub-item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
            {{/unless}}
          </div>
        </li>
        {{/each}}
      </ul>
    </div>
    {{#if isGM}}
    <br>
    <div class="flexcol">
      <span><label>Description (MJ seulement): </label></span>
      <div class="form-group medium-editor">
        {{editor descriptionmj target="system.descriptionmj" button=true owner=owner editable=true engine="prosemirror"}}
      </div>
    </div>
    {{/if}}
  </section>
</form>
