{% import "macros.html" as m %}
{% if not view.ok %}
  {{ m.absence(view) }}
{% elif view.consumes or view.external_deps %}
  <p class="lead fw-lede">Cross-project coupling, declared in <span class="mono">federation.json</span> — fact, not inference.
  {% if view.triggers %}<b>{{ view.triggers }}</b> upstream {{ 'dependency is' if view.triggers == 1 else 'dependencies are' }}
  <span class="mono">trigger_check</span>: an advance there should trigger a check here {{ m.derived() }}.{% endif %}</p>

  {% if view.consumes %}
  <section class="card fw-panel">
    <header class="fw-panel__head"><h2 class="card__title fw-panel__title">Consumes from siblings</h2></header>
    <div class="table-wrap">
      <table class="table">
        <thead><tr><th>From</th><th>What</th><th>Pinned at</th><th>On upstream change</th></tr></thead>
        <tbody>
          {% for c in view.consumes %}
          <tr>
            <td><b class="mono">{{ c['from'] }}</b></td>
            <td>
              <div class="fw-cell-title mono">{{ c.what }}</div>
              {% if c.why %}<div class="evidence">{{ c.why }}</div>{% endif %}
            </td>
            <td class="mono muted">{{ c.pinned_at or '—' }}</td>
            <td>
              {% if c.policy %}<span class="badge {{ 'badge-warning' if c.triggers_check else 'badge-neutral' }}">{{ c.policy }}</span>{% else %}<span class="muted">—</span>{% endif %}
              {% if c.triggers_check %}<div class="fw-couple-flag mono">↑ advance triggers a check here {{ m.derived() }}</div>{% endif %}
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </section>
  {% endif %}

  {% if view.external_deps %}
  <section class="card fw-panel">
    <header class="fw-panel__head"><h2 class="card__title fw-panel__title">Roadmap external dependencies</h2></header>
    <div class="fw-delta">
      {% for d in view.external_deps %}
      <div class="fw-delta__row mono"><b>{{ d.stage }}</b><span class="fw-arrow">depends on</span><span>{{ d.depends_on }}</span></div>
      {% endfor %}
    </div>
  </section>
  {% endif %}
{% else %}
  {{ m.empty_inline(view.empty_title, view.empty_reason) }}
{% endif %}
