<controls:PageBase
    x:Class="JumpPoint.Uwp.Hosted.ChatbotPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:JumpPoint.Uwp.Hosted"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:JumpPoint.Uwp.Controls"
    xmlns:winui="using:Microsoft.UI.Xaml.Controls"
    xmlns:converters="using:JumpPoint.Uwp.Converters"
    xmlns:services="using:JumpPoint.Platform.Services"
    xmlns:helpers="using:JumpPoint.Uwp.Helpers"
    xmlns:items="using:JumpPoint.Platform.Items"
    xmlns:extensions="using:JumpPoint.Platform.Extensions"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:actions="using:NittyGritty.Uwp.Interactivity.Actions"
    xmlns:platform="using:JumpPoint.Platform"
    mc:Ignorable="d"
    xmlns:ngext="using:NittyGritty.Uwp.Extensions"
    xmlns:gtext="using:Glif.Core.Text"
    xmlns:ngconv="using:NittyGritty.Uwp.Converters"
    ngext:ApplicationViewExtensions.Title="Chat"
    ngext:TitleBarExtensions.ButtonBackgroundColor="Transparent"
    ngext:TitleBarExtensions.ButtonInactiveBackgroundColor="Transparent"
    winui:BackdropMaterial.ApplyToRootOrPageBackground="True"
    d:DesignHeight="700"
    d:DesignWidth="500">

    <controls:PageBase.Resources>
        <XamlUICommand x:Key="ExecuteCommand"
                       Command="{x:Bind ViewModel.ExecuteCommand}"/>
        
        <ngconv:ValueWhenConverter x:Key="VisibleWhenOneConverter">
            <ngconv:ValueWhenConverter.When>
                <x:Int32>1</x:Int32>
            </ngconv:ValueWhenConverter.When>
            <ngconv:ValueWhenConverter.Value>
                <Visibility>Visible</Visibility>
            </ngconv:ValueWhenConverter.Value>
            <ngconv:ValueWhenConverter.Otherwise>
                <Visibility>Collapsed</Visibility>
            </ngconv:ValueWhenConverter.Otherwise>
        </ngconv:ValueWhenConverter>
        <converters:MessageTypeTemplateSelector x:Key="MessageTypeTemplateSelector">
            <converters:MessageTypeTemplateSelector.Simple>
                <DataTemplate x:DataType="services:SimpleChatMessage">
                    <Grid CornerRadius="4"
                          Background="{Binding ElementName=ChatMessageBackgroundConverter, Path=Background, Mode=OneWay}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}">
                        <Grid.Resources>
                            <converters:ChatMessageBackgroundConverter x:Name="ChatMessageBackgroundConverter"
                                                                       BotBackground="{ThemeResource SystemChromeMediumLowColor}"
                                                                       UserBackground="{ThemeResource SystemAccentBrush}"
                                                                       Source="{x:Bind Source, Mode=OneWay}"/>
                        </Grid.Resources>
                        <TextBlock Text="{x:Bind Message, Mode=OneWay}"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontWeight="{x:Bind gtext:FontWeightExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontWeight), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.Simple>
            <converters:MessageTypeTemplateSelector.Open>
                <DataTemplate x:DataType="services:OpenChatMessage">
                    <Grid CornerRadius="4"
                          Background="{ThemeResource SystemChromeMediumLowColor}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                          RowSpacing="4">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   FontSize="16"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <TextBlock Text="{x:Bind Uri.AbsoluteUri}" 
                                   TextWrapping="Wrap"
                                   Grid.Row="1"/>
                        <Button Grid.Row="2"
                                Margin="0,4,0,0"
                                HorizontalAlignment="Stretch"
                                Content="Open"
                                CommandParameter="{x:Bind Uri, Mode=OneWay}"
                                Command="{Binding Source={StaticResource Locator}, Path=CommandHelper.OpenUriCommand}"
                                Style="{StaticResource AccentButtonStyle}"/>
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.Open>
            <converters:MessageTypeTemplateSelector.ItemList>
                <DataTemplate x:DataType="services:ItemListChatMessage">
                    <Grid CornerRadius="4"
                          Background="{ThemeResource SystemChromeMediumLowColor}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                          RowSpacing="12">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   FontSize="18"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <winui:ItemsRepeater ItemsSource="{x:Bind Items}"
                                             Grid.Row="1">
                            <winui:ItemsRepeater.Layout>
                                <winui:StackLayout Spacing="8" />
                            </winui:ItemsRepeater.Layout>
                            <DataTemplate x:DataType="items:JumpPointItem">
                                <StackPanel Spacing="4">
                                    <Grid ColumnSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Image Source="{x:Bind converters:IconConverter.GetImageSource((items:JumpPointItem)), Mode=OneWay}"
                                               Width="36"
                                               Height="36" />
                                        <TextBlock Text="{x:Bind DisplayName, Mode=OneWay}"
                                                   FontSize="16"
                                                   FontWeight="SemiBold"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   TextWrapping="WrapWholeWords"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                    </Grid>
                                    <Grid ColumnSpacing="12">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="Type:" />
                                        <TextBlock Text="{x:Bind Type, Converter={StaticResource HumanizerConverter}, Mode=OneWay}"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center" />
                                        <TextBlock Text="Path:"
                                                   Grid.Row="1"/>
                                        <TextBlock Text="{x:Bind Path, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   TextWrapping="WrapWholeWords" />
                                    </Grid>
                                    <Button Content="Launch"
                                            CommandParameter="{x:Bind Mode=OneWay}"
                                            Command="{Binding Source={StaticResource Locator}, Path=CommandHelper.LaunchItemCommand}"
                                            Style="{StaticResource AccentButtonStyle}"
                                            HorizontalAlignment="Stretch"
                                            Margin="0,4,0,0"/>
                                    <MenuFlyoutSeparator Margin="0,4,0,0" />
                                </StackPanel>
                            </DataTemplate>
                        </winui:ItemsRepeater>
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.ItemList>
            <converters:MessageTypeTemplateSelector.ToolList>
                <DataTemplate x:DataType="services:ToolListChatMessage">
                    <Grid CornerRadius="4"
                          Background="{ThemeResource SystemChromeMediumLowColor}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                          RowSpacing="12">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   FontSize="18"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <winui:ItemsRepeater ItemsSource="{x:Bind Items}"
                                             Grid.Row="1">
                            <winui:ItemsRepeater.Layout>
                                <winui:StackLayout Spacing="8" />
                            </winui:ItemsRepeater.Layout>
                            <DataTemplate x:DataType="extensions:Tool">
                                <StackPanel Spacing="8">
                                    <Grid ColumnSpacing="8"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Image Source="{x:Bind converters:IconConverter.GetImageSource(x:Null, Logo, x:Null, 36, 36), Mode=OneWay}"
                                               Width="36"
                                               Height="36" />
                                        <TextBlock Text="{x:Bind Name, Mode=OneWay}"
                                                   FontWeight="SemiBold"
                                                   FontSize="16"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                        <TextBlock Text="{x:Bind Description, Mode=OneWay}"
                                                   FontSize="16"
                                                   Grid.ColumnSpan="2"
                                                   Grid.Row="1"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontWeight="{x:Bind gtext:FontWeightExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontWeight), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                    </Grid>
                                    <Grid ColumnSpacing="12"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="Package ID:"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind PackageId, Mode=OneWay}"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap"/>
                                        
                                        <TextBlock Text="Extension ID:"
                                                   Grid.Row="1"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind ExtensionId, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Package:"
                                                   Grid.Row="2"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Package, Mode=OneWay}"
                                                   Grid.Row="2"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Publisher:"
                                                   Grid.Row="3"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Publisher, Mode=OneWay}"
                                                   Grid.Row="3"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Version:"
                                                   Grid.Row="4"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Version, Mode=OneWay}"
                                                   Grid.Row="4"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Signature:"
                                                   Grid.Row="5"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Signature, Converter={StaticResource HumanizerConverter}, Mode=OneWay}"
                                                   Grid.Row="5"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Enabled:"
                                                   Grid.Row="6"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsEnabled.ToString(), Mode=OneWay}"
                                                   Grid.Row="6"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Available:"
                                                   Grid.Row="7"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsAvailable.ToString(), Mode=OneWay}"
                                                   Grid.Row="7"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Supported File Types:"
                                                   Grid.Row="8"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="Any"
                                                   Visibility="{x:Bind SupportsAnyFileType, Mode=OneWay, Converter={StaticResource VisibleWhenTrueConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="8"
                                                   TextWrapping="Wrap" />
                                        <TextBlock Text="{x:Bind x:String.Join(';', FileTypes), Mode=OneWay}"
                                                   Visibility="{x:Bind SupportsAnyFileType, Mode=OneWay, Converter={StaticResource VisibleWhenFalseConverter}}"
                                                   Grid.Row="8"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Supports Directories:"
                                                   Grid.Row="9"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind SupportsDirectories.ToString(), Mode=OneWay}"
                                                   Grid.Row="9"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Entry Point:"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
                                                   Grid.Row="10" />
                                        <TextBlock Text="{x:Bind Link, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource StringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="10"
                                                   TextWrapping="Wrap" />
                                        <TextBlock Text="{x:Bind Service, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource ReverseStringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="10"
                                                   TextWrapping="Wrap" />

                                        <MenuFlyoutSeparator Margin="0,8,0,0"
                                                             Grid.Row="11"
                                                             Grid.ColumnSpan="2"/>
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </winui:ItemsRepeater>
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.ToolList>
            <converters:MessageTypeTemplateSelector.AppLinkProviderList>
                <DataTemplate x:DataType="services:AppLinkProviderListChatMessage">
                    <Grid CornerRadius="4"
                          Background="{ThemeResource SystemChromeMediumLowColor}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                          RowSpacing="12">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   FontSize="18"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <winui:ItemsRepeater ItemsSource="{x:Bind Items}"
                                             Grid.Row="1">
                            <winui:ItemsRepeater.Layout>
                                <winui:StackLayout Spacing="8" />
                            </winui:ItemsRepeater.Layout>
                            <DataTemplate x:DataType="extensions:AppLinkProvider">
                                <StackPanel Spacing="8">
                                    <Grid ColumnSpacing="8"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Image Source="{x:Bind converters:IconConverter.GetImageSource(x:Null, Logo, x:Null, 36, 36), Mode=OneWay}"
                                               Width="36"
                                               Height="36" />
                                        <TextBlock Text="{x:Bind Name, Mode=OneWay}"
                                                   FontWeight="SemiBold"
                                                   FontSize="16"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                        <TextBlock Text="{x:Bind Description, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.ColumnSpan="2"
                                                   FontSize="16"
                                                   TextWrapping="WrapWholeWords"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontWeight="{x:Bind gtext:FontWeightExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontWeight), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                    </Grid>
                                    <Grid ColumnSpacing="12"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="Package ID:"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind PackageId, Mode=OneWay}"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap"/>

                                        <TextBlock Text="Extension ID:"
                                                   Grid.Row="1"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind ExtensionId, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Package:"
                                                   Grid.Row="2"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Package, Mode=OneWay}"
                                                   Grid.Row="2"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Publisher:"
                                                   Grid.Row="3"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Publisher, Mode=OneWay}"
                                                   Grid.Row="3"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Version:"
                                                   Grid.Row="4"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Version, Mode=OneWay}"
                                                   Grid.Row="4"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Signature:"
                                                   Grid.Row="5"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Signature, Converter={StaticResource HumanizerConverter}, Mode=OneWay}"
                                                   Grid.Row="5"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Enabled:"
                                                   Grid.Row="6"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsEnabled.ToString(), Mode=OneWay}"
                                                   Grid.Row="6"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Available:"
                                                   Grid.Row="7"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsAvailable.ToString(), Mode=OneWay}"
                                                   Grid.Row="7"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Entry Point:"
                                                   Grid.Row="8"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Link, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource StringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="8"
                                                   TextWrapping="Wrap" />
                                        <TextBlock Text="{x:Bind Service, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource ReverseStringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="8"
                                                   TextWrapping="Wrap" />

                                        <MenuFlyoutSeparator Grid.Row="9"
                                                             Grid.ColumnSpan="2"
                                                             Margin="0,8,0,0" />
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </winui:ItemsRepeater>
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.AppLinkProviderList>
            <converters:MessageTypeTemplateSelector.NewItemList>
                <DataTemplate x:DataType="services:NewItemListChatMessage">
                    <Grid CornerRadius="4"
                          Background="{ThemeResource SystemChromeMediumLowColor}"
                          Padding="16"
                          MaxWidth="480"
                          MinWidth="120"
                          HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                          Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                          RowSpacing="12">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   FontSize="18"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <winui:ItemsRepeater ItemsSource="{x:Bind Items}"
                                             Grid.Row="1">
                            <winui:ItemsRepeater.Layout>
                                <winui:StackLayout Spacing="8" />
                            </winui:ItemsRepeater.Layout>
                            <DataTemplate x:DataType="extensions:NewItem">
                                <StackPanel Spacing="8">
                                    <Grid ColumnSpacing="8"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Image Source="{x:Bind converters:IconConverter.GetImageSource(x:Null, Logo, x:Null, 36, 36), Mode=OneWay}"
                                               Width="36"
                                               Height="36" />
                                        <TextBlock Text="{x:Bind Name, Mode=OneWay}"
                                                   FontWeight="SemiBold"
                                                   FontSize="16"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                        <TextBlock Text="{x:Bind Description, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.ColumnSpan="2"
                                                   FontSize="16"
                                                   TextWrapping="WrapWholeWords"
                                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                   FontWeight="{x:Bind gtext:FontWeightExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontWeight), Mode=OneWay}"
                                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                    </Grid>
                                    <Grid ColumnSpacing="12"
                                          RowSpacing="4">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="Package ID:"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind PackageId, Mode=OneWay}"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Extension ID:"
                                                   Grid.Row="1"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind ExtensionId, Mode=OneWay}"
                                                   Grid.Row="1"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Package:"
                                                   Grid.Row="2"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Package, Mode=OneWay}"
                                                   Grid.Row="2"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Publisher:"
                                                   Grid.Row="3"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Publisher, Mode=OneWay}"
                                                   Grid.Row="3"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Version:"
                                                   Grid.Row="4"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Version, Mode=OneWay}"
                                                   Grid.Row="4"
                                                   Grid.Column="1"
                                                   TextWrapping="Wrap" />

                                        <TextBlock Text="Signature:"
                                                   Grid.Row="5"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Signature, Converter={StaticResource HumanizerConverter}, Mode=OneWay}"
                                                   Grid.Row="5"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Enabled:"
                                                   Grid.Row="6"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsEnabled.ToString(), Mode=OneWay}"
                                                   Grid.Row="6"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Is Available:"
                                                   Grid.Row="7"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind IsAvailable.ToString(), Mode=OneWay}"
                                                   Grid.Row="7"
                                                   Grid.Column="1" />

                                        <TextBlock Text="Entry Point:"
                                                   Grid.Row="8"
                                                   Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
                                        <TextBlock Text="{x:Bind Link, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource StringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="8"
                                                   TextWrapping="Wrap" />
                                        <TextBlock Text="{x:Bind Service, Mode=OneWay}"
                                                   Visibility="{x:Bind Link, Mode=OneWay, Converter={StaticResource ReverseStringVisibilityConverter}}"
                                                   Grid.Column="1"
                                                   Grid.Row="8"
                                                   TextWrapping="Wrap" />

                                        <MenuFlyoutSeparator Grid.Row="9"
                                                             Grid.ColumnSpan="2"
                                                             Margin="0,8,0,0" />
                                    </Grid>
                                </StackPanel>
                            </DataTemplate>
                        </winui:ItemsRepeater>
                    </Grid>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.NewItemList>
            <converters:MessageTypeTemplateSelector.CommandList>
                <DataTemplate x:DataType="services:CommandListChatMessage">
                    <StackPanel CornerRadius="4"
                                Background="{ThemeResource SystemChromeMediumLowColor}"
                                Padding="16"
                                MaxWidth="480"
                                MinWidth="120"
                                HorizontalAlignment="{x:Bind converters:ChatMessageConverter.GetHorizontalAlignment(Source)}"
                                Margin="{x:Bind converters:ChatMessageConverter.GetMargin(Source)}"
                                Spacing="4">
                        <TextBlock Text="{x:Bind Title, Mode=OneWay}"
                                   TextWrapping="WrapWholeWords"
                                   FontSize="18"
                                   FontWeight="SemiBold"
                                   FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                   FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                   FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                        <winui:ItemsRepeater ItemsSource="{x:Bind Items}">
                            <DataTemplate x:DataType="services:CommandInfo">
                                <Grid RowSpacing="4">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <TextBlock Text="{x:Bind CommandFormat}"
                                               FontSize="16"
                                               FontWeight="SemiBold"
                                               FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                               FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                               FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                    <TextBlock Text="{x:Bind Description}"
                                               Grid.Row="1"
                                               TextWrapping="WrapWholeWords"/>
                                    <Button Content="Run"
                                            CommandParameter="{x:Bind DefaultCommand}"
                                            Command="{StaticResource ExecuteCommand}"
                                            Width="120"
                                            Margin="0,4,0,0"
                                            Grid.Row="2"
                                            Visibility="{x:Bind Samples.Count, Converter={StaticResource VisibleWhenOneConverter}}"
                                            x:Name="runDefault"/>
                                    <winui:DropDownButton x:Name="runMultiple"
                                                          Content="Run"
                                                          Width="120"
                                                          Margin="0,4,0,0"
                                                          Grid.Row="2"
                                                          Visibility="{Binding ElementName=runDefault, Path=Visibility, Converter={StaticResource ReverseVisibilityConverter}}">
                                        <winui:DropDownButton.Flyout>
                                            <Flyout Placement="Bottom">
                                                <Flyout.FlyoutPresenterStyle>
                                                    <Style TargetType="FlyoutPresenter">
                                                        <Setter Property="MaxHeight"
                                                                Value="504" />
                                                        <Setter Property="MinWidth"
                                                                Value="180" />
                                                        <Setter Property="Padding"
                                                                Value="0,4" />
                                                    </Style>
                                                </Flyout.FlyoutPresenterStyle>
                                                <ListView ItemsSource="{x:Bind Samples}"
                                                          IsItemClickEnabled="True"
                                                          SelectionMode="None">
                                                    <ListView.ItemTemplate>
                                                        <DataTemplate x:DataType="x:String">
                                                            <TextBlock Text="{x:Bind }"
                                                                       FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                                                                       FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                                                                       FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
                                                        </DataTemplate>
                                                    </ListView.ItemTemplate>
                                                    <i:Interaction.Behaviors>
                                                        <core:EventTriggerBehavior EventName="ItemClick">
                                                            <actions:CloseFlyoutAction />
                                                            <core:InvokeCommandAction InputConverter="{StaticResource ItemClickEventArgsConverter}"
                                                                                      Command="{StaticResource ExecuteCommand}" />
                                                        </core:EventTriggerBehavior>
                                                    </i:Interaction.Behaviors>
                                                </ListView>
                                            </Flyout>
                                        </winui:DropDownButton.Flyout>
                                    </winui:DropDownButton>
                                    <MenuFlyoutSeparator Margin="0,4,0,0"
                                                         Grid.Row="3"/>
                                </Grid>
                            </DataTemplate>
                        </winui:ItemsRepeater>
                    </StackPanel>
                </DataTemplate>
            </converters:MessageTypeTemplateSelector.CommandList>
        </converters:MessageTypeTemplateSelector>
    </controls:PageBase.Resources>

    <Grid Padding="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid x:Name="AppTitleBar"
              Margin="-16,-16,-16,0"
              Background="{StaticResource TitleBarBackground}"
              Height="32">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="LeftPaddingColumn"
                                  Width="0" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition x:Name="RightPaddingColumn"
                                  Width="0" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="1"
                  Background="Transparent"
                  x:Name="AppDrag"
                  Padding="12,0"
                  ColumnSpacing="8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Viewbox Width="20"
                         Height="20">
                    <ContentControl Content="{x:Bind converters:IconConverter.GetPathTypeIconElement(platform:AppPath.Chat, x:Null)}" />
                </Viewbox>
                <TextBlock Text="Chat"
                           x:Name="txtTitle"
                           VerticalAlignment="Center"
                           FontWeight="SemiBold"
                           Foreground="White"
                           Grid.Column="1"
                           FontFamily="{x:Bind helpers:ServiceLocator.AppSettings.Font, Mode=OneWay}"
                           FontStyle="{x:Bind gtext:FontStyleExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStyle), Mode=OneWay}"
                           FontStretch="{x:Bind gtext:FontStretchExtensions.ToPlatform(helpers:ServiceLocator.AppSettings.FontStretch), Mode=OneWay}" />
            </Grid>
        </Grid>
        <TextBlock Text="Chat"
                   Grid.Row="1"
                   Margin="0,8"
                   Style="{StaticResource SubtitleTextBlockStyle}"/>
        <ListView Grid.Row="2"
                  Margin="-12,0,-16,8"
                  SelectionMode="None"
                  ItemsSource="{x:Bind ViewModel.Messages}"
                  ItemTemplateSelector="{StaticResource MessageTypeTemplateSelector}">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment"
                            Value="Stretch" />
                    <Setter Property="VerticalContentAlignment"
                            Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <ItemsStackPanel VerticalAlignment="Bottom"
                                     ItemsUpdatingScrollMode="KeepLastItemInView" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>
        
        <AutoSuggestBox Grid.Row="3"
                        PlaceholderText="Type a command or help"
                        Text="{x:Bind ViewModel.TextMessage, Mode=TwoWay}">
            <AutoSuggestBox.QueryIcon>
                <IconSourceElement IconSource="{StaticResource SendIcon}" />
            </AutoSuggestBox.QueryIcon>
            <i:Interaction.Behaviors>
                <core:EventTriggerBehavior EventName="Loaded">
                    <actions:FocusAction />
                </core:EventTriggerBehavior>
                <core:EventTriggerBehavior EventName="QuerySubmitted">
                    <core:InvokeCommandAction Command="{x:Bind ViewModel.SendCommand}" />
                </core:EventTriggerBehavior>
            </i:Interaction.Behaviors>
        </AutoSuggestBox>
    </Grid>
</controls:PageBase>
