{{ define "fragments/starBtn" }}
    {{/* NOTE: this fragment is always replaced with hx-swap-oob */}}
    <button
        id="starBtn"
        class="btn disabled:opacity-50 disabled:cursor-not-allowed flex gap-2 items-center group"
        data-star-subject-at="{{ .SubjectAt }}"
        {{ if .IsStarred }}
            hx-delete="/star?subject={{ .SubjectAt }}&countHint={{ .StarCount }}"
        {{ else }}
            hx-post="/star?subject={{ .SubjectAt }}&countHint={{ .StarCount }}"
        {{ end }}
        {{ if .HxSwapOob }}hx-swap-oob='outerHTML:#starBtn[data-star-subject-at="{{ .SubjectAt }}"]'{{ end }}

        hx-trigger="click"
        hx-disabled-elt="#starBtn"
    >
        {{ if .IsStarred }}
            {{ i "star" "w-4 h-4 fill-current inline group-[.htmx-request]:hidden" }}
        {{ else }}
            {{ i "star" "w-4 h-4 inline group-[.htmx-request]:hidden" }}
        {{ end }}
        {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
        <span class="text-sm">
            {{ .StarCount }}
        </span>
    </button>
{{ end }}
