{{!--
{{> 'daggerheart.inventory-item' }}

Parameters:
- type {string} : The type of items in the list
- isActor {boolean} : Passed through to inventory-item partials.
- categoryAdversary {string} : Category adversary id.
- noExtensible {boolean} : If true, the inventory-item-content would be collapsable/extendible else it always be showed
- hideLabels {boolean} : If true, hide label-tags else show label-tags.
- hideTags {boolean} : If true, hide simple-tags else show simple-tags.
- hideTooltip {boolean} : If true, disables the tooltip on the item image.
- hideControls {boolean} : If true, hides the controls inside inventory-item partials.
- hideDescription {boolean} : If true, hides the item's description.
- hideResources {boolean} : If true, hides the item's resources.
- showActions {boolean} : If true show feature's actions.
--}}

<li class="inventory-item" data-item-id="{{item.id}}" {{#if (or (eq type 'action' ) (eq type 'attack' ))}}
  data-action-id="{{item.id}}" {{/if}} data-item-uuid="{{item.uuid}}" data-type="{{type}}" data-no-compendium-edit="{{noCompendiumEdit}}" draggable="true">
  <div class="inventory-item-header" {{#unless noExtensible}}data-action="toggleExtended" {{/unless}}>
    {{!-- Image --}}
    <div class="img-portait" data-action='{{ifThen (or (hasProperty item "use") (eq type ' attack')) "useItem" (ifThen
      (hasProperty item "toChat" ) "toChat" "editDoc" ) }}' {{#unless hideTooltip}} {{#if (eq type 'attack' )}}
      data-tooltip="#attack#{{item.actor.uuid}}" {{else}} data-tooltip="#item#{{item.uuid}}" {{/if}} {{/unless}}>
      <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" />
      <img class="roll-img" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20">
    </div>

    {{!-- Name & Tags --}}
    <div class="item-label">

      {{!-- Item Name --}}
      <div class="item-name">{{localize item.name}}</div>

      {{!-- Attack Tags Start --}}
      {{#if (eq type 'attack')}}
      <div class="item-tags">
        <div class="tag">
          {{localize 'DAGGERHEART.GENERAL.unarmed'}}
        </div>
        <div class="tag">
          {{localize 'DAGGERHEART.CONFIG.ActionType.action'}}
        </div>
      </div>
      {{!-- Attack Tags End --}}
      {{else}}
      {{!-- Other elements Tags Start --}}
        {{#with item}}
        {{#if (not ../hideTags)}}
        <div class="item-tags">
          {{#each this._getTags as |tag|}}
          <div class="tag">
            {{tag}}
          </div>
          {{/each}}
        </div>
        {{else if (not ../hideLabels)}}
        <div class="item-lables">
          <div class="label">
            {{#each this._getLabels as |label|}}
            {{ifThen label.value label.value label}}
            {{#each label.icons as |icon|}}
            <i class="fa-solid {{icon}}"></i>
            {{/each}}
            {{#if (not @last)}}
            <span>-</span>
            {{/if}}
            {{/each}}
          </div>
        </div>
        {{/if}}
        {{/with}}
      {{/if}}
      {{!-- Other elements Tags End --}}
    </div>

    {{!-- Simple Resource --}}
    {{#if (and (not hideResources) (eq item.system.resource.type 'simple'))}}
    {{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}}
    {{/if}}
    {{#if (and (not hideResources) item.system.quantity)}}
    <div class="item-resource">
      <input type="number" class="inventory-item-quantity" value="{{item.system.quantity}}" min="0" />
    </div>
    {{/if}}

    {{!-- Controls --}}
    {{#unless hideControls}}
    <div class="controls">
      {{#if isActor}}
      <a data-action="editDoc" data-tooltip="DAGGERHEART.UI.Tooltip.openActorWorld">
        <i class="fa-solid fa-globe"></i>
      </a>
      {{#if (eq type 'adversary')}}
      <a data-action='deleteAdversary' data-category="{{categoryAdversary}}" data-tooltip="CONTROLS.CommonDelete">
        <i class='fas fa-trash'></i>
      </a>
      {{/if}}
      {{else}}
      {{#if (eq type 'weapon')}}
      <a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem"
        data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
        <i class="fa-solid fa-hands"></i>
      </a>
      {{else if (eq type 'armor')}}
      <a class="{{#unless item.system.equipped}}unequipped{{/unless}}" data-action="toggleEquipItem"
        data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.equipped 'unequip' 'equip' }}">
        <i class="fa-solid fa-shield"></i>
      </a>
      {{else if (eq type 'domainCard')}}
      <a data-action="toggleVault"
        data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.system.inVault 'sendToLoadout' 'sendToVault' }}">
        <i class="fa-solid {{ifThen item.system.inVault 'fa-arrow-up' 'fa-arrow-down'}}"></i>
      </a>
      {{else if (eq type 'effect')}}
      <a data-action="toggleEffect"
        data-tooltip="DAGGERHEART.UI.Tooltip.{{ifThen item.disabled 'enableEffect' 'disableEffect' }}">
        <i class="{{ifThen item.disabled 'fa-solid fa-toggle-off' 'fa-solid fa-toggle-on'}}"></i>
      </a>
      {{/if}}
      {{#if (hasProperty item "toChat")}}
      <a data-action="toChat" data-tooltip="DAGGERHEART.UI.Tooltip.sendToChat">
        <i class="fa-regular fa-message"></i>
      </a>
      {{/if}}
      <a data-action="triggerContextMenu" data-tooltip="DAGGERHEART.UI.Tooltip.moreOptions">
        <i class="fa-solid fa-ellipsis-vertical"></i>
      </a>
      {{/if}}
    </div>
    {{/unless}}
  </div>
  <div class="inventory-item-content{{#unless noExtensible}} extensible{{/unless}}">
    {{!-- Description --}}
    {{#unless hideDescription}}
    <div class="invetory-description"></div>
    {{/unless}}
  </div>
  {{!-- Dice Resource --}}
  {{#if (and (not hideResources) (eq item.system.resource.type 'diceValue'))}}
  {{> "systems/daggerheart/templates/sheets/global/partials/item-resource.hbs"}}
  {{/if}}
  {{!-- Actions Buttons --}}
  {{#if (and showActions (eq item.type 'feature'))}}
  <div class="item-buttons">
    {{#each item.system.actions as | action |}}
    <button type="button" data-action="useItem" data-item-uuid="{{action.uuid}}">
      {{action.name}}
    </button>
    {{/each}}
  </div>
  {{/if}}
</li>