<fieldset class="basics">
    <div class="form-group">
        <label>{{localize "PF2E.HitPointsHeader"}}</label>
        <input type="number" name="system.hp" min="6" max="12" value="{{data.hp}}">
    </div>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.Actor.Character.Attribute.Key"}}
            <a
                class="tag-selector"
                data-tag-selector="basic"
                data-title="PF2E.Actor.Character.Attribute.Key"
                data-config-types="abilities"
                data-property="system.keyAbility"
                data-no-custom="true"
            ><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each selectedKeyAbility}}
                <span class="tag-legacy {{@key}}">{{localize this}}</span>
            {{/each}}
        </ul>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.PerceptionLabel"}}</label>
        <select name="system.perception" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.perception localize=true}}
        </select>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.SavesHeader"}}</legend>

    <div class="form-group">
        <label>{{localize "PF2E.SavesFortitude"}}</label>
        <select name="system.savingThrows.fortitude" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.savingThrows.fortitude localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.SavesReflex"}}</label>
        <select name="system.savingThrows.reflex" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.savingThrows.reflex localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.SavesWill"}}</label>
        <select name="system.savingThrows.will" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.savingThrows.will localize=true}}
        </select>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.Actor.Character.Proficiency.Attack.Title"}}</legend>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Attack.Simple"}}</label>
        <select name="system.attacks.simple" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.attacks.simple localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Attack.Martial"}}</label>
        <select name="system.attacks.martial" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.attacks.martial localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Attack.Advanced"}}</label>
        <select name="system.attacks.advanced" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.attacks.advanced localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Attack.Unarmed"}}</label>
        <select name="system.attacks.unarmed" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.attacks.unarmed localize=true}}
        </select>
    </div>

    <div class="form-group other-weapons">
        <label>{{localize "PF2E.WeaponTypeSpecial"}}</label>
        <input type="text" name="system.attacks.other.name" value="{{data.attacks.other.name}}">
        <select name="system.attacks.other.rank" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.attacks.other.rank localize=true}}
        </select>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.Actor.Character.Proficiency.Defense.Title"}}</legend>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Defense.Light"}}</label>
        <select name="system.defenses.light" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.defenses.light localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Defense.Medium"}}</label>
        <select name="system.defenses.medium" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.defenses.medium localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Defense.Heavy"}}</label>
        <select name="system.defenses.heavy" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.defenses.heavy localize=true}}
        </select>
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Character.Proficiency.Defense.Unarmored"}}</label>
        <select name="system.defenses.unarmored" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.defenses.unarmored localize=true}}
        </select>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.Item.Spell.Plural"}}</legend>

    <div class="form-group">
        <label>{{localize "PF2E.Actor.Creature.Spellcasting.Label"}}</label>
        <select name="system.spellcasting" data-dtype="Number">
            {{selectOptions proficiencyChoices selected=data.spellcasting localize=true}}
        </select>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.SkillsLabel"}}</legend>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.TrainedSkillsLabel"}}
            <a class="tag-selector" data-tag-selector="basic" data-title="PF2E.TrainedSkillsLabel" data-config-types="skills" data-property="system.trainedSkills"><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each trainedSkills}}
                {{#if this.selected}}
                    <span class="tag-legacy {{@key}}">{{this.label}}</span>
                {{/if}}
            {{/each}}
        </ul>
    </div>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.SkillIncreaseLevels"}}
            <a
                class="tag-selector"
                data-tag-selector="basic"
                data-title="PF2E.SkillIncreaseLevels"
                data-config-types="levels"
                data-property="system.skillIncreaseLevels"
                data-no-custom="true"
            ><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each skillIncreaseLevels}}
                <span class="tag-legacy {{@key}}">{{this.label}}</span>
            {{/each}}
        </ul>
    </div>


    <div class="form-group additional-language">
        <label>{{localize "PF2E.AdditionalSkills"}}</label>
        <input type="number" name="system.trainedSkills.additional" value="{{data.trainedSkills.additional}}">
        <span>{{localize "PF2E.AdditionalLanguagePlusInt"}}</span>
    </div>
</fieldset>

<fieldset>
    <legend>{{localize "PF2E.Item.Feat.Plural"}}</legend>
    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.AncestryFeatLevels"}}
            <a class="tag-selector" data-tag-selector="basic" data-title="PF2E.AncestryFeatLevels" data-config-types="levels" data-property="system.ancestryFeatLevels" data-no-custom="true"><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each ancestryFeatLevels}}
                {{#if this.selected}}
                    <span class="tag-legacy {{@key}}">{{this.label}}</span>
                {{/if}}
            {{/each}}
        </ul>
    </div>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.ClassFeatLevels"}}
            <a class="tag-selector" data-tag-selector="basic" data-title="PF2E.ClassFeatLevels" data-config-types="levels" data-property="system.classFeatLevels" data-no-custom="true"><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each classFeatLevels}}
                <span class="tag-legacy {{@key}}">{{this.label}}</span>
            {{/each}}
        </ul>
    </div>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.GeneralFeatLevels"}}
            <a class="tag-selector" data-tag-selector="basic" data-title="PF2E.GeneralFeatLevels" data-config-types="levels" data-property="system.generalFeatLevels" data-no-custom="true"><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each generalFeatLevels}}
                <span class="tag-legacy {{@key}}">{{this.label}}</span>
            {{/each}}
        </ul>
    </div>

    <div class="form-group form-group-trait">
        <label class="pf-title">
            {{localize "PF2E.SkillFeatLevels"}}
            <a class="tag-selector" data-tag-selector="basic" data-title="PF2E.SkillFeatLevels" data-config-types="levels" data-property="system.skillFeatLevels" data-no-custom="true"><i class="fa-solid fa-edit"></i></a>
        </label>

        <ul class="abc-traits-list">
            {{#each skillFeatLevels}}
                <span class="tag-legacy {{@key}}">{{this.label}}</span>
            {{/each}}
        </ul>
    </div>
</fieldset>

<fieldset data-valid-drops="classfeature">
    <legend>{{localize "PF2E.ClassFeatures"}}</legend>
    <div class="item-ref-group">
        {{#> abcItems}}{{/abcItems}}
        {{#unless data.items}}{{localize PF2E.DragDropFeats}}{{/unless}}
    </div>
</fieldset>

{{~#*inline "abcItem"~}}
    <li data-pack-id="{{item.pack}}" data-index="{{i}}" data-item-uuid="{{item.uuid}}">
        <img src="{{item.img}}">
        <a class="name">
            {{item.name}}{{#if item.fromWorld}}<i class="fa-solid fa-globe" data-tooltip="PF2E.Item.WorldItemWarning"></i>{{/if}}
        </a>
        <input type="number" class="level" value="{{item.level}}" name="system.items.{{i}}.level" />
        <input value="{{item.uuid}}" name="system.items.{{i}}.uuid" type="hidden" data-dtype="String" />
        <input value="{{item.name}}" name="system.items.{{i}}.name" type="hidden" data-dtype="String" />
        <a class="remove" data-action="remove"><i class="fa-solid fa-xmark"></i></a>
        {{#if item.items~}}
            {{#> abcItems item}}{{@partial-block}}items.{{i}}.{{/abcItems}}
        {{~/if}}
    </li>
{{~/inline~}}

{{~#*inline "abcItems"~}}
<ul class="item-refs">
    {{#each features}}
        {{#> abcItem item=this.item i=this.key}}{{@partial-block}}{{/abcItem}}
    {{/each}}
</ul>
{{~/inline~}}
