<core:FragmentDefinition
	xmlns:unittest="http://schemas.sap.com/sapui5/preprocessorextension/sap.fe.unittesting/1"
	xmlns="sap.m"
	xmlns:core="sap.ui.core"
	xmlns:dt="sap.ui.dt"
	xmlns:fl="sap.ui.fl"
	xmlns:fe="sap.fe.templates.ObjectPage.controls"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"
	template:require="{
			COMMON: 'sap/fe/macros/CommonHelper',
			ID: 'sap/fe/core/helpers/StableIdHelper',
			COMMONFORMATTERS: 'sap/fe/core/templating/CommonFormatters'
	}"
>
	<template:if test="{header>avatar}">
		<Avatar
			unittest:id="AvatarOPHeaderContent"
			class="sapUiSmallMarginEnd sapUiSmallMarginBottom"
			src="{header>avatar/src}"
			initials="{header>avatar/initials}"
			fallbackIcon="{header>avatar/fallbackIcon}"
			displayShape="{header>avatar/displayShape}"
			displaySize="XL"
			imageFitType="Contain"
			tooltip="{= COMMONFORMATTERS.getBindingWithText(${headerInfo>Title/Value@@UI.getDataModelObjectPath}) }"
		/>
	</template:if>
	<template:with path="converterContext>header/facets" var="converterHeaderFacets">
		<template:repeat list="{converterHeaderFacets>}" var="converterHeaderFacet">
			<template:if test="{= ${converterHeaderFacet>type} === 'Annotation'}">
				<!-- Header facets from OData Service Annotations -->
				<template:then>
					<template:with path="converterHeaderFacet>annotationPath" var="headerFacet">
						<template:with path="headerFacet>" var="collectionHeaderFacet">
							<template:if test="{= ${converterHeaderFacet>facetType} === 'Reference' }">
								<template:then>
									<core:Fragment fragmentName="sap.fe.templates.ObjectPage.view.fragments.HeaderFacet" type="XML" />
								</template:then>
								<template:elseif test="{= ${converterHeaderFacet>facetType} === 'Collection' }">
									<fe:StashableVBox
										id="{= ID.generate(['fe', 'HeaderCollectionFacetContainer', ${collectionHeaderFacet>@@UI.getDataModelObjectPath} ])}"
										dt:designtime="{= ${converterHeaderFacet>flexSettings/designtime} === 'Default' ? 'sap/fe/templates/ObjectPage/designtime/StashableVBox.designtime' : ${converterHeaderFacet>flexSettings/designtime}}"
										fl:flexibility="sap/fe/templates/ObjectPage/flexibility/StashableVBox.flexibility"
										stashed="{converterHeaderFacet>stashed}"
										displayInline="true"
									>
										<template:repeat list="{converterHeaderFacet>facets}" var="converterHeaderFacet">
											<template:with path="converterHeaderFacet>annotationPath" var="headerFacet">
												<core:Fragment
													fragmentName="sap.fe.templates.ObjectPage.view.fragments.HeaderFacet"
													type="XML"
												/>
											</template:with>
										</template:repeat>
									</fe:StashableVBox>
								</template:elseif>
							</template:if>
						</template:with>
					</template:with>
				</template:then>
				<template:elseif test="{= ${converterHeaderFacet>fragmentName}}">
					<!-- Custom header facets from manifest (FPM) -->
					<core:Fragment fragmentName="sap.fe.templates.ObjectPage.view.fragments.HeaderFacetCustomContainer" type="XML" />
				</template:elseif>
			</template:if>
		</template:repeat>
	</template:with>
</core:FragmentDefinition>
