<Page
    x:Class="Microsoft.PowerToys.Settings.UI.Views.CmdNotFoundPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
    xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
    xmlns:ui="using:CommunityToolkit.WinUI"
    AutomationProperties.LandmarkType="Main"
    mc:Ignorable="d">
    <Page.Resources>
        <tkconverters:BoolToVisibilityConverter
            x:Key="BoolToInvertedVisibilityConverter"
            FalseValue="Visible"
            TrueValue="Collapsed" />
        <tkconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Page.Resources>
    <controls:SettingsPageControl
        x:Uid="CmdNotFound"
        IsEnabled="{x:Bind ViewModel.IsArm64Arch, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
        ModuleImageSource="ms-appx:///Assets/Settings/Modules/CmdNotFound.png">
        <controls:SettingsPageControl.ModuleContent>
            <StackPanel ChildrenTransitions="{StaticResource SettingsCardsAnimations}" Orientation="Vertical">
                <InfoBar
                    x:Uid="GPO_SettingIsManaged"
                    IsClosable="False"
                    IsOpen="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
                    IsTabStop="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}"
                    Severity="Informational" />

                <tkcontrols:SettingsExpander
                    x:Uid="CmdNotFound_Enable"
                    HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/CommandNotFound.png}"
                    IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
                    IsExpanded="True">
                    <tkcontrols:SwitchPresenter TargetType="x:Boolean" Value="{x:Bind ViewModel.IsCommandNotFoundModuleInstalled, Mode=OneWay}">
                        <tkcontrols:Case Value="True">
                            <StackPanel Orientation="Horizontal" Spacing="8">
                                <TextBlock
                                    x:Uid="InstalledLabel"
                                    VerticalAlignment="Center"
                                    Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                <FontIcon
                                    Margin="0,0,4,0"
                                    VerticalAlignment="Center"
                                    AutomationProperties.AccessibilityView="Raw"
                                    Foreground="{ThemeResource SystemFillColorSuccessBrush}"
                                    Glyph="&#xEC61;" />
                                <HyperlinkButton x:Uid="CmdNotFound_UninstallButton" Command="{x:Bind ViewModel.UninstallModuleEventHandler}" />
                            </StackPanel>
                        </tkcontrols:Case>
                        <tkcontrols:Case Value="False">
                            <Button
                                x:Uid="CmdNotFound_InstallButton"
                                Command="{x:Bind ViewModel.InstallModuleEventHandler}"
                                Style="{StaticResource AccentButtonStyle}" />
                        </tkcontrols:Case>
                    </tkcontrols:SwitchPresenter>
                    <tkcontrols:SettingsExpander.ItemsHeader>
                        <StackPanel>
                            <InfoBar
                                x:Uid="CmdNotFound_RequirementsBar"
                                BorderThickness="0"
                                CornerRadius="0"
                                IsClosable="False"
                                IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsArm64Arch, Converter={StaticResource BoolNegationConverter}}">
                                <InfoBar.ActionButton>
                                    <HyperlinkButton x:Uid="CmdNotFound_CheckCompatibility" Command="{x:Bind ViewModel.CheckRequirementsEventHandler}">
                                        <ToolTipService.ToolTip>
                                            <TextBlock x:Uid="CmdNotFound_CheckCompatibilityTooltip" TextWrapping="Wrap" />
                                        </ToolTipService.ToolTip>
                                    </HyperlinkButton>
                                </InfoBar.ActionButton>
                            </InfoBar>
                            <InfoBar
                                x:Uid="CmdNotFound_Arm64ArchBar"
                                BorderThickness="0"
                                CornerRadius="0"
                                IsClosable="False"
                                IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsArm64Arch}" />
                        </StackPanel>
                    </tkcontrols:SettingsExpander.ItemsHeader>
                    <tkcontrols:SettingsExpander.Items>
                        <tkcontrols:SettingsCard x:Uid="CmdNotFound_PowerShellDetection" Visibility="{x:Bind ViewModel.IsArm64Arch, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}">
                            <tkcontrols:SwitchPresenter TargetType="x:Boolean" Value="{x:Bind ViewModel.IsPowerShell7Detected, Mode=OneWay}">
                                <tkcontrols:Case Value="True">
                                    <StackPanel Orientation="Horizontal" Spacing="8">
                                        <TextBlock
                                            x:Uid="DetectedLabel"
                                            VerticalAlignment="Center"
                                            Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                        <FontIcon
                                            AutomationProperties.AccessibilityView="Raw"
                                            Foreground="{ThemeResource SystemFillColorSuccessBrush}"
                                            Glyph="&#xEC61;" />
                                    </StackPanel>
                                </tkcontrols:Case>
                                <tkcontrols:Case Value="False">
                                    <StackPanel Orientation="Horizontal" Spacing="8">
                                        <TextBlock
                                            x:Uid="NotDetectedLabel"
                                            VerticalAlignment="Center"
                                            Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                        <FontIcon
                                            AutomationProperties.AccessibilityView="Raw"
                                            Foreground="{ThemeResource SystemFillColorCriticalBrush}"
                                            Glyph="&#xEB90;" />
                                        <Button x:Uid="CmdNotFound_InstallButton" Command="{x:Bind ViewModel.InstallPowerShell7EventHandler}" />
                                    </StackPanel>
                                </tkcontrols:Case>
                            </tkcontrols:SwitchPresenter>
                        </tkcontrols:SettingsCard>

                        <tkcontrols:SettingsCard x:Uid="CmdNotFound_WinGetClientDetection" Visibility="{x:Bind ViewModel.IsArm64Arch, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}">
                            <tkcontrols:SwitchPresenter TargetType="x:Boolean" Value="{x:Bind ViewModel.IsWinGetClientModuleDetected, Mode=OneWay}">
                                <tkcontrols:Case Value="True">
                                    <StackPanel Orientation="Horizontal" Spacing="8">
                                        <TextBlock
                                            x:Uid="DetectedLabel"
                                            VerticalAlignment="Center"
                                            Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                        <FontIcon
                                            AutomationProperties.AccessibilityView="Raw"
                                            Foreground="{ThemeResource SystemFillColorSuccessBrush}"
                                            Glyph="&#xEC61;" />
                                    </StackPanel>
                                </tkcontrols:Case>
                                <tkcontrols:Case Value="False">
                                    <StackPanel Orientation="Horizontal" Spacing="8">
                                        <TextBlock
                                            x:Uid="NotDetectedLabel"
                                            VerticalAlignment="Center"
                                            Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                        <FontIcon
                                            AutomationProperties.AccessibilityView="Raw"
                                            Foreground="{ThemeResource SystemFillColorCriticalBrush}"
                                            Glyph="&#xEB90;" />
                                        <Button x:Uid="CmdNotFound_InstallButton" Command="{x:Bind ViewModel.InstallWinGetClientModuleEventHandler}" />
                                    </StackPanel>
                                </tkcontrols:Case>
                            </tkcontrols:SwitchPresenter>
                        </tkcontrols:SettingsCard>
                    </tkcontrols:SettingsExpander.Items>
                </tkcontrols:SettingsExpander>
                <TextBlock
                    x:Uid="CmdNotFound_ModuleInstallationLogs"
                    Margin="0,12,0,4"
                    Style="{ThemeResource BodyStrongTextBlockStyle}" />
                <TextBox
                    Height="300"
                    FontFamily="Consolas"
                    IsEnabled="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
                    IsReadOnly="True"
                    Text="{x:Bind ViewModel.CommandOutputLog, Mode=OneWay}"
                    TextWrapping="Wrap" />
            </StackPanel>
        </controls:SettingsPageControl.ModuleContent>

        <controls:SettingsPageControl.PrimaryLinks>
            <controls:PageLink x:Uid="LearnMore_CmdNotFound" Link="https://aka.ms/PowerToysOverview_CmdNotFound" />
        </controls:SettingsPageControl.PrimaryLinks>
    </controls:SettingsPageControl>
</Page>
