<!--
~ Copyright (C) 2023 StApps
~ This program is free software: you can redistribute it and/or modify it
~ under the terms of the GNU General Public License as published by the Free
~ Software Foundation, version 3.
~
~ This program is distributed in the hope that it will be useful, but WITHOUT
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
~ more details.
~
~ You should have received a copy of the GNU General Public License along with
~ this program. If not, see <https://www.gnu.org/licenses/>.
-->

@if (path | async; as stack) {
  <ion-breadcrumbs
    color="light"
    [itemsBeforeCollapse]="1"
    [itemsAfterCollapse]="(($width | async) ?? 0) >= 768 ? 1 : 0"
    [maxItems]="maxItems"
    (ionCollapsedClick)="maxItems = undefined"
  >
    @for (fragment of stack; track fragment) {
      <ion-breadcrumb>
        <ion-label
          (click)="dataRoutingService.emitPathEvent(fragment)"
          [style.max-width]="
            stack.length === 1
              ? '100%'
              : stack.length === 2
                ? '40vw'
                : (($width | async) ?? 0) >= 768
                  ? '30vw'
                  : 'calc(100vw - 120px)'
          "
          class="crumb-label"
          >{{ 'name' | thingTranslate: $any(fragment) }}</ion-label
        >
      </ion-breadcrumb>
    }
  </ion-breadcrumbs>
}
