<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:DodoSSH.Client.Shell.ViewModels"
             x:Class="DodoSSH.Client.App.Views.SignOutCard"
             x:DataType="vm:MainWindowViewModel">

  <!--
    The sign-out confirmation.

    One control used in two places — the preferences screen, where somebody is leaving a machine on
    purpose, and the unlock screen, where somebody has forgotten their passphrase and this is the only way
    forward. The two moments are different and the warning is not, which is why this is a shared control
    rather than two blocks that would drift apart.

    It is a bare StackPanel and not a card: the two hosts frame it differently, because a card that centres
    itself is right over a lock screen and wrong halfway down a scrolling column of preferences.

    Everything it says is something the state machine can actually answer. The count comes from the outbox,
    the shell count from the workspace, and the sentence about the identity provider is there because
    nothing here can end that session — see MainWindowViewModel.ConfirmSignOutAsync.
  -->

  <StackPanel Spacing="10">

    <TextBlock Classes="heading" FontSize="15" Text="Sign out of this machine?" />

    <TextBlock Text="{Binding SignOutWarning}" Foreground="{StaticResource WarnText}"
               TextWrapping="Wrap" />

    <TextBlock Classes="hint" FontSize="11" TextWrapping="Wrap"
               Text="This deletes this machine's copy of the keychain — the profile, the cached hosts, keys and passwords, and this machine's device key. Your keychain is on the server and is not touched: signing in again brings it all back." />

    <Border Background="{StaticResource Panel}" BorderBrush="{StaticResource Border}"
            BorderThickness="1" CornerRadius="4" Padding="10,8"
            IsVisible="{Binding HasLiveSessions, FallbackValue=False}">
      <StackPanel Spacing="4">
        <TextBlock Text="{Binding LiveSessionSummary}" Foreground="{StaticResource Info}"
                   FontWeight="SemiBold" TextWrapping="Wrap" />
        <TextBlock Classes="hint" FontSize="11" TextWrapping="Wrap"
                   Text="Signing out does not close them, exactly as locking does not. Quit DodoSSH to end them." />
      </StackPanel>
    </Border>

    <!--
      The other thing that outlives signing out, on the same reasoning and worth its own line because it is
      a connection this machine holds rather than a window it shows: a transfer in flight authenticated
      before any of this and keeps writing into its part file afterwards.
    -->
    <TextBlock Classes="hint" FontSize="11" TextWrapping="Wrap"
               IsVisible="{Binding Transfers.IsConnected, FallbackValue=False}"
               Text="A file-transfer session is open on this machine. Signing out does not close it either — it goes when DodoSSH does." />

    <StackPanel Orientation="Horizontal" Spacing="8">
      <Button Classes="danger" Content="SIGN OUT AND DELETE"
              Command="{Binding ConfirmSignOutCommand}" IsEnabled="{Binding !IsBusy}" />
      <Button Classes="ghost" Content="CANCEL" Command="{Binding CancelSignOutCommand}" />
    </StackPanel>

    <TextBlock Classes="hint" FontSize="10" TextWrapping="Wrap"
               Text="Your session at the identity provider is not ended by this — DodoSSH has no way to end it — so on a machine that is not yours, sign out there too." />

  </StackPanel>

</UserControl>
