{{!log 'chat-message' this}}
<div class="{{cssClass}}">
  <div class="intro-chat">
    <div class="intro-img">
      <img src="{{actingCharImg}}" data-tooltip="{{actingCharName}}" />
    </div>
    <div class="intro-right">
      <ul>
        <li><strong>{{actingCharName}}</strong></li>
        {{#if (eq rollType "char")}}
          <li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li>
        {{/if}}

        {{#if (eq rollType "skill")}}
          <li><strong>{{localize
                "CTHULHUETERNAL.Label.skillRoll"
              }}</strong></li>
        {{/if}}

        {{#if isNudgedRoll}}
          <li><strong>{{localize "CTHULHUETERNAL.Label.nudgedRoll"}}
              :
              {{wpCost}}
              {{localize "CTHULHUETERNAL.Label.WPSpent"}}</strong></li>
        {{/if}}

        {{#if weapon}}
          <li><strong>{{localize "CTHULHUETERNAL.Label.Weapon"}}
              :
              {{weapon.name}}</strong></li>
        {{/if}}

        {{#if (eq rollType "resource")}}
          <li><strong>{{rollItem.name}} : {{initialScore}}</strong></li>
        {{else}}
          <li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
        {{/if}}

        {{#if isZeroWP}}
          <li class="red-warning">{{localize
              "CTHULHUETERNAL.Label.ZeroWP"
            }}</li>
        {{else}}
          {{#if isLowWP}}
            <li class="orange-warning">{{localize "CTHULHUETERNAL.Label.LowWP"}}
              : -20%</li>
          {{/if}}
        {{/if}}

        {{#if isExhausted}}
          <li class="orange-warning">{{localize
              "CTHULHUETERNAL.Label.Exhausted"
            }}
            : -20%</li>
        {{/if}}

        {{#if isWorn}}
          <li class="orange-warning"><i
              class="fa-solid fa-triangle-exclamation"
            ></i>
            {{localize "CTHULHUETERNAL.Label.wornWeaponWarning"}}</li>
        {{/if}}

        {{#if (eq rollType "resource")}}
          <li>{{localize "CTHULHUETERNAL.Label.multiplier"}}
            :
            {{multiplier}}</li>
        {{else}}
          <li>{{localize "CTHULHUETERNAL.Label.modifier"}}
            :
            {{totalModifier}}%</li>
        {{/if}}

        <li>{{localize "CTHULHUETERNAL.Label.targetScore"}}
          :
          {{targetScore}}%</li>

        {{#if isSuccess}}
          {{#if isCritical}}
            <li class="result-critical-success">{{localize
                "CTHULHUETERNAL.Label.criticalSuccess"
              }}
            </li>
          {{else}}
            <li class="result-success">
              {{localize "CTHULHUETERNAL.Label.success"}}
            </li>
          {{/if}}
        {{/if}}

        {{#if isFailure}}
          {{#if isCritical}}
            <li class="result-critical-failure">{{localize
                "CTHULHUETERNAL.Label.criticalFailure"
              }}
            </li>
          {{else}}
            <li class="result-failure">
              {{localize "CTHULHUETERNAL.Label.failure"}}
            </li>
          {{/if}}
        {{/if}}

        <!-- {{#if isAttackRoll}}
          {{#if defenseRoll}}
            <li>{{localize "CTHULHUETERNAL.Label.defenseRoll"}}</li>
            {{#if attackSuccess}}
              <li class="result-success">{{localize
                  "CTHULHUETERNAL.Label.attackSuccess"
                }}</li>
            {{else}}
              <li class="result-failure">{{localize
                  "CTHULHUETERNAL.Label.attackFailure"
                }}</li>
            {{/if}}
          {{else}}
            {{#if targetId}}
              <li class="orange-warning">{{localize
                  "CTHULHUETERNAL.Label.noDefenseRoll"
                }}</li>
            {{else}}
              <li class="orange-warning">{{localize
                  "CTHULHUETERNAL.Label.noTarget"
                }}</li>
            {{/if}}
          {{/if}}
        {{/if}} -->

      </ul>
    </div>
  </div>

  {{#if isDamage}}
    <div>
      {{#if (and isGM hasTarget)}}
        {{{localize
          "CTHULHUETERNAL.Roll.displayArmor"
          targetName=targetName
          targetArmor=targetArmor
          realDamage=realDamage
        }}}
      {{/if}}
    </div>
  {{/if}}
  {{#unless isPrivate}}
    <div class="dice-result">
      <h4 class="dice-total">{{total}}</h4>
      <div class="dice-formula">{{formula}}</div>
      {{{tooltip}}}
    </div>
  {{/unless}}

  {{#if skillMarkedForProgress}}
    <p class="skill-progress-notice">
      <i class="fa-solid fa-arrow-up-right-dots"></i>
      {{rollItem.name}} — {{localize "CTHULHUETERNAL.Label.skillFailed"}}
    </p>
  {{/if}}

  {{! Zone d'actions regroupées }}
  <div class="chat-actions">
    {{#if isSuccess}}
      {{#if isNudge}}
        <a
          class="nudge-roll chat-action-button"
          data-tooltip="{{localize 'CTHULHUETERNAL.Label.rollNudge'}}"
        >
          <i class="fa-solid fa-circle-sort-down"></i>
        </a>
      {{/if}}

      {{#if (eq rollType "weapon")}}
        {{#if (eq weapon.system.weaponType "rangedfirearm")}}
          {{#if weapon.system.hasDamageDistance}}
            {{#each weapon.system.damageDistance as |damageDistance|}}
              {{#if (gt damageDistance.distance 0)}}
                <a
                  class="damage-roll chat-action-button"
                  data-item-id="{{weapon.id}}"
                  data-action="roll"
                  data-roll-type="damage"
                  data-roll-value="{{damageDistance.damage}}"
                  data-tooltip="{{localize
                    'CTHULHUETERNAL.Label.rollDamage'
                  }} ({{damageDistance.distance}}m : {{damageDistance.damage}})"
                >
                  <i class="fa-solid fa-gun"></i>
                </a>
              {{/if}}
            {{/each}}
          {{else}}
            <a
              class="damage-roll chat-action-button"
              data-roll-value="{{weapon.system.damage}}"
              data-tooltip="{{localize 'CTHULHUETERNAL.Label.rollDamage'}}"
            >
              <i class="fa-solid fa-gun"></i>
            </a>
          {{/if}}
        {{else}}
          <a
            class="damage-roll chat-action-button"
            data-roll-value="{{weapon.system.damage}}"
            data-tooltip="{{localize 'CTHULHUETERNAL.Label.rollDamage'}}"
          >
            <i class="fa-solid fa-sword"></i>
          </a>
        {{/if}}
      {{/if}}

      {{#if (eq rollType "skill")}}
        {{#if rollItem.system.isHealing}}
          <a
            class="healing-roll chat-action-button"
            data-tooltip="{{localize 'CTHULHUETERNAL.Label.rollHealing'}}"
          >
            <i class="fa-solid fa-heart"></i>
          </a>
        {{/if}}
      {{/if}}
    {{/if}}

    {{#if (eq rollType "weapon")}}
      {{#if isWorn}}
        <a
          class="worn-weapon-check chat-action-button"
          data-weapon-id="{{weapon.id}}"
          data-tooltip="{{localize 'CTHULHUETERNAL.Label.wornWeaponCheck'}}"
        >
          <i class="fa-solid fa-dice"></i>
        </a>
      {{/if}}
    {{/if}}

    {{#if isFailure}}
      {{#if isNudge}}
        <a
          class="nudge-roll chat-action-button"
          data-tooltip="{{localize 'CTHULHUETERNAL.Label.rollNudge'}}"
        >
          <i class="fa-solid fa-circle-sort-down"></i>
        </a>
        {{#if wpCostToSucceed}}
          <a
            class="nudge-to-success chat-action-button"
            data-tooltip="{{localize 'CTHULHUETERNAL.Roll.nudgeToSuccess' score=targetScore wp=wpCostToSucceed}}"
          >
            <i class="fa-solid fa-circle-check"></i>
            {{localize "CTHULHUETERNAL.Roll.nudgeToSuccess" score=targetScore wp=wpCostToSucceed}}
          </a>
        {{/if}}
      {{/if}}
    {{/if}}

    <a
      class="opposed-roll chat-action-button"
      data-tooltip="{{localize 'CTHULHUETERNAL.Label.opposedRoll'}}"
    >
      <i class="fa-duotone fa-light fa-arrows-to-line"></i>
    </a>
  </div>
</div>