{# Reusable guidance block rendering macro. Renders a GuidanceBlock with appropriate styling per BlockKind. Used by IPI, CXP, and RXP playbook tabs. #} {% macro render_guidance_block(block) %}

{{ block.label }}

{% if block.kind == "inventory" %} {# Inventory: render metadata.rows as a table, items as a note below #} {% if block.metadata and block.metadata.rows %}
{% for col in block.metadata.rows[0].keys() %} {% endfor %} {% for row in block.metadata.rows %} {% for val in row.values() %} {% endfor %} {% endfor %}
{{ col }}
{{ val }}
{% endif %} {% if block.items and not (block.metadata and block.metadata.rows) %}

{% for item in block.items %} {{ item }}{% if not loop.last %}
{% endif %} {% endfor %}

{% endif %} {% elif block.kind == "trigger_prompts" %} {# Trigger prompts: profile-tabbed or default textarea #} {% set profiles = [] %} {% if block.metadata %} {% if block.metadata.get("anythingllm") is not none or block.metadata.get("open_webui") is not none or block.metadata.get("generic") is not none %} {% set profiles = ["anythingllm", "open_webui", "generic"] %} {% endif %} {% endif %} {% if profiles %} {# Tabbed profile selector #}
{% for profile in profiles %} {% if block.metadata.get(profile) is not none %} {{ profile }} {% endif %} {% endfor %}
{% for profile in profiles %} {% if block.metadata.get(profile) is not none %}
{{ block.metadata[profile] }}
{% endif %} {% endfor %}
{% elif block.metadata.get("default") is not none %} {# CXP-style: default prompt — render as read-only with copy. Editing is handled by the module-specific tab (cxp_tab.html) which has the save endpoint context. #}
{{ block.metadata.override or block.metadata["default"] }}
{% else %} {# Fallback: render items as prompt lines #} {% for item in block.items %}
{{ item }}
{% endfor %} {% endif %} {% elif block.kind == "deployment_steps" %} {# Deployment steps: ordered list #} {% if block.items %}
    {% for item in block.items %}
  1. {{ item }}
  2. {% endfor %}
{% endif %} {% elif block.kind == "monitoring" %} {# Monitoring: bulleted list with info styling #} {% if block.items %} {% endif %} {% elif block.kind == "interpretation" %} {# Interpretation: bulleted list with warning styling #} {% if block.items %} {% endif %} {% else %} {# Factors / fallback: simple bulleted list #} {% if block.items %} {% endif %} {% endif %}
{% endmacro %}