<%# locals: (form:) %>
<div data-controller="list-filter">
  <div class="relative">
    <input type="search" autocomplete="off" placeholder="Filter accounts" data-list-filter-target="input" data-action="input->list-filter#filter" class="block w-full border border-secondary rounded-md py-2 pl-10 pr-3 bg-container focus:ring-gray-500 sm:text-sm">
    <%= icon("search", class: "absolute inset-y-0 left-2 top-1/2 transform -translate-y-1/2") %>
  </div>
  <div class="my-2" id="list" data-list-filter-target="list">
    <% Current.user.accessible_accounts.alphabetically.each do |account| %>
      <div class="filterable-item flex items-center gap-2 p-2" data-filter-name="<%= account.name %>">
        <%= form.check_box :accounts,
                           {
                             multiple: true,
                             checked: @q[:accounts]&.include?(account.name),
                             class: "checkbox checkbox--light"
                           },
                           account.name,
                           nil %>
        <%= form.label :accounts, account.name, value: account.name, class: "text-sm text-primary" %>
      </div>
    <% end %>
  </div>
</div>
