{{ with .Inner }}{{/* don't do anything, just call it */}}{{ end }}
{{ $first := urlize (index (.Store.Get "tabs") 0).name }}
{{ $group := .Get "group" }}
{{ $groupID := fmt.Printf "tabgroup-%s" (urlize $group) }}
{{ $persist := .Get "persist" }}


<div
  class="tabs"
  {{ with $group }}
    {{ if $persist }}
      x-data="{ selected: $persist('{{ $first }}').as('{{ $groupID }}') }"
    {{ else }}
      x-data="{ selected: '{{ $first }}' }"
    {{ end }}
    @tab-select.window="$event.detail.group === '{{ . }}' ? selected =
    $event.detail.name : null"
  {{ else }}
    x-data="{ selected: '{{ $first }}' }"
  {{ end }}
  aria-role="tabpanel"
>
  <div aria-role="tablist" class="tablist">
    {{ range (.Store.Get "tabs") }}
      <button
        class="tab-item"
        :class="selected === '{{ .name | urlize }}' &&
          'border-blue border-b-4 dark:border-b-blue-600'"
        {{ if $group }}
          @click="$dispatch('tab-select', { group: '{{ $group }}', name:
          '{{ .name | urlize }}'})"
        {{ else }}
          @click="selected = '{{ .name | urlize }}'"
        {{ end }}
      >
        {{ .name | page.RenderString }}
      </button>
    {{ end }}
  </div>
  <div>
    {{ range (.Store.Get "tabs") }}
      <div
        aria-role="tab"
        :class="selected !== '{{ .name | urlize }}' && 'hidden'"
      >
        {{ .content | page.RenderString (dict "display" "block") }}
      </div>
    {{ end }}
  </div>
</div>
