<section class="tab biography major" data-group="primary" data-tab="biography">
    {{#if (or document.isOwner biography.visibility.appearance)}}
        <header>
            <span>{{localize "PF2E.BiographyAppearance"}}</span>
            {{#if editable}}
                <a data-action="toggle-bio-visibility" data-section="appearance" data-tooltip="PF2E.Actor.Character.Biography.ToggleVisibility">
                    <i class="fa-solid fa-fw fa-eye{{#unless biography.visibility.appearance}}-slash{{/unless}}"></i>
                </a>
            {{/if}}
        </header>
        <section class="appearance-details{{#if editable}} editable{{/if}}">
            <div class="bio appearance">
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.appearance target="system.details.biography.appearance" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
            <label class="pc pc_height">
                <span class="details-label">{{localize "PF2E.Height"}}</span>
                <input type="text" class="details-input" id="{{options.id}}-pc-height" name="system.details.height.value" value="{{data.details.height.value}}" />
            </label>
            <label class="pc pc_weight">
                <span class="details-label">{{localize "PF2E.Weight"}}</span>
                <input type="text" class="details-input" id="{{options.id}}-pc-weight" name="system.details.weight.value" value="{{data.details.weight.value}}" />
            </label>
        </section>
    {{/if}}

    {{#if (or document.isOwner biography.visibility.backstory)}}
        <header>
            <span>{{localize "PF2E.BiographyBackStory"}}</span>
            {{#if editable}}
                <a data-action="toggle-bio-visibility" data-section="backstory" data-tooltip="PF2E.Actor.Character.Biography.ToggleVisibility">
                    <i class="fa-solid fa-fw fa-eye{{#unless biography.visibility.backstory}}-slash{{/unless}}"></i>
                </a>
            {{/if}}
        </header>
        <section{{#if editable}} class="editable"{{/if}}>
            <div class="bio backstory">
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.backstory target="system.details.biography.backstory" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
            <div class="bio birth-place">
                <label class="details-label" for="{{document.uuid}}-birth-place">{{localize "PF2E.BiographyBirthPlace"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-birth-place" name="system.details.biography.birthPlace" value="{{biography.birthPlace}}" />
                </span>
            </div>
        </section>
    {{/if}}

    {{#if (or document.isOwner biography.visibility.personality)}}
        <header>
            <span>{{localize "PF2E.BiographyPersonalityHeader"}}</span>
            {{#if editable}}
                <a data-action="toggle-bio-visibility" data-section="personality" data-tooltip="PF2E.Actor.Character.Biography.ToggleVisibility">
                    <i class="fa-solid fa-fw fa-eye{{#unless biography.visibility.personality}}-slash{{/unless}}"></i>
                </a>
            {{/if}}
        </header>
        <section class="personality{{#if editable}} editable{{/if}}">
            <div class="bio attitude">
                <label class="details-label" for="{{document.uuid}}-attitude">{{localize "PF2E.BiographyAttitude"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-attitude" name="system.details.biography.attitude" value="{{biography.attitude}}" />
                </span>
            </div>
            <div class="bio beliefs">
                <label class="details-label" for="{{document.uuid}}-beliefs">{{localize "PF2E.BiographyBeliefs"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-beliefs" name="system.details.biography.beliefs" value="{{biography.beliefs}}" />
                </span>
            </div>
            <div class="bio edicts" data-field="edicts" data-tooltip-direction="LEFT">
                <div class="label-add">
                    <label
                        class="details-label"{{#if biography.edicts}}
                        for="{{document.uuid}}-edicts"{{/if}}
                    >{{localize "PF2E.BiographyEdicts"}}</label>
                    <a
                        data-action="add-edict-anathema"
                        data-tooltip="PF2E.Actor.Character.Biography.Edicts.Add"
                    ><i class="fa-solid fa-plus"></i></a>
                </div>
                <ol>
                    {{~#each biography.edicts as |line index|~}}
                        <li>
                            <input
                                type="text"
                                {{#if (eq index 0)}}id="{{../document.uuid}}-edicts"{{/if}}
                                name="system.details.biography.edicts.{{index}}"
                                value="{{line}}"
                            />
                            <a
                                data-action="delete-edict-anathema"
                                data-tooltip="PF2E.Actor.Character.Biography.Edicts.Delete"
                                data-index="{{index}}"
                            ><i class="fa-solid fa-trash"></i></a>
                        </li>
                    {{/each}}
                </ol>
            </div>
            <div class="bio anathema" data-field="anathema" data-tooltip-direction="LEFT">
                <div class="label-add">
                    <label
                        class="details-label"
                        {{#if biography.anathema}}for="{{document.uuid}}-anathema"{{/if}}
                    >{{localize "PF2E.BiographyAnathema"}}</label>
                    <a
                        data-action="add-edict-anathema"
                        data-tooltip="PF2E.Actor.Character.Biography.Anathema.Add"
                    ><i class="fa-solid fa-plus"></i></a>
                </div>
                <ol>
                    {{~#each biography.anathema as |line index|~}}
                        <li>
                            <input
                                type="text"
                                {{#if (eq index 0)}}id="{{../document.uuid}}-anathema"{{/if}}
                                name="system.details.biography.anathema.{{index}}"
                                value="{{line}}"
                            />
                            <a
                                data-action="delete-edict-anathema"
                                data-tooltip="PF2E.Actor.Character.Biography.Anathema.Delete"
                                data-index="{{index}}"
                            ><i class="fa-solid fa-trash"></i></a>
                        </li>
                    {{/each}}
                </ol>
            </div>
            <div class="bio likes">
                <label class="details-label" for="{{document.uuid}}-likes">{{localize "PF2E.BiographyLikes"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-likes" name="system.details.biography.likes" value="{{biography.likes}}" />
                </span>
            </div>
            <div class="bio dislikes">
                <label class="details-label" for="{{document.uuid}}-dislikes">{{localize "PF2E.BiographyDislikes"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-dislikes" name="system.details.biography.dislikes" value="{{biography.dislikes}}" />
                </span>
            </div>
            <div class="bio catchphrases">
                <label class="details-label" for="{{document.uuid}}-catchphrases">{{localize "PF2E.BiographyCatchphrases"}}</label>
                <span>
                    <input type="text" id="{{document.uuid}}-catchphrases" name="system.details.biography.catchphrases" value="{{biography.catchphrases}}" />
                </span>
            </div>
        </section>
    {{/if}}

    {{#if (or document.isOwner biography.visibility.campaign)}}
        <header>
            <span>{{localize "PF2E.BiographyCampaignNotesHeader"}}</span>
            {{#if editable}}
                <a data-action="toggle-bio-visibility" data-section="campaign" data-tooltip="PF2E.Actor.Character.Biography.ToggleVisibility">
                    <i class="fa-solid fa-fw fa-eye{{#unless biography.visibility.campaign}}-slash{{/unless}}"></i>
                </a>
            {{/if}}
        </header>
        <section class="campaign{{#if editable}} editable{{/if}}">
            <div class="bio campaign-notes">
                <h4 class="details-label">{{localize "PF2E.BiographyCampaignNotes"}}</h4>
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.campaignNotes target="system.details.biography.campaignNotes" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
            <div class="bio allies">
                <h4 class="details-label">{{localize "PF2E.BiographyAllies"}}</h4>
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.allies target="system.details.biography.allies" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
            <div class="bio enemies">
                <h4 class="details-label">{{localize "PF2E.BiographyEnemies"}}</h4>
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.enemies target="system.details.biography.enemies" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
            <div class="bio organizations">
                <h4 class="details-label">{{localize "PF2E.BiographyOrganizations"}}</h4>
                <div class="biography-content" data-tooltip-class="">
                    {{editor enrichedContent.organizations target="system.details.biography.organizations" button=true owner=owner editable=editable engine="prosemirror"}}
                </div>
            </div>
        </section>
    {{/if}}
</section>
