All files / src/components FlowsSidebar.vue

94.57% Statements 122/129
84.29% Branches 102/121
96% Functions 48/50
98.14% Lines 106/108

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660  30x             194x                           2x                           2x                                     30x             4x   2x                             2x                                         10x                           194x           194x 2x                 90x                     194x                   194x                   30x                     90x           2x                   1x                         90x                       90x                           24x                   30x                             1x                                           30x 30x 30x 30x 30x 30x 30x 30x 30x       30x 30x 30x 30x 30x 30x     41x 30x 30x 30x 30x     30x 30x 30x 30x 30x   30x                   2x 2x   30x 155x   30x 10x   30x 34x   30x           64x           34x 30x 30x 34x     30x           20x 20x 20x 20x 20x   20x           11x 1x 1x   10x 10x       17x       11x 11x 11x 11x 11x                 3x 3x 3x         4x 4x 1x 1x   3x 3x 3x 3x       3x             153x     30x       30x     30x 10x               21x     30x 10x       30x 32x   2x 2x                                                                                                                                                                                                                                                                                                                                                                                                                                      
<template>
  <AppNavRail
    storage-key="sidebar-scroll-position"
    pinned-width="200px"
    tour="navigation"
    @scroll="onRailScroll"
  >
    <template #pinned>
      <!-- Flow switcher: sits above everything else, it sets the scope for -->
      <!-- the flow-dependent items (Members, Roles, Entities...) below -->
      <div ref="flowSwitcherRef" class="flow-switcher" data-tour="flow-switcher">
        <button
          type="button"
          class="nav-link flow-switcher-trigger"
          :class="{
            active: isFlowSwitcherOpen || isOnFlowScopedRoute,
            'flow-switcher-trigger-no-image': !currentFlowImageKey
          }"
          :aria-expanded="isFlowSwitcherOpen"
          :aria-label="flowSwitcherTriggerLabel"
          @click="toggleFlowSwitcher"
        >
          <div class="flow-switcher-avatar">
            <ImageField
              v-if="currentFlowImageKey"
              :model-value="currentFlowImageKey"
              :field="flowIconField"
              :is-editing="false"
              :entity-id="authStore.currentFlow || undefined"
              :item-id="authStore.currentFlow || undefined"
              :object-fit="currentFlowImageFit"
              :clickable="false"
              no-wrapper
              no-thumbnail
            />
          </div>
          <span class="flow-switcher-name">{{ flowSwitcherTriggerLabel }}</span>
          <font-awesome-icon
            icon="fa-solid fa-chevron-down"
            class="flow-switcher-chevron"
            :class="{ 'flow-switcher-chevron-open': isFlowSwitcherOpen }"
          />
        </button>
 
        <Teleport to="body">
          <div
            v-if="isFlowSwitcherOpen"
            ref="flowSwitcherPanelRef"
            class="flow-switcher-panel"
            :style="flowSwitcherPanelStyle"
          >
            <div v-if="sortedFlows.length === 0" class="flow-switcher-empty">
              {{ t('flow.noFlows') }}
            </div>
 
            <button
              v-for="flow in sortedFlows"
              :key="flow.flowId"
              type="button"
              class="flow-switcher-item"
              :class="{ 'flow-switcher-item-active': flow.flowId === authStore.currentFlow }"
              :disabled="switchingFlowId !== null"
              @click="selectFlow(flow.flowId)"
            >
              <div class="flow-switcher-item-avatar">
                <ImageField
                  v-if="getFlowImageKey(flow)"
                  :model-value="getFlowImageKey(flow)"
                  :field="flowIconField"
                  :is-editing="false"
                  :entity-id="flow.flowId"
                  :item-id="flow.flowId"
                  :object-fit="getFlowImageFit(flow)"
                  :clickable="false"
                  no-wrapper
                  no-thumbnail
                />
                <font-awesome-icon v-else icon="fa-solid fa-building" />
              </div>
              <span class="flow-switcher-item-name">{{ flow.flowName }}</span>
              <span
                v-if="switchingFlowId === flow.flowId"
                class="spinner-border spinner-border-sm ms-auto"
                role="status"
                aria-hidden="true"
              />
              <font-awesome-icon
                v-else-if="flow.flowId === authStore.currentFlow"
                icon="fa-solid fa-check"
                class="flow-switcher-item-check"
              />
            </button>
 
            <div class="flow-switcher-separator" />
 
            <router-link
              :to="{ name: 'flows' }"
              class="flow-switcher-manage"
              @click="closeFlowSwitcher"
            >
              <font-awesome-icon icon="fa-solid fa-gear" class="me-2" />
              {{ t('navigation.manageFlows') }}
              <span v-if="flowsCount > 0" class="badge bg-secondary ms-auto">{{ flowsCount }}</span>
            </router-link>
          </div>
        </Teleport>
      </div>
 
      <!-- Home: the flow's feed ("/" without a flow) -->
      <router-link
        :to="authStore.currentFlow ? flowLink('home') : { name: 'root' }"
        class="nav-link"
        :class="{ active: $route.name === 'home' || $route.name === 'root' }"
      >
        <font-awesome-icon icon="fa-solid fa-house" class="me-2" />
        {{ t('navigation.home') }}
      </router-link>
    </template>
 
    <!-- Separator -->
    <div class="nav-separator" />
    <div class="nav-section-title">{{ t('navigation.data') }}</div>
 
    <!-- Entities -->
    <router-link
      v-if="authStore.currentFlow"
      :to="flowLink('entities')"
      class="nav-link"
      :class="{ active: $route.name === 'entities' }"
    >
      <font-awesome-icon icon="fa-solid fa-cube" class="me-2" />
      {{ t('navigation.entities') }}
      <span v-if="entitiesCount > 0" class="badge bg-secondary ms-auto">{{ entitiesCount }}</span>
    </router-link>
 
    <!-- Catalog -->
    <router-link
      :to="flowLink('catalog')"
      class="nav-link"
      :class="{ active: $route.name === 'catalog' || $route.name === 'flowless-catalog' }"
    >
      <font-awesome-icon icon="fa-solid fa-globe" class="me-2" />
      {{ t('navigation.catalog') }}
    </router-link>
 
    <!-- Store: packs of entities anyone can install -->
    <router-link
      :to="flowLink('store')"
      class="nav-link"
      :class="{ active: $route.name === 'store' || $route.name === 'flowless-store' }"
    >
      <font-awesome-icon icon="fa-solid fa-store" class="me-2" />
      {{ t('navigation.store') }}
    </router-link>
 
    <!-- Moderation: reviewing needs no flow, any signed-in user can help -->
    <router-link
      :to="{ name: 'moderation' }"
      class="nav-link"
      :class="{ active: $route.name === 'moderation' }"
    >
      <font-awesome-icon icon="fa-solid fa-shield-halved" class="me-2" />
      {{ t('navigation.moderation') }}
    </router-link>
 
    <!-- Exports -->
    <router-link
      v-if="authStore.currentFlow"
      :to="flowLink('exports')"
      class="nav-link"
      :class="{ active: $route.name === 'exports' }"
    >
      <font-awesome-icon icon="fa-solid fa-file-export" class="me-2" />
      {{ t('navigation.exports') }}
    </router-link>
 
    <!-- Separator -->
    <div class="nav-separator" />
    <div class="nav-section-title">{{ t('navigation.flowsManagement') }}</div>
 
    <!-- The current flow's settings (UC-FLOW-009.1) -->
    <!-- Opens the edit sidebar over the current page, which stays open -->
    <button
      v-if="authStore.currentFlow && canManageFlow"
      type="button"
      class="nav-link"
      :class="{ active: editedFlowId === authStore.currentFlow }"
      data-testid="nav-flow-settings"
      @click="openFlowEdit(authStore.currentFlow)"
    >
      <font-awesome-icon icon="fa-solid fa-sliders" class="me-2" />
      {{ t('navigation.flowSettings') }}
    </button>
 
    <!-- Members -->
    <router-link
      v-if="authStore.currentFlow"
      :to="flowLink('members')"
      class="nav-link"
      :class="{ active: $route.name === 'members' }"
    >
      <font-awesome-icon icon="fa-solid fa-users" class="me-2" />
      {{ t('navigation.members') }}
      <span v-if="membersCount > 0" class="badge bg-secondary ms-auto">{{ membersCount }}</span>
    </router-link>
 
    <!-- Roles -->
    <router-link
      v-if="authStore.currentFlow"
      :to="flowLink('roles')"
      class="nav-link"
      :class="{ active: $route.name === 'roles' }"
    >
      <font-awesome-icon icon="fa-solid fa-shield-halved" class="me-2" />
      {{ t('navigation.roles') }}
      <span v-if="rolesCount > 0" class="badge bg-secondary ms-auto">{{ rolesCount }}</span>
    </router-link>
 
    <!-- Space pages (UC-SPACE-009.1): once the space is published; before, the
         space settings link to them -->
    <router-link
      v-if="authStore.currentFlow && canEditSpacePages && spacePublished"
      :to="flowLink('space-pages')"
      class="nav-link"
      :class="{ active: $route.name === 'space-pages' || $route.name === 'space-page-editor' }"
      data-testid="nav-space-pages"
    >
      <font-awesome-icon icon="fa-solid fa-file-lines" class="me-2" />
      {{ t('navigation.spacePages') }}
    </router-link>
 
    <!-- Invitations -->
    <router-link
      :to="{ name: 'invitations' }"
      class="nav-link"
      :class="{ active: $route.name === 'invitations' }"
    >
      <font-awesome-icon icon="fa-solid fa-paper-plane" class="me-2" />
      {{ t('navigation.invitations') }}
      <span v-if="pendingInvitationsCount > 0" class="badge bg-danger ms-auto">{{
        pendingInvitationsCount
      }}</span>
    </router-link>
 
    <!-- Administration (platform admins only) -->
    <div v-if="authStore.isPlatformAdmin" class="nav-separator" />
    <router-link
      v-if="authStore.isPlatformAdmin"
      :to="{ name: 'admin' }"
      class="nav-link"
      :class="{ active: $route.name === 'admin' }"
    >
      <font-awesome-icon icon="fa-solid fa-user-shield" class="me-2" />
      {{ t('navigation.administration') }}
    </router-link>
  </AppNavRail>
</template>
 
<script setup lang="ts">
// @implements UC-ADMIN-001.1, UC-FLOW-009.1
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useRolesStore } from '@/stores/roles'
import { useEntitiesStore } from '@/stores/entities'
import { useFlowsStore } from '@/stores/flows'
import { useAuthStore } from '@/stores/auth'
import { useUILanguage } from '@/composables/useUILanguage'
import { usePermissions } from '@/composables/usePermissions'
import ImageField from '@/components/ImageField.vue'
import AppNavRail from '@/components/AppNavRail.vue'
import { useFlowLink } from '@/composables/useFlowLink'
import { useFlowEditSidebar } from '@/composables/useFlowEditSidebar'
import { FLOW_ROUTE_NAMES, flowRoute, isFlowRoute, type FlowRouteName } from '@/router/flowRoutes'
 
const route = useRoute()
const router = useRouter()
const { flowLink, slugOf } = useFlowLink()
const rolesStore = useRolesStore()
const entitiesStore = useEntitiesStore()
const flowsStore = useFlowsStore()
const authStore = useAuthStore()
const { t } = useUILanguage()
const { hasPermission } = usePermissions()
 
// Listing may be denied for the current flow — skip these fetches to avoid
// guaranteed 403s in the console; badges simply show no count in that case.
const canListRoles = computed(() => hasPermission('roles:list'))
const canListEntities = computed(() => hasPermission('entities:list'))
const canListMembers = computed(() => hasPermission('members:list'))
const canEditSpacePages = computed(() => hasPermission('pages:update'))
const { editedFlowId, openFlowEdit } = useFlowEditSidebar()
const canManageFlow = computed(() => hasPermission('flows:update') || hasPermission('flows:delete'))
 
// Computed properties for badges
const pendingInvitationsCount = computed(() => rolesStore.invitations?.length || 0)
const entitiesCount = computed(() => entitiesStore.entities?.length || 0)
const rolesCount = computed(() => rolesStore.roles?.length || 0)
const membersCount = computed(() => flowsStore.currentFlowMembers?.length || 0)
const flowsCount = computed(() => flowsStore.myFlows?.length || 0)
 
// Flow switcher dropdown
const flowSwitcherRef = ref<HTMLElement | null>(null)
const flowSwitcherPanelRef = ref<HTMLElement | null>(null)
const isFlowSwitcherOpen = ref(false)
const switchingFlowId = ref<string | null>(null)
const flowIconField = { name: 'icon', type: 'image' as const, fieldId: 'flow-switcher-icon' }
// Pages about flows themselves, where the switcher is highlighted
const FLOW_MANAGEMENT_ROUTES = [
  'flows',
  'members',
  'roles',
  'invitations',
  'entities',
  'exports',
  'space-pages',
  'space-page-editor'
]
const FLOW_SWITCHER_PANEL_WIDTH = 220
const MOBILE_BREAKPOINT = 767
 
const isOnFlowScopedRoute = computed(() =>
  FLOW_MANAGEMENT_ROUTES.includes(String(route.name ?? ''))
)
const sortedFlows = computed(() =>
  [...flowsStore.myFlows].sort((a, b) => a.flowName.localeCompare(b.flowName))
)
const currentFlowObj = computed(
  () => flowsStore.myFlows.find((flow) => flow.flowId === authStore.currentFlow) || null
)
const spacePublished = computed(() => currentFlowObj.value?.space?.enabled === true)
 
// The flow's cover picture is the image most flows actually set, so it takes
// priority over the smaller logo-style icon; only fall back to a generic
// icon when the flow has neither.
function getFlowImageKey(flow: { picture?: string; icon?: string } | null): string | null {
  return flow?.picture || flow?.icon || null
}
function getFlowImageFit(flow: { picture?: string; icon?: string } | null): 'cover' | 'contain' {
  return flow?.picture ? 'cover' : 'contain'
}
 
const currentFlowImageKey = computed(() => getFlowImageKey(currentFlowObj.value))
const currentFlowImageFit = computed(() => getFlowImageFit(currentFlowObj.value))
const flowSwitcherTriggerLabel = computed(
  () => currentFlowObj.value?.flowName || t('navigation.selectFlow')
)
 
const flowSwitcherPanelStyle = ref<Record<string, string>>({ left: '0px', top: '0px' })
 
// The panel is teleported to <body> to escape the sidebar's overflow
// clipping and stacking context, so its position has to be computed from
// the trigger's viewport coordinates instead of plain CSS.
function updateFlowSwitcherPanelPosition() {
  const trigger = flowSwitcherRef.value?.querySelector('.flow-switcher-trigger')
  Iif (!trigger) return
  const rect = trigger.getBoundingClientRect()
  const left = Math.min(rect.left, window.innerWidth - FLOW_SWITCHER_PANEL_WIDTH - 8)
  const isMobile = window.innerWidth <= MOBILE_BREAKPOINT
 
  flowSwitcherPanelStyle.value = isMobile
    ? { left: `${left}px`, bottom: `${window.innerHeight - rect.top}px` }
    : { left: `${left}px`, top: `${rect.bottom}px` }
}
 
function toggleFlowSwitcher() {
  if (isFlowSwitcherOpen.value) {
    closeFlowSwitcher()
    return
  }
  updateFlowSwitcherPanelPosition()
  isFlowSwitcherOpen.value = true
}
 
function closeFlowSwitcher() {
  isFlowSwitcherOpen.value = false
}
 
function onClickOutsideFlowSwitcher(event: MouseEvent) {
  const target = event.target as Node | null
  Iif (!target) return
  Iif (flowSwitcherRef.value?.contains(target)) return
  Iif (flowSwitcherPanelRef.value?.contains(target)) return
  closeFlowSwitcher()
}
 
/**
 * The same page in the other flow (Members of A -> Members of B), except a
 * page about one of the current flow's objects (an entity), and the global
 * pages: those lead to the other flow's home.
 */
function switchTarget(flowSlug: string) {
  const name = String(route.name ?? '') as FlowRouteName
  const samePage = isFlowRoute(route) && name !== 'entity-items' && FLOW_ROUTE_NAMES.includes(name)
  return flowRoute(flowSlug, samePage ? name : 'home')
}
 
// Switching flow is going to the other flow's URL: only this tab changes flow
async function selectFlow(flowId: string) {
  const flowSlug = slugOf(flowId)
  if (flowId === authStore.currentFlow || !flowSlug) {
    closeFlowSwitcher()
    return
  }
  switchingFlowId.value = flowId
  try {
    await router.push(switchTarget(flowSlug))
    closeFlowSwitcher()
  } catch (err) {
    console.error('[FlowsSidebar] Failed to switch flow:', err)
  } finally {
    switchingFlowId.value = null
  }
}
 
// Keep the teleported panel aligned with the trigger as the menu scrolls or
// the window resizes
function onRailScroll() {
  if (isFlowSwitcherOpen.value) updateFlowSwitcherPanelPosition()
}
 
onMounted(async () => {
  // The flow switcher needs the flow list even when no flow is currently
  // selected, so this fetch runs unconditionally (unlike the flow-scoped
  // badges below).
  flowsStore.fetchMyFlows().catch((err) => console.error('Failed to load flows:', err))
 
  // Load data for badges, skipping fetches the user isn't allowed to list
  if (authStore.currentFlow) {
    await Promise.allSettled([
      canListEntities.value ? entitiesStore.fetchEntities() : Promise.resolve(),
      canListRoles.value ? rolesStore.fetchRoles(authStore.currentFlow) : Promise.resolve(),
      rolesStore.fetchInvitations(),
      canListMembers.value ? flowsStore.fetchMembers(authStore.currentFlow) : Promise.resolve()
    ])
  }
 
  document.addEventListener('mousedown', onClickOutsideFlowSwitcher)
})
 
onUnmounted(() => {
  document.removeEventListener('mousedown', onClickOutsideFlowSwitcher)
})
 
// Reload badges when flow changes or becomes available after initial auth
watch(
  () => authStore.currentFlow,
  async (newFlow) => {
    Eif (newFlow) {
      await Promise.allSettled([
        canListEntities.value ? entitiesStore.fetchEntities() : Promise.resolve(),
        canListRoles.value ? rolesStore.fetchRoles(newFlow) : Promise.resolve(),
        rolesStore.fetchInvitations(),
        canListMembers.value ? flowsStore.fetchMembers(newFlow) : Promise.resolve()
      ])
    }
  }
)
</script>
 
<style scoped>
/* The menu itself is AppNavRail's; only the flow switcher is styled here.
   Its selectors start with .flow-switcher to win over AppNavRail's .nav-link
   rules, which apply to the trigger too. */
.flow-switcher {
  position: relative;
  min-width: 0;
}
 
.flow-switcher .flow-switcher-trigger {
  padding: 0px 0px 0.75rem 0px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: none;
  background: var(--bw-navbar-bg) !important;
  color: var(--bw-navbar-text) !important;
  cursor: pointer;
  font: inherit;
}
 
/* No image: the avatar box is empty, so restore some top padding instead */
.flow-switcher .flow-switcher-trigger-no-image {
  padding-top: 0.75rem;
}
 
.flow-switcher .flow-switcher-avatar {
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.flow-switcher .flow-switcher-avatar svg {
  font-size: 1.5rem;
  margin-bottom: 0;
}
 
.flow-switcher .flow-switcher-avatar :deep(img) {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
 
.flow-switcher .flow-switcher-name {
  display: block;
  width: 100%;
  padding: 0 1rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
 
.flow-switcher .flow-switcher-chevron {
  font-size: 0.7rem !important;
  margin-top: 0.25rem;
  margin-bottom: 0 !important;
  transition: transform 0.2s;
}
 
.flow-switcher .flow-switcher-chevron-open {
  transform: rotate(180deg);
}
 
.flow-switcher-panel {
  /* Teleported to <body>: positioned in JS (viewport coordinates) so it
     escapes the sidebar's overflow clipping and stacking context, and can
     render above the rest of the page (form sidebars, header, etc.) */
  position: fixed;
  z-index: 1160;
  width: 220px;
  padding: 0px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bw-surface);
  color: var(--bw-text);
  border: 1px solid var(--bw-border);
  box-shadow: var(--bw-card-shadow-hover);
  text-align: left;
}
 
.flow-switcher-empty {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--bw-text-muted);
  text-align: center;
}
 
.flow-switcher-item,
.flow-switcher-manage {
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-align: left;
  text-decoration: none;
  color: var(--bw-text);
  cursor: pointer;
}
 
.flow-switcher-item:hover:not(:disabled),
.flow-switcher-manage:hover {
  background: var(--bw-card-clickable-hover-bg);
}
 
.flow-switcher-item:disabled {
  cursor: default;
  opacity: 0.6;
}
 
.flow-switcher-item-active {
  font-weight: 600;
}
 
.flow-switcher-item-avatar {
  width: 3rem;
  height: 1.5rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.flow-switcher-item-avatar svg {
  font-size: 1.1rem;
}
 
.flow-switcher-item-avatar :deep(img) {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: contain;
}
 
.flow-switcher-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
 
.flow-switcher-item-check {
  margin-left: 0.5rem;
  flex-shrink: 0;
  color: var(--bs-success, #198754);
}
 
.flow-switcher-separator {
  height: 1px;
  background: var(--bw-border);
  margin: 0.25rem 0;
}
 
.flow-switcher-manage .badge {
  margin-left: auto;
}
 
@media (max-width: 767px) {
  /* Bottom bar is too short for the flow picture: show a compact
     "name ›" trigger instead, with the chevron pointing right */
  .flow-switcher {
    align-self: stretch;
    display: flex;
  }
 
  .flow-switcher .flow-switcher-trigger,
  .flow-switcher .flow-switcher-trigger-no-image {
    flex-direction: row;
    justify-content: center;
    width: 110px;
    height: auto;
    padding: 0 0.5rem;
  }
 
  .flow-switcher .flow-switcher-avatar {
    display: none;
  }
 
  .flow-switcher .flow-switcher-name {
    width: auto;
    padding: 0;
    flex: 0 1 auto;
  }
 
  .flow-switcher .flow-switcher-chevron,
  .flow-switcher .flow-switcher-chevron-open {
    margin-top: 0;
    margin-left: 0.4rem;
    flex-shrink: 0;
    transform: rotate(-90deg);
  }
}
</style>