<% unless @turbo_status %>
  <div class="alert alert-danger">
    There was an error contacting Redis: please make sure the Redis server is running.
  </div>
<% end %>

<% if Dradis::Plugins::Echo::Agents::Roslin.enabled? %>
  <% if @prompts.any? %>
    <p>
      Interact with <i class="fa-solid fa-robot me-1"></i>Roslin by selecting a
      <%= link_to 'saved prompt', echo.prompts_path, data: { turbo_frame: '_top' } %> to use with this Issue.
    </p>
    <p>
      You can edit the prompt before sending it, any changes are one-off and
      won't affect the saved prompt template.
    </p>

    <div class="row" data-controller="dradis--plugins--echo--prompt-selector">
      <div class="col-12 mb-3">
        <p class="form-label">Saved Prompts</p>
        <select class="form-select">
          <% @prompts.each do |prompt| %>
            <option
              data-combobox-option-icon="fa-solid <%= prompt.icon %>"
              value="<%= echo.preview_project_interaction_path(current_project, prompt.id, type: @type, record: @record.id) %>">
              <%= prompt.title %>
            </option>
          <% end %>
        </select>
      </div>

      <div class="col-12">
        <p class="form-label">Selected Prompt</p>
        <turbo-frame id="echo-prompt-preview" data-dradis--plugins--echo--prompt-selector-target="frame">
        </turbo-frame>
      </div>
    </div>
  <% else %>
    <%= render 'shared/empty_state',
      actions_partial: 'dradis/plugins/echo/prompts/empty_state_actions',
      docs_link: 'https://dradis.com/support/guides/echo/prompts.html',
      name: 'prompt',
      text: 'Create reusable prompts to standardize how your team analyzes findings, writes reports, summarizes vulnerabilities, and more. Save time by building a library of prompts that anyone on your team can use for consistent results.'
    %>
  <% end %>
<% else %>
  <div class="alert alert-warning">
    <% if !current_user.respond_to?(:role?) || current_user.role?(:admin) %>
      The Roslin agent is not enabled.
      <%= link_to 'Enable it', echo.agents_path, data: { turbo_frame: '_top' } %>
      to allow LLM interactions for AI-assisted writing.
    <% else %>
      <i class="fa-solid fa-robot me-1"></i>Roslin is not enabled. Ask an
      admin to enable it to allow LLM interactions.
    <% end %>
  </div>
  <p>
    Think of Roslin as an editor or writing companion. It allows you to interact
    with different LLM providers to help enhance your findings' readability
    or adapt them to your audience.
  </p>
<% end %>
