{{define "main"}}
<!DOCTYPE html>
<html class="h-full bg-gray-100">

<head>
  <title>PARCOURSMOB</title>
  <link rel="stylesheet" href="/public/css/main.css" />
  <link href="https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.snow.css" rel="stylesheet" />
  <link href="https://cdn.jsdelivr.net/npm/maplibre-gl@^5.2.0/dist/maplibre-gl.css" rel="stylesheet" />
  <script src="https://cdn.jsdelivr.net/npm/@kingshott/iodine@8.1.0/dist/iodine.min.umd.js" defer></script>
  <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/maplibre-gl@^5.2.0/dist/maplibre-gl.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/pmtiles@^4.3.0/dist/pmtiles.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@protomaps/basemaps@5/dist/basemaps.js" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/polyline@0.2.0/src/polyline.js"></script>
  <!--<script defer type="text/javascript" src="/public/js/main.js" defer></script>-->
</head>

<body class="h-full" x-data="{ offCanvasMenu: false }">
  <div class="relative z-40 md:hidden" role="dialog" aria-modal="true">

    <div class="fixed inset-0 bg-gray-600 bg-opacity-75" x-show="offCanvasMenu"
      x-transition:enter="transition-opacity ease-linear duration-300" x-transition:enter-start="opacity-0"
      x-transition:enter-end="opacity-100" x-transition:leave="transition-opacity ease-linear duration-300"
      x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0"></div>

    <div class="fixed inset-0 flex z-40" x-show="offCanvasMenu"
      x-transition:enter="transition ease-in-out duration-300 transform" x-transition:enter-start="-translate-x-full"
      x-transition:enter-end="translate-x-0" x-transition:leave="transition ease-in-out duration-300 transform"
      x-transition:leave-start="translate-x-0" x-transition:leave-end="-translate-x-full">
      <div class="relative flex-1 flex flex-col max-w-xs w-full pt-5 pb-4 bg-co-blue">
        <div class="absolute top-0 right-0 -mr-12 pt-2" @click="offCanvasMenu = false">
          <button type="button"
            class="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white">
            <span class="sr-only">Close sidebar</span>
            {{ .IconSet.Icon "hero:outline/x" "h-6 w-6" }}
          </button>
        </div>

        <div class="flex-shrink-0 flex items-center px-4">
          <img class="h-8 w-auto" src="/public/images/mobicoop-solidaire.png" alt="Mobicoop Solidaire">
        </div>
        <div class="mt-5 flex-1 h-0 overflow-y-auto">

          {{ template "mainmenu" . }}

        </div>
      </div>

      <div class="flex-shrink-0 w-14" aria-hidden="true">
        <!-- Dummy element to force sidebar to shrink to fit close icon -->
      </div>
    </div>
  </div>

  <!-- Static sidebar for desktop -->
  <div class="hidden md:flex md:w-64 md:flex-col md:fixed md:inset-y-0">
    <!-- Sidebar component, swap this element with another sidebar if you like -->
    <div class="flex flex-col flex-grow pt-5 bg-co-blue overflow-y-auto">
      <div class="flex items-center flex-shrink-0 px-4">
        <img class="h-8 w-auto" src="/public/images/mobicoop-solidaire.png" alt="Mobicoop Solidaire">
      </div>
      <div class="mt-5 flex-1 flex flex-col">
        {{ template "mainmenu" . }}
      </div>
    </div>
  </div>
  <div class="md:pl-64 flex flex-col flex-1">
    <div class="sticky top-0 z-10 flex-shrink-0 flex h-16 bg-white shadow">
      <button @click="offCanvasMenu = true" type="button"
        class="px-4 border-r border-gray-200 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-co-blue md:hidden">
        <span class="sr-only">Open sidebar</span>
        <!-- Heroicon name: outline/menu-alt-2 -->
        <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2"
          stroke="currentColor" aria-hidden="true">
          <path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h7" />
        </svg>
      </button>
      <div class="flex-1 px-4 flex justify-between">
        <div class="flex-1 flex">
          <form class="w-full flex md:ml-0" action="/app/beneficiaries/" method="GET">
            <label for="search-field" class="sr-only">Search</label>
            <div class="relative w-full text-gray-400 focus-within:text-gray-600">
              <div class="absolute inset-y-0 left-0 flex items-center pointer-events-none">
                <!-- Heroicon name: solid/search -->
                {{$.IconSet.Icon "hero:solid/search" "h5 w-5"}}
              </div>
              <input id="search-field"
                class="block w-full h-full pl-8 pr-3 py-2 border-transparent text-gray-900 placeholder-gray-500 focus:outline-none focus:placeholder-gray-400 focus:ring-0 focus:border-transparent sm:text-sm"
                placeholder="Chercher un bénéficiaire" type="search" name="search">
            </div>
          </form>
        </div>
        <div class="ml-4 flex items-center md:ml-6">


          <a href="/app/administration/">
            {{if and .AdministrationState.Display .AdministrationState.Active}}
            <button
              class="max-w-xs bg-co-blue px-4 py-2 text-white flex items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
              {{.IconSet.Icon "hero:outline/cog" "h-6 w-6"}} Administration
            </button>
            {{else if and .AdministrationState.Display}}
            <button
              class="max-w-xs bg-white hover:bg-gray-50 border-gray-300 border px-4 py-2 text-gray-700 flex items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
              {{.IconSet.Icon "hero:outline/cog" "h-6 w-6"}} Administration
            </button>
            {{end}}
          </a>
          <div class="ml-3 relative" x-data="{ groupMenuOpen: false }">
            <div>
              <button @click="groupMenuOpen = ! groupMenuOpen" type="button"
                class="max-w-xs bg-white hover:bg-gray-50 border-gray-300 border px-4 py-2 text-gray-700 flex items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
                {{.Group.Data.name}}
              </button>
            </div>
            <div
              class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
              role="menu" aria-orientation="vertical" aria-labelledby="group-menu-button" tabindex="-1"
              x-show="groupMenuOpen" x-transition:enter="transition ease-out duration-100"
              x-transition:enter-start="transform opacity-0 scale-95"
              x-transition:enter-end="transform opacity-100 scale-100"
              x-transition:leave="transition ease-in duration-75"
              x-transition:leave-start="transform opacity-100 scale-100"
              x-transition:leave-end="transform opacity-0 scale-95">
              <!-- Active: "bg-gray-100", Not Active: "" -->
              <a href="/app/group/settings" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1"
                id="user-menu-item-1">Paramètres</a>

              <a href="/auth/groups/switch" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1"
                id="user-menu-item-2">Changer d'organisation</a>
            </div>

          </div>

          <!-- Profile dropdown -->
          <div class="ml-3 relative" x-data="{ profileMenuOpen: false }">
            <div>
              <!-- <button @click="profileMenuOpen = ! profileMenuOpen" type="button" -->
              <button  @click="profileMenuOpen = ! profileMenuOpen" type="button"
                class="max-w-xs bg-white flex items-center text-sm rounded-co focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue"
                id="user-menu-button" aria-expanded="false" aria-haspopup="true">
                <span class="sr-only">Open user menu</span>
                <img class="h-8 w-8 rounded-co"
                  src="/app/beneficiaries/{{.UserID}}/picture"
                  alt="Menu utilisateur">
              </button>
            </div>

            <div
              class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
              role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1"
              x-show="profileMenuOpen" x-transition:enter="transition ease-out duration-100"
              x-transition:enter-start="transform opacity-0 scale-95"
              x-transition:enter-end="transform opacity-100 scale-100"
              x-transition:leave="transition ease-in duration-75"
              x-transition:leave-start="transform opacity-100 scale-100"
              x-transition:leave-end="transform opacity-0 scale-95">
              <!-- Active: "bg-gray-100", Not Active: "" -->
              <a href="/app/members/{{.UserID}}" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1"
                id="user-menu-item-0">Votre profil</a>

              <a href="/app/members/{{.UserID}}/update" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1"
                id="user-menu-item-1">Paramètres</a>

              <a href="/auth/disconnect" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1"
                id="user-menu-item-2">Se déconnecter</a>
            </div>
          </div>
        </div>
      </div>
    </div>

    <main>
      <div class="py-6">
        {{ template "content" . }}
      </div>
    </main>
  </div>
  </div>
</body>

</html>
{{end}}
