<% provide :title, @proposal.title %>
<% content_for :meta_description do %><%= @proposal.summary %><% end %>
<% provide :social_media_meta_tags do %>
  <%= render "shared/social_media_meta_tags",
             social_url: legislation_process_proposal_url(process_id: @process),
             social_title: @proposal.title,
             social_description: @proposal.summary %>
<% end %>
<% content_for :canonical do %>
  <%= render "shared/canonical", href: legislation_process_proposal_url(process_id: @process) %>
<% end %>

<div class="row process-proposal">
  <div class="small-12 column">
    <div class="header">
      <p class="process-title">
        <strong><%= t("legislation.proposals.process_title") %></strong>
      </p>
      <%= link_to @process.title, @process, class: "process-link" %>
    </div>
  </div>
</div>

<% cache [locale_and_user_status(@proposal),
          @proposal,
          @proposal.author,
          Flag.flagged?(current_user, @proposal),
          current_user&.voted_as_when_voted_for(@proposal)] do %>
  <div class="proposal-show legislation-proposal-show">
    <div id="<%= dom_id(@proposal) %>" class="row">
      <div class="small-12 medium-9 column">
        <%= back_link_to legislation_process_proposals_path(process_id: @process) %>

        <h1><%= @proposal.title %></h1>
        <% if @proposal.conflictive? %>
          <div data-alert class="callout alert margin-top">
            <strong><%= t("proposals.show.flag") %></strong>
          </div>
        <% end %>

        <div class="proposal-info">
          <%= render "/shared/author_info", resource: @proposal %>

          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= l @proposal.created_at.to_date %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %>

          <% if current_user %>
            <span class="bullet">&nbsp;&bull;&nbsp;</span>
            <span class="js-flag-actions">
              <%= render "shared/flag_actions", flaggable: @proposal %>
            </span>
          <% end %>

        </div>

        <%= render_image(@proposal.image, :large, true) if @proposal.image.present? %>

        <br>
        <p>
          <%= t("proposals.show.code") %>
          <strong><%= @proposal.code %></strong>
        </p>

        <blockquote><%= @proposal.summary %></blockquote>

        <%= render Shared::EmbeddedVideoComponent.new(@proposal) %>

        <%= auto_link_already_sanitized_html wysiwyg(@proposal.description) %>

        <% if @proposal.video_url.present? %>
          <div class="video-link">
            <p>
              <span class="icon-video"></span>&nbsp;
              <strong><%= t("proposals.show.title_video_url") %></strong>
            </p>
            <%= sanitize_and_auto_link @proposal.video_url %>
          </div>

        <% end %>

        <% if feature?(:allow_attached_documents) %>
          <%= render Documents::DocumentsComponent.new(@proposal.documents) %>
        <% end %>

        <%= render "shared/tags", taggable: @proposal %>

        <%= render Shared::GeozoneLinkComponent.new(@proposal, legislation_process_proposals_path(@process, search: geozone_name(@proposal))) %>

        <div class="js-moderator-proposal-actions margin">
          <%= render "legislation/proposals/actions", proposal: @proposal %>
        </div>
      </div>

      <aside class="small-12 medium-3 column">
        <div class="sidebar-divider"></div>
        <h2><%= t("votes.supports") %></h2>
        <div id="<%= dom_id(@proposal) %>_votes">
          <%= render Legislation::Proposals::VotesComponent.new(@proposal) %>
        </div>
        <%= render "shared/social_share",
                   share_title: t("proposals.show.share"),
                   title: @proposal.title,
                   url: legislation_process_proposal_url(process_id: @process),
                   description: @proposal.summary,
                   mobile: @proposal.title %>
      </aside>
    </div>
  </div>
<% end %>

<div class="additional-content">
  <div class="filter-subnav">
    <div class="row">
      <div class="small-12 column">
        <%= render "legislation/proposals/filter_subnav" %>
      </div>
    </div>
  </div>
</div>

<div class="tabs-content" data-tabs-content="legislation_proposals_tabs">
  <div class="tabs-panel is-active" id="tab-comments">
    <%= render "legislation/proposals/comments" %>
  </div>
</div>
