{{#if scenarios}}
{{#each scenarios}}
## {{id}} - {{title}}{{#if extends_scenario_id}} (Extension){{/if}}

{{#if primary_actor}}
**Primary Actor:** {{{actor_link primary_actor}}}
{{/if}}

{{#if supporting_actors}}
**Supporting Actors:** {{#each supporting_actors}}{{#unless (eq this ../primary_actor)}}{{{actor_link this}}}{{#unless @last}}, {{/unless}}{{/unless}}{{/each}}
{{/if}}

{{#if preconditions}}
**Preconditions:**
{{#each preconditions}}
- {{this.text}}{{#if this.target_id}} (see [{{this.target_id}}]({{use_case_link this.target_id}})){{/if}}
{{/each}}

{{/if}}
{{#if postconditions}}
**Postconditions:**
{{#each postconditions}}
- {{this.text}}{{#if this.target_id}} (see [{{this.target_id}}]({{use_case_link this.target_id}})){{/if}}
{{/each}}

{{/if}}
```mermaid
sequenceDiagram
{{#if primary_actor}}
participant {{{actor_name primary_actor}}}
{{/if}}
{{#each supporting_actors}}
{{#unless (eq this ../primary_actor)}}
participant {{{actor_name this}}}
{{/unless}}
{{/each}}
{{#each merged_steps}}
{{#if receiving_actor}}
{{{actor_name acting_actor}}}->>{{actor_name receiving_actor}}: {{order}}. {{{mermaid_safe action}}}
{{else}}
{{{actor_name acting_actor}}}->>{{actor_name acting_actor}}: {{order}}. {{{mermaid_safe action}}}
{{/if}}
{{/each}}
```

### Steps
{{#each merged_steps}}
{{order}}. **{{{actor_name acting_actor}}}**{{#if receiving_actor}} → **{{{actor_name receiving_actor}}}**{{/if}}: {{action}}
{{/each}}

{{#if extends_scenario_id}}
*Extends scenario {{extends_scenario_id}} at step {{extends_at_step}}*{{#if returns_at_step}}, returns at step {{returns_at_step}}{{/if}}

{{/if}}
{{#if repeat_blocks}}
### Repeat Blocks
{{#each repeat_blocks}}
- Steps {{from_step}} to {{to_step}}: Repeats while *{{condition}}*
{{/each}}

{{/if}}
{{/each}}
{{/if}}
