{{ define "labels/fragments/label" }}
  {{ $d := .def }}
  {{ $v := .val }}
  {{ $withPrefix := .withPrefix }}

  {{ $lhs := printf "%s" $d.Name }}
  {{ $rhs := "" }}
  {{ $isDid := false }}
  {{ $resolvedVal := "" }}

  {{ if not $d.ValueType.IsNull }}
    {{ $isDid = $d.ValueType.IsDidFormat }}
    {{ if $isDid }}
      {{ $resolvedVal = resolve $v }}
      {{ $v = $resolvedVal }}
    {{ end }}

    {{ if not $withPrefix }}
      {{ $lhs = "" }}
    {{ else }}
      {{ $lhs = printf "%s/" $d.Name }}
    {{ end }}

    {{ $rhs = printf "%s" $v }}
  {{ end }}

  {{ $chipClasses := "w-fit flex items-center gap-2 font-normal normal-case rounded py-1 px-2 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-sm text-inherit" }}

  {{ if $isDid }}
    <a href="/{{ $resolvedVal }}" class="{{ $chipClasses }} no-underline hover:underline">
      {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }}
      {{ printf "%s%s" $lhs $rhs }}
    </a>
  {{ else }}
    <span class="{{ $chipClasses }}">
      {{ template "repo/fragments/colorBall" (dict "color" $d.GetColor) }}
      {{ printf "%s%s" $lhs $rhs }}
    </span>
  {{ end }}
{{ end }}


{{ define "labelVal" }}
  {{ $d := .def }}
  {{ $v := .val }}

  {{ if $d.ValueType.IsDidFormat }}
      {{ resolve $v }}
  {{ else }}
    {{ $v }}
  {{ end }}
{{ end }}
