<form class="{{cssClass}}" autocomplete="off">
    <!-- ITEM SHEET HEADER -->
    <header class="sheet-header" data-tooltip-class="pf2e">
        {{!-- Source image in case of change during data preparation --}}
        <img src="{{item._source.img}}" data-edit="img" />
        <div class="details">
            {{!-- Likewise with source name --}}
            <input
                name="name"
                type="text"
                value="{{item._source.name}}"
                placeholder="{{localize "PF2E.ItemNamePlaceholder"}}"
                spellcheck="false"
                aria-label="{{localize "PF2E.ItemNamePlaceholder"}}"
            />

            {{#if (or item.actionCost item.actionGlyph)}}{{{actionGlyph (coalesce item.actionCost item.actionGlyph)}}}{{/if}}

            {{#if itemType}}
                <span class="level">
                    {{#if adjustedLevelHint}}<i class="fa-solid fa-info-circle" data-tooltip="{{adjustedLevelHint}}"></i>{{/if}}
                    <span>{{itemType}}</span>
                    <input
                        type="number"
                        {{#if adjustedLevelHint}}class="adjusted"{{/if}}
                        {{#if isPhysical}}data-property="system.level.value"{{else}}name="system.level.value"{{/if}}
                        required="true"
                        min="0"
                        value="{{data.level.value}}"
                        aria-label="{{localize "PF2E.LevelLabel"}}"
                    />
                </span>
            {{/if}}
            <template class="traits-extra">
                {{#if item.rarity}}
                    <select class="tag rarity {{item.rarity}}" data-property="system.traits.rarity">
                        {{#select item.rarity}}
                            {{#each rarities as |label key|}}
                                <option value="{{key}}">{{localize label}}</option>
                            {{/each}}
                        {{/select}}
                    </select>
                {{/if}}
            </template>
            {{#if showTraits}}
                <input class="paizo-style tags" name="system.traits.value" value="{{json traitTagifyData}}" data-dtype="JSON"
                    {{#if (eq data.traits.value.length 0)}}placeholder="{{localize "PF2E.Traits"}}"{{/if}} />
            {{else if rarity}}
                <div class="paizo-style tags"></div>
            {{/if}}
        </div>
    </header>

    <nav class="sheet-tabs">
        {{#if sidebarTemplate}}
            <div class="sidebar-summary">{{sidebarTitle}}</div>
        {{/if}}

        <div class="tabs" data-tab-container="primary">
            <a class="list-row" data-tab="description">{{localize "PF2E.ItemDescription"}}</a>
            <a class="list-row" data-tab="details">{{localize "PF2E.ItemDetails"}}</a>
            {{#if (and isPhysical user.isGM)}}
                <a class="list-row" data-tab="mystification">{{localize "PF2E.ItemMystification"}}</a>
            {{/if}}
            {{#if (and enabledRulesUI (not isVariant))}}
                <a class="list-row" data-tab="rules">{{localize "PF2E.Item.Rules.Tab"}}</a>
            {{/if}}
        </div>
    </nav>

    <!-- ITEM SHEET CONTENT -->
    <div class="sheet-content">
        <!-- ITEM SHEET SIDEBAR -->
        {{#if sidebarTemplate}}
            <section class="sidebar" data-tooltip-class="pf2e" data-tooltip-direction="UP">
                {{> (lookup . "sidebarTemplate")}}
            </section>
        {{/if}}

        <!-- ITEM SHEET BODY -->
        <div class="sheet-body">
            <!-- Item Description -->
            <section class="tab description" data-tab="description">
                {{#if user.isGM}}
                    <section class="editor-container gm-notes{{#if enrichedContent.gmNotes}} has-content{{/if}}">
                        {{editor enrichedContent.gmNotes target="system.description.gm" button=true owner=owner editable=editable}}
                    </section>
                {{/if}}
                <section class="main editor-container">
                    {{#if (not isVariant)}}
                        {{editor enrichedContent.description target="system.description.value" button=true owner=owner editable=editable}}
                    {{else}}
                        <div class="editor">
                            <div class="editor-content">{{{enrichedContent.description}}}</div>
                        </div>
                    {{/if}}
                </section>
            </section>

            <!-- Item Details -->
            <section
                class="tab details{{#unless sidebarTemplate}} no-sidebar{{/unless}}"
                data-tab="details"
                data-tooltip-class="pf2e"
                data-tooltip-direction="UP"
            >
                {{> (lookup . "detailsTemplate")}}

                <fieldset class="publication">
                    <legend>{{localize "PF2E.Publication.Label"}}</legend>
                    <div class="data">
                        {{> "systems/pf2e/templates/partials/publication-data.hbs" path="system.publication" data=data.publication}}
                    </div>
                </fieldset>
            </section>

            <!-- Mystification Details -->
            {{#if (and isPhysical user.isGM)}}
                {{> "systems/pf2e/templates/items/mystify-panel.hbs"}}
            {{/if}}

            <!-- Rules Elements -->
            {{#if (not isVariant)}}
                <section class="tab rules" data-tab="rules" data-tooltip-class="pf2e" data-tooltip-direction="UP">
                    {{!-- Use ~ so that text areas don't add further indentation --}}
                    {{~> systems/pf2e/templates/items/rules-panel.hbs item=item}}
                </section>
            {{/if}}
        </div>
    </div>
</form>
