disabled
  6   ˆl–Ü4ý('ÜZÔâ€vàZ¸ÓJbÑ¿�þC ßYÆÈÜ�¸Ûnoÿ?Àƒu·Ù¿ÃÂ ©    <!-- Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/ -->

<script setup lang="ts">
import { computed, onBeforeMount, ref, watch } from 'vue'

import { useReducedMotion } from '#shared/composables/useReducedMotion.ts'
import emitter from '#shared/utils/emitter.ts'

import { useTransitionConfig } from '#desktop//composables/useTransitionConfig.ts'
import CommonBreadcrumb from '#desktop/components/CommonBreadcrumb/CommonBreadcrumb.vue'
import type { BreadcrumbItem } from '#desktop/components/CommonBreadcrumb/types.ts'
import CommonHelpText from '#desktop/components/CommonPageHelp/CommonHelpText.vue'
import CommonPageHelp from '#desktop/components/CommonPageHelp/CommonPageHelp.vue'
import CommonNavigationTabs from '#desktop/components/CommonTabs/CommonNavigationTabs/CommonNavigationTabs.vue'
import type { NavigationTab } from '#desktop/components/CommonTabs/types.ts'
import LayoutBottomBar from '#desktop/components/layout/LayoutBottomBar.vue'
import LayoutMain from '#desktop/components/layout/LayoutMain.vue'
import LayoutSidebar from '#desktop/components/layout/LayoutSidebar.vue'
import { useSidebarDisplay } from '#desktop/components/layout/useSidebarDisplay.ts'
import { useAppBreakpoints } from '#desktop/composables/responsiveness/useAppBreakpoints.ts'
import { useResizeGridColumns } from '#desktop/composables/useResizeGridColumns.ts'

import {
  SidebarName,
  SidebarPosition,
  type BackgroundVariant,
  type ContentAlignment,
  type ContentWidth,
} from './types.ts'

export interface Props {
  name?: string
  breadcrumbItems?: BreadcrumbItem[]
  width?: ContentWidth
  backgroundVariant?: BackgroundVariant
  contentAlignment?: ContentAlignment
  helpText?: string[] | string
  /**
   * Hides `default slot` content and shows help text if provided
   */
  showInlineHelp?: boolean
  showSidebar?: boolean
  /**
   * Identifies the content sidebar's collapsed state and persisted width, so
   * sections using this layout do not share them.
   */
  sidebarName?: SidebarName
  noPadding?: boolean
  /**
   * Removes padding from main container
   * Applies padding to breadcrumb container
   * âš ï¸� Set manually the padding to the default slot container p-4
   */
  contentPadding?: boolean
  /**
   * Disables the vertical scroll on the main element
   */
  noScrollable?: boolean
  tabs?: NavigationTab[]
  activeTab?: NavigationTab['key']
}

const props = withDefaults(defineProps<Props>(), {
  name: 'content',
  backgroundVariant: 'tertiary',
  width: 'full',
  showInlineHelp: false,
  contentAlignment: 'start',
  activeTab: '',
  sidebarName: SidebarName.TicketContent,
})

const maxWidth = computed(() => (props.width === 'narrow' ? '600px' : undefined))

const contentAlignmentClass = computed(() => {
  return props.contentAlignment === 'center' ? 'items-center' : ''
})

const noTransition = ref(false)

const {
  currentSidebarWidth,
  maxSidebarWidth,
  minSidebarWidth,
  gridColumns,
  resizeSidebar,
  resetSidebarWidth,
} = useResizeGridColumns(props.sidebarName, SidebarPosition.End)

const { transitions } = useTransitionConfig()

const { isSmallScreen } = useAppBreakpoints()
// Needed to make the breakpoint detection work within the layout, which is relevant for the sidebar display behavior
const { isSidebarCollapsed: isPrimaryNavSidebarCollapsed } = useSidebarDisplay(SidebarName.Primary)

const { isSidebarCollapsed: isContentSidebarCollapsed, toggleSidebar: toggleContentSidebar } =
  useSidebarDisplay(props.sidebarName)

// When the primary nav expands on a small screen (<1024px), collapse the content sidebar.
watch(isPrimaryNavSidebarCollapsed, (isCollapsed) => {
  if (!isSmallScreen.value || isCollapsed) return

  toggleContentSidebar(true, { storage: 'session' })
})

watch(isSmallScreen, (smallScreen) => {
  if (!smallScreen) return

  if (!isContentSidebarCollapsed.value) toggleContentSidebar(true, { storage: 'session' })
})

onBeforeMount(() => {
  // When the screen shrinks into the small viewport(<1024px) and both si