<div class="inventory-details" spellcheck="false">
    <div class="form-group duration">
        <label for="{{item.uuid}}-duration">{{localize "PF2E.Time.Duration"}}</label>
        {{> systems/pf2e/templates/items/partials/duration.hbs base="system.duration" duration=data.duration units=timeUnits}}
    </div>
    <div class="form-group">
        <label for="{{item.uuid}}-sustained">{{localize "PF2E.Item.Effect.Sustained"}}</label>
        <div class="form-fields">
            <input id="{{item.uuid}}-sustained" type="checkbox" name="system.duration.sustained" {{checked data.duration.sustained}} />
        </div>
    </div>
    {{#unless (or (eq data.duration.unit "unlimited") (eq data.duration.unit "encounter"))}}
        <div class="form-group">
            <label for="{{item.uuid}}-duration-expiry">{{localize "PF2E.Item.Effect.Expiry.ExpiresOn"}}</label>
            <div class="form-fields">
                <select id="{{item.uuid}}-duration-expiry" name="system.duration.expiry">
                    {{#select data.duration.expiry}}
                        <option value="turn-start">{{localize "PF2E.Item.Effect.Expiry.StartOfTurn"}}</option>
                        <option value="turn-end">{{localize "PF2E.Item.Effect.Expiry.EndOfTurn"}}</option>
                        <option value="round-end">{{localize "PF2E.Item.Effect.Expiry.EndOfRound"}}</option>
                    {{/select}}
                </select>
            </div>
        </div>
    {{/unless}}
    <div class="form-group">
        <label for="{{item.uuid}}-show-token-icon">{{localize "PF2E.Item.Effect.ShowTokenIcon"}}</label>
        <div class="form-fields">
            <input id="{{item.uuid}}-show-token-icon" type="checkbox" name="system.tokenIcon.show" {{checked data.tokenIcon.show}} />
        </div>
    </div>
    {{#if user.isGM}}
        <div class="form-group">
            <label for="{{item.uuid}}-unidentified">{{localize "PF2E.Item.Effect.Unidentified"}}</label>
            <div class="form-fields">
                <input id="{{item.uuid}}-unidentified" type="checkbox" name="system.unidentified" {{checked data.unidentified}} />
            </div>
        </div>
    {{/if}}
    <hr />
    {{#if data.badge}}
        {{#if (eq data.badge.type "formula")~}}
            <div class="form-group">
                <label for="{{item.uuid}}-badge-type">{{badgeType}}</label>
                <div class="form-fields">
                    <input id="{{item.uuid}}-badge-type" type="text" name="system.badge.value" value="{{data.badge.value}}" />
                    {{#if @root.options.editable}}
                        <div class="item-controls">
                            <a data-action="badge-delete"><i class="fa-solid fa-fw fa-times"></i></a>
                        </div>
                    {{/if}}
                </div>
            </div>
            <div class="form-group">
                <label for="{{item.uuid}}-badge-reevaluate">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.Label"}}</label>
                <div class="form-fields">
                    <select id="{{item.uuid}}-badge-reevaluate" name="system.badge.reevaluate">
                        {{#select data.badge.reevaluate}}
                            <option value="">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.Never"}}</option>
                            <option value="turn-start">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnStart"}}</option>
                            <option value="turn-end">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnEnd"}}</option>
                        {{/select}}
                    </select>
                </div>
            </div>
        {{else}}
            <div class="form-group">
                <label for="{{item.uuid}}-badge-type">{{badgeType}}</label>
                <div class="form-fields">
                    <input id="{{item.uuid}}-badge-type" type="number" {{#if data.badge.labels}}disabled{{else}}name="system.badge.value"{{/if}} value="{{data.badge.value}}" />
                    {{#if @root.options.editable}}
                        <div class="item-controls">
                            <a data-action="badge-delete"><i class="fa-solid fa-fw fa-times"></i></a>
                        </div>
                    {{/if}}
                </div>
            </div>
        {{/if}}

        {{#if data.badge.labels}}
            <h4 class="badge-label-header">
                {{localize "PF2E.Item.Effect.Badge.Labels.Label" type=badgeType}}
                <a class="add-badge" data-action="badge-add-label"><i class="fa-solid fa-fw fa-plus"></i></a>
            </h4>
            {{#each data.badge.labels as |label idx|}}
                <div class="badge-label-row form-fields">
                    {{#unless (eq @root.data.badge.type "formula")}}
                        <label>
                            <input
                                type="radio"
                                name="system.badge.value"
                                value="{{add idx 1}}"
                                data-dtype="Number"
                                tabindex="-1"
                                {{checked (eq @root.data.badge.value (add idx 1))}}
                            />
                            <span class="badge-value">{{add idx 1}}</span>
                        </label>
                    {{/unless}}
                    <input type="text" name="system.badge.labels.{{idx}}" value="{{label}}" placeholder="{{localize "PF2E.Item.Effect.Badge.Labels.Placeholder"}}" />
                    {{#if @root.options.editable}}
                        <div class="item-controls">
                            <a data-action="badge-delete-label" data-idx="{{idx}}"><i class="fa-solid fa-fw fa-times"></i></a>
                        </div>
                    {{/if}}
                </div>
            {{/each}}
        {{else}}
            <div class="form-group">
                <label>{{localize "PF2E.Item.Effect.Badge.Range"}}</label>
                <div class="form-fields">
                    <input type="number" name="system.badge.min" value="{{document._source.system.badge.min}}" placeholder="1"/>
                    -
                    <input type="number" name="system.badge.max" value="{{document._source.system.badge.max}}" placeholder="Infinity"/>
                </div>
            </div>
            <button type="button" data-action="badge-add-label">
                <i class="fa-solid fa-fw fa-plus"></i> {{localize "PF2E.Item.Effect.Badge.Labels.Add"}}
            </button>
        {{/if}}
    {{else}}
        <div class="add-badge">
            <select class="badge-type">
                <option value="counter">{{localize "PF2E.Item.Effect.Badge.Type.counter"}}</option>
                <option value="formula">{{localize "PF2E.Item.Effect.Badge.Type.formula"}}</option>
            </select>
            <button type="button" data-action="badge-add">
                <i class="fa-solid fa-fw fa-plus"></i> {{localize "PF2E.Item.Effect.Badge.Add"}}
            </button>
        </div>
    {{/if}}
</div>
