{{define "journeys_public_transit"}}

{{ if or (not .ViewState.journeys) (eq (len .ViewState.journeys.Journeys) 0)}}
<p class="p-12 text-gray-500 text-center text-md">Aucun transport en commun pour ce trajet.</p>
{{end}}

{{$first := true}}
{{if .ViewState.journeys}}
{{range .ViewState.journeys.Journeys}}
{{if $first}}
{{$first = false}}
<div class="p-4 pb-8">
{{else}}
<div class="p-4 border-t-2 pb-8">
{{end}}
    <div class="flex text-md text-grey-900 font-bold">
        <div class="flex-1">{{(timeFrom .Departure).Format "15:04"}} - {{(timeFrom .Arrival).Format "15:04"}}</div>
        <div>{{.Duration.Minutes | printf "%.0f"}} Minutes</div>
    </div>
    <div class="flow-root">

        <ul role="list" class="-mb-8">
            {{$firstwalk := true}}
            {{range .Sections}}
            {{if eq .Type "street_network"}}
            <li>
                <div class="relative py-4">
                    {{if $firstwalk}}
                    {{$firstwalk = false}}
                    <span class="absolute top-4 left-4 -ml-px h-full w-0.5 bg-gray-200" aria-hidden="true"></span>
                    {{end}}
                    <div class="relative flex space-x-3">
                        <div>
                          <span class="ml-2 h-4 w-4 rounded-co bg-gray-200 flex items-center justify-center ring-8 ring-white text-white">
                            {{$.IconSet.Icon "tabler-icons:walk" "h-3 w-3 stroke-gray-800"}}
                          </span>
                        </div>
                        <div class="flex min-w-0 flex-1 justify-between space-x-4 pt-1.5">
                          <div>
                            <p class="text-xs text-gray-500">Marcher  <a href="#" class="font-medium text-gray-900">{{walkingLength .}}m</a></p>
                          </div>
                        </div>
                      </div>
                </div>
            </li>
            {{end}}
            {{if eq .Type "public_transport"}}
            <li>
                <div class="relative py-4">
                    <span class="absolute top-4 left-4 -ml-px h-full w-0.5 bg-gray-200" aria-hidden="true"></span>
                    <div class="relative flex space-x-3">
                        <div>
                          <span class="h-8 w-8 rounded-co bg-co-blue flex items-center justify-center ring-8 ring-white">
                            {{$.IconSet.Icon "tabler-icons:bus" "h-5 w-5 stroke-white"}}
                          </span>
                        </div>
                        <div class="flex min-w-0 flex-1 justify-between space-x-4 pt-1.5">
                            <div>
                              <p class="text-md text-gray-500">{{if eq .Display.Network "Antibes - Envibus"}}Envibus{{else}}{{.Display.Network}}{{end}} <a href="#" class="font-medium text-gray-900">Ligne {{.Display.Label}}</a></p>
                            </div>
                        </div>
                      </div>
                      <div class="ml-16 pt-2">
                        <div>
                            <p class="text-sm text-gray-500">Départ <a href="#" class="font-medium text-gray-900">{{(timeFrom .Departure).Format "15:04"}}</a> - Arrivée <a href="#" class="font-medium text-gray-900">{{(timeFrom .Arrival).Format "15:04"}}</a></p>
                          </div>
                          <div>
                            <p class="text-sm text-gray-500">De <a href="#" class="font-medium text-gray-900">{{.From.Name}}</a> à <a href="#" class="font-medium text-gray-900">{{.To.Name}}</a></p>
                          </div>
                          <div>
                            <p class="text-sm text-gray-500">Direction <a href="#" class="font-medium text-gray-900">{{.Display.Direction}}</a></p>
                          </div>
                      </div>
                </div>
            </li>
            {{end}}
            {{end}}
        </ul>
    </div>
</div>
{{end}}
{{end}}
{{end}}
