{{!-- ======================================================================== --}}
{{!-- INLINE PARTIAL DEFINITIONS --}}
{{!-- ======================================================================== --}}

{{!--
!-- Base template to display a value with unit.
!-- @param unitDatum: the object to display; must have a value and a unit attribute
!-- @param titleKey: The key of the localized title to use.
!-- @param unitNames: mapping of allowed unitDatum.unit values to localized unit name
!-- @param unitAbbrs: mapping of allowed unitDatum.unit values to unit abbreviation
--}}
{{#*inline "unit"}}
<div title="{{localize titleKey}} [{{lookup unitNames unitDatum.unit}}]">
    {{#if unitDatum.value }}
    {{unitDatum.value}}&thinsp;{{lookup unitAbbrs unitDatum.unit}}
    {{else}}-{{/if}}
</div>
{{/inline}}

{{!--
!-- Two templates based on the "unit" template for displaying values with unit.
!-- Both accept a `config` object holding the unitNames and unitAbbr instead of
!-- directly handing over the latter two.
!-- @param titleKey: The key of the localized title to use.
--}}
{{#*inline "temporalUnit"}}
{{> unit unitNames=config.i18n.temporalUnits unitAbbrs=config.i18n.temporalUnitsAbbr unitDatum=unitDatum
titleKey=titleKey}}
{{/inline}}

{{#*inline "distanceUnit"}}
{{> unit unitNames=config.i18n.distanceUnits unitAbbrs=config.i18n.distanceUnitsAbbr unitDatum=unitDatum
titleKey=titleKey}}
{{/inline}}


{{!-- ======================================================================== --}}


<div class="tab spells" data-group="primary" data-tab="spells">
    <ol class="ds4-item-list ds4-item-list--spell item-list">
        {{#> systems/ds4/templates/actor/partials/item-list-header.hbs isEquipable=true hideDescription=true}}
        {{!-- spell type --}}
        <div title="{{localize 'DS4.SpellType'}}">{{localize 'DS4.SpellTypeAbbr'}}</div>

        {{!-- spell bonus --}}
        <div title="{{localize 'DS4.SpellBonus'}}">{{localize 'DS4.SpellBonusAbbr'}}</div>

        {{!-- max. distance --}}
        <div title="{{localize 'DS4.SpellMaxDistance'}}"><i class="fas fa-ruler"></i></div>

        {{!-- duration --}}
        <div title="{{localize 'DS4.SpellDuration'}}"><i class="far fa-clock"></i></div>

        {{!-- cooldown duration --}}
        <div title="{{localize 'DS4.SpellCooldownDuration'}}"><i class="fas fa-hourglass-half"></i></div>
        {{/systems/ds4/templates/actor/partials/item-list-header.hbs}}
        {{#each itemsByType.spell as |itemData id|}}
        {{#> systems/ds4/templates/actor/partials/item-list-entry.hbs itemData=itemData isEquipable=true
        hideDescription=true}}
        {{!-- spell type --}}
        <div class="ds4-item-list__image"
            style="background-image: url('{{lookup ../../config.icons.spellTypes itemData.data.spellType}}')"
            title="{{lookup ../../config.i18n.spellTypes itemData.data.spellType}}">
        </div>

        {{!-- spell bonus --}}
        <input class="ds4-item-list__editable item-change" type="text" data-dtype="String" data-property="data.bonus"
            value="{{itemData.data.bonus}}" title="{{localize 'DS4.SpellBonus'}}" />

        {{!-- max. distance --}}
        {{> distanceUnit titleKey='DS4.SpellMaxDistance' unitDatum=itemData.data.maxDistance
        config=../../config}}

        {{!-- duration --}}
        {{> temporalUnit titleKey='DS4.SpellDuration' unitDatum=itemData.data.duration config=../../config}}

        {{!-- cooldown duration --}}
        {{> temporalUnit titleKey='DS4.SpellCooldownDuration' unitDatum=itemData.data.cooldownDuration
        config=../../config}}
        {{/systems/ds4/templates/actor/partials/item-list-entry.hbs}}
        {{/each}}
    </ol>
    {{!-- add button --}}
    {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='spell' }}
</div>