<section
    class='tab {{tabs.partyMembers.cssClass}} {{tabs.partyMembers.id}}'
    data-tab='{{tabs.partyMembers.id}}'
    data-group='{{tabs.partyMembers.group}}'
>

    <div class="actions-section">
        <button data-action="tagTeamRoll" class="{{#if tagTeamActive}}active-action{{/if}}">
            <i class="fa-solid fa-user-group"></i>
            <span>{{localize "DAGGERHEART.APPLICATIONS.TagTeamSelect.title"}}</span>
        </button>
        <button data-action="groupRoll" class="{{#if groupRollActive}}active-action{{/if}}">
            <i class="fa-solid fa-users"></i>
            <span>{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.title"}}</span>
        </button>
        <button data-action="triggerRest"  data-action="triggerRest" data-type="shortRest">
            <i class="fa-solid fa-utensils"></i>
            <span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}</span>
        </button>
        <button data-action="triggerRest"  data-type="longRest">
            <i class="fa-solid fa-bed"></i>
            <span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.longRest.title"}}</span>
        </button>
    </div>

    {{#if @root.showStats}}
        <ul class="actors-list">
            {{#each partyMembers as |member id|}}
                <li class="actor-resources">
                    <div class="actor-img-frame">
                        <img class="actor-img" src="{{member.img}}">
                        {{#if member.weapons}}
                            <div class="equipped-weapons">
                                {{#each member.weapons as |weapon|}}
                                    <img src="{{weapon.img}}" data-tooltip="{{weapon.name}}"/>
                                {{/each}}
                            </div>
                        {{/if}}
                        {{#if member.evasion includeZero=true}}
                            <div class="evasion" data-tooltip="DAGGERHEART.GENERAL.evasion">{{member.evasion}}</div>
                        {{/if}}
                        {{#if member.difficulty includeZero=true}}
                            <div class="evasion" data-tooltip="DAGGERHEART.GENERAL.difficulty">{{member.difficulty}}</div>
                        {{/if}}
                        {{#unless (eq member.type 'companion')}}
                            <div class="threshold-section">
                                <h4 class="threshold-label">{{localize "DAGGERHEART.ACTORS.Party.Thresholds.minor"}}</h4>
                                <h4 class="threshold-value">{{member.damageThresholds.major}}</h4>
                                <h4 class="threshold-label">{{localize "DAGGERHEART.ACTORS.Party.Thresholds.major"}}</h4>
                                <h4 class="threshold-value">{{member.damageThresholds.severe}}</h4>
                                <h4 class="threshold-label">{{localize "DAGGERHEART.ACTORS.Party.Thresholds.severe"}}</h4>
                            </div>
                        {{/unless}}
                    </div>
                    <header>
                        <h2 class="actor-name">
                            <a data-action="openDocument" data-uuid="{{member.uuid}}">{{member.name}}</a>
                            <a class="delete-icon" data-action="deletePartyMember" data-uuid="{{member.uuid}}"><i class="fa-regular fa-times" inert></i></a>
                        </h2>
                        <div>
                            {{#unless (or (eq member.type 'companion') (eq member.type 'adversary')) }}
                                <div class="hope-section">
                                    <h4>{{localize "DAGGERHEART.GENERAL.hope"}}</h4>
                                    {{#times member.resources.hope.max}}
                                        <span class='hope-value' data-action='toggleHope' data-actor-id="{{member.uuid}}" data-value="{{add this 1}}">
                                            {{#if (gte member.resources.hope.value (add this 1))}}
                                                <i class='fa-solid fa-diamond'></i>
                                            {{else}}
                                                <i class='fa-regular fa-circle'></i>
                                            {{/if}}
                                        </span>
                                    {{/times}}
                                </div>
                            {{/unless}}
                        </div>
                        {{#if member.subtitle}}
                            <span class="subtitle">{{member.subtitle}}</span>
                        {{/if}}
                    </header>
                    <section class="body">
                        <section class="resources">
                            {{#unless (eq member.type 'companion') }}
                                <div class="slot-section">
                                    <div class="slot-label" data-tooltip="DAGGERHEART.GENERAL.HitPoints.plural">
                                        <span class="label">
                                            <i class="fa-solid fa-heart" inert></i>
                                        </span>
                                        <span class="value">
                                            <span class="current">{{member.resources.hitPoints.value}}</span>
                                            / 
                                            <span class="max">{{member.resources.hitPoints.max}}</span>
                                        </span>
                                    </div>
                                    <div class="slot-bar">
                                        {{#times member.resources.hitPoints.max}}
                                            <span class='slot {{#if (gte member.resources.hitPoints.value (add this 1))}}filled{{/if}}'
                                            data-action='toggleHitPoints' data-actor-id="{{member.uuid}}" data-value="{{add this 1}}">
                                            </span>
                                        {{/times}}
                                    </div>
                                </div>
                            {{/unless}}

                            <div class="slot-section">
                                <div class="slot-label" data-tooltip="DAGGERHEART.GENERAL.stress">
                                    <span class="label">
                                        <i class="fa-solid fa-bolt" inert></i>
                                    </span>
                                    <span class="value">
                                        <span class="current">{{member.resources.stress.value}}</span>
                                        / 
                                        <span class="max">{{member.resources.stress.max}}</span>
                                    </span>
                                </div>
                                <div class="slot-bar">
                                    {{#times member.resources.stress.max}}
                                        <span class='slot {{#if (gte member.resources.stress.value (add this 1))}}filled{{/if}}'
                                        data-action='toggleStress' data-actor-id="{{member.uuid}}" data-value="{{add this 1}}">
                                        </span>
                                    {{/times}}
                                </div>
                            </div>

                            {{#if member.armorScore.max}}
                                <div class="slot-section">
                                    <div class="slot-label" data-tooltip="DAGGERHEART.GENERAL.armorSlots">
                                        <span class="label">
                                            <i class="fa-solid fa-shield" inert></i>
                                        </span>
                                        <span class="value">
                                            <span class="current">{{member.armorScore.value}}</span>
                                            / 
                                            <span class="max">{{member.armorScore.max}}</span>
                                        </span>
                                    </div>
                                    <div class="slot-bar">
                                        {{#times member.armorScore.max}}
                                            <a class='armor-slot' data-action='toggleArmorSlot' data-actor-id="{{member.uuid}}" data-value="{{add this 1}}">
                                            {{#if (gte member.armorScore.value (add this 1))}}
                                                <i class="fa-solid fa-shield"></i>
                                            {{else}}
                                                <i class="fa-solid fa-shield-halved"></i>
                                            {{/if}}
                                            </a>
                                        {{/times}}
                                    </div>
                                </div>
                            {{/if}}
                        </section>
                        {{#if member.traits}}
                            <div class="traits">
                                {{#each member.traits as |trait|}}
                                    <span class="trait">
                                        <span class="label">{{trait.label}}</span>
                                        <span class="value">{{trait.value}}</span>
                                    </span>
                                {{/each}}
                            </div>
                        {{/if}}
                    </section>
                </li>
            {{/each}}
        </ul>
    {{else}}
        <ul class="actors-list limited">
            {{#each partyMembers as |member id|}}
                <li class="actor-resources">
                    <div class="actor-img-frame">
                        <img class="actor-img" src="{{member.img}}">
                    </div>
                    <header>
                        <h2 class="actor-name">
                            <a data-action="openDocument" data-uuid="{{member.uuid}}">{{member.name}}</a>
                            <a class="delete-icon" data-action="deletePartyMember" data-uuid="{{member.uuid}}"><i class="fa-regular fa-times" inert></i></a>
                        </h2>
                        {{#if member.subtitle}}
                            <span class="subtitle">{{member.subtitle}}</span>
                        {{/if}}
                    </header>
                </li>
            {{/each}}
        </ul>
    {{/if}}
    {{#unless document.system.partyMembers.length}}
        <div class="actors-dragger">
            <span>{{localize "DAGGERHEART.GENERAL.dropActorsHere"}}</span>
        </div>
    {{/unless}}
</section>
