{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
}}

<BlockSlot @name='header'>
  <dl class={{@item.MeshStatus}}>
    <dt>
      Health
    </dt>
    <dd {{tooltip @item.healthTooltipText}}></dd>
  </dl>
  {{#if (gt @item.InstanceCount 0)}}
    <a
      data-test-service-name
      href={{href-to
        'dc.services.show.index'
        @item.Name
        params=this.linkParams
      }}
    >
      {{@item.Name}}
    </a>
  {{else}}
    <p data-test-service-name>
      {{@item.Name}}
    </p>
  {{/if}}
</BlockSlot>
<BlockSlot @name='details'>
  <Consul::Kind @item={{@item}} />
  <Consul::ExternalSource @item={{@item}} />
  {{#if
    (and
      (not-eq @item.InstanceCount 0)
      (and (not-eq @item.Kind 'terminating-gateway') (not-eq @item.Kind 'ingress-gateway'))
    )
  }}
    <span>
      {{format-number @item.InstanceCount}}
      {{pluralize @item.InstanceCount 'instance' without-count=true}}
    </span>
  {{/if}}
  {{! we are displaying imported-services - don't show bucket-list }}
  {{#unless @isPeerDetail}}
    <Consul::Bucket::List @item={{@item}} @nspace={{@nspace}} @partition={{@partition}} />
  {{/unless}}
  {{#if (eq @item.Kind 'terminating-gateway')}}
    <span data-test-associated-service-count>
      {{format-number @item.GatewayConfig.AssociatedServiceCount}}
      {{pluralize @item.GatewayConfig.AssociatedServiceCount 'linked service' without-count=true}}
    </span>
  {{else if (eq @item.Kind 'ingress-gateway')}}
    <span data-test-associated-service-count>
      {{format-number @item.GatewayConfig.AssociatedServiceCount}}
      {{pluralize @item.GatewayConfig.AssociatedServiceCount 'upstream' without-count=true}}
    </span>
  {{/if}}
  {{#if (or @item.ConnectedWithGateway @item.ConnectedWithProxy)}}
    <dl class='mesh'>
      <dt>
        <Tooltip>
          This service uses a proxy for the Consul service mesh
        </Tooltip>
      </dt>
      {{#if (and @item.ConnectedWithGateway @item.ConnectedWithProxy)}}
        <dd data-test-mesh>
          in service mesh with proxy and gateway
        </dd>
      {{else if @item.ConnectedWithProxy}}
        <dd data-test-mesh>
          in service mesh with proxy
        </dd>
      {{else if @item.ConnectedWithGateway}}
        <dd data-test-mesh>
          in service mesh with gateway
        </dd>
      {{/if}}
    </dl>
  {{/if}}
  <TagList @item={{@item}} />
</BlockSlot>