<div class="tab spells" data-group="primary" data-tab="spells">
    <div class="toggles section-container headerless">
        {{#if toggles.spellcasting}}{{> "systems/pf2e/templates/actors/partials/toggles.hbs" toggles=toggles.spellcasting}}{{/if}}
    </div>
    <ol class="entries-list" data-foundry-list>
        {{#each spellcastingEntries as |entry eid|}}
            <li
                class="spellcasting-entry item item-container"
                data-spellcasting-entry
                data-item-id="{{entry.id}}"
                {{#if entry.hasCollection}}data-container-type="spellcastingEntry" data-container-id="{{entry.id}}"{{/if}}
            >
                <div class="header">
                    {{#unless entry.isEphemeral}}
                        <a class="drag-handle" data-drag-handle><i class="fa-solid fa-fw fa-bars"></i></a>
                    {{/unless}}
                    {{#if entry.isPrepared}}
                        <a
                            class="skill-name prepared-toggle"
                            data-action="open-spell-preparation"
                            data-tooltip="PF2E.ToggleSpellVisibilityTitle"
                        ><i class="fa-duotone fa-book-sparkles"></i></a>
                    {{/if}}

                    <h4 class="name">
                        <input type="text" data-item-id="{{entry.id}}" data-item-property="name" value="{{entry.name}}"{{#if entry.isEphemeral}} readonly{{/if}} />
                    </h4>
                    {{#unless entry.isRitual}}
                        <div class="spellDC inline-field">
                            <label data-tooltip="{{entry.statistic.dc.breakdown}}">{{localize "PF2E.NPC.Spells.DCLabel"}}</label>
                            {{#if entry.isEphemeral}}
                                <span
                                    class="modifier adjustable{{#if entry.adjustedHigher.dc}} adjusted-higher{{/if}}{{#if entry.adjustedLower.dc}} adjusted-lower{{/if}}"
                                >{{entry.statistic.dc.value}}</span>
                            {{else}}
                                <input type="number"
                                    class="dc-input modifier adjustable{{#if entry.adjustedHigher.dc}} adjusted-higher{{/if}}{{#if entry.adjustedLower.dc}} adjusted-lower{{/if}}"
                                    value="{{entry.statistic.dc.value}}"
                                    {{#if entry.isEphemeral}}readonly{{/if}}
                                    placeholder="0"
                                    data-display-value="{{entry.statistic.dc.value}}"
                                    data-base-property="data.items.{{eid}}.system.spelldc.dc"
                                />
                            {{/if}}
                        </div>
                        <div class="spellAttack inline-field">
                            <label class="rollable" title="{{entry.statistic.check.breakdown}}">{{localize "PF2E.NPC.Spells.AttackLabel"}}</label>
                            {{#if entry.isEphemeral}}
                                <span
                                    class="modifier adjustable{{#if entry.adjustedHigher.mod}} adjusted-higher{{/if}}{{#if entry.adjustedLower.mod}} adjusted-lower{{/if}}"
                                >{{entry.statistic.check.mod}}</span>
                            {{else}}
                                <input type="number"
                                    class="attack-input modifier adjustable{{#if entry.adjustedHigher.mod}} adjusted-higher{{/if}}{{#if entry.adjustedLower.mod}} adjusted-lower{{/if}}"
                                    value="{{numberFormat entry.statistic.check.mod decimals=0}}"
                                    {{#if entry.isEphemeral}}readonly{{/if}}
                                    placeholder="0"
                                    data-display-value="{{entry.statistic.check.mod}}"
                                    data-base-property="data.items.{{eid}}.system.spelldc.value"
                                />
                            {{/if}}
                        </div>
                    {{/unless}}

                    {{#if (and ../editable (not entry.isEphemeral))}}
                        <div class="item-controls">
                            {{#if (or entry.isPrepared entry.isSpontaneous entry.isInnate)}}
                                <a data-action="toggle-show-slotless-ranks" data-tooltip="PF2E.ToggleSlotlessSpellLevelsTitle">
                                    <i class="{{#if entry.showSlotlessLevels}}fa-solid{{else}}fa-regular{{/if}} fa-fw fa-list-alt"></i>
                                </a>
                            {{/if}}
                            {{#unless entry.isRitual}}
                                <a data-action="spellcasting-edit" data-tooltip="PF2E.EditItemTitle"><i class="fa-solid fa-fw fa-edit"></i></a>
                                <a data-action="spellcasting-remove" data-tooltip="PF2E.RemoveSpellcastingEntryTitle" data-type="{{eid}}"><i class="fa-solid fa-fw fa-trash"></i></a>
                            {{/unless}}
                        </div>
                    {{/if}}
                </div>
                {{#if entry.hasCollection}}
                    <div class="body">
                        {{> "systems/pf2e/templates/actors/partials/spell-collection.hbs" entry=entry}}
                    </div>
                {{/if}}
            </li>

        {{/each}}
    </ol>

    <div class="footer">
        <button
            type="button"
            class="spellcasting-create blue"
            data-action="spellcasting-create"
        ><i class="fa-solid fa-plus"></i> {{localize "PF2E.AddSpellcastingEntryTitle"}}</button>
    </div>
</div>
