{% block toolbar %}
    {% set icon %}
    <a href="{{ url("webprofiler.dashboard", {profile: token}, {fragment: 'blocks'}) }}" title="{{ 'Blocks'|t }}">
        <img width="20" height="28" alt="{{ 'Blocks'|t }}"
             src="data:image/png;base64,{{ collector.icon }}"/>
        <span class="sf-toolbar-info-piece-additional sf-toolbar-status">{{ collector.renderedBlocksCount }}</span>
    </a>
    {% endset %}
    {% set text %}

    <div class="sf-toolbar-info-piece">
        <b>{{ 'Loaded'|t }}</b>
        <span>{{ collector.loadedBlocksCount }}</span>
    </div>
    <div class="sf-toolbar-info-piece">
        <b>{{ 'Rendered'|t }}</b>
        <span>{{ collector.renderedBlocksCount }}</span>
    </div>
    {% endset %}

    <div class="sf-toolbar-block">
        <div class="sf-toolbar-icon">{{ icon|default('') }}</div>
        <div class="sf-toolbar-info">{{ text|default('') }}</div>
    </div>
{% endblock %}

{% block panel %}
    <script id="blocks" type="text/template">
        <h2 class="panel__title">{{ 'Blocks'|t }}</h2>

        <form class="panel__toolbar">
            <div class="panel__filter--text">
                <input id="edit-sid" class="js--live-filter" placeholder="{{ 'ID'|t }}" type="text"/>
                <label for="edit-sid" class="panel__filter-label">{{ 'ID'|t }}</label>
            </div>
            <div class="panel__filter--text">
                <input id="edit-label" class="js--live-filter" placeholder="{{ 'Label'|t }}" type="text"/>
                <label for="edit-label" class="panel__filter-label">{{ 'Label'|t }}</label>
            </div>
            <div class="panel__filter--text">
                <input id="edit-region" class="js--live-filter" placeholder="{{ 'Region'|t }}" type="text"/>
                <label for="edit-region" class="panel__filter-label">{{ 'Region'|t }}</label>
            </div>
            <div class="panel__filter--text">
                <input id="edit-provider" class="js--live-filter" placeholder="{{ 'Provider'|t }}" type="text"/>
                <label for="edit-provider" class="panel__filter-label">{{ 'Provider'|t }}</label>
            </div>
            <div class="panel__filter--select">
                <select id="edit-rendered" class="js--live-filter">
                    <option value="">{{ 'Any'|t }}</option>
                    <option value="1">{{ 'Yes'|t }}</option>
                    <option value="0">{{ 'No'|t }}</option>
                </select>
                <label for="edit-rendered" class="panel__filter-label">{{ 'Rendered'|t }}</label>
            </div>
        </form>

        <% _.each( data.blocks.loaded, function( item ){ %>

        <div class="panel__container"
             data-wp-sid="<%- item.id %>"
             data-wp-label="<%= item.settings.label %>"
             data-wp-region="<%= item.region %>"
             data-wp-provider="<%= item.settings.provider %>"
             data-wp-rendered="<%- (data.blocks.rendered[item.id]) ? '1' : '0' %>">

            <div class="panel__expand-header">
                <ul class="list--inline">
                    <li>
                        <b>{{ 'ID'|t }}</b> <%- item.id %>
                    </li>
                    <li>
                        <b>{{ 'Label'|t }}</b> <%= item.settings.label %>
                    </li>
                    <li>
                        <b>{{ 'Region'|t }}</b> <%= (item.region == -1) ? '{{ 'No region'|t }}' : item.region %>
                    </li>
                    <li>
                        <b><%- (data.blocks.rendered[item.id]) ? '' : '{{ 'Not rendered'|t }}' %></b>
                    </li>
                </ul>
                <div class="button--flat l-right js--panel-toggle">{{ 'Info'|t }}</div>
                <a class="button--flat l-right " href="<%- item.route %>">{{ 'Edit'|t }}</a>

            </div>

            <div class="panel__expand-content">
                <div class="wp-query-arguments">
                    <table class="table--duo">
                        <tr>
                            <th>{{ 'Provider'|t }}</th>
                            <td><%- item.settings.provider %></td>
                        </tr>
                        <tr>
                            <th>{{ 'Theme'|t }}</th>
                            <td><%- item.theme %></td>
                        </tr>
                        <tr>
                            <th>{{ 'Status'|t }}</th>
                            <td><%- (item.status) ? '{{ 'Enabled'|t }}' : '{{ 'Disabled'|t }}' %></td>
                        </tr>
                        <tr>
                            <th>{{ 'Plugin'|t }}</th>
                            <td><%- item.plugin %></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <% }); %>

    </script>
{% endblock %}
