<div class="field-group">
    {{ formInput fields.custom.fields.enabled name=(concat prefix "custom.enabled") value=source.custom.enabled
                 input=@root.inputs.createCheckboxInput classes="singleton"
                 dataset=(dnd5e-object tooltip="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.custom.enabled.hint")
                 ariaLabel=(localize "DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.custom.enabled.hint")}}
    {{#if source.custom.enabled}}

    {{ formField fields.custom.fields.formula name=(concat prefix "custom.formula") value=source.custom.formula
                 label="DND5E.Formula" hint=false localize=true classes="label-top" }}
    <input type="hidden" name="{{ prefix }}number" value="{{ source.number }}" data-dtype="Number">
    <input type="hidden" name="{{ prefix }}denomination" value="{{ source.denomination }}" data-dtype="Number">
    <input type="hidden" name="{{ prefix }}bonus" value="{{ source.bonus }}">

    {{else}}

    {{ formField fields.number name=(concat prefix "number") value=source.number label="DND5E.Number" hint=false
                 localize=true classes="label-top" }}

    {{ formField fields.denomination name=(concat prefix "denomination") value=source.denomination
                 options=@root.denominationOptions label="DND5E.Die" hint=false localize=true classes="label-top" }}

    {{ formField fields.bonus name=(concat prefix "bonus") value=source.bonus label="DND5E.Bonus" hint=false localize=true
                 classes="label-top" }}

    <input type="hidden" name="{{ prefix }}custom.formula" value="{{ source.custom.formula }}">

    {{/if}}
    {{#unless data.locked}}
    <button type="button" class="unbutton control-button" data-action="deleteDamagePart"
            data-tooltip="DND5E.DAMAGE.Part.Action.Delete"
            aria-label="{{ localize 'DND5E.DAMAGE.Part.Action.Delete' }}">
        <i class="fa-solid fa-minus" inert></i>
    </button>
    {{/unless}}
</div>

<div class="field-group">
    {{ formField fields.types name=(concat prefix "types") value=source.types options=typeOptions hint=false
                 disabled=data.locked label="DND5E.Type" localize=true classes="label-top multi-select" }}
    <!-- TODO: This disabled is only necessary because of https://github.com/foundryvtt/foundryvtt/issues/11564 -->
</div>

{{#if canScale}}
{{#with fields.scaling.fields as |fields|}}
<div class="field-group">
    {{ formField fields.mode name=(concat ../prefix "scaling.mode") value=../source.scaling.mode
                 options=../scalingOptions label="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.scaling.abbr" hint=false
                 localize=true classes="label-top" }}
    {{#if ../source.scaling.mode}}
    {{ formField fields.number name=(concat ../prefix "scaling.number") value=../source.scaling.number
                 label="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.scaling.number.abbr" hint=false localize=true
                 classes="label-top" }}
    {{ formField fields.formula name=(concat ../prefix "scaling.formula") value=../source.scaling.formula
                 label="DND5E.Formula" hint=false localize=true classes="label-top" }}
    {{/if}}
</div>
{{/with}}
{{/if}}
