<?xml version="1.0" encoding="utf-8" ?>
<local:ChatServicePageControlBase
    x:Class="RodelAgent.UI.Controls.Chat.ChatServiceHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:RodelAgent.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:RodelAgent.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:RodelAgent.UI.Controls.Chat"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:winui="using:CommunityToolkit.WinUI"
    mc:Ignorable="d">

    <UserControl.Resources>
        <Style
            x:Key="SelectorCardStyle"
            BasedOn="{StaticResource DefaultCardPanelStyle}"
            TargetType="controls:CardPanel">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="CheckedBackground" Value="{ThemeResource SelectorCardCheckedBackgroundBrsuh}" />
            <Setter Property="CheckedForeground" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
            <Setter Property="CheckedPointerOverBackground" Value="{ThemeResource SelectorCardCheckedPointerOverBackgroundBrsuh}" />
            <Setter Property="CheckedPointerOverForeground" Value="{ThemeResource AccentTextFillColorSecondaryBrush}" />
            <Setter Property="CheckedPressedBackground" Value="{ThemeResource SelectorCardCheckedPressedBackgroundBrsuh}" />
            <Setter Property="CheckedPressedForeground" Value="{ThemeResource AccentTextFillColorTertiaryBrush}" />
            <Setter Property="StrokeThickness" Value="0" />
        </Style>
    </UserControl.Resources>

    <StackPanel Padding="20,12,20,0" Spacing="12">
        <Grid ColumnSpacing="12">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Style="{StaticResource SubtitleTextBlockStyle}"
                Text="{ext:Locale Name=MyChat}"
                TextTrimming="CharacterEllipsis" />
            <StackPanel Grid.Column="1" Orientation="Horizontal">
                <Button
                    AutomationProperties.Name="{ext:Locale Name=NewAgent}"
                    Command="{x:Bind ViewModel.AddAgentCommand}"
                    Style="{StaticResource IconButtonStyle}"
                    ToolTipService.ToolTip="{ext:Locale Name=NewAgent}">
                    <ic:SymbolIcon
                        FontSize="14"
                        Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                        IconVariant="Filled"
                        Symbol="BotAdd" />
                </Button>
                <Button
                    AutomationProperties.Name="{ext:Locale Name=MoreOptions}"
                    Style="{StaticResource IconButtonStyle}"
                    ToolTipService.ToolTip="{ext:Locale Name=MoreOptions}">
                    <ic:SymbolIcon
                        FontSize="14"
                        IconVariant="Filled"
                        Symbol="MoreHorizontal" />
                    <Button.Flyout>
                        <MenuFlyout Placement="Bottom">
                            <MenuFlyoutItem
                                x:Name="AddGroupItem"
                                MinWidth="200"
                                Command="{x:Bind ViewModel.AddGroupCommand}"
                                Text="{ext:Locale Name=CreateGroup}">
                                <MenuFlyoutItem.Icon>
                                    <ic:SymbolIcon Symbol="ChatMultiple" />
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                            <MenuFlyoutItem
                                x:Name="ImportPluginItem"
                                MinWidth="200"
                                Command="{x:Bind ViewModel.ImportPluginCommand}"
                                Text="{ext:Locale Name=ImportPlugin}">
                                <MenuFlyoutItem.Icon>
                                    <ic:SymbolIcon Symbol="FlashAdd" />
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                        </MenuFlyout>
                    </Button.Flyout>
                </Button>
            </StackPanel>
        </Grid>
        <Grid
            x:Name="SectionTypeContainer"
            Height="46"
            Padding="4"
            HorizontalAlignment="Stretch"
            Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
            ColumnSpacing="4"
            CornerRadius="{StaticResource ControlCornerRadius}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <controls:CardPanel
                x:Name="ServiceButton"
                HorizontalAlignment="Stretch"
                AutomationProperties.Name="{ext:Locale Name=ServiceAndAgent}"
                Click="OnServiceButtonClick"
                IsChecked="{x:Bind ViewModel.IsServiceSectionVisible, Mode=OneWay}"
                Style="{StaticResource SelectorCardStyle}">
                <Grid Margin="12,8">
                    <StackPanel
                        x:Name="ServiceContainer"
                        HorizontalAlignment="Center"
                        Orientation="Horizontal"
                        Spacing="8">
                        <ic:SymbolIcon
                            VerticalAlignment="Center"
                            FontSize="12"
                            IconVariant="{x:Bind GetIconVariant(ViewModel.IsServiceSectionVisible), Mode=OneWay}"
                            Symbol="BotSparkle" />
                        <TextBlock
                            x:Name="ServiceBlock"
                            VerticalAlignment="Center"
                            Style="{StaticResource CaptionTextBlockStyle}"
                            Text="{ext:Locale Name=ServiceAndAgent}" />
                    </StackPanel>
                </Grid>
            </controls:CardPanel>
            <controls:CardPanel
                x:Name="PresetButton"
                Grid.Column="1"
                HorizontalAlignment="Stretch"
                AutomationProperties.Name="{ext:Locale Name=PluginManagement}"
                Click="OnPresetButtonClick"
                IsChecked="{x:Bind ViewModel.IsPluginSectionVisible, Mode=OneWay}"
                Style="{StaticResource SelectorCardStyle}">
                <Grid Margin="12,8">
                    <StackPanel
                        x:Name="PresetContainer"
                        HorizontalAlignment="Center"
                        Orientation="Horizontal"
                        Spacing="8">
                        <ic:SymbolIcon
                            VerticalAlignment="Center"
                            FontSize="12"
                            IconVariant="{x:Bind GetIconVariant(ViewModel.IsPluginSectionVisible), Mode=OneWay}"
                            Symbol="FlashSparkle" />
                        <TextBlock
                            x:Name="PresetBlock"
                            VerticalAlignment="Center"
                            Style="{StaticResource CaptionTextBlockStyle}"
                            Text="{ext:Locale Name=PluginManagement}" />
                    </StackPanel>
                </Grid>
            </controls:CardPanel>
        </Grid>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="DefaultState">
                    <VisualState.StateTriggers>
                        <winui:ControlSizeTrigger MinWidth="240" TargetElement="{x:Bind SectionTypeContainer}" />
                    </VisualState.StateTriggers>
                </VisualState>
                <VisualState x:Name="CompactState">
                    <VisualState.StateTriggers>
                        <winui:ControlSizeTrigger MinWidth="0" TargetElement="{x:Bind SectionTypeContainer}" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="ServiceContainer.Spacing" Value="0" />
                        <Setter Target="ServiceBlock.Visibility" Value="Collapsed" />
                        <Setter Target="PresetContainer.Spacing" Value="0" />
                        <Setter Target="PresetBlock.Visibility" Value="Collapsed" />
                        <Setter Target="ServiceButton.(ToolTipService.ToolTip)" Value="{ext:Locale Name=ServiceAndAgent}" />
                        <Setter Target="PresetButton.(ToolTipService.ToolTip)" Value="{ext:Locale Name=PluginManagement}" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </StackPanel>
</local:ChatServicePageControlBase>
