<form class="{{cssClass}} flexcol" autocomplete="off">

    {{!-- NPC Sheet Header --}}
    <header class="sheet-header flexrow">
        <img class="profile" src="{{actor.img}}" data-tooltip="{{actor.name}}" data-edit="img"/>

        <section class="header-details flexrow">
            {{> "dnd5e.actor-warnings"}}

            <h1 class="charname">
                <input name="name" type="text" value="{{actor.name}}" placeholder="{{ localize 'DND5E.Name' }}"/>
            </h1>

            <aside class="header-exp flexcol">
                <div class="cr">
                    <label>{{ localize "DND5E.AbbreviationCR" }}</label>
                    <input name="system.details.cr" type="text" value="{{labels.cr}}" placeholder="1"/>
                </div>
                <div class="experience">
                    <span>{{system.details.xp.value}} XP</span>
                </div>
                <div class="proficiency">
                    <span>
                        {{ localize "DND5E.Proficiency" }} {{labels.proficiency}}
                    </span>
                </div>
            </aside>

            {{!-- Character Summary --}}
            <ul class="summary flexrow">
                <li class="size">
                    <span>{{lookup config.actorSizes system.traits.size}}</span>
                </li>
                <li class="alignment">
                    <input type="text" name="system.details.alignment" value="{{system.details.alignment}}" placeholder="{{ localize 'DND5E.Alignment' }}"/>
                </li>
                <li class="creature-type">
                    <span data-tooltip="{{labels.type}}">{{labels.type}}</span>
                    <a class="config-button" data-action="type" data-tooltip="DND5E.CreatureTypeConfig">
                        <i class="fas fa-cog"></i>
                    </a>
                </li>
                <li class="source">
                    <input type="text" name="system.details.source" value="{{system.details.source}}"
                           placeholder="{{ localize 'DND5E.Source' }}"/>
                </li>
            </ul>

            {{!-- Header Attributes --}}
            <ul class="attributes flexrow">
                <li class="attribute health">
                    <h4 class="attribute-name box-title">{{ localize "DND5E.HitPoints" }}</h4>
                    <a class="config-button" data-action="hit-points" data-tooltip="DND5E.HitPointsConfig">
                        <i class="fas fa-cog"></i>
                    </a>
                    <div class="attribute-value multiple">
                        <input name="system.attributes.hp.value" type="text" value="{{hp.value}}" placeholder="10"
                            data-tooltip="DND5E.HitPointsCurrent" data-dtype="Number">
                        <span class="sep"> / </span>
                        <input name="system.attributes.hp.max" type="text" value="{{hp.max}}" placeholder="10"
                            data-tooltip="DND5E.HitPointsMax" data-dtype="Number">
                    </div>
                    <footer class="attribute-footer flexrow">
                        <input name="system.attributes.hp.temp" type="text" class="temphp"
                               placeholder="+{{ localize 'DND5E.Temp' }}" value="{{hp.temp}}"
                               data-tooltip="DND5E.HitPointsTemp">
                        <input name="system.attributes.hp.tempmax" type="text" class="temphp"
                               placeholder="+{{ localize 'DND5E.Max' }}" value="{{hp.tempmax}}"
                               data-tooltip="DND5E.HitPointsTempMax">
                    </footer>
                </li>

                <li class="attribute armor">
                    <h4 class="attribute-name box-title">{{ localize "DND5E.ArmorClass" }}</h4>
                    <a class="config-button" data-action="armor" data-tooltip="DND5E.ArmorConfig">
                        <i class="fas fa-cog"></i>
                    </a>
                    <div class="attribute-value" data-attribution="attributes.ac"
                        data-attribution-caption="DND5E.ArmorClass" data-tooltip-direction="DOWN">
                        <span>{{system.attributes.ac.value}}</span>
                    </div>
                    <footer class="attribute-footer">
                        <span>{{labels.armorType}}</span>
                    </footer>
                </li>

                <li class="attribute movement">
                    <h4 class="attribute-name box-title">{{ localize "DND5E.Movement" }}</h4>
                    <a class="config-button" data-action="movement" data-tooltip="DND5E.MovementConfig">
                        <i class="fas fa-cog"></i>
                    </a>
                    <div class="attribute-value">
                        <span>{{movement.primary}}</span>
                    </div>
                    <footer class="attribute-footer">
                        <span>{{movement.special}}</span>
                    </footer>
                </li>
            </ul>
        </section>
    </header>

    {{!-- NPC Sheet Navigation --}}
    <nav class="sheet-navigation tabs" data-group="primary">
        <a class="item active" data-tab="attributes">{{ localize "DND5E.Attributes" }}</a>
        <a class="item" data-tab="features">{{ localize "DND5E.Features" }}</a>
        <a class="item" data-tab="spellbook">{{ localize "DND5E.Spellbook" }}</a>
        <a class="item" data-tab="effects">{{ localize "DND5E.Effects" }}</a>
        <a class="item" data-tab="biography">{{ localize "DND5E.Biography" }}</a>
    </nav>

    {{!-- NPC Sheet Body --}}
    <section class="sheet-body">
        <div class="tab attributes flexrow" data-group="primary" data-tab="attributes">

            {{!-- Ability Scores --}}
            <ul class="ability-scores flexrow">
            {{#each abilities as |ability id|}}
                <li class="ability {{#if ability.proficient}}proficient{{/if}}" data-ability="{{id}}">
                    <h4 class="ability-name box-title rollable">{{ability.label}}</h4>
                    <input type="text" value="{{ability.value}}" name="{{concat "system.abilities." id ".value"}}"
                        class="ability-score" placeholder="10" data-dtype="Number">
                    <div class="ability-modifiers flexrow">
                        <span class="ability-mod" data-tooltip="DND5E.Modifier">
                            {{numberFormat ability.mod decimals=0 sign=true}}
                        </span>
                        <input type="hidden" name="system.abilities.{{id}}.proficient" value="{{ability.baseProf}}"
                               data-dtype="Number"/>
                        <a class="proficiency-toggle ability-proficiency" data-tooltip="DND5E.Proficiency">
                            {{{ability.icon}}}
                        </a>
                        <span class="ability-save" data-tooltip="DND5E.SavingThrow">
                            {{numberFormat ability.save decimals=0 sign=true}}
                        </span>
                    </div>
                    <a class="config-button" data-action="ability" data-tooltip="DND5E.AbilityConfigure">
                        <i class="fas fa-cog"></i>
                    </a>
                </li>
            {{/each}}
            </ul>

            {{!-- Skills --}}
            <ul class="skills-list">
            {{#each config.skills as |obj s|}}
            {{#with (lookup ../skills s) as |skill|}}
                <li class="skill proficiency-row flexrow {{#if skill.value}}proficient{{/if}}" data-property="skills"
                    data-key="{{s}}">
                    <input type="hidden" name="system.skills.{{s}}.value"
                           value="{{skill.baseValue}}" data-dtype="Number">
                    <input type="hidden" name="system.skills.{{s}}.ability" value="{{skill.ability}}">
                    <a class="proficiency-toggle skill-proficiency" data-tooltip="{{skill.hover}}">{{{skill.icon}}}</a>
                    <div class="skill-name-controls">
                      <h4 class="skill-name rollable">{{skill.label}}</h4>
                      <a class="config-button" data-action="skill" data-tooltip="DND5E.SkillConfigure">
                          <i class="fas fa-cog"></i>
                      </a>
                    </div>
                    <span class="skill-ability">{{skill.abbreviation}}</span>
                    <span class="skill-mod" data-tooltip="{{localize 'DND5E.SkillModifierHint' skill=skill.label}}">
                        {{numberFormat skill.total decimals=0 sign=true}}
                    </span>
                    <span class="skill-passive" data-tooltip="{{localize 'DND5E.SkillPassiveHint' skill=skill.label}}">
                        ({{skill.passive}})
                    </span>
                </li>
            {{/with}}
            {{/each}}
            </ul>

            <section class="center-pane flexcol">

                {{!-- Legendary Actions --}}
                <div class="counters">
                    <div class="counter flexrow legendary">
                        <h4>{{ localize "DND5E.LegAct" }}</h4>
                        <div class="counter-value">
                            <input name="system.resources.legact.value" type="text" step="any"
                                   value="{{system.resources.legact.value}}" placeholder="0"
                                   data-tooltip="DND5E.LegActRemaining" data-dtype="Number">
                            <span class="sep">/</span>
                            {{numberInput system.resources.legact.max name="system.resources.legact.max" min=0 step=1
                                          placeholder=0}}
                        </div>
                    </div>
                    <div class="counter flexrow legendary">
                        <h4>{{ localize "DND5E.LegRes" }}</h4>
                        <div class="counter-value">
                            <input name="system.resources.legres.value" type="text" step="any"
                                   value="{{system.resources.legres.value}}" placeholder="0"
                                   data-tooltip="DND5E.LegResRemaining" data-dtype="Number">
                            <span class="sep">/</span>
                            {{numberInput system.resources.legres.max name="system.resources.legres.max" min=0 step=1
                                          placeholder=0}}
                        </div>
                    </div>
                    <div class="counter flexrow lair">
                        <h4>{{ localize "DND5E.LairAct" }}</h4>
                        <div class="counter-value">
                            <input name="system.resources.lair.value" type="checkbox"
                                   value="{{system.resources.lair.value}}"
                                   data-dtype="Boolean" {{checked system.resources.lair.value}}>
                            <input name="system.resources.lair.initiative" type="number" step="any"
                                   value="{{system.resources.lair.initiative}}"
                                   placeholder="20" data-tooltip="DND5E.LairActionInitiative">
                        </div>
                    </div>
                </div>

                {{!-- Traits --}}
                {{> "dnd5e.actor-traits"}}
            </section>
        </div>

        {{!-- Features Tab --}}
        <div class="tab features flexcol" data-group="primary" data-tab="features">
            {{> "dnd5e.actor-features" sections=features}}
        </div>

        {{!-- Spellbook Tab --}}
        <div class="tab spellbook flexcol" data-group="primary" data-tab="spellbook">
            {{> "dnd5e.actor-spellbook"}}
        </div>

        {{!-- Effects Tab --}}
        <div class="tab effects flexcol" data-group="primary" data-tab="effects">
            {{> "dnd5e.active-effects"}}
        </div>

        {{!-- Biography Tab --}}
        <div class="tab biography flexcol" data-group="primary" data-tab="biography">
            {{editor biographyHTML target="system.details.biography.value" button=true editable=editable
                     engine="prosemirror" collaborate=false}}
        </div>
    </section>
</form>
