<?xml version="1.0" encoding="utf-8" ?>
<controls:ChatServiceConfigControlBase
    x:Class="RodelAgent.UI.Controls.Settings.OpenAIChatConfigSettingSection"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="using:Richasy.WinUI.Share.Base"
    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.Settings"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:startup="using:RodelAgent.UI.Controls.Startup"
    mc:Ignorable="d">

    <base:SettingsExpander>
        <base:SettingsExpander.Header>
            <controls:ProviderLogo x:Name="Logo" Height="22" />
        </base:SettingsExpander.Header>
        <base:SettingsExpander.Items>
            <base:SettingsCard x:Name="KeyCard" Header="{ext:Locale Name=AccessKey}">
                <PasswordBox
                    x:Name="KeyBox"
                    Width="200"
                    AutomationProperties.Name="{ext:Locale Name=AccessKey}"
                    Loaded="OnKeyBoxLoaded"
                    PasswordChanged="OnKeyBoxPasswordChanged" />
            </base:SettingsCard>
            <base:SettingsCard
                x:Name="EndpointCard"
                Description="{ext:Locale Name=EndpointDescription}"
                Header="{ext:Locale Name=Endpoint}">
                <TextBox
                    x:Name="EndpointBox"
                    Width="200"
                    AutomationProperties.Name="{ext:Locale Name=Endpoint}"
                    PlaceholderText="{ext:Locale Name=EndpointPlaceholder}"
                    TextChanged="OnEndpointBoxTextChanged" />
            </base:SettingsCard>
            <base:SettingsCard
                x:Name="OrganizationCard"
                Description="{ext:Locale Name=OptionalPlaceholder}"
                Header="{ext:Locale Name=Organization_Optional}">
                <TextBox
                    x:Name="OrganizationBox"
                    Width="200"
                    AutomationProperties.Name="{ext:Locale Name=Organization_Optional}"
                    PlaceholderText="{ext:Locale Name=OptionalPlaceholder}"
                    TextChanged="OnOrganizationBoxTextChanged" />
            </base:SettingsCard>
            <base:SettingsCard
                x:Name="PredefinedCard"
                Header="{ext:Locale Name=PredefinedModels}"
                Visibility="{x:Bind ViewModel.IsServerModelVisible, Mode=OneWay}">
                <HyperlinkButton Click="OnPredefinedModelsButtonClick" Content="{ext:Locale Name=SeeAllModels}">
                    <FlyoutBase.AttachedFlyout>
                        <Flyout Placement="Bottom" ShouldConstrainToRootBounds="False">
                            <startup:PredefinedChatModelSection ViewModel="{x:Bind ViewModel}" />
                        </Flyout>
                    </FlyoutBase.AttachedFlyout>
                </HyperlinkButton>
            </base:SettingsCard>
        </base:SettingsExpander.Items>
        <base:SettingsExpander.ItemsFooter>
            <Grid
                Padding="58,8,44,12"
                Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
                BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
                BorderThickness="0,1,0,0">
                <startup:CustomChatModelSection ViewModel="{x:Bind ViewModel}" />
            </Grid>
        </base:SettingsExpander.ItemsFooter>
        <ic:SymbolIcon
            FontSize="14"
            Foreground="{ThemeResource SystemFillColorSuccessBrush}"
            IconVariant="Filled"
            Symbol="CheckmarkCircle"
            Visibility="{x:Bind ViewModel.IsCompleted, Mode=OneWay}" />
    </base:SettingsExpander>
</controls:ChatServiceConfigControlBase>
