<?xml version="1.0" encoding="utf-8" ?>
<local:SearchPageControlBase
    x:Class="BiliCopilot.UI.Controls.Search.SearchHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:components="using:BiliCopilot.UI.ViewModels.Components"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:BiliCopilot.UI.Controls.Search"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <UserControl.Resources>
        <DataTemplate x:Key="VideoTemplate" x:DataType="components:VideoSearchSectionDetailViewModel">
            <local:VideoSearchExtraHeader ViewModel="{x:Bind}" />
        </DataTemplate>
        <DataTemplate x:Key="EmptyTemplate">
            <Border />
        </DataTemplate>
        <ext:SearchSectionTemplateSelector
            x:Key="ExtraSelector"
            ArticleTemplate="{StaticResource EmptyTemplate}"
            LiveTemplate="{StaticResource EmptyTemplate}"
            PgcTemplate="{StaticResource EmptyTemplate}"
            UserTemplate="{StaticResource EmptyTemplate}"
            VideoTemplate="{StaticResource VideoTemplate}" />
    </UserControl.Resources>

    <Grid Padding="16,0" ColumnSpacing="8">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock
            VerticalAlignment="Center"
            MaxLines="1"
            Style="{StaticResource BodyStrongTextBlockStyle}"
            TextTrimming="CharacterEllipsis">
            <Run Text="{ext:Locale Name=Search}" />
            <Run Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" Text="{x:Bind ViewModel.Keyword, Mode=OneWay}" />
        </TextBlock>
        <ContentControl
            Grid.Column="1"
            Content="{x:Bind ViewModel.SelectedSection, Mode=OneWay}"
            ContentTemplateSelector="{StaticResource ExtraSelector}"
            Style="{StaticResource AppContentControlStyle}" />
        <Button
            Grid.Column="2"
            VerticalAlignment="Center"
            AutomationProperties.Name="{ext:Locale Name=Refresh}"
            Command="{x:Bind ViewModel.SelectedSection.RefreshCommand, Mode=OneWay}"
            IsEnabled="{x:Bind ViewModel.SelectedSection.IsEmpty, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
            ToolTipService.ToolTip="{ext:Locale Name=Refresh}">
            <StackPanel Orientation="Horizontal" Spacing="8">
                <ic:SymbolIcon
                    VerticalAlignment="Center"
                    FontSize="12"
                    Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                    Symbol="ArrowSync" />
                <TextBlock VerticalAlignment="Center" Text="{ext:Locale Name=Refresh}" />
            </StackPanel>
        </Button>
    </Grid>
</local:SearchPageControlBase>
